single-table copy did not copy the constraints
This commit is contained in:
@@ -5,6 +5,11 @@ phpMyAdmin - ChangeLog
|
|||||||
$Id$
|
$Id$
|
||||||
$Source$
|
$Source$
|
||||||
|
|
||||||
|
2006-07-04 Marc Delisle <lem9@users.sourceforge.net>
|
||||||
|
* db_operations.php, tbl_properties_operations.php,
|
||||||
|
libraries/Table.class.php, libraries/export/sql.php:
|
||||||
|
a single-table copy did not copy the constraints
|
||||||
|
|
||||||
2006-07-04 Sebastian Mendel <cybot_tm@users.sourceforge.net>
|
2006-07-04 Sebastian Mendel <cybot_tm@users.sourceforge.net>
|
||||||
* js\querywindow.js, libraries\footer.inc.php: renamed JavaScript function
|
* js\querywindow.js, libraries\footer.inc.php: renamed JavaScript function
|
||||||
refreshLeft() to refreshNavigation()
|
refreshLeft() to refreshNavigation()
|
||||||
|
@@ -264,7 +264,7 @@ if (!$is_information_schema) {
|
|||||||
id="checkbox_auto_increment" style="vertical-align: middle" />
|
id="checkbox_auto_increment" style="vertical-align: middle" />
|
||||||
<label for="checkbox_auto_increment">
|
<label for="checkbox_auto_increment">
|
||||||
<?php echo $strAddAutoIncrement; ?></label><br />
|
<?php echo $strAddAutoIncrement; ?></label><br />
|
||||||
<input type="checkbox" name="sql_constraints" value="1"
|
<input type="checkbox" name="add_constraints" value="1"
|
||||||
id="checkbox_constraints" style="vertical-align: middle" />
|
id="checkbox_constraints" style="vertical-align: middle" />
|
||||||
<label for="checkbox_constraints">
|
<label for="checkbox_constraints">
|
||||||
<?php echo $strAddConstraints; ?></label><br />
|
<?php echo $strAddConstraints; ?></label><br />
|
||||||
|
@@ -540,6 +540,7 @@ class PMA_Table {
|
|||||||
require_once './libraries/export/sql.php';
|
require_once './libraries/export/sql.php';
|
||||||
|
|
||||||
$no_constraints_comments = true;
|
$no_constraints_comments = true;
|
||||||
|
$GLOBALS['sql_constraints_query'] = '';
|
||||||
$sql_structure = PMA_getTableDef($source_db, $source_table, "\n", $err_url);
|
$sql_structure = PMA_getTableDef($source_db, $source_table, "\n", $err_url);
|
||||||
unset($no_constraints_comments);
|
unset($no_constraints_comments);
|
||||||
$parsed_sql = PMA_SQP_parse($sql_structure);
|
$parsed_sql = PMA_SQP_parse($sql_structure);
|
||||||
@@ -595,9 +596,9 @@ class PMA_Table {
|
|||||||
@PMA_DBI_query($sql_structure);
|
@PMA_DBI_query($sql_structure);
|
||||||
$GLOBALS['sql_query'] .= "\n" . $sql_structure . ';';
|
$GLOBALS['sql_query'] .= "\n" . $sql_structure . ';';
|
||||||
|
|
||||||
if (($move || isset($GLOBALS['constraints']))
|
if (($move || isset($GLOBALS['add_constraints']))
|
||||||
&& isset($GLOBALS['sql_constraints'])) {
|
&& isset($GLOBALS['sql_constraints_query'])) {
|
||||||
$parsed_sql = PMA_SQP_parse($GLOBALS['sql_constraints']);
|
$parsed_sql = PMA_SQP_parse($GLOBALS['sql_constraints_query']);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
// find the first quote_backtick, it must be the source table name
|
// find the first quote_backtick, it must be the source table name
|
||||||
@@ -624,11 +625,11 @@ class PMA_Table {
|
|||||||
|
|
||||||
|
|
||||||
// Generate query back
|
// Generate query back
|
||||||
$GLOBALS['sql_constraints'] = PMA_SQP_formatHtml($parsed_sql,
|
$GLOBALS['sql_constraints_query'] = PMA_SQP_formatHtml($parsed_sql,
|
||||||
'query_only');
|
'query_only');
|
||||||
PMA_DBI_query($GLOBALS['sql_constraints']);
|
PMA_DBI_query($GLOBALS['sql_constraints_query']);
|
||||||
$GLOBALS['sql_query'] .= "\n" . $GLOBALS['sql_constraints'];
|
$GLOBALS['sql_query'] .= "\n" . $GLOBALS['sql_constraints_query'];
|
||||||
unset($GLOBALS['sql_constraints']);
|
unset($GLOBALS['sql_constraints_query']);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@@ -346,6 +346,7 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $show_dates = false)
|
|||||||
global $sql_backquotes;
|
global $sql_backquotes;
|
||||||
global $cfgRelation;
|
global $cfgRelation;
|
||||||
global $sql_constraints;
|
global $sql_constraints;
|
||||||
|
global $sql_constraints_query; // just the text of the query
|
||||||
|
|
||||||
$schema_create = '';
|
$schema_create = '';
|
||||||
$auto_increment = '';
|
$auto_increment = '';
|
||||||
@@ -456,7 +457,7 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $show_dates = false)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// let's do the work
|
// let's do the work
|
||||||
$sql_constraints .= 'ALTER TABLE ' . PMA_backquote($table) . $crlf;
|
$sql_constraints_query .= 'ALTER TABLE ' . PMA_backquote($table) . $crlf;
|
||||||
|
|
||||||
$first = TRUE;
|
$first = TRUE;
|
||||||
for ($j = $i; $j < $sql_count; $j++) {
|
for ($j = $i; $j < $sql_count; $j++) {
|
||||||
@@ -465,9 +466,11 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $show_dates = false)
|
|||||||
$sql_constraints .= $crlf;
|
$sql_constraints .= $crlf;
|
||||||
}
|
}
|
||||||
if (strpos($sql_lines[$j], 'CONSTRAINT') === FALSE) {
|
if (strpos($sql_lines[$j], 'CONSTRAINT') === FALSE) {
|
||||||
$sql_constraints .= preg_replace('/(FOREIGN[\s]+KEY)/', 'ADD \1', $sql_lines[$j]);
|
$sql_constraints_query .= preg_replace('/(FOREIGN[\s]+KEY)/', 'ADD \1', $sql_lines[$j]);
|
||||||
|
$sql_constraints .= $sql_constraints_query;
|
||||||
} else {
|
} else {
|
||||||
$sql_constraints .= preg_replace('/(CONSTRAINT)/', 'ADD \1', $sql_lines[$j]);
|
$sql_constraints_query .= preg_replace('/(CONSTRAINT)/', 'ADD \1', $sql_lines[$j]);
|
||||||
|
$sql_constraints .= $sql_constraints_query;
|
||||||
}
|
}
|
||||||
$first = FALSE;
|
$first = FALSE;
|
||||||
} else {
|
} else {
|
||||||
@@ -475,6 +478,8 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $show_dates = false)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$sql_constraints .= ';' . $crlf;
|
$sql_constraints .= ';' . $crlf;
|
||||||
|
$sql_constraints_query .= ';';
|
||||||
|
|
||||||
$create_query = implode($crlf, array_slice($sql_lines, 0, $i)) . $crlf . implode($crlf, array_slice($sql_lines, $j, $sql_count - 1));
|
$create_query = implode($crlf, array_slice($sql_lines, 0, $i)) . $crlf . implode($crlf, array_slice($sql_lines, $j, $sql_count - 1));
|
||||||
unset($sql_lines);
|
unset($sql_lines);
|
||||||
}
|
}
|
||||||
|
@@ -368,7 +368,7 @@ foreach ($dblist as $each_db) {
|
|||||||
// foreign keys
|
// foreign keys
|
||||||
if (PMA_getForeigners($GLOBALS['db'], $GLOBALS['table'], '', 'innodb')) {
|
if (PMA_getForeigners($GLOBALS['db'], $GLOBALS['table'], '', 'innodb')) {
|
||||||
?>
|
?>
|
||||||
<input type="checkbox" name="sql_constraints" value="1" id="checkbox_constraints" />
|
<input type="checkbox" name="add_constraints" value="1" id="checkbox_constraints" />
|
||||||
<label for="checkbox_constraints"><?php echo $strAddConstraints; ?></label><br />
|
<label for="checkbox_constraints"><?php echo $strAddConstraints; ?></label><br />
|
||||||
<?php
|
<?php
|
||||||
} // endif
|
} // endif
|
||||||
|
Reference in New Issue
Block a user