The branch, master has been updated via 1fe6e59d732f408c95754579015b8cf0c746b89d (commit) via c0d1c7a2ae0d3f70bacac2d5abcb8bdc41590248 (commit) via c812a4b7fafea51c537e0fc778c521980b07a36a (commit) from 5811f3420687cb5b48b41a511cb2973254f2e17d (commit)
- Log ----------------------------------------------------------------- commit 1fe6e59d732f408c95754579015b8cf0c746b89d Merge: 5811f3420687cb5b48b41a511cb2973254f2e17d c0d1c7a2ae0d3f70bacac2d5abcb8bdc41590248 Author: Dieter Adriaenssens ruleant@users.sourceforge.net Date: Tue Sep 28 20:07:00 2010 +0200
Merge branch 'QA_3_3'
-----------------------------------------------------------------------
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 c4cfa35..d187e2a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -121,6 +121,8 @@ 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 2f89351..288de7b 100644 --- a/db_operations.php +++ b/db_operations.php @@ -69,6 +69,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(); } @@ -181,40 +215,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 2cb48ec..cc8cc75 100644 --- a/libraries/export/sql.php +++ b/libraries/export/sql.php @@ -370,9 +370,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(__('Procedures')) + . 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(__('Functions')) + . 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; }
/** @@ -415,49 +466,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(__('Procedures')) - . 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(__('Functions')) - . 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(__('Events')) @@ -469,8 +487,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