Documentation
¶
Index ¶
- Constants
- Variables
- func NewErrColumnNotExist(v any) error
- func NewErrColumnsNotEqual(v1, v2 int) error
- func NewErrDatabaseExist(v string) error
- func NewErrDatabaseNotExist(v string) error
- func NewErrExist(v any) error
- func NewErrNotEqual(v1, v2 any) error
- func NewErrNotExist(v any) error
- func NewErrNotImplemented(msg string) error
- func NewErrNotSupported(msg string) error
- func NewErrPreparedQueryNotExist(name string) error
- func NewErrTableExist(v string) error
- func NewErrTableNotExist(v string) error
- func WithConnDatabase(name string) func(*Conn)
- func WithConnTracer(t tracer.Context) func(*Conn)
- type Authenticator
- type BaseAuthenticator
- type BaseExecutor
- type BaseProtocolExecutor
- type BaseQueryExecutor
- func (executor *BaseQueryExecutor) Copy(*Conn, *query.Copy, *CopyStream) (message.Responses, error)
- func (executor *BaseQueryExecutor) CreateDatabase(*Conn, *query.CreateDatabase) (message.Responses, error)
- func (executor *BaseQueryExecutor) CreateIndex(*Conn, *query.CreateIndex) (message.Responses, error)
- func (executor *BaseQueryExecutor) CreateTable(*Conn, *query.CreateTable) (message.Responses, error)
- func (executor *BaseQueryExecutor) Delete(*Conn, *query.Delete) (message.Responses, error)
- func (executor *BaseQueryExecutor) DropDatabase(*Conn, *query.DropDatabase) (message.Responses, error)
- func (executor *BaseQueryExecutor) DropTable(*Conn, *query.DropTable) (message.Responses, error)
- func (executor *BaseQueryExecutor) Insert(*Conn, *query.Insert) (message.Responses, error)
- func (executor *BaseQueryExecutor) Select(*Conn, *query.Select) (message.Responses, error)
- func (executor *BaseQueryExecutor) Update(*Conn, *query.Update) (message.Responses, error)
- type BulkExecutor
- type Config
- type Conn
- type ConnOption
- type CopyStream
- type DDOExecutor
- type DMOExecutor
- type Executor
- type PreparedQuery
- type PreparedQueryMap
- type ProtocolHandler
- type QueryExecutor
- type Server
- type StatusHandler
Constants ¶
const ( // PackageName is the package name. PackageName = "go-postgresql" // DefaultPort is the default port for PostgreSQL protocol server. DefaultPort = 5432 )
const (
Version = ""
)
Variables ¶
var ErrExist = errors.New("exist")
ErrExist is returned when the specified object is exist.
var ErrNotEqual = errors.New("not equal")
ErrNotEqual is returned when the specified object is not equal.
var ErrNotExist = errors.New("not exist")
ErrNotExist is returned when the specified object is not exist.
var ErrNotImplemented = errors.New("not implemented")
ErrNotImplemented is returned when the operation is not implemented.
var ErrNotSupported = errors.New("not supported")
ErrNotSupported is returned when the operation is not supported.
Functions ¶
func NewErrColumnNotExist ¶ added in v0.9.1
NewErrColumnNotExist returns a new column not exist error.
func NewErrColumnsNotEqual ¶ added in v0.9.1
NewErrColumnsNotEqual returns a new columns not equal error.
func NewErrDatabaseExist ¶
NewErrDatabaseExist returns a new database exist error.
func NewErrDatabaseNotExist ¶
NewErrDatabaseNotExist returns a new database not exist error.
func NewErrNotEqual ¶ added in v0.9.1
NewErrNotEqual returns a new not equal error.
func NewErrNotExist ¶
NewErrNotExist returns a new not exist error.
func NewErrNotImplemented ¶
NewErrNotImplemented returns a new ErrNotImplemented error.
func NewErrNotSupported ¶
NewErrNotSupported returns a new ErrNotSupported error.
func NewErrPreparedQueryNotExist ¶ added in v0.9.1
NewErrPreparedQueryNotExist returns a new prepared query not exist error.
func NewErrTableExist ¶
NewErrTableExist returns a new table exist error.
func NewErrTableNotExist ¶
NewErrTableNotExist returns a new table not exist error.
func WithConnDatabase ¶
WithConnDatabase sets the database name.
func WithConnTracer ¶
WithConnDatabase sets the database name.
Types ¶
type Authenticator ¶
type Authenticator interface { // Authenticate handles the Start-up message and returns an Authentication or ErrorResponse message. Authenticate(*Conn, *message.Startup) (message.Response, error) }
Authenticator represents a frontend message authenticator.
type BaseAuthenticator ¶
type BaseAuthenticator struct { }
BaseAuthenticator represents a base frontend message authenticator.
func NewBaseAuthenticator ¶
func NewBaseAuthenticator() *BaseAuthenticator
NewBaseAuthenticator returns a base frontend message authenticator.
func (*BaseAuthenticator) Authenticate ¶
Authenticate authenticates the connection with the startup message.
type BaseExecutor ¶
type BaseExecutor struct { Authenticator ProtocolHandler QueryExecutor }
BaseExecutor represents a base frontend message executor.
func NewBaseExecutor ¶
func NewBaseExecutor() *BaseExecutor
NewBaseExecutor returns a base frontend message executor.
func (*BaseExecutor) SetAuthenticator ¶
func (executor *BaseExecutor) SetAuthenticator(at Authenticator)
SetAuthenticator sets a user authenticator.
func (*BaseExecutor) SetProtocolHandler ¶
func (executor *BaseExecutor) SetProtocolHandler(pe ProtocolHandler)
SetProtocolHandler sets a user protocol executor.
func (*BaseExecutor) SetQueryExecutor ¶
func (executor *BaseExecutor) SetQueryExecutor(qe QueryExecutor)
SetQueryExecutor sets a user query executor.
type BaseProtocolExecutor ¶
type BaseProtocolExecutor struct {
// contains filtered or unexported fields
}
BaseProtocolExecutor represents a base frontend message executor.
func NewBaseProtocolExecutor ¶
func NewBaseProtocolExecutor() *BaseProtocolExecutor
NewBaseProtocolExecutor returns a base frontend message executor.
func (*BaseProtocolExecutor) Authenticate ¶
func (executor *BaseProtocolExecutor) Authenticate(*Conn, *message.Startup) (message.Response, error)
Authenticate authenticates the connection with the startup message.
func (*BaseProtocolExecutor) BackendKeyData ¶
func (executor *BaseProtocolExecutor) BackendKeyData(*Conn) (message.Response, error)
BackendKeyData returns the backend key data.
func (*BaseProtocolExecutor) ParameterStatus ¶
func (executor *BaseProtocolExecutor) ParameterStatus(*Conn) (message.Response, error)
ParameterStatus returns the parameter status.
type BaseQueryExecutor ¶
type BaseQueryExecutor struct { }
BaseQueryExecutor represents a base query message executor.
func NewBaseQueryExecutor ¶
func NewBaseQueryExecutor() *BaseQueryExecutor
NewBaseQueryExecutor returns a base frontend message executor.
func (*BaseQueryExecutor) Copy ¶ added in v0.9.1
func (executor *BaseQueryExecutor) Copy(*Conn, *query.Copy, *CopyStream) (message.Responses, error)
Copy handles a COPY query.
func (*BaseQueryExecutor) CreateDatabase ¶
func (executor *BaseQueryExecutor) CreateDatabase(*Conn, *query.CreateDatabase) (message.Responses, error)
CreateDatabase handles a CREATE DATABASE query.
func (*BaseQueryExecutor) CreateIndex ¶
func (executor *BaseQueryExecutor) CreateIndex(*Conn, *query.CreateIndex) (message.Responses, error)
CreateIndex handles a CREATE INDEX query.
func (*BaseQueryExecutor) CreateTable ¶
func (executor *BaseQueryExecutor) CreateTable(*Conn, *query.CreateTable) (message.Responses, error)
CreateTable handles a CREATE TABLE query.
func (*BaseQueryExecutor) DropDatabase ¶
func (executor *BaseQueryExecutor) DropDatabase(*Conn, *query.DropDatabase) (message.Responses, error)
DropDatabase handles a DROP DATABASE query.
type BulkExecutor ¶ added in v0.9.1
type BulkExecutor interface { // Copy handles a COPY query. Copy(*Conn, *query.Copy, *CopyStream) (message.Responses, error) }
BulkExecutor defines a executor interface for bulk operations.
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config stores server configuration parammeters.
func NewDefaultConfig ¶
func NewDefaultConfig() *Config
NewDefaultConfig returns a default configuration instance.
type Conn ¶
type Conn struct { tracer.Context PreparedQueryMap // contains filtered or unexported fields }
Conn represents a connection of PostgreSQL binary protocol.
func NewConnWith ¶
func NewConnWith(c net.Conn, opts ...ConnOption) *Conn
NewConnWith returns a connection with a raw connection.
func (*Conn) DatabaseName ¶
DatabaseName returns the database name.
func (*Conn) SetDatabaseName ¶
SetDatabaseName sets the database name.
func (*Conn) SpanContext ¶
SpanContext returns the tracer span context of the connection.
type CopyStream ¶ added in v0.9.1
type CopyStream struct {
*message.MessageReader
}
CopyStream represents a copy stream.
func NewCopyStreamWithReader ¶ added in v0.9.1
func NewCopyStreamWithReader(reader *message.MessageReader) *CopyStream
NewCopyStreamWithReader returns a new copy stream with the specified reader.
func (*CopyStream) CopyData ¶ added in v0.9.1
func (stream *CopyStream) CopyData() (*message.CopyData, error)
CopyData returns a copy data message.
func (*CopyStream) Next ¶ added in v0.9.1
func (stream *CopyStream) Next() (bool, error)
Next returns true if the next message is available.
type DDOExecutor ¶
type DDOExecutor interface { // CreateDatabase handles a CREATE DATABASE query. CreateDatabase(*Conn, *query.CreateDatabase) (message.Responses, error) // CreateTable handles a CREATE TABLE query. CreateTable(*Conn, *query.CreateTable) (message.Responses, error) // CreateIndex handles a CREATE INDEX query. CreateIndex(*Conn, *query.CreateIndex) (message.Responses, error) // DropDatabase handles a DROP DATABASE query. DropDatabase(*Conn, *query.DropDatabase) (message.Responses, error) // DropIndex handles a DROP INDEX query. DropTable(*Conn, *query.DropTable) (message.Responses, error) }
DDOExecutor defines a executor interface for DDO (Data Definition Operations).
type DMOExecutor ¶
type DMOExecutor interface { // Insert handles a INSERT query. Insert(*Conn, *query.Insert) (message.Responses, error) // Select handles a SELECT query. Select(*Conn, *query.Select) (message.Responses, error) // Update handles a UPDATE query. Update(*Conn, *query.Update) (message.Responses, error) // Delete handles a DELETE query. Delete(*Conn, *query.Delete) (message.Responses, error) }
DMOExecutor defines a executor interface for DMO (Data Manipulation Operations).
type Executor ¶
type Executor interface { Authenticator ProtocolHandler QueryExecutor // SetAuthenticator sets a user authenticator. SetAuthenticator(Authenticator) // SetProtocolHandler sets a user protocol executor. SetProtocolHandler(ProtocolHandler) // SetQueryExecutor sets a user query executor. SetQueryExecutor(QueryExecutor) }
Executor represents a frontend message executor.
type PreparedQuery ¶ added in v0.9.1
PreparedQuery represents a prepared query.
type PreparedQueryMap ¶ added in v0.9.1
type PreparedQueryMap map[string]*PreparedQuery
PreparedQueryMap represents a prepared query map.
func NewPreparedQueryMap ¶ added in v0.9.1
func NewPreparedQueryMap() PreparedQueryMap
NewPreparedQueryMap returns a new prepared query map.
func (PreparedQueryMap) PreparedQuery ¶ added in v0.9.1
func (queries PreparedQueryMap) PreparedQuery(name string) (*PreparedQuery, error)
PreparedQuery returns a prepared query.
func (PreparedQueryMap) SetPreparedQuery ¶ added in v0.9.1
func (queries PreparedQueryMap) SetPreparedQuery(query *PreparedQuery) error
SetPreparedQuery sets a prepared query.
type ProtocolHandler ¶
type ProtocolHandler interface { StatusHandler }
ProtocolHandler represents a backend protocol message handler.
type QueryExecutor ¶
type QueryExecutor interface { DDOExecutor DMOExecutor BulkExecutor }
QueryExecutor represents a user query message executor.
type Server ¶
Server represents a PostgreSQL protocol server.
type StatusHandler ¶
type StatusHandler interface { // ParameterStatus returns the parameter status. ParameterStatus(*Conn) (message.Response, error) // BackendKeyData returns the backend key data. BackendKeyData(*Conn) (message.Response, error) }
StatusHandler represents a backend status message handler.