MDEV-38045 Implement QB_NAME hint with path syntax for nested query blocks #4482
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR follows #4463.
Extended QB_NAME hint to support path-based addressing of query blocks
nested within views, derived tables, and CTEs, following TiDB's syntax.
New syntax:
For example,
SELECT /*+ qb_name(qb_v1, v1) */* FROM v1The name
qb_v1is assigned to the inner query block of the viewv1.SELECT /*+ qb_name(qb_v1, v1@sel_1) */* FROM v1Means the same but specifies that
v1is present in SELECT#1 of the currentquery block.
SELECT /*+ qb_name(qb_v1, v1@sel_1 .@sel_2) */* FROM v1This means SELECT#2 of view
v1, which is present in SELECT#1 ofthe current query block, gets the name
qb_v1.It is possible to specify not only view names but also derived tables
and CTE's in the path.
Views and derived tables may be nested on multiple levels, for example:
SELECT /*+ qb_name(dt2_dt1_v1_1, dt1 .dt2 .v2 .@SEL_2) no_index(t1@dt2_dt1_v1_1)*/ v1.* FROM v1 JOIN (SELECT v1.* FROM v1 JOIN (SELECT * FROM v2) dt2) dt1How can this PR be tested?
./mtr opt_hints_qb_name_pathBasing the PR against the correct MariaDB version
mainbranch.PR quality check