diff --git a/go/vt/vtgate/planbuilder/select.go b/go/vt/vtgate/planbuilder/select.go index 24e72e731f0..496c06d1e2b 100644 --- a/go/vt/vtgate/planbuilder/select.go +++ b/go/vt/vtgate/planbuilder/select.go @@ -332,12 +332,17 @@ func (r *rewriter) rewriteTableSchema(cursor *sqlparser.Cursor) bool { switch parent := cursor.Parent().(type) { case *sqlparser.ComparisonExpr: if parent.Operator == sqlparser.EqualOp && shouldRewrite(parent.Right) { - 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 } + r.tableNameExpressions = append(r.tableNameExpressions, evalExpr) parent.Right = sqlparser.NewArgument([]byte(":" + sqltypes.BvSchemaName)) } diff --git a/go/vt/vtgate/planbuilder/testdata/from_cases.txt b/go/vt/vtgate/planbuilder/testdata/from_cases.txt index bdf90d1151b..0a76fe74543 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 = (select schema() from dual)" + } +}