...

Package pgproto3

import "github.com/jackc/pgx/v5/pgproto3"
Overview
Index
Subdirectories

Overview ▾

Package pgproto3 is an encoder and decoder of the PostgreSQL wire protocol version 3.

The primary interfaces are Frontend and Backend. They correspond to a client and server respectively. Messages are sent with Send (or a specialized Send variant). Messages are automatically buffered to minimize small writes. Call Flush to ensure a message has actually been sent.

The Trace method of Frontend and Backend can be used to examine the wire-level message traffic. It outputs in a similar format to the PQtrace function in libpq.

See https://www.postgresql.org/docs/current/protocol-message-formats.html for meanings of the different messages.

Index ▾

Constants
type AuthenticationCleartextPassword
    func (*AuthenticationCleartextPassword) AuthenticationResponse()
    func (*AuthenticationCleartextPassword) Backend()
    func (dst *AuthenticationCleartextPassword) Decode(src []byte) error
    func (src *AuthenticationCleartextPassword) Encode(dst []byte) ([]byte, error)
    func (src AuthenticationCleartextPassword) MarshalJSON() ([]byte, error)
type AuthenticationGSS
    func (a *AuthenticationGSS) AuthenticationResponse()
    func (a *AuthenticationGSS) Backend()
    func (a *AuthenticationGSS) Decode(src []byte) error
    func (a *AuthenticationGSS) Encode(dst []byte) ([]byte, error)
    func (a *AuthenticationGSS) MarshalJSON() ([]byte, error)
    func (a *AuthenticationGSS) UnmarshalJSON(data []byte) error
type AuthenticationGSSContinue
    func (a *AuthenticationGSSContinue) AuthenticationResponse()
    func (a *AuthenticationGSSContinue) Backend()
    func (a *AuthenticationGSSContinue) Decode(src []byte) error
    func (a *AuthenticationGSSContinue) Encode(dst []byte) ([]byte, error)
    func (a *AuthenticationGSSContinue) MarshalJSON() ([]byte, error)
    func (a *AuthenticationGSSContinue) UnmarshalJSON(data []byte) error
type AuthenticationMD5Password
    func (*AuthenticationMD5Password) AuthenticationResponse()
    func (*AuthenticationMD5Password) Backend()
    func (dst *AuthenticationMD5Password) Decode(src []byte) error
    func (src *AuthenticationMD5Password) Encode(dst []byte) ([]byte, error)
    func (src AuthenticationMD5Password) MarshalJSON() ([]byte, error)
    func (dst *AuthenticationMD5Password) UnmarshalJSON(data []byte) error
type AuthenticationOk
    func (*AuthenticationOk) AuthenticationResponse()
    func (*AuthenticationOk) Backend()
    func (dst *AuthenticationOk) Decode(src []byte) error
    func (src *AuthenticationOk) Encode(dst []byte) ([]byte, error)
    func (src AuthenticationOk) MarshalJSON() ([]byte, error)
type AuthenticationResponseMessage
type AuthenticationSASL
    func (*AuthenticationSASL) AuthenticationResponse()
    func (*AuthenticationSASL) Backend()
    func (dst *AuthenticationSASL) Decode(src []byte) error
    func (src *AuthenticationSASL) Encode(dst []byte) ([]byte, error)
    func (src AuthenticationSASL) MarshalJSON() ([]byte, error)
type AuthenticationSASLContinue
    func (*AuthenticationSASLContinue) AuthenticationResponse()
    func (*AuthenticationSASLContinue) Backend()
    func (dst *AuthenticationSASLContinue) Decode(src []byte) error
    func (src *AuthenticationSASLContinue) Encode(dst []byte) ([]byte, error)
    func (src AuthenticationSASLContinue) MarshalJSON() ([]byte, error)
    func (dst *AuthenticationSASLContinue) UnmarshalJSON(data []byte) error
type AuthenticationSASLFinal
    func (*AuthenticationSASLFinal) AuthenticationResponse()
    func (*AuthenticationSASLFinal) Backend()
    func (dst *AuthenticationSASLFinal) Decode(src []byte) error
    func (src *AuthenticationSASLFinal) Encode(dst []byte) ([]byte, error)
    func (src AuthenticationSASLFinal) MarshalJSON() ([]byte, error)
    func (dst *AuthenticationSASLFinal) UnmarshalJSON(data []byte) error
type Backend
    func NewBackend(r io.Reader, w io.Writer) *Backend
    func (b *Backend) Flush() error
    func (b *Backend) Receive() (FrontendMessage, error)
    func (b *Backend) ReceiveStartupMessage() (FrontendMessage, error)
    func (b *Backend) Send(msg BackendMessage)
    func (b *Backend) SetAuthType(authType uint32) error
    func (b *Backend) SetMaxBodyLen(maxBodyLen int)
    func (b *Backend) Trace(w io.Writer, options TracerOptions)
    func (b *Backend) Untrace()
type BackendKeyData
    func (*BackendKeyData) Backend()
    func (dst *BackendKeyData) Decode(src []byte) error
    func (src *BackendKeyData) Encode(dst []byte) ([]byte, error)
    func (src BackendKeyData) MarshalJSON() ([]byte, error)
type BackendMessage
type BigEndianBuf
    func (b BigEndianBuf) Int16(n int16) []byte
    func (b BigEndianBuf) Int32(n int32) []byte
    func (b BigEndianBuf) Int64(n int64) []byte
    func (b BigEndianBuf) Uint16(n uint16) []byte
    func (b BigEndianBuf) Uint32(n uint32) []byte
type Bind
    func (dst *Bind) Decode(src []byte) error
    func (src *Bind) Encode(dst []byte) ([]byte, error)
    func (*Bind) Frontend()
    func (src Bind) MarshalJSON() ([]byte, error)
    func (dst *Bind) UnmarshalJSON(data []byte) error
type BindComplete
    func (*BindComplete) Backend()
    func (dst *BindComplete) Decode(src []byte) error
    func (src *BindComplete) Encode(dst []byte) ([]byte, error)
    func (src BindComplete) MarshalJSON() ([]byte, error)
type CancelRequest
    func (dst *CancelRequest) Decode(src []byte) error
    func (src *CancelRequest) Encode(dst []byte) ([]byte, error)
    func (*CancelRequest) Frontend()
    func (src CancelRequest) MarshalJSON() ([]byte, error)
type Close
    func (dst *Close) Decode(src []byte) error
    func (src *Close) Encode(dst []byte) ([]byte, error)
    func (*Close) Frontend()
    func (src Close) MarshalJSON() ([]byte, error)
    func (dst *Close) UnmarshalJSON(data []byte) error
type CloseComplete
    func (*CloseComplete) Backend()
    func (dst *CloseComplete) Decode(src []byte) error
    func (src *CloseComplete) Encode(dst []byte) ([]byte, error)
    func (src CloseComplete) MarshalJSON() ([]byte, error)
type CommandComplete
    func (*CommandComplete) Backend()
    func (dst *CommandComplete) Decode(src []byte) error
    func (src *CommandComplete) Encode(dst []byte) ([]byte, error)
    func (src CommandComplete) MarshalJSON() ([]byte, error)
    func (dst *CommandComplete) UnmarshalJSON(data []byte) error
type CopyBothResponse
    func (*CopyBothResponse) Backend()
    func (dst *CopyBothResponse) Decode(src []byte) error
    func (src *CopyBothResponse) Encode(dst []byte) ([]byte, error)
    func (src CopyBothResponse) MarshalJSON() ([]byte, error)
    func (dst *CopyBothResponse) UnmarshalJSON(data []byte) error
type CopyData
    func (*CopyData) Backend()
    func (dst *CopyData) Decode(src []byte) error
    func (src *CopyData) Encode(dst []byte) ([]byte, error)
    func (*CopyData) Frontend()
    func (src CopyData) MarshalJSON() ([]byte, error)
    func (dst *CopyData) UnmarshalJSON(data []byte) error
type CopyDone
    func (*CopyDone) Backend()
    func (dst *CopyDone) Decode(src []byte) error
    func (src *CopyDone) Encode(dst []byte) ([]byte, error)
    func (*CopyDone) Frontend()
    func (src CopyDone) MarshalJSON() ([]byte, error)
type CopyFail
    func (dst *CopyFail) Decode(src []byte) error
    func (src *CopyFail) Encode(dst []byte) ([]byte, error)
    func (*CopyFail) Frontend()
    func (src CopyFail) MarshalJSON() ([]byte, error)
type CopyInResponse
    func (*CopyInResponse) Backend()
    func (dst *CopyInResponse) Decode(src []byte) error
    func (src *CopyInResponse) Encode(dst []byte) ([]byte, error)
    func (src CopyInResponse) MarshalJSON() ([]byte, error)
    func (dst *CopyInResponse) UnmarshalJSON(data []byte) error
type CopyOutResponse
    func (*CopyOutResponse) Backend()
    func (dst *CopyOutResponse) Decode(src []byte) error
    func (src *CopyOutResponse) Encode(dst []byte) ([]byte, error)
    func (src CopyOutResponse) MarshalJSON() ([]byte, error)
    func (dst *CopyOutResponse) UnmarshalJSON(data []byte) error
type DataRow
    func (*DataRow) Backend()
    func (dst *DataRow) Decode(src []byte) error
    func (src *DataRow) Encode(dst []byte) ([]byte, error)
    func (src DataRow) MarshalJSON() ([]byte, error)
    func (dst *DataRow) UnmarshalJSON(data []byte) error
type Describe
    func (dst *Describe) Decode(src []byte) error
    func (src *Describe) Encode(dst []byte) ([]byte, error)
    func (*Describe) Frontend()
    func (src Describe) MarshalJSON() ([]byte, error)
    func (dst *Describe) UnmarshalJSON(data []byte) error
type EmptyQueryResponse
    func (*EmptyQueryResponse) Backend()
    func (dst *EmptyQueryResponse) Decode(src []byte) error
    func (src *EmptyQueryResponse) Encode(dst []byte) ([]byte, error)
    func (src EmptyQueryResponse) MarshalJSON() ([]byte, error)
type ErrorResponse
    func (*ErrorResponse) Backend()
    func (dst *ErrorResponse) Decode(src []byte) error
    func (src *ErrorResponse) Encode(dst []byte) ([]byte, error)
    func (src ErrorResponse) MarshalJSON() ([]byte, error)
    func (dst *ErrorResponse) UnmarshalJSON(data []byte) error
type ExceededMaxBodyLenErr
    func (e *ExceededMaxBodyLenErr) Error() string
type Execute
    func (dst *Execute) Decode(src []byte) error
    func (src *Execute) Encode(dst []byte) ([]byte, error)
    func (*Execute) Frontend()
    func (src Execute) MarshalJSON() ([]byte, error)
type FieldDescription
    func (fd FieldDescription) MarshalJSON() ([]byte, error)
type Flush
    func (dst *Flush) Decode(src []byte) error
    func (src *Flush) Encode(dst []byte) ([]byte, error)
    func (*Flush) Frontend()
    func (src Flush) MarshalJSON() ([]byte, error)
type Frontend
    func NewFrontend(r io.Reader, w io.Writer) *Frontend
    func (f *Frontend) Flush() error
    func (f *Frontend) GetAuthType() uint32
    func (f *Frontend) ReadBufferLen() int
    func (f *Frontend) Receive() (BackendMessage, error)
    func (f *Frontend) Send(msg FrontendMessage)
    func (f *Frontend) SendBind(msg *Bind)
    func (f *Frontend) SendClose(msg *Close)
    func (f *Frontend) SendDescribe(msg *Describe)
    func (f *Frontend) SendExecute(msg *Execute)
    func (f *Frontend) SendParse(msg *Parse)
    func (f *Frontend) SendQuery(msg *Query)
    func (f *Frontend) SendSync(msg *Sync)
    func (f *Frontend) SendUnbufferedEncodedCopyData(msg []byte) error
    func (f *Frontend) Trace(w io.Writer, options TracerOptions)
    func (f *Frontend) Untrace()
type FrontendMessage
type FunctionCall
    func (dst *FunctionCall) Decode(src []byte) error
    func (src *FunctionCall) Encode(dst []byte) ([]byte, error)
    func (*FunctionCall) Frontend()
type FunctionCallResponse
    func (*FunctionCallResponse) Backend()
    func (dst *FunctionCallResponse) Decode(src []byte) error
    func (src *FunctionCallResponse) Encode(dst []byte) ([]byte, error)
    func (src FunctionCallResponse) MarshalJSON() ([]byte, error)
    func (dst *FunctionCallResponse) UnmarshalJSON(data []byte) error
type GSSEncRequest
    func (dst *GSSEncRequest) Decode(src []byte) error
    func (src *GSSEncRequest) Encode(dst []byte) ([]byte, error)
    func (*GSSEncRequest) Frontend()
    func (src GSSEncRequest) MarshalJSON() ([]byte, error)
type GSSResponse
    func (g *GSSResponse) Decode(data []byte) error
    func (g *GSSResponse) Encode(dst []byte) ([]byte, error)
    func (g *GSSResponse) Frontend()
    func (g *GSSResponse) MarshalJSON() ([]byte, error)
    func (g *GSSResponse) UnmarshalJSON(data []byte) error
type Message
type NoData
    func (*NoData) Backend()
    func (dst *NoData) Decode(src []byte) error
    func (src *NoData) Encode(dst []byte) ([]byte, error)
    func (src NoData) MarshalJSON() ([]byte, error)
type NoticeResponse
    func (*NoticeResponse) Backend()
    func (dst *NoticeResponse) Decode(src []byte) error
    func (src *NoticeResponse) Encode(dst []byte) ([]byte, error)
type NotificationResponse
    func (*NotificationResponse) Backend()
    func (dst *NotificationResponse) Decode(src []byte) error
    func (src *NotificationResponse) Encode(dst []byte) ([]byte, error)
    func (src NotificationResponse) MarshalJSON() ([]byte, error)
type ParameterDescription
    func (*ParameterDescription) Backend()
    func (dst *ParameterDescription) Decode(src []byte) error
    func (src *ParameterDescription) Encode(dst []byte) ([]byte, error)
    func (src ParameterDescription) MarshalJSON() ([]byte, error)
type ParameterStatus
    func (*ParameterStatus) Backend()
    func (dst *ParameterStatus) Decode(src []byte) error
    func (src *ParameterStatus) Encode(dst []byte) ([]byte, error)
    func (ps ParameterStatus) MarshalJSON() ([]byte, error)
type Parse
    func (dst *Parse) Decode(src []byte) error
    func (src *Parse) Encode(dst []byte) ([]byte, error)
    func (*Parse) Frontend()
    func (src Parse) MarshalJSON() ([]byte, error)
type ParseComplete
    func (*ParseComplete) Backend()
    func (dst *ParseComplete) Decode(src []byte) error
    func (src *ParseComplete) Encode(dst []byte) ([]byte, error)
    func (src ParseComplete) MarshalJSON() ([]byte, error)
type PasswordMessage
    func (dst *PasswordMessage) Decode(src []byte) error
    func (src *PasswordMessage) Encode(dst []byte) ([]byte, error)
    func (*PasswordMessage) Frontend()
    func (*PasswordMessage) InitialResponse()
    func (src PasswordMessage) MarshalJSON() ([]byte, error)
type PortalSuspended
    func (*PortalSuspended) Backend()
    func (dst *PortalSuspended) Decode(src []byte) error
    func (src *PortalSuspended) Encode(dst []byte) ([]byte, error)
    func (src PortalSuspended) MarshalJSON() ([]byte, error)
type Query
    func (dst *Query) Decode(src []byte) error
    func (src *Query) Encode(dst []byte) ([]byte, error)
    func (*Query) Frontend()
    func (src Query) MarshalJSON() ([]byte, error)
type ReadyForQuery
    func (*ReadyForQuery) Backend()
    func (dst *ReadyForQuery) Decode(src []byte) error
    func (src *ReadyForQuery) Encode(dst []byte) ([]byte, error)
    func (src ReadyForQuery) MarshalJSON() ([]byte, error)
    func (dst *ReadyForQuery) UnmarshalJSON(data []byte) error
type RowDescription
    func (*RowDescription) Backend()
    func (dst *RowDescription) Decode(src []byte) error
    func (src *RowDescription) Encode(dst []byte) ([]byte, error)
    func (src RowDescription) MarshalJSON() ([]byte, error)
    func (dst *RowDescription) UnmarshalJSON(data []byte) error
type SASLInitialResponse
    func (dst *SASLInitialResponse) Decode(src []byte) error
    func (src *SASLInitialResponse) Encode(dst []byte) ([]byte, error)
    func (*SASLInitialResponse) Frontend()
    func (src SASLInitialResponse) MarshalJSON() ([]byte, error)
    func (dst *SASLInitialResponse) UnmarshalJSON(data []byte) error
type SASLResponse
    func (dst *SASLResponse) Decode(src []byte) error
    func (src *SASLResponse) Encode(dst []byte) ([]byte, error)
    func (*SASLResponse) Frontend()
    func (src SASLResponse) MarshalJSON() ([]byte, error)
    func (dst *SASLResponse) UnmarshalJSON(data []byte) error
type SSLRequest
    func (dst *SSLRequest) Decode(src []byte) error
    func (src *SSLRequest) Encode(dst []byte) ([]byte, error)
    func (*SSLRequest) Frontend()
    func (src SSLRequest) MarshalJSON() ([]byte, error)
type StartupMessage
    func (dst *StartupMessage) Decode(src []byte) error
    func (src *StartupMessage) Encode(dst []byte) ([]byte, error)
    func (*StartupMessage) Frontend()
    func (src StartupMessage) MarshalJSON() ([]byte, error)
type Sync
    func (dst *Sync) Decode(src []byte) error
    func (src *Sync) Encode(dst []byte) ([]byte, error)
    func (*Sync) Frontend()
    func (src Sync) MarshalJSON() ([]byte, error)
type Terminate
    func (dst *Terminate) Decode(src []byte) error
    func (src *Terminate) Encode(dst []byte) ([]byte, error)
    func (*Terminate) Frontend()
    func (src Terminate) MarshalJSON() ([]byte, error)
type TracerOptions

Package files

authentication_cleartext_password.go authentication_gss.go authentication_gss_continue.go authentication_md5_password.go authentication_ok.go authentication_sasl.go authentication_sasl_continue.go authentication_sasl_final.go backend.go backend_key_data.go big_endian.go bind.go bind_complete.go cancel_request.go chunkreader.go close.go close_complete.go command_complete.go copy_both_response.go copy_data.go copy_done.go copy_fail.go copy_in_response.go copy_out_response.go data_row.go describe.go doc.go empty_query_response.go error_response.go execute.go flush.go frontend.go function_call.go function_call_response.go gss_enc_request.go gss_response.go no_data.go notice_response.go notification_response.go parameter_description.go parameter_status.go parse.go parse_complete.go password_message.go pgproto3.go portal_suspended.go query.go ready_for_query.go row_description.go sasl_initial_response.go sasl_response.go ssl_request.go startup_message.go sync.go terminate.go trace.go

Constants

Authentication message type constants. See src/include/libpq/pqcomm.h for all constants.

const (
    AuthTypeOk                = 0
    AuthTypeCleartextPassword = 3
    AuthTypeMD5Password       = 5
    AuthTypeSCMCreds          = 6
    AuthTypeGSS               = 7
    AuthTypeGSSCont           = 8
    AuthTypeSSPI              = 9
    AuthTypeSASL              = 10
    AuthTypeSASLContinue      = 11
    AuthTypeSASLFinal         = 12
)
const (
    TextFormat   = 0
    BinaryFormat = 1
)
const ProtocolVersionNumber = 196608 // 3.0

type AuthenticationCleartextPassword

AuthenticationCleartextPassword is a message sent from the backend indicating that a clear-text password is required.

type AuthenticationCleartextPassword struct {
}

func (*AuthenticationCleartextPassword) AuthenticationResponse

func (*AuthenticationCleartextPassword) AuthenticationResponse()

Backend identifies this message as an authentication response.

func (*AuthenticationCleartextPassword) Backend

func (*AuthenticationCleartextPassword) Backend()

Backend identifies this message as sendable by the PostgreSQL backend.

func (*AuthenticationCleartextPassword) Decode

func (dst *AuthenticationCleartextPassword) Decode(src []byte) error

Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message type identifier and 4 byte message length.

func (*AuthenticationCleartextPassword) Encode

func (src *AuthenticationCleartextPassword) Encode(dst []byte) ([]byte, error)

Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.

func (AuthenticationCleartextPassword) MarshalJSON

func (src AuthenticationCleartextPassword) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

type AuthenticationGSS

type AuthenticationGSS struct{}

func (*AuthenticationGSS) AuthenticationResponse

func (a *AuthenticationGSS) AuthenticationResponse()

func (*AuthenticationGSS) Backend

func (a *AuthenticationGSS) Backend()

func (*AuthenticationGSS) Decode

func (a *AuthenticationGSS) Decode(src []byte) error

func (*AuthenticationGSS) Encode

func (a *AuthenticationGSS) Encode(dst []byte) ([]byte, error)

func (*AuthenticationGSS) MarshalJSON

func (a *AuthenticationGSS) MarshalJSON() ([]byte, error)

func (*AuthenticationGSS) UnmarshalJSON

func (a *AuthenticationGSS) UnmarshalJSON(data []byte) error

type AuthenticationGSSContinue

type AuthenticationGSSContinue struct {
    Data []byte
}

func (*AuthenticationGSSContinue) AuthenticationResponse

func (a *AuthenticationGSSContinue) AuthenticationResponse()

func (*AuthenticationGSSContinue) Backend

func (a *AuthenticationGSSContinue) Backend()

func (*AuthenticationGSSContinue) Decode

func (a *AuthenticationGSSContinue) Decode(src []byte) error

func (*AuthenticationGSSContinue) Encode

func (a *AuthenticationGSSContinue) Encode(dst []byte) ([]byte, error)

func (*AuthenticationGSSContinue) MarshalJSON

func (a *AuthenticationGSSContinue) MarshalJSON() ([]byte, error)

func (*AuthenticationGSSContinue) UnmarshalJSON

func (a *AuthenticationGSSContinue) UnmarshalJSON(data []byte) error

type AuthenticationMD5Password

AuthenticationMD5Password is a message sent from the backend indicating that an MD5 hashed password is required.

type AuthenticationMD5Password struct {
    Salt [4]byte
}

func (*AuthenticationMD5Password) AuthenticationResponse

func (*AuthenticationMD5Password) AuthenticationResponse()

Backend identifies this message as an authentication response.

func (*AuthenticationMD5Password) Backend

func (*AuthenticationMD5Password) Backend()

Backend identifies this message as sendable by the PostgreSQL backend.

func (*AuthenticationMD5Password) Decode

func (dst *AuthenticationMD5Password) Decode(src []byte) error

Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message type identifier and 4 byte message length.

func (*AuthenticationMD5Password) Encode

func (src *AuthenticationMD5Password) Encode(dst []byte) ([]byte, error)

Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.

func (AuthenticationMD5Password) MarshalJSON

func (src AuthenticationMD5Password) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

func (*AuthenticationMD5Password) UnmarshalJSON

func (dst *AuthenticationMD5Password) UnmarshalJSON(data []byte) error

UnmarshalJSON implements encoding/json.Unmarshaler.

type AuthenticationOk

AuthenticationOk is a message sent from the backend indicating that authentication was successful.

type AuthenticationOk struct {
}

func (*AuthenticationOk) AuthenticationResponse

func (*AuthenticationOk) AuthenticationResponse()

Backend identifies this message as an authentication response.

func (*AuthenticationOk) Backend

func (*AuthenticationOk) Backend()

Backend identifies this message as sendable by the PostgreSQL backend.

func (*AuthenticationOk) Decode

func (dst *AuthenticationOk) Decode(src []byte) error

Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message type identifier and 4 byte message length.

func (*AuthenticationOk) Encode

func (src *AuthenticationOk) Encode(dst []byte) ([]byte, error)

Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.

func (AuthenticationOk) MarshalJSON

func (src AuthenticationOk) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

type AuthenticationResponseMessage

type AuthenticationResponseMessage interface {
    BackendMessage
    AuthenticationResponse() // no-op method to distinguish authentication responses
}

type AuthenticationSASL

AuthenticationSASL is a message sent from the backend indicating that SASL authentication is required.

type AuthenticationSASL struct {
    AuthMechanisms []string
}

func (*AuthenticationSASL) AuthenticationResponse

func (*AuthenticationSASL) AuthenticationResponse()

Backend identifies this message as an authentication response.

func (*AuthenticationSASL) Backend

func (*AuthenticationSASL) Backend()

Backend identifies this message as sendable by the PostgreSQL backend.

func (*AuthenticationSASL) Decode

func (dst *AuthenticationSASL) Decode(src []byte) error

Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message type identifier and 4 byte message length.

func (*AuthenticationSASL) Encode

func (src *AuthenticationSASL) Encode(dst []byte) ([]byte, error)

Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.

func (AuthenticationSASL) MarshalJSON

func (src AuthenticationSASL) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

type AuthenticationSASLContinue

AuthenticationSASLContinue is a message sent from the backend containing a SASL challenge.

type AuthenticationSASLContinue struct {
    Data []byte
}

func (*AuthenticationSASLContinue) AuthenticationResponse

func (*AuthenticationSASLContinue) AuthenticationResponse()

Backend identifies this message as an authentication response.

func (*AuthenticationSASLContinue) Backend

func (*AuthenticationSASLContinue) Backend()

Backend identifies this message as sendable by the PostgreSQL backend.

func (*AuthenticationSASLContinue) Decode

func (dst *AuthenticationSASLContinue) Decode(src []byte) error

Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message type identifier and 4 byte message length.

func (*AuthenticationSASLContinue) Encode

func (src *AuthenticationSASLContinue) Encode(dst []byte) ([]byte, error)

Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.

func (AuthenticationSASLContinue) MarshalJSON

func (src AuthenticationSASLContinue) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

func (*AuthenticationSASLContinue) UnmarshalJSON

func (dst *AuthenticationSASLContinue) UnmarshalJSON(data []byte) error

UnmarshalJSON implements encoding/json.Unmarshaler.

type AuthenticationSASLFinal

AuthenticationSASLFinal is a message sent from the backend indicating a SASL authentication has completed.

type AuthenticationSASLFinal struct {
    Data []byte
}

func (*AuthenticationSASLFinal) AuthenticationResponse

func (*AuthenticationSASLFinal) AuthenticationResponse()

Backend identifies this message as an authentication response.

func (*AuthenticationSASLFinal) Backend

func (*AuthenticationSASLFinal) Backend()

Backend identifies this message as sendable by the PostgreSQL backend.

func (*AuthenticationSASLFinal) Decode

func (dst *AuthenticationSASLFinal) Decode(src []byte) error

Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message type identifier and 4 byte message length.

func (*AuthenticationSASLFinal) Encode

func (src *AuthenticationSASLFinal) Encode(dst []byte) ([]byte, error)

Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.

func (AuthenticationSASLFinal) MarshalJSON

func (src AuthenticationSASLFinal) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Unmarshaler.

func (*AuthenticationSASLFinal) UnmarshalJSON

func (dst *AuthenticationSASLFinal) UnmarshalJSON(data []byte) error

UnmarshalJSON implements encoding/json.Unmarshaler.

type Backend

Backend acts as a server for the PostgreSQL wire protocol version 3.

type Backend struct {
    // contains filtered or unexported fields
}

func NewBackend

func NewBackend(r io.Reader, w io.Writer) *Backend

NewBackend creates a new Backend.

func (*Backend) Flush

func (b *Backend) Flush() error

Flush writes any pending messages to the frontend (i.e. the client).

func (*Backend) Receive

func (b *Backend) Receive() (FrontendMessage, error)

Receive receives a message from the frontend. The returned message is only valid until the next call to Receive.

func (*Backend) ReceiveStartupMessage

func (b *Backend) ReceiveStartupMessage() (FrontendMessage, error)

ReceiveStartupMessage receives the initial connection message. This method is used of the normal Receive method because the initial connection message is "special" and does not include the message type as the first byte. This will return either a StartupMessage, SSLRequest, GSSEncRequest, or CancelRequest.

func (*Backend) Send

func (b *Backend) Send(msg BackendMessage)

Send sends a message to the frontend (i.e. the client). The message is buffered until Flush is called. Any error encountered will be returned from Flush.

func (*Backend) SetAuthType

func (b *Backend) SetAuthType(authType uint32) error

SetAuthType sets the authentication type in the backend. Since multiple message types can start with 'p', SetAuthType allows contextual identification of FrontendMessages. For example, in the PG message flow documentation for PasswordMessage:

		Byte1('p')

     Identifies the message as a password response. Note that this is also used for
		GSSAPI, SSPI and SASL response messages. The exact message type can be deduced from
		the context.

Since the Frontend does not know about the state of a backend, it is important to call SetAuthType() after an authentication request is received by the Frontend.

func (*Backend) SetMaxBodyLen

func (b *Backend) SetMaxBodyLen(maxBodyLen int)

SetMaxBodyLen sets the maximum length of a message body in octets. If a message body exceeds this length, Receive will return an error. This is useful for protecting against malicious clients that send large messages with the intent of causing memory exhaustion. The default value is 0. If maxBodyLen is 0, then no maximum is enforced.

func (*Backend) Trace

func (b *Backend) Trace(w io.Writer, options TracerOptions)

Trace starts tracing the message traffic to w. It writes in a similar format to that produced by the libpq function PQtrace.

func (*Backend) Untrace

func (b *Backend) Untrace()

Untrace stops tracing.

type BackendKeyData

type BackendKeyData struct {
    ProcessID uint32
    SecretKey uint32
}

func (*BackendKeyData) Backend

func (*BackendKeyData) Backend()

Backend identifies this message as sendable by the PostgreSQL backend.

func (*BackendKeyData) Decode

func (dst *BackendKeyData) Decode(src []byte) error

Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message type identifier and 4 byte message length.

func (*BackendKeyData) Encode

func (src *BackendKeyData) Encode(dst []byte) ([]byte, error)

Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.

func (BackendKeyData) MarshalJSON

func (src BackendKeyData) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

type BackendMessage

BackendMessage is a message sent by the backend (i.e. the server).

type BackendMessage interface {
    Message
    Backend() // no-op method to distinguish frontend from backend methods
}

type BigEndianBuf

type BigEndianBuf [8]byte

func (BigEndianBuf) Int16

func (b BigEndianBuf) Int16(n int16) []byte

func (BigEndianBuf) Int32

func (b BigEndianBuf) Int32(n int32) []byte

func (BigEndianBuf) Int64

func (b BigEndianBuf) Int64(n int64) []byte

func (BigEndianBuf) Uint16

func (b BigEndianBuf) Uint16(n uint16) []byte

func (BigEndianBuf) Uint32

func (b BigEndianBuf) Uint32(n uint32) []byte

type Bind

type Bind struct {
    DestinationPortal    string
    PreparedStatement    string
    ParameterFormatCodes []int16
    Parameters           [][]byte
    ResultFormatCodes    []int16
}

func (*Bind) Decode

func (dst *Bind) Decode(src []byte) error

Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message type identifier and 4 byte message length.

func (*Bind) Encode

func (src *Bind) Encode(dst []byte) ([]byte, error)

Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.

func (*Bind) Frontend

func (*Bind) Frontend()

Frontend identifies this message as sendable by a PostgreSQL frontend.

func (Bind) MarshalJSON

func (src Bind) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

func (*Bind) UnmarshalJSON

func (dst *Bind) UnmarshalJSON(data []byte) error

UnmarshalJSON implements encoding/json.Unmarshaler.

type BindComplete

type BindComplete struct{}

func (*BindComplete) Backend

func (*BindComplete) Backend()

Backend identifies this message as sendable by the PostgreSQL backend.

func (*BindComplete) Decode

func (dst *BindComplete) Decode(src []byte) error

Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message type identifier and 4 byte message length.

func (*BindComplete) Encode

func (src *BindComplete) Encode(dst []byte) ([]byte, error)

Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.

func (BindComplete) MarshalJSON

func (src BindComplete) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

type CancelRequest

type CancelRequest struct {
    ProcessID uint32
    SecretKey uint32
}

func (*CancelRequest) Decode

func (dst *CancelRequest) Decode(src []byte) error

func (*CancelRequest) Encode

func (src *CancelRequest) Encode(dst []byte) ([]byte, error)

Encode encodes src into dst. dst will include the 4 byte message length.

func (*CancelRequest) Frontend

func (*CancelRequest) Frontend()

Frontend identifies this message as sendable by a PostgreSQL frontend.

func (CancelRequest) MarshalJSON

func (src CancelRequest) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

type Close

type Close struct {
    ObjectType byte // 'S' = prepared statement, 'P' = portal
    Name       string
}

func (*Close) Decode

func (dst *Close) Decode(src []byte) error

Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message type identifier and 4 byte message length.

func (*Close) Encode

func (src *Close) Encode(dst []byte) ([]byte, error)

Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.

func (*Close) Frontend

func (*Close) Frontend()

Frontend identifies this message as sendable by a PostgreSQL frontend.

func (Close) MarshalJSON

func (src Close) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

func (*Close) UnmarshalJSON

func (dst *Close) UnmarshalJSON(data []byte) error

UnmarshalJSON implements encoding/json.Unmarshaler.

type CloseComplete

type CloseComplete struct{}

func (*CloseComplete) Backend

func (*CloseComplete) Backend()

Backend identifies this message as sendable by the PostgreSQL backend.

func (*CloseComplete) Decode

func (dst *CloseComplete) Decode(src []byte) error

Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message type identifier and 4 byte message length.

func (*CloseComplete) Encode

func (src *CloseComplete) Encode(dst []byte) ([]byte, error)

Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.

func (CloseComplete) MarshalJSON

func (src CloseComplete) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

type CommandComplete

type CommandComplete struct {
    CommandTag []byte
}

func (*CommandComplete) Backend

func (*CommandComplete) Backend()

Backend identifies this message as sendable by the PostgreSQL backend.

func (*CommandComplete) Decode

func (dst *CommandComplete) Decode(src []byte) error

Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message type identifier and 4 byte message length.

func (*CommandComplete) Encode

func (src *CommandComplete) Encode(dst []byte) ([]byte, error)

Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.

func (CommandComplete) MarshalJSON

func (src CommandComplete) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

func (*CommandComplete) UnmarshalJSON

func (dst *CommandComplete) UnmarshalJSON(data []byte) error

UnmarshalJSON implements encoding/json.Unmarshaler.

type CopyBothResponse

type CopyBothResponse struct {
    OverallFormat     byte
    ColumnFormatCodes []uint16
}

func (*CopyBothResponse) Backend

func (*CopyBothResponse) Backend()

Backend identifies this message as sendable by the PostgreSQL backend.

func (*CopyBothResponse) Decode

func (dst *CopyBothResponse) Decode(src []byte) error

Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message type identifier and 4 byte message length.

func (*CopyBothResponse) Encode

func (src *CopyBothResponse) Encode(dst []byte) ([]byte, error)

Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.

func (CopyBothResponse) MarshalJSON

func (src CopyBothResponse) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

func (*CopyBothResponse) UnmarshalJSON

func (dst *CopyBothResponse) UnmarshalJSON(data []byte) error

UnmarshalJSON implements encoding/json.Unmarshaler.

type CopyData

type CopyData struct {
    Data []byte
}

func (*CopyData) Backend

func (*CopyData) Backend()

Backend identifies this message as sendable by the PostgreSQL backend.

func (*CopyData) Decode

func (dst *CopyData) Decode(src []byte) error

Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message type identifier and 4 byte message length.

func (*CopyData) Encode

func (src *CopyData) Encode(dst []byte) ([]byte, error)

Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.

func (*CopyData) Frontend

func (*CopyData) Frontend()

Frontend identifies this message as sendable by a PostgreSQL frontend.

func (CopyData) MarshalJSON

func (src CopyData) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

func (*CopyData) UnmarshalJSON

func (dst *CopyData) UnmarshalJSON(data []byte) error

UnmarshalJSON implements encoding/json.Unmarshaler.

type CopyDone

type CopyDone struct {
}

func (*CopyDone) Backend

func (*CopyDone) Backend()

Backend identifies this message as sendable by the PostgreSQL backend.

func (*CopyDone) Decode

func (dst *CopyDone) Decode(src []byte) error

Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message type identifier and 4 byte message length.

func (*CopyDone) Encode

func (src *CopyDone) Encode(dst []byte) ([]byte, error)

Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.

func (*CopyDone) Frontend

func (*CopyDone) Frontend()

Frontend identifies this message as sendable by a PostgreSQL frontend.

func (CopyDone) MarshalJSON

func (src CopyDone) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

type CopyFail

type CopyFail struct {
    Message string
}

func (*CopyFail) Decode

func (dst *CopyFail) Decode(src []byte) error

Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message type identifier and 4 byte message length.

func (*CopyFail) Encode

func (src *CopyFail) Encode(dst []byte) ([]byte, error)

Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.

func (*CopyFail) Frontend

func (*CopyFail) Frontend()

Frontend identifies this message as sendable by a PostgreSQL frontend.

func (CopyFail) MarshalJSON

func (src CopyFail) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

type CopyInResponse

type CopyInResponse struct {
    OverallFormat     byte
    ColumnFormatCodes []uint16
}

func (*CopyInResponse) Backend

func (*CopyInResponse) Backend()

Backend identifies this message as sendable by the PostgreSQL backend.

func (*CopyInResponse) Decode

func (dst *CopyInResponse) Decode(src []byte) error

Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message type identifier and 4 byte message length.

func (*CopyInResponse) Encode

func (src *CopyInResponse) Encode(dst []byte) ([]byte, error)

Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.

