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

handle system databases other that information_schema correctly (#12175) #144

Closed
wants to merge 1 commit into from
Closed
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
12 changes: 12 additions & 0 deletions go/test/endtoend/vtgate/gen4/system_schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,15 @@ func TestMultipleSchemaPredicates(t *testing.T) {
require.Error(t, err)
require.Contains(t, err.Error(), "specifying two different database in the query is not supported")
}

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

utils.Exec(t, conn, `select * from sys.sys_config`)
utils.Exec(t, conn, "select * from mysql.`db`")
utils.Exec(t, conn, "select * from performance_schema.error_log")
}
57 changes: 57 additions & 0 deletions go/vt/vtgate/planbuilder/testdata/systemtables_cases80.json
Original file line number Diff line number Diff line change
Expand Up @@ -1866,5 +1866,62 @@
"information_schema.key_column_usage"
]
}
},
{
"comment": "select variable, value from sys.sys_config",
"query": "select variable, value from sys.sys_config",
"plan": {
"QueryType": "SELECT",
"Original": "select variable, value from sys.sys_config",
"Instructions": {
"OperatorType": "Route",
"Variant": "DBA",
"Keyspace": {
"Name": "main",
"Sharded": false
},
"FieldQuery": "select variable, value from sys.sys_config where 1 != 1",
"Query": "select variable, value from sys.sys_config",
"Table": "sys.sys_config"
}
}
},
{
"comment": "select host, db from mysql.`db`",
"query": "select host, db from mysql.`db`",
"plan": {
"QueryType": "SELECT",
"Original": "select host, db from mysql.`db`",
"Instructions": {
"OperatorType": "Route",
"Variant": "DBA",
"Keyspace": {
"Name": "main",
"Sharded": false
},
"FieldQuery": "select host, db from mysql.db where 1 != 1",
"Query": "select host, db from mysql.db",
"Table": "mysql.db"
}
}
},
{
"comment": "select logged, prio from performance_schema.error_log",
"query": "select logged, prio from performance_schema.error_log",
"plan": {
"QueryType": "SELECT",
"Original": "select logged, prio from performance_schema.error_log",
"Instructions": {
"OperatorType": "Route",
"Variant": "DBA",
"Keyspace": {
"Name": "main",
"Sharded": false
},
"FieldQuery": "select logged, prio from performance_schema.error_log where 1 != 1",
"Query": "select logged, prio from performance_schema.error_log",
"Table": "performance_schema.error_log"
}
}
}
]
3 changes: 2 additions & 1 deletion go/vt/vtgate/semantics/table_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ func (tc *tableCollector) up(cursor *sqlparser.Cursor) error {
isInfSchema := sqlparser.SystemSchema(t.Qualifier.String())
var err error
tbl, vindex, _, _, _, err = tc.si.FindTableOrVindex(t)
if err != nil {
if err != nil && !isInfSchema {
// if we are dealing with a system table, it might not be available in the vschema, but that is OK
return err
}
if tbl == nil && vindex != nil {
Expand Down
Loading