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
18 changes: 18 additions & 0 deletions ast/backup_statement.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package ast

// BackupDatabaseStatement represents a BACKUP DATABASE statement
type BackupDatabaseStatement struct {
DatabaseName *IdentifierOrValueExpression
Devices []*DeviceInfo
Options []*BackupOption
}

func (s *BackupDatabaseStatement) statementNode() {}
func (s *BackupDatabaseStatement) statement() {}
func (s *BackupDatabaseStatement) node() {}

// BackupOption represents a backup option
type BackupOption struct {
OptionKind string // Compression, NoCompression, StopOnError, ContinueAfterError, etc.
Value ScalarExpression
}
17 changes: 9 additions & 8 deletions ast/create_columnstore_index_statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ package ast

// CreateColumnStoreIndexStatement represents a CREATE COLUMNSTORE INDEX statement
type CreateColumnStoreIndexStatement struct {
Name *Identifier
Clustered bool
OnName *SchemaObjectName
Columns []*ColumnReferenceExpression
OrderedColumns []*ColumnReferenceExpression
IndexOptions []IndexOption
FilterClause ScalarExpression
OnPartition *PartitionSpecifier
Name *Identifier
Clustered bool
ClusteredExplicit bool // true if CLUSTERED or NONCLUSTERED was explicitly specified
OnName *SchemaObjectName
Columns []*ColumnReferenceExpression
OrderedColumns []*ColumnReferenceExpression
IndexOptions []IndexOption
FilterClause ScalarExpression
OnPartition *PartitionSpecifier
}

