message

package
v1.5.4 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthenticationKerberosV5Required        = 2
	AuthenticationCleartextPasswordRequired = 3
	AuthenticationMD5PasswordRequired       = 5
	AuthenticationSCMCredentialRequired     = 6
	AuthenticationGSSRequired               = 7
	AuthenticationGSSContinueRequired       = 8
	AuthenticationSSPIRequired              = 9
	AuthenticationSASLRequired              = 10
	AuthenticationSASLContinueRequired      = 11
	AuthenticationSASLFinalRequired         = 12
	AuthenticationOk                        = 0
)
View Source
const (
	// TextCopy represents a textual copy format.
	TextCopy = CopyFormat(0)
	// BinaryCopy represents a binary copy format.
	BinaryCopy = CopyFormat(1)
)
View Source
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
)
View Source
const (
	ApplicationName = "application_name"
	ClientEncoding  = "client_encoding"
	ServerEncoding  = "server_ encoding"
	DateStyle       = "DateStyle"
	TimeZone        = "TimeZone"
	IntervalStyle   = "IntervalStyle"
)
View Source
const (
	DefaultTransactiOnReadOnly = "default_transaction_read_only"
	InHotStandby               = "in_hot_standby"
	IsSuperuser                = "is_superuser"
	OntegerDatetimes           = "integer_datetimes"
)

on/off parameters.

View Source
const (
	ServerVersion             = "#server_version"
	StandardConformingStrings = "#standard_conforming_strings"
)
View Source
const (
	// PreparedStatementByte represents a prepared statement.
	PreparedStatementByte = 'S'
	// PreparedPortalByte represents a prepared portal.
	PreparedPortalByte = 'P'
)
View Source
const (
	TransactionIdle   = 'I'
	TransactionBlock  = 'T'
	TransactionFailed = 'E'
)
View Source
const (
	SSLEnabled  = 'S'
	SSLDisabled = 'N'
)
View Source
const (
	StartUpUser            = "user"
	StartUpPassword        = "password"
	StartUpDatabase        = "database"
	StartUpApplicationName = "application_name"
	StartUpClientEncoding  = "client_encoding"
)
View Source
const (
	DateStyleISO = "ISO, MDY.S"
)
View Source
const (
	EncodingUTF8 = "UTF8"
)
View Source
const (
	NoneMessage = 0x00
)
View Source
const SSLRequestCode = 80877103

SSLRequestCode represents a SSLRequest message code.

Variables

View Source
var ErrExist = errors.New("exist")

ErrExist is returned when the specified object is exist.

View Source
var ErrInvalid = errors.New("invalid")

ErrInvalid is returned when the message is invalid.

View Source
var ErrNotExist = errors.New("not exist")

ErrNotExist is returned when the specified object is not exist.

View Source
var ErrNotSupported = errors.New("not supported")

ErrNotSupported is returned when the message is not supported.

Functions

func NewErrExist

func NewErrExist(v any) error

NewErrExist returns a new exist error.

func NewErrInvalidMessage added in v0.9.1

func NewErrInvalidMessage(t Type) error

NewErrInvalidMessage eturns a new message not supported error.

func NewErrMessageNotSuppoted

func NewErrMessageNotSuppoted(t Type) error

NewErrMessageNotSuppoted returns a new message not supported error.

func NewErrNotExist

func NewErrNotExist(v any) error

NewErrNotExist returns a new not exist error.

func WithRowFieldDataType added in v1.2.0

func WithRowFieldDataType(dt *DataType) func(*RowField)

WithRowFieldDataType sets a data type.

func WithRowFieldFormatCode added in v1.2.0

func WithRowFieldFormatCode(formatCode int16) func(*RowField)

WithRowFieldFormatCode sets a format code.

func WithRowFieldModifier added in v1.2.0

func WithRowFieldModifier(typeModifier int32) func(*RowField)

WithRowFieldModifier sets a type modifier.

func WithRowFieldNumber added in v1.2.0

func WithRowFieldNumber(number int16) func(*RowField)

WithRowFieldNumber sets a number.

func WithRowFieldObjectID added in v1.2.0

func WithRowFieldObjectID(dataTypeID int32) func(*RowField)

WithRowFieldObjectID sets a data type ID.

func WithRowFieldSize added in v1.2.0

func WithRowFieldSize(dataTypeSize int16) func(*RowField)

WithRowFieldSize sets a data type size.

func WithRowFieldTableID added in v1.2.0

func WithRowFieldTableID(tableID int32) func(*RowField)

WithRowFieldTableID sets a table ID.

Types

type BackendKeyData

type BackendKeyData struct {
	*ResponseMessage
}

BackendKeyData represents a parameter status response message.

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 message.

func NewBindWithReader added in v0.9.1

func NewBindWithReader(reader *MessageReader) (*Bind, error)

NewBind returns a new bind message.

type BindComplete

type BindComplete struct {
	*ResponseMessage
}

BindComplete represents a bind complete message.

func NewBindComplete

func NewBindComplete() *BindComplete

NewBindComplete returns a new bind complete message instance.

type BindParam

type BindParam struct {
	FormatCode int16
	Value      any
}

BindParam represents a bind parameter.

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

type Close struct {
	*RequestMessage
	Type PreparedType
	Name string
}

Close represents a close message.

func NewCloseWithReader added in v1.3.0

func NewCloseWithReader(reader *MessageReader) (*Close, error)

NewCloseWithReader returns a new close message with the specified reader.

type CloseComplete added in v1.3.0

type CloseComplete struct {
	*ResponseMessage
}

CloseComplete represents a close complete message.

func NewCloseComplete added in v1.3.0

func NewCloseComplete() *CloseComplete

NewCloseComplete returns a new close complete message instance.

type CommandComplete

type CommandComplete struct {
	*ResponseMessage
}

CommandComplete represents a command complete message.

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 added in v0.9.1

func NewCommitComplete() (*CommandComplete, error)

NewCommitComplete returns a new command complete message for commit query.

func NewCopyCompleteWith added in v0.9.1

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

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 CopyData added in v0.9.1

type CopyData struct {
	*RequestMessage
	Data []string
}

CopyData represents a copy data message.

func NewCopyDataWithReader added in v0.9.1

func NewCopyDataWithReader(reader *MessageReader) (*CopyData, error)

NewCopyDataWithReader returns a new copy data message with the specified reader.

type CopyDone added in v0.9.1

type CopyDone struct {
	*RequestMessage
}

CopyDone represents a copy done message.

func NewCopyDoneWithReader added in v0.9.1

func NewCopyDoneWithReader(reader *MessageReader) (*CopyDone, error)

NewCopyDataWithReader returns a new copy data message with the specified reader.

type CopyFail added in v0.9.1

type CopyFail struct {
	MessageLength int32
	Message       string
}

CopyFail represents a copy fail message.

func NewCopyFailWithReader added in v0.9.1

func NewCopyFailWithReader(reader *Reader) (*CopyFail, error)

NewCopyFailWithReader returns a new copy fail message with the specified reader.

type CopyFormat added in v0.9.1

type CopyFormat = int8

CopyFormat represents a copy format.

type CopyInResponse added in v0.9.1

type CopyInResponse struct {
	*ResponseMessage
	// contains filtered or unexported fields
}

CopyInResponse represents a command complete message.

func NewCopyInResponseWith added in v0.9.1

func NewCopyInResponseWith(fmt CopyFormat) *CopyInResponse

NewCopyInResponse returns a new command complete message instance.

func (*CopyInResponse) AppendFormatCode added in v0.9.1

func (msg *CopyInResponse) AppendFormatCode(formatCode int16)

AppendFormatCode appends a format code.

func (*CopyInResponse) Bytes added in v0.9.1

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 message.

func NewDataRow

func NewDataRow() *DataRow

NewDataRow returns a new data row message instance.

func (*DataRow) AppendData

func (msg *DataRow) AppendData(rowField *RowField, v any) error

AppendData appends a column value to the data row message.

func (*DataRow) Bytes

func (msg *DataRow) Bytes() ([]byte, error)

Bytes appends a length of the message content bytes, and returns the message bytes.

type DataType added in v1.0.0

type DataType = system.DataType

DataType represents a data type.

type Describe added in v1.3.0

type Describe struct {
	*RequestMessage
	Type PreparedType
	Name string
}

Describe represents a describe message.

func NewDescribeWithReader added in v1.3.0

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 message.

func NewEmptyQueryResponse

func NewEmptyQueryResponse() *EmptyQueryResponse

NewEmptyQueryResponse returns an empty query response message instance.

type ErrorResponse

type ErrorResponse struct {
	*ResponseMessage
}

ErrorResponse represents an error response message.

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

type Execute struct {
	*RequestMessage
	PortalName string
	MaxRows    int32
}

Execute represents an execute message.

func NewExecuteWithReader added in v1.3.0

func NewExecuteWithReader(reader *MessageReader) (*Execute, error)

NewExecute returns a new execute message.

type Flush added in v1.3.0

type Flush struct {
	*RequestMessage
}

Flush represents a flush message.

func NewFlushWithReader added in v1.3.0

func NewFlushWithReader(reader *MessageReader) (*Flush, error)

NewFlush returns a new flush message.

type FormatCode added in v1.3.0

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 added in v0.9.1

type Message struct {
	*MessageReader
	Type   Type
	Length int32
}

Message represents a message of PostgreSQL packet.

func NewMessageWithReader added in v0.9.1

func NewMessageWithReader(reader *MessageReader) (*Message, error)

NewMessageWithReader returns a new message with the specified reader.

func (*Message) MessageDataLength added in v0.9.1

func (msg *Message) MessageDataLength() int32

MessageLength returns a message data length without the message header.

func (*Message) MessageLength added in v0.9.1

func (msg *Message) MessageLength() int32

MessageLength returns a message length.

func (*Message) MessageType added in v0.9.1

func (msg *Message) MessageType() Type

MessageType returns a message type.

func (*Message) ReadMessageData added in v0.9.1

func (msg *Message) ReadMessageData() ([]byte, error)

ReadMessageData reads all message data.

type MessageReader added in v0.9.1

type MessageReader struct {
	*Reader
	Type   Type
	Length int32
}

func NewMessageReaderWith added in v0.9.1

func NewMessageReaderWith(reader io.Reader) *MessageReader

NewMessageReader returns a new message reader.

func (*MessageReader) IsPeekType added in v1.3.0

func (reader *MessageReader) IsPeekType(t Type) (bool, error)

IsPeekType returns true whether the peeked message type is the specified type.

func (*MessageReader) PeekType added in v0.9.1

func (reader *MessageReader) PeekType() (Type, error)

PeekType peeks a message type.

func (*MessageReader) ReadLength added in v0.9.1

func (reader *MessageReader) ReadLength() (int32, error)

ReadLength reads a message length.

func (*MessageReader) ReadType added in v0.9.1

func (reader *MessageReader) ReadType() (Type, error)

ReadType reads a message type.

type NoData

type NoData struct {
	*ResponseMessage
}

NoData represents a no data message.

func NewNoData

func NewNoData() *NoData

NewNoData returns a new no data message instance.

type ObjectID added in v1.2.0

type ObjectID = system.ObjectID

ObjectID represents a object identifier.

type ParameterDescription added in v1.3.0

type ParameterDescription struct {
	*ResponseMessage
}

ParameterDescription represents a parameter description response message.

func NewParameterDescription added in v1.3.0

func NewParameterDescription() *ParameterDescription

NewParameterDescription returns a parameter description response instance.

func NewParameterDescriptionWith added in v1.3.0

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 message.

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 message.

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 message.

func NewParseComplete

func NewParseComplete() *ParseComplete

NewParseComplete returns a parser complete instance.

type Password added in v1.4.0

type Password struct {
	*RequestMessage
	Password string
}

Password represents a password message.

func NewPasswordWithReader added in v1.4.0

func NewPasswordWithReader(reader *MessageReader) (*Password, error)

NewPasswordWithReader returns a new password message.

type PreparedType added in v1.3.0

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

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 message.

func NewQueryWith

func NewQueryWith(parseMsg *Parse, bindMsg *Bind) (*Query, error)

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 Reader

type Reader struct {
	io.Reader
	// contains filtered or unexported fields
}

Reader represents a message reader.

func NewReaderWith

func NewReaderWith(reader io.Reader) *Reader

NewReader returns a new message reader.

func (*Reader) PeekBytes added in v1.3.0

func (reader *Reader) PeekBytes(n int) ([]byte, error)

func (*Reader) PeekInt32 added in v1.0.1

func (reader *Reader) PeekInt32() (int32, error)

PeekInt32 reads a 32-bit integer.

func (*Reader) ReadByte added in v1.3.0

func (reader *Reader) ReadByte() (byte, error)

func (*Reader) ReadBytes added in v0.9.1

func (reader *Reader) ReadBytes(buf []byte) (int, error)

func (*Reader) ReadBytesUntil added in v1.3.0

func (reader *Reader) ReadBytesUntil(delim byte) ([]byte, error)

func (*Reader) ReadInt16

func (reader *Reader) ReadInt16() (int16, error)

ReadInt16 reads a 16-bit integer.

func (*Reader) ReadInt32

func (reader *Reader) ReadInt32() (int32, error)

ReadInt32 reads a 32-bit integer.

func (*Reader) ReadString

func (reader *Reader) ReadString() (string, error)

ReadString reads a string.

type ReadyForQuery

type ReadyForQuery struct {
	*ResponseMessage
}

ReadyForQuery represents a ready for query message.

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 added in v0.9.1

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

func NewAuthenticationCleartextPassword() (*ResponseMessage, error)

NewAuthenticationCleartextPassword returns a new AuthenticationCleartextPassword message.

func NewAuthenticationMD5Password added in v1.4.0

func NewAuthenticationMD5Password(salt []byte) (*ResponseMessage, error)

NewAuthenticationMD5Password returns a new AuthenticationMD5Password message.

func NewAuthenticationOk

func NewAuthenticationOk() (*ResponseMessage, error)

NewAuthenticationOk returns a new AuthenticationOk message.

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

func NewCommandCompleteResponsesWith(msg string) (Responses, error)

NewCommandCompleteResponsesWith returns a new responses with the specified message.

func NewCopyCompleteResponsesWith added in v0.9.1

func NewCopyCompleteResponsesWith(n int) (Responses, error)

NewCopyCompleteResponsesWith returns a new responses with the specified message.

func NewDeleteCompleteResponsesWith

func NewDeleteCompleteResponsesWith(n int) (Responses, error)

NewDeleteCompleteResponsesWith returns a new responses with the specified message.

func NewEmptyCompleteResponses added in v1.4.0

func NewEmptyCompleteResponses() (Responses, error)

NewEmptyCompleteResponses returns a new responses with the specified message.

func NewInsertCompleteResponsesWith

func NewInsertCompleteResponsesWith(n int) (Responses, error)

NewInsertCompleteResponsesWith returns a new responses with the specified message.

func NewParameterStatusesWith added in v1.0.1

func NewParameterStatusesWith(m map[string]string) (Responses, error)

NewParameterStatusesWith returns parameter status response instances with the specified parameter statuses.

func NewResponses

func NewResponses() Responses

NewResponses returns a new empty responses.

func NewResponsesWith

func NewResponsesWith(responses ...Response) Responses

NewResponsesWith returns a new responses with the specified responses.

func NewSelectCompleteResponsesWith

func NewSelectCompleteResponsesWith(n int) (Responses, error)

NewSelectCompleteResponsesWith returns a new responses with the specified message.

func NewUpdateCompleteResponsesWith

func NewUpdateCompleteResponsesWith(n int) (Responses, error)

NewUpdateCompleteResponsesWith returns a new responses with the specified message.

func (Responses) Append

func (responses Responses) Append(res Response) Responses

Append appends the specified response to this responses.

func (Responses) HasErrorResponse added in v1.3.0

func (responses Responses) HasErrorResponse() bool

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 message.

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 message.

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

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

func (field *RowField) WirteBytes(w *Writer) error

WirteBytes appends a row field elements.

type RowFieldOption

type RowFieldOption = func(*RowField)

RowFieldOption represents a row description field option.

type SSLRequest added in v1.0.1

type SSLRequest struct {
	RequestCode int32
}

SSLRequest represents a SSLRequest message.

func NewSSLRequestWithReader added in v1.0.1

func NewSSLRequestWithReader(reader *MessageReader) (*SSLRequest, error)

NewSSLRequestWithReader returns a new SSLRequest message with the specified reader.

type SSLResponse added in v1.0.1

type SSLResponse struct {
	Enabled byte
}

SSLResponse represents a SSLResponse message.

func NewSSLResponseWith added in v1.0.1

func NewSSLResponseWith(enabled rune) *SSLResponse

NewSSLResponse returns a new SSLResponse message.

func (*SSLResponse) Bytes added in v1.0.1

func (msg *SSLResponse) Bytes() ([]byte, error)

Bytes returns a byte array of the message.

func (*SSLResponse) Type added in v1.0.1

func (msg *SSLResponse) Type() Type

Type returns the message type.

type Startup

type Startup struct {
	MajorVersion  int
	MinorVersion  int
	MessageLength int32
	Parameters    map[string]string
}

Startup represents a startup message.

func NewStartupWithReader

func NewStartupWithReader(reader *MessageReader) (*Startup, error)

NewStartupWithReader returns a new startup message with the specified reader.

func (*Startup) ApplicationName

func (msg *Startup) ApplicationName() (string, bool)

ApplicationName returns the application name.

func (*Startup) ClientEncoding

func (msg *Startup) ClientEncoding() (string, bool)

ClientEncoding returns the client encoding.

func (*Startup) Database

func (msg *Startup) Database() (string, bool)

Database returns the database name.

func (*Startup) Password added in v1.4.0

func (msg *Startup) Password() (string, bool)

Password returns the password.

func (*Startup) User

func (msg *Startup) User() (string, bool)

User returns the user name.

type Sync added in v1.3.0

type Sync struct {
	*RequestMessage
}

Sync represents a sync message.

func NewSyncWithReader added in v1.3.0

func NewSyncWithReader(reader *MessageReader) (*Sync, error)

NewSync returns a new sync message.

type Terminate added in v0.9.1

type Terminate struct {
	*RequestMessage
}

Terminate represents a terminate message.

func NewTerminateWithReader added in v0.9.1

func NewTerminateWithReader(reader *MessageReader) (*Terminate, error)

NewTerminate returns a new terminate message.

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).

const (
	CopyDataMessage Type = 'd'
	CopyDoneMessage Type = 'c'
)

Both (F & B).

func (Type) String added in v0.9.1

func (t Type) String() string

type Writer

type Writer struct {
	*bytes.Buffer
	*bufio.Writer
}

Writer represents a message writer.

func NewWriter

func NewWriter() *Writer

NewWriter returns a new message writer.

func (*Writer) AppendByte

func (writer *Writer) AppendByte(c byte) error

AppendByte appends the specified byte.

func (*Writer) AppendBytes

func (writer *Writer) AppendBytes(p []byte) error

AppendBytes appends the specified bytes.

func (*Writer) AppendFloat32

func (writer *Writer) AppendFloat32(v float32) error

AppendFloat32 appends the specified float32 value.

func (*Writer) AppendFloat64

func (writer *Writer) AppendFloat64(v float64) error

AppendFloat64 appends the specified float64 value.

func (*Writer) AppendInt16

func (writer *Writer) AppendInt16(v int16) error

AppendInt16 appends the specified int16 value.

func (*Writer) AppendInt32

func (writer *Writer) AppendInt32(v int32) error

AppendInt32 appends the specified int32 value.

func (*Writer) AppendInt64

func (writer *Writer) AppendInt64(v int64) error

AppendInt64 appends the specified int64 value.

func (*Writer) AppendInt8

func (writer *Writer) AppendInt8(v int8) error

AppendInt8 appends the specified int8 value.

func (*Writer) AppendString

func (writer *Writer) AppendString(s string) error

AppendString appends the specified string.

func (*Writer) AppendTerminator

func (writer *Writer) AppendTerminator() error

AppendTerminator appends a null terminator.

func (*Writer) Bytes

func (writer *Writer) Bytes() ([]byte, error)

Bytes returns the message bytes.

Jump to

Keyboard shortcuts

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