statement

package
v0.17.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 16, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BindExpr added in v0.17.0

func BindExpr(ctx *Context, tableName string, e expr.Expr) (err error)

Types

type AlterTableAddColumnStmt

type AlterTableAddColumnStmt struct {
	TableName        string
	ColumnConstraint *database.ColumnConstraint
	TableConstraints database.TableConstraints
}

func (*AlterTableAddColumnStmt) Bind added in v0.17.0

func (stmt *AlterTableAddColumnStmt) Bind(ctx *Context) error

func (*AlterTableAddColumnStmt) IsReadOnly

func (stmt *AlterTableAddColumnStmt) IsReadOnly() bool

IsReadOnly always returns false. It implements the Statement interface.

func (*AlterTableAddColumnStmt) Run

func (stmt *AlterTableAddColumnStmt) Run(ctx *Context) (Result, error)

Run runs the ALTER TABLE ADD COLUMN statement in the given transaction. It implements the Statement interface. The statement rebuilds the table.

type AlterTableRenameStmt

type AlterTableRenameStmt struct {
	TableName    string
	NewTableName string
}

AlterTableRenameStmt is a DSL that allows creating a full ALTER TABLE query.

func (*AlterTableRenameStmt) Bind added in v0.17.0

func (stmt *AlterTableRenameStmt) Bind(ctx *Context) error

func (*AlterTableRenameStmt) IsReadOnly

func (stmt *AlterTableRenameStmt) IsReadOnly() bool

IsReadOnly always returns false. It implements the Statement interface.

func (*AlterTableRenameStmt) Run

func (stmt *AlterTableRenameStmt) Run(ctx *Context) (Result, error)

Run runs the ALTER TABLE statement in the given transaction. It implements the Statement interface.

type Context

type Context struct {
	DB     *database.Database
	Conn   *database.Connection
	Tx     *database.Transaction
	Params []environment.Param
}

type CreateIndexStmt

type CreateIndexStmt struct {
	IfNotExists bool
	Info        database.IndexInfo
}

CreateIndexStmt represents a parsed CREATE INDEX statement.

func (*CreateIndexStmt) Bind added in v0.17.0

func (stmt *CreateIndexStmt) Bind(ctx *Context) error

func (*CreateIndexStmt) IsReadOnly

func (stmt *CreateIndexStmt) IsReadOnly() bool

IsReadOnly always returns false. It implements the Statement interface.

func (*CreateIndexStmt) Run

func (stmt *CreateIndexStmt) Run(ctx *Context) (Result, error)

Run runs the Create index statement in the given transaction. It implements the Statement interface.

type CreateSequenceStmt

type CreateSequenceStmt struct {
	IfNotExists bool
	Info        database.SequenceInfo
}

CreateSequenceStmt represents a parsed CREATE SEQUENCE statement.

func (*CreateSequenceStmt) Bind added in v0.17.0

func (stmt *CreateSequenceStmt) Bind(ctx *Context) error

func (*CreateSequenceStmt) IsReadOnly

func (stmt *CreateSequenceStmt) IsReadOnly() bool

IsReadOnly always returns false. It implements the Statement interface.

func (*CreateSequenceStmt) Run

func (stmt *CreateSequenceStmt) Run(ctx *Context) (Result, error)

Run the statement in the given transaction. It implements the Statement interface.

type CreateTableStmt

type CreateTableStmt struct {
	IfNotExists bool
	Info        database.TableInfo
}

CreateTableStmt represents a parsed CREATE TABLE statement.

func (*CreateTableStmt) Bind added in v0.17.0

func (stmt *CreateTableStmt) Bind(ctx *Context) error

func (*CreateTableStmt) IsReadOnly

func (stmt *CreateTableStmt) IsReadOnly() bool

IsReadOnly always returns false. It implements the Statement interface.

func (*CreateTableStmt) Run

func (stmt *CreateTableStmt) Run(ctx *Context) (Result, error)

Run runs the Create table statement in the given transaction. It implements the Statement interface.

type DeleteStmt

type DeleteStmt struct {
	TableName        string
	WhereExpr        expr.Expr
	OffsetExpr       expr.Expr
	OrderBy          *expr.Column
	LimitExpr        expr.Expr
	OrderByDirection scanner.Token
	// contains filtered or unexported fields
}

DeleteConfig holds DELETE configuration.

func NewDeleteStatement

func NewDeleteStatement() *DeleteStmt

func (*DeleteStmt) Bind added in v0.17.0

func (stmt *DeleteStmt) Bind(ctx *Context) error

func (*DeleteStmt) IsReadOnly

func (stmt *DeleteStmt) IsReadOnly() bool

func (*DeleteStmt) Prepare

func (stmt *DeleteStmt) Prepare(c *Context) (Statement, error)

