Skip to content

Commit

Permalink
feat(embedded/sql): show databases/tables stmt
Browse files Browse the repository at this point in the history
Signed-off-by: Jeronimo Irazabal <[email protected]>
  • Loading branch information
jeroiraz committed Oct 27, 2023
1 parent 88c7377 commit 91a30ec
Show file tree
Hide file tree
Showing 3 changed files with 308 additions and 269 deletions.
3 changes: 3 additions & 0 deletions embedded/sql/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ var reservedWords = map[string]int{
"IS": IS,
"CAST": CAST,
"::": SCAST,
"SHOW": SHOW,
"DATABASES": DATABASES,
"TABLES": TABLES,
}

var joinTypes = map[string]JoinType{
Expand Down
15 changes: 15 additions & 0 deletions embedded/sql/sql_grammar.y
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ func setResult(l yyLexer, stmts []SQLStmt) {
%token SELECT DISTINCT FROM JOIN HAVING WHERE GROUP BY LIMIT OFFSET ORDER ASC DESC AS UNION ALL
%token NOT LIKE IF EXISTS IN IS
%token AUTO_INCREMENT NULL CAST SCAST
%token SHOW DATABASES TABLES
%token <id> NPARAM
%token <pparam> PPARAM
%token <joinType> JOINTYPE
Expand Down Expand Up @@ -523,6 +524,20 @@ dqlstmt:
right: $4.(DataSource),
}
}
|
SHOW DATABASES
{
$$ = &SelectStmt{
ds: &FnDataSourceStmt{fnCall: &FnCall{fn: "databases"}},
}
}
|
SHOW TABLES
{
$$ = &SelectStmt{
ds: &FnDataSourceStmt{fnCall: &FnCall{fn: "tables"}},
}
}

select_stmt: SELECT opt_distinct opt_selectors FROM ds opt_indexon opt_joins opt_where opt_groupby opt_having opt_orderby opt_limit opt_offset
{
Expand Down
Loading

0 comments on commit 91a30ec

Please sign in to comment.