Documentation
¶
Overview ¶
Package parser provides SQL parsing functionality for SQL queries.
Index ¶
- func PutBinaryExpression(expr *BinaryExpression)
- func PutColumnReference(col *ColumnReference)
- func PutJoinClause(join *JoinClause)
- func PutSelectStatement(stmt *SelectStatement)
- type AliasedExpression
- type AlterAction
- type AlterTableStatement
- type Assignment
- type AssignmentStatement
- type BaseNode
- type BeginTransactionStatement
- type BinaryExpression
- type CaseExpression
- type CaseStatement
- type CatchBlock
- type CloseStatement
- type ColumnDefinition
- type ColumnReference
- type CommitStatement
- type CommonTableExpression
- type ContinueStatement
- type CreateFunctionStatement
- type CreateIndexStatement
- type CreateProcedureStatement
- type CreateTableStatement
- type CreateTriggerStatement
- type CreateViewStatement
- type CursorDecl
- type DataTypeDefinition
- type DeallocateStatement
- type DeleteStatement
- type DropStatement
- type ElseIfBlock
- type ExceptionBlock
- type ExistsExpression
- type ExitStatement
- type ExplainStatement
- type Expression
- type FetchStatement
- type ForStatement
- type ForeignKeyReference
- type FrameBound
- type FromClause
- type FunctionCall
- type HandlerDeclaration
- type IfStatement
- type InExpression
- type InsertStatement
- type JoinClause
- type LimitClause
- type Literal
- type LoopStatement
- type MergeAction
- type MergeStatement
- type MergeWhenClause
- type Node
- type OpenCursorStatement
- type OrderByClause
- type OverClause
- type ParseError
- type Parser
- type ProcedureBody
- type ProcedureParameter
- type RaiseStatement
- type ReleaseSavepointStatement
- type RepeatStatement
- type ReturnStatement
- type RollbackStatement
- type SavepointStatement
- type SelectStatement
- type SetOperation
- type SignalStatement
- type StarExpression
- type Statement
- type SubqueryExpression
- type SyntaxError
- type TableConstraint
- type TableReference
- type ThrowStatement
- type TopClause
- type TryStatement
- type UnaryExpression
- type UpdateStatement
- type VariableDecl
- type WhenBlock
- type WhenClause
- type WhenExceptionClause
- type WhileStatement
- type WindowFrame
- type WindowFunction
- type WithStatement
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PutBinaryExpression ¶
func PutBinaryExpression(expr *BinaryExpression)
PutBinaryExpression returns a BinaryExpression to the pool
func PutColumnReference ¶
func PutColumnReference(col *ColumnReference)
PutColumnReference returns a ColumnReference to the pool
func PutJoinClause ¶
func PutJoinClause(join *JoinClause)
PutJoinClause returns a JoinClause to the pool
func PutSelectStatement ¶
func PutSelectStatement(stmt *SelectStatement)
PutSelectStatement returns a SelectStatement to the pool
Types ¶
type AliasedExpression ¶
type AliasedExpression struct {
BaseNode
Expression Expression
Alias string
}
Aliased Expression (expression AS alias)
func (*AliasedExpression) String ¶
func (ae *AliasedExpression) String() string
func (*AliasedExpression) Type ¶
func (ae *AliasedExpression) Type() string
type AlterAction ¶
type AlterAction struct {
BaseNode
ActionType string // ADD, DROP, MODIFY, CHANGE, RENAME
Column *ColumnDefinition // For ADD/MODIFY
ColumnName string // For DROP/CHANGE
NewColumn *ColumnDefinition // For CHANGE
Constraint *TableConstraint // For ADD constraint
}
ALTER Action
func (*AlterAction) String ¶
func (aa *AlterAction) String() string
func (*AlterAction) Type ¶
func (aa *AlterAction) Type() string
type AlterTableStatement ¶
type AlterTableStatement struct {
BaseNode
Table TableReference
Action *AlterAction
}
ALTER TABLE Statement
func (*AlterTableStatement) String ¶
func (ats *AlterTableStatement) String() string
func (*AlterTableStatement) Type ¶
func (ats *AlterTableStatement) Type() string
type Assignment ¶
type Assignment struct {
BaseNode
Column string
Value Expression
}
Assignment for UPDATE SET clause
func (*Assignment) String ¶
func (a *Assignment) String() string
func (*Assignment) Type ¶
func (a *Assignment) Type() string
type AssignmentStatement ¶
type AssignmentStatement struct {
BaseNode
Variable string
Value Expression
}
AssignmentStatement represents variable assignment (SET or :=)
func (*AssignmentStatement) String ¶
func (as *AssignmentStatement) String() string
func (*AssignmentStatement) Type ¶
func (as *AssignmentStatement) Type() string
type BeginTransactionStatement ¶
type BeginTransactionStatement struct {
BaseNode
UseStart bool // true if START TRANSACTION, false if BEGIN
}
BEGIN/START TRANSACTION Statement
func (*BeginTransactionStatement) String ¶
func (bts *BeginTransactionStatement) String() string
func (*BeginTransactionStatement) Type ¶
func (bts *BeginTransactionStatement) Type() string
type BinaryExpression ¶
type BinaryExpression struct {
BaseNode
Left Expression
Operator string
Right Expression
}
Binary Expression (for WHERE conditions, etc.)
func GetBinaryExpression ¶
func GetBinaryExpression() *BinaryExpression
GetBinaryExpression gets a pooled BinaryExpression
func (*BinaryExpression) String ¶
func (be *BinaryExpression) String() string
func (*BinaryExpression) Type ¶
func (be *BinaryExpression) Type() string
type CaseExpression ¶
type CaseExpression struct {
BaseNode
Input Expression // Optional input for simple CASE
WhenClauses []*WhenClause
ElseResult Expression // Optional ELSE clause
}
CASE Expression
func (*CaseExpression) String ¶
func (ce *CaseExpression) String() string
func (*CaseExpression) Type ¶
func (ce *CaseExpression) Type() string
type CaseStatement ¶
type CaseStatement struct {
BaseNode
Expression Expression // Optional: CASE expr WHEN...
WhenList []*WhenBlock // WHEN conditions
ElseBlock []Statement // ELSE block
}
CaseStatement represents CASE statement (procedural, not expression)
func (*CaseStatement) String ¶
func (cs *CaseStatement) String() string
func (*CaseStatement) Type ¶
func (cs *CaseStatement) Type() string
type CatchBlock ¶
type CloseStatement ¶
CloseStatement represents CLOSE cursor
func (*CloseStatement) String ¶
func (cs *CloseStatement) String() string
func (*CloseStatement) Type ¶
func (cs *CloseStatement) Type() string
type ColumnDefinition ¶
type ColumnDefinition struct {
BaseNode
Name string
DataType string
Length int // For VARCHAR(255), etc.
Precision int // For DECIMAL(10,2)
Scale int // For DECIMAL(10,2)
NotNull bool
PrimaryKey bool
Unique bool
AutoIncrement bool
Default Expression
References *ForeignKeyReference // For inline FOREIGN KEY
}
Column Definition
func (*ColumnDefinition) String ¶
func (cd *ColumnDefinition) String() string
func (*ColumnDefinition) Type ¶
func (cd *ColumnDefinition) Type() string
type ColumnReference ¶
Column Reference
func GetColumnReference ¶
func GetColumnReference() *ColumnReference
GetColumnReference gets a pooled ColumnReference
func (*ColumnReference) String ¶
func (cr *ColumnReference) String() string
func (*ColumnReference) Type ¶
func (cr *ColumnReference) Type() string
type CommitStatement ¶
COMMIT Statement
func (*CommitStatement) String ¶
func (cs *CommitStatement) String() string
func (*CommitStatement) Type ¶
func (cs *CommitStatement) Type() string
type CommonTableExpression ¶
type CommonTableExpression struct {
BaseNode
Name string
Columns []string // Optional column names
Query Statement // Can be SelectStatement or SetOperation (for recursive CTEs with UNION)
}
CTE (Common Table Expression) - WITH clause
func (*CommonTableExpression) String ¶
func (cte *CommonTableExpression) String() string
func (*CommonTableExpression) Type ¶
func (cte *CommonTableExpression) Type() string
type ContinueStatement ¶
type ContinueStatement struct {
BaseNode
Label string // Loop label
Condition Expression // WHEN condition (PostgreSQL)
}
ContinueStatement represents CONTINUE/ITERATE (loop control)
func (*ContinueStatement) String ¶
func (cs *ContinueStatement) String() string
func (*ContinueStatement) Type ¶
func (cs *ContinueStatement) Type() string
type CreateFunctionStatement ¶
type CreateFunctionStatement struct {
BaseNode
Name string
Parameters []*ProcedureParameter
ReturnType *DataTypeDefinition
Body *ProcedureBody
Language string // SQL, PLPGSQL, etc.
Deterministic bool // DETERMINISTIC
SecurityDefiner bool // SECURITY DEFINER vs INVOKER
Options map[string]string // Dialect-specific options
OrReplace bool // CREATE OR REPLACE
IfNotExists bool // IF NOT EXISTS
}
CreateFunctionStatement represents CREATE FUNCTION
func (*CreateFunctionStatement) String ¶
func (cfs *CreateFunctionStatement) String() string
func (*CreateFunctionStatement) Type ¶
func (cfs *CreateFunctionStatement) Type() string
type CreateIndexStatement ¶
type CreateIndexStatement struct {
BaseNode
IndexName string
Table TableReference
Columns []string
Unique bool
IfNotExists bool
}
CREATE INDEX Statement
func (*CreateIndexStatement) String ¶
func (cis *CreateIndexStatement) String() string
func (*CreateIndexStatement) Type ¶
func (cis *CreateIndexStatement) Type() string
type CreateProcedureStatement ¶
type CreateProcedureStatement struct {
BaseNode
Name string
Parameters []*ProcedureParameter
Body *ProcedureBody
Language string // SQL, PLPGSQL, etc.
SecurityDefiner bool // SECURITY DEFINER vs INVOKER
Options map[string]string // Dialect-specific options
OrReplace bool // CREATE OR REPLACE
IfNotExists bool // IF NOT EXISTS
}
CreateProcedureStatement represents CREATE PROCEDURE
func (*CreateProcedureStatement) String ¶
func (cps *CreateProcedureStatement) String() string
func (*CreateProcedureStatement) Type ¶
func (cps *CreateProcedureStatement) Type() string
type CreateTableStatement ¶
type CreateTableStatement struct {
BaseNode
Table TableReference
Columns []*ColumnDefinition
Constraints []*TableConstraint
IfNotExists bool
}
CREATE TABLE Statement
func (*CreateTableStatement) String ¶
func (cts *CreateTableStatement) String() string
func (*CreateTableStatement) Type ¶
func (cts *CreateTableStatement) Type() string
type CreateTriggerStatement ¶
type CreateTriggerStatement struct {
BaseNode
TriggerName string // Trigger name
Timing string // BEFORE, AFTER, INSTEAD OF
Events []string // INSERT, UPDATE, DELETE
TableName TableReference // Table the trigger is on
ForEachRow bool // FOR EACH ROW (vs FOR EACH STATEMENT)
WhenCondition Expression // Optional WHEN condition
Body *ProcedureBody // Trigger body (BEGIN...END or single statement)
OrReplace bool // OR REPLACE (PostgreSQL)
IfNotExists bool // IF NOT EXISTS (MySQL)
Options map[string]string // Dialect-specific options
}
CreateTriggerStatement represents CREATE TRIGGER
func (*CreateTriggerStatement) String ¶
func (cts *CreateTriggerStatement) String() string
func (*CreateTriggerStatement) Type ¶
func (cts *CreateTriggerStatement) Type() string
type CreateViewStatement ¶
type CreateViewStatement struct {
BaseNode
OrReplace bool // CREATE OR REPLACE VIEW
Materialized bool // MATERIALIZED VIEW (PostgreSQL)
IfNotExists bool // IF NOT EXISTS
ViewName TableReference // View name (can have schema)
Columns []string // Optional column list
SelectStmt *SelectStatement // The SELECT query
WithCheck bool // WITH CHECK OPTION
Options map[string]string // Dialect-specific options (e.g., SECURITY DEFINER)
}
CreateViewStatement represents CREATE VIEW or CREATE MATERIALIZED VIEW
func (*CreateViewStatement) String ¶
func (cvs *CreateViewStatement) String() string
func (*CreateViewStatement) Type ¶
func (cvs *CreateViewStatement) Type() string
type CursorDecl ¶
type CursorDecl struct {
BaseNode
Name string
Query *SelectStatement
}
CursorDecl represents a cursor declaration
func (*CursorDecl) String ¶
func (cd *CursorDecl) String() string
func (*CursorDecl) Type ¶
func (cd *CursorDecl) Type() string
type DataTypeDefinition ¶
type DataTypeDefinition struct {
BaseNode
Name string // VARCHAR, INT, DECIMAL, etc.
Length int // For VARCHAR(255), CHAR(10), etc.
Precision int // For DECIMAL(10,2), NUMERIC(8,3)
Scale int // For DECIMAL(10,2), NUMERIC(8,3)
IsArray bool // For array types (PostgreSQL)
}
DataTypeDefinition represents a data type with optional size/precision
func (*DataTypeDefinition) String ¶
func (dtd *DataTypeDefinition) String() string
func (*DataTypeDefinition) Type ¶
func (dtd *DataTypeDefinition) Type() string
type DeallocateStatement ¶
DeallocateStatement represents DEALLOCATE cursor
func (*DeallocateStatement) String ¶
func (ds *DeallocateStatement) String() string
func (*DeallocateStatement) Type ¶
func (ds *DeallocateStatement) Type() string
type DeleteStatement ¶
type DeleteStatement struct {
BaseNode
From TableReference
Where Expression
OrderBy []*OrderByClause // MySQL/SQLite support ORDER BY in DELETE
Limit *LimitClause // MySQL/SQLite support LIMIT in DELETE
}
DELETE Statement
func (*DeleteStatement) String ¶
func (ds *DeleteStatement) String() string
func (*DeleteStatement) Type ¶
func (ds *DeleteStatement) Type() string
type DropStatement ¶
type DropStatement struct {
BaseNode
ObjectType string // TABLE, DATABASE, INDEX
ObjectName string
IfExists bool
Cascade bool
}
DROP Statement (TABLE, DATABASE, INDEX)
func (*DropStatement) String ¶
func (ds *DropStatement) String() string
func (*DropStatement) Type ¶
func (ds *DropStatement) Type() string
type ElseIfBlock ¶
type ElseIfBlock struct {
BaseNode
Condition Expression
Block []Statement
}
ElseIfBlock represents ELSEIF/ELSIF block
func (*ElseIfBlock) String ¶
func (eib *ElseIfBlock) String() string
func (*ElseIfBlock) Type ¶
func (eib *ElseIfBlock) Type() string
type ExceptionBlock ¶
type ExceptionBlock struct {
BaseNode
WhenClauses []*WhenExceptionClause // WHEN exception_name THEN ...
}
ExceptionBlock represents EXCEPTION...WHEN block (PostgreSQL/Oracle)
func (*ExceptionBlock) String ¶
func (eb *ExceptionBlock) String() string
func (*ExceptionBlock) Type ¶
func (eb *ExceptionBlock) Type() string
type ExistsExpression ¶
EXISTS Expression
func (*ExistsExpression) String ¶
func (ee *ExistsExpression) String() string
func (*ExistsExpression) Type ¶
func (ee *ExistsExpression) Type() string
type ExitStatement ¶
type ExitStatement struct {
BaseNode
Label string // Loop label to exit
Condition Expression // WHEN condition (PostgreSQL)
}
ExitStatement represents EXIT/BREAK (loop control)
func (*ExitStatement) String ¶
func (es *ExitStatement) String() string
func (*ExitStatement) Type ¶
func (es *ExitStatement) Type() string
type ExplainStatement ¶
type ExplainStatement struct {
BaseNode
Statement Statement // The statement to explain
Analyze bool // EXPLAIN ANALYZE
Format string // FORMAT (JSON, XML, TEXT, etc.)
Options map[string]string // Dialect-specific options
}
EXPLAIN Statement
func (*ExplainStatement) String ¶
func (es *ExplainStatement) String() string
func (*ExplainStatement) Type ¶
func (es *ExplainStatement) Type() string
type Expression ¶
type Expression interface {
Node
// contains filtered or unexported methods
}
type FetchStatement ¶
type FetchStatement struct {
BaseNode
Direction string // NEXT, PRIOR, FIRST, LAST, ABSOLUTE, RELATIVE (empty for simple FETCH)
Count int // For ABSOLUTE/RELATIVE n (0 means not specified)
CursorName string
Variables []string // INTO variables
}
FetchStatement represents FETCH cursor
func (*FetchStatement) String ¶
func (fs *FetchStatement) String() string
func (*FetchStatement) Type ¶
func (fs *FetchStatement) Type() string
type ForStatement ¶
type ForStatement struct {
BaseNode
Variable string
Start Expression
End Expression
Step Expression // Optional
Block []Statement
Label string // Loop label
IsReverse bool // FOR ... IN REVERSE (PostgreSQL)
}
ForStatement represents FOR loop
func (*ForStatement) String ¶
func (fs *ForStatement) String() string
func (*ForStatement) Type ¶
func (fs *ForStatement) Type() string
type ForeignKeyReference ¶
type ForeignKeyReference struct {
BaseNode
Table string
Columns []string
OnDelete string // CASCADE, SET NULL, etc.
OnUpdate string
}
Foreign Key Reference
func (*ForeignKeyReference) String ¶
func (fkr *ForeignKeyReference) String() string
func (*ForeignKeyReference) Type ¶
func (fkr *ForeignKeyReference) Type() string
type FrameBound ¶
type FrameBound struct {
BaseNode
BoundType string // UNBOUNDED, CURRENT, or expression
Direction string // PRECEDING or FOLLOWING
Offset Expression // For expression-based bounds
}
Frame Boundary (UNBOUNDED PRECEDING, CURRENT ROW, etc.)
func (*FrameBound) String ¶
func (fb *FrameBound) String() string
func (*FrameBound) Type ¶
func (fb *FrameBound) Type() string
type FromClause ¶
type FromClause struct {
BaseNode
Tables []TableReference
}
FROM Clause
func (*FromClause) String ¶
func (fc *FromClause) String() string
func (*FromClause) Type ¶
func (fc *FromClause) Type() string
type FunctionCall ¶
type FunctionCall struct {
BaseNode
Name string
Arguments []Expression
}
Function Call
func (*FunctionCall) String ¶
func (fc *FunctionCall) String() string
func (*FunctionCall) Type ¶
func (fc *FunctionCall) Type() string
type HandlerDeclaration ¶
type HandlerDeclaration struct {
BaseNode
HandlerType string // CONTINUE, EXIT, UNDO
Condition string // SQLEXCEPTION, SQLWARNING, NOT FOUND, SQLSTATE, etc.
Body []Statement // Handler body
}
HandlerDeclaration represents DECLARE...HANDLER (MySQL)
func (*HandlerDeclaration) String ¶
func (hd *HandlerDeclaration) String() string
func (*HandlerDeclaration) Type ¶
func (hd *HandlerDeclaration) Type() string
type IfStatement ¶
type IfStatement struct {
BaseNode
Condition Expression
ThenBlock []Statement
ElseIfList []*ElseIfBlock
ElseBlock []Statement
}
IfStatement represents IF...THEN...ELSE
func (*IfStatement) String ¶
func (is *IfStatement) String() string
func (*IfStatement) Type ¶
func (is *IfStatement) Type() string
type InExpression ¶
type InExpression struct {
BaseNode
Expression Expression
Values []Expression
Not bool
}
IN Expression
func (*InExpression) String ¶
func (ie *InExpression) String() string
func (*InExpression) Type ¶
func (ie *InExpression) Type() string
type InsertStatement ¶
type InsertStatement struct {
BaseNode
Table TableReference
Columns []string // Optional column list
Values [][]Expression // For INSERT ... VALUES
Select *SelectStatement // For INSERT ... SELECT
}
INSERT Statement
func (*InsertStatement) String ¶
func (is *InsertStatement) String() string
func (*InsertStatement) Type ¶
func (is *InsertStatement) Type() string
type JoinClause ¶
type JoinClause struct {
BaseNode
JoinType string // INNER, LEFT, RIGHT, FULL
Table TableReference
Condition Expression
}
JOIN Clause
func (*JoinClause) String ¶
func (jc *JoinClause) String() string
func (*JoinClause) Type ¶
func (jc *JoinClause) Type() string
type LimitClause ¶
LIMIT Clause
func (*LimitClause) String ¶
func (lc *LimitClause) String() string
func (*LimitClause) Type ¶
func (lc *LimitClause) Type() string
type LoopStatement ¶
LoopStatement represents LOOP...END LOOP
func (*LoopStatement) String ¶
func (ls *LoopStatement) String() string
func (*LoopStatement) Type ¶
func (ls *LoopStatement) Type() string
type MergeAction ¶
type MergeAction struct {
BaseNode
ActionType string // UPDATE, INSERT, DELETE
Columns []string // For UPDATE/INSERT
Values []Expression // For UPDATE/INSERT
}
MergeAction represents an action in a MERGE WHEN clause
func (*MergeAction) String ¶
func (ma *MergeAction) String() string
func (*MergeAction) Type ¶
func (ma *MergeAction) Type() string
type MergeStatement ¶
type MergeStatement struct {
BaseNode
TargetTable TableReference
SourceTable interface{} // Can be TableReference or SelectStatement
SourceAlias string // Alias for source
OnCondition Expression // MERGE condition
WhenMatched []*MergeWhenClause // WHEN MATCHED clauses (can have multiple)
WhenNotMatched []*MergeWhenClause // WHEN NOT MATCHED clauses
WhenNotMatchedBy []*MergeWhenClause // WHEN NOT MATCHED BY SOURCE (SQL Server)
}
MERGE Statement
func (*MergeStatement) String ¶
func (ms *MergeStatement) String() string
func (*MergeStatement) Type ¶
func (ms *MergeStatement) Type() string
type MergeWhenClause ¶
type MergeWhenClause struct {
BaseNode
Matched bool // true for WHEN MATCHED, false for WHEN NOT MATCHED
BySource bool // true for WHEN NOT MATCHED BY SOURCE (SQL Server)
Condition Expression // Optional AND condition
Action *MergeAction // The action to perform
}
MergeWhenClause represents a WHEN clause in MERGE
func (*MergeWhenClause) String ¶
func (mwc *MergeWhenClause) String() string
func (*MergeWhenClause) Type ¶
func (mwc *MergeWhenClause) Type() string
type OpenCursorStatement ¶
OpenCursorStatement represents OPEN cursor
func (*OpenCursorStatement) String ¶
func (ocs *OpenCursorStatement) String() string
func (*OpenCursorStatement) Type ¶
func (ocs *OpenCursorStatement) Type() string
type OrderByClause ¶
type OrderByClause struct {
BaseNode
Expression Expression
Direction string // ASC, DESC
}
ORDER BY Clause
func (*OrderByClause) String ¶
func (obc *OrderByClause) String() string
func (*OrderByClause) Type ¶
func (obc *OrderByClause) Type() string
type OverClause ¶
type OverClause struct {
BaseNode
PartitionBy []Expression
OrderBy []*OrderByClause
Frame *WindowFrame
}
OVER Clause for Window Functions
func (*OverClause) String ¶
func (oc *OverClause) String() string
func (*OverClause) Type ¶
func (oc *OverClause) Type() string
type ParseError ¶
ParseError represents errors that occur during SQL parsing. It provides detailed information about the location and nature of parsing errors.
func NewParseError ¶
func NewParseError(message, token string, line, column int) *ParseError
NewParseError creates a new ParseError with the given details.
func (*ParseError) Error ¶
func (e *ParseError) Error() string
Error returns a formatted error message implementing the error interface.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
func NewWithDialect ¶
func (*Parser) GetDialect ¶
GetDialect returns the dialect used by this parser
func (*Parser) GetParseMetrics ¶
func (*Parser) ParseStatement ¶
func (*Parser) SetDialect ¶
SetDialect sets the dialect for this parser
type ProcedureBody ¶
type ProcedureBody struct {
BaseNode
Statements []Statement // List of statements in the body
Variables []*VariableDecl // DECLARE variables
Cursors []*CursorDecl // DECLARE cursors
ExceptionBlock *ExceptionBlock // EXCEPTION block (PostgreSQL/Oracle)
}
ProcedureBody represents the body of a procedure/function
func (*ProcedureBody) String ¶
func (pb *ProcedureBody) String() string
func (*ProcedureBody) Type ¶
func (pb *ProcedureBody) Type() string
type ProcedureParameter ¶
type ProcedureParameter struct {
BaseNode
Name string
Mode string // IN, OUT, INOUT
DataType *DataTypeDefinition // Parameter type
Default Expression // Default value
IsVariadic bool // VARIADIC (PostgreSQL)
}
ProcedureParameter represents a parameter in a procedure/function
func (*ProcedureParameter) String ¶
func (pp *ProcedureParameter) String() string
func (*ProcedureParameter) Type ¶
func (pp *ProcedureParameter) Type() string
type RaiseStatement ¶
type RaiseStatement struct {
BaseNode
Level string // EXCEPTION, NOTICE, WARNING, INFO, LOG, DEBUG
Message Expression // Error message
Code string // Optional SQLSTATE code
}
RaiseStatement represents RAISE (PostgreSQL/Oracle)
func (*RaiseStatement) String ¶
func (rs *RaiseStatement) String() string
func (*RaiseStatement) Type ¶
func (rs *RaiseStatement) Type() string
type ReleaseSavepointStatement ¶
RELEASE SAVEPOINT Statement
func (*ReleaseSavepointStatement) String ¶
func (rss *ReleaseSavepointStatement) String() string
func (*ReleaseSavepointStatement) Type ¶
func (rss *ReleaseSavepointStatement) Type() string
type RepeatStatement ¶
type RepeatStatement struct {
BaseNode
Body []Statement // Loop body
Condition Expression // UNTIL condition
Label string // Optional loop label
}
RepeatStatement represents a REPEAT...UNTIL loop (MySQL)
func (*RepeatStatement) String ¶
func (rs *RepeatStatement) String() string
func (*RepeatStatement) Type ¶
func (rs *RepeatStatement) Type() string
type ReturnStatement ¶
type ReturnStatement struct {
BaseNode
Value Expression
}
ReturnStatement represents RETURN
func (*ReturnStatement) String ¶
func (rs *ReturnStatement) String() string
func (*ReturnStatement) Type ¶
func (rs *ReturnStatement) Type() string
type RollbackStatement ¶
type RollbackStatement struct {
BaseNode
Work bool // true if ROLLBACK WORK
ToSavepoint string // Optional: ROLLBACK TO SAVEPOINT name
}
ROLLBACK Statement
func (*RollbackStatement) String ¶
func (rs *RollbackStatement) String() string
func (*RollbackStatement) Type ¶
func (rs *RollbackStatement) Type() string
type SavepointStatement ¶
SAVEPOINT Statement
func (*SavepointStatement) String ¶
func (ss *SavepointStatement) String() string
func (*SavepointStatement) Type ¶
func (ss *SavepointStatement) Type() string
type SelectStatement ¶
type SelectStatement struct {
BaseNode
Distinct bool
Top *TopClause
Columns []Expression
From *FromClause
Joins []*JoinClause
Where Expression
GroupBy []Expression
Having Expression
OrderBy []*OrderByClause
Limit *LimitClause
}
SELECT Statement
func GetSelectStatement ¶
func GetSelectStatement() *SelectStatement
GetSelectStatement gets a pooled SelectStatement
func (*SelectStatement) String ¶
func (ss *SelectStatement) String() string
func (*SelectStatement) Type ¶
func (ss *SelectStatement) Type() string
type SetOperation ¶
type SetOperation struct {
BaseNode
Left Statement
Operator string // UNION, INTERSECT, EXCEPT
All bool // UNION ALL, etc.
Right Statement
}
Set Operation (UNION, INTERSECT, EXCEPT)
func (*SetOperation) String ¶
func (so *SetOperation) String() string
func (*SetOperation) Type ¶
func (so *SetOperation) Type() string
type SignalStatement ¶
type SignalStatement struct {
BaseNode
SqlState string // SQLSTATE value
Properties map[string]string // MESSAGE_TEXT, MYSQL_ERRNO, etc.
}
SignalStatement represents SIGNAL (MySQL)
func (*SignalStatement) String ¶
func (ss *SignalStatement) String() string
func (*SignalStatement) Type ¶
func (ss *SignalStatement) Type() string
type StarExpression ¶
SELECT * Expression
func (*StarExpression) String ¶
func (se *StarExpression) String() string
func (*StarExpression) Type ¶
func (se *StarExpression) Type() string
type SubqueryExpression ¶
type SubqueryExpression struct {
BaseNode
Query *SelectStatement
}
SubqueryExpression wraps a SelectStatement to make it usable as an Expression
func (*SubqueryExpression) String ¶
func (se *SubqueryExpression) String() string
func (*SubqueryExpression) Type ¶
func (se *SubqueryExpression) Type() string
type SyntaxError ¶
SyntaxError represents syntax errors in SQL statements.
func NewSyntaxError ¶
func NewSyntaxError(expected, found string, line, column int) *SyntaxError
NewSyntaxError creates a new SyntaxError with the given details.
func (*SyntaxError) Error ¶
func (e *SyntaxError) Error() string
Error returns a formatted syntax error message.
type TableConstraint ¶
type TableConstraint struct {
BaseNode
Name string // Optional constraint name
ConstraintType string // PRIMARY_KEY, FOREIGN_KEY, UNIQUE, CHECK
Columns []string
References *ForeignKeyReference // For FOREIGN KEY
Check Expression // For CHECK constraint
}
Table Constraint (PRIMARY KEY, FOREIGN KEY, UNIQUE, CHECK)
func (*TableConstraint) String ¶
func (tc *TableConstraint) String() string
func (*TableConstraint) Type ¶
func (tc *TableConstraint) Type() string
type TableReference ¶
type TableReference struct {
BaseNode
Schema string
Name string
Alias string
Subquery *SelectStatement // For derived tables: (SELECT ...) AS alias
}
Table Reference
func (*TableReference) String ¶
func (tr *TableReference) String() string
func (*TableReference) Type ¶
func (tr *TableReference) Type() string
type ThrowStatement ¶
type ThrowStatement struct {
BaseNode
ErrorNumber int // Error number
Message Expression // Error message
State int // Error state
}
ThrowStatement represents THROW (SQL Server)
func (*ThrowStatement) String ¶
func (ts *ThrowStatement) String() string
func (*ThrowStatement) Type ¶
func (ts *ThrowStatement) Type() string
type TryStatement ¶
type TryStatement struct {
BaseNode
TryBlock []Statement // Statements in TRY block
CatchBlock *CatchBlock // CATCH block
}
TryStatement represents TRY...CATCH block (SQL Server)
func (*TryStatement) String ¶
func (ts *TryStatement) String() string
func (*TryStatement) Type ¶
func (ts *TryStatement) Type() string
type UnaryExpression ¶
type UnaryExpression struct {
BaseNode
Operator string
Operand Expression
}
Unary Expression (NOT, etc.)
func (*UnaryExpression) String ¶
func (ue *UnaryExpression) String() string
func (*UnaryExpression) Type ¶
func (ue *UnaryExpression) Type() string
type UpdateStatement ¶
type UpdateStatement struct {
BaseNode
Table TableReference
Set []*Assignment
Where Expression
OrderBy []*OrderByClause // MySQL/SQLite support ORDER BY in UPDATE
Limit *LimitClause // MySQL/SQLite support LIMIT in UPDATE
}
UPDATE Statement
func (*UpdateStatement) String ¶
func (us *UpdateStatement) String() string
func (*UpdateStatement) Type ¶
func (us *UpdateStatement) Type() string
type VariableDecl ¶
type VariableDecl struct {
BaseNode
Name string
DataType *DataTypeDefinition
Default Expression
}
VariableDecl represents a variable declaration (DECLARE)
func (*VariableDecl) String ¶
func (vd *VariableDecl) String() string
func (*VariableDecl) Type ¶
func (vd *VariableDecl) Type() string
type WhenBlock ¶
type WhenBlock struct {
BaseNode
Condition Expression
Block []Statement
}
WhenBlock represents a WHEN block in CASE
type WhenClause ¶
type WhenClause struct {
BaseNode
Condition Expression
Result Expression
}
WHEN Clause in CASE expression
func (*WhenClause) String ¶
func (wc *WhenClause) String() string
func (*WhenClause) Type ¶
func (wc *WhenClause) Type() string
type WhenExceptionClause ¶
type WhileStatement ¶
type WhileStatement struct {
BaseNode
Condition Expression
Block []Statement
Label string // Loop label
}
WhileStatement represents WHILE loop
func (*WhileStatement) String ¶
func (ws *WhileStatement) String() string
func (*WhileStatement) Type ¶
func (ws *WhileStatement) Type() string
type WindowFrame ¶
type WindowFrame struct {
BaseNode
FrameType string // ROWS or RANGE
Start *FrameBound
End *FrameBound
}
Window Frame (ROWS/RANGE BETWEEN ... AND ...)
func (*WindowFrame) String ¶
func (wf *WindowFrame) String() string
func (*WindowFrame) Type ¶
func (wf *WindowFrame) Type() string
type WindowFunction ¶
type WindowFunction struct {
BaseNode
Function *FunctionCall // The window function (ROW_NUMBER, RANK, etc.)
OverClause *OverClause
}
Window Function
func (*WindowFunction) String ¶
func (wf *WindowFunction) String() string
func (*WindowFunction) Type ¶
func (wf *WindowFunction) Type() string
type WithStatement ¶
type WithStatement struct {
BaseNode
Recursive bool
CTEs []*CommonTableExpression
Query Statement // Main query (usually SelectStatement)
}
WITH Statement (contains CTEs and main query)
func (*WithStatement) String ¶
func (ws *WithStatement) String() string
func (*WithStatement) Type ¶
func (ws *WithStatement) Type() string