From b00f3d56cba0683bd3a97f7ea3f0f3fcb75d6da5 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Sun, 1 Oct 2006 18:48:43 +0000 Subject: [PATCH] bug #1550690, wrong export of constraints --- ChangeLog | 2 ++ libraries/export/sql.php | 11 +++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 19be696f0..356eff248 100755 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,8 @@ $Source$ ### 2.9.0.1 released from MAINT_2_9_0 * tbl_relation.php: trap error 1452 when adding a foreign key and a constraint fails + * libraries/export/sql.php: bug #1550690, wrong export of constraints, + thanks to Robert Vock 2006-09-29 Marc Delisle * libraries/database_interface.lib.php, bug #1566904, typo in require, diff --git a/libraries/export/sql.php b/libraries/export/sql.php index 18d11db14..4a4fc51a3 100644 --- a/libraries/export/sql.php +++ b/libraries/export/sql.php @@ -461,6 +461,7 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $show_dates = false) // let's do the work $sql_constraints_query .= 'ALTER TABLE ' . PMA_backquote($table) . $crlf; + $sql_constraints .= 'ALTER TABLE ' . PMA_backquote($table) . $crlf; $first = TRUE; 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; } if (strpos($sql_lines[$j], 'CONSTRAINT') === FALSE) { - $sql_constraints_query .= preg_replace('/(FOREIGN[\s]+KEY)/', 'ADD \1', $sql_lines[$j]); - $sql_constraints .= $sql_constraints_query; + $str_tmp = preg_replace('/(FOREIGN[\s]+KEY)/', 'ADD \1', $sql_lines[$j]); + $sql_constraints_query .= $str_tmp; + $sql_constraints .= $str_tmp; } else { - $sql_constraints_query .= preg_replace('/(CONSTRAINT)/', 'ADD \1', $sql_lines[$j]); - $sql_constraints .= $sql_constraints_query; + $str_tmp = preg_replace('/(CONSTRAINT)/', 'ADD \1', $sql_lines[$j]); + $sql_constraints_query .= $str_tmp; + $sql_constraints .= $str_tmp; } $first = FALSE; } else {