Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow table_schema comparisons #6887

Merged
merged 1 commit into from
Oct 16, 2020
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
5 changes: 5 additions & 0 deletions go/vt/vtgate/planbuilder/select.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,11 @@ func (r *rewriter) rewriteTableSchema(cursor *sqlparser.Cursor) bool {

evalExpr, err := sqlparser.Convert(parent.Right)
if err != nil {
if err == sqlparser.ErrExprNotSupported {
// This just means we can't rewrite this particular expression,
// not that we have to exit altogether
return true
}
r.err = err
return false
}
Expand Down
17 changes: 17 additions & 0 deletions go/vt/vtgate/planbuilder/testdata/from_cases.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2115,3 +2115,20 @@
# non-existent table on right of join
"select c from user join t"
"table t not found"

# information schema query that uses table_schema
"select column_name from information_schema.columns where table_schema = (select schema())"
{
"QueryType": "SELECT",
"Original": "select column_name from information_schema.columns where table_schema = (select schema())",
"Instructions": {
"OperatorType": "Route",
"Variant": "SelectDBA",
"Keyspace": {
"Name": "main",
"Sharded": false
},
"FieldQuery": "select column_name from information_schema.`columns` where 1 != 1",
"Query": "select column_name from information_schema.`columns` where table_schema = schema()"
}
}