Documentation
¶
Index ¶
- Constants
- func ExprString(expr Expr) string
- func ForEachSource(src Source, fn func(Source) bool)
- func IdentName(ident *Ident) string
- func IsInteger(s string) bool
- func SourceName(src Source) string
- type AlterTableStatement
- type AnalyzeStatement
- type Assignment
- type BeginStatement
- type BinaryExpr
- type BindExpr
- type BlobLit
- type BoolLit
- type CTE
- type Call
- type CaseBlock
- type CaseExpr
- type CastExpr
- type CheckConstraint
- type CollateConstraint
- type CollationClause
- type ColumnArg
- type ColumnDefinition
- type CommitStatement
- type Constraint
- type CreateIndexStatement
- type CreateTableStatement
- type CreateTriggerStatement
- type CreateViewStatement
- type CreateVirtualTableStatement
- type DefaultConstraint
- type DeleteStatement
- type DropIndexStatement
- type DropTableStatement
- type DropTriggerStatement
- type DropViewStatement
- type Error
- type Exists
- type ExplainStatement
- type Expr
- type ExprList
- type FilterClause
- type ForeignKeyArg
- type ForeignKeyConstraint
- type FrameSpec
- type GeneratedConstraint
- type Ident
- type IndexedColumn
- type InsertStatement
- type JoinClause
- type JoinConstraint
- type JoinOperator
- type ModuleArgument
- type Node
- type NotNullConstraint
- type Null
- type NullLit
- type NumberLit
- type OnConstraint
- type OrderingTerm
- type OverClause
- type ParenExpr
- type ParenSource
- type Parser
- type Pos
- type PragmaStatement
- type PrimaryKeyConstraint
- type QualifiedRef
- type QualifiedTableFunctionName
- type QualifiedTableName
- type Raise
- type Range
- type ReindexStatement
- type ReleaseStatement
- type ResultColumn
- type ReturningClause
- type RollbackStatement
- type SavepointStatement
- type Scanner
- type Scope
- type SelectExpr
- type SelectStatement
- type Source
- type Statement
- type StringLit
- type TimestampLit
- type Token
- type Type
- type UnaryExpr
- type UniqueConstraint
- type UpdateStatement
- type UpsertClause
- type UsingConstraint
- type VisitEndFunc
- type VisitFunc
- type Visitor
- type Window
- type WindowDefinition
- type WithClause
Constants ¶
const ( LowestPrec = 0 // non-operators UnaryPrec = 13 HighestPrec = 14 )
Variables ¶
This section is empty.
Functions ¶
func ExprString ¶
ExprString returns the string representation of expr. Returns a blank string if expr is nil.
func ForEachSource ¶
ForEachSource calls fn for every source within the current scope. Stops iteration if fn returns false.
func SourceName ¶
SourceName returns the name of the source. Only returns for QualifiedTableName & ParenSource.
Types ¶
type AlterTableStatement ¶
type AlterTableStatement struct {
Alter Pos // position of ALTER keyword
Table Pos // position of TABLE keyword
Name *Ident // table name
Rename Pos // position of RENAME keyword
RenameTo Pos // position of TO keyword after RENAME
NewName *Ident // new table name
RenameColumn Pos // position of COLUMN keyword after RENAME
ColumnName *Ident // column name
To Pos // position of TO keyword
NewColumnName *Ident // new column name
Add Pos // position of ADD keyword
AddColumn Pos // position of COLUMN keyword after ADD
ColumnDef *ColumnDefinition // new column definition
Drop Pos // position of DROP keyword
DropColumn Pos // position of COLUMN keyword after DROP
DropColumnName *Ident // column name to drop
}
func (*AlterTableStatement) Clone ¶
func (s *AlterTableStatement) Clone() *AlterTableStatement
Clone returns a deep copy of s.
func (*AlterTableStatement) String ¶
func (s *AlterTableStatement) String() string
String returns the string representation of the statement.
type AnalyzeStatement ¶
type AnalyzeStatement struct {
Analyze Pos // position of ANALYZE keyword
Name *Ident // table name
}
func (*AnalyzeStatement) Clone ¶
func (s *AnalyzeStatement) Clone() *AnalyzeStatement
Clone returns a deep copy of s.
func (*AnalyzeStatement) String ¶
func (s *AnalyzeStatement) String() string
String returns the string representation of the statement.
type Assignment ¶
type Assignment struct {
Lparen Pos // position of column list left paren
Columns []*Ident // column list
Rparen Pos // position of column list right paren
Eq Pos // position of =
Expr Expr // assigned expression
}
Assignment is used within the UPDATE statement & upsert clause. It is similiar to an expression except that it must be an equality.
func (*Assignment) String ¶
func (a *Assignment) String() string
String returns the string representation of the clause.
type BeginStatement ¶
type BeginStatement struct {
Begin Pos // position of BEGIN
Deferred Pos // position of DEFERRED keyword
Immediate Pos // position of IMMEDIATE keyword
Exclusive Pos // position of EXCLUSIVE keyword
Transaction Pos // position of TRANSACTION keyword (optional)
}
func (*BeginStatement) Clone ¶
func (s *BeginStatement) Clone() *BeginStatement
Clone returns a deep copy of s.
func (*BeginStatement) String ¶
func (s *BeginStatement) String() string
String returns the string representation of the statement.
type BinaryExpr ¶
type BinaryExpr struct {
X Expr // lhs
OpPos Pos // position of Op
Op Token // operator
Y Expr // rhs
}
func (*BinaryExpr) Clone ¶
func (expr *BinaryExpr) Clone() *BinaryExpr
Clone returns a deep copy of expr.
func (*BinaryExpr) String ¶
func (expr *BinaryExpr) String() string
String returns the string representation of the expression.
type CTE ¶
type CTE struct {
TableName *Ident // table name
ColumnsLparen Pos // position of column list left paren
Columns []*Ident // optional column list
ColumnsRparen Pos // position of column list right paren
As Pos // position of AS keyword
SelectLparen Pos // position of select left paren
Select *SelectStatement // select statement
SelectRparen Pos // position of select right paren
}
CTE represents an AST node for a common table expression.
type Call ¶
type Call struct {
Name *Ident // function name
Lparen Pos // position of left paren
Star Pos // position of *
Distinct Pos // position of DISTINCT keyword
Args []Expr // argument list
Rparen Pos // position of right paren
Filter *FilterClause // filter clause
Over *OverClause // over clause
}
type CaseBlock ¶
type CaseBlock struct {
When Pos // position of WHEN keyword
Condition Expr // block condition
Then Pos // position of THEN keyword
Body Expr // result expression
}
type CaseExpr ¶
type CastExpr ¶
type CheckConstraint ¶
type CheckConstraint struct {
Constraint Pos // position of CONSTRAINT keyword
Name *Ident // constraint name
Check Pos // position of UNIQUE keyword
Lparen Pos // position of left paren
Expr Expr // check expression
Rparen Pos // position of right paren
}
func (*CheckConstraint) Clone ¶
func (c *CheckConstraint) Clone() *CheckConstraint
Clone returns a deep copy of c.
func (*CheckConstraint) String ¶
func (c *CheckConstraint) String() string
String returns the string representation of the constraint.
type CollateConstraint ¶
type CollateConstraint struct {
Constraint Pos // position of CONSTRAINT keyword
Name *Ident // constraint name
Collate Pos // position of COLLATE keyword
Collation *Ident // collation name
}
func (*CollateConstraint) Clone ¶
func (c *CollateConstraint) Clone() *CollateConstraint
Clone returns a deep copy of c.
func (*CollateConstraint) String ¶
func (c *CollateConstraint) String() string
String returns the string representation of the constraint.
type CollationClause ¶
type CollationClause struct {
Collate Pos // position of COLLATE keyword
Name *Ident // collation function (e.g. BINARY, NOCASE, RTRIM or custom)
}
func (*CollationClause) Clone ¶
func (c *CollationClause) Clone() *CollationClause
Clone returns a deep copy of c.
func (*CollationClause) String ¶
func (c *CollationClause) String() string
String returns the string representation of the collation.
type ColumnDefinition ¶
type ColumnDefinition struct {
Name *Ident // column name
Type *Type // data type
Constraints []Constraint // column constraints
}
func (*ColumnDefinition) Clone ¶
func (d *ColumnDefinition) Clone() *ColumnDefinition
Clone returns a deep copy of d.
func (*ColumnDefinition) String ¶
func (c *ColumnDefinition) String() string
String returns the string representation of the statement.
type CommitStatement ¶
type CommitStatement struct {
Commit Pos // position of COMMIT keyword
End Pos // position of END keyword
Transaction Pos // position of TRANSACTION keyword (optional)
}
func (*CommitStatement) Clone ¶
func (s *CommitStatement) Clone() *CommitStatement
Clone returns a deep copy of s.
func (*CommitStatement) String ¶
func (s *CommitStatement) String() string
String returns the string representation of the statement.
type Constraint ¶
type Constraint interface {
Node
// contains filtered or unexported methods
}
func CloneConstraint ¶
func CloneConstraint(cons Constraint) Constraint
CloneConstraint returns a deep copy cons.
type CreateIndexStatement ¶
type CreateIndexStatement struct {
Create Pos // position of CREATE keyword
Unique Pos // position of optional UNIQUE keyword
Index Pos // position of INDEX keyword
If Pos // position of IF keyword
IfNot Pos // position of NOT keyword after IF
IfNotExists Pos // position of EXISTS keyword after IF NOT
Name *Ident // index name
On Pos // position of ON keyword
Table *Ident // index name
Lparen Pos // position of column list left paren
Columns []*IndexedColumn // column list
Rparen Pos // position of column list right paren
Where Pos // position of WHERE keyword
WhereExpr Expr // conditional expression
}
func (*CreateIndexStatement) Clone ¶
func (s *CreateIndexStatement) Clone() *CreateIndexStatement
Clone returns a deep copy of s.
func (*CreateIndexStatement) String ¶
func (s *CreateIndexStatement) String() string
String returns the string representation of the statement.
type CreateTableStatement ¶
type CreateTableStatement struct {
Create Pos // position of CREATE keyword
Table Pos // position of CREATE keyword
If Pos // position of IF keyword (optional)
IfNot Pos // position of NOT keyword (optional)
IfNotExists Pos // position of EXISTS keyword (optional)
Schema *Ident // optional schema name
Name *Ident // table name
Lparen Pos // position of left paren of column list
Columns []*ColumnDefinition // column definitions
Constraints []Constraint // table constraints
Rparen Pos // position of right paren of column list
Without Pos // position of WITHOUT keyword (optional)
Rowid Pos // position of ROWID keyword (optional)
Strict Pos // position of STRICT keyword (optional)
As Pos // position of AS keyword (optional)
Select *SelectStatement // select stmt to build from
}
func (*CreateTableStatement) Clone ¶
func (s *CreateTableStatement) Clone() *CreateTableStatement
Clone returns a deep copy of s.
func (*CreateTableStatement) String ¶
func (s *CreateTableStatement) String() string
String returns the string representation of the statement.
type CreateTriggerStatement ¶
type CreateTriggerStatement struct {
Create Pos // position of CREATE keyword
Trigger Pos // position of TRIGGER keyword
If Pos // position of IF keyword
IfNot Pos // position of NOT keyword after IF
IfNotExists Pos // position of EXISTS keyword after IF NOT
Name *Ident // index name
Before Pos // position of BEFORE keyword
After Pos // position of AFTER keyword
Instead Pos // position of INSTEAD keyword
InsteadOf Pos // position of OF keyword after INSTEAD
Delete Pos // position of DELETE keyword
Insert Pos // position of INSERT keyword
Update Pos // position of UPDATE keyword
UpdateOf Pos // position of OF keyword after UPDATE
UpdateOfColumns []*Ident // columns list for UPDATE OF
On Pos // position of ON keyword
Table *Ident // table name
For Pos // position of FOR keyword
ForEach Pos // position of EACH keyword after FOR
ForEachRow Pos // position of ROW keyword after FOR EACH
When Pos // position of WHEN keyword
WhenExpr Expr // conditional expression
Begin Pos // position of BEGIN keyword
Body []Statement // trigger body
End Pos // position of END keyword
}
func (*CreateTriggerStatement) Clone ¶
func (s *CreateTriggerStatement) Clone() *CreateTriggerStatement
Clone returns a deep copy of s.
func (*CreateTriggerStatement) String ¶
func (s *CreateTriggerStatement) String() string
String returns the string representation of the statement.
type CreateViewStatement ¶
type CreateViewStatement struct {
Create Pos // position of CREATE keyword
View Pos // position of VIEW keyword
If Pos // position of IF keyword
IfNot Pos // position of NOT keyword after IF
IfNotExists Pos // position of EXISTS keyword after IF NOT
Name *Ident // view name
Lparen Pos // position of column list left paren
Columns []*Ident // column list
Rparen Pos // position of column list right paren
As Pos // position of AS keyword
Select *SelectStatement // source statement
}
func (*CreateViewStatement) Clone ¶
func (s *CreateViewStatement) Clone() *CreateViewStatement
Clone returns a deep copy of s.
func (*CreateViewStatement) String ¶
func (s *CreateViewStatement) String() string
String returns the string representation of the statement.
type CreateVirtualTableStatement ¶
type CreateVirtualTableStatement struct {
Create Pos // position of CREATE keyword
Virtual Pos // position of VIRTUAL keyword
Table Pos // position of TABLE keyword
If Pos // position of IF keyword (optional)
IfNot Pos // position of NOT keyword (optional)
IfNotExists Pos // position of EXISTS keyword (optional)
Schema *Ident // schema name (optional)
Dot Pos // position of DOT token (optional)
Name *Ident // table name
Using Pos // position of USING
ModuleName *Ident // name of an object that implements the virtual table
Lparen Pos // position of left paren of module argument list (optional)
Arguments []*ModuleArgument // module argument list (optional)
Rparen Pos // position of right paren of module argument list (optional)
}
func (*CreateVirtualTableStatement) Clone ¶
func (s *CreateVirtualTableStatement) Clone() *CreateVirtualTableStatement
Clone returns a deep copy of s.
func (*CreateVirtualTableStatement) String ¶
func (s *CreateVirtualTableStatement) String() string
String returns the string representation of the statement.
type DefaultConstraint ¶
type DefaultConstraint struct {
Constraint Pos // position of CONSTRAINT keyword
Name *Ident // constraint name
Default Pos // position of DEFAULT keyword
Lparen Pos // position of left paren
Expr Expr // default expression
Rparen Pos // position of right paren
}
func (*DefaultConstraint) Clone ¶
func (c *DefaultConstraint) Clone() *DefaultConstraint
Clone returns a deep copy of c.
func (*DefaultConstraint) String ¶
func (c *DefaultConstraint) String() string
String returns the string representation of the constraint.
type DeleteStatement ¶
type DeleteStatement struct {
WithClause *WithClause // clause containing CTEs
Delete Pos // position of UPDATE keyword
From Pos // position of FROM keyword
Table *QualifiedTableName // table name
Where Pos // position of WHERE keyword
WhereExpr Expr // conditional expression
Order Pos // position of ORDER keyword
OrderBy Pos // position of BY keyword after ORDER
OrderingTerms []*OrderingTerm // terms of ORDER BY clause
Limit Pos // position of LIMIT keyword
LimitExpr Expr // limit expression
Offset Pos // position of OFFSET keyword
OffsetComma Pos // position of COMMA (instead of OFFSET)
OffsetExpr Expr // offset expression
ReturningClause *ReturningClause // optional RETURNING clause
}
func (*DeleteStatement) Clone ¶
func (s *DeleteStatement) Clone() *DeleteStatement
Clone returns a deep copy of s.
func (*DeleteStatement) String ¶
func (s *DeleteStatement) String() string
String returns the string representation of the clause.
type DropIndexStatement ¶
type DropIndexStatement struct {
Drop Pos // position of DROP keyword
Index Pos // position of INDEX keyword
If Pos // position of IF keyword
IfExists Pos // position of EXISTS keyword after IF
Name *Ident // index name
}
func (*DropIndexStatement) Clone ¶
func (s *DropIndexStatement) Clone() *DropIndexStatement
Clone returns a deep copy of s.
func (*DropIndexStatement) String ¶
func (s *DropIndexStatement) String() string
String returns the string representation of the statement.
type DropTableStatement ¶
type DropTableStatement struct {
Drop Pos // position of DROP keyword
Table Pos // position of TABLE keyword
If Pos // position of IF keyword
IfExists Pos // position of EXISTS keyword after IF
Name *Ident // view name
}
func (*DropTableStatement) Clone ¶
func (s *DropTableStatement) Clone() *DropTableStatement
Clone returns a deep copy of s.
func (*DropTableStatement) String ¶
func (s *DropTableStatement) String() string
String returns the string representation of the statement.
type DropTriggerStatement ¶
type DropTriggerStatement struct {
Drop Pos // position of DROP keyword
Trigger Pos // position of TRIGGER keyword
If Pos // position of IF keyword
IfExists Pos // position of EXISTS keyword after IF
Name *Ident // trigger name
}
func (*DropTriggerStatement) Clone ¶
func (s *DropTriggerStatement) Clone() *DropTriggerStatement
Clone returns a deep copy of s.
func (*DropTriggerStatement) String ¶
func (s *DropTriggerStatement) String() string
String returns the string representation of the statement.
type DropViewStatement ¶
type DropViewStatement struct {
Drop Pos // position of DROP keyword
View Pos // position of VIEW keyword
If Pos // position of IF keyword
IfExists Pos // position of EXISTS keyword after IF
Name *Ident // view name
}
func (*DropViewStatement) Clone ¶
func (s *DropViewStatement) Clone() *DropViewStatement
Clone returns a deep copy of s.
func (*DropViewStatement) String ¶
func (s *DropViewStatement) String() string
String returns the string representation of the statement.
type Exists ¶
type Exists struct {
Not Pos // position of optional NOT keyword
Exists Pos // position of EXISTS keyword
Lparen Pos // position of left paren
Select *SelectStatement // select statement
Rparen Pos // position of right paren
}
type ExplainStatement ¶
type ExplainStatement struct {
Explain Pos // position of EXPLAIN
Query Pos // position of QUERY (optional)
QueryPlan Pos // position of PLAN after QUERY (optional)
Stmt Statement // target statement
}
func (*ExplainStatement) Clone ¶
func (s *ExplainStatement) Clone() *ExplainStatement
Clone returns a deep copy of s.
func (*ExplainStatement) String ¶
func (s *ExplainStatement) String() string
String returns the string representation of the statement.
type Expr ¶
type Expr interface {
Node
// contains filtered or unexported methods
}
func MustParseExprString ¶
MustParseExprString parses s into an expression. Panic on error.
func ParseExprString ¶
ParseExprString parses s into an expression. Returns nil if s is blank.
func SplitExprTree ¶
SplitExprTree splits apart expr so it is a list of all AND joined expressions. For example, the expression "A AND B AND (C OR (D AND E))" would be split into a list of "A", "B", "C OR (D AND E)".
type ExprList ¶
type FilterClause ¶
type FilterClause struct {
Filter Pos // position of FILTER keyword
Lparen Pos // position of left paren
Where Pos // position of WHERE keyword
X Expr // filter expression
Rparen Pos // position of right paren
}
func (*FilterClause) Clone ¶
func (c *FilterClause) Clone() *FilterClause
Clone returns a deep copy of c.
func (*FilterClause) String ¶
func (c *FilterClause) String() string
String returns the string representation of the clause.
type ForeignKeyArg ¶
type ForeignKeyArg struct {
On Pos // position of ON keyword
OnUpdate Pos // position of the UPDATE keyword
OnDelete Pos // position of the DELETE keyword
Set Pos // position of the SET keyword
SetNull Pos // position of the NULL keyword after SET
SetDefault Pos // position of the DEFAULT keyword after SET
Cascade Pos // position of the CASCADE keyword
Restrict Pos // position of the RESTRICT keyword
No Pos // position of the NO keyword
NoAction Pos // position of the ACTION keyword after NO
}
func (*ForeignKeyArg) Clone ¶
func (arg *ForeignKeyArg) Clone() *ForeignKeyArg
Clone returns a deep copy of arg.
func (*ForeignKeyArg) String ¶
func (c *ForeignKeyArg) String() string
String returns the string representation of the argument.
type ForeignKeyConstraint ¶
type ForeignKeyConstraint struct {
Constraint Pos // position of CONSTRAINT keyword
Name *Ident // constraint name
Foreign Pos // position of FOREIGN keyword (table only)
ForeignKey Pos // position of KEY keyword after FOREIGN (table only)
Lparen Pos // position of left paren (table only)
Columns []*Ident // indexed columns (table only)
Rparen Pos // position of right paren (table only)
References Pos // position of REFERENCES keyword
ForeignTable *Ident // foreign table name
ForeignLparen Pos // position of left paren
ForeignColumns []*Ident // column list
ForeignRparen Pos // position of right paren
Args []*ForeignKeyArg // arguments
Deferrable Pos // position of DEFERRABLE keyword
Not Pos // position of NOT keyword
NotDeferrable Pos // position of DEFERRABLE keyword after NOT
Initially Pos // position of INITIALLY keyword
InitiallyDeferred Pos // position of DEFERRED keyword after INITIALLY
InitiallyImmediate Pos // position of IMMEDIATE keyword after INITIALLY
}
func (*ForeignKeyConstraint) Clone ¶
func (c *ForeignKeyConstraint) Clone() *ForeignKeyConstraint
Clone returns a deep copy of c.
func (*ForeignKeyConstraint) String ¶
func (c *ForeignKeyConstraint) String() string
String returns the string representation of the constraint.
type FrameSpec ¶
type FrameSpec struct {
Range Pos // position of RANGE keyword
Rows Pos // position of ROWS keyword
Groups Pos // position of GROUPS keyword
Between Pos // position of BETWEEN keyword
X Expr // lhs expression
UnboundedX Pos // position of lhs UNBOUNDED keyword
PrecedingX Pos // position of lhs PRECEDING keyword
CurrentX Pos // position of lhs CURRENT keyword
CurrentRowX Pos // position of lhs ROW keyword
FollowingX Pos // position of lhs FOLLOWING keyword
And Pos // position of AND keyword
Y Expr // lhs expression
UnboundedY Pos // position of rhs UNBOUNDED keyword
FollowingY Pos // position of rhs FOLLOWING keyword
CurrentY Pos // position of rhs CURRENT keyword
CurrentRowY Pos // position of rhs ROW keyword
PrecedingY Pos // position of rhs PRECEDING keyword
Exclude Pos // position of EXCLUDE keyword
ExcludeNo Pos // position of NO keyword after EXCLUDE
ExcludeNoOthers Pos // position of OTHERS keyword after EXCLUDE NO
ExcludeCurrent Pos // position of CURRENT keyword after EXCLUDE
ExcludeCurrentRow Pos // position of ROW keyword after EXCLUDE CURRENT
ExcludeGroup Pos // position of GROUP keyword after EXCLUDE
ExcludeTies Pos // position of TIES keyword after EXCLUDE
}
type GeneratedConstraint ¶
type GeneratedConstraint struct {
Constraint Pos // position of CONSTRAINT keyword
Name *Ident // constraint name
Generated Pos // position of GENERATED keyword
Always Pos // position of ALWAYS keyword
As Pos // position of AS keyword
Lparen Pos // position of left paren
Expr Expr // default expression
Rparen Pos // position of right paren
Stored Pos // position of STORED keyword
Virtual Pos // position of VIRTUAL keyword
}
func (*GeneratedConstraint) Clone ¶
func (c *GeneratedConstraint) Clone() *GeneratedConstraint
Clone returns a deep copy of c.
func (*GeneratedConstraint) String ¶
func (c *GeneratedConstraint) String() string
String returns the string representation of the constraint.
type Ident ¶
type IndexedColumn ¶
type IndexedColumn struct {
X Expr // column expression
Collate Pos // position of COLLATE keyword
Collation *Ident // collation name
Asc Pos // position of optional ASC keyword
Desc Pos // position of optional DESC keyword
}
func (*IndexedColumn) Clone ¶
func (c *IndexedColumn) Clone() *IndexedColumn
Clone returns a deep copy of c.
func (*IndexedColumn) String ¶
func (c *IndexedColumn) String() string
String returns the string representation of the column.
type InsertStatement ¶
type InsertStatement struct {
WithClause *WithClause // clause containing CTEs
Insert Pos // position of INSERT keyword
Replace Pos // position of REPLACE keyword
InsertOr Pos // position of OR keyword after INSERT
InsertOrReplace Pos // position of REPLACE keyword after INSERT OR
InsertOrRollback Pos // position of ROLLBACK keyword after INSERT OR
InsertOrAbort Pos // position of ABORT keyword after INSERT OR
InsertOrFail Pos // position of FAIL keyword after INSERT OR
InsertOrIgnore Pos // position of IGNORE keyword after INSERT OR
Into Pos // position of INTO keyword
Table *Ident // table name
As Pos // position of AS keyword
Alias *Ident // optional alias
ColumnsLparen Pos // position of column list left paren
Columns []*Ident // optional column list
ColumnsRparen Pos // position of column list right paren
Values Pos // position of VALUES keyword
ValueLists []*ExprList // lists of lists of values
Select *SelectStatement // SELECT statement
Default Pos // position of DEFAULT keyword
DefaultValues Pos // position of VALUES keyword after DEFAULT
UpsertClause *UpsertClause // optional upsert clause
ReturningClause *ReturningClause // optional RETURNING clause
}
func (*InsertStatement) Clone ¶
func (s *InsertStatement) Clone() *InsertStatement
Clone returns a deep copy of s.
func (*InsertStatement) String ¶
func (s *InsertStatement) String() string
String returns the string representation of the statement.
type JoinClause ¶
type JoinClause struct {
X Source // lhs source
Operator *JoinOperator // join operator
Y Source // rhs source
Constraint JoinConstraint // join constraint
}
func (*JoinClause) String ¶
func (c *JoinClause) String() string
String returns the string representation of the clause.
type JoinConstraint ¶
type JoinConstraint interface {
Node
// contains filtered or unexported methods
}
JoinConstraint represents either an ON or USING join constraint.
func CloneJoinConstraint ¶
func CloneJoinConstraint(cons JoinConstraint) JoinConstraint
CloneJoinConstraint returns a deep copy cons.
type JoinOperator ¶
type JoinOperator struct {
Comma Pos // position of comma
Natural Pos // position of NATURAL keyword
Left Pos // position of LEFT keyword
Outer Pos // position of OUTER keyword
Inner Pos // position of INNER keyword
Cross Pos // position of CROSS keyword
Join Pos // position of JOIN keyword
}
func (*JoinOperator) Clone ¶
func (op *JoinOperator) Clone() *JoinOperator
Clone returns a deep copy of op.
func (*JoinOperator) String ¶
func (op *JoinOperator) String() string
String returns the string representation of the operator.
type ModuleArgument ¶
type ModuleArgument struct {
Name *Ident // argument name
Assign Pos // position of ASSIGN token (optional)
Literal Expr // literal that is assigned to name (optional)
Type *Type // type of Name, if Assign is set then Type cant be (optional)
}
func (*ModuleArgument) Clone ¶
func (a *ModuleArgument) Clone() *ModuleArgument
func (*ModuleArgument) String ¶
func (a *ModuleArgument) String() string
type Node ¶
type NotNullConstraint ¶
type NotNullConstraint struct {
Constraint Pos // position of CONSTRAINT keyword
Name *Ident // constraint name
Not Pos // position of NOT keyword
Null Pos // position of NULL keyword
}
func (*NotNullConstraint) Clone ¶
func (c *NotNullConstraint) Clone() *NotNullConstraint
Clone returns a deep copy of c.
func (*NotNullConstraint) String ¶
func (c *NotNullConstraint) String() string
String returns the string representation of the constraint.
type Null ¶
type OnConstraint ¶
func (*OnConstraint) Clone ¶
func (c *OnConstraint) Clone() *OnConstraint
Clone returns a deep copy of c.
func (*OnConstraint) String ¶
func (c *OnConstraint) String() string
String returns the string representation of the constraint.
type OrderingTerm ¶
type OrderingTerm struct {
X Expr // ordering expression
Collation *CollationClause
Asc Pos // position of ASC keyword
Desc Pos // position of DESC keyword
Nulls Pos // position of NULLS keyword
NullsFirst Pos // position of FIRST keyword
NullsLast Pos // position of LAST keyword
}
func (*OrderingTerm) Clone ¶
func (t *OrderingTerm) Clone() *OrderingTerm
Clone returns a deep copy of t.
func (*OrderingTerm) String ¶
func (t *OrderingTerm) String() string
String returns the string representation of the term.
type OverClause ¶
type OverClause struct {
Over Pos // position of OVER keyword
Name *Ident // window name
Definition *WindowDefinition // window definition
}
func (*OverClause) String ¶
func (c *OverClause) String() string
String returns the string representation of the clause.
type ParenExpr ¶
type ParenExpr struct {
Lparen Pos // position of left paren
X Expr // parenthesized expression
Rparen Pos // position of right paren
}
type ParenSource ¶
type ParenSource struct {
Lparen Pos // position of left paren
X Source // nested source
Rparen Pos // position of right paren
As Pos // position of AS keyword (select source only)
Alias *Ident // optional table alias (select source only)
}
func (*ParenSource) Clone ¶
func (s *ParenSource) Clone() *ParenSource
Clone returns a deep copy of s.
func (*ParenSource) String ¶
func (s *ParenSource) String() string
String returns the string representation of the source.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser represents a SQL parser.
func NewParser ¶
func NewParser(r io.RuneReader) *Parser
NewParser returns a new instance of Parser that reads from r.
func (*Parser) ParseStatement ¶
type Pos ¶
type PragmaStatement ¶
type PragmaStatement struct {
Pragma Pos // position of PRAGMA keyword
Schema *Ident // name of schema (optional)
Dot Pos // position of DOT token (optional)
Expr Expr // can be Ident, Call or BinaryExpr
}
func (*PragmaStatement) Clone ¶
func (s *PragmaStatement) Clone() *PragmaStatement
Clone returns a deep copy of s.
func (*PragmaStatement) String ¶
func (s *PragmaStatement) String() string
String returns the string representation of the pragma statement.
type PrimaryKeyConstraint ¶
type PrimaryKeyConstraint struct {
Constraint Pos // position of CONSTRAINT keyword
Name *Ident // constraint name
Primary Pos // position of PRIMARY keyword
Key Pos // position of KEY keyword
Lparen Pos // position of left paren (table only)
Columns []*Ident // indexed columns (table only)
Rparen Pos // position of right paren (table only)
Autoincrement Pos // position of AUTOINCREMENT keyword (column only)
}
func (*PrimaryKeyConstraint) Clone ¶
func (c *PrimaryKeyConstraint) Clone() *PrimaryKeyConstraint
Clone returns a deep copy of c.
func (*PrimaryKeyConstraint) String ¶
func (c *PrimaryKeyConstraint) String() string
String returns the string representation of the constraint.
type QualifiedRef ¶
type QualifiedRef struct {
Table *Ident // table name
Dot Pos // position of dot
Star Pos // position of * (result column only)
Column *Ident // column name
}
func (*QualifiedRef) Clone ¶
func (r *QualifiedRef) Clone() *QualifiedRef
Clone returns a deep copy of r.
func (*QualifiedRef) String ¶
func (r *QualifiedRef) String() string
String returns the string representation of the expression.
type QualifiedTableFunctionName ¶
type QualifiedTableFunctionName struct {
Name *Ident // table function name
Lparen Pos // position of left paren
Args []Expr // argument list
Rparen Pos // position of right paren
As Pos // position of AS keyword
Alias *Ident // optional table alias
}
func (*QualifiedTableFunctionName) Clone ¶
func (n *QualifiedTableFunctionName) Clone() *QualifiedTableFunctionName
Clone returns a deep copy of n.
func (*QualifiedTableFunctionName) String ¶
func (n *QualifiedTableFunctionName) String() string
String returns the string representation of the table name.
func (*QualifiedTableFunctionName) TableName ¶
func (n *QualifiedTableFunctionName) TableName() string
TableName returns the name used to identify n. Returns the alias, if one is specified. Otherwise returns the name.
type QualifiedTableName ¶
type QualifiedTableName struct {
Schema *Ident // schema name
Dot Pos // position of dot
Name *Ident // table name
As Pos // position of AS keyword
Alias *Ident // optional table alias
Indexed Pos // position of INDEXED keyword
IndexedBy Pos // position of BY keyword after INDEXED
Not Pos // position of NOT keyword before INDEXED
NotIndexed Pos // position of NOT keyword before INDEXED
Index *Ident // name of index
}
func (*QualifiedTableName) Clone ¶
func (n *QualifiedTableName) Clone() *QualifiedTableName
Clone returns a deep copy of n.
func (*QualifiedTableName) String ¶
func (n *QualifiedTableName) String() string
String returns the string representation of the table name.
func (*QualifiedTableName) TableName ¶
func (n *QualifiedTableName) TableName() string
TableName returns the name used to identify n. Returns the alias, if one is specified. Otherwise returns the name.
type Raise ¶
type Raise struct {
Raise Pos // position of RAISE keyword
Lparen Pos // position of left paren
Ignore Pos // position of IGNORE keyword
Rollback Pos // position of ROLLBACK keyword
Abort Pos // position of ABORT keyword
Fail Pos // position of FAIL keyword
Comma Pos // position of comma
Error *StringLit // error message
Rparen Pos // position of right paren
}
type Range ¶
type ReindexStatement ¶
type ReindexStatement struct {
Reindex Pos // position of REINDEX keyword
Name Expr // collation, index or table name (or schema.table, schema.index)
}
func (*ReindexStatement) Clone ¶
func (s *ReindexStatement) Clone() *ReindexStatement
Clone returns a deep copy of s.
func (*ReindexStatement) String ¶
func (s *ReindexStatement) String() string
String returns the string representation of the statement.
type ReleaseStatement ¶
type ReleaseStatement struct {
Release Pos // position of RELEASE keyword
Savepoint Pos // position of SAVEPOINT keyword (optional)
Name *Ident // name of savepoint
}
func (*ReleaseStatement) Clone ¶
func (s *ReleaseStatement) Clone() *ReleaseStatement
Clone returns a deep copy of s.
func (*ReleaseStatement) String ¶
func (s *ReleaseStatement) String() string
String returns the string representation of the statement.
type ResultColumn ¶
type ResultColumn struct {
Star Pos // position of *
Expr Expr // column expression (may be "tbl.*")
As Pos // position of AS keyword
Alias *Ident // alias name
}
func (*ResultColumn) Clone ¶
func (c *ResultColumn) Clone() *ResultColumn
Clone returns a deep copy of c.
func (*ResultColumn) String ¶
func (c *ResultColumn) String() string
String returns the string representation of the column.
type ReturningClause ¶
type ReturningClause struct {
Returning Pos // position of RETURNING keyword
Columns []*ResultColumn // list of result columns in the SELECT clause
}
func (*ReturningClause) Clone ¶
func (c *ReturningClause) Clone() *ReturningClause
Clone returns a deep copy of c.
func (*ReturningClause) String ¶
func (c *ReturningClause) String() string
String returns the string representation of the clause.
type RollbackStatement ¶
type RollbackStatement struct {
Rollback Pos // position of ROLLBACK keyword
Transaction Pos // position of TRANSACTION keyword (optional)
To Pos // position of TO keyword (optional)
Savepoint Pos // position of SAVEPOINT keyword (optional)
SavepointName *Ident // name of savepoint
}
func (*RollbackStatement) Clone ¶
func (s *RollbackStatement) Clone() *RollbackStatement
Clone returns a deep copy of s.
func (*RollbackStatement) String ¶
func (s *RollbackStatement) String() string
String returns the string representation of the statement.
type SavepointStatement ¶
type SavepointStatement struct {
Savepoint Pos // position of SAVEPOINT keyword
Name *Ident // name of savepoint
}
func (*SavepointStatement) Clone ¶
func (s *SavepointStatement) Clone() *SavepointStatement
Clone returns a deep copy of s.
func (*SavepointStatement) String ¶
func (s *SavepointStatement) String() string
String returns the string representation of the statement.
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
func NewScanner ¶
func NewScanner(r io.RuneReader) *Scanner
type Scope ¶
Scope represents a context for name resolution. Names can be resolved at the current source or in parent scopes.
type SelectExpr ¶
type SelectExpr struct {
*SelectStatement
}
SelectExpr represents a SELECT statement inside an expression.
func (SelectExpr) Clone ¶
func (expr SelectExpr) Clone() SelectExpr
Clone returns a deep copy of expr.
type SelectStatement ¶
type SelectStatement struct {
WithClause *WithClause // clause containing CTEs
Values Pos // position of VALUES keyword
ValueLists []*ExprList // lists of lists of values
Select Pos // position of SELECT keyword
Distinct Pos // position of DISTINCT keyword
All Pos // position of ALL keyword
Columns []*ResultColumn // list of result columns in the SELECT clause
From Pos // position of FROM keyword
Source Source // chain of tables & subqueries in FROM clause
Where Pos // position of WHERE keyword
WhereExpr Expr // condition for WHERE clause
Group Pos // position of GROUP keyword
GroupBy Pos // position of BY keyword after GROUP
GroupByExprs []Expr // group by expression list
Having Pos // position of HAVING keyword
HavingExpr Expr // HAVING expression
Window Pos // position of WINDOW keyword
Windows []*Window // window list
Union Pos // position of UNION keyword
UnionAll Pos // position of ALL keyword after UNION
Intersect Pos // position of INTERSECT keyword
Except Pos // position of EXCEPT keyword
Compound *SelectStatement // compounded SELECT statement
Order Pos // position of ORDER keyword
OrderBy Pos // position of BY keyword after ORDER
OrderingTerms []*OrderingTerm // terms of ORDER BY clause
Limit Pos // position of LIMIT keyword
LimitExpr Expr // limit expression
Offset Pos // position of OFFSET keyword
OffsetComma Pos // position of COMMA (instead of OFFSET)
OffsetExpr Expr // offset expression
}
func (*SelectStatement) Clone ¶
func (s *SelectStatement) Clone() *SelectStatement
Clone returns a deep copy of s.
func (*SelectStatement) String ¶
func (s *SelectStatement) String() string
String returns the string representation of the statement.
type Source ¶
type Source interface {
Node
// contains filtered or unexported methods
}
Source represents a table or subquery.
func ResolveSource ¶
ResolveSource returns a source with the given name. This can either be the table name or the alias for a source.
func SourceList ¶
SourceList returns a list of scopes in the current scope.
func StatementSource ¶
StatementSource returns the root statement for a statement.
type Statement ¶
type Statement interface {
Node
// contains filtered or unexported methods
}
func CloneStatement ¶
CloneStatement returns a deep copy stmt.
type StringLit ¶
type StringLit struct {
ValuePos Pos // literal position
Value string // literal value (without quotes)
}
type TimestampLit ¶
func (*TimestampLit) Clone ¶
func (lit *TimestampLit) Clone() *TimestampLit
Clone returns a deep copy of lit.
func (*TimestampLit) String ¶
func (lit *TimestampLit) String() string
String returns the string representation of the expression.
type Token ¶
type Token int
Token is the set of lexical tokens of the Go programming language.
const ( // Special tokens ILLEGAL Token = iota EOF COMMENT SPACE IDENT // IDENT QIDENT // "IDENT" STRING // 'string' BLOB // ??? FLOAT // 123.45 INTEGER // 123 NULL // NULL TRUE // true FALSE // false BIND //? or ?NNN or :VVV or @VVV or $VVV SEMI // ; LP // ( RP // ) COMMA // , NE // != EQ // = LE // <= LT // < GT // > GE // >= BITAND // & BITOR // | BITNOT // ~ LSHIFT // << RSHIFT // >> PLUS // + MINUS // - STAR // * SLASH // / REM // % CONCAT // || DOT // . JSON_EXTRACT_JSON // -> JSON_EXTRACT_SQL // ->> ABORT ACTION ADD AFTER AGG_COLUMN AGG_FUNCTION ALL ALTER ALWAYS ANALYZE AND AS ASC ASTERISK ATTACH AUTOINCREMENT BEFORE BEGIN BETWEEN BY CASCADE CASE CAST CHECK COLLATE COLUMN COLUMNKW COMMIT CONFLICT CONSTRAINT CREATE CROSS CTIME_KW CURRENT CURRENT_TIME CURRENT_DATE CURRENT_TIMESTAMP DATABASE DEFAULT DEFERRABLE DEFERRED DELETE DESC DETACH DISTINCT DO DROP EACH ELSE END ESCAPE EXCEPT EXCLUDE EXCLUSIVE EXISTS EXPLAIN FAIL FILTER FIRST FOLLOWING FOR FOREIGN FROM FUNCTION GENERATED GLOB GROUP GROUPS HAVING IF IF_NULL_ROW IGNORE IMMEDIATE IN INDEX INDEXED INITIALLY INNER INSERT INSTEAD INTERSECT INTO IS ISNOT ISNULL // TODO: REMOVE? JOIN KEY LAST LEFT LIKE LIMIT MATCH NATURAL NO NOT NOTBETWEEN NOTEXISTS NOTGLOB NOTHING NOTIN NOTLIKE NOTMATCH NOTNULL NOTREGEXP NULLS OF OFFSET ON OR ORDER OTHERS OUTER OVER PARTITION PLAN PRAGMA PRECEDING PRIMARY QUERY RAISE RANGE RECURSIVE REFERENCES REGEXP REGISTER REINDEX RELEASE RENAME REPLACE RESTRICT RETURNING ROLLBACK ROW ROWID ROWS SAVEPOINT SELECT SELECT_COLUMN SET SPAN STORED STRICT TABLE TEMP THEN TIES TO TRANSACTION TRIGGER TRUTH UNBOUNDED UNION UNIQUE UPDATE USING VACUUM VALUES VARIABLE VECTOR VIEW VIRTUAL WHEN WHERE WINDOW WITH WITHOUT ANY // ??? )
The list of tokens.
func (Token) IsBinaryOp ¶
func (Token) Precedence ¶
type Type ¶
type UnaryExpr ¶
type UnaryExpr struct {
OpPos Pos // operation position
Op Token // operation
X Expr // target expression
}
type UniqueConstraint ¶
type UniqueConstraint struct {
Constraint Pos // position of CONSTRAINT keyword
Name *Ident // constraint name
Unique Pos // position of UNIQUE keyword
Lparen Pos // position of left paren (table only)
Columns []*IndexedColumn // indexed columns (table only)
Rparen Pos // position of right paren (table only)
}
func (*UniqueConstraint) Clone ¶
func (c *UniqueConstraint) Clone() *UniqueConstraint
Clone returns a deep copy of c.
func (*UniqueConstraint) String ¶
func (c *UniqueConstraint) String() string
String returns the string representation of the constraint.
type UpdateStatement ¶
type UpdateStatement struct {
WithClause *WithClause // clause containing CTEs
Update Pos // position of UPDATE keyword
UpdateOr Pos // position of OR keyword after UPDATE
UpdateOrReplace Pos // position of REPLACE keyword after UPDATE OR
UpdateOrRollback Pos // position of ROLLBACK keyword after UPDATE OR
UpdateOrAbort Pos // position of ABORT keyword after UPDATE OR
UpdateOrFail Pos // position of FAIL keyword after UPDATE OR
UpdateOrIgnore Pos // position of IGNORE keyword after UPDATE OR
Table *QualifiedTableName // table name
Set Pos // position of SET keyword
Assignments []*Assignment // list of column assignments
Where Pos // position of WHERE keyword
WhereExpr Expr // conditional expression
ReturningClause *ReturningClause // optional RETURNING clause
}
func (*UpdateStatement) Clone ¶
func (s *UpdateStatement) Clone() *UpdateStatement
Clone returns a deep copy of s.
func (*UpdateStatement) String ¶
func (s *UpdateStatement) String() string
String returns the string representation of the clause.
type UpsertClause ¶
type UpsertClause struct {
On Pos // position of ON keyword
OnConflict Pos // position of CONFLICT keyword after ON
Lparen Pos // position of column list left paren
Columns []*IndexedColumn // optional indexed column list
Rparen Pos // position of column list right paren
Where Pos // position of WHERE keyword
WhereExpr Expr // optional conditional expression
Do Pos // position of DO keyword
DoNothing Pos // position of NOTHING keyword after DO
DoUpdate Pos // position of UPDATE keyword after DO
DoUpdateSet Pos // position of SET keyword after DO UPDATE
Assignments []*Assignment // list of column assignments
UpdateWhere Pos // position of WHERE keyword for DO UPDATE SET
UpdateWhereExpr Expr // optional conditional expression for DO UPDATE SET
}
func (*UpsertClause) Clone ¶
func (c *UpsertClause) Clone() *UpsertClause
Clone returns a deep copy of c.
func (*UpsertClause) String ¶
func (c *UpsertClause) String() string
String returns the string representation of the clause.
type UsingConstraint ¶
type UsingConstraint struct {
Using Pos // position of USING keyword
Lparen Pos // position of left paren
Columns []*Ident // column list
Rparen Pos // position of right paren
}
func (*UsingConstraint) Clone ¶
func (c *UsingConstraint) Clone() *UsingConstraint
Clone returns a deep copy of c.
func (*UsingConstraint) String ¶
func (c *UsingConstraint) String() string
String returns the string representation of the constraint.
type VisitEndFunc ¶
VisitEndFunc represents a function type that implements Visitor. Executes on node exit.
type VisitFunc ¶
VisitFunc represents a function type that implements Visitor. Executes on node entry.
type Visitor ¶
type Visitor interface {
Visit(n Node) (w Visitor, node Node, err error)
VisitEnd(n Node) (Node, error)
}
A Visitor's Visit method is invoked for each node encountered by Walk. If the result visitor w is not nil, Walk visits each of the children of node with the visitor w, followed by a call of w.VisitEnd(n).
type Window ¶
type Window struct {
Name *Ident // name of window
As Pos // position of AS keyword
Definition *WindowDefinition // window definition
}
type WindowDefinition ¶
type WindowDefinition struct {
Lparen Pos // position of left paren
Base *Ident // base window name
Partition Pos // position of PARTITION keyword
PartitionBy Pos // position of BY keyword (after PARTITION)
Partitions []Expr // partition expressions
Order Pos // position of ORDER keyword
OrderBy Pos // position of BY keyword (after ORDER)
OrderingTerms []*OrderingTerm // ordering terms
Frame *FrameSpec // frame
Rparen Pos // position of right paren
}
func (*WindowDefinition) Clone ¶
func (d *WindowDefinition) Clone() *WindowDefinition
Clone returns a deep copy of d.
func (*WindowDefinition) String ¶
func (d *WindowDefinition) String() string
String returns the string representation of the window definition.
type WithClause ¶
type WithClause struct {
With Pos // position of WITH keyword
Recursive Pos // position of RECURSIVE keyword
CTEs []*CTE // common table expressions
}
func (*WithClause) String ¶
func (c *WithClause) String() string
String returns the string representation of the clause.