func (CopyInResponse) MarshalJSON

func (src CopyInResponse) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

func (*CopyInResponse) UnmarshalJSON

func (dst *CopyInResponse) UnmarshalJSON(data []byte) error

UnmarshalJSON implements encoding/json.Unmarshaler.

type CopyOutResponse

type CopyOutResponse struct {
    OverallFormat     byte
    ColumnFormatCodes []uint16
}

func (*CopyOutResponse) Backend

func (*CopyOutResponse) Backend()

func (*CopyOutResponse) Decode

func (dst *CopyOutResponse) Decode(src []byte) error

Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message type identifier and 4 byte message length.

func (*CopyOutResponse) Encode

func (src *CopyOutResponse) Encode(dst []byte) ([]byte, error)

Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.

func (CopyOutResponse) MarshalJSON

func (src CopyOutResponse) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

func (*CopyOutResponse) UnmarshalJSON

func (dst *CopyOutResponse) UnmarshalJSON(data []byte) error

UnmarshalJSON implements encoding/json.Unmarshaler.

type DataRow

type DataRow struct {
    Values [][]byte
}

func (*DataRow) Backend

func (*DataRow) Backend()

Backend identifies this message as sendable by the PostgreSQL backend.

func (*DataRow) Decode

func (dst *DataRow) Decode(src []byte) error

Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message type identifier and 4 byte message length.

func (*DataRow) Encode

func (src *DataRow) Encode(dst []byte) ([]byte, error)

Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.

func (DataRow) MarshalJSON

func (src DataRow) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

func (*DataRow) UnmarshalJSON

func (dst *DataRow) UnmarshalJSON(data []byte) error

UnmarshalJSON implements encoding/json.Unmarshaler.

type Describe

type Describe struct {
    ObjectType byte // 'S' = prepared statement, 'P' = portal
    Name       string
}

func (*Describe) Decode

func (dst *Describe) Decode(src []byte) error

Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message type identifier and 4 byte message length.

func (*Describe) Encode

func (src *Describe) Encode(dst []byte) ([]byte, error)

Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.

func (*Describe) Frontend

func (*Describe) Frontend()

Frontend identifies this message as sendable by a PostgreSQL frontend.

func (Describe) MarshalJSON

func (src Describe) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

func (*Describe) UnmarshalJSON

func (dst *Describe) UnmarshalJSON(data []byte) error

UnmarshalJSON implements encoding/json.Unmarshaler.

type EmptyQueryResponse

type EmptyQueryResponse struct{}

func (*EmptyQueryResponse) Backend

func (*EmptyQueryResponse) Backend()

Backend identifies this message as sendable by the PostgreSQL backend.

func (*EmptyQueryResponse) Decode

func (dst *EmptyQueryResponse) Decode(src []byte) error

Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message type identifier and 4 byte message length.

func (*EmptyQueryResponse) Encode

func (src *EmptyQueryResponse) Encode(dst []byte) ([]byte, error)

Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.

func (EmptyQueryResponse) MarshalJSON

func (src EmptyQueryResponse) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

type ErrorResponse

type ErrorResponse struct {
    Severity            string
    SeverityUnlocalized string // only in 9.6 and greater
    Code                string
    Message             string
    Detail              string
    Hint                string
    Position            int32
    InternalPosition    int32
    InternalQuery       string
    Where               string
    SchemaName          string
    TableName           string
    ColumnName          string
    DataTypeName        string
    ConstraintName      string
    File                string
    Line                int32
    Routine             string

    UnknownFields map[byte]string
}

func (*ErrorResponse) Backend

func (*ErrorResponse) Backend()

Backend identifies this message as sendable by the PostgreSQL backend.

func (*ErrorResponse) Decode

func (dst *ErrorResponse) Decode(src []byte) error

Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message type identifier and 4 byte message length.

func (*ErrorResponse) Encode

func (src *ErrorResponse) Encode(dst []byte) ([]byte, error)

Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.

func (ErrorResponse) MarshalJSON

func (src ErrorResponse) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

func (*ErrorResponse) UnmarshalJSON

func (dst *ErrorResponse) UnmarshalJSON(data []byte) error

UnmarshalJSON implements encoding/json.Unmarshaler.

type ExceededMaxBodyLenErr

type ExceededMaxBodyLenErr struct {
    MaxExpectedBodyLen int
    ActualBodyLen      int
}

func (*ExceededMaxBodyLenErr) Error

func (e *ExceededMaxBodyLenErr) Error() string

type Execute

type Execute struct {
    Portal  string
    MaxRows uint32
}

func (*Execute) Decode

func (dst *Execute) Decode(src []byte) error

Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message type identifier and 4 byte message length.

func (*Execute) Encode

func (src *Execute) Encode(dst []byte) ([]byte, error)

Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.

func (*Execute) Frontend

func (*Execute) Frontend()

Frontend identifies this message as sendable by a PostgreSQL frontend.

func (Execute) MarshalJSON

func (src Execute) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

type FieldDescription

type FieldDescription struct {
    Name                 []byte
    TableOID             uint32
    TableAttributeNumber uint16
    DataTypeOID          uint32
    DataTypeSize         int16
    TypeModifier         int32
    Format               int16
}

func (FieldDescription) MarshalJSON

func (fd FieldDescription) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

type Flush

type Flush struct{}

func (*Flush) Decode

func (dst *Flush) Decode(src []byte) error

Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message type identifier and 4 byte message length.

func (*Flush) Encode

func (src *Flush) Encode(dst []byte) ([]byte, error)

Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.

func (*Flush) Frontend

func (*Flush) Frontend()

Frontend identifies this message as sendable by a PostgreSQL frontend.

func (Flush) MarshalJSON

func (src Flush) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

type Frontend

Frontend acts as a client for the PostgreSQL wire protocol version 3.

type Frontend struct {
    // contains filtered or unexported fields
}

func NewFrontend

func NewFrontend(r io.Reader, w io.Writer) *Frontend

NewFrontend creates a new Frontend.

func (*Frontend) Flush

func (f *Frontend) Flush() error

Flush writes any pending messages to the backend (i.e. the server).

func (*Frontend) GetAuthType

func (f *Frontend) GetAuthType() uint32

GetAuthType returns the authType used in the current state of the frontend. See SetAuthType for more information.

func (*Frontend) ReadBufferLen

func (f *Frontend) ReadBufferLen() int

func (*Frontend) Receive

func (f *Frontend) Receive() (BackendMessage, error)

Receive receives a message from the backend. The returned message is only valid until the next call to Receive.

func (*Frontend) Send

func (f *Frontend) Send(msg FrontendMessage)

Send sends a message to the backend (i.e. the server). The message is buffered until Flush is called. Any error encountered will be returned from Flush.

Send can work with any FrontendMessage. Some commonly used message types such as Bind have specialized send methods such as SendBind. These methods should be preferred when the type of message is known up front (e.g. when building an extended query protocol query) as they may be faster due to knowing the type of msg rather than it being hidden behind an interface.

func (*Frontend) SendBind

func (f *Frontend) SendBind(msg *Bind)

SendBind sends a Bind message to the backend (i.e. the server). The message is buffered until Flush is called. Any error encountered will be returned from Flush.

func (*Frontend) SendClose

func (f *Frontend) SendClose(msg *Close)

SendClose sends a Close message to the backend (i.e. the server). The message is buffered until Flush is called. Any error encountered will be returned from Flush.

func (*Frontend) SendDescribe

func (f *Frontend) SendDescribe(msg *Describe)

SendDescribe sends a Describe message to the backend (i.e. the server). The message is buffered until Flush is called. Any error encountered will be returned from Flush.

func (*Frontend) SendExecute

