From 1454b4307d5718cab1fc5fa1ee1a48eabe7f0d65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Tue, 4 May 2004 12:17:01 +0000 Subject: [PATCH] Fix handling of multi column foreign keys (bug #946861). --- ChangeLog | 2 ++ libraries/export/sql.php | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index b6aa82846..8e4a7444f 100755 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,8 @@ $Source$ 2004-05-04 Michal Cihar * libraries/sqlparser.data.php: Add ENGINE to reserved words (used instead of TYPE in MySQL 4.1.1). + * libraries/export/sql.php: Fix handling of multi column foreign keys (bug + #946861). 2004-05-04 Garvin Hicking * Documentation.html, config.inc.php, left.php: Use NaturalOrder diff --git a/libraries/export/sql.php b/libraries/export/sql.php index 2fb6e0567..04c852990 100644 --- a/libraries/export/sql.php +++ b/libraries/export/sql.php @@ -261,7 +261,7 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $show_dates = false) $tmpres[1] = preg_replace('/^CREATE TABLE/', 'CREATE TABLE IF NOT EXISTS', $tmpres[1]); } - if (preg_match_all('((,\r?\n[\s]*(CONSTRAINT|FOREIGN[\s]*KEY)[^\r\n,]+)+)', $tmpres[1], $regs)) { + if (preg_match_all('((,\r?\n[\s]*(CONSTRAINT|FOREIGN[\s]*KEY)[^\r\n]+)+)', $tmpres[1], $regs)) { if (!isset($sql_constraints)) { if (isset($GLOBALS['no_constraints_comments'])) { $sql_constraints = ''; @@ -277,7 +277,7 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $show_dates = false) $sql_constraints .= 'ALTER TABLE ' . PMA_backquote($table) . $crlf . preg_replace('/(,\r?\n|^)([\s]*)(CONSTRAINT|FOREIGN[\s]*KEY)/', '\1\2ADD \3', substr($regs[0][0], 2)) . ";\n"; - $tmpres[1] = preg_replace('((,\r?\n[\s]*(CONSTRAINT|FOREIGN[\s]*KEY)[^\r\n,]+)+)', '', $tmpres[1]); + $tmpres[1] = preg_replace('((,\r?\n[\s]*(CONSTRAINT|FOREIGN[\s]*KEY)[^\r\n]+)+)', '', $tmpres[1]); } $schema_create .= $tmpres[1]; }