diff --git a/ChangeLog b/ChangeLog index 9cda086be..933c452d2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17,6 +17,7 @@ $HeadURL: https://phpmyadmin.svn.sourceforge.net/svnroot/phpmyadmin/trunk/phpMyA - bug [views] VIEW name created via the GUI was not protected with backquotes - bug #1989813 [interface] Deleting multiple views (space in name) - bug #1992628 [parser] SQL parser removes essential space +- bug #1989281 [export] Export fails if one table is marked as crashed 2.11.7.0 (2008-06-23) - bug #1908719 [interface] New field cannot be auto-increment and primary key diff --git a/libraries/export/sql.php b/libraries/export/sql.php index e78ac948a..a6420852e 100644 --- a/libraries/export/sql.php +++ b/libraries/export/sql.php @@ -493,7 +493,14 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $show_dates = false) // Note: SHOW CREATE TABLE, at least in MySQL 5.1.23, does not // produce a displayable result for the default value of a BIT // field, nor does the mysqldump command. See MySQL bug 35796 - $result = PMA_DBI_query('SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table)); + $result = PMA_DBI_try_query('SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table)); + + // an error can happen, for example the table is crashed + $tmp_error = PMA_DBI_getError(); + if ($tmp_error) { + return PMA_exportComment($GLOBALS['strInUse'] . '(' . $tmp_error . ')'); + } + if ($result != FALSE && ($row = PMA_DBI_fetch_row($result))) { $create_query = $row[1]; unset($row); @@ -593,7 +600,7 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $show_dates = false) $schema_create .= $auto_increment; PMA_DBI_free_result($result); - return $schema_create; + return $schema_create . ';' . $crlf; } // end of the 'PMA_getTableDef()' function @@ -717,7 +724,7 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $relation = FALSE, case 'create_table': $dump .= PMA_exportComment($GLOBALS['strTableStructure'] . ' ' . $formatted_table_name) . PMA_exportComment(); - $dump .= PMA_getTableDef($db, $table, $crlf, $error_url, $dates) . ';' . $crlf; + $dump .= PMA_getTableDef($db, $table, $crlf, $error_url, $dates); $triggers = PMA_DBI_get_triggers($db, $table); if ($triggers) { $dump .= $crlf @@ -740,7 +747,7 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $relation = FALSE, if ($export_type != 'table') { $dump .= 'DROP TABLE IF EXISTS ' . PMA_backquote($table) . ';' . $crlf; } - $dump .= PMA_getTableDef($db, $table, $crlf, $error_url, $dates) . ';' . $crlf; + $dump .= PMA_getTableDef($db, $table, $crlf, $error_url, $dates); break; case 'stand_in': $dump .= PMA_exportComment($GLOBALS['strStandInStructureForView'] . ' ' . $formatted_table_name) @@ -824,7 +831,12 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) // are used, we did not get the true column name in case of aliases) $analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($sql_query)); - $result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED); + $result = PMA_DBI_try_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED); + // a possible error: the table has crashed + $tmp_error = PMA_DBI_getError(); + if ($tmp_error) { + return PMA_exportOutputHandler(PMA_exportComment($GLOBALS['strInUse'] . ' (' . $tmp_error . ')')); + } if ($result != FALSE) { $fields_cnt = PMA_DBI_num_fields($result);