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

Assertion failure or unexpected result upon 2nd execution of SP with DELETE RETURNING from view

    XMLWordPrintable

Details

    Description

      CREATE TABLE t (a INT, b INT);
      CREATE VIEW v AS SELECT * FROM t;
      ALTER TABLE t DROP b;
      CREATE PROCEDURE sp() DELETE FROM v RETURNING *;
      --error ER_VIEW_INVALID
      CALL sp;
      --error ER_VIEW_INVALID
      CALL sp;
      select * from v;
       
      # Cleanup
      DROP VIEW v;
      DROP TABLE t;
      DROP PROCEDURE sp;
      

      On a debug build of 10.5+ the 2nd execution results in the assertion failure:

      10.5 b8f4b984

      mariadbd: /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sql_base.cc:7544: int setup_wild(THD*, TABLE_LIST*, List<Item>&, List<Item>*, SELECT_LEX*, bool): Assertion `!(*with_wild)' failed.
      221227 20:52:16 [ERROR] mysqld got signal 6 ;
       
      #7  0x00007f7b1fffb662 in __GI___assert_fail (assertion=0x557416c866c0 "!(*with_wild)", file=0x557416c80520 "/home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sql_base.cc", line=7544, function=0x557416c86700 "int setup_wild(THD*, TABLE_LIST*, List<Item>&, List<Item>*, SELECT_LEX*, bool)") at assert.c:101
      #8  0x0000557414bd3b05 in setup_wild (thd=0x62b000069218, tables=0x6250000f8690, fields=..., sum_func_list=0x0, select_lex=0x6250000faa38, returning_field=true) at /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sql_base.cc:7544
      #9  0x0000557414bd58cf in setup_returning_fields (thd=0x62b000069218, table_list=0x6250000f8690) at /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sql_base.cc:7713
      #10 0x00005574159e468a in mysql_prepare_delete (thd=0x62b000069218, table_list=0x6250000f8690, conds=0x7f7b16ab92e0, delete_while_scanning=0x7f7b16ab9220) at /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sql_delete.cc:1048
      #11 0x00005574159ddf05 in mysql_delete (thd=0x62b000069218, table_list=0x6250000f8690, conds=0x0, order_list=0x6250000facd8, limit=18446744073709551615, options=0, result=0x6250001091b0) at /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sql_delete.cc:370
      #12 0x0000557414d59512 in mysql_execute_command (thd=0x62b000069218) at /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sql_parse.cc:4869
      #13 0x0000557414b0772e in sp_instr_stmt::exec_core (this=0x6250000f8f10, thd=0x62b000069218, nextp=0x7f7b16abaa80) at /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sp_head.cc:3775
      #14 0x0000557414b05d0b in sp_lex_keeper::reset_lex_and_exec_core (this=0x6250000f8f58, thd=0x62b000069218, nextp=0x7f7b16abaa80, open_tables=false, instr=0x6250000f8f10) at /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sp_head.cc:3500
      #15 0x0000557414b06eb8 in sp_instr_stmt::execute (this=0x6250000f8f10, thd=0x62b000069218, nextp=0x7f7b16abaa80) at /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sp_head.cc:3681
      #16 0x0000557414af8297 in sp_head::execute (this=0x6250000f7938, thd=0x62b000069218, merge_da_on_success=true) at /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sp_head.cc:1438
      #17 0x0000557414afe8c5 in sp_head::execute_procedure (this=0x6250000f7938, thd=0x62b000069218, args=0x62b00006e2e0) at /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sp_head.cc:2450
      #18 0x0000557414d4c933 in do_execute_sp (thd=0x62b000069218, sp=0x6250000f7938) at /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sql_parse.cc:3089
      #19 0x0000557414d4e49f in Sql_cmd_call::execute (this=0x62b000038300, thd=0x62b000069218) at /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sql_parse.cc:3335
      #20 0x0000557414d61e40 in mysql_execute_command (thd=0x62b000069218) at /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sql_parse.cc:6059
      #21 0x0000557414d6f112 in mysql_parse (thd=0x62b000069218, rawbuf=0x62b000038238 "CALL sp", length=7, parser_state=0x7f7b16abcbb0, is_com_multi=false, is_next_command=false) at /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sql_parse.cc:8089
      #22 0x0000557414d45742 in dispatch_command (command=COM_QUERY, thd=0x62b000069218, packet=0x62900024e219 "CALL sp", packet_length=7, is_com_multi=false, is_next_command=false) at /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sql_parse.cc:1891
      #23 0x0000557414d4215f in do_command (thd=0x62b000069218) at /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sql_parse.cc:1375
      #24 0x000055741517f1a2 in do_handle_one_connection (connect=0x608000002538, put_in_cache=true) at /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sql_connect.cc:1416
      #25 0x000055741517eb3f in handle_one_connection (arg=0x6080000024b8) at /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sql_connect.cc:1318
      #26 0x0000557415da372a in pfs_spawn_thread (arg=0x615000005d18) at /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/storage/perfschema/pfs.cc:2201
      #27 0x00007f7b204d9ea7 in start_thread (arg=<optimized out>) at pthread_create.c:477
      #28 0x00007f7b200c6aef in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
      

      Non-debug builds of 10.5+ and any builds of 10.3-10.4 do not crash, but the 2nd execution unexpectedly succeeds (even although it should fail the same way as the 1st execution does, with ER_VIEW_INVALID):

      10.4 f97f6955

      CALL sp;
      ERROR HY000: View 'test.v' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
      CALL sp;
      bug.wild1a                               [ fail ]
              Test ended at 2022-12-27 20:54:09
       
      CURRENT_TEST: bug.wild1a
      mysqltest: At line 8: query 'CALL sp' succeeded - should have failed with errno 1356...
      

      Attachments

        Activity

          People

            shulga Dmitry Shulga
            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.