Skip to content
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
46 changes: 30 additions & 16 deletions go/vt/vtgate/planbuilder/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,26 +115,40 @@ func buildVariablePlan(show *sqlparser.ShowBasic, vschema ContextVSchema) (engin
func buildShowTblPlan(show *sqlparser.ShowBasic, vschema ContextVSchema) (engine.Primitive, error) {
if show.DbName != "" {
show.Tbl.Qualifier = sqlparser.NewTableIdent(show.DbName)
// Remove Database Name from the query.
show.DbName = ""
}
table, _, _, _, destination, err := vschema.FindTableOrVindex(show.Tbl)
if err != nil {
return nil, err
}
if table == nil {
return nil, vterrors.NewErrorf(vtrpcpb.Code_NOT_FOUND, vterrors.UnknownTable, "Table '%s' doesn't exist", show.Tbl.Name.String())
}
if destination == nil {
destination = key.DestinationAnyShard{}
}

// Remove Database Name from the query.
show.DbName = ""
show.Tbl.Qualifier = sqlparser.NewTableIdent("")
show.Tbl.Name = table.Name
dest := key.Destination(key.DestinationAnyShard{})
var ks *vindexes.Keyspace
var err error

if !show.Tbl.Qualifier.IsEmpty() && sqlparser.SystemSchema(show.Tbl.Qualifier.String()) {
ks, err = vschema.AnyKeyspace()
if err != nil {
return nil, err
}
} else {
table, _, _, _, destination, err := vschema.FindTableOrVindex(show.Tbl)
if err != nil {
return nil, err
}
if table == nil {
return nil, vterrors.NewErrorf(vtrpcpb.Code_NOT_FOUND, vterrors.UnknownTable, "Table '%s' doesn't exist", show.Tbl.Name.String())
}
// Update the table.
show.Tbl.Qualifier = sqlparser.NewTableIdent("")
show.Tbl.Name = table.Name

if destination != nil {
dest = destination
}
ks = table.Keyspace
}

return &engine.Send{
Keyspace: table.Keyspace,
TargetDestination: destination,
Keyspace: ks,
TargetDestination: dest,
Query: sqlparser.String(show),
IsDML: false,
SingleShardOnly: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,39 @@
]
}
}

# show full columns from system schema
"show full columns from sys.sys_config"
{
"QueryType": "SHOW",
"Original": "show full columns from sys.sys_config",
"Instructions": {
"OperatorType": "Send",
"Keyspace": {
"Name": "main",
"Sharded": false
},
"TargetDestination": "AnyShard()",
"IsDML": false,
"Query": "show full columns from sys.sys_config",
"SingleShardOnly": true
}
}

# show full columns from system schema replacing qualifier
"show full columns from x.sys_config from sys"
{
"QueryType": "SHOW",
"Original": "show full columns from x.sys_config from sys",
"Instructions": {
"OperatorType": "Send",
"Keyspace": {
"Name": "main",
"Sharded": false
},
"TargetDestination": "AnyShard()",
"IsDML": false,
"Query": "show full columns from sys.sys_config",
"SingleShardOnly": true
}
}