Once again, the record is properly created! So even though the record was inserted into the table, LAST_INSERT_ID() returns 0.
I can set a breakpoint on the below DEALLOCATE line, go to a query window and execute the EXACT same statement that's being EXECUTEd and it works fine, returning the LAST_INSERT_ID().
I've spent hours trying to figure out this issue, and the only conclusion I can come up with is that dbForge is somehow engaging in different pool usage on the back-end of MySQL and it's causing LAST_INSERT_ID() to get out of sync when EXECUTE is called. Or perhaps a deeper bug with MySQL?
This is causing a LOT of problems when debugging. This is reproducible 100% of the time and ONLY happens with the below code:
Code: Select all
SET @mysql := var_sql_insert;
PREPARE SQLStatement1 FROM @mysql;
EXECUTE SQLStatement1;
DEALLOCATE PREPARE SQLStatement1;
SET var_index = LAST_INSERT_ID();
Code: Select all
INSERT INTO sourcing_item_data (detail_text) VALUES ('hello!')