[MDEV-17217] Assertion `0' failed in make_sortkey upon ORDER BY with RPAD Created: 2018-09-17  Updated: 2023-07-21  Resolved: 2023-07-21

Status: Closed
Project: MariaDB Server
Component/s: Server
Affects Version/s: 5.5, 10.0, 10.1, 10.2, 10.3
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Oleksandr Byelkin
Resolution: Cannot Reproduce Votes: 0
Labels: None


 Description   

SET sql_mode= '';
CREATE TABLE t1 (c CHAR(1) NOT NULL);
INSERT IGNORE INTO t1 VALUES (''),('');
SELECT * FROM t1 ORDER BY RPAD('foo', 4, c);
 
# Cleanup
DROP TABLE t1;

5.5 e43bc02e7b275

mysqld: /data/src/5.5/sql/filesort.cc:934: void make_sortkey(SORTPARAM*, uchar*, uchar*): Assertion `0' failed.
180917 17:46:15 [ERROR] mysqld got signal 6 ;
 
#7  0x00007f9f5fbdaee2 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
#8  0x00000000007ac9af in make_sortkey (param=0x7f9f6164d240, to=0x7f9f5a421dd8 '\245' <repeats 90 times>, "h4z\025", ref_pos=0x7f9f6164d0b0 "") at /data/src/5.5/sql/filesort.cc:934
#9  0x00000000007ac1dc in find_all_keys (param=0x7f9f6164d240, select=0x7f9f5a580398, sort_keys=0x7f9f5a421d60, sort_keys_buf=0x7f9f5a421dd8 '\245' <repeats 90 times>, "h4z\025", buffpek_pointers=0x7f9f6164d450, tempfile=0x7f9f6164d2c0) at /data/src/5.5/sql/filesort.cc:757
#10 0x00000000007aaaea in filesort (thd=0x7f9f5b664060, table=0x7f9f5a5d9460, sortorder=0x7f9f5a580580, s_length=1, select=0x7f9f5a580398, max_rows=18446744073709551615, sort_positions=false, examined_rows=0x7f9f6164d6d8) at /data/src/5.5/sql/filesort.cc:250
#11 0x0000000000660f1a in create_sort_index (thd=0x7f9f5b664060, join=0x7f9f5a548d68, order=0x7f9f5a548c68, filesort_limit=18446744073709551615, select_limit=18446744073709551615, is_order_by=true) at /data/src/5.5/sql/sql_select.cc:20071
#12 0x0000000000637604 in JOIN::exec (this=0x7f9f5a548d68) at /data/src/5.5/sql/sql_select.cc:2882
#13 0x0000000000637ffa in mysql_select (thd=0x7f9f5b664060, rref_pointer_array=0x7f9f5b667d08, tables=0x7f9f5a548298, wild_num=1, fields=..., conds=0x0, og_num=1, order=0x7f9f5a548c68, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f9f5a548d48, unit=0x7f9f5b667388, select_lex=0x7f9f5b667a68) at /data/src/5.5/sql/sql_select.cc:3133
#14 0x000000000062e5b6 in handle_select (thd=0x7f9f5b664060, lex=0x7f9f5b6672d8, result=0x7f9f5a548d48, setup_tables_done_option=0) at /data/src/5.5/sql/sql_select.cc:323
#15 0x00000000006079ce in execute_sqlcom_select (thd=0x7f9f5b664060, all_tables=0x7f9f5a548298) at /data/src/5.5/sql/sql_parse.cc:4678
#16 0x0000000000600d4f in mysql_execute_command (thd=0x7f9f5b664060) at /data/src/5.5/sql/sql_parse.cc:2224
#17 0x000000000060a59a in mysql_parse (thd=0x7f9f5b664060, rawbuf=0x7f9f5a548078 "SELECT * FROM t1 ORDER BY RPAD('foo', 4, c)", length=43, parser_state=0x7f9f6164e640) at /data/src/5.5/sql/sql_parse.cc:5923
#18 0x00000000005fe2af in dispatch_command (command=COM_QUERY, thd=0x7f9f5b664060, packet=0x7f9f5f35b061 "SELECT * FROM t1 ORDER BY RPAD('foo', 4, c)", packet_length=43) at /data/src/5.5/sql/sql_parse.cc:1066
#19 0x00000000005fd4a1 in do_command (thd=0x7f9f5b664060) at /data/src/5.5/sql/sql_parse.cc:793
#20 0x0000000000700a21 in do_handle_one_connection (thd_arg=0x7f9f5b664060) at /data/src/5.5/sql/sql_connect.cc:1268
#21 0x00000000007007ae in handle_one_connection (arg=0x7f9f5b664060) at /data/src/5.5/sql/sql_connect.cc:1184
#22 0x0000000000a0ff43 in pfs_spawn_thread (arg=0x7f9f5c376fc0) at /data/src/5.5/storage/perfschema/pfs.cc:1015
#23 0x00007f9f61281494 in start_thread (arg=0x7f9f6164f700) at pthread_create.c:333
#24 0x00007f9f5fc9793f in clone () from /lib/x86_64-linux-gnu/libc.so.6

Reproducible with at least MyISAM and InnoDB.
No visible effect on non-debug builds.



 Comments   
Comment by Alice Sherepa [ 2023-07-21 ]

not reproducible on 10.4 (4b3f93063958834e3d)-11.0 now

Generated at Thu Feb 08 08:34:47 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.