func (f *Frontend) SendExecute(msg *Execute)

SendExecute sends an Execute message to the backend (i.e. the server). The message is buffered until Flush is called. Any error encountered will be returned from Flush.

func (*Frontend) SendParse

func (f *Frontend) SendParse(msg *Parse)

SendParse sends a Parse message to the backend (i.e. the server). The message is buffered until Flush is called. Any error encountered will be returned from Flush.

func (*Frontend) SendQuery

func (f *Frontend) SendQuery(msg *Query)

SendQuery sends a Query message to the backend (i.e. the server). The message is buffered until Flush is called. Any error encountered will be returned from Flush.

func (*Frontend) SendSync

func (f *Frontend) SendSync(msg *Sync)

SendSync sends a Sync message to the backend (i.e. the server). The message is buffered until Flush is called. Any error encountered will be returned from Flush.

func (*Frontend) SendUnbufferedEncodedCopyData

func (f *Frontend) SendUnbufferedEncodedCopyData(msg []byte) error

SendUnbufferedEncodedCopyData immediately sends an encoded CopyData message to the backend (i.e. the server). This method is more efficient than sending a CopyData message with Send as the message data is not copied to the internal buffer before being written out. The internal buffer is flushed before the message is sent.

func (*Frontend) Trace

func (f *Frontend) Trace(w io.Writer, options TracerOptions)

Trace starts tracing the message traffic to w. It writes in a similar format to that produced by the libpq function PQtrace.

func (*Frontend) Untrace

func (f *Frontend) Untrace()

Untrace stops tracing.

type FrontendMessage

FrontendMessage is a message sent by the frontend (i.e. the client).

type FrontendMessage interface {
    Message
    Frontend() // no-op method to distinguish frontend from backend methods
}

type FunctionCall

type FunctionCall struct {
    Function         uint32
    ArgFormatCodes   []uint16
    Arguments        [][]byte
    ResultFormatCode uint16
}

func (*FunctionCall) Decode

func (dst *FunctionCall) Decode(src []byte) error

Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message type identifier and 4 byte message length.

func (*FunctionCall) Encode

func (src *FunctionCall) Encode(dst []byte) ([]byte, error)

Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.

func (*FunctionCall) Frontend

func (*FunctionCall) Frontend()

Frontend identifies this message as sendable by a PostgreSQL frontend.

type FunctionCallResponse

type FunctionCallResponse struct {
    Result []byte
}

func (*FunctionCallResponse) Backend

func (*FunctionCallResponse) Backend()

Backend identifies this message as sendable by the PostgreSQL backend.

func (*FunctionCallResponse) Decode

func (dst *FunctionCallResponse) Decode(src []byte) error

Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message type identifier and 4 byte message length.

func (*FunctionCallResponse) Encode

func (src *FunctionCallResponse) Encode(dst []byte) ([]byte, error)

Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.

func (FunctionCallResponse) MarshalJSON

func (src FunctionCallResponse) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

func (*FunctionCallResponse) UnmarshalJSON

func (dst *FunctionCallResponse) UnmarshalJSON(data []byte) error

UnmarshalJSON implements encoding/json.Unmarshaler.

type GSSEncRequest

type GSSEncRequest struct {
}

func (*GSSEncRequest) Decode

func (dst *GSSEncRequest) Decode(src []byte) error

func (*GSSEncRequest) Encode

func (src *GSSEncRequest) Encode(dst []byte) ([]byte, error)

Encode encodes src into dst. dst will include the 4 byte message length.

func (*GSSEncRequest) Frontend

func (*GSSEncRequest) Frontend()

Frontend identifies this message as sendable by a PostgreSQL frontend.

func (GSSEncRequest) MarshalJSON

func (src GSSEncRequest) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

type GSSResponse

type GSSResponse struct {
    Data []byte
}

func (*GSSResponse) Decode

func (g *GSSResponse) Decode(data []byte) error

func (*GSSResponse) Encode

func (g *GSSResponse) Encode(dst []byte) ([]byte, error)

func (*GSSResponse) Frontend

func (g *GSSResponse) Frontend()

Frontend identifies this message as sendable by a PostgreSQL frontend.

func (*GSSResponse) MarshalJSON

func (g *GSSResponse) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

func (*GSSResponse) UnmarshalJSON

func (g *GSSResponse) UnmarshalJSON(data []byte) error

UnmarshalJSON implements encoding/json.Unmarshaler.

type Message

Message is the interface implemented by an object that can decode and encode a particular PostgreSQL message.

type Message interface {
    // Decode is allowed and expected to retain a reference to data after
    // returning (unlike encoding.BinaryUnmarshaler).
    Decode(data []byte) error

    // Encode appends itself to dst and returns the new buffer.
    Encode(dst []byte) ([]byte, error)
}

type NoData

type NoData struct{}

func (*NoData) Backend

func (*NoData) Backend()

Backend identifies this message as sendable by the PostgreSQL backend.

func (*NoData) Decode

func (dst *NoData) Decode(src []byte) error

Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message type identifier and 4 byte message length.

func (*NoData) Encode

func (src *NoData) Encode(dst []byte) ([]byte, error)

Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.

func (NoData) MarshalJSON

func (src NoData) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

type NoticeResponse

type NoticeResponse ErrorResponse

func (*NoticeResponse) Backend

func (*NoticeResponse) Backend()

Backend identifies this message as sendable by the PostgreSQL backend.

func (*NoticeResponse) Decode

func (dst *NoticeResponse) Decode(src []byte) error

Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message type identifier and 4 byte message length.

func (*NoticeResponse) Encode

func (src *NoticeResponse) Encode(dst []byte) ([]byte, error)

Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.

type NotificationResponse

type NotificationResponse struct {
    PID     uint32
    Channel string
    Payload string
}

func (*NotificationResponse) Backend

func (*NotificationResponse) Backend()

Backend identifies this message as sendable by the PostgreSQL backend.

func (*NotificationResponse) Decode

func (dst *NotificationResponse) Decode(src []byte) error

Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message type identifier and 4 byte message length.

func (*NotificationResponse) Encode

func (src *NotificationResponse) Encode(dst []byte) ([]byte, error)

Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.

func (NotificationResponse) MarshalJSON

func (src NotificationResponse) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

type ParameterDescription

type ParameterDescription struct {
    ParameterOIDs []uint32
}

func (*ParameterDescription) Backend

func (*ParameterDescription) Backend()

Backend identifies this message as sendable by the PostgreSQL backend.

func (*ParameterDescription) Decode

func (dst *ParameterDescription) Decode(src []byte) error

Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message type identifier and 4 byte message length.

func (*ParameterDescription) Encode

func (src *ParameterDescription) Encode(dst []byte) ([]byte, error)

Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.

func (ParameterDescription) MarshalJSON

func (src ParameterDescription) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

type ParameterStatus

type ParameterStatus struct {
    Name  string
    Value string
}

func (*ParameterStatus) Backend

func (*ParameterStatus) Backend()

Backend identifies this message as sendable by the PostgreSQL backend.

func (*ParameterStatus) Decode

func (dst *ParameterStatus) Decode(src []byte) error

Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message type identifier and 4 byte message length.

func (*ParameterStatus) Encode

func (src *ParameterStatus) Encode(dst []byte) ([]byte, error)

Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.

func (ParameterStatus) MarshalJSON

func (ps ParameterStatus) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

type Parse

type Parse struct {
    Name          string
    Query         string
    ParameterOIDs []uint32
}

func (*Parse) Decode

func (dst *Parse) Decode(src []byte) error

Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message type identifier and 4 byte message length.

func (*Parse) Encode

func (src *Parse) Encode(dst []byte) ([]byte, error)

Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.

func (*Parse) Frontend

func (*Parse) Frontend()

