sometimes we cannot rely on the cached information about a table

This commit is contained in:
Marc Delisle
2008-05-31 13:34:16 +00:00
parent 8e570751c5
commit 80b7f58ca2
2 changed files with 8 additions and 4 deletions

View File

@@ -255,9 +255,9 @@ class PMA_Table
. ' (' . PMA_Table::countRecords($db, $table, true) . ')';
}
static public function sGetStatusInfo($db, $table, $info = null)
static public function sGetStatusInfo($db, $table, $info = null, $force_read = false)
{
if (! isset(PMA_Table::$cache[$db][$table])) {
if (! isset(PMA_Table::$cache[$db][$table]) || $force_read) {
PMA_Table::$cache[$db][$table] = PMA_DBI_fetch_single_row('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . $table . '\'');
}
@@ -265,7 +265,7 @@ class PMA_Table
return PMA_Table::$cache[$db][$table];
}
if (! isset(PMA_Table::$cache[$db][$table][$info])) {
if (! isset(PMA_Table::$cache[$db][$table][$info]) || $force_read) {
PMA_Table::$cache[$db][$table] = PMA_DBI_fetch_single_row('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . $table . '\'');
}
return PMA_Table::$cache[$db][$table][$info];

View File

@@ -36,7 +36,11 @@ global $showtable, $tbl_is_view, $tbl_type, $show_comment, $tbl_collation,
// otherwise error #1046, no database selected
PMA_DBI_select_db($GLOBALS['db']);
$showtable = PMA_Table::sGetStatusInfo($GLOBALS['db'], $GLOBALS['table']);
// PMA_Table::sGetStatusInfo() does caching by default, but here
// we force reading of the current table status
// if $reread_info is true (for example, coming from tbl_operations.php
// and we just changed the table's storage engine)
$showtable = PMA_Table::sGetStatusInfo($GLOBALS['db'], $GLOBALS['table'], null, (isset($reread_info) && $reread_info ? true : false));
// need this test because when we are creating a table, we get 0 rows
// from the SHOW TABLE query