Repository navigation
Conversation
- Refactor AnalyzeStmt to support multi-table entries - Add CheckTableStmt and ShowProfileStmt AST nodes - Update grammar (mysql_sql.y) for all three statement types - Add frontend handlers returning "not supported" for CHECK/SHOW PROFILE - Handle ANALYZE multi-table by iterating entries WIP: still need to wire up new handlers in self_handle.go dispatch and regenerate mysql_sql.go
…arser (matrixorigin#23122) - Add dispatch cases in self_handle.go for CheckTableStmt and ShowProfileStmt - Add FPrint constants (FPCheckTableStmt, FPShowProfileStmt, etc.) in types.go - Add "profile" keyword mapping to keywords.go for lexer recognition - Regenerate mysql_sql.go from updated grammar (goyacc) - Add StmtKind() methods to CheckTableStmt and ShowProfileStmt AST nodes - Add analysis and design documents All parser and AST unit tests pass.
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Requesting changes on the latest head 032b824447. The previous result ownership, quoted identifier, snapshot, and rewrite-chain findings are addressed, but the latest per-statement policy change is not closed through the execution layer.
[High] Multi-statement database remaps are still collapsed to the first statement. rewriteSQL now materializes a separate merged hint for every statement (pkg/frontend/rewrite_rule.go:201-218), so inline remap overrides can legitimately differ by statement. However, GetComputationWrapper still calls extractInlineRemapDb(execCtx.input.getSql()) once on the complete command, applies that one map to every parsed AST, and stores it in the single execCtx.remapDb (pkg/frontend/mysql_cmd_executor.go:2751-2763). extractInlineRemapDb only reads the first leading hint.
Concrete failure: with statement 1 carrying src -> first_db and statement 2 carrying src -> second_db, e.g. SELECT 1; ANALYZE TABLE src.t(id), the second Analyze AST is rewritten to first_db.t, not second_db.t. If the first statement has no remap, a remap present only on the second statement is ignored. The same mismatch affects later SELECT/DML statements and unqualified-name resolution through TxnCompilerContext.DefaultDatabase, so this can read or modify the wrong database and can violate the intended rewrite/remap policy boundary.
I reproduced this with the exact parser/execution preprocessing sequence: Parse + AddRewriteHints produces two statement-specific options, but extractInlineRemapDb(fullSQL) returns the first map and applyRemapDb(stmts, map) rewrites both statements with it. The existing tests only verify that the rewritten SQL text contains a policy on later statements; they do not pass those statements through the consumer that collapses the maps.
Please carry remap metadata per parsed statement/computation wrapper, apply each map only to its matching AST, and install the matching map on the ExecCtx before authorization/planning/execution (including cached/prepared paths). Add end-to-end unit coverage for: first statement without remap + second with remap; distinct inline overrides on consecutive statements; session remap restored after a one-statement inline override; qualified and unqualified targets; and ANALYZE followed/preceded by SELECT.
Focused frontend/parser/tree tests pass, so this is a missing cross-layer invariant rather than a test failure.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Blocking: per-statement policy materialization uses lexical semicolons rather than parser-level statement boundaries.
rewriteSQL calls SplitSqlBySemicolon at pkg/frontend/rewrite_rule.go:201, and that helper splits every scanner-visible ;. However, MatrixOne accepts compound statements whose body contains semicolons as one AST, for example the existing parser case:
create task task_quotes when ('gate' = 'gate') as begin
insert into gate_sink select 'gate-ok';
select case when 1 = 1 then 'PASS' else 'FAIL' end;
endWhen enable_remap_hint is on and any role/session rewrite policy is non-empty, rewriteSQL prepends a materialized hint to each body fragment. Parsing still returns one CreateSQLTask, while extractLeadingHints returns three statement-bearing fragments; AddRewriteHints then fails at pkg/sql/parsers/sqlparse.go:463 with SQL parser error: parse hints bug. I reproduced this on head 4772b88a645ef3a8566be4b90bed1d0ff543a44f with a frontend regression test exercising rewriteSQL -> parsers.Parse -> parsers.AddRewriteHints.
Please derive policy boundaries from top-level SQL statement boundaries compatible with the grammar (so semicolons inside BEGIN ... END remain inside one statement), and add a regression covering a compound CREATE TASK under a non-empty rewrite/remap policy.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Approved on latest head 1cfd2748ef after re-reviewing the complete functional chain.
The previous blocker is closed at the correct abstraction boundary: statement policy splitting now uses grammar-level top-level semicolon positions, so semicolons inside compound bodies remain within one AST, while malformed input is still surfaced as the standard parser error class. I also rechecked the broader changes: ANALYZE result ownership and multi-result flags, responder/context restoration on success and error, quoted identifiers, snapshot-aware implicit columns, per-statement remap propagation across normal/cache/prepared paths, mid-list failure atomicity, and transaction/privilege routing. No new confirmed correctness, compatibility, leak, hang, or unbounded-growth issue was found.
Local evidence on this exact head:
go test -count=1 -timeout=180s ./pkg/sql/parsers/...passed with the repository CGo runtime setup.go test -count=1 -timeout=300s ./pkg/frontendpassed.go vet ./pkg/sql/parsers/... ./pkg/frontendpassed.git diff --check origin/main...HEADpassed.
The parser-aware boundary scan is measurably more expensive than the former lexical splitter, but the measured absolute cost is only a few microseconds per invocation and is gated by enable_remap_hint; this is a reasonable correctness tradeoff, with parse-result reuse available as a future optimization. CI is still running and the branch is behind main, so normal CI/rebase gates should still apply.
Merge Queue Status
This pull request spent 33 minutes 46 seconds in the queue, with no time running CI. Waiting for
All conditions
ReasonThe merge conditions cannot be satisfied due to failing checks Failing checks:
HintYou may have to fix your CI before adding the pull request to the queue again. Requeued — the merge queue status continues in this comment ↓. |
Merge Queue Status
This pull request spent 58 minutes 24 seconds in the queue, with no time running CI. ReasonPull request #24659 has been dequeued Queue conditions are not satisfied:
HintYou should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. Requeued — the merge queue status continues in this comment ↓. |
# Conflicts: # pkg/frontend/mysql_cmd_executor.go
Merge Queue Status
This pull request spent 2 hours 12 minutes 32 seconds in the queue, with no time running CI. Waiting for
All conditions
ReasonPull request #24659 has been dequeued Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.
Failing checks:
HintYou should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. Tick the box to put this pull request back in the merge queue (same as
|
What type of PR is this?
Which issue(s) this PR fixes:
issue #23122
What this PR does / why we need it:
MatrixOne currently returns generic parser error 1064 for several MySQL-compatible statements, including multi-table
ANALYZE TABLE,CHECK TABLE, andSHOW PROFILE. Supporting these statements also requires preserving session, transaction, snapshot, result, and SQL-rewrite state whenANALYZE TABLEexecutes derived queries.This PR adds:
Statement support
ANALYZE TABLEto accept multiple tables, with or without explicit column lists.CHECK TABLE, includingEXTENDEDandFOR UPGRADE.SHOW PROFILE, includingFOR QUERYandLIMIT.NotSupportederrors forCHECK TABLEandSHOW PROFILEinstead of generic parser errors.ANALYZE execution
SQL rewrite and database remapping
COM_QUERYrequests and cached plans.ANALYZE TABLEderived queries.Tests