From 0287bc32df390b754231b21d12074446453fcba7 Mon Sep 17 00:00:00 2001 From: Andres Taylor Date: Wed, 14 Oct 2020 17:45:39 +0200 Subject: [PATCH] No need to fail the whole query here Signed-off-by: Andres Taylor --- go/vt/vtgate/planbuilder/select.go | 5 +++++ .../vtgate/planbuilder/testdata/from_cases.txt | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/go/vt/vtgate/planbuilder/select.go b/go/vt/vtgate/planbuilder/select.go index 092476d790b..d2410a0ebb8 100644 --- a/go/vt/vtgate/planbuilder/select.go +++ b/go/vt/vtgate/planbuilder/select.go @@ -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 } diff --git a/go/vt/vtgate/planbuilder/testdata/from_cases.txt b/go/vt/vtgate/planbuilder/testdata/from_cases.txt index bdf90d1151b..67195e515f4 100644 --- a/go/vt/vtgate/planbuilder/testdata/from_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/from_cases.txt @@ -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()" + } +}