Bug #43261 Server crashes while slave is executing master statement from stored routine
Submitted: 27 Feb 2009 13:23 Modified: 27 Feb 2009 15:56
Reporter: Eram Artinian Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Replication Severity:S3 (Non-critical)
Version:5.0.77 OS:Windows (XP64)
Assigned to: CPU Architecture:Any
Tags: exception 0xc0000005, name_const, replication, stored routine

[27 Feb 2009 13:23] Eram Artinian
Description:
MySql server 5.0.77 crashes at every try to execute a statement from the master binlog throwing an exception 0xc0000005 just after starting replication.

After downgrading to 5.0.67 the slave process reported an error "Slave: Error 'Incorrect arguments to NAME_CONST' on query" but the server didn't crash. 

The error may be related to the incorrectly formed binlog master record regarding the NAME_CONST function parameters collation (see Bug#39182 and bug #39283) that should be corrected in version 5.0.77:

master statement: 

CREATE TABLE IF NOT EXISTS test.daily_avg_level (Station INT(5) NOT NULL,DATSa DATE NOT NULL,DailyAvgLevel FLOAT NOT NULL,PRIMARY KEY (Station,DATSa)) ENGINE MEMORY
SELECT Station,DATE_FORMAT(Dat,'%Y-%m-%d') AS DATSa,ROUND(AVG(auto_hydro_1h.Stoej),0) AS DailyAvgLevel from auto_hydro_1h
WHERE date_format(Dat,'%Y-%m-%d')=date_format(DATS,'%Y-%m-%d')
GROUP BY Station,DATSa;

statement to be executed by the slave:

CREATE TEMPORARY TABLE IF NOT EXISTS test.daily_avg_level (Station INT(5) NOT NULL,DATSa DATE NOT NULL,DailyAvgLevel FLOAT NOT NULL,PRIMARY KEY (Station,DATSa)) ENGINE MEMORY
SELECT Station,DATE_FORMAT(Dat,'%Y-%m-%d') AS DATSa,ROUND(AVG(auto_hydro_1h.Stoej),0) AS DailyAvgLevel from auto_hydro_1h
WHERE date_format(Dat,'%Y-%m-%d')= NAME_CONST('DATS',_binary'2009-02-23' COLLATE 'binary')
GROUP BY Station,DATSa

How to repeat:
In a master-slave configuration version 5.0.77 create a stored routine on the master with one parameter variable YYY of type DATE, containing a select statement with use of the construction "WHERE date_format(xxx,'%Y-%m-%d')=date_format(YYY,'%Y-%m-%d')". The server where the slave process is running will keep crashing.

Suggested fix:
To see if bug 39283 is not appearing in connection with NAME_CONST parameters collation when DATE type is passed to a stored routine
[27 Feb 2009 13:53] Eram Artinian
lines from the error.log with backtrace

Attachment: MySQL_5_0_77_crash.txt (text/plain), 2.67 KiB.

[27 Feb 2009 15:56] Valeriy Kravchuk
This is a duplicate of bug #42014 (fixed in 5.0.78).