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

Assertion `ltime->neg == 0' fails with COALESCE, ADDDATE, MAKEDATE

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 10.0.9
    • 10.0.10
    • None
    • None

    Description

      The problem appeared in 10.0 tree with the following revision:

      revno: 4033
      revision-id: bar@mnogosearch.org-20140306202125-ereir633u2qgp18m
      parent: svoj@mariadb.org-20140306121912-i1p8iilpsgc8m4bn
      committer: Alexander Barkov <bar@mnogosearch.org>
      branch nick: maria-10.0.dt2
      timestamp: Fri 2014-03-07 00:21:25 +0400
      message:
        MDEV-5372 Make "CAST(time_expr AS DATETIME)" compatible with MySQL-5.6 (and the SQL Standard)

      CREATE TABLE t1 (dt DATETIME) ENGINE=MyISAM;
      INSERT INTO t1 VALUES ('2003-05-13 19:36:05'), ('2012-12-12 09:20:06');
       
      SELECT COALESCE( ADDDATE( MAKEDATE( 2011, 121 ), dt ), '2006-09-12' ) FROM t1;

      10.0/sql/sql_time.h:68: void datetime_to_date(MYSQL_TIME*): Assertion `ltime->neg == 0' failed.
      140315 11:42:21 [ERROR] mysqld got signal 6 ;

      #6  0x00007f7eade3e621 in *__GI___assert_fail (assertion=0xf3aec1 "ltime->neg == 0", file=<optimized out>, line=68, function=0xf3baa0 "void datetime_to_date(MYSQL_TIME*)") at assert.c:81
      #7  0x0000000000759938 in datetime_to_date (ltime=0x7f7eafdacb90) at 10.0/sql/sql_time.h:68
      #8  0x0000000000919012 in Item_temporal_hybrid_func::fix_temporal_type (this=0x7f7ea61a1500, ltime=0x7f7eafdacb90) at 10.0/sql/item_timefunc.cc:1526
      #9  0x00000000009190b6 in Item_temporal_hybrid_func::val_str_ascii (this=0x7f7ea61a1500, str=0x7f7ea61a1708) at 10.0/sql/item_timefunc.cc:1543
      #10 0x00000000008e013c in Item_func::val_str_from_val_str_ascii (this=0x7f7ea61a1500, str=0x7f7ea61a1708, str2=0x7f7ea61a15d0) at 10.0/sql/item_strfunc.cc:83
      #11 0x000000000091f334 in Item_temporal_hybrid_func::val_str (this=0x7f7ea61a1500, str=0x7f7ea61a1708) at 10.0/sql/item_timefunc.h:558
      #12 0x0000000000898124 in Item_func_coalesce::str_op (this=0x7f7ea61a16f0, str=0x7f7ea61a1708) at 10.0/sql/item_cmpfunc.cc:3276
      #13 0x00000000008bd502 in Item_func_hybrid_result_type::val_str (this=0x7f7ea61a16f0, str=0x7f7eafdace00) at 10.0/sql/item_func.cc:942
      #14 0x000000000087d42f in Item::send (this=0x7f7ea61a16f0, protocol=0x7f7ea7f3d5f8, buffer=0x7f7eafdace00) at 10.0/sql/item.cc:6578
      #15 0x00000000005ccd30 in Protocol::send_result_set_row (this=0x7f7ea7f3d5f8, row_items=0x7f7ea7f41578) at 10.0/sql/protocol.cc:900
      #16 0x0000000000639221 in select_send::send_data (this=0x7f7ea61a1f48, items=...) at 10.0/sql/sql_class.cc:2552
      #17 0x00000000006d3d4e in end_send (join=0x7f7ea61a1f68, join_tab=0x7f7ea63e93b0, end_of_records=false) at 10.0/sql/sql_select.cc:18530
      #18 0x00000000006d1b39 in evaluate_join_record (join=0x7f7ea61a1f68, join_tab=0x7f7ea63e9088, error=0) at 10.0/sql/sql_select.cc:17638
      #19 0x00000000006d1432 in sub_select (join=0x7f7ea61a1f68, join_tab=0x7f7ea63e9088, end_of_records=false) at 10.0/sql/sql_select.cc:17416
      #20 0x00000000006d0c97 in do_select (join=0x7f7ea61a1f68, fields=0x7f7ea7f41578, table=0x0, procedure=0x0) at 10.0/sql/sql_select.cc:17078
      #21 0x00000000006ae86e in JOIN::exec_inner (this=0x7f7ea61a1f68) at 10.0/sql/sql_select.cc:3065
      #22 0x00000000006abd80 in JOIN::exec (this=0x7f7ea61a1f68) at 10.0/sql/sql_select.cc:2355
      #23 0x00000000006af0ff in mysql_select (thd=0x7f7ea7f3d070, rref_pointer_array=0x7f7ea7f416d8, tables=0x7f7ea61a18c0, wild_num=0, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f7ea61a1f48, unit=0x7f7ea7f40d78, select_lex=0x7f7ea7f41460) at 10.0/sql/sql_select.cc:3292
      #24 0x00000000006a582f in handle_select (thd=0x7f7ea7f3d070, lex=0x7f7ea7f40cb0, result=0x7f7ea61a1f48, setup_tables_done_option=0) at 10.0/sql/sql_select.cc:372
      #25 0x000000000067a794 in execute_sqlcom_select (thd=0x7f7ea7f3d070, all_tables=0x7f7ea61a18c0) at 10.0/sql/sql_parse.cc:5301
      #26 0x0000000000672b3f in mysql_execute_command (thd=0x7f7ea7f3d070) at 10.0/sql/sql_parse.cc:2587
      #27 0x000000000067cf1f in mysql_parse (thd=0x7f7ea7f3d070, rawbuf=0x7f7ea61a1088 "SELECT COALESCE( ADDDATE( MAKEDATE( 2011, 121 ), dt ), '2006-09-12' ) FROM t1", length=77, parser_state=0x7f7eafdae610) at 10.0/sql/sql_parse.cc:6447
      #28 0x000000000066fcec in dispatch_command (command=COM_QUERY, thd=0x7f7ea7f3d070, packet=0x7f7ea7f33071 "", packet_length=77) at 10.0/sql/sql_parse.cc:1308
      #29 0x000000000066f08e in do_command (thd=0x7f7ea7f3d070) at 10.0/sql/sql_parse.cc:1005
      #30 0x0000000000788ed6 in do_handle_one_connection (thd_arg=0x7f7ea7f3d070) at 10.0/sql/sql_connect.cc:1379
      #31 0x0000000000788c29 in handle_one_connection (arg=0x7f7ea7f3d070) at 10.0/sql/sql_connect.cc:1293
      #32 0x0000000000a2da80 in pfs_spawn_thread (arg=0x7f7ea725dcb0) at 10.0/storage/perfschema/pfs.cc:1853
      #33 0x00007f7eaf9e2b50 in start_thread (arg=<optimized out>) at pthread_create.c:304
      #34 0x00007f7eadeeda7d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112

      Stack trace from:

      revision-id: psergey@askmonty.org-20140314175216-ztbe8wskbc5ou7vn
      date: 2014-03-14 18:52:16 +0100
      build-date: 2014-03-15 12:20:52 +0400
      revno: 4054
      branch-nick: 10.0

      Before revision 4033, the same query produced a result with a warning, which probably wasn't correct either:

      SELECT COALESCE( ADDDATE( MAKEDATE( 2011, 121 ), dt ), '2006-09-12' ) FROM t1;
      COALESCE( ADDDATE( MAKEDATE( 2011, 121 ), dt ), '2006-09-12' )
      7355-03-22
      2006-09-12
      Warnings:
      Warning	1441	Datetime function: datetime field overflow

      Attachments

        Activity

          People

            bar Alexander Barkov
            elenst Elena Stepanova
            Votes:
            0 Vote for this issue
            Watchers:
            3 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.