зеркало из https://github.com/github/vitess-gh.git
Merge pull request #4785 from mcuadros/show-schemas
sqlparser: support for SHOW SCHEMAS
This commit is contained in:
Коммит
6c55f2783e
|
@ -1120,6 +1120,9 @@ var (
|
|||
}, {
|
||||
input: "show databases",
|
||||
output: "show databases",
|
||||
}, {
|
||||
input: "show schemas",
|
||||
output: "show schemas",
|
||||
}, {
|
||||
input: "show engine INNODB",
|
||||
output: "show engine",
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -181,7 +181,7 @@ func skipToEnd(yylex interface{}) {
|
|||
%token <bytes> NULLX AUTO_INCREMENT APPROXNUM SIGNED UNSIGNED ZEROFILL
|
||||
|
||||
// Supported SHOW tokens
|
||||
%token <bytes> COLLATION DATABASES TABLES VITESS_KEYSPACES VITESS_SHARDS VITESS_TABLETS VSCHEMA VSCHEMA_TABLES VITESS_TARGET FULL PROCESSLIST COLUMNS FIELDS ENGINES PLUGINS
|
||||
%token <bytes> COLLATION DATABASES SCHEMAS TABLES VITESS_KEYSPACES VITESS_SHARDS VITESS_TABLETS VSCHEMA VSCHEMA_TABLES VITESS_TARGET FULL PROCESSLIST COLUMNS FIELDS ENGINES PLUGINS
|
||||
|
||||
// SET tokens
|
||||
%token <bytes> NAMES CHARSET GLOBAL SESSION ISOLATION LEVEL READ WRITE ONLY REPEATABLE COMMITTED UNCOMMITTED SERIALIZABLE
|
||||
|
@ -1485,6 +1485,10 @@ show_statement:
|
|||
{
|
||||
$$ = &Show{Type: string($2)}
|
||||
}
|
||||
| SHOW SCHEMAS ddl_skip_to_end
|
||||
{
|
||||
$$ = &Show{Type: string($2)}
|
||||
}
|
||||
| SHOW ENGINES
|
||||
{
|
||||
$$ = &Show{Type: string($2)}
|
||||
|
@ -3364,6 +3368,7 @@ non_reserved_keyword:
|
|||
| REPEATABLE
|
||||
| RESTRICT
|
||||
| ROLLBACK
|
||||
| SCHEMAS
|
||||
| SESSION
|
||||
| SERIALIZABLE
|
||||
| SHARE
|
||||
|
|
|
@ -318,7 +318,7 @@ var keywords = map[string]int{
|
|||
"rlike": REGEXP,
|
||||
"rollback": ROLLBACK,
|
||||
"schema": SCHEMA,
|
||||
"schemas": UNUSED,
|
||||
"schemas": SCHEMAS,
|
||||
"second_microsecond": UNUSED,
|
||||
"select": SELECT,
|
||||
"sensitive": UNUSED,
|
||||
|
|
|
@ -775,7 +775,7 @@ func (e *Executor) handleShow(ctx context.Context, safeSession *SafeSession, sql
|
|||
show.ShowTablesOpt.DbName = ""
|
||||
}
|
||||
sql = sqlparser.String(show)
|
||||
case sqlparser.KeywordString(sqlparser.DATABASES), sqlparser.KeywordString(sqlparser.VITESS_KEYSPACES):
|
||||
case sqlparser.KeywordString(sqlparser.DATABASES), sqlparser.KeywordString(sqlparser.SCHEMAS), sqlparser.KeywordString(sqlparser.VITESS_KEYSPACES):
|
||||
keyspaces, err := e.resolver.resolver.GetAllKeyspaces(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -599,7 +599,7 @@ func TestExecutorShow(t *testing.T) {
|
|||
executor, _, _, sbclookup := createExecutorEnv()
|
||||
session := NewSafeSession(&vtgatepb.Session{TargetString: "@master"})
|
||||
|
||||
for _, query := range []string{"show databases", "show vitess_keyspaces"} {
|
||||
for _, query := range []string{"show databases", "show schemas", "show vitess_keyspaces"} {
|
||||
qr, err := executor.Execute(context.Background(), "TestExecute", session, query, nil)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
|
|
Загрузка…
Ссылка в новой задаче