Skip to content

Commit b6a94a9

Browse files
committed
Handle TEMPORARY keyword in EXISTS and SHOW statements
Add Temporary field to ExistsQuery and ShowQuery AST types. Parse TEMPORARY keyword in: - EXISTS TEMPORARY TABLE statements - SHOW TEMPORARY TABLES statements Fixes 5 statements across 2 tests: - 00564_temporary_table_management (3 statements) - 00492_drop_temporary_table (2 statements)
1 parent 41cafb0 commit b6a94a9

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

ast/ast.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,7 @@ func (d *DescribeQuery) statementNode() {}
775775
type ShowQuery struct {
776776
Position token.Position `json:"-"`
777777
ShowType ShowType `json:"show_type"`
778+
Temporary bool `json:"temporary,omitempty"`
778779
Database string `json:"database,omitempty"`
779780
From string `json:"from,omitempty"`
780781
Like string `json:"like,omitempty"`
@@ -956,6 +957,7 @@ const (
956957
type ExistsQuery struct {
957958
Position token.Position `json:"-"`
958959
ExistsType ExistsType `json:"exists_type,omitempty"`
960+
Temporary bool `json:"temporary,omitempty"`
959961
Database string `json:"database,omitempty"`
960962
Table string `json:"table"`
961963
Settings []*SettingExpr `json:"settings,omitempty"`

parser/parser.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5862,6 +5862,12 @@ func (p *Parser) parseShow() ast.Statement {
58625862
Position: pos,
58635863
}
58645864

5865+
// Handle TEMPORARY keyword (SHOW TEMPORARY TABLES)
5866+
if p.currentIs(token.TEMPORARY) {
5867+
show.Temporary = true
5868+
p.nextToken()
5869+
}
5870+
58655871
switch p.current.Token {
58665872
case token.TABLES:
58675873
show.ShowType = ast.ShowTables
@@ -7192,6 +7198,12 @@ func (p *Parser) parseExistsStatement() *ast.ExistsQuery {
71927198

71937199
p.nextToken() // skip EXISTS
71947200

7201+
// Check for TEMPORARY keyword
7202+
if p.currentIs(token.TEMPORARY) {
7203+
exists.Temporary = true
7204+
p.nextToken()
7205+
}
7206+
71957207
// Check for DICTIONARY, DATABASE, VIEW, or TABLE keyword
71967208
if p.currentIs(token.TABLE) {
71977209
exists.ExistsType = ast.ExistsTable
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1 @@
1-
{
2-
"explain_todo": {
3-
"stmt6": true,
4-
"stmt8": true
5-
}
6-
}
1+
{}
Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,2 @@
11
{
2-
"explain_todo": {
3-
"stmt3": true,
4-
"stmt5": true,
5-
"stmt7": true
6-
}
72
}

0 commit comments

Comments
 (0)