sql

package
v1.3.5 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: Apache-2.0 Imports: 7 Imported by: 10

Documentation

Index

Constants

View Source
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
)
View Source
const (
	Version = "v1.3.5"
)

Variables

View Source
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

func WithConnTracer(t tracer.Context) func(*conn)

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

type AlterDatabase interface {
	Query
	DatabaseName() string
	RenameTo() *query.Database
}

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 ConnID added in v1.3.1

type ConnID uint64

ConnID represents a connection ID.

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

type CreateDatabase interface {
	Query
	DatabaseName() string
	IfNotExists() bool
}

CreateDatabase represents a "CREATE DATABASE" statement interface.

type CreateTable added in v1.3.2

type CreateTable interface {
	Query
	TableName() string
	Schema() *Schema
	IfNotExists() bool
}

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 Delete added in v1.3.2

type Delete interface {
	Query
	TableName() string
	Where() *query.Condition
}

Delete represents a "DELETE" statement interface.

type DropDatabase added in v1.3.2

type DropDatabase interface {
	Query
	DatabaseName() string
	IfExists() bool
}

DropTable represents a "DROP TABLE" statement interface.

type DropTable added in v1.3.2

type DropTable interface {
	Query
	Tables() query.TableList
	IfExists() bool
}

DropTable represents a "DROP TABLE" statement interface.

type ErrorHandler added in v1.3.1

type ErrorHandler interface {
	ParserError(Conn, string, error) error
}

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 Function added in v1.3.2

type Function = query.Function

Function represents a function.

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.

func NewParser

func NewParser() Parser

NewParser returns a new parser.

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 ResultSet added in v1.3.3

type ResultSet interface {
	// Bytes returns the message bytes.
	Bytes() ([]byte, error)
}

ResultSet represents a response resultset interface.

type Rollback added in v1.3.2

type Rollback interface {
	Query
}

Rollback represents a "ROLLBACK" statement interface.

type Schema added in v1.3.3

type Schema = query.Schema

Schema represents a schema.

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 Truncate added in v1.3.3

type Truncate interface {
	Query
	Tables() query.TableList
}

Truncate represents a "TRUNCATE" statement interface.

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.

type Use added in v1.3.5

type Use interface {
	Query
	DatabaseName() string
}

Use represents a "USE" statement interface.

type Vacuum added in v1.3.3

type Vacuum interface {
	Query
	TableName() string
}

Vacuum represents a "VACUUM" statement interface.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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