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

Assertion `!ldate->neg' or unexpected result upon extracting unit from invalid value

    XMLWordPrintable

Details

    Description

      SELECT EXTRACT(DAY FROM TIMESTAMP(-177498480001));
      

      On a non-debug build, it returns 0 without warnings:

      10.5 cf2d49ddcfdb158e46dcd9cc575c54205b5eef50

      SELECT EXTRACT(DAY FROM TIMESTAMP(-177498480001));
      EXTRACT(DAY FROM TIMESTAMP(-177498480001))
      0
      

      This is a weird result, because TIMESTAMP(-177498480001), when executed separately, returns NULL with a warning, so I would think that the wrapping it EXTRACT should return the same.

      On a debug build, the assertion fails:

      10.5 cf2d49ddcfdb158e46dcd9cc575c54205b5eef50

      mariadbd: /data/bld/10.5-asan/sql/sql_time.cc:1251: void mix_date_and_time_complex(MYSQL_TIME*, const MYSQL_TIME*): Assertion `!ldate->neg' failed.
      241122 21:42:52 [ERROR] mysqld got signal 6 ;
       
      #9  0x00007f1683253e32 in __GI___assert_fail (assertion=0x55a97785c320 "!ldate->neg", file=0x55a97785b4c0 "/data/bld/10.5-asan/sql/sql_time.cc", line=1251, function=0x55a97785c2c0 "void mix_date_and_time_complex(MYSQL_TIME*, const MYSQL_TIME*)") at ./assert/assert.c:101
      #10 0x000055a975926f6a in mix_date_and_time_complex (ldate=0x7f1679a578e0, ltime=0x7f1679a57db0) at /data/bld/10.5-asan/sql/sql_time.cc:1251
      #11 0x000055a975927289 in mix_date_and_time (to=0x7f1679a578e0, from=0x7f1679a57db0) at /data/bld/10.5-asan/sql/sql_time.cc:1273
      #12 0x000055a97592791e in time_to_datetime (thd=0x62b000069218, from=0x7f1679a57db0, to=0x7f1679a578e0) at /data/bld/10.5-asan/sql/sql_time.cc:1329
      #13 0x000055a975927b68 in time_to_datetime_with_warn (thd=0x62b000069218, from=0x7f1679a57db0, to=0x7f1679a578e0, fuzzydate=...) at /data/bld/10.5-asan/sql/sql_time.cc:1348
      #14 0x000055a975b75c2c in Temporal_with_date::make_from_item (this=0x7f1679a57db0, thd=0x62b000069218, item=0x62b0000389a8, fuzzydate=...) at /data/bld/10.5-asan/sql/sql_type.cc:1016
      #15 0x000055a9752acf6c in Temporal_with_date::Temporal_with_date (this=0x7f1679a57db0, thd=0x62b000069218, item=0x62b0000389a8, fuzzydate=<error reading variable: Cannot access memory at address 0xffffffffffffffe0>) at /data/bld/10.5-asan/sql/sql_type.h:2120
      #16 0x000055a9752ad385 in Datetime::Datetime (this=0x7f1679a57db0, thd=0x62b000069218, item=0x62b0000389a8, fuzzydate=<error reading variable: Cannot access memory at address 0xffffffffffffffe6>) at /data/bld/10.5-asan/sql/sql_type.h:2399
      #17 0x000055a975d96826 in Datetime::Datetime (this=0x7f1679a57db0, thd=0x62b000069218, item=0x62b0000389a8, fuzzydate=..., dec=0) at /data/bld/10.5-asan/sql/sql_type.h:2450
      #18 0x000055a9760a2e5f in Item_datetime_typecast::get_date (this=0x62b000038a48, thd=0x62b000069218, ltime=0x7f1679a57db0, fuzzydate=...) at /data/bld/10.5-asan/sql/item_timefunc.cc:2601
      #19 0x000055a975b6fe2f in Temporal_hybrid::Temporal_hybrid (this=0x7f1679a57db0, thd=0x62b000069218, item=0x62b000038a48, fuzzydate=...) at /data/bld/10.5-asan/sql/sql_type.cc:362
      #20 0x000055a9760aaf3f in Extract_source::Extract_source (this=0x7f1679a57db0, thd=0x62b000069218, item=0x62b000038a48, mode=<error reading variable: Cannot access memory at address 0xffffffffffffffe6>) at /data/bld/10.5-asan/sql/sql_type.h:1360
      #21 0x000055a97609e531 in Item_extract::val_int (this=0x62b000038b18) at /data/bld/10.5-asan/sql/item_timefunc.cc:2194
      #22 0x000055a975b9615e in Type_handler::Item_send_long (this=0x55a979c95da0 <type_handler_slong>, item=0x62b000038b18, protocol=0x62b000069818, buf=0x7f1679a57fa0) at /data/bld/10.5-asan/sql/sql_type.cc:7598
      #23 0x000055a975bb2280 in Type_handler_long::Item_send (this=0x55a979c95da0 <type_handler_slong>, item=0x62b000038b18, protocol=0x62b000069818, buf=0x7f1679a57fa0) at /data/bld/10.5-asan/sql/sql_type.h:5736
      #24 0x000055a9752ae61a in Item::send (this=0x62b000038b18, protocol=0x62b000069818, buffer=0x7f1679a57fa0) at /data/bld/10.5-asan/sql/item.h:1083
      #25 0x000055a97529f327 in Protocol::send_result_set_row (this=0x62b000069818, row_items=0x62b000038618) at /data/bld/10.5-asan/sql/protocol.cc:1086
      #26 0x000055a975455b64 in select_send::send_data (this=0x62b0000395a8, items=...) at /data/bld/10.5-asan/sql/sql_class.cc:3161
      #27 0x000055a975722c75 in select_result_sink::send_data_with_check (this=0x62b0000395a8, items=..., u=0x62b00006d3d0, sent=0) at /data/bld/10.5-asan/sql/sql_class.h:5580
      #28 0x000055a975659834 in JOIN::exec_inner (this=0x62b0000395d8) at /data/bld/10.5-asan/sql/sql_select.cc:4529
      #29 0x000055a9756583ea in JOIN::exec (this=0x62b0000395d8) at /data/bld/10.5-asan/sql/sql_select.cc:4441
      #30 0x000055a97565c701 in mysql_select (thd=0x62b000069218, tables=0x0, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x62b0000395a8, unit=0x62b00006d3d0, select_lex=0x62b0000384b0) at /data/bld/10.5-asan/sql/sql_select.cc:4918
      #31 0x000055a97562c8f8 in handle_select (thd=0x62b000069218, lex=0x62b00006d308, result=0x62b0000395a8, setup_tables_done_option=0) at /data/bld/10.5-asan/sql/sql_select.cc:449
      #32 0x000055a9755934f9 in execute_sqlcom_select (thd=0x62b000069218, all_tables=0x0) at /data/bld/10.5-asan/sql/sql_parse.cc:6437
      #33 0x000055a97558193b in mysql_execute_command (thd=0x62b000069218) at /data/bld/10.5-asan/sql/sql_parse.cc:4029
      #34 0x000055a97559e307 in mysql_parse (thd=0x62b000069218, rawbuf=0x62b0000383e0 "SELECT EXTRACT(DAY FROM TIMESTAMP(-177498480001))", length=49, parser_state=0x7f1679a59c70, is_com_multi=false, is_next_command=false) at /data/bld/10.5-asan/sql/sql_parse.cc:8237
      #35 0x000055a9755735ed in dispatch_command (command=COM_QUERY, thd=0x62b000069218, packet=0x629000235219 "", packet_length=49, is_com_multi=false, is_next_command=false) at /data/bld/10.5-asan/sql/sql_parse.cc:1891
      #36 0x000055a97556ff80 in do_command (thd=0x62b000069218) at /data/bld/10.5-asan/sql/sql_parse.cc:1375
      #37 0x000055a9759c9b89 in do_handle_one_connection (connect=0x608000002ab8, put_in_cache=true) at /data/bld/10.5-asan/sql/sql_connect.cc:1407
      #38 0x000055a9759c96ef in handle_one_connection (arg=0x608000002a38) at /data/bld/10.5-asan/sql/sql_connect.cc:1319
      #39 0x000055a976627bac in pfs_spawn_thread (arg=0x615000006c18) at /data/bld/10.5-asan/storage/perfschema/pfs.cc:2201
      #40 0x00007f16832a8044 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
      #41 0x00007f168332861c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
      

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:

              Git Integration

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