Skip to content

Commit

Permalink
Cherry-pick 11a655c with conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
vitess-bot[bot] authored and vitess-bot committed Oct 23, 2024
1 parent 477bb22 commit d3aaaf7
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 10 deletions.
14 changes: 14 additions & 0 deletions go/vt/vttablet/endtoend/queries_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,20 @@ var TestQueryCases = []framework.Testable{
},
RowsReturned: 1,
},
&framework.TestCase{
Name: "explain with bindvars",
Query: "explain select :__vtudvp as `@p` from dual",
BindVars: map[string]*querypb.BindVariable{
"__vtudvp": sqltypes.Int64BindVariable(1),
},
Result: [][]string{
{"1", "SIMPLE", "", "", "", "", "", "", "", "", "", "No tables used"},
},
Rewritten: []string{
"explain select 1 as `@p` from dual",
},
RowsReturned: 1,
},
&framework.TestCase{
Name: "limit",
Query: "select /* limit */ eid, id from vitess_a limit :a",
Expand Down
9 changes: 9 additions & 0 deletions go/vt/vttablet/tabletserver/planbuilder/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,16 @@ func Build(env *vtenv.Environment, statement sqlparser.Statement, tables map[str
case *sqlparser.Show:
plan, err = analyzeShow(stmt, dbName)
case *sqlparser.Analyze, sqlparser.Explain:
<<<<<<< HEAD

Check failure on line 237 in go/vt/vttablet/tabletserver/planbuilder/plan.go

View workflow job for this annotation

GitHub Actions / Code Coverage

syntax error: unexpected <<, expected case or default or }

Check failure on line 237 in go/vt/vttablet/tabletserver/planbuilder/plan.go

View workflow job for this annotation

GitHub Actions / Code Coverage

syntax error: unexpected <<, expected case or default or }
plan, err = &Plan{PlanID: PlanOtherRead}, nil

Check failure on line 238 in go/vt/vttablet/tabletserver/planbuilder/plan.go

View workflow job for this annotation

GitHub Actions / Code Coverage

syntax error: unexpected comma at end of statement

Check failure on line 238 in go/vt/vttablet/tabletserver/planbuilder/plan.go

View workflow job for this annotation

GitHub Actions / Code Coverage

syntax error: unexpected comma at end of statement
=======

Check failure on line 239 in go/vt/vttablet/tabletserver/planbuilder/plan.go

View workflow job for this annotation

GitHub Actions / Code Coverage

syntax error: unexpected ==, expected }

Check failure on line 239 in go/vt/vttablet/tabletserver/planbuilder/plan.go

View workflow job for this annotation

GitHub Actions / Code Coverage

syntax error: unexpected ==, expected }
// Analyze and Explain are treated as read-only queries.
// We send down a string, and get a table result back.
plan = &Plan{
PlanID: PlanSelect,
FullQuery: GenerateFullQuery(stmt),
}
>>>>>>> 11a655ca06 (bugfix: treat EXPLAIN like SELECT (#17054))

Check failure on line 246 in go/vt/vttablet/tabletserver/planbuilder/plan.go

View workflow job for this annotation

GitHub Actions / Code Coverage

invalid character U+0023 '#'

Check failure on line 246 in go/vt/vttablet/tabletserver/planbuilder/plan.go

View workflow job for this annotation

GitHub Actions / Code Coverage

invalid character U+0023 '#'
case *sqlparser.OtherAdmin:
plan, err = &Plan{PlanID: PlanOtherAdmin}, nil
case *sqlparser.Savepoint:
Expand Down
23 changes: 13 additions & 10 deletions go/vt/vttablet/tabletserver/planbuilder/testdata/exec_cases.txt
Original file line number Diff line number Diff line change
Expand Up @@ -763,14 +763,15 @@ options:PassthroughDMLs
# analyze
"analyze table a"
{
"PlanID": "OtherRead",
"PlanID": "Select",
"TableName": "",
"Permissions": [
{
"TableName": "a",
"Role": 1
}
]
{
"TableName": "a",
"Role": 1
}
],
"FullQuery": "analyze table a"
}

# show
Expand All @@ -783,15 +784,17 @@ options:PassthroughDMLs
# describe
"describe a"
{
"PlanID": "OtherRead",
"TableName": ""
"PlanID": "Select",
"TableName": "",
"FullQuery": "explain a"
}

# explain
"explain a"
{
"PlanID": "OtherRead",
"TableName": ""
"PlanID": "Select",
"TableName": "",
"FullQuery": "explain a"
}

# repair
Expand Down

0 comments on commit d3aaaf7

Please sign in to comment.