diff options
author | unknown <kaa@kaamos.(none)> | 2008-03-05 16:02:33 +0300 |
---|---|---|
committer | unknown <kaa@kaamos.(none)> | 2008-03-05 16:02:33 +0300 |
commit | 0c1dd98ec883323fc79fd5ac558ed3d278a68c31 (patch) | |
tree | f32ed20f75eaab6c83bd857a5ce5a13326109f8d /tests | |
parent | 4f3eab58046a42f66abd68d547ad97a9d58ecb04 (diff) | |
download | mariadb-git-0c1dd98ec883323fc79fd5ac558ed3d278a68c31.tar.gz |
Fix for bug #34889: mysql_client_test::test_mysql_insert_id test fails
sporadically
Under some circumstances, the mysql_insert_id() value after SELECT ...
INSERT could return a wrong value. This could happen when the last
SELECT ... INSERT did not involve an AUTO_INCREMENT column, but the
value of mysql_insert_id() was changed by some previous statements.
Fixed by checking the value of thd->insert_id_used in
select_insert::send_eof() and returning 0 for mysql_insert_id() if it
is not set.
sql/sql_insert.cc:
Do not return thd->last_insert_id unconditionally in
select_insert::send_eof(). First check if thd->insert_id_used is
non-zero, and return 0 otherwise.
tests/mysql_client_test.c:
Added a test case for bug #34889.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/mysql_client_test.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 9cc2af25529..f8c554a06fd 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -15241,6 +15241,22 @@ static void test_mysql_insert_id() myquery(rc); res= mysql_insert_id(mysql); DIE_UNLESS(res == 0); + + /* + Test for bug #34889: mysql_client_test::test_mysql_insert_id test fails + sporadically + */ + rc= mysql_query(mysql, "create table t2 (f1 int not null primary key auto_increment, f2 varchar(255))"); + myquery(rc); + rc= mysql_query(mysql, "insert into t2 values (null,'b')"); + myquery(rc); + rc= mysql_query(mysql, "insert into t1 select 5,'c'"); + myquery(rc); + res= mysql_insert_id(mysql); + DIE_UNLESS(res == 0); + rc= mysql_query(mysql, "drop table t2"); + myquery(rc); + rc= mysql_query(mysql, "insert into t1 select null,'d'"); myquery(rc); res= mysql_insert_id(mysql); |