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

Assertion `null_ref_table' failed in virtual table_map Item_direct_view_ref::used_tables() const on 2nd execution of PS

Details

    • 5.5.55, 5.5.58

    Description

      CREATE TABLE t1 (f1 VARCHAR(10)) ENGINE=MyISAM;
      CREATE ALGORITHM=MERGE VIEW v1 AS SELECT * FROM t1;
      INSERT INTO t1 VALUES ('a'),('b');
       
      CREATE TABLE t2 (f2 VARCHAR(10)) ENGINE=MyISAM;
      INSERT INTO t2 VALUES ('c'),('d');
       
      PREPARE stmt FROM "SELECT * FROM v1 WHERE f1 = SOME ( SELECT f2 FROM t2 )";
      EXECUTE stmt;
      EXECUTE stmt;

      Stack trace from 5.5 commit ceba41c0951d1d8c9b4961772b4a088769814a66

      mysqld: /src/5.5/sql/item.cc:9873: virtual table_map Item_direct_view_ref::used_tables() const: Assertion `null_ref_table' failed.
      160223 23:53:41 [ERROR] mysqld got signal 6 ;
       
      #7  0x00007fa6ed15b1d2 in __assert_fail () from /lib64/libc.so.6
      #8  0x00000000007fbd04 in Item_direct_view_ref::used_tables (this=0x7fa6e87acd38) at /src/5.5/sql/item.cc:9873
      #9  0x00000000007638a3 in get_bound_sj_equalities (sj_nest=0x7fa6e87acec0, remaining_tables=3) at /src/5.5/sql/opt_subselect.cc:3196
      #10 0x00000000006917d3 in Loose_scan_opt::init (this=0x7fa6eeba93c0, join=0x7fa6e87c63b0, s=0x7fa6e87c7830, remaining_tables=3) at /src/5.5/sql/opt_subselect.h:133
      #11 0x000000000065fe10 in best_access_path (join=0x7fa6e87c63b0, s=0x7fa6e87c7830, remaining_tables=3, idx=0, disable_jbuf=true, record_count=1, pos=0x7fa6e87c7d78, loose_scan_pos=0x7fa6eeba95a0) at /src/5.5/sql/sql_select.cc:5435
      #12 0x00000000006637c8 in best_extension_by_limited_search (join=0x7fa6e87c63b0, remaining_tables=3, idx=0, record_count=1, read_time=0, search_depth=62, prune_level=1) at /src/5.5/sql/sql_select.cc:7029
      #13 0x0000000000662b73 in greedy_search (join=0x7fa6e87c63b0, remaining_tables=3, search_depth=62, prune_level=1) at /src/5.5/sql/sql_select.cc:6620
      #14 0x0000000000662209 in choose_plan (join=0x7fa6e87c63b0, join_tables=3) at /src/5.5/sql/sql_select.cc:6207
      #15 0x000000000065bc83 in make_join_statistics (join=0x7fa6e87c63b0, tables_list=..., conds=0x7fa6e87c7280, keyuse_array=0x7fa6e87c66c8) at /src/5.5/sql/sql_select.cc:3800
      #16 0x0000000000652be0 in JOIN::optimize (this=0x7fa6e87c63b0) at /src/5.5/sql/sql_select.cc:1229
      #17 0x00000000006595a0 in mysql_select (thd=0x7fa6eb7c3a20, rref_pointer_array=0x7fa6e87c9280, tables=0x7fa6e87c9dc8, wild_num=0, fields=..., conds=0x7fa6e87c61a8, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2416184064, result=0x7fa6e87aa040, unit=0x7fa6e87c8930, select_lex=0x7fa6e87c9010) at /src/5.5/sql/sql_select.cc:3080
      #18 0x000000000064fed1 in handle_select (thd=0x7fa6eb7c3a20, lex=0x7fa6e87c8880, result=0x7fa6e87aa040, setup_tables_done_option=0) at /src/5.5/sql/sql_select.cc:319
      #19 0x0000000000629364 in execute_sqlcom_select (thd=0x7fa6eb7c3a20, all_tables=0x7fa6e87c9dc8) at /src/5.5/sql/sql_parse.cc:4689
      #20 0x0000000000622697 in mysql_execute_command (thd=0x7fa6eb7c3a20) at /src/5.5/sql/sql_parse.cc:2234
      #21 0x00000000006435be in Prepared_statement::execute (this=0x7fa6e87b3060, expanded_query=0x7fa6eebaad00, open_cursor=false) at /src/5.5/sql/sql_prepare.cc:3930
      #22 0x00000000006426fb in Prepared_statement::execute_loop (this=0x7fa6e87b3060, expanded_query=0x7fa6eebaad00, open_cursor=false, packet=0x0, packet_end=0x0) at /src/5.5/sql/sql_prepare.cc:3589
      #23 0x0000000000640833 in mysql_sql_stmt_execute (thd=0x7fa6eb7c3a20) at /src/5.5/sql/sql_prepare.cc:2738
      #24 0x00000000006226c5 in mysql_execute_command (thd=0x7fa6eb7c3a20) at /src/5.5/sql/sql_parse.cc:2244
      #25 0x000000000062be44 in mysql_parse (thd=0x7fa6eb7c3a20, rawbuf=0x7fa6e87c6078 "EXECUTE stmt", length=12, parser_state=0x7fa6eebab650) at /src/5.5/sql/sql_parse.cc:5914
      #26 0x000000000061fc36 in dispatch_command (command=COM_QUERY, thd=0x7fa6eb7c3a20, packet=0x7fa6e8d4f361 "EXECUTE stmt", packet_length=12) at /src/5.5/sql/sql_parse.cc:1079
      #27 0x000000000061edc9 in do_command (thd=0x7fa6eb7c3a20) at /src/5.5/sql/sql_parse.cc:793
      #28 0x000000000072185f in do_handle_one_connection (thd_arg=0x7fa6eb7c3a20) at /src/5.5/sql/sql_connect.cc:1269
      #29 0x00000000007215ec in handle_one_connection (arg=0x7fa6eb7c3a20) at /src/5.5/sql/sql_connect.cc:1185
      #30 0x0000000000c8b271 in pfs_spawn_thread (arg=0x7fa6eb7f3140) at /src/5.5/storage/perfschema/pfs.cc:1015
      #31 0x00007fa6ee8230a4 in start_thread () from /lib64/libpthread.so.0
      #32 0x00007fa6ed21204d in clone () from /lib64/libc.so.6

      The problem appeared in 5.5 tree with this revision:

      commit 54b998173b128bb8362b5dbafbd66c4199776937
      Author: Oleksandr Byelkin <sanja@mariadb.com>
      Date:   Thu Apr 23 20:08:57 2015 +0200
       
          MDEV-7846: Server crashes in Item_subselect::fix_fields or fails with Thread stack overrun
          
          Substitute into transformed subselects original left expression and than register its change in case it was substituted.

      Attachments

        Activity

          elenst Elena Stepanova created issue -
          elenst Elena Stepanova made changes -
          Field Original Value New Value
          Status Open [ 1 ] Confirmed [ 10101 ]
          sanja Oleksandr Byelkin made changes -
          Status Confirmed [ 10101 ] In Progress [ 3 ]

          It looks like f1 lost its NULL reference table

          sanja Oleksandr Byelkin added a comment - It looks like f1 lost its NULL reference table

          f1 was never inner table of outer JOIN so it does not need NULL table reference

          sanja Oleksandr Byelkin added a comment - f1 was never inner table of outer JOIN so it does not need NULL table reference
          sanja Oleksandr Byelkin added a comment - - edited

          So it must (and was) set to 0x1 (NO_NULL_TABLE) but somehow was reset.

          sanja Oleksandr Byelkin added a comment - - edited So it must (and was) set to 0x1 (NO_NULL_TABLE) but somehow was reset.

          the field was cleaned up, but fix_field() was not called for it again.

          sanja Oleksandr Byelkin added a comment - the field was cleaned up, but fix_field() was not called for it again.

          It looks like saving old link on Item when other already allocated

          sanja Oleksandr Byelkin added a comment - It looks like saving old link on Item when other already allocated

          The link on the old item stuck in sj_outer_expr_list

          sanja Oleksandr Byelkin added a comment - The link on the old item stuck in sj_outer_expr_list

          Need to discuss sj_outer_expr_list & convert_subq_to_sj() with psergey

          sanja Oleksandr Byelkin added a comment - Need to discuss sj_outer_expr_list & convert_subq_to_sj() with psergey
          sanja Oleksandr Byelkin made changes -
          Status In Progress [ 3 ] Stalled [ 10000 ]
          sanja Oleksandr Byelkin made changes -
          Sprint 5.5.55&10.0.30 [ 138 ]

          revision-id: e0a1e632e4e6084cd989f217943618f4e9ac9179 (mariadb-5.5.54-25-ge0a1e63)
          parent(s): 29d78dbb44ee9890b6bc28873344f20fc9157928
          committer: Oleksandr Byelkin
          timestamp: 2017-02-18 17:47:31 +0100
          message:

          MDEV-9619: Assertion `null_ref_table' failed in virtual table_map Item_direct_view_ref::used_tables() const on 2nd execution of PS

          Refer left expression indirectly in case it changes from execution to execution.

          —

          sanja Oleksandr Byelkin added a comment - revision-id: e0a1e632e4e6084cd989f217943618f4e9ac9179 (mariadb-5.5.54-25-ge0a1e63) parent(s): 29d78dbb44ee9890b6bc28873344f20fc9157928 committer: Oleksandr Byelkin timestamp: 2017-02-18 17:47:31 +0100 message: MDEV-9619 : Assertion `null_ref_table' failed in virtual table_map Item_direct_view_ref::used_tables() const on 2nd execution of PS Refer left expression indirectly in case it changes from execution to execution. —

          bb-5.5-MDEV-9619 on github

          sanja Oleksandr Byelkin added a comment - bb-5.5- MDEV-9619 on github
          sanja Oleksandr Byelkin made changes -
          Assignee Oleksandr Byelkin [ sanja ] Sergei Petrunia [ psergey ]
          Status Stalled [ 10000 ] In Review [ 10002 ]

          revision-id: ffa50282e2ba147019e77972ae14972d77a0354b (mariadb-5.5.54-30-gffa5028)
          parent(s): 5ddfcb05ca98a62b01da1c8b939e5303f900a5cc
          committer: Oleksandr Byelkin
          timestamp: 2017-02-22 14:17:27 +0100
          message:

          MDEV-9619: Assertion `null_ref_table' failed in virtual table_map Item_direct_view_ref::used_tables() const on 2nd execution of PS

          Refer left expression indirectly in case it changes from execution to execution.

          —

          sanja Oleksandr Byelkin added a comment - revision-id: ffa50282e2ba147019e77972ae14972d77a0354b (mariadb-5.5.54-30-gffa5028) parent(s): 5ddfcb05ca98a62b01da1c8b939e5303f900a5cc committer: Oleksandr Byelkin timestamp: 2017-02-22 14:17:27 +0100 message: MDEV-9619 : Assertion `null_ref_table' failed in virtual table_map Item_direct_view_ref::used_tables() const on 2nd execution of PS Refer left expression indirectly in case it changes from execution to execution. —

          revision-id: 144b1552d2c3dced53d8e111e213117861ff8b95 (mariadb-5.5.54-38-g144b155)
          parent(s): ac78927aefa2bd0d869d999839480d69086a9882
          committer: Oleksandr Byelkin
          timestamp: 2017-02-27 12:37:32 +0100
          message:

          MDEV-9619: Assertion `null_ref_table' failed in virtual table_map Item_direct_view_ref::used_tables() const on 2nd execution of PS

          Refer left expression indirectly in case it changes from execution to execution.

          —

          sanja Oleksandr Byelkin added a comment - revision-id: 144b1552d2c3dced53d8e111e213117861ff8b95 (mariadb-5.5.54-38-g144b155) parent(s): ac78927aefa2bd0d869d999839480d69086a9882 committer: Oleksandr Byelkin timestamp: 2017-02-27 12:37:32 +0100 message: MDEV-9619 : Assertion `null_ref_table' failed in virtual table_map Item_direct_view_ref::used_tables() const on 2nd execution of PS Refer left expression indirectly in case it changes from execution to execution. —
          elenst Elena Stepanova made changes -
          Fix Version/s 10.2 [ 14601 ]
          Affects Version/s 10.2 [ 14601 ]

          10.3 is also affected.

          elenst Elena Stepanova added a comment - 10.3 is also affected.
          sanja Oleksandr Byelkin made changes -
          Assignee Sergei Petrunia [ psergey ] Oleksandr Byelkin [ sanja ]
          sanja Oleksandr Byelkin made changes -
          Assignee Oleksandr Byelkin [ sanja ] Sergei Golubchik [ serg ]
          serg Sergei Golubchik made changes -
          Sprint 5.5.55 [ 138 ] 5.5.55, 5.5.58 [ 138, 197 ]
          serg Sergei Golubchik made changes -
          Assignee Sergei Golubchik [ serg ] Oleksandr Byelkin [ sanja ]
          Status In Review [ 10002 ] Stalled [ 10000 ]
          sanja Oleksandr Byelkin made changes -
          Fix Version/s 5.5.58 [ 22540 ]
          Fix Version/s 10.0.33 [ 22552 ]
          Fix Version/s 10.1.29 [ 22636 ]
          Fix Version/s 10.2.10 [ 22615 ]
          Fix Version/s 10.2 [ 14601 ]
          Fix Version/s 5.5 [ 15800 ]
          Fix Version/s 10.0 [ 16000 ]
          Fix Version/s 10.1 [ 16100 ]
          Resolution Fixed [ 1 ]
          Status Stalled [ 10000 ] Closed [ 6 ]
          serg Sergei Golubchik made changes -
          Workflow MariaDB v3 [ 74113 ] MariaDB v4 [ 150150 ]

          People

            sanja Oleksandr Byelkin
            elenst Elena Stepanova
            Votes:
            0 Vote for this issue
            Watchers:
            2 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.