Frontend identifies this message as sendable by a PostgreSQL frontend.

func (Parse) MarshalJSON

func (src Parse) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

type ParseComplete

type ParseComplete struct{}

func (*ParseComplete) Backend

func (*ParseComplete) Backend()

Backend identifies this message as sendable by the PostgreSQL backend.

func (*ParseComplete) Decode

func (dst *ParseComplete) Decode(src []byte) error

Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message type identifier and 4 byte message length.

func (*ParseComplete) Encode

func (src *ParseComplete) Encode(dst []byte) ([]byte, error)

Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.

func (ParseComplete) MarshalJSON

func (src ParseComplete) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

type PasswordMessage

type PasswordMessage struct {
    Password string
}

func (*PasswordMessage) Decode

func (dst *PasswordMessage) Decode(src []byte) error

Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message type identifier and 4 byte message length.

func (*PasswordMessage) Encode

func (src *PasswordMessage) Encode(dst []byte) ([]byte, error)

Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.

func (*PasswordMessage) Frontend

func (*PasswordMessage) Frontend()

Frontend identifies this message as sendable by a PostgreSQL frontend.

func (*PasswordMessage) InitialResponse

func (*PasswordMessage) InitialResponse()

Frontend identifies this message as an authentication response.

func (PasswordMessage) MarshalJSON

func (src PasswordMessage) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

type PortalSuspended

type PortalSuspended struct{}

func (*PortalSuspended) Backend

func (*PortalSuspended) Backend()

Backend identifies this message as sendable by the PostgreSQL backend.

func (*PortalSuspended) Decode

func (dst *PortalSuspended) Decode(src []byte) error

Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message type identifier and 4 byte message length.

func (*PortalSuspended) Encode

func (src *PortalSuspended) Encode(dst []byte) ([]byte, error)

Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.

func (PortalSuspended) MarshalJSON

func (src PortalSuspended) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

type Query

type Query struct {
    String string
}

func (*Query) Decode

func (dst *Query) Decode(src []byte) error

Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message type identifier and 4 byte message length.

func (*Query) Encode

func (src *Query) Encode(dst []byte) ([]byte, error)

Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.

func (*Query) Frontend

func (*Query) Frontend()

Frontend identifies this message as sendable by a PostgreSQL frontend.

func (Query) MarshalJSON

func (src Query) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

type ReadyForQuery

type ReadyForQuery struct {
    TxStatus byte
}

func (*ReadyForQuery) Backend

func (*ReadyForQuery) Backend()

Backend identifies this message as sendable by the PostgreSQL backend.

func (*ReadyForQuery) Decode

func (dst *ReadyForQuery) Decode(src []byte) error

Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message type identifier and 4 byte message length.

func (*ReadyForQuery) Encode

func (src *ReadyForQuery) Encode(dst []byte) ([]byte, error)

Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.

func (ReadyForQuery) MarshalJSON

func (src ReadyForQuery) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

func (*ReadyForQuery) UnmarshalJSON

func (dst *ReadyForQuery) UnmarshalJSON(data []byte) error

UnmarshalJSON implements encoding/json.Unmarshaler.

type RowDescription

type RowDescription struct {
    Fields []FieldDescription
}

func (*RowDescription) Backend

func (*RowDescription) Backend()

Backend identifies this message as sendable by the PostgreSQL backend.

func (*RowDescription) Decode

func (dst *RowDescription) Decode(src []byte) error

Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message type identifier and 4 byte message length.

func (*RowDescription) Encode

func (src *RowDescription) Encode(dst []byte) ([]byte, error)

Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.

func (RowDescription) MarshalJSON

func (src RowDescription) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

func (*RowDescription) UnmarshalJSON

func (dst *RowDescription) UnmarshalJSON(data []byte) error

UnmarshalJSON implements encoding/json.Unmarshaler.

type SASLInitialResponse

type SASLInitialResponse struct {
    AuthMechanism string
    Data          []byte
}

func (*SASLInitialResponse) Decode

func (dst *SASLInitialResponse) Decode(src []byte) error

Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message type identifier and 4 byte message length.

func (*SASLInitialResponse) Encode

func (src *SASLInitialResponse) Encode(dst []byte) ([]byte, error)

Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.

func (*SASLInitialResponse) Frontend

func (*SASLInitialResponse) Frontend()

Frontend identifies this message as sendable by a PostgreSQL frontend.

func (SASLInitialResponse) MarshalJSON

func (src SASLInitialResponse) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

func (*SASLInitialResponse) UnmarshalJSON

func (dst *SASLInitialResponse) UnmarshalJSON(data []byte) error

UnmarshalJSON implements encoding/json.Unmarshaler.

type SASLResponse

type SASLResponse struct {
    Data []byte
}

func (*SASLResponse) Decode

func (dst *SASLResponse) Decode(src []byte) error

Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message type identifier and 4 byte message length.

func (*SASLResponse) Encode

func (src *SASLResponse) Encode(dst []byte) ([]byte, error)

Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.

func (*SASLResponse) Frontend

func (*SASLResponse) Frontend()

Frontend identifies this message as sendable by a PostgreSQL frontend.

func (SASLResponse) MarshalJSON

func (src SASLResponse) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

func (*SASLResponse) UnmarshalJSON

func (dst *SASLResponse) UnmarshalJSON(data []byte) error

UnmarshalJSON implements encoding/json.Unmarshaler.

type SSLRequest

type SSLRequest struct {
}

func (*SSLRequest) Decode

func (dst *SSLRequest) Decode(src []byte) error

func (*SSLRequest) Encode

func (src *SSLRequest) Encode(dst []byte) ([]byte, error)

Encode encodes src into dst. dst will include the 4 byte message length.

func (*SSLRequest) Frontend

func (*SSLRequest) Frontend()

Frontend identifies this message as sendable by a PostgreSQL frontend.

func (SSLRequest) MarshalJSON

func (src SSLRequest) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

type StartupMessage

type StartupMessage struct {
    ProtocolVersion uint32
    Parameters      map[string]string
}

func (*StartupMessage) Decode

func (dst *StartupMessage) Decode(src []byte) error

Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message type identifier and 4 byte message length.

func (*StartupMessage) Encode

func (src *StartupMessage) Encode(dst []byte) ([]byte, error)

Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.

func (*StartupMessage) Frontend

func (*StartupMessage) Frontend()

Frontend identifies this message as sendable by a PostgreSQL frontend.

func (StartupMessage) MarshalJSON

func (src StartupMessage) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

type Sync

type Sync struct{}

func (*Sync) Decode

func (dst *Sync) Decode(src []byte) error

Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message type identifier and 4 byte message length.

func (*Sync) Encode

func (src *Sync) Encode(dst []byte) ([]byte, error)

Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.

func (*Sync) Frontend

func (*Sync) Frontend()

Frontend identifies this message as sendable by a PostgreSQL frontend.

func (Sync) MarshalJSON

func (src Sync) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

type Terminate

type Terminate struct{}

func (*Terminate) Decode

func (dst *Terminate) Decode(src []byte) error

Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message type identifier and 4 byte message length.

func (*Terminate) Encode

func (src *Terminate) Encode(dst []byte) ([]byte, error)

Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.

func (*Terminate) Frontend

func (*Terminate) Frontend()

Frontend identifies this message as sendable by a PostgreSQL frontend.

func (Terminate) MarshalJSON

func (src Terminate) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

type TracerOptions

TracerOptions controls tracing behavior. It is roughly equivalent to the libpq function PQsetTraceFlags.

type TracerOptions struct {
    // SuppressTimestamps prevents printing of timestamps.
    SuppressTimestamps bool

    // RegressMode redacts fields that may be vary between executions.
    RegressMode bool
}

Subdirectories

Name Synopsis
..
example
pgfortune