Bug #44144 | INSERT INTO in Stored Function, outside LAST_INSERT_ID() return old ID | ||
---|---|---|---|
Submitted: | 8 Apr 2009 9:17 | Modified: | 8 Apr 2009 12:40 |
Reporter: | Richard Teubel | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: Stored Routines | Severity: | S3 (Non-critical) |
Version: | 5.0.45-log, 5.0.51a-3ubuntu5.4-log | OS: | Linux |
Assigned to: | CPU Architecture: | Any | |
Tags: | insert into, LAST_INSERT_ID, Stored Functions |
[8 Apr 2009 9:17]
Richard Teubel
[8 Apr 2009 12:40]
Valeriy Kravchuk
Sorry, but this is not a bug. Please, read the manual, http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_last-insert-id: "Within the body of a stored routine (procedure or function) or a trigger, the value of LAST_INSERT_ID() changes the same way as for statements executed outside the body of these kinds of objects. The effect of a stored routine or trigger upon the value of LAST_INSERT_ID() that is seen by following statements depends on the kind of routine: - If a stored procedure executes statements that change the value of LAST_INSERT_ID(), the changed value will be seen by statements that follow the procedure call. - For stored functions and triggers that change the value, the value is restored when the function or trigger ends, so following statements will not see a changed value."