From 1f7c41936aaf1b8e7d1e241d446bcdcd027d82d4 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 475f3844e..5772d5014 100644 --- a/ChangeLog +++ b/ChangeLog @@ -14,6 +14,8 @@ $HeadURL: https://phpmyadmin.svn.sourceforge.net/svnroot/phpmyadmin/trunk/phpMyA + [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 643e35ae9..f4564dff6 100644 --- a/libraries/export/sql.php +++ b/libraries/export/sql.php @@ -381,7 +381,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 '; } @@ -456,14 +462,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,