[MDEV-22758] Assertion `!item->null_value' failed in Type_handler_inet6::make_sort_key_part Created: 2020-05-30  Updated: 2020-06-03  Resolved: 2020-06-03

Status: Closed
Project: MariaDB Server
Component/s: Data types
Affects Version/s: 10.5
Fix Version/s: 10.5.4

Type: Bug Priority: Critical
Reporter: Elena Stepanova Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-20784 Testing for MDEV-274 (INET6, data typ... Closed

 Description   

CREATE TABLE t1 (a VARCHAR(8) NOT NULL, b INET6 NOT NULL);
INSERT INTO t1 VALUES ('foo','::'),('bar','1::1');
SELECT * FROM t1 ORDER BY CASE WHEN a THEN b ELSE a END;
 
# Cleanup
DROP TABLE t1;

10.5 debug 043828bd

mariadbd: /data/src/10.5/plugin/type_inet/sql_type_inet.cc:1380: virtual void Type_handler_inet6::make_sort_key_part(uchar*, Item*, const SORT_FIELD_ATTR*, Sort_param*) const: Assertion `!item->null_value' failed.
200531  2:10:06 [ERROR] mysqld got signal 6 ;
 
#7  0x00007f47d4feef12 in __GI___assert_fail (assertion=0x55b5c9410fab "!item->null_value", file=0x55b5c9410bf0 "/data/src/10.5/plugin/type_inet/sql_type_inet.cc", line=1380, function=0x55b5c9411400 <Type_handler_inet6::make_sort_key_part(unsigned char*, Item*, SORT_FIELD_ATTR const*, Sort_param*) const::__PRETTY_FUNCTION__> "virtual void Type_handler_inet6::make_sort_key_part(uchar*, Item*, const SORT_FIELD_ATTR*, Sort_param*) const") at assert.c:101
#8  0x000055b5c8dbe550 in Type_handler_inet6::make_sort_key_part (this=0x55b5ca4e5050 <type_handler_inet6>, to=0x7f47b4066538 '\245' <repeats 200 times>..., item=0x7f47b4015330, sort_field=0x7f47b4017e98, param=0x7f47d038c090) at /data/src/10.5/plugin/type_inet/sql_type_inet.cc:1380
#9  0x000055b5c83db235 in make_sortkey (param=0x7f47d038c090, to=0x7f47b4066538 '\245' <repeats 200 times>...) at /data/src/10.5/sql/filesort.cc:3012
#10 0x000055b5c83d6ba5 in make_sortkey (param=0x7f47d038c090, to=0x7f47b4066538 '\245' <repeats 200 times>..., ref_pos=0x7f47b41abcb8 "", using_packed_sortkeys=false) at /data/src/10.5/sql/filesort.cc:1338
#11 0x000055b5c83d5821 in find_all_keys (thd=0x7f47b4000b18, param=0x7f47d038c090, select=0x7f47b4017540, fs_info=0x7f47b40661c0, buffpek_pointers=0x7f47d038c2a0, tempfile=0x7f47d038c130, pq=0x0, found_rows=0x7f47b40663b0) at /data/src/10.5/sql/filesort.cc:955
#12 0x000055b5c83d380d in filesort (thd=0x7f47b4000b18, table=0x7f47b40f8ca8, filesort=0x7f47b4017710, tracker=0x7f47b4017e00, join=0x7f47b4015610, first_table_bit=1) at /data/src/10.5/sql/filesort.cc:361
#13 0x000055b5c8114b44 in create_sort_index (thd=0x7f47b4000b18, join=0x7f47b4015610, tab=0x7f47b4016c00, fsort=0x7f47b4017710) at /data/src/10.5/sql/sql_select.cc:23870
#14 0x000055b5c810ebaa in st_join_table::sort_table (this=0x7f47b4016c00) at /data/src/10.5/sql/sql_select.cc:21599
#15 0x000055b5c810e785 in join_init_read_record (tab=0x7f47b4016c00) at /data/src/10.5/sql/sql_select.cc:21538
#16 0x000055b5c810c51d in sub_select (join=0x7f47b4015610, join_tab=0x7f47b4016c00, end_of_records=false) at /data/src/10.5/sql/sql_select.cc:20612
#17 0x000055b5c810b9de in do_select (join=0x7f47b4015610, procedure=0x0) at /data/src/10.5/sql/sql_select.cc:20149
#18 0x000055b5c80df771 in JOIN::exec_inner (this=0x7f47b4015610) at /data/src/10.5/sql/sql_select.cc:4464
#19 0x000055b5c80de89d in JOIN::exec (this=0x7f47b4015610) at /data/src/10.5/sql/sql_select.cc:4245
#20 0x000055b5c80dffce in mysql_select (thd=0x7f47b4000b18, tables=0x7f47b4014018, fields=..., conds=0x0, og_num=1, order=0x7f47b4015478, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f47b40155e8, unit=0x7f47b4004b30, select_lex=0x7f47b4013a20) at /data/src/10.5/sql/sql_select.cc:4669
#21 0x000055b5c80cfae4 in handle_select (thd=0x7f47b4000b18, lex=0x7f47b4004a68, result=0x7f47b40155e8, setup_tables_done_option=0) at /data/src/10.5/sql/sql_select.cc:429
#22 0x000055b5c809516d in execute_sqlcom_select (thd=0x7f47b4000b18, all_tables=0x7f47b4014018) at /data/src/10.5/sql/sql_parse.cc:6207
#23 0x000055b5c808c4c7 in mysql_execute_command (thd=0x7f47b4000b18) at /data/src/10.5/sql/sql_parse.cc:3939
#24 0x000055b5c8099fb9 in mysql_parse (thd=0x7f47b4000b18, rawbuf=0x7f47b4013950 "SELECT * FROM t1 ORDER BY CASE WHEN a THEN b ELSE a END", length=55, parser_state=0x7f47d038d520, is_com_multi=false, is_next_command=false) at /data/src/10.5/sql/sql_parse.cc:7991
#25 0x000055b5c8086365 in dispatch_command (command=COM_QUERY, thd=0x7f47b4000b18, packet=0x7f47b41b0409 "", packet_length=55, is_com_multi=false, is_next_command=false) at /data/src/10.5/sql/sql_parse.cc:1875
#26 0x000055b5c8084a9d in do_command (thd=0x7f47b4000b18) at /data/src/10.5/sql/sql_parse.cc:1356
#27 0x000055b5c82285fb in do_handle_one_connection (connect=0x55b5cb060508, put_in_cache=true) at /data/src/10.5/sql/sql_connect.cc:1411
#28 0x000055b5c8228363 in handle_one_connection (arg=0x55b5cb072658) at /data/src/10.5/sql/sql_connect.cc:1313
#29 0x000055b5c875f2de in pfs_spawn_thread (arg=0x55b5caffb888) at /data/src/10.5/storage/perfschema/pfs.cc:2201
#30 0x00007f47d6f774a4 in start_thread (arg=0x7f47d038e700) at pthread_create.c:456
#31 0x00007f47d50abd0f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:97

Non-debug build produces warnings about data truncation, which is probably correct:

SELECT * FROM t1 ORDER BY CASE WHEN a THEN b ELSE a END;
a	b
bar	1::1
foo	::
Warnings:
Warning	1292	Truncated incorrect DOUBLE value: 'foo'
Warning	1292	Incorrect inet6 value: 'foo'
Warning	1292	Truncated incorrect DOUBLE value: 'bar'
Warning	1292	Incorrect inet6 value: 'bar'



 Comments   
Comment by Alexander Barkov [ 2020-06-03 ]

Also repeatable with this script:

CREATE OR REPLACE TABLE t1 (a VARCHAR(8) NOT NULL);
INSERT INTO t1 VALUES ('foo'),('bar');
SELECT * FROM t1 ORDER BY CAST(a AS INET6);

Generated at Thu Feb 08 09:17:14 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.