Bug #6466 | @@LAST_INSERT_ID out-dated in stored procedure | ||
---|---|---|---|
Submitted: | 5 Nov 2004 15:52 | Modified: | 6 Nov 2004 15:52 |
Reporter: | Michael Kofler | Email Updates: | |
Status: | Can't repeat | Impact on me: | |
Category: | MySQL Server | Severity: | S3 (Non-critical) |
Version: | 5.0.2 compiled Nov. 04 2004 | OS: | Linux (linux) |
Assigned to: | CPU Architecture: | Any |
[5 Nov 2004 15:52]
Michael Kofler
[6 Nov 2004 15:52]
Alexander Keremidarski
5.0 compiled from ChangeSet@1.1631, 2004-11-05 22:49:15-08:00, brian@avenger.(none) always returns 3 equal values as expected
[6 Nov 2004 16:10]
Michael Kofler
CREATE PROCEDURE `test`.`test_last_insert_id`() BEGIN DROP TABLE IF EXISTS _test; CREATE TABLE _test (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT) ENGINE = MyISAM; INSERT INTO _test (b) VALUES (123); SELECT LAST_INSERT_ID(), @@last_insert_id, @@identity; INSERT INTO _test (b) VALUES (123); SELECT LAST_INSERT_ID(), @@last_insert_id, @@identity; END --- mysql> call test_last_insert_id(); +------------------+------------------+------------+ | LAST_INSERT_ID() | @@last_insert_id | @@identity | +------------------+------------------+------------+ | 1 | 1 | 1 | +------------------+------------------+------------+ 1 row in set (0,13 sec) +------------------+------------------+------------+ | LAST_INSERT_ID() | @@last_insert_id | @@identity | +------------------+------------------+------------+ | 2 | 1 | 1 | +------------------+------------------+------------+ 1 row in set (0,14 sec) Query OK, 0 rows affected (0,14 sec)