Merge remote-tracking branch 'origin/QA_4_4' into QA_4_4

This commit is contained in:
Weblate 2015-07-31 09:07:46 +02:00
commit 375602fc21
3 changed files with 69 additions and 41 deletions

View File

@ -662,6 +662,13 @@ function PMA_exportDatabase(
if (! $export_plugin->exportDBFooter($db, $db_alias)) {
return;
}
if (($GLOBALS['sql_structure_or_data'] == 'structure'
|| $GLOBALS['sql_structure_or_data'] == 'structure_and_data')
&& isset($GLOBALS['sql_procedure_function'])
) {
$export_plugin->exportEvents($db, $aliases);
}
}
/**

View File

@ -109,6 +109,19 @@ abstract class ExportPlugin
;
}
/**
* Exports events
*
* @param string $db Database
* @param array $aliases Aliases of db/table/columns
*
* @return bool Whether it succeeded
*/
public function exportEvents($db, $aliases = array())
{
;
}
/**
* Outputs table's structure
*

View File

@ -887,50 +887,58 @@ class ExportSql extends ExportPlugin
unset($GLOBALS['sql_constraints']);
}
if (($GLOBALS['sql_structure_or_data'] == 'structure'
|| $GLOBALS['sql_structure_or_data'] == 'structure_and_data')
&& isset($GLOBALS['sql_procedure_function'])
) {
$text = '';
$delimiter = '$$';
$event_names = $GLOBALS['dbi']->fetchResult(
'SELECT EVENT_NAME FROM information_schema.EVENTS WHERE'
. ' EVENT_SCHEMA= \''
. PMA_Util::sqlAddSlashes($db, true)
. '\';'
);
if ($event_names) {
$text .= $crlf
. 'DELIMITER ' . $delimiter . $crlf;
$text .=
$this->_exportComment()
. $this->_exportComment(__('Events'))
. $this->_exportComment();
foreach ($event_names as $event_name) {
if (! empty($GLOBALS['sql_drop_table'])) {
$text .= 'DROP EVENT '
. PMA_Util::backquote($event_name)
. $delimiter . $crlf;
}
$text .= $GLOBALS['dbi']
->getDefinition($db, 'EVENT', $event_name)
. $delimiter . $crlf . $crlf;
}
$text .= 'DELIMITER ;' . $crlf;
}
if (! empty($text)) {
$result = PMA_exportOutputHandler($text);
}
}
return $result;
}
/**
* Exports events
*
* @param string $db Database
* @param array $aliases Aliases of db/table/columns
*
* @return bool Whether it succeeded
*/
public function exportEvents($db, $aliases = array())
{
global $crlf;
$text = '';
$delimiter = '$$';
$event_names = $GLOBALS['dbi']->fetchResult(
"SELECT EVENT_NAME FROM information_schema.EVENTS WHERE"
. " EVENT_SCHEMA= '" . PMA_Util::sqlAddSlashes($db, true) . "';"
);
if ($event_names) {
$text .= $crlf
. "DELIMITER " . $delimiter . $crlf;
$text .=
$this->_exportComment()
. $this->_exportComment(__('Events'))
. $this->_exportComment();
foreach ($event_names as $event_name) {
if (! empty($GLOBALS['sql_drop_table'])) {
$text .= "DROP EVENT "
. PMA_Util::backquote($event_name)
. $delimiter . $crlf;
}
$text .= $GLOBALS['dbi']->getDefinition($db, 'EVENT', $event_name)
. $delimiter . $crlf . $crlf;
}
$text .= "DELIMITER ;" . $crlf;
}
if (! empty($text)) {
return PMA_exportOutputHandler($text);
} else {
return false;
}
}
/**
* Returns a stand-in CREATE definition to resolve view dependencies
*