Bug #24347 passing LAST_INSERT_ID as argument in UDF by using trigger fails
Submitted: 15 Nov 2006 23:54 Modified: 3 May 2007 15:21
Reporter: Abu Aqil Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.0.27max OS:Linux (Linux)
Assigned to: Hartmut Holzgraefe CPU Architecture:Any
Tags: LAST_INSERT_ID, trigger, udf

[15 Nov 2006 23:54] Abu Aqil
Description:

Situation 1:
passing last insert  id value to udf using trigger fails. No value passed.

Situation 2:
i have also some weird problem with long arguments using udf with the same situation (using trigger and call udf with dozen of arguments) some of the argument are empty or populated with some binary. This problem happened only on my 9th argument (args->args[8]). 

I have 11 args all together :

 args->args[0] until args->[7] have correct values
 args->args[8] empty value
 args->args[9] until args->[10] have correct values

How to repeat:
delimiter ||
create trigger dbsync_trigger AFTER INSERT ON data_table
FOR EACH ROW
BEGIN
        SET @LASTID = LAST_INSERT_ID();
        INSERT INTO dbsync_journal SET dbsync_id='', username=NEW.username,
        dbsync_status=dbsyncinsert(@LASTID, NEW.username, NEW.data1, NEW.data2, NEW.data3, NEW.data4, NEW.data5, NEW.data6, NEW.data8, NEW.data9, NEW.data10);
END
||
delimiter ;

@LASTID dont have any value

Suggested fix:

temporary fix:

this will fix the the last insert id problem (inside my trigger):
and the problem with my 9th argument

BEGIN
...
dbsync_status=dbsyncinsert(substring(@LASTID,1), NEW.username, NEW.data1, NEW.data2, NEW.data3, NEW.data4, NEW.data5, NEW.data6, substring(NEW.data8,1), NEW.data9, NEW.data10);
---
END

however i end up putting substrings in all arguments just for preacaution...
[15 Nov 2006 23:56] Abu Aqil
-