{{ message }}
Repository navigation
Commit ebc36f0
fix(advisor/tidb): switch DDL detection to pingcap DDLNode for Tier-4-grammar coverage (Codex P1, cumulative #30 Codex-fix-1f)
Codex caught: omni's parser rejects Tier-4-deferred DDL grammar
(CREATE/ALTER/DROP SEQUENCE, FLASHBACK DATABASE/TABLE). Per
invariant #2, `getTiDBOmniNodes` soft-fails on omni-rejected stmts.
For builtin_prior_backup_check — a safety gate — this silently
drops DDL classification on these valid tidb statements:
CREATE SEQUENCE seq1 START 1; UPDATE bar SET x=1;
FLASHBACK TABLE foo; DELETE FROM bar WHERE id=5;
Pre-omni: pingcap parses both, classifies as DDL via DDLNode
interface → mixed-DDL+DML advice fires.
Post-omni: omni rejects SEQUENCE/FLASHBACK → soft-fail skips →
advisor sees only UPDATE/DELETE → no DDL detected → safety gate
silently misses.
Empirical verification (parse-test through omni): all five inputs
(CREATE/ALTER/DROP SEQUENCE, FLASHBACK DATABASE, FLASHBACK TABLE)
fail omni parsing with syntax error.
Fix: DDL detection switches to the `getTiDBNodes` (pingcap) path.
Pingcap's DDLNode interface (via the ddlNode struct embedding in
ast/base.go:81-88) catches all 22 implementers including Tier-4-
deferred grammar. The advisor still uses `getTiDBOmniNodes` for
per-table DML mixing detection (where omni AST shape is required);
DDL detection sidesteps omni's grammar gaps.
Architectural note: this dual-path approach mirrors mysql's analog,
which uses mysqlparser.ExtractTables alongside the omni AST.
Specialized advisors that need both full-grammar coverage AND
omni-specific AST shape will need both paths until omni grammar
parity catches up.
Side effects:
- omniIsDDLStmt helper REMOVED. Eight rounds of Codex catches on
omni-only DDL enumeration (cumulative #30 Codex-fix-1c through 1e)
demonstrated the brittle-enumeration anti-pattern; pingcap's
authoritative DDLNode interface eliminates the maintenance burden.
- TestOmniIsDDLStmt REMOVED. The helper it tested is gone. End-to-end
coverage of the DDL-detection path moves to TestTiDBPriorBackupCheckAdvisor.
Regression-direction pins added (TestTiDBPriorBackupCheckAdvisor
case count: 14 → 16):
- "CREATE SEQUENCE + UPDATE fires mixed DDL+DML via pingcap path
(Codex-fix-1f)": `CREATE SEQUENCE seq1 ...; UPDATE tech_book ...;`
→ MUST fire.
- "FLASHBACK TABLE + DELETE fires mixed DDL+DML via pingcap path
(Codex-fix-1f)": `FLASHBACK TABLE tech_book TO tech_book_old;
DELETE FROM orders ...;` → MUST fire.
Both pins exercise the new pingcap-DDLNode resolution path.
Cumulative #30 algorithm-corrections sub-fix lineage now spans
eight sub-fixes:
1 — SET-clause-based target extraction
1b — distinct-base gating
1c — DDL classification (DropView + AlterDatabase)
1d — schema-qualified UPDATE target lookup
1e — schema-aware unqualified-SET resolution
1f — DDL detection via pingcap DDLNode (drops omniIsDDLStmt)
2 — case-insensitive grouping key
2-revised — DBSchema.Name default-DB
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 1e7ec6c commit ebc36f0
3 files changed
Lines changed: 87 additions & 118 deletions
File tree
- backend/plugin/advisor/tidb
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
268 | 268 | | |
269 | 269 | | |
270 | 270 | | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
271 | 305 | | |
272 | 306 | | |
273 | 307 | | |
| |||

0 commit comments