forked from mysql/mysql-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BUG#22028117 - MYSQLCLIENT DOES NOT RETURN CORRECT
MYSQL_INSERT_ID VIA DATABASE HANDLE DESCRIPTION =========== mysql_insert_id() does not return correct values after performing inserts in a table containing an AUTO_INCREMENT field and then performing a SELECT operation. The value of insert_id is getting reset to 0 after performing SELECT. However, LAST_INSERT_ID() gives the correct value. ANALYSIS ======== An OK packet is sent from the server to the client to signal successful completion of a command. As of MySQL 5.7.5, OK packes are also used to indicate EOF, as EOF packets are deprecated. The packet identifier 0x00 represents an OK packet whereas the packet identifier OxFE represents an EOF packet. The EOF packet has valid values for the following fields: packet header, warnings and server status. The fields affected_rows and insert_id will have valid values only if it was an OK packet and not for an EOF packet. Reading the values of the above two fields for an EOF packet will result in inconsistent values being assigned to the connection handle. FIX ==== The fix is to assign the affected_rows and insert_id fields to the connection handle only if they were read from an OK packet. In case of an EOF packet, skip the assignment and proceed to the next valid fields. This way we can make sure that they don't get wrongly updated in the connection handle.
- Loading branch information
Anushree Prakash B
committed
Feb 20, 2017
1 parent
1202cdb
commit 06484ed
Showing
2 changed files
with
93 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters