Documentation ¶
Index ¶
- Constants
- Variables
- func NewConnWith(netconn net.Conn, opts ...connOption) *conn
- func NewErrExist(v any) error
- func NewErrInvalidMessage(t Type) error
- func NewErrMessageNotSuppoted(t Type) error
- func NewErrNotExist(v any) error
- func WithConnDatabase(name string) func(*conn)
- func WithConnTLSConn(s *tls.Conn) func(*conn)
- func WithConnTracer(t tracer.Context) func(*conn)
- func WithRowFieldDataType(dt *DataType) func(*RowField)
- func WithRowFieldFormatCode(formatCode int16) func(*RowField)
- func WithRowFieldModifier(typeModifier int32) func(*RowField)
- func WithRowFieldNumber(number int16) func(*RowField)
- func WithRowFieldObjectID(dataTypeID int32) func(*RowField)
- func WithRowFieldSize(dataTypeSize int16) func(*RowField)
- func WithRowFieldTableID(tableID int32) func(*RowField)
- type BackendKeyData
- type Bind
- type BindComplete
- type BindParam
- type BindParams
- type Close
- type CloseComplete
- type CommandComplete
- func NewCommandComplete() *CommandComplete
- func NewCommandCompleteWith(tag string) (*CommandComplete, error)
- func NewCommitComplete() (*CommandComplete, error)
- func NewCopyCompleteWith(n int) (*CommandComplete, error)
- func NewDeleteCompleteWith(n int) (*CommandComplete, error)
- func NewEmptyComplete() (*CommandComplete, error)
- func NewInsertCompleteWith(n int) (*CommandComplete, error)
- func NewSelectCompleteWith(n int) (*CommandComplete, error)
- func NewUpdateCompleteWith(n int) (*CommandComplete, error)
- type Config
- type Conn
- type ConnID
- type CopyData
- type CopyDone
- type CopyFail
- type CopyFormat
- type CopyInResponse
- type DataRow
- type DataType
- type Describe
- type EmptyQueryResponse
- type ErrorResponse
- type ErrorType
- type Execute
- type ExtendedQueryHandler
- type Flush
- type FormatCode
- type Message
- type MessageConn
- type MessageHandler
- type MessageReader
- type NoData
- type ObjectID
- type ParameterDescription
- type ParameterStatus
- type Parse
- type ParseComplete
- type Password
- type PreparedType
- type Query
- type QueryHandler
- type Reader
- func (reader *Reader) PeekBytes(n int) ([]byte, error)
- func (reader *Reader) PeekInt32() (int32, error)
- func (reader *Reader) ReadByte() (byte, error)
- func (reader *Reader) ReadBytes(buf []byte) (int, error)
- func (reader *Reader) ReadBytesUntil(delim byte) ([]byte, error)
- func (reader *Reader) ReadInt16() (int16, error)
- func (reader *Reader) ReadInt32() (int32, error)
- func (reader *Reader) ReadString() (string, error)
- type ReadyForQuery
- type RequestMessage
- type Response
- type ResponseMessage
- type Responses
- func NewCommandCompleteResponsesWith(msg string) (Responses, error)
- func NewCopyCompleteResponsesWith(n int) (Responses, error)
- func NewDeleteCompleteResponsesWith(n int) (Responses, error)
- func NewEmptyCompleteResponses() (Responses, error)
- func NewInsertCompleteResponsesWith(n int) (Responses, error)
- func NewParameterStatusesWith(m map[string]string) (Responses, error)
- func NewResponses() Responses
- func NewResponsesWith(responses ...Response) Responses
- func NewSelectCompleteResponsesWith(n int) (Responses, error)
- func NewUpdateCompleteResponsesWith(n int) (Responses, error)
- type RowDescription
- type RowField
- type RowFieldOption
- type SSLRequest
- type SSLResponse
- type Server
- type SimpleQueryHandler
- type Startup
- type StartupHandler
- type Sync
- type TLSConn
- type Terminate
- type TransactionStatus
- type Type
- type Writer
- func (writer *Writer) AppendByte(c byte) error
- func (writer *Writer) AppendBytes(p []byte) error
- func (writer *Writer) AppendFloat32(v float32) error
- func (writer *Writer) AppendFloat64(v float64) error
- func (writer *Writer) AppendInt16(v int16) error
- func (writer *Writer) AppendInt32(v int32) error
- func (writer *Writer) AppendInt64(v int64) error
- func (writer *Writer) AppendInt8(v int8) error
- func (writer *Writer) AppendString(s string) error
- func (writer *Writer) AppendTerminator() error
- func (writer *Writer) Bytes() ([]byte, error)
Constants ¶
const ( AuthenticationKerberosV5Required = 2 AuthenticationCleartextPasswordRequired = 3 AuthenticationMD5PasswordRequired = 5 AuthenticationSCMCredentialRequired = 6 AuthenticationGSSRequired = 7 AuthenticationGSSContinueRequired = 8 AuthenticationSSPIRequired = 9 AuthenticationSASLRequired = 10 AuthenticationSASLContinueRequired = 11 AuthenticationSASLFinalRequired = 12 AuthenticationOk = 0 )
const ( // TextCopy represents a textual copy format. TextCopy = CopyFormat(0) // BinaryCopy represents a binary copy format. BinaryCopy = CopyFormat(1) )
const ( // MessageTypeSize is the size of the message type. MessageTypeSize = 1 // MessageLengthSize is the size of the message length. MessageLengthSize = 4 // MessageHeaderSize is the size of the message header. MessageHeaderSize = MessageTypeSize + MessageLengthSize )
const ( ApplicationName = "application_name" ClientEncoding = "client_encoding" ServerEncoding = "server_ encoding" DateStyle = "DateStyle" TimeZone = "TimeZone" IntervalStyle = "IntervalStyle" )
const ( DefaultTransactiOnReadOnly = "default_transaction_read_only" InHotStandby = "in_hot_standby" IsSuperuser = "is_superuser" OntegerDatetimes = "integer_datetimes" )
on/off parameters.
const ( ServerVersion = "#server_version" StandardConformingStrings = "#standard_conforming_strings" )
const ( // PreparedStatementByte represents a prepared statement. PreparedStatementByte = 'S' // PreparedPortalByte represents a prepared portal. PreparedPortalByte = 'P' )
const ( TransactionIdle = 'I' TransactionBlock = 'T' TransactionFailed = 'E' )
const ( SSLEnabled = 'S' SSLDisabled = 'N' )
const ( StartUpUser = "user" StartUpPassword = "password" StartUpDatabase = "database" StartUpApplicationName = "application_name" StartUpClientEncoding = "client_encoding" )
const (
DateStyleISO = "ISO, MDY.S"
)
const (
EncodingUTF8 = "UTF8"
)
const (
NoneMessage = 0x00
)
const SSLRequestCode = 80877103
SSLRequestCode represents a SSLRequest message code.
Variables ¶
var ErrExist = errors.New("exist")
ErrExist is returned when the specified object is exist.
var ErrInvalid = errors.New("invalid")
ErrInvalid is returned when the message is invalid.
var ErrNotExist = errors.New("not exist")
ErrNotExist is returned when the specified object is not exist.
var ErrNotSupported = errors.New("not supported")
ErrNotSupported is returned when the message is not supported.
Functions ¶
func NewConnWith ¶ added in v1.5.9
NewConnWith returns a connection with a raw connection.
func NewErrInvalidMessage ¶
NewErrInvalidMessage eturns a new message not supported error.
func NewErrMessageNotSuppoted ¶
NewErrMessageNotSuppoted returns a new message not supported error.
func NewErrNotExist ¶
NewErrNotExist returns a new not exist error.
func WithConnDatabase ¶ added in v1.6.2
func WithConnDatabase(name string) func(*conn)
WithConnDatabase sets a database name.
func WithConnTLSConn ¶ added in v1.6.2
WithConnTLSConn sets a TLS connection.
func WithConnTracer ¶ added in v1.6.2
WithConnTracer sets a tracer context.
func WithRowFieldDataType ¶
WithRowFieldDataType sets a data type.
func WithRowFieldFormatCode ¶
WithRowFieldFormatCode sets a format code.
func WithRowFieldModifier ¶
WithRowFieldModifier sets a type modifier.
func WithRowFieldNumber ¶
WithRowFieldNumber sets a number.
func WithRowFieldObjectID ¶
WithRowFieldObjectID sets a data type ID.
func WithRowFieldSize ¶
WithRowFieldSize sets a data type size.
func WithRowFieldTableID ¶
WithRowFieldTableID sets a table ID.
Types ¶
type BackendKeyData ¶
type BackendKeyData struct {
*ResponseMessage
}
BackendKeyData represents a parameter status response protocol.
func NewBackendKeyData ¶
func NewBackendKeyData() *BackendKeyData
NewBackendKeyData returns a parameter status response instance.
func NewBackendKeyDataWith ¶
func NewBackendKeyDataWith(processID int32, secretKey int32) (*BackendKeyData, error)
NewBackendKeyDataWith returns a parameter status response instance with the specified parameters.
type Bind ¶
type Bind struct { *RequestMessage PortalName string StatementName string Params BindParams }
Bind represents a bind protocol.
func NewBindWithReader ¶
func NewBindWithReader(reader *MessageReader) (*Bind, error)
NewBind returns a new bind protocol.
type BindComplete ¶
type BindComplete struct {
*ResponseMessage
}
BindComplete represents a bind complete protocol.
func NewBindComplete ¶
func NewBindComplete() *BindComplete
NewBindComplete returns a new bind complete message instance.
type BindParams ¶
type BindParams []*BindParam
BindParams represents bind parameters.
func (BindParams) FindBindParam ¶
func (params BindParams) FindBindParam(id string) (*BindParam, error)
FindBindParam returns a bind parameter with specified id.
type Close ¶
type Close struct { *RequestMessage Type PreparedType Name string }
Close represents a close protocol.
func NewCloseWithReader ¶
func NewCloseWithReader(reader *MessageReader) (*Close, error)
NewCloseWithReader returns a new close message with the specified reader.
type CloseComplete ¶
type CloseComplete struct {
*ResponseMessage
}
CloseComplete represents a close complete protocol.
func NewCloseComplete ¶
func NewCloseComplete() *CloseComplete
NewCloseComplete returns a new close complete message instance.
type CommandComplete ¶
type CommandComplete struct {
*ResponseMessage
}
CommandComplete represents a command complete protocol.
func NewCommandComplete ¶
func NewCommandComplete() *CommandComplete
NewCommandComplete returns a new command complete message instance.
func NewCommandCompleteWith ¶
func NewCommandCompleteWith(tag string) (*CommandComplete, error)
NewInsertCompleteWith returns a new command complete message for insert query.
func NewCommitComplete ¶
func NewCommitComplete() (*CommandComplete, error)
NewCommitComplete returns a new command complete message for commit query.
func NewCopyCompleteWith ¶
func NewCopyCompleteWith(n int) (*CommandComplete, error)
NewCopyCompleteWith returns a new command complete message for copy query.
func NewDeleteCompleteWith ¶
func NewDeleteCompleteWith(n int) (*CommandComplete, error)
NewDeleteCompleteWith returns a new command complete message for delete query.
func NewEmptyComplete ¶
func NewEmptyComplete() (*CommandComplete, error)
NewEmptyComplete returns a new command complete message for empty ping query.
func NewInsertCompleteWith ¶
func NewInsertCompleteWith(n int) (*CommandComplete, error)
NewInsertCompleteWith returns a new command complete message for insert query.
func NewSelectCompleteWith ¶
func NewSelectCompleteWith(n int) (*CommandComplete, error)
NewSelectCompleteWith returns a new command complete message for select query.
func NewUpdateCompleteWith ¶
func NewUpdateCompleteWith(n int) (*CommandComplete, error)
NewUpdateCompleteWith returns a new command complete message for update query.
type Config ¶ added in v1.5.9
type Config interface { tls.CertConfig // SetProuctName sets a product name to the configuration. SetProductName(v string) // SetProductVersion sets a product version to the configuration. SetProductVersion(v string) // ProductName returns the product name from the configuration. ProductName() string // ProductVersion returns the product version from the configuration. ProductVersion() string // SetAddress sets a listen address to the configuration. SetAddress(addr string) // SetPort sets a listen port to the configuration. SetPort(port int) // Address returns a listen address from the configuration. Address() string // Port returns a listen port from the configuration. Port() int }
Config represents a server configuration.
func NewDefaultConfig ¶ added in v1.5.9
func NewDefaultConfig() Config
NewDefaultConfig returns a default configuration instance.
type Conn ¶ added in v1.5.9
type Conn interface { net.Conn MessageConn TLSConn }
Conn represents a connection.
type CopyData ¶
type CopyData struct { *RequestMessage Data []string }
CopyData represents a copy data protocol.
func NewCopyDataWithReader ¶
func NewCopyDataWithReader(reader *MessageReader) (*CopyData, error)
NewCopyDataWithReader returns a new copy data message with the specified reader.
type CopyDone ¶
type CopyDone struct {
*RequestMessage
}
CopyDone represents a copy done protocol.
func NewCopyDoneWithReader ¶
func NewCopyDoneWithReader(reader *MessageReader) (*CopyDone, error)
NewCopyDataWithReader returns a new copy data message with the specified reader.
type CopyFail ¶
CopyFail represents a copy fail protocol.
func NewCopyFailWithReader ¶
NewCopyFailWithReader returns a new copy fail message with the specified reader.
type CopyInResponse ¶
type CopyInResponse struct { *ResponseMessage // contains filtered or unexported fields }
CopyInResponse represents a command complete protocol.
func NewCopyInResponseWith ¶
func NewCopyInResponseWith(fmt CopyFormat) *CopyInResponse
NewCopyInResponse returns a new command complete message instance.
func (*CopyInResponse) AppendFormatCode ¶
func (msg *CopyInResponse) AppendFormatCode(formatCode int16)
AppendFormatCode appends a format code.
func (*CopyInResponse) Bytes ¶
func (msg *CopyInResponse) Bytes() ([]byte, error)
Bytes appends a length of the message content bytes, and returns the message bytes.
type DataRow ¶
type DataRow struct { *ResponseMessage Data []any }
DataRow represents a data row protocol.
func (*DataRow) AppendData ¶
AppendData appends a column value to the data row protocol.
type Describe ¶
type Describe struct { *RequestMessage Type PreparedType Name string }
Describe represents a describe protocol.
func NewDescribeWithReader ¶
func NewDescribeWithReader(reader *MessageReader) (*Describe, error)
NewDescribeWithReader returns a new describe message with the specified reader.
type EmptyQueryResponse ¶
type EmptyQueryResponse struct {
*ResponseMessage
}
EmptyQueryResponse represents an empty query response protocol.
func NewEmptyQueryResponse ¶
func NewEmptyQueryResponse() *EmptyQueryResponse
NewEmptyQueryResponse returns an empty query response message instance.
type ErrorResponse ¶
type ErrorResponse struct {
*ResponseMessage
}
ErrorResponse represents an error response protocol.
func NewErrorResponse ¶
func NewErrorResponse() *ErrorResponse
NewErrorResponse returns a new error response instance.
func NewErrorResponseWith ¶
func NewErrorResponseWith(err error) (*ErrorResponse, error)
NewErrorResponseWith returns a new error response instance with the specified error.
func (*ErrorResponse) AddCode ¶
func (msg *ErrorResponse) AddCode(code int32) error
AddCode adds an error code to the error response.
func (*ErrorResponse) AddError ¶
func (msg *ErrorResponse) AddError(err error) error
AddError adds an error message to the error response.
func (*ErrorResponse) AppendField ¶
func (msg *ErrorResponse) AppendField(t ErrorType, v string) error
AppendField appends an error field to the error response.
func (*ErrorResponse) Bytes ¶
func (msg *ErrorResponse) Bytes() ([]byte, error)
Bytes returns the message bytes after adding a null terminator.
type ErrorType ¶
type ErrorType byte
ErrorType represents a error response type.
const ( SeverityError ErrorType = 'S' CodeError ErrorType = 'C' MessageError ErrorType = 'M' DetailError ErrorType = 'D' HintError ErrorType = 'H' PositionError ErrorType = 'P' InternalPositionError ErrorType = 'p' InternalQueryError ErrorType = 'q' WhereError ErrorType = 'W' SchemaError ErrorType = 's' TableError ErrorType = 't' ColumnError ErrorType = 'c' DataTypeNameError ErrorType = 'd' ConstraintError ErrorType = 'n' FileError ErrorType = 'F' LineError ErrorType = 'L' RoutineError ErrorType = 'R' )
type Execute ¶
type Execute struct { *RequestMessage PortalName string MaxRows int32 }
Execute represents an execute protocol.
func NewExecuteWithReader ¶
func NewExecuteWithReader(reader *MessageReader) (*Execute, error)
NewExecute returns a new execute protocol.
type ExtendedQueryHandler ¶ added in v1.5.9
type ExtendedQueryHandler interface { // Prepare handles a parse Parse(Conn, *Parse) (Responses, error) // Bind handles a bind Bind(Conn, *Bind) (Responses, error) // Describe handles a describe Describe(Conn, *Describe) (Responses, error) // Execute handles a execute Execute(Conn, *Execute) (Responses, error) // Close handles a close Close(Conn, *Close) (Responses, error) // Sync handles a sync Sync(Conn, *Sync) (Responses, error) // Flush handles a flush Flush(Conn, *Flush) (Responses, error) }
ExtendedQueryHandler defines a executor interface for extended query operations.
type Flush ¶
type Flush struct {
*RequestMessage
}
Flush represents a flush protocol.
func NewFlushWithReader ¶
func NewFlushWithReader(reader *MessageReader) (*Flush, error)
NewFlush returns a new flush protocol.
type FormatCode ¶
type FormatCode = system.FormatCode
FormatCode represents a format code.
const ( // TextFormat represents a text format code. TextFormat FormatCode = system.TextFormat // BinaryFormat represents a binary format code. BinaryFormat FormatCode = system.BinaryFormat )
type Message ¶
type Message struct { *MessageReader Type Type Length int32 }
Message represents a message of PostgreSQL packet.
func NewMessageWithReader ¶
func NewMessageWithReader(reader *MessageReader) (*Message, error)
NewMessageWithReader returns a new message with the specified reader.
func (*Message) MessageDataLength ¶
MessageLength returns a message data length without the message header.
func (*Message) MessageLength ¶
MessageLength returns a message length.
func (*Message) MessageType ¶
MessageType returns a message type.
func (*Message) ReadMessageData ¶
ReadMessageData reads all message data.
type MessageConn ¶ added in v1.5.9
type MessageConn interface { // MessageReader returns a message reader. MessageReader() *MessageReader // ResponseMessage sends a response ResponseMessage(resMsg Response) error // ResponseMessages sends response messages. ResponseMessages(resMsgs Responses) error // ResponseError sends an error response. ResponseError(err error) error // SkipMessage skips a SkipMessage() error // ReadyForMessage sends a ready for ReadyForMessage(status TransactionStatus) error }
MessageConn represents a message connection.
type MessageHandler ¶ added in v1.5.9
type MessageHandler interface { StartupHandler QueryHandler }
MessageHandler represents a message handler.
type MessageReader ¶
func NewMessageReaderWith ¶
func NewMessageReaderWith(reader io.Reader) *MessageReader
NewMessageReader returns a new message reader.
func (*MessageReader) IsPeekType ¶
func (reader *MessageReader) IsPeekType(t Type) (bool, error)
IsPeekType returns true whether the peeked message type is the specified type.
func (*MessageReader) PeekType ¶
func (reader *MessageReader) PeekType() (Type, error)
PeekType peeks a message type.
func (*MessageReader) ReadLength ¶
func (reader *MessageReader) ReadLength() (int32, error)
ReadLength reads a message length.
func (*MessageReader) ReadType ¶
func (reader *MessageReader) ReadType() (Type, error)
ReadType reads a message type.
type ParameterDescription ¶
type ParameterDescription struct {
*ResponseMessage
}
ParameterDescription represents a parameter description response protocol.
func NewParameterDescription ¶
func NewParameterDescription() *ParameterDescription
NewParameterDescription returns a parameter description response instance.
func NewParameterDescriptionWith ¶
func NewParameterDescriptionWith(objectIDs ...ObjectID) (*ParameterDescription, error)
NewParameterDescriptionWith returns a parameter description response instance with the specified parameters.
type ParameterStatus ¶
type ParameterStatus struct {
*ResponseMessage
}
ParameterStatus represents a parameter status response protocol.
func NewParameterStatus ¶
func NewParameterStatus() *ParameterStatus
NewParameterStatus returns a parameter status response instance.
func NewParameterStatusWith ¶
func NewParameterStatusWith(name string, value string) (*ParameterStatus, error)
NewParameterStatusWith returns a parameter status response instance with the specified parameter status.
func (*ParameterStatus) AppendParameters ¶
func (msg *ParameterStatus) AppendParameters(s ...string) error
AppendParameters appends the specified parameters.
type Parse ¶
type Parse struct { *RequestMessage Name string Query string NumDataTypes int16 DataTypes []int32 }
Parse represents a parse protocol.
func NewParseWithReader ¶
func NewParseWithReader(reader *MessageReader) (*Parse, error)
NewParseWithReader returns a new parse message with the specified reader.
type ParseComplete ¶
type ParseComplete struct {
*ResponseMessage
}
ParseComplete represents a parser complete protocol.
func NewParseComplete ¶
func NewParseComplete() *ParseComplete
NewParseComplete returns a parser complete instance.
type Password ¶
type Password struct { *RequestMessage Password string }
Password represents a password protocol.
func NewPasswordWithReader ¶
func NewPasswordWithReader(reader *MessageReader) (*Password, error)
NewPasswordWithReader returns a new password protocol.
type PreparedType ¶
type PreparedType int
PreparedType represents a prepared type.
const ( // PreparedStatement represents a prepared statement. PreparedStatement PreparedType = iota // PreparedPortal represents a prepared portal. PreparedPortal )
func NewPreparedTypeWithByte ¶
func NewPreparedTypeWithByte(bt byte) (PreparedType, error)
NewPreparedTypeWithByte returns a new prepared type with the specified byte.
type Query ¶
type Query struct { *RequestMessage Query string BindParams }
Query represents a parse protocol.
func NewQueryWith ¶
NewQueryWith returns a new query message with specified parameters.
func NewQueryWithReader ¶
func NewQueryWithReader(reader *MessageReader) (*Query, error)
NewQueryWithReader returns a new query message with specified reader.
type QueryHandler ¶ added in v1.5.9
type QueryHandler interface { SimpleQueryHandler ExtendedQueryHandler }
QueryHandler represents a query handler.
type Reader ¶
Reader represents a message reader.
func NewReaderWith ¶
NewReader returns a new message reader.
func (*Reader) ReadString ¶
ReadString reads a string.
type ReadyForQuery ¶
type ReadyForQuery struct {
*ResponseMessage
}
ReadyForQuery represents a ready for query protocol.
func NewReadyForQuery ¶
func NewReadyForQuery() *ReadyForQuery
NewReadyForQuery returns a new ready for query message instance.
func NewReadyForQueryWith ¶
func NewReadyForQueryWith(s TransactionStatus) (*ReadyForQuery, error)
NewReadyForQueryWith returns a new error response instance with the specified error.
type RequestMessage ¶
type RequestMessage struct {
*Message
}
RequestMessage represents a frontend request.
func NewRequestMessageWithReader ¶
func NewRequestMessageWithReader(reader *MessageReader) (*RequestMessage, error)
NewRequestMessageWithReader returns a new request message with the specified reader.
type Response ¶
type Response interface { // Type returns the message type. Type() Type // Bytes returns the message bytes. Bytes() ([]byte, error) }
Response represents a backend response message interface.
type ResponseMessage ¶
type ResponseMessage struct { *Writer // contains filtered or unexported fields }
ResponseMessage represents a backend response instance.
func NewAuthenticationCleartextPassword ¶
func NewAuthenticationCleartextPassword() (*ResponseMessage, error)
NewAuthenticationCleartextPassword returns a new AuthenticationCleartextPassword protocol.
func NewAuthenticationMD5Password ¶
func NewAuthenticationMD5Password(salt []byte) (*ResponseMessage, error)
NewAuthenticationMD5Password returns a new AuthenticationMD5Password protocol.
func NewAuthenticationOk ¶
func NewAuthenticationOk() (*ResponseMessage, error)
NewAuthenticationOk returns a new AuthenticationOk protocol.
func NewResponseMessage ¶
func NewResponseMessage() *ResponseMessage
NewResponseMessage returns a new request message instance.
func NewResponseMessageWith ¶
func NewResponseMessageWith(t Type) *ResponseMessage
NewResponseMessageWith returns a new response message with the specified message type.
func (*ResponseMessage) Bytes ¶
func (msg *ResponseMessage) Bytes() ([]byte, error)
Bytes appends a length of the message content bytes, and returns the message bytes.
func (*ResponseMessage) SetType ¶
func (msg *ResponseMessage) SetType(t Type)
SetType sets a message type.
func (*ResponseMessage) Type ¶
func (msg *ResponseMessage) Type() Type
Type returns the message type.
type Responses ¶
type Responses []Response
Responses represents a list of response.
func NewCommandCompleteResponsesWith ¶
NewCommandCompleteResponsesWith returns a new responses with the specified protocol.
func NewCopyCompleteResponsesWith ¶
NewCopyCompleteResponsesWith returns a new responses with the specified protocol.
func NewDeleteCompleteResponsesWith ¶
NewDeleteCompleteResponsesWith returns a new responses with the specified protocol.
func NewEmptyCompleteResponses ¶
NewEmptyCompleteResponses returns a new responses with the specified protocol.
func NewInsertCompleteResponsesWith ¶
NewInsertCompleteResponsesWith returns a new responses with the specified protocol.
func NewParameterStatusesWith ¶
NewParameterStatusesWith returns parameter status response instances with the specified parameter statuses.
func NewResponsesWith ¶
NewResponsesWith returns a new responses with the specified responses.
func NewSelectCompleteResponsesWith ¶
NewSelectCompleteResponsesWith returns a new responses with the specified protocol.
func NewUpdateCompleteResponsesWith ¶
NewUpdateCompleteResponsesWith returns a new responses with the specified protocol.
func (Responses) HasErrorResponse ¶
HasErrorResponse returns true whether this responses has an error response.
type RowDescription ¶
type RowDescription struct { *ResponseMessage // contains filtered or unexported fields }
RowDescription represents a row description protocol.
func NewRowDescription ¶
func NewRowDescription() *RowDescription
NewRowDescription returns a new row description message instance.
func (*RowDescription) AppendField ¶
func (msg *RowDescription) AppendField(field *RowField)
AppendField appends a field to the protocol.
func (*RowDescription) Bytes ¶
func (msg *RowDescription) Bytes() ([]byte, error)
Bytes appends a length of the message content bytes, and returns the message bytes.
func (*RowDescription) Field ¶
func (msg *RowDescription) Field(n int) *RowField
Field returns a field at the specified index.
type RowField ¶
type RowField struct { Name string TableID int32 Number int16 ObjectID int32 DataTypeSize int16 TypeModifier int32 FormatCode int16 }
RowField represents a row description field.
func NewRowFieldWith ¶
func NewRowFieldWith(name string, opts ...RowFieldOption) *RowField
NewRowField returns a new row description field.
func (*RowField) WirteBytes ¶
WirteBytes appends a row field elements.
type RowFieldOption ¶
type RowFieldOption = func(*RowField)
RowFieldOption represents a row description field option.
type SSLRequest ¶
type SSLRequest struct {
RequestCode int32
}
SSLRequest represents a SSLRequest protocol.
func NewSSLRequestWithReader ¶
func NewSSLRequestWithReader(reader *MessageReader) (*SSLRequest, error)
NewSSLRequestWithReader returns a new SSLRequest message with the specified reader.
type SSLResponse ¶
type SSLResponse struct {
Enabled byte
}
SSLResponse represents a SSLResponse protocol.
func NewSSLResponseWith ¶
func NewSSLResponseWith(enabled rune) *SSLResponse
NewSSLResponse returns a new SSLResponse protocol.
func (*SSLResponse) Bytes ¶
func (msg *SSLResponse) Bytes() ([]byte, error)
Bytes returns a byte array of the protocol.
type Server ¶ added in v1.5.9
type Server interface { tracer.Tracer Config auth.Manager SetMessageHandler(MessageHandler) // SetTracer sets a tracing tracer. SetTracer(tracer.Tracer) // Start starts the server. Start() error // Stop stops the server. Stop() error }
Server represents a PostgreSQL protocol server.
type SimpleQueryHandler ¶ added in v1.5.9
type SimpleQueryHandler interface { // Query handles a query Query(Conn, *Query) (Responses, error) }
SimpleQueryHandler defines a executor interface for simple query operations.
type Startup ¶
type Startup struct { MajorVersion int MinorVersion int MessageLength int32 Parameters map[string]string }
Startup represents a startup protocol.
func NewStartupWithReader ¶
func NewStartupWithReader(reader *MessageReader) (*Startup, error)
NewStartupWithReader returns a new startup message with the specified reader.
func (*Startup) ApplicationName ¶
ApplicationName returns the application name.
func (*Startup) ClientEncoding ¶
ClientEncoding returns the client encoding.
type StartupHandler ¶ added in v1.5.9
type StartupHandler interface { // ParameterStatuses returns the parameter statuses. ParameterStatuses(Conn) (Responses, error) // BackendKeyData returns the backend key data. BackendKeyData(Conn) (Response, error) }
StartupHandler represents a start-up message handler.
type Sync ¶
type Sync struct {
*RequestMessage
}
Sync represents a sync protocol.
func NewSyncWithReader ¶
func NewSyncWithReader(reader *MessageReader) (*Sync, error)
NewSync returns a new sync protocol.
type TLSConn ¶ added in v1.5.9
type TLSConn interface { // IsTLSConnection return true if the connection is enabled TLS. IsTLSConnection() bool // TLSConn returns a TLS connection. TLSConn() *tls.Conn }
TLSConn represents a TLS connection.
type Terminate ¶
type Terminate struct {
*RequestMessage
}
Terminate represents a terminate protocol.
func NewTerminateWithReader ¶
func NewTerminateWithReader(reader *MessageReader) (*Terminate, error)
NewTerminate returns a new terminate protocol.
type TransactionStatus ¶
type TransactionStatus = byte
TransactionStatus represents a transaction status.
type Type ¶
type Type byte
Type represents a message type.
const ( BindMessage Type = 'B' CancelRequestMessage Type = ' ' // Int32(16) CloseMessage Type = 'C' CopyFailMessage Type = 'f' DescribeMessage Type = 'D' ExecuteMessage Type = 'E' FlushMessage Type = 'H' FunctionCallMessage Type = 'F' GSSENCRequestMessage Type = ' ' // Int32(8) GSSResponseMessage Type = 'p' ParseMessage Type = 'P' PasswordMessage Type = 'p' QueryMessage Type = 'Q' SASLInitialResponseMessage Type = 'p' SASLResponseMessage Type = 'p' SSLRequestMessage Type = ' ' // Int32(8) SSLResponseMessage Type = ' ' StartupMessage Type = ' ' // Int32 SyncMessage Type = 'S' TerminateMessage Type = 'X' )
Frontend (F).
const ( AuthenticationOkMessage Type = 'R' AuthenticationKerberosV5Message Type = 'R' AuthenticationCleartextPasswordMessage Type = 'R' AuthenticationMD5PasswordMessage Type = 'R' AuthenticationGSSMessage Type = 'R' AuthenticationSSPIMessage Type = 'R' AuthenticationSASLMessage Type = 'R' AuthenticationSASLContinueMessage Type = 'R' AuthenticationSASLFinalMessage Type = 'R' BackendKeyDataMessage Type = 'K' BindCompleteMessage Type = '2' CloseCompleteMessage Type = '3' CommandCompleteMessage Type = 'C' CopyInResponseMessage Type = 'G' CopyOutResponseMessage Type = 'H' CopyBothResponseMessage Type = 'W' DataRowMessage Type = 'D' EmptyQueryResponseMessage Type = 'I' ErrorResponseMessage Type = 'E' FunctionCallResponseMessage Type = 'V' NegotiateProtocolVersionMessage Type = 'v' NoDataMessage Type = 'n' NoticeResponseMessage Type = 'N' NotificationResponseMessage Type = 'A' ParameterDescriptionMessage Type = 't' ParameterStatusMessage Type = 'S' ParseCompleteMessage Type = '1' PortalSuspendedMessage Type = 's' ReadyForQueryMessage Type = 'Z' RowDescriptionMessage Type = 'T' )
Backend (B).
type Writer ¶
Writer represents a message writer.
func (*Writer) AppendByte ¶
AppendByte appends the specified byte.
func (*Writer) AppendBytes ¶
AppendBytes appends the specified bytes.
func (*Writer) AppendFloat32 ¶
AppendFloat32 appends the specified float32 value.
func (*Writer) AppendFloat64 ¶
AppendFloat64 appends the specified float64 value.
func (*Writer) AppendInt16 ¶
AppendInt16 appends the specified int16 value.
func (*Writer) AppendInt32 ¶
AppendInt32 appends the specified int32 value.
func (*Writer) AppendInt64 ¶
AppendInt64 appends the specified int64 value.
func (*Writer) AppendInt8 ¶
AppendInt8 appends the specified int8 value.
func (*Writer) AppendString ¶
AppendString appends the specified string.
func (*Writer) AppendTerminator ¶
AppendTerminator appends a null terminator.
Source Files ¶
- authentication.go
- authentication_ok.go
- authentication_required.go
- backend_key_data.go
- bind.go
- bind_complete.go
- close.go
- close_complete.go
- command_complete.go
- config.go
- config_impl.go
- conn.go
- conn_impl.go
- copy_data.go
- copy_done.go
- copy_fail.go
- copy_in_response.go
- data_row.go
- data_type.go
- describe.go
- empty_query_response.go
- error_response.go
- errors.go
- execute.go
- flush.go
- format.go
- handler.go
- message.go
- message_reader.go
- no_data.go
- parameter_description.go
- parameter_status.go
- parse.go
- parse_complete.go
- password.go
- prepared.go
- query.go
- reader.go
- ready_for_query.go
- request_message.go
- response.go
- response_message.go
- responses.go
- row_description.go
- row_field.go
- server.go
- server_impl.go
- ssl_request.go
- ssl_response.go
- startup.go
- sync.go
- terminate.go
- type.go
- writer.go