From 32bb3ab27328639b9eec5c68cd134f2731fe3ad6 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Fri, 21 Mar 2008 13:38:23 +0000 Subject: [PATCH] support ROW_FORMAT and PAGE_CHECKSUM table option; verify warnings coming from ALTER TABLE --- ChangeLog | 3 ++- libraries/common.lib.php | 23 +++++++++++++++++++ libraries/sqlparser.data.php | 3 ++- libraries/tbl_info.inc.php | 1 + tbl_operations.php | 43 ++++++++++++++++++++++++++++++++++-- 5 files changed, 69 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 807d0b61c..1472deffa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -47,7 +47,8 @@ danbarry * minimal support on db structure page * export + [pdf] Merged tcpdf 2.2.002 (PHP5 version), thanks to Nicola Asuni -+ [engines] Maria (work in progress) ++ [engines] Maria support ++ [engines] MyISAM and InnoDB: support ROW_FORMAT table option 2.11.6.0 (not yet released) - bug #1903724 [interface] Displaying of very large queries in error message diff --git a/libraries/common.lib.php b/libraries/common.lib.php index ec8653f17..163b8b2c9 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -2328,6 +2328,29 @@ function PMA_generate_html_radio($html_field_name, $choices, $checked_choice = ' } } +/** + * Generates and echoes an HTML dropdown + * + * @uses htmlspecialchars() + * @param string $select_name + * @param array $choices the choices values + * @param string $active_choice the choice to select by default + * @todo support titles + */ +function PMA_generate_html_dropdown($select_name, $choices, $active_choice) +{ + $result = '' . "\n"; + echo $result; +} + /** * Generates a slider effect (Mootools) * diff --git a/libraries/sqlparser.data.php b/libraries/sqlparser.data.php index d8e92c028..dc1513485 100644 --- a/libraries/sqlparser.data.php +++ b/libraries/sqlparser.data.php @@ -572,6 +572,7 @@ $PMA_SQPdata_reserved_word = array ( 'OUTER', 'OUTFILE', 'PACK_KEYS', + 'PAGE', // 5.1-maria ? 'PARTIAL', 'PARTITION', // 5.1 'PARTITIONS', // 5.1 @@ -685,7 +686,7 @@ $PMA_SQPdata_reserved_word = array ( * * @global integer MySQL reserved words count */ -$PMA_SQPdata_reserved_word_cnt = 283; +$PMA_SQPdata_reserved_word_cnt = 284; /** * The previous array must be sorted so that the binary search work. * Sometimes a word is not added in the correct order, so diff --git a/libraries/tbl_info.inc.php b/libraries/tbl_info.inc.php index b2f329c70..73f076c62 100644 --- a/libraries/tbl_info.inc.php +++ b/libraries/tbl_info.inc.php @@ -80,6 +80,7 @@ if ($table_info_result && PMA_DBI_num_rows($table_info_result) > 0) { $showtable['Name'], true, true); } $table_info_num_rows = isset($showtable['Rows']) ? $showtable['Rows'] : 0; + $row_format = isset($showtable['Row_format']) ? $showtable['Row_format'] : ''; $auto_increment = isset($showtable['Auto_increment']) ? $showtable['Auto_increment'] : ''; diff --git a/tbl_operations.php b/tbl_operations.php index c11490186..dc63e23f9 100644 --- a/tbl_operations.php +++ b/tbl_operations.php @@ -59,6 +59,7 @@ if ($is_maria) { // ($transactional may have been set by libraries/tbl_info.inc.php, // from the $create_options) $transactional = (isset($transactional) && $transactional == '0') ? '0' : '1'; + $page_checksum = (isset($page_checksum)) ? $page_checksum : ''; } $reread_info = false; @@ -69,6 +70,8 @@ $table_alters = array(); */ if (isset($_REQUEST['submitoptions'])) { $_message = ''; + $warning_messages = array(); + if (isset($_REQUEST['new_name'])) { if ($pma_table->rename($_REQUEST['new_name'])) { $_message .= $pma_table->getLastMessage(); @@ -136,12 +139,22 @@ if (isset($_REQUEST['submitoptions'])) { $table_alters[] = 'auto_increment = ' . PMA_sqlAddslashes($_REQUEST['new_auto_increment']); } + if (($is_myisam_or_maria || $is_innodb) + && ! empty($_REQUEST['new_row_format']) + && (! isset($row_format) || $_REQUEST['new_row_format'] !== $row_format)) { + $table_alters[] = 'ROW_FORMAT = ' . PMA_sqlAddslashes($_REQUEST['new_row_format']); + } + if (count($table_alters) > 0) { $sql_query = 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']); $sql_query .= "\r\n" . implode("\r\n", $table_alters); $result .= PMA_DBI_query($sql_query) ? true : false; $reread_info = true; unset($table_alters); + foreach (PMA_DBI_get_warnings() as $warning) { + $warning_messages[] = $warning['Level'] . ': #' . $warning['Code'] + . ' ' . $warning['Message']; + } } } /** @@ -179,10 +192,17 @@ require_once './libraries/tbl_links.inc.php'; if (isset($result)) { if (empty($_message)) { $_message = $result ? $strSuccess : $strError; + // $result should exist, regardless of $_message + $_type = $result ? 'success' : 'error'; + } + if (! empty($warning_messages)) { + $_message = new PMA_Message; + $_message->addMessages($warning_messages); + $_message->isWarning(true); + unset($warning_messages); } - // $result should exist, regardless of $_message - $_type = $result ? 'success' : 'error'; PMA_showMessage($_message, $sql_query, $_type); + unset($_message, $_type); } $url_params['goto'] = 'tbl_operations.php'; @@ -400,6 +420,25 @@ if (isset($auto_increment) && strlen($auto_increment) > 0 array('FIXED','DYNAMIC','PAGE'), + 'MYISAM' => array('FIXED','DYNAMIC'), + 'INNODB' => array('COMPACT','REDUNDANT') +); +// for MYISAM there is also COMPRESSED but it can be set only by the +// myisampack utility, so don't offer here the choice because if we +// try it inside an ALTER TABLE, MySQL (at least in 5.1.23-maria) +// does not return a warning +// (if the table was compressed, it can be seen on the Structure page) + +$current_row_format = strtoupper($showtable['Row_format']); +echo ''; +echo ''; +PMA_generate_html_dropdown('new_row_format', $possible_row_formats[$tbl_type], $current_row_format); +unset($possible_row_formats, $current_row_format); +echo ''; +echo ''; ?>