Skip to content

Commit

Permalink
fix: remove show statement from getting normalized
Browse files Browse the repository at this point in the history
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
  • Loading branch information
harshit-gangal committed Jan 27, 2025
1 parent e4e4715 commit b3b79f1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion go/vt/sqlparser/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func ASTToStatementType(stmt Statement) StatementType {
// CanNormalize takes Statement and returns if the statement can be normalized.
func CanNormalize(stmt Statement) bool {
switch stmt.(type) {
case *Select, *Union, *Insert, *Update, *Delete, *Set, *CallProc, *Stream, *VExplainStmt, *Show: // TODO: we could merge this logic into ASTrewriter
case *Select, *Union, *Insert, *Update, *Delete, *Set, *CallProc, *Stream, *VExplainStmt: // TODO: we could merge this logic into ASTrewriter
return true
}
return false
Expand Down
24 changes: 24 additions & 0 deletions go/vt/vtgate/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1860,6 +1860,30 @@ func TestPassthroughDDL(t *testing.T) {
sbc2.Queries = nil
}

func TestShowStatus(t *testing.T) {
executor, sbc1, _, _, ctx := createExecutorEnvWithConfig(t, createExecutorConfigWithNormalizer())
session := &vtgatepb.Session{
TargetString: "TestExecutor",
}

sql1 := "show slave status"
_, err := executorExec(ctx, executor, session, sql1, nil)
require.NoError(t, err)

sql2 := "show replica status"
_, err = executorExec(ctx, executor, session, sql2, nil)
require.NoError(t, err)

wantQueries := []*querypb.BoundQuery{{
Sql: sql1,
BindVariables: map[string]*querypb.BindVariable{},
}, {
Sql: sql2,
BindVariables: map[string]*querypb.BindVariable{},
}}
assert.Equal(t, wantQueries, sbc1.Queries)
}

func TestParseEmptyTargetSingleKeyspace(t *testing.T) {
r, _, _, _, _ := createExecutorEnv(t)

Expand Down

0 comments on commit b3b79f1

Please sign in to comment.