bug #1831646 [table creation] Error in CREATE TABLE with multiple primary keys and AUTO_INCREMENT

This commit is contained in:
Marc Delisle
2007-11-14 18:42:47 +00:00
parent 9f9e801da5
commit 19721fd519
2 changed files with 17 additions and 9 deletions

View File

@@ -20,7 +20,9 @@ $HeadURL: https://phpmyadmin.svn.sourceforge.net/svnroot/phpmyadmin/trunk/phpMyA
- bug #1823045 [import] Error importing file with lowercase "delimiter"
- bug #1828913 [structure] Can't set FULLTEXT index on CHAR column
- bug #1804081 [export] export on server doesn't obey AllowAnyWhereRecoding
- bug #178988 [display] space before SHOW COLUMNS
- bug #1789988 [display] space before SHOW COLUMNS
- bug #1831646 [table creation] Error in CREATE TABLE with multiple primary
keys and AUTO_INCREMENT
2.11.2.1 (2007-11-11)
- fixed possible SQL injection using database name

View File

@@ -343,16 +343,22 @@ class PMA_Table {
if (!empty($extra)) {
$query .= ' ' . $extra;
// An auto_increment field must be use as a primary key
if ($extra == 'AUTO_INCREMENT' && isset($field_primary)) {
// Force an auto_increment field to be part of the primary key
// even if user did not tick the PK box;
// but the PK could contain other columns so do not append
// a PRIMARY KEY clause, just add a member to $field_primary
if ($extra == 'AUTO_INCREMENT') {
$primary_cnt = count($field_primary);
for ($j = 0; $j < $primary_cnt && $field_primary[$j] != $index; $j++) {
// void
$found_in_pk = false;
for ($j = 0; $j < $primary_cnt; $j++) {
if ($field_primary[$j] == $index) {
$found_in_pk = true;
break;
}
} // end for
if (isset($field_primary[$j]) && $field_primary[$j] == $index) {
$query .= ' PRIMARY KEY';
unset($field_primary[$j]);
} // end if
if (! $found_in_pk) {
$field_primary[] = $index;
}
} // end if (auto_increment)
}
if (PMA_MYSQL_INT_VERSION >= 40100 && !empty($comment)) {