Description:
The following test case crashes the server. The crash does not happen when the calculated column is omitted from the result or when the characteristic of the function is corrected to 'DETERMINISTIC'. The crash does not happen with 5.0.22.
Reported for 5.0.45, reproduced with 5.0.50. Reproduced with 5.1.22.
Linux stack trace:
#5 <signal handler called>
#6 0x0815fb0f in Field::offset (this=0x0,
record=0x8ddf1b8 "ÿ", '¥' <repeats 15 times>, "ÿ", '¥' <repeats 183 times>...) at field.h:382
#7 0x08267dca in create_tmp_table (thd=0x8d89ef0, param=0x8de5618,
fields=@0x8de56d4, group=0x8def228, distinct=false, save_sum_fields=false,
select_options=2149861889, rows_limit=4294967295, table_alias=0x85a857f "")
at sql_select.cc:9933
#8 0x082554b4 in JOIN::optimize (this=0x8de45d0) at sql_select.cc:1361
#9 0x08257d87 in mysql_select (thd=0x8d89ef0, rref_pointer_array=0x8d8b098,
tables=0x8dd7628, wild_num=0, fields=@0x8d8b028, conds=0x8de40f8,
og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0,
select_options=2149861889, result=0x8de45c0, unit=0x8d8ad34,
select_lex=0x8d8af94) at sql_select.cc:2257
How to repeat:
DROP TABLE IF EXISTS test.t1;
CREATE TABLE test.t1 (
id int(10) unsigned NOT NULL auto_increment,
barcode int(8) unsigned zerofill NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY barcode (barcode)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_german2_ci;
INSERT INTO test.t1 (id, barcode) VALUES (1, 12345678);
INSERT INTO test.t1 (id, barcode) VALUES (2, 12345679);
DROP TABLE IF EXISTS test.t2;
CREATE TABLE test.t2 (
id int(10) unsigned NOT NULL auto_increment,
barcode bigint(11) unsigned zerofill NOT NULL,
PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_german2_ci;
INSERT INTO test.t2 (id, barcode) VALUES (1, 12345106708);
INSERT INTO test.t2 (id, barcode) VALUES (2, 12345106709);
DELIMITER |
DROP FUNCTION IF EXISTS test.barcode_umsetzung |
CREATE FUNCTION test.barcode_umsetzung(barcode8 INT(8))
RETURNS BIGINT(11) UNSIGNED
READS SQL DATA
BEGIN
RETURN FLOOR(barcode8/1000)*1000000 + 100000 + FLOOR((barcode8 MOD 1000)/10)*100 + (barcode8 MOD 10);
END |
DELIMITER ;
SELECT DISTINCT
t1.barcode, test.barcode_umsetzung(t1.barcode)
FROM test.t1
INNER JOIN test.t2
ON test.barcode_umsetzung(t1.barcode)=t2.barcode
WHERE t1.barcode=12345678;