Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

refactor(advisor/tidb): migrate WHERE-required pair + leading-wildcard LIKE to omni AST (Phase 1.5 §1.5.3 batch 5) (#20211)

Vincent Huangd497ff369b51
diff --git a/backend/plugin/advisor/tidb/advisor_stmt_no_leading_wildcard_like.go b/backend/plugin/advisor/tidb/advisor_stmt_no_leading_wildcard_like.go
index 99f398e882..0bf56455f5 100644
--- a/backend/plugin/advisor/tidb/advisor_stmt_no_leading_wildcard_like.go
+++ b/backend/plugin/advisor/tidb/advisor_stmt_no_leading_wildcard_like.go
@@ -4,8 +4,7 @@ import (
"context"
"fmt"
- "github.com/pingcap/tidb/pkg/parser/ast"
- "github.com/pingcap/tidb/pkg/parser/format"
+ "github.com/bytebase/omni/tidb/ast"
"github.com/bytebase/bytebase/backend/common"
storepb "github.com/bytebase/bytebase/backend/generated-go/store"
@@ -14,26 +13,39 @@ import (
)
const (
- wildcard string = "%"
+ wildcard byte = '%'
)
var (
_ advisor.Advisor = (*NoLeadingWildcardLikeAdvisor)(nil)
- _ ast.Visitor = (*noLeadingWildcardLikeChecker)(nil)
+ _ ast.Visitor = (*noLeadingWildcardLikeVisitor)(nil)
)
func init() {
advisor.Register(storepb.Engine_TIDB, storepb.SQLReviewRule_STATEMENT_WHERE_NO_LEADING_WILDCARD_LIKE, &NoLeadingWildcardLikeAdvisor{})
}
-// NoLeadingWildcardLikeAdvisor is the advisor checking for no leading wildcard LIKE.
+// NoLeadingWildcardLikeAdvisor checks for LIKE patterns that begin with
+// `%`, e.g. `WHERE x LIKE '%foo'`. Such patterns force a full table scan;
+// the rule warns even on NOT LIKE because the same scan cost applies.
type NoLeadingWildcardLikeAdvisor struct {
}
-// Check checks for no leading wildcard LIKE.
+// Check is Recipe B (sub-walk via omni Visitor) — LIKE expressions can
+// appear in any WHERE clause depth, including UNION arms, subqueries, and
+// CTEs.
+//
+// Per pingcap-typed advisor's behavior (preserved here):
+// - Fires once per top-level statement, regardless of how many leading-`%`
+// LIKE expressions it contains.
+// - Doesn't distinguish LIKE from NOT LIKE — both trigger.
+// - Only `%` triggers; `_` (single-character wildcard) doesn't.
+// - ESCAPE clause doesn't affect the pattern check.
+// - Non-string-literal patterns (parameter `?`, column refs, function
+// calls) silently skip — pingcap's restoreNode produced text starting
+// with `?` / column-name / function-name, none of which start with `%`.
func (*NoLeadingWildcardLikeAdvisor) Check(_ context.Context, checkCtx advisor.Context) ([]*storepb.Advice, error) {
- root, err := getTiDBNodes(checkCtx)
-
+ stmts, err := getTiDBOmniNodes(checkCtx)
if err != nil {
return nil, err
}
@@ -43,53 +55,68 @@ func (*NoLeadingWildcardLikeAdvisor) Check(_ context.Context, checkCtx advisor.C
return nil, err
}
- checker := &noLeadingWildcardLikeChecker{level: level}
- for _, stmtNode := range root {
- checker.text = stmtNode.Text()
- checker.leadingWildcardLike = false
- (stmtNode).Accept(checker)
-
- if checker.leadingWildcardLike {
- checker.adviceList = append(checker.adviceList, &storepb.Advice{
- Status: checker.level,
- Code: code.StatementLeadingWildcardLike.Int32(),
- Title: checkCtx.Rule.Type.String(),
- Content: fmt.Sprintf("\"%s\" uses leading wildcard LIKE", checker.text),
- StartPosition: common.ConvertANTLRLineToPosition(stmtNode.OriginTextPosition()),
- })
+ title := checkCtx.Rule.Type.String()
+ var adviceList []*storepb.Advice
+ for _, ostmt := range stmts {
+ v := &noLeadingWildcardLikeVisitor{}
+ ast.Walk(v, ostmt.Node)
+ if !v.found {
+ continue
}
+ adviceList = append(adviceList, &storepb.Advice{
+ Status: level,
+ Code: code.StatementLeadingWildcardLike.Int32(),
+ Title: title,
+ Content: fmt.Sprintf("\"%s\" uses leading wildcard LIKE", ostmt.TrimmedText()),
+ StartPosition: common.ConvertANTLRLineToPosition(ostmt.FirstTokenLine()),
+ })
}
-
- return checker.adviceList, nil
+ return adviceList, nil
}
-type noLeadingWildcardLikeChecker struct {
- adviceList []*storepb.Advice
- level storepb.Advice_Status
- text string
- leadingWildcardLike bool
+type noLeadingWildcardLikeVisitor struct {
+ found bool
}
-// Enter implements the ast.Visitor interface.
-func (v *noLeadingWildcardLikeChecker) Enter(in ast.Node) (ast.Node, bool) {
- if node, ok := in.(*ast.PatternLikeOrIlikeExpr); !v.leadingWildcardLike && ok {
- pattern, err := restoreNode(node.Pattern, format.RestoreStringWithoutCharset)
- if err != nil {
- v.adviceList = append(v.adviceList, &storepb.Advice{
- Status: v.level,
- Code: code.Internal.Int32(),
- Title: "Internal error for no leading wildcard LIKE rule",
- Content: fmt.Sprintf("\"%s\" meet internal error %q", v.text, err.Error()),
- })
- }
- if len(pattern) > 0 && pattern[:1] == wildcard {
- v.leadingWildcardLike = true
+// Visit returns v to recurse into children. Once a leading-`%` is found,
+// returns nil to skip the remaining subtree — the check is per-statement
+// boolean, no benefit to continuing.
+func (v *noLeadingWildcardLikeVisitor) Visit(node ast.Node) ast.Visitor {
+ if node == nil || v.found {
+ return nil
+ }
+ like, ok := node.(*ast.LikeExpr)
+ if !ok {
+ return v
+ }
+ // Pingcap doesn't gate on like.Not — NOT LIKE with leading wildcard
+ // triggers the same as LIKE. Mirror that behavior.
+ //
+ // Cumulative shape divergence #11: omni wraps `'%abc' COLLATE
+ // utf8mb4_bin` as *CollateExpr{Expr: *StringLit, Collation: "..."}.
+ // Pingcap's *SetCollationExpr restored to text as
+ // "%abc COLLATE utf8mb4_bin" (value first, COLLATE clause after), so
+ // pingcap's leading-`%` check accidentally fired on the rendered text.
+ // Without the unwrap, omni would silently skip and regress vs. pingcap.
+ // The loop handles nested COLLATE defensively (not produced by current
+ // TiDB grammar but cheap insurance).
+ pattern := like.Pattern
+ for {
+ c, ok := pattern.(*ast.CollateExpr)
+ if !ok {
+ break
}
+ pattern = c.Expr
}
- return in, false
-}
-
-// Leave implements the ast.Visitor interface.
-func (*noLeadingWildcardLikeChecker) Leave(in ast.Node) (ast.Node, bool) {
- return in, true
+ lit, ok := pattern.(*ast.StringLit)
+ if !ok {
+ // Non-literal patterns (parameter, column ref, expression) — skip.
+ // Per pingcap parity (see Check() docstring).
+ return v
+ }
+ if len(lit.Value) > 0 && lit.Value[0] == wildcard {
+ v.found = true
+ return nil
+ }
+ return v
}
diff --git a/backend/plugin/advisor/tidb/advisor_stmt_where_required_for_select.go b/backend/plugin/advisor/tidb/advisor_stmt_where_required_for_select.go
index dc099944db..0d8de07eb1 100644
--- a/backend/plugin/advisor/tidb/advisor_stmt_where_required_for_select.go
+++ b/backend/plugin/advisor/tidb/advisor_stmt_where_required_for_select.go
@@ -4,31 +4,40 @@ import (
"context"
"fmt"
+ "github.com/bytebase/omni/tidb/ast"
+
"github.com/bytebase/bytebase/backend/common"
storepb "github.com/bytebase/bytebase/backend/generated-go/store"
"github.com/bytebase/bytebase/backend/plugin/advisor"
advisorcode "github.com/bytebase/bytebase/backend/plugin/advisor/code"
-
- "github.com/pingcap/tidb/pkg/parser/ast"
)
var (
_ advisor.Advisor = (*WhereRequirementForSelectAdvisor)(nil)
- _ ast.Visitor = (*whereRequirementForSelectChecker)(nil)
+ _ ast.Visitor = (*whereRequireSelectVisitor)(nil)
)
func init() {
advisor.Register(storepb.Engine_TIDB, storepb.SQLReviewRule_STATEMENT_WHERE_REQUIRE_SELECT, &WhereRequirementForSelectAdvisor{})
}
-// WhereRequirementForSelectAdvisor is the advisor checking for the WHERE clause requirement for SELECT statements.
+// WhereRequirementForSelectAdvisor checks the WHERE clause requirement for
+// SELECT statements.
type WhereRequirementForSelectAdvisor struct {
}
-// Check checks for the WHERE clause requirement.
+// Check is Recipe B (sub-walk via omni Visitor) — the pingcap-typed
+// version's Visitor returns (in, false) and so recurses into sub-selects;
+// the existing fixture
+//
+// SELECT id FROM tech_book WHERE id > (SELECT max(id) FROM tech_book)
+//
+// expects an advice on the inner SELECT (outer has a WHERE; trigger must
+// come from the inner subquery). A naive Recipe-A top-level type-switch
+// would silently regress on this case — same shape of bug as batch 3's
+// no_select_all round-1 missed-qualified-wildcard.
func (*WhereRequirementForSelectAdvisor) Check(_ context.Context, checkCtx advisor.Context) ([]*storepb.Advice, error) {
- root, err := getTiDBNodes(checkCtx)
-
+ stmts, err := getTiDBOmniNodes(checkCtx)
if err != nil {
return nil, err
}
@@ -37,50 +46,58 @@ func (*WhereRequirementForSelectAdvisor) Check(_ context.Context, checkCtx advis
if err != nil {
return nil, err
}
- checker := &whereRequirementForSelectChecker{
- level: level,
- title: checkCtx.Rule.Type.String(),
- }
- for _, stmtNode := range root {
- checker.text = stmtNode.Text()
- checker.line = stmtNode.OriginTextPosition()
- (stmtNode).Accept(checker)
- }
- return checker.adviceList, nil
+ title := checkCtx.Rule.Type.String()
+ var adviceList []*storepb.Advice
+ for _, ostmt := range stmts {
+ // Pingcap parity: every match reports the OUTER statement's
+ // first-token line and trimmed text, not the inner SelectStmt's
+ // position — checker.text/line are set ONCE per top-level statement
+ // in the pingcap version (before Accept()).
+ v := &whereRequireSelectVisitor{
+ level: level,
+ title: title,
+ text: ostmt.TrimmedText(),
+ line: ostmt.FirstTokenLine(),
+ advices: &adviceList,
+ }
+ ast.Walk(v, ostmt.Node)
+ }
+ return adviceList, nil
}
-type whereRequirementForSelectChecker struct {
- adviceList []*storepb.Advice
- level storepb.Advice_Status
- title string
- text string
- line int
+type whereRequireSelectVisitor struct {
+ level storepb.Advice_Status
+ title string
+ text string
+ line int
+ advices *[]*storepb.Advice
}
-// Enter implements the ast.Visitor interface.
-func (v *whereRequirementForSelectChecker) Enter(in ast.Node) (ast.Node, bool) {
- code := advisorcode.Ok
- if node, ok := in.(*ast.SelectStmt); ok {
- // Allow SELECT queries without a FROM clause to proceed, e.g. SELECT 1.
- if node.Where == nil && node.From != nil {
- code = advisorcode.StatementNoWhere
- }
+// Visit returns v to recurse into children, including SelectStmt.Left/Right
+// (UNION arms) per omni's Walk contract.
+func (v *whereRequireSelectVisitor) Visit(node ast.Node) ast.Visitor {
+ if node == nil {
+ return nil
}
-
- if code != advisorcode.Ok {
- v.adviceList = append(v.adviceList, &storepb.Advice{
+ sel, ok := node.(*ast.SelectStmt)
+ if !ok {
+ return v
+ }
+ // Cumulative shape divergence #10: omni's SelectStmt.From is []TableExpr
+ // (slice), not pingcap's *TableRefsClause (pointer). len(From) > 0
+ // is the correct "has FROM" check; `From != nil` would be wrong on
+ // empty-but-non-nil slices.
+ //
+ // Allow SELECT without FROM (e.g. SELECT 1, SELECT CURDATE()).
+ if sel.Where == nil && len(sel.From) > 0 {
+ *v.advices = append(*v.advices, &storepb.Advice{
Status: v.level,
- Code: code.Int32(),
+ Code: advisorcode.StatementNoWhere.Int32(),
Title: v.title,
Content: fmt.Sprintf("\"%s\" requires WHERE clause", v.text),
StartPosition: common.ConvertANTLRLineToPosition(v.line),
})
}
- return in, false
-}
-
-// Leave implements the ast.Visitor interface.
-func (*whereRequirementForSelectChecker) Leave(in ast.Node) (ast.Node, bool) {
- return in, true
+ return v
}
diff --git a/backend/plugin/advisor/tidb/advisor_stmt_where_required_for_update_delete.go b/backend/plugin/advisor/tidb/advisor_stmt_where_required_for_update_delete.go
index 464c9f550f..8ed348224d 100644
--- a/backend/plugin/advisor/tidb/advisor_stmt_where_required_for_update_delete.go
+++ b/backend/plugin/advisor/tidb/advisor_stmt_where_required_for_update_delete.go
@@ -4,31 +4,42 @@ import (
"context"
"fmt"
+ "github.com/bytebase/omni/tidb/ast"
+
"github.com/bytebase/bytebase/backend/common"
storepb "github.com/bytebase/bytebase/backend/generated-go/store"
"github.com/bytebase/bytebase/backend/plugin/advisor"
advisorcode "github.com/bytebase/bytebase/backend/plugin/advisor/code"
-
- "github.com/pingcap/tidb/pkg/parser/ast"
)
var (
_ advisor.Advisor = (*WhereRequirementForUpdateDeleteAdvisor)(nil)
- _ ast.Visitor = (*whereRequirementForUpdateDeleteChecker)(nil)
+ _ ast.Visitor = (*whereRequireUpdateDeleteVisitor)(nil)
)
func init() {
advisor.Register(storepb.Engine_TIDB, storepb.SQLReviewRule_STATEMENT_WHERE_REQUIRE_UPDATE_DELETE, &WhereRequirementForUpdateDeleteAdvisor{})
}
-// WhereRequirementForUpdateDeleteAdvisor is the advisor checking for the WHERE clause requirement for UPDATE and DELETE statements.
+// WhereRequirementForUpdateDeleteAdvisor checks the WHERE clause
+// requirement for UPDATE and DELETE statements.
type WhereRequirementForUpdateDeleteAdvisor struct {
}
-// Check checks for the WHERE clause requirement.
+// Check is Recipe B (sub-walk via omni Visitor). The initial batch-5
+// implementation was Recipe A on the assumption that UPDATE and DELETE
+// can't nest in standard SQL — but that missed statement-wrapper forms
+// like `EXPLAIN DELETE FROM t` and `EXPLAIN UPDATE t SET x = 1`. Both
+// pingcap and omni produce *ExplainStmt{Stmt: *DeleteStmt}, and pingcap's
+// Visitor walked into the inner DML to fire the rule. A Recipe A
+// migration silently regresses on the EXPLAIN-wrapped form.
+//
+// Per Phase 1.5 cumulative shape divergence #13 (Codex P2 round-1 catch
+// on PR #20211): wrapper statements (EXPLAIN, TRACE, DESCRIBE, ...) embed
+// DML at omni's nodes that mechanical top-level type-switch ignores.
+// Recipe B with omniast.Walk handles every wrapper kind automatically.
func (*WhereRequirementForUpdateDeleteAdvisor) Check(_ context.Context, checkCtx advisor.Context) ([]*storepb.Advice, error) {
- root, err := getTiDBNodes(checkCtx)
-
+ stmts, err := getTiDBOmniNodes(checkCtx)
if err != nil {
return nil, err
}
@@ -37,57 +48,61 @@ func (*WhereRequirementForUpdateDeleteAdvisor) Check(_ context.Context, checkCtx
if err != nil {
return nil, err
}
- checker := &whereRequirementForUpdateDeleteChecker{
- level: level,
- title: checkCtx.Rule.Type.String(),
- }
- for _, stmtNode := range root {
- checker.text = stmtNode.Text()
- checker.line = stmtNode.OriginTextPosition()
- (stmtNode).Accept(checker)
- }
- return checker.adviceList, nil
+ title := checkCtx.Rule.Type.String()
+ var adviceList []*storepb.Advice
+ for _, ostmt := range stmts {
+ // Pingcap parity: every match reports the OUTER statement's
+ // trimmed text and first-token line. For EXPLAIN DELETE FROM t,
+ // the advice content is the EXPLAIN statement, not the inner
+ // DeleteStmt — same as pingcap's `checker.text/line` set once
+ // before Accept().
+ v := &whereRequireUpdateDeleteVisitor{
+ level: level,
+ title: title,
+ text: ostmt.TrimmedText(),
+ line: ostmt.FirstTokenLine(),
+ advices: &adviceList,
+ }
+ ast.Walk(v, ostmt.Node)
+ }
+ return adviceList, nil
}
-type whereRequirementForUpdateDeleteChecker struct {
- adviceList []*storepb.Advice
- level storepb.Advice_Status
- title string
- text string
- line int
+type whereRequireUpdateDeleteVisitor struct {
+ level storepb.Advice_Status
+ title string
+ text string
+ line int
+ advices *[]*storepb.Advice
}
-// Enter implements the ast.Visitor interface.
-func (v *whereRequirementForUpdateDeleteChecker) Enter(in ast.Node) (ast.Node, bool) {
- code := advisorcode.Ok
- switch node := in.(type) {
- // DELETE
+// Visit returns v to recurse into children, including ExplainStmt.Stmt
+// and other statement-wrapper forms.
+func (v *whereRequireUpdateDeleteVisitor) Visit(node ast.Node) ast.Visitor {
+ if node == nil {
+ return nil
+ }
+ var noWhere bool
+ switch n := node.(type) {
case *ast.DeleteStmt:
- if node.Where == nil {
- code = advisorcode.StatementNoWhere
+ if n.Where == nil {
+ noWhere = true
}
- // UPDATE
case *ast.UpdateStmt:
- if node.Where == nil {
- code = advisorcode.StatementNoWhere
+ if n.Where == nil {
+ noWhere = true
}
default:
}
-
- if code != advisorcode.Ok {
- v.adviceList = append(v.adviceList, &storepb.Advice{
+ if noWhere {
+ *v.advices = append(*v.advices, &storepb.Advice{
Status: v.level,
- Code: code.Int32(),
+ Code: advisorcode.StatementNoWhere.Int32(),
Title: v.title,
Content: fmt.Sprintf("\"%s\" requires WHERE clause", v.text),
StartPosition: common.ConvertANTLRLineToPosition(v.line),
})
}
- return in, false
-}
-
-// Leave implements the ast.Visitor interface.
-func (*whereRequirementForUpdateDeleteChecker) Leave(in ast.Node) (ast.Node, bool) {
- return in, true
+ return v
}
diff --git a/backend/plugin/advisor/tidb/test/statement_where_no_leading_wildcard_like.yaml b/backend/plugin/advisor/tidb/test/statement_where_no_leading_wildcard_like.yaml
index 6cb384930f..1a16bc8c71 100644
--- a/backend/plugin/advisor/tidb/test/statement_where_no_leading_wildcard_like.yaml
+++ b/backend/plugin/advisor/tidb/test/statement_where_no_leading_wildcard_like.yaml
@@ -44,3 +44,82 @@
line: 1
column: 0
endposition: null
+# LIKE matrix pins (added with the omni Recipe B migration). Per pingcap
+# parity, NOT LIKE with leading `%` triggers (advisor doesn't gate on
+# the Not flag); ESCAPE clause doesn't affect the pattern check; only
+# `%` is the wildcard (`_` is not flagged); non-string-literal patterns
+# silently skip (parameter `?` doesn't trigger because pingcap restored
+# it as `?`, omni skips because pattern is not *StringLit). UNION arms
+# are walked by omni's Walk per the cumulative shape-divergence table
+# item #5.
+- statement: SELECT * FROM t WHERE a NOT LIKE '%abc'
+ changeType: 1
+ want:
+ - status: 2
+ code: 204
+ title: STATEMENT_WHERE_NO_LEADING_WILDCARD_LIKE
+ content: '"SELECT * FROM t WHERE a NOT LIKE ''%abc''" uses leading wildcard LIKE'
+ startposition:
+ line: 1
+ column: 0
+ endposition: null
+- statement: SELECT * FROM t WHERE a LIKE '%abc' ESCAPE '\\'
+ changeType: 1
+ want:
+ - status: 2
+ code: 204
+ title: STATEMENT_WHERE_NO_LEADING_WILDCARD_LIKE
+ content: '"SELECT * FROM t WHERE a LIKE ''%abc'' ESCAPE ''\\''" uses leading wildcard LIKE'
+ startposition:
+ line: 1
+ column: 0
+ endposition: null
+- statement: SELECT * FROM t WHERE a LIKE '_abc'
+ changeType: 1
+- statement: SELECT * FROM t WHERE a LIKE 'abc'
+ changeType: 1
+- statement: SELECT * FROM t WHERE a LIKE ?
+ changeType: 1
+- statement: SELECT * FROM t WHERE a LIKE 'foo' UNION SELECT * FROM u WHERE a LIKE '%bar'
+ changeType: 1
+ want:
+ - status: 2
+ code: 204
+ title: STATEMENT_WHERE_NO_LEADING_WILDCARD_LIKE
+ content: '"SELECT * FROM t WHERE a LIKE ''foo'' UNION SELECT * FROM u WHERE a LIKE ''%bar''" uses leading wildcard LIKE'
+ startposition:
+ line: 1
+ column: 0
+ endposition: null
+# Cumulative shape divergence #11 (Codex P1 catch on PR #20211):
+# omni wraps `'%abc' COLLATE utf8mb4_bin` as *CollateExpr{Expr: *StringLit};
+# pingcap rendered *SetCollationExpr to text as "%abc COLLATE utf8mb4_bin"
+# (value first), so the leading-`%` check accidentally fired. The omni
+# port unwraps CollateExpr before the StringLit type-assert to preserve
+# pingcap behavior. Both fixtures pin the contract: leading-`%` with
+# COLLATE triggers; non-leading with COLLATE doesn't.
+- statement: SELECT * FROM t WHERE a LIKE '%abc' COLLATE utf8mb4_bin
+ changeType: 1
+ want:
+ - status: 2
+ code: 204
+ title: STATEMENT_WHERE_NO_LEADING_WILDCARD_LIKE
+ content: '"SELECT * FROM t WHERE a LIKE ''%abc'' COLLATE utf8mb4_bin" uses leading wildcard LIKE'
+ startposition:
+ line: 1
+ column: 0
+ endposition: null
+- statement: SELECT * FROM t WHERE a LIKE 'abc' COLLATE utf8mb4_bin
+ changeType: 1
+# Cumulative shape divergence #12 (peer-review preempt; empirically NOT
+# a regression). LIKE ('%abc') wraps the literal in parens. Pingcap
+# parses Pattern as *ast.ParenthesesExpr; restoreNode renders as
+# "(%abc)" (parens preserved), so pattern[0] == '(' and pingcap does
+# NOT trigger. Omni parses Pattern as *ast.ParenExpr{Expr: *StringLit};
+# the StringLit type-assert fails, silently skips. Same outcome via
+# different mechanisms — no divergence. DO NOT add ParenExpr to the
+# CollateExpr unwrap loop; doing so would make omni start triggering
+# on a case pingcap doesn't, introducing a real regression. This
+# fixture pins the non-trigger contract.
+- statement: SELECT * FROM t WHERE a LIKE ('%abc')
+ changeType: 1
diff --git a/backend/plugin/advisor/tidb/test/statement_where_require_update_delete.yaml b/backend/plugin/advisor/tidb/test/statement_where_require_update_delete.yaml
index 3809646ab7..261286be15 100644
--- a/backend/plugin/advisor/tidb/test/statement_where_require_update_delete.yaml
+++ b/backend/plugin/advisor/tidb/test/statement_where_require_update_delete.yaml
@@ -24,3 +24,36 @@
changeType: 1
- statement: UPDATE tech_book SET id = 1 WHERE id > 10
changeType: 1
+# Cumulative shape divergence #13 (Codex P2 catch on PR #20211, batch 5
+# round-1). EXPLAIN/TRACE/DESCRIBE wrap DML — both pingcap and omni
+# parse `EXPLAIN DELETE FROM t` as *ExplainStmt{Stmt: *DeleteStmt}.
+# Pingcap's Visitor walked into the inner DML; the initial batch-5
+# Recipe A migration only checked the top-level type and silently
+# regressed on the EXPLAIN-wrapped form. Switched to Recipe B; these
+# fixtures pin the contract.
+- statement: EXPLAIN DELETE FROM tech_book
+ changeType: 1
+ want:
+ - status: 2
+ code: 202
+ title: STATEMENT_WHERE_REQUIRE_UPDATE_DELETE
+ content: '"EXPLAIN DELETE FROM tech_book" requires WHERE clause'
+ startposition:
+ line: 1
+ column: 0
+ endposition: null
+- statement: EXPLAIN UPDATE tech_book SET id = 1
+ changeType: 1
+ want:
+ - status: 2
+ code: 202
+ title: STATEMENT_WHERE_REQUIRE_UPDATE_DELETE
+ content: '"EXPLAIN UPDATE tech_book SET id = 1" requires WHERE clause'
+ startposition:
+ line: 1
+ column: 0
+ endposition: null
+- statement: EXPLAIN DELETE FROM tech_book WHERE id > 0
+ changeType: 1
+- statement: EXPLAIN UPDATE tech_book SET id = 1 WHERE id > 10
+ changeType: 1