From c486b807f5270ea0b3a2dc85356c3c7d7eac26f7 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Wed, 29 Jun 2005 11:17:17 +0000 Subject: [PATCH] bug 1228862, creating a table under MySQL 5.x with wrong table type --- ChangeLog | 4 +++ tbl_properties_table_info.php | 57 ++++++++++++++++++++--------------- 2 files changed, 36 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index 437718a56..7fa500ea8 100755 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,10 @@ phpMyAdmin - Changelog $Id$ $Source$ +2005-06-29 Marc Delisle + * tbl_properties_table_info.php: bug #1228862, creating a table under + MySQL 5.x with wrong table type + 2005-06-28 Marc Delisle * tbl_properties_operations.php: bug #1225635, cannot change table's collation under MySQL 5.0.4 diff --git a/tbl_properties_table_info.php b/tbl_properties_table_info.php index e4a56b118..1c9d72f84 100644 --- a/tbl_properties_table_info.php +++ b/tbl_properties_table_info.php @@ -28,31 +28,38 @@ PMA_DBI_select_db($db); // The 'show table' statement works correct since 3.23.03 $table_info_result = PMA_DBI_query('SHOW TABLE STATUS LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\';'); -$showtable = PMA_DBI_fetch_assoc($table_info_result); -if (!isset($showtable['Type']) && isset($showtable['Engine'])) { - $showtable['Type'] =& $showtable['Engine']; -} -if (PMA_MYSQL_INT_VERSION >= 50000 && !isset($showtable['Type']) && isset($showtable['Comment']) && $showtable['Comment'] == 'view') { - $tbl_is_view = TRUE; - $tbl_type = $strView; - $show_comment = NULL; -} else { - $tbl_is_view = FALSE; - $tbl_type = isset($showtable['Type']) ? strtoupper($showtable['Type']) : ''; - $show_comment = (isset($showtable['Comment']) ? $showtable['Comment'] : ''); -} -$tbl_collation = empty($showtable['Collation']) ? '' : $showtable['Collation']; -$table_info_num_rows = (isset($showtable['Rows']) ? $showtable['Rows'] : 0); -$auto_increment = (isset($showtable['Auto_increment']) ? $showtable['Auto_increment'] : ''); -$tmp = isset($showtable['Create_options']) ? explode(' ', $showtable['Create_options']) : array(); -$tmp_cnt = count($tmp); -for ($i = 0; $i < $tmp_cnt; $i++) { - $tmp1 = explode('=', $tmp[$i]); - if (isset($tmp1[1])) { - $$tmp1[0] = $tmp1[1]; +// need this test because when we are creating a table, we get 0 rows +// from the SHOW TABLE query +// and we don't want to mess up the $tbl_type coming from the form + +if ($table_info_result && PMA_DBI_num_rows($table_info_result) > 0) { + $showtable = PMA_DBI_fetch_assoc($table_info_result); + if (!isset($showtable['Type']) && isset($showtable['Engine'])) { + $showtable['Type'] =& $showtable['Engine']; } -} // end for -PMA_DBI_free_result($table_info_result); -unset($tmp1, $tmp, $table_info_result); + if (PMA_MYSQL_INT_VERSION >= 50000 && !isset($showtable['Type']) && isset($showtable['Comment']) && $showtable['Comment'] == 'view') { + $tbl_is_view = TRUE; + $tbl_type = $strView; + $show_comment = NULL; + } else { + $tbl_is_view = FALSE; + $tbl_type = isset($showtable['Type']) ? strtoupper($showtable['Type']) : ''; + $show_comment = (isset($showtable['Comment']) ? $showtable['Comment'] : ''); + } + $tbl_collation = empty($showtable['Collation']) ? '' : $showtable['Collation']; + $table_info_num_rows = (isset($showtable['Rows']) ? $showtable['Rows'] : 0); + $auto_increment = (isset($showtable['Auto_increment']) ? $showtable['Auto_increment'] : ''); + + $tmp = isset($showtable['Create_options']) ? explode(' ', $showtable['Create_options']) : array(); + $tmp_cnt = count($tmp); + for ($i = 0; $i < $tmp_cnt; $i++) { + $tmp1 = explode('=', $tmp[$i]); + if (isset($tmp1[1])) { + $$tmp1[0] = $tmp1[1]; + } + } // end for + PMA_DBI_free_result($table_info_result); + unset($tmp1, $tmp, $table_info_result); +} // end if ?>