func (s *CreateColumnStoreIndexStatement) statement() {}
Expand Down
10 changes: 10 additions & 0 deletions ast/declare_variable_statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,13 @@ type SqlDataTypeReference struct {

func (s *SqlDataTypeReference) node() {}
func (s *SqlDataTypeReference) dataTypeReference() {}

// XmlDataTypeReference represents an XML data type with optional schema collection
type XmlDataTypeReference struct {
XmlDataTypeOption string `json:"XmlDataTypeOption,omitempty"`
XmlSchemaCollection *SchemaObjectName `json:"XmlSchemaCollection,omitempty"`
Name *SchemaObjectName `json:"Name,omitempty"`
}

func (x *XmlDataTypeReference) node() {}
func (x *XmlDataTypeReference) dataTypeReference() {}
46 changes: 46 additions & 0 deletions ast/event_statements.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package ast

// CreateEventSessionStatement represents CREATE EVENT SESSION statement
type CreateEventSessionStatement struct {
Name *Identifier
ServerName *Identifier
Events []*EventDeclaration
Targets []*EventTarget
Options []*EventSessionOption
}

func (s *CreateEventSessionStatement) node() {}
func (s *CreateEventSessionStatement) statement() {}

// EventDeclaration represents an event in the event session
type EventDeclaration struct {
PackageName *Identifier
EventName *Identifier
Actions []*EventAction
WhereClause ScalarExpression
}

// EventAction represents an action for an event
type EventAction struct {
PackageName *Identifier
ActionName *Identifier
}

// EventTarget represents a target for the event session
type EventTarget struct {
PackageName *Identifier
TargetName *Identifier
Options []*EventTargetOption
}

// EventTargetOption represents an option for an event target
type EventTargetOption struct {
Name *Identifier
Value ScalarExpression
}

// EventSessionOption represents an option for the event session
type EventSessionOption struct {
OptionKind string
Value ScalarExpression
}
81 changes: 81 additions & 0 deletions ast/external_statements.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package ast

// CreateExternalDataSourceStatement represents CREATE EXTERNAL DATA SOURCE statement
type CreateExternalDataSourceStatement struct {
Name *Identifier
Options []*ExternalDataSourceOption
}

func (s *CreateExternalDataSourceStatement) node() {}
func (s *CreateExternalDataSourceStatement) statement() {}

// ExternalDataSourceOption represents an option for external data source
type ExternalDataSourceOption struct {
OptionKind string
Value ScalarExpression
}

// CreateExternalFileFormatStatement represents CREATE EXTERNAL FILE FORMAT statement
type CreateExternalFileFormatStatement struct {
Name *Identifier
Options []*ExternalFileFormatOption
}

func (s *CreateExternalFileFormatStatement) node() {}
func (s *CreateExternalFileFormatStatement) statement() {}

// ExternalFileFormatOption represents an option for external file format
type ExternalFileFormatOption struct {
OptionKind string
Value ScalarExpression
SubOptions []*ExternalFileFormatOption
}

// CreateExternalTableStatement represents CREATE EXTERNAL TABLE statement
type CreateExternalTableStatement struct {
SchemaObjectName *SchemaObjectName
Definition *TableDefinition
DataSource *Identifier
Location ScalarExpression
FileFormat *Identifier
Options []*ExternalTableOption
}

func (s *CreateExternalTableStatement) node() {}
func (s *CreateExternalTableStatement) statement() {}

// ExternalTableOption represents an option for external table
type ExternalTableOption struct {
OptionKind string
Value ScalarExpression
}

// CreateExternalLanguageStatement represents CREATE EXTERNAL LANGUAGE statement
type CreateExternalLanguageStatement struct {
Name *Identifier
Options []*ExternalLanguageOption
}

func (s *CreateExternalLanguageStatement) node() {}
func (s *CreateExternalLanguageStatement) statement() {}

// ExternalLanguageOption represents an option for external language
type ExternalLanguageOption struct {
OptionKind string
Value ScalarExpression
}

// CreateExternalLibraryStatement represents CREATE EXTERNAL LIBRARY statement
type CreateExternalLibraryStatement struct {
Name *Identifier
Options []*ExternalLibraryOption
}

func (s *CreateExternalLibraryStatement) node() {}
func (s *CreateExternalLibraryStatement) statement() {}

// ExternalLibraryOption represents an option for external library
type ExternalLibraryOption struct {
OptionKind string
Value ScalarExpression
}
50 changes: 50 additions & 0 deletions ast/trivial_statements.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,53 @@ type LineNoStatement struct {

func (l *LineNoStatement) node() {}
func (l *LineNoStatement) statement() {}

// CloseSymmetricKeyStatement represents CLOSE SYMMETRIC KEY statement
type CloseSymmetricKeyStatement struct {
Name *Identifier
All bool
}

func (s *CloseSymmetricKeyStatement) node() {}
func (s *CloseSymmetricKeyStatement) statement() {}

// CloseMasterKeyStatement represents CLOSE MASTER KEY statement
type CloseMasterKeyStatement struct{}

func (s *CloseMasterKeyStatement) node() {}
func (s *CloseMasterKeyStatement) statement() {}

// OpenMasterKeyStatement represents OPEN MASTER KEY statement
type OpenMasterKeyStatement struct {
Password ScalarExpression
}

func (s *OpenMasterKeyStatement) node() {}
func (s *OpenMasterKeyStatement) statement() {}

// OpenSymmetricKeyStatement represents OPEN SYMMETRIC KEY statement
type OpenSymmetricKeyStatement struct {
Name *Identifier
DecryptionMechanism string // "Key", "Certificate", "Password", "AsymmetricKey"
DecryptionKey ScalarExpression
}

func (s *OpenSymmetricKeyStatement) node() {}
func (s *OpenSymmetricKeyStatement) statement() {}

// KillStatsJobStatement represents KILL STATS JOB statement
type KillStatsJobStatement struct {
JobId ScalarExpression
}

func (s *KillStatsJobStatement) node() {}
func (s *KillStatsJobStatement) statement() {}

// KillQueryNotificationSubscriptionStatement represents KILL QUERY NOTIFICATION SUBSCRIPTION statement
type KillQueryNotificationSubscriptionStatement struct {
SubscriptionId ScalarExpression
All bool
}

func (s *KillQueryNotificationSubscriptionStatement) node() {}
func (s *KillQueryNotificationSubscriptionStatement) statement() {}
22 changes: 22 additions & 0 deletions parser/lexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,17 @@ const (
TokenBackup
TokenFilestream
TokenReturns
TokenClose
TokenOpen
TokenSymmetric
TokenStats
TokenJob
TokenQuery
TokenNotification
TokenSubscription
TokenDecryption
TokenAsymmetric
TokenCertificate
)

// Token represents a lexical token.
Expand Down Expand Up @@ -682,6 +693,17 @@ var keywords = map[string]TokenType{
"BACKUP": TokenBackup,
"FILESTREAM": TokenFilestream,
"RETURNS": TokenReturns,
"CLOSE": TokenClose,
"OPEN": TokenOpen,
"SYMMETRIC": TokenSymmetric,
"STATS": TokenStats,
"JOB": TokenJob,
"QUERY": TokenQuery,
"NOTIFICATION": TokenNotification,
"SUBSCRIPTION": TokenSubscription,
"DECRYPTION": TokenDecryption,
"ASYMMETRIC": TokenAsymmetric,
"CERTIFICATE": TokenCertificate,
}

func lookupKeyword(ident string) TokenType {
Expand Down
Loading
Loading