Merge remote branch 'origin/master'

This commit is contained in:
Pootle server
2011-02-13 20:40:03 +01:00
2 changed files with 69 additions and 48 deletions

View File

@@ -458,6 +458,10 @@ if ($export_type == 'server') {
if (!PMA_exportDBCreate($current_db)) {
break 2;
}
if (function_exists('PMA_exportRoutines') && strpos($GLOBALS['sql_structure_or_data'], 'structure') !== false && isset($GLOBALS['sql_procedure_function'])) {
PMA_exportRoutines($current_db);
}
$tables = PMA_DBI_get_tables($current_db);
$views = array();
foreach ($tables as $table) {
@@ -506,6 +510,11 @@ if ($export_type == 'server') {
if (!PMA_exportDBHeader($db)) {
break;
}
if (function_exists('PMA_exportRoutines') && strpos($GLOBALS['sql_structure_or_data'], 'structure') !== false && isset($GLOBALS['sql_procedure_function'])) {
PMA_exportRoutines($db);
}
$i = 0;
$views = array();
// $tables contains the choices from the user (via $table_select)

View File

@@ -182,6 +182,66 @@ if (! isset($sql_backquotes)) {
$sql_backquotes = null;
}
/**
* Exports routines (procedures and functions)
*
* @param string $db
*
* @return bool Whether it suceeded
*/
function PMA_exportRoutines($db) {
global $crlf;
$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)) {
return PMA_exportOutputHandler($text);
} else {
return false;
}
}
/**
* Possibly outputs comment
*
@@ -375,54 +435,6 @@ function PMA_exportDBCreate($db)
$result = PMA_exportOutputHandler('USE ' . $db . ';' . $crlf);
}
if ($result && strpos($GLOBALS['sql_structure_or_data'], 'structure') !== false && 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 $result;
}