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 f82c6e9c5e
commit 728e553098
2 changed files with 24 additions and 11 deletions

View File

@@ -51,6 +51,9 @@ danbarry
+ [engines] MyISAM and InnoDB: support ROW_FORMAT table option + [engines] MyISAM and InnoDB: support ROW_FORMAT table option
+ prevent search indexes from indexing phpMyAdmin installations + prevent search indexes from indexing phpMyAdmin installations
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
- bug #1905711 [compatibility] Functions deprecated in PHP 5.3: is_a() and - bug #1905711 [compatibility] Functions deprecated in PHP 5.3: is_a() and

View File

@@ -332,20 +332,30 @@ class PMA_Table {
if (!empty($extra)) { if (!empty($extra)) {
$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);
$found_in_pk = false; if (1 == $primary_cnt) {
for ($j = 0; $j < $primary_cnt; $j++) { for ($j = 0; $j < $primary_cnt && $field_primary[$j] != $index; $j++) {
if ($field_primary[$j] == $index) { //void
$found_in_pk = true; }
break; 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;
for ($j = 0; $j < $primary_cnt; $j++) {
if ($field_primary[$j] == $index) {
$found_in_pk = true;
break;
}
} // end for
if (! $found_in_pk) {
$field_primary[] = $index;
} }
} // end for
if (! $found_in_pk) {
$field_primary[] = $index;
} }
} // end if (auto_increment) } // end if (auto_increment)
} }