diff --git a/ChangeLog b/ChangeLog index 77a80a9101..021baf3189 100644 --- a/ChangeLog +++ b/ChangeLog @@ -22,6 +22,7 @@ phpMyAdmin - ChangeLog 4.2.6.0 (not yet released) - bug #4471 Undefined index warning with referenced column. +- bug #4027 $cfg['MaxExactCount'] is ignored when BROWSING is back 4.2.5.0 (2014-06-26) - bug #4467 shell_exec() has been disabled for security reasons diff --git a/doc/config.rst b/doc/config.rst index 64f16ce22d..6c2a75d213 100644 --- a/doc/config.rst +++ b/doc/config.rst @@ -2556,7 +2556,7 @@ Various display setting .. config:option:: $cfg['MaxExactCount'] :type: integer - :default: 0 + :default: 500000 For InnoDB tables, determines for how large tables phpMyAdmin should get the exact row count using ``SELECT COUNT``. If the approximate row diff --git a/libraries/config.default.php b/libraries/config.default.php index 19c20d74ae..19ce6b4107 100644 --- a/libraries/config.default.php +++ b/libraries/config.default.php @@ -2540,7 +2540,7 @@ $cfg['BrowseMIME'] = true; * * @global integer $cfg['MaxExactCount'] */ -$cfg['MaxExactCount'] = 0; +$cfg['MaxExactCount'] = 500000; /** * Zero means that no row count is done for views; see the doc diff --git a/libraries/sql.lib.php b/libraries/sql.lib.php index 0ca977cab7..7c2fd25407 100644 --- a/libraries/sql.lib.php +++ b/libraries/sql.lib.php @@ -1424,11 +1424,30 @@ function PMA_countQueryResults( // However, do not count again if we did it previously // due to $find_real_end == true if ($justBrowsing) { + // Get row count (is approximate for InnoDB) $unlim_num_rows = PMA_Table::countRecords( $db, $table, - true + false ); + /** + * @todo Can we know at this point that this is InnoDB, + * (in this case there would be no need for getting + * an exact count)? + */ + if ($unlim_num_rows < $GLOBALS['cfg']['MaxExactCount']) { + // Get the exact count if approximate count + // is less than MaxExactCount + /** + * @todo In countRecords(), MaxExactCount is also verified, + * so can we avoid checking it twice? + */ + $unlim_num_rows = PMA_Table::countRecords( + $db, + $table, + true + ); + } } else { // add select expression after the SQL_CALC_FOUND_ROWS