func (*DeleteStmt) Run

func (stmt *DeleteStmt) Run(ctx *Context) (Result, error)

type DropIndexStmt

type DropIndexStmt struct {
	IndexName string
	IfExists  bool
}

DropIndexStmt is a DSL that allows creating a DROP INDEX query.

func (*DropIndexStmt) Bind added in v0.17.0

func (stmt *DropIndexStmt) Bind(ctx *Context) error

func (*DropIndexStmt) IsReadOnly

func (stmt *DropIndexStmt) IsReadOnly() bool

IsReadOnly always returns false. It implements the Statement interface.

func (*DropIndexStmt) Run

func (stmt *DropIndexStmt) Run(ctx *Context) (Result, error)

Run runs the DropIndex statement in the given transaction. It implements the Statement interface.

type DropSequenceStmt

type DropSequenceStmt struct {
	SequenceName string
	IfExists     bool
}

DropSequenceStmt is a DSL that allows creating a DROP INDEX query.

func (*DropSequenceStmt) Bind added in v0.17.0

func (stmt *DropSequenceStmt) Bind(ctx *Context) error

func (*DropSequenceStmt) IsReadOnly

func (stmt *DropSequenceStmt) IsReadOnly() bool

IsReadOnly always returns false. It implements the Statement interface.

func (*DropSequenceStmt) Run

func (stmt *DropSequenceStmt) Run(ctx *Context) (Result, error)

Run runs the DropSequence statement in the given transaction. It implements the Statement interface.

type DropTableStmt

type DropTableStmt struct {
	TableName string
	IfExists  bool
}

DropTableStmt is a DSL that allows creating a DROP TABLE query.

func (*DropTableStmt) Bind added in v0.17.0

func (stmt *DropTableStmt) Bind(ctx *Context) error

func (*DropTableStmt) IsReadOnly

func (stmt *DropTableStmt) IsReadOnly() bool

IsReadOnly always returns false. It implements the Statement interface.

func (*DropTableStmt) Run

func (stmt *DropTableStmt) Run(ctx *Context) (Result, error)

Run runs the DropTable statement in the given transaction. It implements the Statement interface.

type ExplainStmt

type ExplainStmt struct {
	Statement Preparer
}

ExplainStmt is a Statement that displays information about how a statement is going to be executed, without executing it.

func (*ExplainStmt) Bind added in v0.17.0

func (stmt *ExplainStmt) Bind(ctx *Context) error

func (*ExplainStmt) IsReadOnly

func (s *ExplainStmt) IsReadOnly() bool

IsReadOnly indicates that this statement doesn't write anything into the database.

func (*ExplainStmt) Run

func (stmt *ExplainStmt) Run(ctx *Context) (Result, error)

Run analyses the inner statement and displays its execution plan. If the statement is a stream, Optimize will be called prior to displaying all the operations. Explain currently only works on SELECT, UPDATE, INSERT and DELETE statements.

type InsertStmt

type InsertStmt struct {
	TableName  string
	Values     []expr.Expr
	Columns    []string
	SelectStmt Preparer
	Returning  []expr.Expr
	OnConflict database.OnConflictAction
	// contains filtered or unexported fields
}

InsertStmt holds INSERT configuration.

func NewInsertStatement

func NewInsertStatement() *InsertStmt

func (*InsertStmt) Bind added in v0.17.0

func (stmt *InsertStmt) Bind(ctx *Context) error

func (*InsertStmt) IsReadOnly

func (stmt *InsertStmt) IsReadOnly() bool

func (*InsertStmt) Prepare

func (stmt *InsertStmt) Prepare(c *Context) (Statement, error)

func (*InsertStmt) Run

func (stmt *InsertStmt) Run(ctx *Context) (Result, error)

type PreparedStreamStmt

type PreparedStreamStmt struct {
	Stream   *stream.Stream
	ReadOnly bool
}

PreparedStreamStmt is a PreparedStreamStmt using a Stream.

func (*PreparedStreamStmt) Bind added in v0.17.0

func (s *PreparedStreamStmt) Bind(ctx *Context) error

func (*PreparedStreamStmt) IsReadOnly

func (s *PreparedStreamStmt) IsReadOnly() bool

IsReadOnly reports whether the stream will modify the database or only read it.

func (*PreparedStreamStmt) Run

func (s *PreparedStreamStmt) Run(ctx *Context) (Result, error)

Run returns a result containing the stream. The stream will be executed by calling the Iterate method of the result.

func (*PreparedStreamStmt) String

func (s *PreparedStreamStmt) String() string

type Preparer

type Preparer interface {
	Prepare(*Context) (Statement, error)
}

type ReIndexStmt

type ReIndexStmt struct {
	TableOrIndexName string
	// contains filtered or unexported fields
}

