The branch, QA_3_3 has been updated via c0d1c7a2ae0d3f70bacac2d5abcb8bdc41590248 (commit) from c812a4b7fafea51c537e0fc778c521980b07a36a (commit)
- Log ----------------------------------------------------------------- -----------------------------------------------------------------------
Summary of changes: ChangeLog | 2 + db_operations.php | 68 +++++++++++++++++----------------- libraries/export/sql.php | 93 +++++++++++++++++++++++++++------------------- 3 files changed, 91 insertions(+), 72 deletions(-)
diff --git a/ChangeLog b/ChangeLog index eeebed1..699aaba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,8 @@ $HeadURL: https://phpmyadmin.svn.sourceforge.net/svnroot/phpmyadmin/trunk/phpMyA 3.3.8.0 (not yet released) - bug #3059311 [import] BIGINT field type added to table analysis - [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
3.3.7.0 (2010-09-07) - patch #3050492 [PDF scratchboard] Cannot drag table box to the edge after diff --git a/db_operations.php b/db_operations.php index f051877..29d2635 100644 --- a/db_operations.php +++ b/db_operations.php @@ -66,6 +66,40 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) { $GLOBALS['pma']->databases->build(); }
+ if (PMA_MYSQL_INT_VERSION >= 50000) { + // here I don't use DELIMITER because it's not part of the + // language; I have to send each statement one by one + + // to avoid selecting alternatively the current and new db + // we would need to modify the CREATE definitions to qualify + // the db name + $procedure_names = PMA_DBI_get_procedures_or_functions($db, 'PROCEDURE'); + if ($procedure_names) { + foreach($procedure_names as $procedure_name) { + PMA_DBI_select_db($db); + $tmp_query = PMA_DBI_get_definition($db, 'PROCEDURE', $procedure_name); + // collect for later display + $GLOBALS['sql_query'] .= "\n" . $tmp_query; + PMA_DBI_select_db($newname); + PMA_DBI_query($tmp_query); + } + } + + $function_names = PMA_DBI_get_procedures_or_functions($db, 'FUNCTION'); + if ($function_names) { + foreach($function_names as $function_name) { + PMA_DBI_select_db($db); + $tmp_query = PMA_DBI_get_definition($db, 'FUNCTION', $function_name); + // collect for later display + $GLOBALS['sql_query'] .= "\n" . $tmp_query; + PMA_DBI_select_db($newname); + PMA_DBI_query($tmp_query); + } + } + } + // go back to current db, just in case + PMA_DBI_select_db($db); + if (isset($GLOBALS['add_constraints']) || $move) { $GLOBALS['sql_constraints_query_full_db'] = array(); } @@ -178,40 +212,6 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) { unset($GLOBALS['sql_constraints_query_full_db'], $one_query); }
- if (PMA_MYSQL_INT_VERSION >= 50000) { - // here I don't use DELIMITER because it's not part of the - // language; I have to send each statement one by one - - // to avoid selecting alternatively the current and new db - // we would need to modify the CREATE definitions to qualify - // the db name - $procedure_names = PMA_DBI_get_procedures_or_functions($db, 'PROCEDURE'); - if ($procedure_names) { - foreach($procedure_names as $procedure_name) { - PMA_DBI_select_db($db); - $tmp_query = PMA_DBI_get_definition($db, 'PROCEDURE', $procedure_name); - // collect for later display - $GLOBALS['sql_query'] .= "\n" . $tmp_query; - PMA_DBI_select_db($newname); - PMA_DBI_query($tmp_query); - } - } - - $function_names = PMA_DBI_get_procedures_or_functions($db, 'FUNCTION'); - if ($function_names) { - foreach($function_names as $function_name) { - PMA_DBI_select_db($db); - $tmp_query = PMA_DBI_get_definition($db, 'FUNCTION', $function_name); - // collect for later display - $GLOBALS['sql_query'] .= "\n" . $tmp_query; - PMA_DBI_select_db($newname); - PMA_DBI_query($tmp_query); - } - } - } - // go back to current db, just in case - PMA_DBI_select_db($db); - // Duplicate the bookmarks for this db (done once for each db) if (! $_error && $db != $newname) { $get_fields = array('user', 'label', 'query'); diff --git a/libraries/export/sql.php b/libraries/export/sql.php index 9c177b4..d026f2c 100644 --- a/libraries/export/sql.php +++ b/libraries/export/sql.php @@ -307,9 +307,60 @@ function PMA_exportDBCreate($db) return FALSE; } if (isset($GLOBALS['sql_backquotes']) && isset($GLOBALS['sql_compatibility']) && $GLOBALS['sql_compatibility'] == 'NONE') { - return PMA_exportOutputHandler('USE ' . PMA_backquote($db) . ';' . $crlf); + $result = PMA_exportOutputHandler('USE ' . PMA_backquote($db) . ';' . $crlf); + } else { + $result = PMA_exportOutputHandler('USE ' . $db . ';' . $crlf); + } + + if ($result && isset($GLOBALS['sql_structure']) && isset($GLOBALS['sql_procedure_function'])) { + $text = ''; + $delimiter = '$$'; + + $procedure_names = PMA_DBI_get_procedures_or_functions($db, 'PROCEDURE'); + $function_names = PMA_DBI_get_procedures_or_functions($db, 'FUNCTION'); + + if ($procedure_names || $function_names) { + $text .= $crlf + . 'DELIMITER ' . $delimiter . $crlf; + } + + if ($procedure_names) { + $text .= + PMA_exportComment() + . PMA_exportComment($GLOBALS['strProcedures']) + . PMA_exportComment(); + + foreach($procedure_names as $procedure_name) { + if (! empty($GLOBALS['sql_drop_table'])) { + $text .= 'DROP PROCEDURE IF EXISTS ' . PMA_backquote($procedure_name) . $delimiter . $crlf; + } + $text .= PMA_DBI_get_definition($db, 'PROCEDURE', $procedure_name) . $delimiter . $crlf . $crlf; + } + } + + if ($function_names) { + $text .= + PMA_exportComment() + . PMA_exportComment($GLOBALS['strFunctions']) + . PMA_exportComment(); + + foreach($function_names as $function_name) { + if (! empty($GLOBALS['sql_drop_table'])) { + $text .= 'DROP FUNCTION IF EXISTS ' . PMA_backquote($function_name) . $delimiter . $crlf; + } + $text .= PMA_DBI_get_definition($db, 'FUNCTION', $function_name) . $delimiter . $crlf . $crlf; + } + } + + if ($procedure_names || $function_names) { + $text .= 'DELIMITER ;' . $crlf; + } + + if (! empty($text)) { + $result = PMA_exportOutputHandler($text); + } } - return PMA_exportOutputHandler('USE ' . $db . ';' . $crlf); + return $result; }
/** @@ -352,49 +403,16 @@ function PMA_exportDBFooter($db) $text = ''; $delimiter = '$$';
- $procedure_names = PMA_DBI_get_procedures_or_functions($db, 'PROCEDURE'); - $function_names = PMA_DBI_get_procedures_or_functions($db, 'FUNCTION'); - if (PMA_MYSQL_INT_VERSION > 50100) { $event_names = PMA_DBI_fetch_result('SELECT EVENT_NAME FROM information_schema.EVENTS WHERE EVENT_SCHEMA= '' . PMA_sqlAddslashes($db,true) . '';'); } else { $event_names = array(); }
- if ($procedure_names || $function_names || $event_names) { + if ($event_names) { $text .= $crlf . 'DELIMITER ' . $delimiter . $crlf; - } - - if ($procedure_names) { - $text .= - PMA_exportComment() - . PMA_exportComment($GLOBALS['strProcedures']) - . PMA_exportComment(); - - foreach($procedure_names as $procedure_name) { - if (! empty($GLOBALS['sql_drop_table'])) { - $text .= 'DROP PROCEDURE IF EXISTS ' . PMA_backquote($procedure_name) . $delimiter . $crlf; - } - $text .= PMA_DBI_get_definition($db, 'PROCEDURE', $procedure_name) . $delimiter . $crlf . $crlf; - } - }
- if ($function_names) { - $text .= - PMA_exportComment() - . PMA_exportComment($GLOBALS['strFunctions']) - . PMA_exportComment(); - - foreach($function_names as $function_name) { - if (! empty($GLOBALS['sql_drop_table'])) { - $text .= 'DROP FUNCTION IF EXISTS ' . PMA_backquote($function_name) . $delimiter . $crlf; - } - $text .= PMA_DBI_get_definition($db, 'FUNCTION', $function_name) . $delimiter . $crlf . $crlf; - } - } - - if ($event_names) { $text .= PMA_exportComment() . PMA_exportComment($GLOBALS['strEvents']) @@ -406,8 +424,7 @@ function PMA_exportDBFooter($db) } $text .= PMA_DBI_get_definition($db, 'EVENT', $event_name) . $delimiter . $crlf . $crlf; } - } - if ($procedure_names || $function_names || $event_names) { + $text .= 'DELIMITER ;' . $crlf; }
hooks/post-receive