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

Assertion `used_tables_cache == 0' fails upon using a table with RAND in virtual column definition

    XMLWordPrintable

Details

    Description

      CREATE TABLE t (f INT, v INT AS (CASE f WHEN 1 THEN ('x' && 1) WHEN 2 THEN RAND(1) END));
      INSERT INTO t (f) VALUES (1),(2);
      CREATE TABLE tmp AS SELECT INDEX_LENGTH FROM information_schema.TABLES WHERE TABLE_NAME = 't';
      SELECT * FROM t;
       
      # Cleanup
      DROP TABLE tmp, t;
      

      10.3 55a53949

      mysqld: /data/src/10.3/sql/item_func.cc:329: virtual bool Item_func::fix_fields(THD*, Item**): Assertion `used_tables_cache == 0' failed.
      230504 15:56:50 [ERROR] mysqld got signal 6 ;
       
      #9  0x00007fb4c4453df2 in __GI___assert_fail (assertion=0x555e966aafa0 "used_tables_cache == 0", file=0x555e966aaa80 "/data/src/10.3/sql/item_func.cc", line=329, function=0x555e966aaf40 "virtual bool Item_func::fix_fields(THD*, Item**)") at ./assert/assert.c:101
      #10 0x0000555e94ecbca9 in Item_func::fix_fields (this=0x61d00018dbe8, thd=0x62a000060208, ref=0x61d00018ddf8) at /data/src/10.3/sql/item_func.cc:329
      #11 0x0000555e94e61fe7 in Item_func_case::fix_fields (this=0x61d00018dbe8, thd=0x62a000060208, ref=0x61d00018ddf8) at /data/src/10.3/sql/item_cmpfunc.cc:3048
      #12 0x0000555e9490f29d in Virtual_column_info::fix_expr (this=0x61d00018dde8, thd=0x62a000060208) at /data/src/10.3/sql/table.cc:2966
      #13 0x0000555e9490f6bc in Virtual_column_info::fix_session_expr (this=0x61d00018dde8, thd=0x62a000060208) at /data/src/10.3/sql/table.cc:2992
      #14 0x0000555e949101dd in TABLE::vcol_fix_expr (this=0x61f000043688, thd=0x62a000060208) at /data/src/10.3/sql/table.cc:3080
      #15 0x0000555e944b146f in open_table (thd=0x62a000060208, table_list=0x62b000000448, ot_ctx=0x7fb4bb5c66d0) at /data/src/10.3/sql/sql_base.cc:2057
      #16 0x0000555e944b9d39 in open_and_process_table (thd=0x62a000060208, tables=0x62b000000448, counter=0x7fb4bb5c67e0, flags=0, prelocking_strategy=0x7fb4bb5c68f0, has_prelocking_list=false, ot_ctx=0x7fb4bb5c66d0) at /data/src/10.3/sql/sql_base.cc:3733
      #17 0x0000555e944bc296 in open_tables (thd=0x62a000060208, options=..., start=0x7fb4bb5c67f0, counter=0x7fb4bb5c67e0, flags=0, prelocking_strategy=0x7fb4bb5c68f0) at /data/src/10.3/sql/sql_base.cc:4208
      #18 0x0000555e944c132d in open_and_lock_tables (thd=0x62a000060208, options=..., tables=0x62b000000448, derived=true, flags=0, prelocking_strategy=0x7fb4bb5c68f0) at /data/src/10.3/sql/sql_base.cc:5148
      #19 0x0000555e94427599 in open_and_lock_tables (thd=0x62a000060208, tables=0x62b000000448, derived=true, flags=0) at /data/src/10.3/sql/sql_base.h:503
      #20 0x0000555e94637c6e in execute_sqlcom_select (thd=0x62a000060208, all_tables=0x62b000000448) at /data/src/10.3/sql/sql_parse.cc:6261
      #21 0x0000555e946264b7 in mysql_execute_command (thd=0x62a000060208) at /data/src/10.3/sql/sql_parse.cc:3871
      #22 0x0000555e94642180 in mysql_parse (thd=0x62a000060208, rawbuf=0x62b000000228 "SELECT * FROM t", length=15, parser_state=0x7fb4bb5c89b0, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:7855
      #23 0x0000555e94618faf in dispatch_command (command=COM_QUERY, thd=0x62a000060208, packet=0x6290000dc209 "SELECT * FROM t", packet_length=15, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:1852
      #24 0x0000555e94615b47 in do_command (thd=0x62a000060208) at /data/src/10.3/sql/sql_parse.cc:1398
      #25 0x0000555e949ddf5c in do_handle_one_connection (connect=0x6080000006a8) at /data/src/10.3/sql/sql_connect.cc:1404
      #26 0x0000555e949dd889 in handle_one_connection (arg=0x6080000006a8) at /data/src/10.3/sql/sql_connect.cc:1309
      #27 0x0000555e95fc4bd5 in pfs_spawn_thread (arg=0x615000003008) at /data/src/10.3/storage/perfschema/pfs.cc:1869
      #28 0x00007fb4c44a7fd4 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
      #29 0x00007fb4c45285bc in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
      

      The failure started happening after this commit in 10.3.36 / 10.4.26 / 10.5.17 / 10.6.10 / 10.7.5 / 10.8.4 / 10.9.2:

      commit 6c7e3e5c13162b7ffa90eaa81b4ba5afaf3e0c1e
      Author: Sergei Golubchik
      Date:   Fri Jul 29 10:24:45 2022 +0200
       
          bugfix: RAND is VCOL_SESSION_FUNC
      

      Attachments

        Activity

          People

            serg Sergei Golubchik
            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.