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

Prepare statement with select from view fails on second execution when view definition has HAVING in a correlated subquery references columns in the outer query

    XMLWordPrintable

Details

    Description

      After fix enable "view-protocol" for cases marked with MDEV-34155

      Testcase:

      CREATE TABLE t(c INT,c2 INT UNIQUE) ENGINE=InnoDB;
       
      create view v1 as SELECT 1 FROM t WHERE c2=(SELECT 1 FROM t GROUP BY c HAVING c2=c+1) AND c2=1;
      prepare stmt1 from 'SELECT * FROM v1';
      execute stmt1;
      execute stmt1;
      deallocate prepare stmt1;
       
      drop view v1;
      drop table t;
      

      Stacktrace:

      Thread pointer: 0x7b541c000dc8
      Attempting backtrace. You can use the following information to find out
      where mysqld died. If you see no messages after this, something went
      terribly wrong...
      stack_bottom = 0x7b544c158bf8 thread_stack 0x49000
      mysys/stacktrace.c:215(my_print_stacktrace)[0x59fe44d67a7a]
      sql/signal_handler.cc:238(handle_fatal_signal)[0x59fe44427fb4]
      libc_sigaction.c:0(__restore_rt)[0x7b545a042520]
      sql/item.cc:8213(Item_ref::fix_fields(THD*, Item**))[0x59fe44467ee8]
      sql/item.h:1166(Item::fix_fields_if_needed(THD*, Item**))[0x59fe43ed74f4]
      sql/item_func.cc:359(Item_func::fix_fields(THD*, Item**))[0x59fe444bed8e]
      sql/item.h:1166(Item::fix_fields_if_needed(THD*, Item**))[0x59fe43ed74f4]
      sql/item.h:1175(Item::fix_fields_if_needed_for_scalar(THD*, Item**))[0x59fe43ed752d]
      sql/item.h:1180(Item::fix_fields_if_needed_for_bool(THD*, Item**))[0x59fe43f626cb]
      sql/sql_select.cc:1611(JOIN::prepare(TABLE_LIST*, Item*, unsigned int, st_order*, bool, st_order*, Item*, st_order*, st_select_lex*, st_select_lex_unit*))[0x59fe44076dd6]
      sql/item_subselect.cc:3958(subselect_single_select_engine::prepare(THD*))[0x59fe44551ef7]
      sql/item_subselect.cc:296(Item_subselect::fix_fields(THD*, Item**))[0x59fe445432f6]
      sql/item.h:1166(Item::fix_fields_if_needed(THD*, Item**))[0x59fe43ed74f4]
      sql/item_func.cc:359(Item_func::fix_fields(THD*, Item**))[0x59fe444bed8e]
      sql/item.h:1166(Item::fix_fields_if_needed(THD*, Item**))[0x59fe43ed74f4]
      sql/item.h:1175(Item::fix_fields_if_needed_for_scalar(THD*, Item**))[0x59fe43ed752d]
      sql/item.h:1180(Item::fix_fields_if_needed_for_bool(THD*, Item**))[0x59fe43f626cb]
      sql/item_cmpfunc.cc:5105(Item_cond::fix_fields(THD*, Item**))[0x59fe4448f3a8]
      sql/item.h:1166(Item::fix_fields_if_needed(THD*, Item**))[0x59fe43ed74f4]
      sql/item.h:1175(Item::fix_fields_if_needed_for_scalar(THD*, Item**))[0x59fe43ed752d]
      sql/item.h:1180(Item::fix_fields_if_needed_for_bool(THD*, Item**))[0x59fe43f626cb]
      sql/sql_base.cc:8911(setup_conds(THD*, TABLE_LIST*, List<TABLE_LIST>&, Item**))[0x59fe43f5e8ac]
      sql/sql_select.cc:932(setup_without_group(THD*, Bounds_checked_array<Item*>, TABLE_LIST*, List<TABLE_LIST>&, List<Item>&, List<Item>&, Item**, st_order*, st_order*, List<Window_spec>&, List<Item_window_func>&, bool*))[0x59fe4407378c]
      sql/sql_select.cc:1554(JOIN::prepare(TABLE_LIST*, Item*, unsigned int, st_order*, bool, st_order*, Item*, st_order*, st_select_lex*, st_select_lex_unit*))[0x59fe44076a0a]
      sql/sql_select.cc:5279(mysql_select(THD*, TABLE_LIST*, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*))[0x59fe440846db]
      sql/sql_select.cc:630(handle_select(THD*, LEX*, select_result*, unsigned long long))[0x59fe44072ca3]
      sql/sql_parse.cc:6094(execute_sqlcom_select(THD*, TABLE_LIST*))[0x59fe440152c1]
      sql/sql_parse.cc:3943(mysql_execute_command(THD*, bool))[0x59fe4400d113]
      sql/sql_prepare.cc:5076(Prepared_statement::execute(String*, bool))[0x59fe44056ef6]
      sql/sql_prepare.cc:4461(Prepared_statement::execute_loop(String*, bool, unsigned char*, unsigned char*))[0x59fe44054f14]
      sql/sql_prepare.cc:3481(mysql_sql_stmt_execute(THD*))[0x59fe440523b5]
      sql/sql_parse.cc:3960(mysql_execute_command(THD*, bool))[0x59fe4400d158]
      sql/sql_parse.cc:7815(mysql_parse(THD*, char*, unsigned int, Parser_state*))[0x59fe4401a2c6]
      sql/sql_parse.cc:1895(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool))[0x59fe44006c15]
      sql/sql_parse.cc:1406(do_command(THD*, bool))[0x59fe4400555b]
      sql/sql_connect.cc:1437(do_handle_one_connection(CONNECT*, bool))[0x59fe44202376]
      sql/sql_connect.cc:1341(handle_one_connection)[0x59fe442020df]
      perfschema/pfs.cc:2203(pfs_spawn_thread)[0x59fe447a1f7f]
      nptl/pthread_create.c:442(start_thread)[0x7b545a094ac3]
      x86_64/clone3.S:83(__clone3)[0x7b545a126850]
      

      Attachments

        Issue Links

          Activity

            People

              oleg.smirnov Oleg Smirnov
              lstartseva Lena Startseva
              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.