For performance reasons we remove the ability in unique indexes on autoincrements to remove the ability to insert key lower then the current autoincrement value.

This commit is contained in:
brian@zim.(none) 2007-01-26 14:17:45 -08:00
parent 24d9d866c2
commit 8820333ec3
3 changed files with 7 additions and 6 deletions

View File

@ -12367,6 +12367,7 @@ INSERT INTO t5 VALUES (NULL, "foo");
INSERT INTO t5 VALUES (NULL, "foo"); INSERT INTO t5 VALUES (NULL, "foo");
INSERT INTO t5 VALUES (32, "foo"); INSERT INTO t5 VALUES (32, "foo");
INSERT INTO t5 VALUES (23, "foo"); INSERT INTO t5 VALUES (23, "foo");
ERROR 23000: Can't write; duplicate key in table 't5'
INSERT INTO t5 VALUES (NULL, "foo"); INSERT INTO t5 VALUES (NULL, "foo");
INSERT INTO t5 VALUES (NULL, "foo"); INSERT INTO t5 VALUES (NULL, "foo");
INSERT INTO t5 VALUES (3, "foo"); INSERT INTO t5 VALUES (3, "foo");
@ -12380,7 +12381,6 @@ a b
4 foo 4 foo
5 foo 5 foo
32 foo 32 foo
23 foo
33 foo 33 foo
34 foo 34 foo
35 foo 35 foo

View File

@ -1379,6 +1379,7 @@ INSERT INTO t5 VALUES (NULL, "foo");
INSERT INTO t5 VALUES (NULL, "foo"); INSERT INTO t5 VALUES (NULL, "foo");
INSERT INTO t5 VALUES (NULL, "foo"); INSERT INTO t5 VALUES (NULL, "foo");
INSERT INTO t5 VALUES (32, "foo"); INSERT INTO t5 VALUES (32, "foo");
--error 1022
INSERT INTO t5 VALUES (23, "foo"); INSERT INTO t5 VALUES (23, "foo");
INSERT INTO t5 VALUES (NULL, "foo"); INSERT INTO t5 VALUES (NULL, "foo");
INSERT INTO t5 VALUES (NULL, "foo"); INSERT INTO t5 VALUES (NULL, "foo");

View File

@ -784,23 +784,22 @@ int ha_archive::write_row(byte *buf)
temp_auto= table->next_number_field->val_int(); temp_auto= table->next_number_field->val_int();
/* /*
Simple optimization to see if we fail for duplicate key immediatly We don't support decremening auto_increment. They make the performance
because we have just given out this value. just cry.
*/ */
if (temp_auto == share->archive_write.auto_increment && if (temp_auto <= share->archive_write.auto_increment &&
mkey->flags & HA_NOSAME) mkey->flags & HA_NOSAME)
{ {
rc= HA_ERR_FOUND_DUPP_KEY; rc= HA_ERR_FOUND_DUPP_KEY;
goto error; goto error;
} }
#ifdef DEAD_CODE
/* /*
Bad news, this will cause a search for the unique value which is very Bad news, this will cause a search for the unique value which is very
expensive since we will have to do a table scan which will lock up expensive since we will have to do a table scan which will lock up
all other writers during this period. This could perhaps be optimized all other writers during this period. This could perhaps be optimized
in the future. in the future.
*/ */
if (temp_auto < share->archive_write.auto_increment &&
mkey->flags & HA_NOSAME)
{ {
/* /*
First we create a buffer that we can use for reading rows, and can pass First we create a buffer that we can use for reading rows, and can pass
@ -838,6 +837,7 @@ int ha_archive::write_row(byte *buf)
} }
} }
} }
#endif
else else
{ {
if (temp_auto > share->archive_write.auto_increment) if (temp_auto > share->archive_write.auto_increment)