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
6 changes: 3 additions & 3 deletions pkg/sql/parser/cte.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ func (p *Parser) parseCommonTableExpr() (*ast.CommonTableExpr, error) {
)
}

// Parse CTE name
if !p.isType(models.TokenTypeIdentifier) {
// Parse CTE name (supports double-quoted identifiers)
if !p.isIdentifier() {
return nil, p.expectedError("CTE name")
}
name := p.currentToken.Literal
Expand All @@ -121,7 +121,7 @@ func (p *Parser) parseCommonTableExpr() (*ast.CommonTableExpr, error) {
p.advance() // Consume (

for {
if !p.isType(models.TokenTypeIdentifier) {
if !p.isIdentifier() {
return nil, p.expectedError("column name")
}
columns = append(columns, p.currentToken.Literal)
Expand Down
52 changes: 26 additions & 26 deletions pkg/sql/parser/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ func (p *Parser) parseCreateView(orReplace, temporary bool) (*ast.CreateViewStat
stmt.IfNotExists = true
}

// Parse view name
if !p.isType(models.TokenTypeIdentifier) {
// Parse view name (supports double-quoted identifiers for PostgreSQL compatibility)
if !p.isIdentifier() {
return nil, p.expectedError("view name")
}
stmt.Name = p.currentToken.Literal
Expand All @@ -109,7 +109,7 @@ func (p *Parser) parseCreateView(orReplace, temporary bool) (*ast.CreateViewStat
if p.isType(models.TokenTypeLParen) {
p.advance() // Consume (
for {
if !p.isType(models.TokenTypeIdentifier) {
if !p.isIdentifier() {
return nil, p.expectedError("column name")
}
stmt.Columns = append(stmt.Columns, p.currentToken.Literal)
Expand Down Expand Up @@ -202,8 +202,8 @@ func (p *Parser) parseCreateMaterializedView() (*ast.CreateMaterializedViewState
stmt.IfNotExists = true
}

// Parse view name
if !p.isType(models.TokenTypeIdentifier) {
// Parse view name (supports double-quoted identifiers for PostgreSQL compatibility)
if !p.isIdentifier() {
return nil, p.expectedError("materialized view name")
}
stmt.Name = p.currentToken.Literal
Expand All @@ -213,7 +213,7 @@ func (p *Parser) parseCreateMaterializedView() (*ast.CreateMaterializedViewState
if p.isType(models.TokenTypeLParen) {
p.advance() // Consume (
for {
if !p.isType(models.TokenTypeIdentifier) {
if !p.isIdentifier() {
return nil, p.expectedError("column name")
}
stmt.Columns = append(stmt.Columns, p.currentToken.Literal)
Expand All @@ -234,7 +234,7 @@ func (p *Parser) parseCreateMaterializedView() (*ast.CreateMaterializedViewState
// Parse optional TABLESPACE
if p.isTokenMatch("TABLESPACE") {
p.advance() // Consume TABLESPACE
if !p.isType(models.TokenTypeIdentifier) {
if !p.isIdentifier() {
return nil, p.expectedError("tablespace name")
}
stmt.Tablespace = p.currentToken.Literal
Expand Down Expand Up @@ -307,8 +307,8 @@ func (p *Parser) parseCreateTable(temporary bool) (*ast.CreateTableStatement, er
stmt.IfNotExists = true
}

// Parse table name
if !p.isType(models.TokenTypeIdentifier) {
// Parse table name (supports double-quoted identifiers for PostgreSQL compatibility)
if !p.isIdentifier() {
return nil, p.expectedError("table name")
}
stmt.Name = p.currentToken.Literal
Expand Down Expand Up @@ -398,7 +398,7 @@ func (p *Parser) parseCreateTable(temporary bool) (*ast.CreateTableStatement, er
if p.isType(models.TokenTypeEq) {
p.advance() // Consume =
}
if p.isType(models.TokenTypeIdentifier) || p.isType(models.TokenTypeString) {
if p.isIdentifier() || p.isType(models.TokenTypeString) {
opt.Value = p.currentToken.Literal
p.advance()
}
Expand Down Expand Up @@ -434,7 +434,7 @@ func (p *Parser) parsePartitionByClause() (*ast.PartitionBy, error) {

// Parse column list
for {
if !p.isType(models.TokenTypeIdentifier) {
if !p.isIdentifier() {
return nil, p.expectedError("column name")
}
partitionBy.Columns = append(partitionBy.Columns, p.currentToken.Literal)
Expand Down Expand Up @@ -466,8 +466,8 @@ func (p *Parser) parsePartitionDefinition() (*ast.PartitionDefinition, error) {
}
p.advance() // Consume PARTITION

// Parse partition name
if !p.isType(models.TokenTypeIdentifier) {
// Parse partition name (supports double-quoted identifiers)
if !p.isIdentifier() {
return nil, p.expectedError("partition name")
}
partDef.Name = p.currentToken.Literal
Expand Down Expand Up @@ -581,7 +581,7 @@ func (p *Parser) parsePartitionDefinition() (*ast.PartitionDefinition, error) {
// Parse optional TABLESPACE
if p.isTokenMatch("TABLESPACE") {
p.advance() // Consume TABLESPACE
if !p.isType(models.TokenTypeIdentifier) {
if !p.isIdentifier() {
return nil, p.expectedError("tablespace name")
}
partDef.Tablespace = p.currentToken.Literal
Expand Down Expand Up @@ -611,8 +611,8 @@ func (p *Parser) parseCreateIndex(unique bool) (*ast.CreateIndexStatement, error
stmt.IfNotExists = true
}

// Parse index name
if !p.isType(models.TokenTypeIdentifier) {
// Parse index name (supports double-quoted identifiers)
if !p.isIdentifier() {
return nil, p.expectedError("index name")
}
stmt.Name = p.currentToken.Literal
Expand All @@ -624,8 +624,8 @@ func (p *Parser) parseCreateIndex(unique bool) (*ast.CreateIndexStatement, error
}
p.advance() // Consume ON

// Parse table name
if !p.isType(models.TokenTypeIdentifier) {
// Parse table name (supports double-quoted identifiers for PostgreSQL compatibility)
if !p.isIdentifier() {
return nil, p.expectedError("table name")
}
stmt.Table = p.currentToken.Literal
Expand All @@ -634,7 +634,7 @@ func (p *Parser) parseCreateIndex(unique bool) (*ast.CreateIndexStatement, error
// Parse optional USING
if p.isType(models.TokenTypeUsing) {
p.advance() // Consume USING
if !p.isType(models.TokenTypeIdentifier) {
if !p.isIdentifier() {
return nil, p.expectedError("index method")
}
stmt.Using = p.currentToken.Literal
Expand All @@ -650,7 +650,7 @@ func (p *Parser) parseCreateIndex(unique bool) (*ast.CreateIndexStatement, error
// Parse column list
for {
col := ast.IndexColumn{}
if !p.isType(models.TokenTypeIdentifier) {
if !p.isIdentifier() {
return nil, p.expectedError("column name")
}
col.Column = p.currentToken.Literal
Expand Down Expand Up @@ -739,9 +739,9 @@ func (p *Parser) parseDropStatement() (*ast.DropStatement, error) {
stmt.IfExists = true
}

// Parse object names (can be comma-separated)
// Parse object names (can be comma-separated, supports double-quoted identifiers)
for {
if !p.isType(models.TokenTypeIdentifier) {
if !p.isIdentifier() {
return nil, p.expectedError("object name")
}
stmt.Names = append(stmt.Names, p.currentToken.Literal)
Expand Down Expand Up @@ -788,8 +788,8 @@ func (p *Parser) parseRefreshStatement() (*ast.RefreshMaterializedViewStatement,
p.advance()
}

// Parse view name
if !p.isType(models.TokenTypeIdentifier) {
// Parse view name (supports double-quoted identifiers for PostgreSQL compatibility)
if !p.isIdentifier() {
return nil, p.expectedError("materialized view name")
}
stmt.Name = p.currentToken.Literal
Expand Down Expand Up @@ -827,9 +827,9 @@ func (p *Parser) parseTruncateStatement() (*ast.TruncateStatement, error) {
p.advance() // Consume TABLE
}

// Parse table names (can be comma-separated)
// Parse table names (can be comma-separated, supports double-quoted identifiers)
for {
if !p.isType(models.TokenTypeIdentifier) {
if !p.isIdentifier() {
return nil, p.expectedError("table name")
}
stmt.Tables = append(stmt.Tables, p.currentToken.Literal)
Expand Down
36 changes: 18 additions & 18 deletions pkg/sql/parser/dml.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ func (p *Parser) parseInsertStatement() (ast.Statement, error) {
}
p.advance() // Consume INTO

// Parse table name
if !p.isType(models.TokenTypeIdentifier) {
// Parse table name (supports double-quoted identifiers for PostgreSQL compatibility)
if !p.isIdentifier() {
return nil, p.expectedError("table name")
}
tableName := p.currentToken.Literal
Expand All @@ -34,8 +34,8 @@ func (p *Parser) parseInsertStatement() (ast.Statement, error) {
p.advance() // Consume (

for {
// Parse column name
if !p.isType(models.TokenTypeIdentifier) {
// Parse column name (supports double-quoted identifiers)
if !p.isIdentifier() {
return nil, p.expectedError("column name")
}
columns = append(columns, &ast.Identifier{Name: p.currentToken.Literal})
Expand Down Expand Up @@ -143,8 +143,8 @@ func (p *Parser) parseInsertStatement() (ast.Statement, error) {
func (p *Parser) parseUpdateStatement() (ast.Statement, error) {
// We've already consumed the UPDATE token in matchToken

// Parse table name
if !p.isType(models.TokenTypeIdentifier) {
// Parse table name (supports double-quoted identifiers for PostgreSQL compatibility)
if !p.isIdentifier() {
return nil, p.expectedError("table name")
}
tableName := p.currentToken.Literal
Expand All @@ -159,8 +159,8 @@ func (p *Parser) parseUpdateStatement() (ast.Statement, error) {
// Parse assignments
updates := make([]ast.UpdateExpression, 0)
for {
// Parse column name
if !p.isType(models.TokenTypeIdentifier) {
// Parse column name (supports double-quoted identifiers)
if !p.isIdentifier() {
return nil, p.expectedError("column name")
}
columnName := p.currentToken.Literal
Expand Down Expand Up @@ -250,8 +250,8 @@ func (p *Parser) parseDeleteStatement() (ast.Statement, error) {
}
p.advance() // Consume FROM

// Parse table name
if !p.isType(models.TokenTypeIdentifier) {
// Parse table name (supports double-quoted identifiers for PostgreSQL compatibility)
if !p.isIdentifier() {
return nil, p.expectedError("table name")
}
tableName := p.currentToken.Literal
Expand Down Expand Up @@ -311,7 +311,7 @@ func (p *Parser) parseMergeStatement() (ast.Statement, error) {
// Parse optional target alias (AS alias or just alias)
if p.isType(models.TokenTypeAs) {
p.advance() // Consume AS
if !p.isType(models.TokenTypeIdentifier) && !p.isNonReservedKeyword() {
if !p.isIdentifier() && !p.isNonReservedKeyword() {
return nil, p.expectedError("target alias after AS")
}
stmt.TargetAlias = p.currentToken.Literal
Expand All @@ -337,7 +337,7 @@ func (p *Parser) parseMergeStatement() (ast.Statement, error) {
// Parse optional source alias
if p.isType(models.TokenTypeAs) {
p.advance() // Consume AS
if !p.isType(models.TokenTypeIdentifier) && !p.isNonReservedKeyword() {
if !p.isIdentifier() && !p.isNonReservedKeyword() {
return nil, p.expectedError("source alias after AS")
}
stmt.SourceAlias = p.currentToken.Literal
Expand Down Expand Up @@ -449,7 +449,7 @@ func (p *Parser) parseMergeAction(clauseType string) (*ast.MergeAction, error) {

// Parse SET clauses
for {
if !p.isType(models.TokenTypeIdentifier) && !p.canBeAlias() {
if !p.isIdentifier() && !p.canBeAlias() {
return nil, p.expectedError("column name")
}
// Handle qualified column names (e.g., t.name)
Expand All @@ -459,7 +459,7 @@ func (p *Parser) parseMergeAction(clauseType string) (*ast.MergeAction, error) {
// Check for qualified name (table.column)
if p.isType(models.TokenTypePeriod) {
p.advance() // Consume .
if !p.isType(models.TokenTypeIdentifier) && !p.canBeAlias() {
if !p.isIdentifier() && !p.canBeAlias() {
return nil, p.expectedError("column name after .")
}
columnName = columnName + "." + p.currentToken.Literal
Expand Down Expand Up @@ -496,7 +496,7 @@ func (p *Parser) parseMergeAction(clauseType string) (*ast.MergeAction, error) {
if p.isType(models.TokenTypeLParen) {
p.advance() // Consume (
for {
if !p.isType(models.TokenTypeIdentifier) {
if !p.isIdentifier() {
return nil, p.expectedError("column name")
}
action.Columns = append(action.Columns, p.currentToken.Literal)
Expand Down Expand Up @@ -601,7 +601,7 @@ func (p *Parser) parseOnConflictClause() (*ast.OnConflict, error) {
var targets []ast.Expression

for {
if !p.isType(models.TokenTypeIdentifier) {
if !p.isIdentifier() {
return nil, p.expectedError("column name in ON CONFLICT target")
}
targets = append(targets, &ast.Identifier{Name: p.currentToken.Literal})
Expand All @@ -622,7 +622,7 @@ func (p *Parser) parseOnConflictClause() (*ast.OnConflict, error) {
// ON CONSTRAINT constraint_name
p.advance() // Consume ON
p.advance() // Consume CONSTRAINT
if !p.isType(models.TokenTypeIdentifier) {
if !p.isIdentifier() {
return nil, p.expectedError("constraint name")
}
onConflict.Constraint = p.currentToken.Literal
Expand Down Expand Up @@ -651,7 +651,7 @@ func (p *Parser) parseOnConflictClause() (*ast.OnConflict, error) {
// Parse update assignments
var updates []ast.UpdateExpression
for {
if !p.isType(models.TokenTypeIdentifier) {
if !p.isIdentifier() {
return nil, p.expectedError("column name")
}
columnName := p.currentToken.Literal
Expand Down
Loading
Loading