Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions go/test/endtoend/vtgate/misc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,19 @@ func TestSavepointAdditionalCase(t *testing.T) {
assertMatches(t, conn, "select id1 from t1 order by id1", `[]`)
}

func TestExplainPassthrough(t *testing.T) {
defer cluster.PanicHandler(t)
ctx := context.Background()
conn, err := mysql.Connect(ctx, &vtParams)
require.Nil(t, err)
defer conn.Close()

result := exec(t, conn, "explain select * from t1")
got := fmt.Sprintf("%v", result.Rows)
require.Contains(t, got, "SIMPLE") // there is a lot more coming from mysql,
// but we are trying to make the test less fragile
}

func assertMatches(t *testing.T, conn *mysql.Conn, query, expected string) {
t.Helper()
qr := exec(t, conn, query)
Expand Down
4 changes: 1 addition & 3 deletions go/vt/vttablet/tabletserver/planbuilder/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,7 @@ func Build(statement sqlparser.Statement, tables map[string]*schema.Table, isRes
// DDLs and other statements below don't get fully parsed.
// We have to use the original query at the time of execution.
plan = &Plan{PlanID: PlanDDL}
case *sqlparser.Show:
plan, err = &Plan{PlanID: PlanOtherRead}, nil
case *sqlparser.OtherRead:
case *sqlparser.Show, *sqlparser.OtherRead, *sqlparser.Explain:
plan, err = &Plan{PlanID: PlanOtherRead}, nil
case *sqlparser.OtherAdmin:
plan, err = &Plan{PlanID: PlanOtherAdmin}, nil
Expand Down