summaryrefslogtreecommitdiff
path: root/sql/ha_partition.cc
diff options
context:
space:
mode:
authorMattias Jonsson <mattias.jonsson@sun.com>2010-03-04 18:16:10 +0100
committerMattias Jonsson <mattias.jonsson@sun.com>2010-03-04 18:16:10 +0100
commit1f77c7b49a976026522aba4ff766702b7a76346d (patch)
tree031a05a024ef97a5600d3d6441dcb34deb2df7d1 /sql/ha_partition.cc
parentee4a3099b3ebf0c9b448e4404665bb0a8638dc3f (diff)
downloadmariadb-git-1f77c7b49a976026522aba4ff766702b7a76346d.tar.gz
Bug#50392: insert_id is not reset for partitioned tables
auto_increment on duplicate entry The bug was that when INSERT_ID was used and the storage engine was told to release any reserved but not used auto_increment values, it set the highest auto_increment value to INSERT_ID. The fix was to check if the auto_increment value was forced by user (INSERT_ID) or by slave-thread, i.e. not auto- generated. So that it is only allowed to release generated values. mysql-test/r/partition_error.result: Bug#50392: insert_id is not reset for partitioned tables auto_increment on duplicate entry updated result mysql-test/suite/parts/inc/partition_auto_increment.inc: Bug#50392: insert_id is not reset for partitioned tables auto_increment on duplicate entry Added test mysql-test/suite/parts/r/partition_auto_increment_archive.result: Bug#50392: insert_id is not reset for partitioned tables auto_increment on duplicate entry Added result, note that archive does only allow increasing auto_increment values mysql-test/suite/parts/r/partition_auto_increment_blackhole.result: Bug#50392: insert_id is not reset for partitioned tables auto_increment on duplicate entry Added result, note that blackhole accepts all inserts :) mysql-test/suite/parts/r/partition_auto_increment_innodb.result: Bug#50392: insert_id is not reset for partitioned tables auto_increment on duplicate entry Added result, note that innodb rolls back inserts on error, but keeps the auto_increment value. mysql-test/suite/parts/r/partition_auto_increment_memory.result: Bug#50392: insert_id is not reset for partitioned tables auto_increment on duplicate entry Added result, note that memory and myisam inserts all rows before the error. mysql-test/suite/parts/r/partition_auto_increment_myisam.result: Bug#50392: insert_id is not reset for partitioned tables auto_increment on duplicate entry Added result, note that memory and myisam inserts all rows before the error. mysql-test/suite/parts/r/partition_auto_increment_ndb.result: Bug#50392: insert_id is not reset for partitioned tables auto_increment on duplicate entry Added result, note that NDB does not seem to handle INSERT_ID as other engines. (Martin will look into it). mysql-test/t/partition_error.test: Bug#50392: insert_id is not reset for partitioned tables auto_increment on duplicate entry Added test sql/ha_partition.cc: Bug#50392: insert_id is not reset for partitioned tables auto_increment on duplicate entry If the next_insert_id comes from non generated (i.e forced by INSERT_ID or slave-thread) then we cannot lower the reserved auto_increment value, since it have not reserved any values.
Diffstat (limited to 'sql/ha_partition.cc')
-rw-r--r--sql/ha_partition.cc15
1 files changed, 14 insertions, 1 deletions
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index 1d4290c6ab0..ddeeab56968 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -6454,9 +6454,22 @@ void ha_partition::release_auto_increment()
ulonglong next_auto_inc_val;
lock_auto_increment();
next_auto_inc_val= ha_data->next_auto_inc_val;
+ /*
+ If the current auto_increment values is lower than the reserved
+ value, and the reserved value was reserved by this thread,
+ we can lower the reserved value.
+ */
if (next_insert_id < next_auto_inc_val &&
auto_inc_interval_for_cur_row.maximum() >= next_auto_inc_val)
- ha_data->next_auto_inc_val= next_insert_id;
+ {
+ THD *thd= ha_thd();
+ /*
+ Check that we do not lower the value because of a failed insert
+ with SET INSERT_ID, i.e. forced/non generated values.
+ */
+ if (thd->auto_inc_intervals_forced.maximum() < next_insert_id)
+ ha_data->next_auto_inc_val= next_insert_id;
+ }
DBUG_PRINT("info", ("ha_data->next_auto_inc_val: %lu",
(ulong) ha_data->next_auto_inc_val));