Skip to content

Commit 8dd12c7

Browse files
committed
Add support for TRUNCATE TEMPORARY TABLE syntax
Parse TEMPORARY keyword in TRUNCATE statements and skip it when determining the table name. Fixed test: 00670_truncate_temporary_table/stmt7
1 parent 30836d9 commit 8dd12c7

3 files changed

Lines changed: 8 additions & 5 deletions

File tree

ast/ast.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,7 @@ const (
692692
// TruncateQuery represents a TRUNCATE statement.
693693
type TruncateQuery struct {
694694
Position token.Position `json:"-"`
695+
Temporary bool `json:"temporary,omitempty"`
695696
IfExists bool `json:"if_exists,omitempty"`
696697
Database string `json:"database,omitempty"`
697698
Table string `json:"table"`

parser/parser.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5849,6 +5849,12 @@ func (p *Parser) parseTruncate() *ast.TruncateQuery {
58495849

58505850
p.nextToken() // skip TRUNCATE
58515851

5852+
// Handle TEMPORARY keyword
5853+
if p.currentIs(token.TEMPORARY) {
5854+
trunc.Temporary = true
5855+
p.nextToken()
5856+
}
5857+
58525858
if p.currentIs(token.TABLE) {
58535859
p.nextToken()
58545860
}
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
{
2-
"explain_todo": {
3-
"stmt7": true
4-
}
5-
}
1+
{}

0 commit comments

Comments
 (0)