ReIndexStmt is a DSL that allows creating a full REINDEX statement.

func NewReIndexStatement

func NewReIndexStatement() *ReIndexStmt

func (*ReIndexStmt) Bind added in v0.17.0

func (stmt *ReIndexStmt) Bind(ctx *Context) error

func (*ReIndexStmt) IsReadOnly

func (stmt *ReIndexStmt) IsReadOnly() bool

func (*ReIndexStmt) Prepare

func (stmt *ReIndexStmt) Prepare(ctx *Context) (Statement, error)

Prepare implements the Preparer interface.

func (*ReIndexStmt) Run

func (stmt *ReIndexStmt) Run(ctx *Context) (Result, error)

type Result

type Result struct {
	Result database.Result
	Tx     *database.Transaction
	// contains filtered or unexported fields
}

Result of a query.

func (*Result) Close

func (r *Result) Close() (err error)

Close the result stream. After closing the result, Stream is not supposed to be used. If the result stream was already closed, it returns an error.

func (*Result) Columns added in v0.17.0

func (r *Result) Columns() ([]string, error)

func (*Result) Iterate

func (r *Result) Iterate(fn func(r database.Row) error) (err error)

func (*Result) Iterator

func (r *Result) Iterator() (database.Iterator, error)

func (*Result) Skip added in v0.17.0

func (r *Result) Skip() (err error)

Skip iterates over the result and skips all rows. It is useful when you need the query to be executed but don't care about the results.

type SelectCoreStmt

type SelectCoreStmt struct {
	TableName       string
	Distinct        bool
	WhereExpr       expr.Expr
	GroupByExpr     expr.Expr
	ProjectionExprs []expr.Expr
}

func (*SelectCoreStmt) Bind added in v0.17.0

func (stmt *SelectCoreStmt) Bind(ctx *Context) error

func (*SelectCoreStmt) Prepare

func (stmt *SelectCoreStmt) Prepare(ctx *Context) (*StreamStmt, error)

type SelectStmt

type SelectStmt struct {
	CompoundSelect    []*SelectCoreStmt
	CompoundOperators []scanner.Token
	OrderBy           *expr.Column
	OrderByDirection  scanner.Token
	OffsetExpr        expr.Expr
	LimitExpr         expr.Expr
	// contains filtered or unexported fields
}

SelectStmt holds SELECT configuration.

func NewSelectStatement

func NewSelectStatement() *SelectStmt

func (*SelectStmt) Bind added in v0.17.0

func (stmt *SelectStmt) Bind(ctx *Context) error

func (*SelectStmt) IsReadOnly

func (stmt *SelectStmt) IsReadOnly() bool

func (*SelectStmt) Prepare

func (stmt *SelectStmt) Prepare(ctx *Context) (Statement, error)

Prepare implements the Preparer interface.

func (*SelectStmt) Run

func (stmt *SelectStmt) Run(ctx *Context) (Result, error)

type Statement

type Statement interface {
	Bind(*Context) error
	Run(*Context) (Result, error)
	IsReadOnly() bool
}

A Statement represents a unique action that can be executed against the database.

type StreamStmt

type StreamStmt struct {
	Stream   *stream.Stream
	ReadOnly bool
}

StreamStmt is a StreamStmt using a Stream.

func (*StreamStmt) Prepare

func (s *StreamStmt) Prepare(ctx *Context) (Statement, error)

Prepare implements the Preparer interface.

type StreamStmtResult added in v0.17.0

type StreamStmtResult struct {
	Stream  *stream.Stream
	Context *Context
}

StreamStmtResult iterates over a stream.

func (*StreamStmtResult) Iterator added in v0.17.0

func (s *StreamStmtResult) Iterator() (database.Iterator, error)

type UpdateSetPair

type UpdateSetPair struct {
	Column *expr.Column
	E      expr.Expr
}

type UpdateStmt

type UpdateStmt struct {
	TableName string

	// SetPairs is used along with the Set clause. It holds
	// each column with its corresponding value that
	// should be set in the row.
	SetPairs []UpdateSetPair

	WhereExpr expr.Expr
	// contains filtered or unexported fields
}

UpdateConfig holds UPDATE configuration.

func NewUpdateStatement

func NewUpdateStatement() *UpdateStmt

func (*UpdateStmt) Bind added in v0.17.0

func (stmt *UpdateStmt) Bind(ctx *Context) error

func (*UpdateStmt) IsReadOnly

func (stmt *UpdateStmt) IsReadOnly() bool

func (*UpdateStmt) Prepare

func (stmt *UpdateStmt) Prepare(c *Context) (Statement, error)

Prepare implements the Preparer interface.

func (*UpdateStmt) Run

func (stmt *UpdateStmt) Run(ctx *Context) (Result, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL