forked from phpmyadmin/phpmyadmin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug 1388048, constraints copied too early when copying a db
- Loading branch information
Marc Delisle
committed
Jul 4, 2006
1 parent
029a63a
commit e79079b
Showing
4 changed files
with
36 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,10 @@ $Source$ | |
|
||
2006-07-04 Marc Delisle <[email protected]> | ||
* db_operations.php, tbl_properties_operations.php, | ||
libraries/Table.class.php, libraries/export/sql.php: | ||
a single-table copy did not copy the constraints | ||
libraries/Table.class.php, libraries/export/sql.php, | ||
tbl_move_copy.php: | ||
a single-table copy did not copy the constraints; | ||
also bug #1388048, contraints copied too early when copying a db | ||
|
||
2006-07-04 Sebastian Mendel <[email protected]> | ||
* js\querywindow.js, libraries\footer.inc.php: renamed JavaScript function | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -505,7 +505,7 @@ function duplicateInfo($work, $pma_table, $get_fields, $where_fields, | |
* | ||
* @author Michal Cihar <[email protected]> | ||
*/ | ||
function moveCopy($source_db, $source_table, $target_db, $target_table, $what, $move) | ||
function moveCopy($source_db, $source_table, $target_db, $target_table, $what, $move, $mode) | ||
{ | ||
global $dblist, $err_url; | ||
|
||
|
@@ -541,13 +541,14 @@ function moveCopy($source_db, $source_table, $target_db, $target_table, $what, $ | |
|
||
$no_constraints_comments = true; | ||
$GLOBALS['sql_constraints_query'] = ''; | ||
|
||
$sql_structure = PMA_getTableDef($source_db, $source_table, "\n", $err_url); | ||
unset($no_constraints_comments); | ||
$parsed_sql = PMA_SQP_parse($sql_structure); | ||
$analyzed_sql = PMA_SQP_analyze($parsed_sql); | ||
$i = 0; | ||
if (empty($analyzed_sql[0]['create_table_fields'])) { | ||
// lem9: this is not a CREATE TABLE, so find the first VIEW | ||
// this is not a CREATE TABLE, so find the first VIEW | ||
$target_for_view = PMA_backquote($target_db); | ||
while (true) { | ||
if ($parsed_sql[$i]['type'] == 'alpha_reservedWord' && $parsed_sql[$i]['data'] == 'VIEW') { | ||
|
@@ -597,13 +598,17 @@ function moveCopy($source_db, $source_table, $target_db, $target_table, $what, $ | |
$GLOBALS['sql_query'] .= "\n" . $sql_structure . ';'; | ||
|
||
if (($move || isset($GLOBALS['add_constraints'])) | ||
&& isset($GLOBALS['sql_constraints_query'])) { | ||
&& !empty($GLOBALS['sql_constraints_query'])) { | ||
$parsed_sql = PMA_SQP_parse($GLOBALS['sql_constraints_query']); | ||
$i = 0; | ||
|
||
// find the first quote_backtick, it must be the source table name | ||
while ($parsed_sql[$i]['type'] != 'quote_backtick') { | ||
$i++; | ||
// maybe someday we should guard against going over limit | ||
//if ($i == $parsed_sql['len']) { | ||
// break; | ||
//} | ||
} | ||
|
||
// replace it by the target table name, no need to PMA_backquote() | ||
|
@@ -623,13 +628,16 @@ function moveCopy($source_db, $source_table, $target_db, $target_table, $what, $ | |
} | ||
} | ||
|
||
|
||
// Generate query back | ||
$GLOBALS['sql_constraints_query'] = PMA_SQP_formatHtml($parsed_sql, | ||
'query_only'); | ||
PMA_DBI_query($GLOBALS['sql_constraints_query']); | ||
if ($mode == 'one_table') { | ||
PMA_DBI_query($GLOBALS['sql_constraints_query']); | ||
} | ||
$GLOBALS['sql_query'] .= "\n" . $GLOBALS['sql_constraints_query']; | ||
unset($GLOBALS['sql_constraints_query']); | ||
if ($mode == 'one_table') { | ||
unset($GLOBALS['sql_constraints_query']); | ||
} | ||
} | ||
|
||
} else { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters