From 0f6eb412ec4a5f7b5d5cbb9822a9f434d21265f5 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Wed, 10 Mar 2004 15:57:59 +0000 Subject: [PATCH] bug 877359, constraint and MySQL 3.23.58 --- ChangeLog | 4 ++++ libraries/relation.lib.php | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 65d2b271b..9a3ef7da4 100755 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,10 @@ phpMyAdmin - Changelog $Id$ $Source$ +2004-03-10 Marc Delisle + * libraries/relation.lib.php: bug 877359, no CONSTRAINT in + SHOW CREATE TABLE on older MySQL versions + 2004-03-10 Michal Cihar * export.php: Correctly report error when export fails. * libraries/database_interface.lib.php, libraries/dbi/mysql.dbi.lib.php, diff --git a/libraries/relation.lib.php b/libraries/relation.lib.php index e7cd0f432..2ed64a10a 100644 --- a/libraries/relation.lib.php +++ b/libraries/relation.lib.php @@ -310,7 +310,16 @@ function PMA_getForeigners($db, $table, $column = '', $source = 'both') { // and in 'innodb', we won't get it twice if $source='both' // because we use $field as key - $foreign[$field]['constraint'] = $one_key['constraint']; + // The parser looks for a CONSTRAINT clause just before + // the FOREIGN KEY clause. It finds it (as output from + // SHOW CREATE TABLE) in MySQL 4.0.13, but not in older + // versions like 3.23.58. + // In those cases, the FOREIGN KEY parsing will put numbers + // like -1, 0, 1... instead of the constraint number. + + if (isset($one_key['constraint'])) { + $foreign[$field]['constraint'] = $one_key['constraint']; + } if (isset($one_key['ref_db_name'])) { $foreign[$field]['foreign_db'] = $one_key['ref_db_name'];