Documentation
¶
Index ¶
- Constants
- Variables
- func WithConnDatabase(name string) func(*conn)
- func WithConnID(v ConnID) func(*conn)
- func WithConnTracer(t tracer.Context) func(*conn)
- type AggregateFunction
- type AggregateResultSet
- type AlterDatabase
- type AlterTable
- type Begin
- type Commit
- type Conn
- type ConnID
- type ConnOption
- type Copy
- type CreateDatabase
- type CreateTable
- type DDOExecutor
- type DMOExecutor
- type Delete
- type DropDatabase
- type DropTable
- type ErrorHandler
- type Executor
- type Function
- type FunctionExecutor
- type Insert
- type Parser
- type Query
- type QueryExecutor
- type ResultSet
- type Rollback
- type Schema
- type Select
- type TCLExecutor
- type Truncate
- type Update
- type Use
- type Vacuum
Constants ¶
const ( EQ = query.EQ NEQ = query.NEQ LT = query.LT LE = query.LE GT = query.GT GE = query.GE IN = query.IN NIN = query.NIN )
const (
Version = "v1.3.5"
)
Variables ¶
var ErrEmptyQuery = parser.ErrEmptyQuery
ErrEmptyQuery is returned when the query is empty.
Functions ¶
func WithConnDatabase ¶ added in v1.3.1
func WithConnDatabase(name string) func(*conn)
WithConnDatabase sets a database name.
func WithConnID ¶ added in v1.3.1
func WithConnID(v ConnID) func(*conn)
WithConnID sets a connection ID.
func WithConnTracer ¶ added in v1.3.1
WithConnTracer sets a tracer context.
Types ¶
type AggregateFunction ¶ added in v1.3.2
type AggregateFunction = query.AggregateFunction
AggregateFunction represents an aggregate function.
type AggregateResultSet ¶ added in v1.3.2
type AggregateResultSet = query.AggregateResultSet
AggregateResultSet represents an aggregate result set.
type AlterDatabase ¶ added in v1.3.2
AlterDatabase represents a "ALTER DATABASE" statement interface.
type AlterTable ¶ added in v1.3.2
type AlterTable interface {
Query
TableName() string
AddColumn() (*query.Column, bool)
AddIndex() (*query.Index, bool)
DropColumn() (*query.Column, bool)
RenameColumns() (*query.Column, *query.Column, bool)
RenameTo() (*query.Table, bool)
}
AlterTable represents a "ALTER TABLE" statement interface.
type Begin ¶ added in v1.3.2
type Begin interface {
Query
}
Begin represents a "BEGIN" statement interface.
type Commit ¶ added in v1.3.2
type Commit interface {
Query
}
Commit represents a "COMMIT" statement interface.
type Conn ¶ added in v1.3.1
type Conn interface {
tracer.Context
// RemoteAddr returns the remote address.
RemoteAddr() net.Addr
// Close closes the connection.
Close() error
// SetDatabase sets a database name.
SetDatabase(db string)
// Database returns the database name.
Database() string
// Timestamp returns the timestamp.
Timestamp() time.Time
// UUID returns the UUID.
UUID() uuid.UUID
// ID returns the ID.
ID() ConnID
// SetSpanContext sets a span context.
SetSpanContext(ctx tracer.Context)
// SpanContext returns a span context.
SpanContext() tracer.Context
}
Conn represents a connection.
func NewConnWith ¶ added in v1.3.1
func NewConnWith(netConn net.Conn, opts ...ConnOption) Conn
NewConnWith returns a connection with a raw connection.
type ConnOption ¶ added in v1.3.1
type ConnOption = func(*conn)
ConnOption represents a connection option.
type Copy ¶ added in v1.3.3
type Copy interface {
Query
Columns() query.ColumnList
TableName() string
}
Copy represents a "COPY" statement interface.
type CreateDatabase ¶ added in v1.3.2
CreateDatabase represents a "CREATE DATABASE" statement interface.
type CreateTable ¶ added in v1.3.2
CreateTable represents a "CREATE TABLE" statement interface.
type DDOExecutor ¶ added in v1.3.1
type DDOExecutor interface {
// CreateDatabase handles a CREATE DATABASE query.
CreateDatabase(Conn, CreateDatabase) error
// CreateTable handles a CREATE TABLE query.
CreateTable(Conn, CreateTable) error
// AlterDatabase handles a ALTER DATABASE query.
AlterDatabase(Conn, AlterDatabase) error
// AlterTable handles a ALTER TABLE query.
AlterTable(Conn, AlterTable) error
// DropDatabase handles a DROP DATABASE query.
DropDatabase(Conn, DropDatabase) error
// DropIndex handles a DROP INDEX query.
DropTable(Conn, DropTable) error
}
DDOExecutor defines a executor interface for DDO (Data Definition Operations).
type DMOExecutor ¶ added in v1.3.1
type DMOExecutor interface {
// Insert handles a INSERT query.
Insert(Conn, Insert) error
// Select handles a SELECT query.
Select(Conn, Select) (ResultSet, error)
// Update handles a UPDATE query.
Update(Conn, Update) (ResultSet, error)
// Delete handles a DELETE query.
Delete(Conn, Delete) (ResultSet, error)
}
DMOExecutor defines a executor interface for DMO (Data Manipulation Operations).
type DropDatabase ¶ added in v1.3.2
DropTable represents a "DROP TABLE" statement interface.
type ErrorHandler ¶ added in v1.3.1
ErrorHandler represents a user error handler.
type Executor ¶ added in v1.3.1
type Executor interface {
TCLExecutor
QueryExecutor
ErrorHandler
}
Executor represents a frontend message executor.
type FunctionExecutor ¶ added in v1.3.2
type FunctionExecutor = query.FunctionExecutor
FunctionExecutor represents a function executor.
type Insert ¶ added in v1.3.2
type Insert interface {
Query
TableName() string
Columns() query.ColumnList
IsSelectAll() bool
}
Insert represents a "INSERT" statement interface.
type Parser ¶
type Parser interface {
// ParseString parses a SQL statement string and returns the query statements.
ParseString(string) ([]query.Statement, error)
}
Parser represents a parser interface for SQL.
type Query ¶ added in v1.3.2
type Query interface {
StatementType() query.StatementType
String() string
}
Query represents a common query interface.
type QueryExecutor ¶ added in v1.3.1
type QueryExecutor interface {
DDOExecutor
DMOExecutor
}
QueryExecutor represents a user query message executor.
type Rollback ¶ added in v1.3.2
type Rollback interface {
Query
}
Rollback represents a "ROLLBACK" statement interface.
type Select ¶ added in v1.3.2
type Select interface {
Query
IsSelectAll() bool
Selectors() query.SelectorList
From() query.TableList
Limit() *query.Limit
GroupBy() *query.GroupBy
OrderBy() *query.OrderBy
Where() *query.Condition
}
Select represents a "SELECT" statement interface.
type TCLExecutor ¶ added in v1.3.1
type TCLExecutor interface {
// Begin handles a BEGIN query.
Begin(Conn, Begin) error
// Commit handles a COMMIT query.
Commit(Conn, Commit) error
// Rollback handles a ROLLBACK query.
Rollback(Conn, Rollback) error
}
TCLExecutor defines a executor interface for TCL (Transaction Control Language).
type Update ¶ added in v1.3.2
type Update interface {
Query
TableName() string
Columns() query.ColumnList
Where() *query.Condition
}
Update represents a "UPDATE" statement interface.