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

Wrong result or Assertion `0' failed in Item::val_native upon query with TIMESTAMP field, NULLIF and ROLLUP

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 10.4, 10.5
    • Fix Version/s: 10.4, 10.5
    • Component/s: Temporal Types
    • Labels:
      None

      Description

      CREATE TABLE t1 (s TIMESTAMP);
      INSERT INTO t1 VALUES ('2033-06-06'),('2015-09-10');
      SELECT NULLIF( s, NULL ) AS f FROM t1 GROUP BY s WITH ROLLUP;
       
      # Cleanup
      DROP TABLE t1;
      

      10.4 non-debug bf2a2444

      SELECT NULLIF( s, NULL ) AS f FROM t1 GROUP BY s WITH ROLLUP;
      f
      2033-06-06 00:00:00
      2033-06-06 00:00:00
      NULL
      

      The expected result is

      10.3

      SELECT NULLIF( s, NULL ) AS f FROM t1 GROUP BY s WITH ROLLUP;
      f
      2015-09-10 00:00:00
      2033-06-06 00:00:00
      NULL
      

      10.4 debug bf2a2444

      mysqld: /data/src/10.4/sql/item.h:1344: virtual bool Item::val_native(THD*, Native*): Assertion `0' failed.
      200613 17:07:15 [ERROR] mysqld got signal 6 ;
       
      #7  0x00007f158b3e1f12 in __GI___assert_fail (assertion=0x560fb2c5a400 "0", file=0x560fb2c5a3d3 "/data/src/10.4/sql/item.h", line=1344, function=0x560fb2c5a940 <Item::val_native(THD*, Native*)::__PRETTY_FUNCTION__> "virtual bool Item::val_native(THD*, Native*)") at assert.c:101
      #8  0x0000560fb1e6e770 in Item::val_native (this=0x7f1574017150, thd=0x7f1574000af0, to=0x7f1585589da0) at /data/src/10.4/sql/item.h:1344
      #9  0x0000560fb2027fcf in Item::val_native_from_item (this=0x7f1574015658, thd=0x7f1574000af0, item=0x7f1574017150, to=0x7f1585589da0) at /data/src/10.4/sql/item.h:867
      #10 0x0000560fb231ccec in Item_ref::val_native (this=0x7f1574015658, thd=0x7f1574000af0, to=0x7f1585589da0) at /data/src/10.4/sql/item.cc:8268
      #11 0x0000560fb21b9b49 in Type_handler_timestamp_common::Item_val_native_with_conversion (this=0x560fb375ac00 <type_handler_timestamp2>, thd=0x7f1574000af0, item=0x7f1574015658, to=0x7f1585589da0) at /data/src/10.4/sql/sql_type.cc:8261
      #12 0x0000560fb2257390 in Item::val_native_with_conversion (this=0x7f1574015658, thd=0x7f1574000af0, to=0x7f1585589da0, th=0x560fb375ac00 <type_handler_timestamp2>) at /data/src/10.4/sql/item.h:1302
      #13 0x0000560fb2257342 in Item::val_native_with_conversion_from_item (this=0x7f15740138d0, thd=0x7f1574000af0, item=0x7f1574015658, to=0x7f1585589da0, handler=0x560fb375ac00 <type_handler_timestamp2>) at /data/src/10.4/sql/item.h:881
      #14 0x0000560fb2337da6 in Item_func_nullif::native_op (this=0x7f15740138d0, thd=0x7f1574000af0, to=0x7f1585589da0) at /data/src/10.4/sql/item_cmpfunc.cc:2934
      #15 0x0000560fb1f7515f in Item_func_hybrid_field_type::val_native (this=0x7f15740138d0, thd=0x7f1574000af0, to=0x7f1585589da0) at /data/src/10.4/sql/item_func.h:783
      #16 0x0000560fb21b9f32 in Timestamp_or_zero_datetime_native_null::Timestamp_or_zero_datetime_native_null (this=0x7f1585589da0, thd=0x7f1574000af0, item=0x7f15740138d0, conv=false) at /data/src/10.4/sql/sql_type.cc:8305
      #17 0x0000560fb21be70b in Timestamp_or_zero_datetime_native_null::Timestamp_or_zero_datetime_native_null (this=0x7f1585589da0, thd=0x7f1574000af0, item=0x7f15740138d0) at /data/src/10.4/sql/sql_type.h:2521
      #18 0x0000560fb21b474b in Type_handler::Item_send_timestamp (this=0x560fb375ac00 <type_handler_timestamp2>, item=0x7f15740138d0, protocol=0x7f15740010b8, buf=0x7f1585589eb0) at /data/src/10.4/sql/sql_type.cc:6832
      #19 0x0000560fb21c20fc in Type_handler_timestamp_common::Item_send (this=0x560fb375ac00 <type_handler_timestamp2>, item=0x7f15740138d0, protocol=0x7f15740010b8, buf=0x7f1585589eb0) at /data/src/10.4/sql/sql_type.h:5656
      #20 0x0000560fb1e6e4ec in Item::send (this=0x7f15740138d0, protocol=0x7f15740010b8, buffer=0x7f1585589eb0) at /data/src/10.4/sql/item.h:1038
      #21 0x0000560fb1e68637 in Protocol::send_result_set_row (this=0x7f15740010b8, row_items=0x7f15740154a0) at /data/src/10.4/sql/protocol.cc:1035
      #22 0x0000560fb1f1d2a2 in select_send::send_data (this=0x7f1574014cc0, items=...) at /data/src/10.4/sql/sql_class.cc:2998
      #23 0x0000560fb201d7c1 in JOIN::rollup_send_data (this=0x7f1574014ce8, idx=0) at /data/src/10.4/sql/sql_select.cc:25938
      #24 0x0000560fb2012937 in end_send_group (join=0x7f1574014ce8, join_tab=0x7f1574016718, end_of_records=true) at /data/src/10.4/sql/sql_select.cc:21730
      #25 0x0000560fb200ee31 in sub_select (join=0x7f1574014ce8, join_tab=0x7f1574016370, end_of_records=true) at /data/src/10.4/sql/sql_select.cc:20329
      #26 0x0000560fb200e55a in do_select (join=0x7f1574014ce8, procedure=0x0) at /data/src/10.4/sql/sql_select.cc:19920
      #27 0x0000560fb1fe33bd in JOIN::exec_inner (this=0x7f1574014ce8) at /data/src/10.4/sql/sql_select.cc:4470
      #28 0x0000560fb1fe24fa in JOIN::exec (this=0x7f1574014ce8) at /data/src/10.4/sql/sql_select.cc:4252
      #29 0x0000560fb1fe3c0f in mysql_select (thd=0x7f1574000af0, tables=0x7f1574013b90, wild_num=0, fields=..., conds=0x0, og_num=1, order=0x0, group=0x7f1574014380, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f1574014cc0, unit=0x7f1574004a18, select_lex=0x7f1574013278) at /data/src/10.4/sql/sql_select.cc:4684
      #30 0x0000560fb1fd36f2 in handle_select (thd=0x7f1574000af0, lex=0x7f1574004958, result=0x7f1574014cc0, setup_tables_done_option=0) at /data/src/10.4/sql/sql_select.cc:422
      #31 0x0000560fb1f9a21c in execute_sqlcom_select (thd=0x7f1574000af0, all_tables=0x7f1574013b90) at /data/src/10.4/sql/sql_parse.cc:6360
      #32 0x0000560fb1f908a9 in mysql_execute_command (thd=0x7f1574000af0) at /data/src/10.4/sql/sql_parse.cc:3898
      #33 0x0000560fb1f9e1c9 in mysql_parse (thd=0x7f1574000af0, rawbuf=0x7f1574013198 "SELECT  NULLIF( s, NULL ) AS f FROM t1 GROUP BY s WITH ROLLUP", length=61, parser_state=0x7f158558b570, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:7901
      #34 0x0000560fb1f8a753 in dispatch_command (command=COM_QUERY, thd=0x7f1574000af0, packet=0x7f15740083a1 "", packet_length=61, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:1842
      #35 0x0000560fb1f88ef5 in do_command (thd=0x7f1574000af0) at /data/src/10.4/sql/sql_parse.cc:1360
      #36 0x0000560fb2111aa8 in do_handle_one_connection (connect=0x560fb496cce0) at /data/src/10.4/sql/sql_connect.cc:1412
      #37 0x0000560fb21117f7 in handle_one_connection (arg=0x560fb496cce0) at /data/src/10.4/sql/sql_connect.cc:1316
      #38 0x0000560fb2b0fda1 in pfs_spawn_thread (arg=0x560fb4988900) at /data/src/10.4/storage/perfschema/pfs.cc:1869
      #39 0x00007f158d36a4a4 in start_thread (arg=0x7f158558c700) at pthread_create.c:456
      #40 0x00007f158b49ed0f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:97
      

      Reproducible with at least InnoDB, MyISAM, Aria.
      The assertion failure appeared in 10.4 branch after this commit:

      commit ea7830eef48333e28f98a9b91f05a95735b465a3
      Author: Alexander Barkov
      Date:   Fri May 22 16:31:16 2020 +0400
       
          MDEV-14221 Assertion `0' failed in Item::field_type_for_temporal_comparison
      

      However the wrong result was there before.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:

                  Git Integration