diff options
author | Mattias Jonsson <mattias.jonsson@sun.com> | 2008-10-23 22:14:07 +0200 |
---|---|---|
committer | Mattias Jonsson <mattias.jonsson@sun.com> | 2008-10-23 22:14:07 +0200 |
commit | df6a8d0b6912e102d8820dbb87b8e7ba8abf6d12 (patch) | |
tree | c38541e7d0a13a04986b68b22359df5401c49172 /sql/ha_partition.cc | |
parent | 78b3623337e043bbff863ee9d9fde7c58318acce (diff) | |
download | mariadb-git-df6a8d0b6912e102d8820dbb87b8e7ba8abf6d12.tar.gz |
Bug#40176: update as first partitioning statement
breaks auto increment
The auto_increment value was not initialized if
the first statement after opening a table was
an 'UPDATE'.
solution was to check initialize if it was not,
before trying to increase it in update.
mysql-test/suite/parts/inc/partition_auto_increment.inc:
Bug#40176: update as first partitioning statement
breaks auto increment
Added tests for verifying the bug and show some more
auto_increment flaws
mysql-test/suite/parts/r/partition_auto_increment_archive.result:
Bug#40176: update as first partitioning statement
breaks auto increment
Updated test results, due to added tests
mysql-test/suite/parts/r/partition_auto_increment_blackhole.result:
Bug#40176: update as first partitioning statement
breaks auto increment
Updated test results, due to added tests
mysql-test/suite/parts/r/partition_auto_increment_innodb.result:
Bug#40176: update as first partitioning statement
breaks auto increment
Updated test results, due to added tests
mysql-test/suite/parts/r/partition_auto_increment_memory.result:
Bug#40176: update as first partitioning statement
breaks auto increment
Updated test results, due to added tests
mysql-test/suite/parts/r/partition_auto_increment_myisam.result:
Bug#40176: update as first partitioning statement
breaks auto increment
Updated test results, due to added tests
mysql-test/suite/parts/r/partition_auto_increment_ndb.result:
Bug#40176: update as first partitioning statement
breaks auto increment
Updated test results, due to added tests
sql/ha_partition.cc:
Bug#40176: update as first partitioning statement
breaks auto increment
make sure that the auto_increment value is initialized
before updating it.
(missed initializing in mysql_update_row).
sql/ha_partition.h:
Bug#40176: update as first partitioning statement
breaks auto increment
Assert that it is initialized, before updating
the auto_increment value
Diffstat (limited to 'sql/ha_partition.cc')
-rw-r--r-- | sql/ha_partition.cc | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 14e321218ca..47de9c50891 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -2996,17 +2996,6 @@ int ha_partition::update_row(const uchar *old_data, uchar *new_data) DBUG_PRINT("info", ("Update in partition %d", new_part_id)); tmp_disable_binlog(thd); /* Do not replicate the low-level changes. */ error= m_file[new_part_id]->ha_update_row(old_data, new_data); - /* - if updating an auto_increment column, update - table_share->ha_data->next_auto_inc_val if needed. - (not to be used if auto_increment on secondary field in a multi- - column index) - mysql_update does not set table->next_number_field, so we use - table->found_next_number_field instead. - */ - if (table->found_next_number_field && new_data == table->record[0] && - !table->s->next_number_keypart) - set_auto_increment_if_higher(table->found_next_number_field->val_int()); reenable_binlog(thd); goto exit; } @@ -3016,9 +3005,6 @@ int ha_partition::update_row(const uchar *old_data, uchar *new_data) old_part_id, new_part_id)); tmp_disable_binlog(thd); /* Do not replicate the low-level changes. */ error= m_file[new_part_id]->ha_write_row(new_data); - if (table->found_next_number_field && new_data == table->record[0] && - !table->s->next_number_keypart) - set_auto_increment_if_higher(table->found_next_number_field->val_int()); reenable_binlog(thd); if (error) goto exit; @@ -3036,6 +3022,22 @@ int ha_partition::update_row(const uchar *old_data, uchar *new_data) } exit: + /* + if updating an auto_increment column, update + table_share->ha_data->next_auto_inc_val if needed. + (not to be used if auto_increment on secondary field in a multi-column + index) + mysql_update does not set table->next_number_field, so we use + table->found_next_number_field instead. + */ + if (table->found_next_number_field && new_data == table->record[0] && + !table->s->next_number_keypart) + { + HA_DATA_PARTITION *ha_data= (HA_DATA_PARTITION*) table_share->ha_data; + if (!ha_data->auto_inc_initialized) + info(HA_STATUS_AUTO); + set_auto_increment_if_higher(table->found_next_number_field->val_int()); + } table->timestamp_field_type= orig_timestamp_type; DBUG_RETURN(error); } |