Details
-
Bug
-
Status: Closed (View Workflow)
-
Minor
-
Resolution: Not a Bug
-
10.11.11
-
debian 12 on amd64
-
Not for Release Notes
Description
Hello,
function last_insert_id() delivers correct and expected values before and after "insert" statement execued on first table modified within stored procedure.
function last_insert_id() seems to deliver unexpected/wrong values before and after "insert" statement on second table modified within the same stored procedure.
Both tables rely on "int unsigned" primary keys with "auto_increment" flag set.
This finding was initially discovered on two tables with primary keys of type "serial".
use-case:
function last_insert_id() precedes and follows "insert" command, their results get compared in aim to verify if insert was successful.
business use-case:
Transaction within stored procedure modifies both tables with commit or
transaction gets rolled back.
How to verify the finding:
import attached 'sandbox' schema with 2 tables and 1 stored procedure into your Maria instance, please execute
call Sandbox();
from within mysql client several times.
Calls of procedure "Sandbox" display expected values of variables pairs "var1_before" and "var1_after": var1_after is bigger than var1_before.
Results for pairs of values of var2_before and var2_after variables remain inconsistent.