Documentation
¶
Overview ¶
Code generated by goyacc -l -o yy_parser.go grammar.y. DO NOT EDIT.
Index ¶
- Constants
- Variables
- func GetUniqueTableReferences(node Node) []string
- func Walk(visit Visit, nodes ...Node) error
- type AST
- type AliasedSelectColumn
- type AliasedTableExpr
- type AlterTable
- type AlterTableAdd
- type AlterTableClause
- type AlterTableDrop
- type AlterTableRename
- type AndExpr
- type BetweenExpr
- type BinaryExpr
- type BoolValue
- type CaseExpr
- type CmpExpr
- type ColTuple
- type CollateExpr
- type Column
- type ColumnConstraint
- type ColumnConstraintCheck
- type ColumnConstraintDefault
- type ColumnConstraintGenerated
- type ColumnConstraintNotNull
- type ColumnConstraintPrimaryKey
- type ColumnConstraintUnique
- type ColumnDef
- type ColumnList
- type CompoundSelect
- type ConvertExpr
- type ConvertType
- type CreateTable
- type CreateTableStatement
- type CustomFuncExpr
- type Delete
- type ErrAlterTablePrimaryKeyNotAllowed
- type ErrAlterTableUniqueNotAllowed
- type ErrBlobTooBig
- type ErrCompoudSelectNotAllowed
- type ErrContainsJoinTableExpr
- type ErrGrantRepeatedPrivilege
- type ErrKeywordIsNotAllowed
- type ErrMultiplePrimaryKey
- type ErrNaturalJoinWithOnOrUsingClause
- type ErrNoSuchFunction
- type ErrNotNullConstraintDefaultNotNull
- type ErrNumericLiteralFloat
- type ErrRowIDNotAllowed
- type ErrStatementContainsSubquery
- type ErrSyntaxError
- type ErrTableNameWrongFormat
- type ErrTextTooLong
- type ErrTooManyColumns
- type ErrUpdateColumnsAndValuesDiffer
- type ErrUpsertMissingTarget
- type ExistsExpr
- type Expr
- type Exprs
- type FuncExpr
- type Grant
- type GrantOrRevokeStatement
- type GroupBy
- type Identifier
- type IndexedColumn
- type IndexedColumnList
- type Insert
- type IsExpr
- type IsNullExpr
- type JoinOperator
- type JoinTableExpr
- type Lexer
- type Limit
- type Node
- type NotExpr
- type NotNullExpr
- type NullValue
- type NullsType
- type OnConflictClause
- type OnConflictTarget
- type OnConflictUpdate
- type OrExpr
- type OrderBy
- type OrderingTerm
- type Param
- type ParenExpr
- type ParenTableExpr
- type Privileges
- type ReadStatement
- type ReadStatementResolver
- type Revoke
- type Select
- type SelectColumn
- type SelectColumnList
- type SimpleTableExpr
- type StarSelectColumn
- type Statement
- type Subquery
- type Table
- type TableConstraint
- type TableConstraintCheck
- type TableConstraintPrimaryKey
- type TableConstraintUnique
- type TableExpr
- type UnaryExpr
- type Update
- type UpdateExpr
- type UpdateExprs
- type Upsert
- type ValidatedCreateTable
- type ValidatedTable
- type Value
- type ValueType
- type Visit
- type When
- type Where
- type WriteStatement
- type WriteStatementResolver
Constants ¶
const ( CompoundUnionStr = "union" CompoundUnionAllStr = "union all" CompoundIntersectStr = "intersect" CompoundExceptStr = "except" )
Compound Select operation types.
const ( DistinctStr = "distinct " AllStr = "all " )
Distinct/All.
const ( JoinStr = "join" LeftJoinStr = "left join" RightJoinStr = "right join" FullJoinStr = "full join" InnerJoinStr = "inner join" )
Kinds of JoinOperator.
const ( WhereStr = "where" HavingStr = "having" )
Types for Where.
const ( AscStr = "asc" DescStr = "desc" )
Possible directions for OrderingTerm.
const ( StrValue = ValueType(iota) IntValue FloatValue HexNumValue BlobValue )
All possible value types.
const ( UPlusStr = "+" UMinusStr = "-" TildaStr = "~" )
Operators for UnaryExpr.
const ( BitAndStr = "&" BitOrStr = "|" PlusStr = "+" MinusStr = "-" MultStr = "*" DivStr = "/" ModStr = "%" ShiftLeftStr = "<<" ShiftRightStr = ">>" ConcatStr = "||" JSONExtractOp = "->" JSONUnquoteExtractOp = "->>" )
Operators for BinaryExpr.
const ( EqualStr = "=" LessThanStr = "<" GreaterThanStr = ">" LessEqualStr = "<=" GreaterEqualStr = ">=" NotEqualStr = "!=" InStr = "in" NotInStr = "not in" LikeStr = "like" NotLikeStr = "not like" RegexpStr = "regexp" NotRegexpStr = "not regexp" MatchStr = "match" NotMatchStr = "not match" GlobStr = "glob" NotGlobStr = "not glob" )
Operators for CmpExpr.
const ( // NoneStr NONE convert type. NoneStr = ConvertType("none") // TextStr TEXT convert type. TextStr = ConvertType("text") // IntegerStr INTEGER convert type. IntegerStr = ConvertType("integer") )
const ( BetweenStr = "between" NotBetweenStr = "not between" )
Operators for BetweenExpr.
const ( TypeIntStr = "int" TypeIntegerStr = "integer" TypeTextStr = "text" TypeBlobStr = "blob" )
Types for ColumnDef type.
const ( // PrimaryKeyOrderEmpty no primary key order. PrimaryKeyOrderEmpty = "" // PrimaryKeyOrderAsc primary key asc order. PrimaryKeyOrderAsc = "asc" // PrimaryKeyOrderDesc primary key desc order. PrimaryKeyOrderDesc = "desc" )
const ( // MaxTextLength is the limit for the length of a TEXT literal value. MaxTextLength = 1024 // MaxBlobLength is the limit for the length of a BLOB literal value. MaxBlobLength = 1024 // MaxAllowedColumns is the limit for the number of columns in a CREATE TABLE statement. MaxAllowedColumns = 24 )
const ADD = 57417
const ALL = 57382
const ALTER = 57414
const ALWAYS = 57398
const AND = 57356
const ANDOP = 57430
const AS = 57361
const ASC = 57376
const BETWEEN = 57438
const BLOB = 57391
const BLOBVAL = 57351
const BY = 57371
const CASE = 57362
const CAST = 57360
const CHECK = 57395
const COLLATE = 57452
const COLUMN = 57416
const CONCAT = 57449
const CONFLICT = 57408
const CONSTRAINT = 57401
const CREATE = 57388
const CROSS = 57425
const DEFAULT = 57396
const DELETE = 57405
const DESC = 57377
const DISTINCT = 57381
const DO = 57409
const DROP = 57418
const ELSE = 57365
const END = 57366
const EOF = 0
EOF is the end of input.
const ERROR = 57352
const ESCAPE = 57446
const EXCEPT = 57386
const EXISTS = 57383
const FALSE = 57354
const FILTER = 57384
const FIRST = 57379
const FLOAT = 57350
const FROM = 57368
const FULL = 57420
const GE = 57444
const GENERATED = 57397
const GLOB = 57435
const GRANT = 57411
const GROUP = 57370
const HAVING = 57372
const HEXNUM = 57349
const IDENTIFIER = 57346
const IN = 57439
const INEQUALITY = 57445
const INNER = 57421
const INSERT = 57402
const INT = 57390
const INTEGER = 57358
const INTEGRAL = 57348
const INTERSECT = 57387
const INTO = 57403
const IS = 57432
const ISNOT = 57433
const ISNULL = 57440
const JOIN = 57426
const JSON_EXTRACT_OP = 57450
const JSON_UNQUOTE_EXTRACT_OP = 57451
const KEY = 57393
const LAST = 57380
const LE = 57443
const LEFT = 57422
const LIKE = 57437
const LIMIT = 57373
const LSHIFT = 57447
const MATCH = 57434
const NATURAL = 57423
const NE = 57442
const NONE = 57357
const NOT = 57431
const NOTHING = 57410
const NOTNULL = 57441
const NULL = 57355
const NULLS = 57378
const OFFSET = 57374
const ON = 57427
const OR = 57429
const ORDER = 57375
const OUTER = 57424
const PRIMARY = 57392
const REGEXP = 57436
const RENAME = 57415
const REVOKE = 57413
const RIGHT = 57419
const RSHIFT = 57448
const SELECT = 57367
const SET = 57407
const STORED = 57399
const STRING = 57347
const TABLE = 57389
const TEXT = 57359
const THEN = 57364
const TO = 57412
const TRUE = 57353
const UNARY = 57453
const UNION = 57385
const UNIQUE = 57394
const UPDATE = 57406
const USING = 57428
const VALUES = 57404
const VIRTUAL = 57400
const WHEN = 57363
const WHERE = 57369
Variables ¶
var AllowedFunctions = map[string]bool{ "abs": false, "char": false, "coalesce": false, "format": false, "glob": false, "hex": false, "ifnull": false, "iif": false, "instr": false, "length": false, "like": false, "lower": false, "ltrim": false, "max": false, "min": false, "nullif": false, "printf": false, "quote": false, "replace": false, "round": false, "rtrim": false, "sign": false, "substr": false, "substring": false, "trim": false, "typeof": false, "unicode": false, "upper": false, "acos": false, "acosh": false, "asin": false, "asinh": false, "atan": false, "atan2": false, "atanh": false, "ceil": false, "ceiling": false, "cos": false, "cosh": false, "degrees": false, "exp": false, "floor": false, "ln": false, "log": false, "log10": false, "log2": false, "mod": false, "pi": false, "pow": false, "power": false, "radians": false, "sin": false, "sinh": false, "sqrt": false, "tan": false, "tanh": false, "trunc": false, "json": false, "json_array": false, "json_array_length": false, "json_extract": false, "json_insert": false, "json_object": false, "json_patch": false, "json_remove": false, "json_replace": false, "json_set": false, "json_type": false, "json_valid": false, "json_quote": false, "json_group_array": false, "json_group_object": false, "avg": false, "count": false, "group_concat": false, "sum": false, "total": false, "txn_hash": true, "block_num": true, }
AllowedFunctions is a map of allowed functions in Tableland. The value indicates if the function is custom.
Functions ¶
func GetUniqueTableReferences ¶
GetUniqueTableReferences returns a slice of tables' names referenced by the node.
Types ¶
type AliasedSelectColumn ¶
type AliasedSelectColumn struct { Expr Expr As Identifier }
AliasedSelectColumn defines an aliased SELECT column.
func (*AliasedSelectColumn) String ¶
func (node *AliasedSelectColumn) String() string
String returns the string representation of the node.
type AliasedTableExpr ¶
type AliasedTableExpr struct { Expr SimpleTableExpr As Identifier }
AliasedTableExpr represents a table expression coupled with an optional alias. If As is empty, no alias was used.
func (*AliasedTableExpr) String ¶
func (node *AliasedTableExpr) String() string
String returns the string representation of the node.
type AlterTable ¶
type AlterTable struct { Table *Table AlterTableClause AlterTableClause }
AlterTable represents an ALTER TABLE statement.
func (*AlterTable) GetTable ¶
func (node *AlterTable) GetTable() *Table
GetTable returns the table that ALTER refers to.
func (*AlterTable) Resolve ¶
func (node *AlterTable) Resolve(resolver WriteStatementResolver) (string, error)
Resolve returns a string representation with custom function nodes resolved to the values passed by resolver.
func (*AlterTable) String ¶
func (node *AlterTable) String() string
String returns the string representation of the node.
type AlterTableAdd ¶
type AlterTableAdd struct {
ColumnDef *ColumnDef
}
AlterTableAdd represents the alter table clause that adds a column.
func (*AlterTableAdd) String ¶
func (node *AlterTableAdd) String() string
String returns the string representation of the node.
type AlterTableClause ¶
type AlterTableClause interface { Node // contains filtered or unexported methods }
AlterTableClause represents an ALTER TABLE operation such as RENAME, ADD, or DROP.
type AlterTableDrop ¶
type AlterTableDrop struct {
Column *Column
}
AlterTableDrop represents the alter table clause that drops a column.
func (*AlterTableDrop) String ¶
func (node *AlterTableDrop) String() string
String returns the string representation of the node.
type AlterTableRename ¶
AlterTableRename represents the alter table clause that renames a column.
func (*AlterTableRename) String ¶
func (node *AlterTableRename) String() string
String returns the string representation of the node.
type BetweenExpr ¶
BetweenExpr represents a BETWEEN or a NOT BETWEEN expression.
func (*BetweenExpr) String ¶
func (node *BetweenExpr) String() string
String returns the string representation of the node.
type BinaryExpr ¶
BinaryExpr represents a binary value expression.
func (*BinaryExpr) String ¶
func (node *BinaryExpr) String() string
String returns the string representation of the node.
type ColTuple ¶
type ColTuple interface { Expr // contains filtered or unexported methods }
ColTuple represents a list of column values for IN operator. It can be ValTuple or Subquery.
type CollateExpr ¶
type CollateExpr struct { Expr Expr CollationName Identifier }
CollateExpr the COLLATE operator.
func (*CollateExpr) String ¶
func (node *CollateExpr) String() string
String returns the string representation of the node.
type ColumnConstraint ¶
type ColumnConstraint interface { Node // contains filtered or unexported methods }
ColumnConstraint is used for parsing column constraint info from SQL.
type ColumnConstraintCheck ¶
type ColumnConstraintCheck struct { Name Identifier Expr Expr }
ColumnConstraintCheck represents a CHECK column constraint for CREATE TABLE.
func (*ColumnConstraintCheck) String ¶
func (node *ColumnConstraintCheck) String() string
String returns the string representation of the node.
type ColumnConstraintDefault ¶
type ColumnConstraintDefault struct { Name Identifier Expr Expr Parenthesis bool }
ColumnConstraintDefault represents a DEFAULT column constraint for CREATE TABLE.
func (*ColumnConstraintDefault) String ¶
func (node *ColumnConstraintDefault) String() string
String returns the string representation of the node.
type ColumnConstraintGenerated ¶
type ColumnConstraintGenerated struct { Name Identifier Expr Expr // the GENERATED ALWAYS keywords are optional in the grammar. GeneratedAlways bool // this is a flag for VIRTUAL or STORED keywords. IsStored bool }
ColumnConstraintGenerated represents a GENERATED ALWAYS column constraint for CREATE TABLE.
func (*ColumnConstraintGenerated) String ¶
func (node *ColumnConstraintGenerated) String() string
String returns the string representation of the node.
type ColumnConstraintNotNull ¶
type ColumnConstraintNotNull struct {
Name Identifier
}
ColumnConstraintNotNull represents a NOT NULL column constraint for CREATE TABLE.
func (*ColumnConstraintNotNull) String ¶
func (node *ColumnConstraintNotNull) String() string
String returns the string representation of the node.
type ColumnConstraintPrimaryKey ¶
type ColumnConstraintPrimaryKey struct { Name Identifier Order string AutoIncrement bool }
ColumnConstraintPrimaryKey represents a PRIMARY KEY column constraint for CREATE TABLE.
func (*ColumnConstraintPrimaryKey) String ¶
func (node *ColumnConstraintPrimaryKey) String() string
String returns the string representation of the node.
type ColumnConstraintUnique ¶
type ColumnConstraintUnique struct {
Name Identifier
}
ColumnConstraintUnique represents a UNIQUE column constraint for CREATE TABLE.
func (*ColumnConstraintUnique) String ¶
func (node *ColumnConstraintUnique) String() string
String returns the string representation of the node.
type ColumnDef ¶
type ColumnDef struct { Column *Column Type string Constraints []ColumnConstraint }
ColumnDef represents the column definition of a CREATE TABLE statement.
func (*ColumnDef) HasPrimaryKey ¶
HasPrimaryKey checks if column definition has a primary key constraint.
type ColumnList ¶
type ColumnList []*Column
ColumnList is a list of columns.
func (ColumnList) String ¶
func (node ColumnList) String() string
String returns the string representation of the node.
type CompoundSelect ¶
type CompoundSelect struct { Left *Select Type string Right ReadStatement }
CompoundSelect represents a compound operation of selects.
func (*CompoundSelect) Resolve ¶
func (node *CompoundSelect) Resolve(resolver ReadStatementResolver) (string, error)
Resolve returns a string representation with custom function nodes resolved to the values passed by resolver.
func (*CompoundSelect) String ¶
func (node *CompoundSelect) String() string
type ConvertExpr ¶
type ConvertExpr struct { Expr Expr Type ConvertType }
ConvertExpr represents a CAST expression.
func (*ConvertExpr) String ¶
func (node *ConvertExpr) String() string
String returns the string representation of the node.
type CreateTable ¶
type CreateTable struct { Table *Table ColumnsDef []*ColumnDef Constraints []TableConstraint // This is the only TableOption supported in the AST. // The grammar cannot parse this option. // It is used to toggle the strict mode directiy in the AST. StrictMode bool }
CreateTable represents a CREATE TABLE statement.
func (*CreateTable) String ¶
func (node *CreateTable) String() string
String returns the string representation of the node.
func (*CreateTable) StructureHash ¶
func (node *CreateTable) StructureHash() string
StructureHash returns the hash of the structure of the statement.
type CreateTableStatement ¶
type CreateTableStatement interface { Node // contains filtered or unexported methods }
CreateTableStatement is any CREATE TABLE statement.
type CustomFuncExpr ¶
type CustomFuncExpr struct { Name Identifier Args Exprs ResolvedString string }
CustomFuncExpr represents a function call.
func (*CustomFuncExpr) String ¶
func (node *CustomFuncExpr) String() string
String returns the string representation of the node.
type Delete ¶
Delete represents an DELETE statement.
func (*Delete) AddWhereClause ¶
AddWhereClause add a WHERE clause to DELETE.
type ErrAlterTablePrimaryKeyNotAllowed ¶
type ErrAlterTablePrimaryKeyNotAllowed struct{}
ErrAlterTablePrimaryKeyNotAllowed indicates that primary key is not allowed in ALTER TABLE.
func (*ErrAlterTablePrimaryKeyNotAllowed) Error ¶
func (e *ErrAlterTablePrimaryKeyNotAllowed) Error() string
type ErrAlterTableUniqueNotAllowed ¶
type ErrAlterTableUniqueNotAllowed struct{}
ErrAlterTableUniqueNotAllowed indicates that unique is not allowed in ALTER TABLE.
func (*ErrAlterTableUniqueNotAllowed) Error ¶
func (e *ErrAlterTableUniqueNotAllowed) Error() string
type ErrBlobTooBig ¶
ErrBlobTooBig is an error returned when a query contains a BLOB constant that is too long.
func (*ErrBlobTooBig) Error ¶
func (e *ErrBlobTooBig) Error() string
type ErrCompoudSelectNotAllowed ¶
type ErrCompoudSelectNotAllowed struct{}
ErrCompoudSelectNotAllowed indicates that a compound SELECT is not allowed.
func (*ErrCompoudSelectNotAllowed) Error ¶
func (e *ErrCompoudSelectNotAllowed) Error() string
type ErrContainsJoinTableExpr ¶
type ErrContainsJoinTableExpr struct{}
ErrContainsJoinTableExpr indicates that a node contains a JOIN.
func (*ErrContainsJoinTableExpr) Error ¶
func (e *ErrContainsJoinTableExpr) Error() string
type ErrGrantRepeatedPrivilege ¶
type ErrGrantRepeatedPrivilege struct {
Privilege string
}
ErrGrantRepeatedPrivilege indicates a repeated privilege.
func (*ErrGrantRepeatedPrivilege) Error ¶
func (e *ErrGrantRepeatedPrivilege) Error() string
type ErrKeywordIsNotAllowed ¶
type ErrKeywordIsNotAllowed struct {
Keyword string
}
ErrKeywordIsNotAllowed indicates an error for keyword that is not allowed (eg CURRENT_TIME).
func (*ErrKeywordIsNotAllowed) Error ¶
func (e *ErrKeywordIsNotAllowed) Error() string
type ErrMultiplePrimaryKey ¶
type ErrMultiplePrimaryKey struct{}
ErrMultiplePrimaryKey indicates a that a CREATE statement has more than one primary key.
func (*ErrMultiplePrimaryKey) Error ¶
func (e *ErrMultiplePrimaryKey) Error() string
type ErrNaturalJoinWithOnOrUsingClause ¶
type ErrNaturalJoinWithOnOrUsingClause struct{}
ErrNaturalJoinWithOnOrUsingClause indicates that a ON or USING clause is used together with a NATURAL JOIN.
func (*ErrNaturalJoinWithOnOrUsingClause) Error ¶
func (e *ErrNaturalJoinWithOnOrUsingClause) Error() string
type ErrNoSuchFunction ¶
type ErrNoSuchFunction struct {
FunctionName string
}
ErrNoSuchFunction indicates that the function called does not exist.
func (*ErrNoSuchFunction) Error ¶
func (e *ErrNoSuchFunction) Error() string
type ErrNotNullConstraintDefaultNotNull ¶
type ErrNotNullConstraintDefaultNotNull struct{}
ErrNotNullConstraintDefaultNotNull indicates that you cannot add a not null constraint together with a not null default.
func (*ErrNotNullConstraintDefaultNotNull) Error ¶
func (e *ErrNotNullConstraintDefaultNotNull) Error() string
type ErrNumericLiteralFloat ¶
type ErrNumericLiteralFloat struct {
Value []byte
}
ErrNumericLiteralFloat indicates a literal numeric float is being used.
func (*ErrNumericLiteralFloat) Error ¶
func (e *ErrNumericLiteralFloat) Error() string
type ErrRowIDNotAllowed ¶
type ErrRowIDNotAllowed struct{}
ErrRowIDNotAllowed indicates a reference to the columns rowid, _rowid_, or oid in an INSERT, UPDATE or CREATE statement.
func (*ErrRowIDNotAllowed) Error ¶
func (e *ErrRowIDNotAllowed) Error() string
type ErrStatementContainsSubquery ¶
type ErrStatementContainsSubquery struct {
StatementKind string
}
ErrStatementContainsSubquery indicates a statement contains a subquery.
func (*ErrStatementContainsSubquery) Error ¶
func (e *ErrStatementContainsSubquery) Error() string
type ErrSyntaxError ¶
ErrSyntaxError indicates a syntax error.
func (*ErrSyntaxError) Error ¶
func (e *ErrSyntaxError) Error() string
type ErrTableNameWrongFormat ¶
type ErrTableNameWrongFormat struct {
Name string
}
ErrTableNameWrongFormat indicates that a table's name has the wrong format.
func (*ErrTableNameWrongFormat) Error ¶
func (e *ErrTableNameWrongFormat) Error() string
type ErrTextTooLong ¶
ErrTextTooLong is an error returned when a query contains a text constant that is too long.
func (*ErrTextTooLong) Error ¶
func (e *ErrTextTooLong) Error() string
type ErrTooManyColumns ¶
ErrTooManyColumns is an error returned when a create statement has more columns that allowed.
func (*ErrTooManyColumns) Error ¶
func (e *ErrTooManyColumns) Error() string
type ErrUpdateColumnsAndValuesDiffer ¶
ErrUpdateColumnsAndValuesDiffer indicates that there's a mismatch between the number of columns and number of values.
func (*ErrUpdateColumnsAndValuesDiffer) Error ¶
func (e *ErrUpdateColumnsAndValuesDiffer) Error() string
type ErrUpsertMissingTarget ¶
type ErrUpsertMissingTarget struct{}
ErrUpsertMissingTarget indicates a missing conflict target. The conflict target may be omitted on the last ON CONFLICT clause in the INSERT statement, but is required for all other ON CONFLICT clause.
func (*ErrUpsertMissingTarget) Error ¶
func (e *ErrUpsertMissingTarget) Error() string
type ExistsExpr ¶
type ExistsExpr struct {
Subquery *Subquery
}
ExistsExpr represents a EXISTS expression.
func (*ExistsExpr) String ¶
func (node *ExistsExpr) String() string
String returns the string representation of the node.
type Expr ¶
type Expr interface { Node // contains filtered or unexported methods }
Expr represents an expr node in the AST.
type FuncExpr ¶
type FuncExpr struct { Name Identifier Distinct bool Args Exprs Filter *Where }
FuncExpr represents a function call.
type Grant ¶
type Grant struct { Privileges Privileges Table *Table Roles []string }
Grant represents a GRANT statement.
func (*Grant) GetPrivileges ¶
func (node *Grant) GetPrivileges() Privileges
GetPrivileges returns the privileges.
type GrantOrRevokeStatement ¶
type GrantOrRevokeStatement interface { Statement GetRoles() []string GetPrivileges() Privileges GetTable() *Table // contains filtered or unexported methods }
GrantOrRevokeStatement is any GRANT/REVOKE statement.
type Identifier ¶
type Identifier string
Identifier represents a Column, Table and Function name identifier.
func (Identifier) IsEmpty ¶
func (node Identifier) IsEmpty() bool
IsEmpty returns if the identifier is empty.
func (Identifier) String ¶
func (node Identifier) String() string
String returns the string representation of the node.
type IndexedColumn ¶
type IndexedColumn struct { Column *Column CollationName Identifier Order string }
IndexedColumn represents a indexed column.
func (*IndexedColumn) String ¶
func (node *IndexedColumn) String() string
String returns the string representation of the node.
type IndexedColumnList ¶
type IndexedColumnList []*IndexedColumn
IndexedColumnList is a list of indexed columns.
func (IndexedColumnList) String ¶
func (node IndexedColumnList) String() string
String returns the string representation of the node.
type Insert ¶
type Insert struct { Table *Table Columns ColumnList Rows []Exprs DefaultValues bool Upsert Upsert Select *Select // RETURNING clause is not accepted in the parser. ReturningClause Exprs }
Insert represents an INSERT statement.
type IsNullExpr ¶
type IsNullExpr struct {
Expr Expr
}
IsNullExpr represents a IS expression.
func (*IsNullExpr) String ¶
func (node *IsNullExpr) String() string
String returns the string representation of the node.
type JoinOperator ¶
JoinOperator represents a join operator.
func (*JoinOperator) String ¶
func (node *JoinOperator) String() string
type JoinTableExpr ¶
type JoinTableExpr struct { LeftExpr TableExpr JoinOperator *JoinOperator RightExpr TableExpr On Expr Using ColumnList }
JoinTableExpr represents a TableExpr that's a JOIN operation.
func (*JoinTableExpr) String ¶
func (node *JoinTableExpr) String() string
String returns the string representation of the node.
type Lexer ¶
type Lexer struct {
// contains filtered or unexported fields
}
Lexer is responsible for token generation.
func (*Lexer) AddError ¶
AddError keeps track of errors per statement for syntatically valid statements.
type Node ¶
type Node interface { String() string // contains filtered or unexported methods }
Node represents a node in the AST.
type NotNullExpr ¶
type NotNullExpr struct {
Expr Expr
}
NotNullExpr represents a IS expression.
func (*NotNullExpr) String ¶
func (node *NotNullExpr) String() string
String returns the string representation of the node.
type OnConflictClause ¶
type OnConflictClause struct { Target *OnConflictTarget DoUpdate *OnConflictUpdate }
OnConflictClause represents an ON CONFLICT clause for upserts.
func (*OnConflictClause) String ¶
func (node *OnConflictClause) String() string
type OnConflictTarget ¶
type OnConflictTarget struct { Columns ColumnList Where *Where }
OnConflictTarget represents an ON CONFLICT target for upserts.
type OnConflictUpdate ¶
type OnConflictUpdate struct { Exprs UpdateExprs Where *Where }
OnConflictUpdate represents an ON CONFLICT.
type OrderingTerm ¶
OrderingTerm represents an ordering term expression.
func (*OrderingTerm) String ¶
func (node *OrderingTerm) String() string
String returns the string representation of the node.
type Param ¶
type Param struct {
ResolvedString string
}
Param represents a question mark (?) parameter.
type ParenTableExpr ¶
type ParenTableExpr struct {
TableExpr TableExpr
}
ParenTableExpr represents a parenthesized TableExpr.
func (*ParenTableExpr) String ¶
func (node *ParenTableExpr) String() string
String returns the string representation of the node.
type Privileges ¶
type Privileges map[string]struct{}
Privileges represents the GRANT privilges (INSERT, UPDATE, DELETE).
func (Privileges) Len ¶
func (node Privileges) Len() int
Len returns the length of privileges slice.
func (Privileges) String ¶
func (node Privileges) String() string
String returns the string representation of the node.
type ReadStatement ¶
type ReadStatement interface { Statement // Resolve returns a string representation with custom function nodes resolved to the values // passed by resolver. Resolve(ReadStatementResolver) (string, error) // contains filtered or unexported methods }
ReadStatement is any SELECT statement or UNION statement.
type ReadStatementResolver ¶
type ReadStatementResolver interface { // GetBlockNumber returns the last known block number for the provided chainID. If the chainID isn't known, // it returns (0, false). GetBlockNumber(chainID int64) (int64, bool) // GetBindValues returns a slice of values to be bound to their respective parameters. GetBindValues() []Expr }
ReadStatementResolver resolves Tableland Custom Functions for a read statement.
type Revoke ¶
type Revoke struct { Privileges Privileges Table *Table Roles []string }
Revoke represents a REVOKE statement.
func (*Revoke) GetPrivileges ¶
func (node *Revoke) GetPrivileges() Privileges
GetPrivileges returns the privileges.
type Select ¶
type Select struct { Distinct string SelectColumnList SelectColumnList From TableExpr Where *Where GroupBy GroupBy Having *Where Limit *Limit OrderBy OrderBy }
Select represents a SELECT statement.
type SelectColumn ¶
type SelectColumn interface { Node // contains filtered or unexported methods }
SelectColumn represents a SELECT column.
type SelectColumnList ¶
type SelectColumnList []SelectColumn
SelectColumnList represents a list of columns of a SELECT.
func (SelectColumnList) String ¶
func (node SelectColumnList) String() string
String returns the string representation of the node.
type SimpleTableExpr ¶
type SimpleTableExpr interface { Node // contains filtered or unexported methods }
SimpleTableExpr represents a direct table reference or a subquery.
type StarSelectColumn ¶
type StarSelectColumn struct {
TableRef *Table
}
StarSelectColumn defines a '*' or 'table.*' column.
func (*StarSelectColumn) String ¶
func (node *StarSelectColumn) String() string
String returns the string representation of the node.
type Statement ¶
type Statement interface { Node // contains filtered or unexported methods }
Statement represents a SQL statement.
type Table ¶
type Table struct { Name Identifier // IsTarget indicates if the table is a target of a statement or simply a reference. IsTarget bool }
Table represents a table.
type TableConstraint ¶
type TableConstraint interface { Node // contains filtered or unexported methods }
TableConstraint is a contrainst applied to the whole table in a CREATE TABLE statement.
type TableConstraintCheck ¶
type TableConstraintCheck struct { Name Identifier Expr Expr }
TableConstraintCheck is a CHECK constraint for table definition.
func (*TableConstraintCheck) String ¶
func (node *TableConstraintCheck) String() string
String returns the string representation of the node.
type TableConstraintPrimaryKey ¶
type TableConstraintPrimaryKey struct { Name Identifier Columns IndexedColumnList }
TableConstraintPrimaryKey is a PRIMARY KEY constraint for table definition.
func (*TableConstraintPrimaryKey) String ¶
func (node *TableConstraintPrimaryKey) String() string
String returns the string representation of the node.
type TableConstraintUnique ¶
type TableConstraintUnique struct { Name Identifier Columns ColumnList }
TableConstraintUnique is a UNIQUE constraint for table definition.
func (*TableConstraintUnique) String ¶
func (node *TableConstraintUnique) String() string
String returns the string representation of the node.
type TableExpr ¶
type TableExpr interface { Node // contains filtered or unexported methods }
TableExpr represents an expression referenced by FROM.
type Update ¶
type Update struct { Table *Table Exprs UpdateExprs Where *Where // RETURNING clause is not accepted in the parser. ReturningClause Exprs }
Update represents an UPDATE statement.
func (*Update) AddWhereClause ¶
AddWhereClause add a WHERE clause to UPDATE.
type UpdateExpr ¶
UpdateExpr represents an UPDATE SET expression (Column = Expr).
type UpdateExprs ¶
type UpdateExprs []*UpdateExpr
UpdateExprs represents a slice of UpdateExpr.
func (UpdateExprs) String ¶
func (node UpdateExprs) String() string
String returns the string representation of the node.
type Upsert ¶
type Upsert []*OnConflictClause
Upsert represents an upsert clause, which is a list of on conflict clause.
type ValidatedCreateTable ¶
type ValidatedCreateTable struct {
// contains filtered or unexported fields
}
ValidatedCreateTable is a Table that was validated by ValidateCreateTargetTable.
func ValidateCreateTargetTable ¶
func ValidateCreateTargetTable(table *Table) (*ValidatedCreateTable, error)
ValidateCreateTargetTable validates the table name for CREATE statements.
func (*ValidatedCreateTable) ChainID ¶
func (node *ValidatedCreateTable) ChainID() int64
ChainID returns the table's chain id.
func (*ValidatedCreateTable) Name ¶
func (node *ValidatedCreateTable) Name() string
Name returns the table's name.
func (*ValidatedCreateTable) Prefix ¶
func (node *ValidatedCreateTable) Prefix() string
Prefix returns table's prefix.
type ValidatedTable ¶
type ValidatedTable struct {
// contains filtered or unexported fields
}
ValidatedTable is a Table that was validated by ValidateTargetTable.
func ValidateTargetTable ¶
func ValidateTargetTable(table *Table) (*ValidatedTable, error)
ValidateTargetTable validates the tables' names of statements.
func ValidateTargetTables ¶
func ValidateTargetTables(node Node) ([]*ValidatedTable, error)
ValidateTargetTables recursively validates all tables found in the node and return them.
func (*ValidatedTable) ChainID ¶
func (node *ValidatedTable) ChainID() int64
ChainID returns the table's chain id.
func (*ValidatedTable) Name ¶
func (node *ValidatedTable) Name() string
Name returns the table's name.
func (*ValidatedTable) Prefix ¶
func (node *ValidatedTable) Prefix() string
Prefix returns table's prefix.
func (*ValidatedTable) TokenID ¶
func (node *ValidatedTable) TokenID() int64
TokenID returns the table's token id.
type Visit ¶
Visit defines the signature of a function that can be used to visit all nodes of a parse tree.
type Where ¶
Where represents a WHERE or HAVING clause.
type WriteStatement ¶
type WriteStatement interface { Statement GetTable() *Table // Resolve returns a string representation with custom function nodes resolved to the values // passed by resolver. Resolve(WriteStatementResolver) (string, error) // contains filtered or unexported methods }
WriteStatement is any INSERT, UPDATE or DELETE statement.
type WriteStatementResolver ¶
type WriteStatementResolver interface { // GetTxnHash returns the transaction hash of the transaction containing the query being processed. GetTxnHash() string // GetBlockNumber returns the block number of the block containing query being processed. GetBlockNumber() int64 }
WriteStatementResolver resolves Tableland Custom Functions for a write statement.