bug #1550690, wrong export of constraints

This commit is contained in:
Marc Delisle
2006-10-01 18:48:43 +00:00
parent 1060b0fa14
commit b00f3d56cb
2 changed files with 9 additions and 4 deletions

View File

@@ -9,6 +9,8 @@ $Source$
### 2.9.0.1 released from MAINT_2_9_0 ### 2.9.0.1 released from MAINT_2_9_0
* tbl_relation.php: trap error 1452 when adding a foreign key * tbl_relation.php: trap error 1452 when adding a foreign key
and a constraint fails and a constraint fails
* libraries/export/sql.php: bug #1550690, wrong export of constraints,
thanks to Robert Vock
2006-09-29 Marc Delisle <lem9@users.sourceforge.net> 2006-09-29 Marc Delisle <lem9@users.sourceforge.net>
* libraries/database_interface.lib.php, bug #1566904, typo in require, * libraries/database_interface.lib.php, bug #1566904, typo in require,

View File

@@ -461,6 +461,7 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $show_dates = false)
// let's do the work // let's do the work
$sql_constraints_query .= 'ALTER TABLE ' . PMA_backquote($table) . $crlf; $sql_constraints_query .= 'ALTER TABLE ' . PMA_backquote($table) . $crlf;
$sql_constraints .= 'ALTER TABLE ' . PMA_backquote($table) . $crlf;
$first = TRUE; $first = TRUE;
for ($j = $i; $j < $sql_count; $j++) { for ($j = $i; $j < $sql_count; $j++) {
@@ -469,11 +470,13 @@ 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_query .= preg_replace('/(FOREIGN[\s]+KEY)/', 'ADD \1', $sql_lines[$j]); $str_tmp = preg_replace('/(FOREIGN[\s]+KEY)/', 'ADD \1', $sql_lines[$j]);
$sql_constraints .= $sql_constraints_query; $sql_constraints_query .= $str_tmp;
$sql_constraints .= $str_tmp;
} else { } else {
$sql_constraints_query .= preg_replace('/(CONSTRAINT)/', 'ADD \1', $sql_lines[$j]); $str_tmp = preg_replace('/(CONSTRAINT)/', 'ADD \1', $sql_lines[$j]);
$sql_constraints .= $sql_constraints_query; $sql_constraints_query .= $str_tmp;
$sql_constraints .= $str_tmp;
} }
$first = FALSE; $first = FALSE;
} else { } else {