bug #1908719 [interface] New field cannot be auto-increment and primary key

This commit is contained in:
Marc Delisle
2008-04-24 17:05:50 +00:00
parent 55cc1ad593
commit f0b01f6533
2 changed files with 21 additions and 10 deletions

View File

@@ -6,6 +6,7 @@ $Id$
$HeadURL: https://phpmyadmin.svn.sourceforge.net/svnroot/phpmyadmin/trunk/phpMyAdmin/ChangeLog $ $HeadURL: https://phpmyadmin.svn.sourceforge.net/svnroot/phpmyadmin/trunk/phpMyAdmin/ChangeLog $
2.11.7.0 (not yet released) 2.11.7.0 (not yet released)
- bug #1908719 [interface] New field cannot be auto-increment and primary key
2.11.6.0 (not yet released) 2.11.6.0 (not yet released)
- bug #1903724 [interface] Displaying of very large queries in error message - bug #1903724 [interface] Displaying of very large queries in error message

View File

@@ -345,10 +345,19 @@ class PMA_Table {
$query .= ' ' . $extra; $query .= ' ' . $extra;
// Force an auto_increment field to be part of the primary key // Force an auto_increment field to be part of the primary key
// even if user did not tick the PK box; // 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') { if ($extra == 'AUTO_INCREMENT') {
$primary_cnt = count($field_primary); $primary_cnt = count($field_primary);
if (1 == $primary_cnt) {
for ($j = 0; $j < $primary_cnt && $field_primary[$j] != $index; $j++) {
//void
}
if (isset($field_primary[$j]) && $field_primary[$j] == $index) {
$query .= ' PRIMARY KEY';
unset($field_primary[$j]);
}
// but the PK could contain other columns so do not append
// a PRIMARY KEY clause, just add a member to $field_primary
} else {
$found_in_pk = false; $found_in_pk = false;
for ($j = 0; $j < $primary_cnt; $j++) { for ($j = 0; $j < $primary_cnt; $j++) {
if ($field_primary[$j] == $index) { if ($field_primary[$j] == $index) {
@@ -359,6 +368,7 @@ class PMA_Table {
if (! $found_in_pk) { if (! $found_in_pk) {
$field_primary[] = $index; $field_primary[] = $index;
} }
}
} // end if (auto_increment) } // end if (auto_increment)
} }
if (PMA_MYSQL_INT_VERSION >= 40100 && !empty($comment)) { if (PMA_MYSQL_INT_VERSION >= 40100 && !empty($comment)) {