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

QB_Name hint with path is silently ignored inside view definition

    XMLWordPrintable

Details

    • Bug
    • Status: In Review (View Workflow)
    • Minor
    • Resolution: Unresolved
    • 13.0
    • 13.0
    • Optimizer
    • None
    • Can result in unexpected behaviour
    • Q2/2026 Server Maintenance

    Description

      Bug found while testing MDEV-38045

      Case:

      --------

      SELECT * FROM (SELECT a FROM t3) dt1, (SELECT b FROM t3) dt2;
      

      In QB_NAME path , 3rd select block can be referenced as
      1)dt2
      2)dt2@sel_1
      3) @sel_3

      Issue:

      --------
      3rd block referenced as dt2 or dt2@sel_1 , QB_NAME hint applied inside view (Refer: case1)
      When referenced as @sel_3 , QB_NAME hint not applied( Refer: case2)

      case1)

      --------------

      explain 
      SELECT /*+ no_index(t3@dt1) QB_NAME(dt1,dt2)*/ * FROM (SELECT a FROM t3) dt1, (SELECT b FROM t3) dt2;
      

      or

      QB_NAME(dt1,dt2@sel_1)
      

      or

      create view v1 as 
      SELECT /*+ no_index(t3@dt1) QB_NAME(dt1,dt2)*/ * FROM (SELECT a FROM t3) dt1, (SELECT b FROM t3) dt2;
      explain select * from v1;
      

      Expected and returned result same

      +------+-------------+-------+-------+---------------+------+---------+------+------+------------------------------------+
      | id   | select_type | table | type  | possible_keys | key  | key_len | ref  | rows | Extra                              |
      +------+-------------+-------+-------+---------------+------+---------+------+------+------------------------------------+
      |    1 | SIMPLE      | t3    | index | NULL          | a    | 5       | NULL | 1    | Using index                        |
      |    1 | SIMPLE      | t3    | ALL   | NULL          | NULL | NULL    | NULL | 1    | Using join buffer (flat, BNL join) |
      +------+-------------+-------+-------+---------------+------+---------+------+------+------------------------------------+
      

      case2)

      --------------

      SELECT /*+ no_index(t3@dt1) QB_NAME(dt1,@sel_3)*/ * FROM (SELECT a FROM t3) dt1, (SELECT b FROM t3) dt2;
      

      Returned: Expected (Same)
      ---------------
      t3-index
      t3-ALL (Hint applied here)

      create view v1 as 
      SELECT /*+ no_index(t3@dt1) QB_NAME(dt1,@sel_3)*/ * FROM (SELECT a FROM t3) dt1, (SELECT b FROM t3) dt2;
      explain select * from v1;
      

      Returned: Not expected( QB_NAME hint didn't apply)
      ---------------
      t3- ALL (Hint applied here)
      t3 -index

      How to repro:

      create table t3( a int,b int ,index(a),index(b));
      Repeat case2)
      

      Attachments

        Issue Links

          Activity

            People

              psergei Sergei Petrunia
              mariadb-pavithrapandith Pavithra Pandith
              Votes:
              0 Vote for this issue
              Watchers:
              3 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.