From ae2979fa661b8c3bdbfc25b6107a90508884af7b Mon Sep 17 00:00:00 2001 From: Daylon Wilkins Date: Mon, 20 May 2024 05:18:17 -0700 Subject: [PATCH] Added InjectedStatement --- go/vt/sqlparser/ast.go | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/go/vt/sqlparser/ast.go b/go/vt/sqlparser/ast.go index 2b6842c75ef..20f257bd70b 100644 --- a/go/vt/sqlparser/ast.go +++ b/go/vt/sqlparser/ast.go @@ -7486,16 +7486,16 @@ func (node *SrsAttribute) Format(buf *TrackedBuffer) { buf.Myprintf("description '%s'", node.Description) } -// InjectableExpression is an expression that can accept a set of analyzed/resolved children. Used within InjectedExpr. -type InjectableExpression interface { +// Injectable is an expression that can accept a set of analyzed/resolved children. Used within InjectedExpr. +type Injectable interface { WithResolvedChildren(children []any) (any, error) } // InjectedExpr allows bypassing AST analysis. This is used by projects that rely on Vitess, but may not implement // MySQL's dialect. type InjectedExpr struct { - Expression InjectableExpression - Children []Expr + Expression Injectable + Children Exprs } var _ Expr = InjectedExpr{} @@ -7516,3 +7516,24 @@ func (d InjectedExpr) Format(buf *TrackedBuffer) { buf.WriteString("InjectedExpr") } } + +// InjectedStatement allows bypassing AST analysis. This is used by projects that rely on Vitess, but may not implement +// MySQL's dialect. +type InjectedStatement struct { + Statement Injectable + Children Exprs +} + +var _ Statement = InjectedStatement{} + +// iStatement implements the Statement interface. +func (d InjectedStatement) iStatement() {} + +// Format implements the Statement interface. +func (d InjectedStatement) Format(buf *TrackedBuffer) { + if stringer, ok := d.Statement.(fmt.Stringer); ok { + buf.WriteString(stringer.String()) + } else { + buf.WriteString("InjectedStatement") + } +}