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
30 changes: 30 additions & 0 deletions ast/alter_database_set_statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,35 @@ type OnOffDatabaseOption struct {
func (o *OnOffDatabaseOption) node() {}
func (o *OnOffDatabaseOption) databaseOption() {}

// DelayedDurabilityDatabaseOption represents DELAYED_DURABILITY option
type DelayedDurabilityDatabaseOption struct {
OptionKind string // "DelayedDurability"
Value string // "Disabled", "Allowed", "Forced"
}

func (d *DelayedDurabilityDatabaseOption) node() {}
func (d *DelayedDurabilityDatabaseOption) databaseOption() {}

// IdentifierDatabaseOption represents a database option with an identifier value
type IdentifierDatabaseOption struct {
OptionKind string `json:"OptionKind,omitempty"` // "CatalogCollation"
Value *Identifier `json:"Value,omitempty"`
}

func (i *IdentifierDatabaseOption) node() {}
func (i *IdentifierDatabaseOption) databaseOption() {}

// CreateDatabaseOption is an interface for CREATE DATABASE options (can be DatabaseOption)
type CreateDatabaseOption interface {
node()
createDatabaseOption()
}

// Make existing database options implement CreateDatabaseOption
func (o *OnOffDatabaseOption) createDatabaseOption() {}
func (i *IdentifierDatabaseOption) createDatabaseOption() {}
func (d *DelayedDurabilityDatabaseOption) createDatabaseOption() {}

// AlterDatabaseAddFileStatement represents ALTER DATABASE ... ADD FILE statement
type AlterDatabaseAddFileStatement struct {
DatabaseName *Identifier
Expand Down Expand Up @@ -97,6 +126,7 @@ func (a *AlterDatabaseRemoveFileStatement) statement() {}
type AlterDatabaseRemoveFileGroupStatement struct {
DatabaseName *Identifier
FileGroupName *Identifier
UseCurrent bool
}

func (a *AlterDatabaseRemoveFileGroupStatement) node() {}
Expand Down
6 changes: 4 additions & 2 deletions ast/alter_simple_statements.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ func (s *AlterCertificateStatement) statement() {}

// AlterApplicationRoleStatement represents an ALTER APPLICATION ROLE statement.
type AlterApplicationRoleStatement struct {
Name *Identifier `json:"Name,omitempty"`
Name *Identifier `json:"Name,omitempty"`
ApplicationRoleOptions []*ApplicationRoleOption `json:"ApplicationRoleOptions,omitempty"`
}

func (s *AlterApplicationRoleStatement) node() {}
Expand All @@ -64,7 +65,8 @@ func (s *AlterAsymmetricKeyStatement) statement() {}

// AlterQueueStatement represents an ALTER QUEUE statement.
type AlterQueueStatement struct {
Name *SchemaObjectName `json:"Name,omitempty"`
Name *SchemaObjectName `json:"Name,omitempty"`
QueueOptions []QueueOption `json:"QueueOptions,omitempty"`
}

func (s *AlterQueueStatement) node() {}
Expand Down
53 changes: 47 additions & 6 deletions ast/create_simple_statements.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package ast

// CreateDatabaseStatement represents a CREATE DATABASE statement.
type CreateDatabaseStatement struct {
DatabaseName *Identifier `json:"DatabaseName,omitempty"`
DatabaseName *Identifier `json:"DatabaseName,omitempty"`
Options []CreateDatabaseOption `json:"Options,omitempty"`
AttachMode string `json:"AttachMode,omitempty"` // "None", "Attach", "AttachRebuildLog"
}

func (s *CreateDatabaseStatement) node() {}
Expand All @@ -24,9 +26,33 @@ type CreateServiceStatement struct {
func (s *CreateServiceStatement) node() {}
func (s *CreateServiceStatement) statement() {}

// QueueOption is an interface for queue options.
type QueueOption interface {
node()
queueOption()
}

// QueueStateOption represents a queue state option (STATUS, RETENTION, POISON_MESSAGE_HANDLING).
type QueueStateOption struct {
OptionState string `json:"OptionState,omitempty"` // "On" or "Off"
OptionKind string `json:"OptionKind,omitempty"` // "Status", "Retention", "PoisonMessageHandlingStatus"
}

func (o *QueueStateOption) node() {}
func (o *QueueStateOption) queueOption() {}

// QueueOptionSimple represents a simple queue option like ActivationDrop.
type QueueOptionSimple struct {
OptionKind string `json:"OptionKind,omitempty"` // e.g. "ActivationDrop"
}

func (o *QueueOptionSimple) node() {}
func (o *QueueOptionSimple) queueOption() {}

// CreateQueueStatement represents a CREATE QUEUE statement.
type CreateQueueStatement struct {
Name *SchemaObjectName `json:"Name,omitempty"`
Name *SchemaObjectName `json:"Name,omitempty"`
QueueOptions []QueueOption `json:"QueueOptions,omitempty"`
}

func (s *CreateQueueStatement) node() {}
Expand Down Expand Up @@ -82,7 +108,10 @@ func (s *CreateSymmetricKeyStatement) statement() {}

// CreateMessageTypeStatement represents a CREATE MESSAGE TYPE statement.
type CreateMessageTypeStatement struct {
Name *Identifier `json:"Name,omitempty"`
Name *Identifier `json:"Name,omitempty"`
Owner *Identifier `json:"Owner,omitempty"`
ValidationMethod string `json:"ValidationMethod,omitempty"`
XmlSchemaCollectionName *SchemaObjectName `json:"XmlSchemaCollectionName,omitempty"`
}

func (s *CreateMessageTypeStatement) node() {}
Expand All @@ -98,12 +127,21 @@ func (s *CreateRemoteServiceBindingStatement) statement() {}

// CreateApplicationRoleStatement represents a CREATE APPLICATION ROLE statement.
type CreateApplicationRoleStatement struct {
Name *Identifier `json:"Name,omitempty"`
Name *Identifier `json:"Name,omitempty"`
ApplicationRoleOptions []*ApplicationRoleOption `json:"ApplicationRoleOptions,omitempty"`
}

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

// ApplicationRoleOption represents an option in CREATE/ALTER APPLICATION ROLE
type ApplicationRoleOption struct {
OptionKind string `json:"OptionKind,omitempty"`
Value *IdentifierOrValueExpression `json:"Value,omitempty"`
}

func (o *ApplicationRoleOption) node() {}

// CreateFulltextCatalogStatement represents a CREATE FULLTEXT CATALOG statement.
type CreateFulltextCatalogStatement struct {
Name *Identifier `json:"Name,omitempty"`
Expand Down Expand Up @@ -150,8 +188,11 @@ func (s *CreateIndexStatement) statement() {}

// CreateStatisticsStatement represents a CREATE STATISTICS statement.
type CreateStatisticsStatement struct {
Name *Identifier `json:"Name,omitempty"`
OnName *SchemaObjectName `json:"OnName,omitempty"`
Name *Identifier `json:"Name,omitempty"`
OnName *SchemaObjectName `json:"OnName,omitempty"`
Columns []*ColumnReferenceExpression `json:"Columns,omitempty"`
StatisticsOptions []StatisticsOption `json:"StatisticsOptions,omitempty"`
FilterPredicate BooleanExpression `json:"FilterPredicate,omitempty"`
}

func (s *CreateStatisticsStatement) node() {}
Expand Down
50 changes: 50 additions & 0 deletions ast/cursor_statements.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package ast

// FetchType represents the orientation for a FETCH statement.
type FetchType struct {
Orientation string `json:"Orientation,omitempty"`
RowOffset ScalarExpression `json:"RowOffset,omitempty"`
}

// DeclareCursorStatement represents DECLARE cursor_name CURSOR FOR SELECT.
type DeclareCursorStatement struct {
Name *Identifier `json:"Name,omitempty"`
CursorDefinition *CursorDefinition `json:"CursorDefinition,omitempty"`
}

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

// OpenCursorStatement represents OPEN cursor_name.
type OpenCursorStatement struct {
Cursor *CursorId `json:"Cursor,omitempty"`
}

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

// CloseCursorStatement represents CLOSE cursor_name.
type CloseCursorStatement struct {
Cursor *CursorId `json:"Cursor,omitempty"`
}

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

// DeallocateCursorStatement represents DEALLOCATE cursor_name.
type DeallocateCursorStatement struct {
Cursor *CursorId `json:"Cursor,omitempty"`
}

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

// FetchCursorStatement represents FETCH cursor_name.
type FetchCursorStatement struct {
FetchType *FetchType `json:"FetchType,omitempty"`
Cursor *CursorId `json:"Cursor,omitempty"`
IntoVariables []ScalarExpression `json:"IntoVariables,omitempty"`
}

func (s *FetchCursorStatement) node() {}
func (s *FetchCursorStatement) statement() {}
12 changes: 12 additions & 0 deletions ast/enable_disable_trigger_statement.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package ast

// EnableDisableTriggerStatement represents ENABLE/DISABLE TRIGGER statements
type EnableDisableTriggerStatement struct {
TriggerEnforcement string // "Enable" or "Disable"
All bool // true if ENABLE/DISABLE TRIGGER ALL
TriggerNames []*SchemaObjectName
TriggerObject *TriggerObject
}

func (s *EnableDisableTriggerStatement) statement() {}
func (s *EnableDisableTriggerStatement) node() {}
47 changes: 47 additions & 0 deletions ast/update_statistics_statement.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package ast

// UpdateStatisticsStatement represents UPDATE STATISTICS.
type UpdateStatisticsStatement struct {
SchemaObjectName *SchemaObjectName `json:"SchemaObjectName,omitempty"`
SubElements []*Identifier `json:"SubElements,omitempty"`
StatisticsOptions []StatisticsOption `json:"StatisticsOptions,omitempty"`
}

func (u *UpdateStatisticsStatement) node() {}
func (u *UpdateStatisticsStatement) statement() {}

// StatisticsOption is an interface for statistics options.
type StatisticsOption interface {
statisticsOption()
}

// SimpleStatisticsOption represents a simple statistics option like ALL, FULLSCAN, etc.
type SimpleStatisticsOption struct {
OptionKind string `json:"OptionKind,omitempty"`
}

func (s *SimpleStatisticsOption) statisticsOption() {}

// LiteralStatisticsOption represents a statistics option with a literal value.
type LiteralStatisticsOption struct {
OptionKind string `json:"OptionKind,omitempty"`
Literal ScalarExpression `json:"Literal,omitempty"`
}

func (l *LiteralStatisticsOption) statisticsOption() {}

// OnOffStatisticsOption represents a statistics option with ON/OFF value.
type OnOffStatisticsOption struct {
OptionKind string `json:"OptionKind,omitempty"`
OptionState string `json:"OptionState,omitempty"`
}

func (o *OnOffStatisticsOption) statisticsOption() {}

// ResampleStatisticsOption represents RESAMPLE statistics option.
type ResampleStatisticsOption struct {
OptionKind string `json:"OptionKind,omitempty"`
Partitions []ScalarExpression `json:"Partitions,omitempty"`
}

func (r *ResampleStatisticsOption) statisticsOption() {}
Loading
Loading