From 9ddb422b87e0a85e3074aecabd681490ca34231c Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Tue, 18 Mar 2008 16:57:33 +0000 Subject: [PATCH] bug #1906980 [Export] Import of VIEWs fails if temp table exists --- ChangeLog | 2 ++ libraries/export/sql.php | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 91b4d031f..807d0b61c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -58,6 +58,8 @@ danbarry + [lang] Russian update, thanks to Victor Volkov - bug #1910485 [core] Unsetting the whitelist during the loop, thanks to Jeroen Vrijkorte - jv_map +- bug #1906980 [Export] Import of VIEWs fails if temp table exists, + thanks to Falk Nisius - klaf 2.11.5.0 (2008-03-01) - bug #1862661 [GUI] Warn about rename deleting database diff --git a/libraries/export/sql.php b/libraries/export/sql.php index ed3ffe640..5706979c9 100644 --- a/libraries/export/sql.php +++ b/libraries/export/sql.php @@ -389,7 +389,13 @@ function PMA_exportDBFooter($db) * @access public */ function PMA_getTableDefStandIn($db, $view, $crlf) { - $create_query = 'CREATE TABLE '; + $create_query = ''; + if (! empty($GLOBALS['sql_drop_table'])) { + $create_query .= 'DROP VIEW IF EXISTS ' . PMA_backquote($view) . ';' . $crlf; + } + + $create_query .= 'CREATE TABLE '; + if (isset($GLOBALS['sql_if_not_exists']) && $GLOBALS['sql_if_not_exists']) { $create_query .= 'IF NOT EXISTS '; } @@ -464,14 +470,9 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $show_dates = false) $schema_create .= $new_crlf; - if (!empty($sql_drop_table)) { - if (PMA_Table::isView($db,$table)) { - $drop_clause = 'DROP VIEW'; - } else { - $drop_clause = 'DROP TABLE'; - } - $schema_create .= $drop_clause . ' IF EXISTS ' . PMA_backquote($table, $sql_backquotes) . ';' . $crlf; - unset($drop_clause); + // no need to generate a DROP VIEW here, it was done earlier + if (! empty($sql_drop_table) && ! PMA_Table::isView($db,$table)) { + $schema_create .= 'DROP TABLE IF EXISTS ' . PMA_backquote($table, $sql_backquotes) . ';' . $crlf; } // Steve Alberty's patch for complete table dump,