Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-16958

Assertion `field_length < 5' failed in Field_year::val_str or data corruption upon SELECT with UNION and aggregate functions

    XMLWordPrintable

    Details

      Description

      CREATE TABLE t1 (f YEAR);
      INSERT IGNORE INTO t1 VALUES (1971),(1972);
      SELECT MAX( NULLIF( f, '1900' ) ) AS f FROM t1 UNION SELECT MAX( NULLIF( f, '1900' ) ) AS f FROM t1;
       
      # Cleanup
      DROP TABLE t1;
      

      10.1 5b735e8f09c debug

      mysqld: /data/src/10.1/sql/field.cc:6276: virtual String* Field_year::val_str(String*, String*): Assertion `field_length < 5' failed.
      181031 17:43:14 [ERROR] mysqld got signal 6 ;
       
      #7  0x00007f11a7d5fee2 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
      #8  0x0000558470fe80ff in Field_year::val_str (this=0x7f1190173328, val_buffer=0x7f11a2039420, val_ptr=0x7f11a2039420) at /data/src/10.2-bug/sql/field.cc:6325
      #9  0x0000558470ccba07 in Field::val_str (this=0x7f1190173328, str=0x7f11a2039420) at /data/src/10.2-bug/sql/field.h:865
      #10 0x0000558470cc9e59 in Protocol_text::store (this=0x7f11900010b8, field=0x7f1190173328) at /data/src/10.2-bug/sql/protocol.cc:1245
      #11 0x000055847102e621 in Item_field::send (this=0x7f1190015a40, protocol=0x7f11900010b8, buffer=0x7f11a20397c0) at /data/src/10.2-bug/sql/item.cc:7149
      #12 0x0000558470cc8f34 in Protocol::send_result_set_row (this=0x7f11900010b8, row_items=0x7f1190004d70) at /data/src/10.2-bug/sql/protocol.cc:979
      #13 0x0000558470d4ab36 in select_send::send_data (this=0x7f1190014550, items=...) at /data/src/10.2-bug/sql/sql_class.cc:2703
      #14 0x0000558470e04c4c in end_send (join=0x7f119015f960, join_tab=0x7f1190160ca8, end_of_records=false) at /data/src/10.2-bug/sql/sql_select.cc:19902
      #15 0x0000558470e02728 in evaluate_join_record (join=0x7f119015f960, join_tab=0x7f11901608f8, error=0) at /data/src/10.2-bug/sql/sql_select.cc:18954
      #16 0x0000558470e02032 in sub_select (join=0x7f119015f960, join_tab=0x7f11901608f8, end_of_records=false) at /data/src/10.2-bug/sql/sql_select.cc:18734
      #17 0x0000558470e015cb in do_select (join=0x7f119015f960, procedure=0x0) at /data/src/10.2-bug/sql/sql_select.cc:18278
      #18 0x0000558470ddbbbb in JOIN::exec_inner (this=0x7f119015f960) at /data/src/10.2-bug/sql/sql_select.cc:3601
      #19 0x0000558470ddb068 in JOIN::exec (this=0x7f119015f960) at /data/src/10.2-bug/sql/sql_select.cc:3396
      #20 0x0000558470ddc233 in mysql_select (thd=0x7f1190000b00, tables=0x7f1190004730, wild_num=0, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=268435456, result=0x7f1190014550, unit=0x7f11900046e0, select_lex=0x7f1190013518) at /data/src/10.2-bug/sql/sql_select.cc:3796
      #21 0x0000558470e7bcd3 in st_select_lex_unit::exec (this=0x7f11900046e0) at /data/src/10.2-bug/sql/sql_union.cc:1161
      #22 0x0000558470e77ed6 in mysql_union (thd=0x7f1190000b00, lex=0x7f1190004618, result=0x7f1190014550, unit=0x7f11900046e0, setup_tables_done_option=0) at /data/src/10.2-bug/sql/sql_union.cc:41
      #23 0x0000558470dd0453 in handle_select (thd=0x7f1190000b00, lex=0x7f1190004618, result=0x7f1190014550, setup_tables_done_option=0) at /data/src/10.2-bug/sql/sql_select.cc:354
      #24 0x0000558470d9bc87 in execute_sqlcom_select (thd=0x7f1190000b00, all_tables=0x7f1190012b00) at /data/src/10.2-bug/sql/sql_parse.cc:6477
      #26 0x0000558470d9faec in mysql_parse (thd=0x7f1190000b00, rawbuf=0x7f1190012488 "SELECT MAX( NULLIF( f, '1900' ) ) AS f FROM t1 UNION SELECT MAX( NULLIF( f, '1900' ) ) AS f FROM t1", length=99, parser_state=0x7f11a203b200, is_com_multi=false, is_next_command=false) at /data/src/10.2-bug/sql/sql_parse.cc:8009
      #27 0x0000558470d8d56a in dispatch_command (command=COM_QUERY, thd=0x7f1190000b00, packet=0x7f119008ca41 "", packet_length=99, is_com_multi=false, is_next_command=false) at /data/src/10.2-bug/sql/sql_parse.cc:1824
      #28 0x0000558470d8becd in do_command (thd=0x7f1190000b00) at /data/src/10.2-bug/sql/sql_parse.cc:1378
      #29 0x0000558470edd6a6 in do_handle_one_connection (connect=0x5584733123e0) at /data/src/10.2-bug/sql/sql_connect.cc:1335
      #30 0x0000558470edd433 in handle_one_connection (arg=0x5584733123e0) at /data/src/10.2-bug/sql/sql_connect.cc:1241
      #31 0x00005584712ffa50 in pfs_spawn_thread (arg=0x5584732f4fe0) at /data/src/10.2-bug/storage/perfschema/pfs.cc:1862
      #32 0x00007f11a9a36494 in start_thread (arg=0x7f11a203c700) at pthread_create.c:333
      #33 0x00007f11a7e1c93f in clone () from /lib/x86_64-linux-gnu/libc.so.6
      

      10.1 5b735e8f09c8 non-debug

      SELECT MAX( NULLIF( f, '1900' ) ) AS f FROM t1 UNION SELECT MAX( NULLIF( f, '1900' ) ) AS f FROM t1;
      f
      0072V0Mb�V�t
      

      Reproducible on 10.1, 10.2 with at least MyISAM and InnoDB.
      Not reproducible with the provided test case (and not observed so far in concurrent tests) on 10.0, 10.3, 10.4.

        Attachments

          Activity

            People

            Assignee:
            bar Alexander Barkov
            Reporter:
            elenst Elena Stepanova
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.