1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

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.
This commit is contained in:
unknown
2008-03-05 16:02:33 +03:00
parent 4f3eab5804
commit 0c1dd98ec8
2 changed files with 18 additions and 1 deletions

View File

@@ -3006,7 +3006,8 @@ bool select_insert::send_eof()
((thd->client_capabilities & CLIENT_FOUND_ROWS) ?
info.touched : info.updated);
id= autoinc_value_of_first_inserted_row > 0 ?
autoinc_value_of_first_inserted_row : thd->last_insert_id;
autoinc_value_of_first_inserted_row : thd->insert_id_used ?
thd->last_insert_id : 0;
::send_ok(thd, (ulong) thd->row_count_func, id, buff);
DBUG_RETURN(0);
}