mirror of
https://github.com/vrana/adminer.git
synced 2025-08-06 14:46:36 +02:00
Allow exporting views dependent on each other (bug #3459151)
This commit is contained in:
@@ -70,30 +70,28 @@ SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
|
|||||||
$table = (DB == "" || in_array($name, (array) $_POST["tables"]));
|
$table = (DB == "" || in_array($name, (array) $_POST["tables"]));
|
||||||
$data = (DB == "" || in_array($name, (array) $_POST["data"]));
|
$data = (DB == "" || in_array($name, (array) $_POST["data"]));
|
||||||
if ($table || $data) {
|
if ($table || $data) {
|
||||||
if (!is_view($table_status)) {
|
if ($ext == "tar") {
|
||||||
if ($ext == "tar") {
|
ob_start();
|
||||||
ob_start();
|
}
|
||||||
}
|
$adminer->dumpTable($name, ($table ? $_POST["table_style"] : ""), (is_view($table_status) ? 2 : 0));
|
||||||
$adminer->dumpTable($name, ($table ? $_POST["table_style"] : ""));
|
if (is_view($table_status)) {
|
||||||
if ($data) {
|
|
||||||
$fields = fields($name);
|
|
||||||
$adminer->dumpData($name, $_POST["data_style"], "SELECT *" . convert_fields($fields, $fields) . " FROM " . table($name));
|
|
||||||
}
|
|
||||||
if ($is_sql && $_POST["triggers"] && $table && ($triggers = trigger_sql($name, $_POST["table_style"]))) {
|
|
||||||
echo "\nDELIMITER ;;\n$triggers\nDELIMITER ;\n";
|
|
||||||
}
|
|
||||||
if ($ext == "tar") {
|
|
||||||
echo tar_file((DB != "" ? "" : "$db/") . "$name.csv", ob_get_clean());
|
|
||||||
} elseif ($is_sql) {
|
|
||||||
echo "\n";
|
|
||||||
}
|
|
||||||
} elseif ($is_sql) {
|
|
||||||
$views[] = $name;
|
$views[] = $name;
|
||||||
|
} elseif ($data) {
|
||||||
|
$fields = fields($name);
|
||||||
|
$adminer->dumpData($name, $_POST["data_style"], "SELECT *" . convert_fields($fields, $fields) . " FROM " . table($name));
|
||||||
|
}
|
||||||
|
if ($is_sql && $_POST["triggers"] && $table && ($triggers = trigger_sql($name, $_POST["table_style"]))) {
|
||||||
|
echo "\nDELIMITER ;;\n$triggers\nDELIMITER ;\n";
|
||||||
|
}
|
||||||
|
if ($ext == "tar") {
|
||||||
|
echo tar_file((DB != "" ? "" : "$db/") . "$name.csv", ob_get_clean());
|
||||||
|
} elseif ($is_sql) {
|
||||||
|
echo "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach ($views as $view) {
|
foreach ($views as $view) {
|
||||||
$adminer->dumpTable($view, $_POST["table_style"], true);
|
$adminer->dumpTable($view, $_POST["table_style"], 1);
|
||||||
}
|
}
|
||||||
if ($ext == "tar") {
|
if ($ext == "tar") {
|
||||||
echo pack("x512");
|
echo pack("x512");
|
||||||
|
@@ -590,22 +590,30 @@ username.form['auth[driver]'].onchange();
|
|||||||
/** Export table structure
|
/** Export table structure
|
||||||
* @param string
|
* @param string
|
||||||
* @param string
|
* @param string
|
||||||
* @param bool
|
* @param int 0 table, 1 view, 2 temporary view table
|
||||||
* @return null prints data
|
* @return null prints data
|
||||||
*/
|
*/
|
||||||
function dumpTable($table, $style, $is_view = false) {
|
function dumpTable($table, $style, $is_view = 0) {
|
||||||
if ($_POST["format"] != "sql") {
|
if ($_POST["format"] != "sql") {
|
||||||
echo "\xef\xbb\xbf"; // UTF-8 byte order mark
|
echo "\xef\xbb\xbf"; // UTF-8 byte order mark
|
||||||
if ($style) {
|
if ($style) {
|
||||||
dump_csv(array_keys(fields($table)));
|
dump_csv(array_keys(fields($table)));
|
||||||
}
|
}
|
||||||
} elseif ($style) {
|
} elseif ($style) {
|
||||||
$create = create_sql($table, $_POST["auto_increment"]);
|
if ($is_view == 2) {
|
||||||
if ($create) {
|
$fields = array();
|
||||||
if ($style == "DROP+CREATE") {
|
foreach (fields($table) as $name => $field) {
|
||||||
echo "DROP " . ($is_view ? "VIEW" : "TABLE") . " IF EXISTS " . table($table) . ";\n";
|
$fields[] = idf_escape($name) . " $field[full_type]";
|
||||||
}
|
}
|
||||||
if ($is_view) {
|
$create = "CREATE TABLE " . table($table) . " (" . implode(", ", $fields) . ")";
|
||||||
|
} else {
|
||||||
|
$create = create_sql($table, $_POST["auto_increment"]);
|
||||||
|
}
|
||||||
|
if ($create) {
|
||||||
|
if ($style == "DROP+CREATE" || $is_view == 1) {
|
||||||
|
echo "DROP " . ($is_view == 2 ? "VIEW" : "TABLE") . " IF EXISTS " . table($table) . ";\n";
|
||||||
|
}
|
||||||
|
if ($is_view == 1) {
|
||||||
$create = remove_definer($create);
|
$create = remove_definer($create);
|
||||||
}
|
}
|
||||||
echo "$create;\n\n";
|
echo "$create;\n\n";
|
||||||
|
@@ -4,6 +4,7 @@ Print run time next to executed queries
|
|||||||
Disable SQL export when applying functions in select
|
Disable SQL export when applying functions in select
|
||||||
Allow using lang() in plugins (customization)
|
Allow using lang() in plugins (customization)
|
||||||
Remove bzip2 compression support
|
Remove bzip2 compression support
|
||||||
|
Allow exporting views dependent on each other (bug #3459151)
|
||||||
MySQL: Optimize create table page and Editor navigation
|
MySQL: Optimize create table page and Editor navigation
|
||||||
MySQL: Display bit type as binary number
|
MySQL: Display bit type as binary number
|
||||||
MySQL: Improve export of binary data types
|
MySQL: Improve export of binary data types
|
||||||
|
Reference in New Issue
Block a user