The branch, QA_3_3 has been updated via 22fa5adee3cece9229f457d724d516eb96975186 (commit) from c0d1c7a2ae0d3f70bacac2d5abcb8bdc41590248 (commit)
- Log ----------------------------------------------------------------- -----------------------------------------------------------------------
Summary of changes: ChangeLog | 1 + libraries/import.lib.php | 27 +++++++++++++++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog index 699aaba..a7c8d83 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,7 @@ $HeadURL: https://phpmyadmin.svn.sourceforge.net/svnroot/phpmyadmin/trunk/phpMyA - [core] Update library PHPExcel to version 1.7.4 - bug #3062455 [core] copy procedures and routines before tables - bug #3062455 [export] with SQL, export procedures and routines before tables +- bug #3056023 [import] USE query not working
3.3.7.0 (2010-09-07) - patch #3050492 [PDF scratchboard] Cannot drag table box to the edge after diff --git a/libraries/import.lib.php b/libraries/import.lib.php index 24b27db..12dfbf6 100644 --- a/libraries/import.lib.php +++ b/libraries/import.lib.php @@ -118,6 +118,8 @@ function PMA_importRunQuery($sql = '', $full = '', $controluser = false) $display_query = ''; } $sql_query = $import_run_buffer['sql']; + // If a 'USE <db>' SQL-clause was found, set our current $db to the new one + list($db, $reload) = PMA_lookForUse($import_run_buffer['sql'], $db, $reload); } elseif ($run_query) { if ($controluser) { $result = PMA_query_as_controluser($import_run_buffer['sql']); @@ -156,10 +158,8 @@ function PMA_importRunQuery($sql = '', $full = '', $controluser = false) }
// If a 'USE <db>' SQL-clause was found and the query succeeded, set our current $db to the new one - if ($result != FALSE && preg_match('@^[\s]*USE[[:space:]]*([\S]+)@i', $import_run_buffer['sql'], $match)) { - $db = trim($match[1]); - $db = trim($db,';'); // for example, USE abc; - $reload = TRUE; + if ($result != FALSE) { + list($db, $reload) = PMA_lookForUse($import_run_buffer['sql'], $db, $reload); }
if ($result != FALSE && preg_match('@^[\s]*(DROP|CREATE)[\s]+(IF EXISTS[[:space:]]+)?(TABLE|DATABASE)[[:space:]]+(.+)@im', $import_run_buffer['sql'])) { @@ -205,6 +205,25 @@ function PMA_importRunQuery($sql = '', $full = '', $controluser = false) } }
+/** + * Looks for the presence of USE to possibly change current db + * + * @param string buffer to examine + * @param string current db + * @param boolean reload + * @return array (current or new db, whether to reload) + * @access public + */ +function PMA_lookForUse($buffer, $db, $reload) +{ + if (preg_match('@^[\s]*USE[[:space:]]*([\S]+)@i', $buffer, $match)) { + $db = trim($match[1]); + $db = trim($db,';'); // for example, USE abc; + $reload = TRUE; + } + return(array($db, $reload)); +} +
/** * Returns next part of imported file/buffer
hooks/post-receive