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

Crash when using AS OF with a stored function

    XMLWordPrintable

Details

    Description

      This script crashes the server:

      CREATE OR REPLACE FUNCTION f1() RETURNS DATETIME RETURN '2001-01-01 10:20:30';
      CREATE OR REPLACE TABLE t1
      (
         x INT,
         start_timestamp BIGINT UNSIGNED GENERATED ALWAYS AS ROW START,
         end_timestamp BIGINT UNSIGNED  GENERATED ALWAYS AS ROW END,
         PERIOD FOR SYSTEM_TIME(start_timestamp, end_timestamp)
      ) ENGINE=InnoDB WITH SYSTEM VERSIONING;
      SELECT * FROM t1 FOR SYSTEM_TIME AS OF f1();
      

      10.3 57c3dd991b

      mysqld: /data/src/10.3/sql/item_func.cc:6404: virtual const Type_handler* Item_func_sp::type_handler() const: Assertion `sp_result_field' failed.
      180506 14:46:14 [ERROR] mysqld got signal 6 ;
       
      #7  0x00007fe58d5bcee2 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
      #8  0x00005556ff6c3e81 in Item_func_sp::type_handler (this=0x7fe50c0cd4a0) at /data/src/10.3/sql/item_func.cc:6404
      #9  0x00005556ff259725 in Item::result_type (this=0x7fe50c0cd4a0) at /data/src/10.3/sql/item.h:850
      #10 0x00005556ff46ebf5 in Vers_history_point::resolve_unit (this=0x7fe50c0ced58, timestamps_only=false) at /data/src/10.3/sql/table.cc:8875
      #11 0x00005556ff46eb55 in vers_select_conds_t::resolve_units (this=0x7fe50c0ced50, timestamps_only=false) at /data/src/10.3/sql/table.cc:8865
      #12 0x00005556ff38f514 in st_select_lex::vers_setup_conds (this=0x7fe50c0050d0, thd=0x7fe50c000b00, tables=0x7fe50c0ce738) at /data/src/10.3/sql/sql_select.cc:846
      #13 0x00005556ff390607 in JOIN::prepare (this=0x7fe50c0cf0f8, tables_init=0x7fe50c0ce738, wild_num=1, conds_init=0x0, og_num=0, order_init=0x0, skip_order_by=false, group_init=0x0, having_init=0x0, proc_param_init=0x0, select_lex_arg=0x7fe50c0050d0, unit_arg=0x7fe50c004958) at /data/src/10.3/sql/sql_select.cc:1026
      #14 0x00005556ff39b813 in mysql_select (thd=0x7fe50c000b00, tables=0x7fe50c0ce738, wild_num=1, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7fe50c0cf0d8, unit=0x7fe50c004958, select_lex=0x7fe50c0050d0) at /data/src/10.3/sql/sql_select.cc:4132
      #15 0x00005556ff38ddf2 in handle_select (thd=0x7fe50c000b00, lex=0x7fe50c004890, result=0x7fe50c0cf0d8, setup_tables_done_option=0) at /data/src/10.3/sql/sql_select.cc:382
      #16 0x00005556ff35905d in execute_sqlcom_select (thd=0x7fe50c000b00, all_tables=0x7fe50c0ce738) at /data/src/10.3/sql/sql_parse.cc:6539
      #17 0x00005556ff34f7be in mysql_execute_command (thd=0x7fe50c000b00) at /data/src/10.3/sql/sql_parse.cc:3768
      #18 0x00005556ff35ca6e in mysql_parse (thd=0x7fe50c000b00, rawbuf=0x7fe50c0cd078 "SELECT * FROM t1 FOR SYSTEM_TIME AS OF f1()", length=43, parser_state=0x7fe574083620, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:8001
      #19 0x00005556ff34a251 in dispatch_command (command=COM_QUERY, thd=0x7fe50c000b00, packet=0x7fe50c0c4f41 "SELECT * FROM t1 FOR SYSTEM_TIME AS OF f1()", packet_length=43, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:1846
      #20 0x00005556ff348c90 in do_command (thd=0x7fe50c000b00) at /data/src/10.3/sql/sql_parse.cc:1391
      #21 0x00005556ff4abb45 in do_handle_one_connection (connect=0x5557020c80d0) at /data/src/10.3/sql/sql_connect.cc:1402
      #22 0x00005556ff4ab8d2 in handle_one_connection (arg=0x5557020c80d0) at /data/src/10.3/sql/sql_connect.cc:1308
      #23 0x00007fe58f293494 in start_thread (arg=0x7fe574084700) at pthread_create.c:333
      #24 0x00007fe58d67993f in clone () from /lib/x86_64-linux-gnu/libc.so.6
      

      So does this, if I change the function to return a BIGINT (assuming transaction ID):

      CREATE OR REPLACE FUNCTION f1() RETURNS BIGINT UNSIGNED RETURN '1';
      CREATE OR REPLACE TABLE t1
      (
         x INT,
         start_timestamp BIGINT UNSIGNED GENERATED ALWAYS AS ROW START,
         end_timestamp BIGINT UNSIGNED  GENERATED ALWAYS AS ROW END,
         PERIOD FOR SYSTEM_TIME(start_timestamp, end_timestamp)
      ) ENGINE=InnoDB WITH SYSTEM VERSIONING;
      SELECT * FROM t1 FOR SYSTEM_TIME AS OF f1();
      

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              bar Alexander Barkov
              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.