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

Server crash in Item_field::fix_outer_field with nested subquery using GROUP BY and HAVING.

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Incomplete
    • 12.0.1
    • N/A
    • None
    • None

    Description

      I can reproduce a debug-build server crash caused by nested subqueries with outer
      references.The crash happens in Item_field::fix_outer_field at sql/item.cc:6152, with the following
      assertion:
      DBUG_ASSERT(*ref && (*ref)->fixed());
      The issue reproduces with a very small query and seems related to outer-reference resolution during JOIN::prepare() for nested subqueries.

      Version:

      12.0.1-MariaDB-debug
      source revision: ecb7c9b692811f96cfa54add61012a701c47523d

      Steps to Reproduce:
      ```
      DROP TABLE IF EXISTS t;

      CREATE TABLE t(c INT);

      SELECT
      (SELECT 0 GROUP BY c HAVING (SELECT c))
      FROM t
      GROUP BY c;

      DROP TABLE t;
      ```

      backtrace:
      ```
      sql/item.cc:6152(Item_field::fix_outer_field)
      sql/item.cc:6450(Item_field::fix_fields)
      sql/item.h:1113(Item::fix_fields_if_needed)
      sql/item.h:1122(Item::fix_fields_if_needed_for_scalar)
      sql/sql_base.cc:8117(setup_fields)
      sql/sql_select.cc:1572(JOIN::prepare)
      sql/item_subselect.cc:3981(subselect_single_select_engine::prepare)
      sql/item_subselect.cc:294(Item_subselect::fix_fields)
      sql/sql_select.cc:5350(mysql_select)
      sql/sql_parse.cc:6191(execute_sqlcom_select)
      ```

      Attachments

        Activity

          People

            Unassigned Unassigned
            chunlingqin chunlingqin
            Votes:
            0 Vote for this issue
            Watchers:
            4 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.