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
AuthenticationCleartextPassword is a message sent from the backend indicating that a clear-text password is required.
type AuthenticationCleartextPassword struct { }
func (*AuthenticationCleartextPassword) AuthenticationResponse()
Backend identifies this message as an authentication response.
func (*AuthenticationCleartextPassword) Backend()
Backend identifies this message as sendable by the PostgreSQL backend.
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 (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 (src AuthenticationCleartextPassword) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
type AuthenticationGSS struct{}
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 struct { Data []byte }
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
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()
Backend identifies this message as an authentication response.
func (*AuthenticationMD5Password) Backend()
Backend identifies this message as sendable by the PostgreSQL backend.
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 (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 (src AuthenticationMD5Password) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
func (dst *AuthenticationMD5Password) UnmarshalJSON(data []byte) error
UnmarshalJSON implements encoding/json.Unmarshaler.
AuthenticationOk is a message sent from the backend indicating that authentication was successful.
type AuthenticationOk struct { }
func (*AuthenticationOk) AuthenticationResponse()
Backend identifies this message as an authentication response.
func (*AuthenticationOk) Backend()
Backend identifies this message as sendable by the PostgreSQL backend.
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 (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 (src AuthenticationOk) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
type AuthenticationResponseMessage interface { BackendMessage AuthenticationResponse() // no-op method to distinguish authentication responses }
AuthenticationSASL is a message sent from the backend indicating that SASL authentication is required.
type AuthenticationSASL struct { AuthMechanisms []string }
func (*AuthenticationSASL) AuthenticationResponse()
Backend identifies this message as an authentication response.
func (*AuthenticationSASL) Backend()
Backend identifies this message as sendable by the PostgreSQL backend.
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 (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 (src AuthenticationSASL) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
AuthenticationSASLContinue is a message sent from the backend containing a SASL challenge.
type AuthenticationSASLContinue struct { Data []byte }
func (*AuthenticationSASLContinue) AuthenticationResponse()
Backend identifies this message as an authentication response.
func (*AuthenticationSASLContinue) Backend()
Backend identifies this message as sendable by the PostgreSQL backend.
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 (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 (src AuthenticationSASLContinue) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
func (dst *AuthenticationSASLContinue) UnmarshalJSON(data []byte) error
UnmarshalJSON implements encoding/json.Unmarshaler.
AuthenticationSASLFinal is a message sent from the backend indicating a SASL authentication has completed.
type AuthenticationSASLFinal struct { Data []byte }
func (*AuthenticationSASLFinal) AuthenticationResponse()
Backend identifies this message as an authentication response.
func (*AuthenticationSASLFinal) Backend()
Backend identifies this message as sendable by the PostgreSQL backend.
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 (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 (src AuthenticationSASLFinal) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Unmarshaler.
func (dst *AuthenticationSASLFinal) UnmarshalJSON(data []byte) error
UnmarshalJSON implements encoding/json.Unmarshaler.
Backend acts as a server for the PostgreSQL wire protocol version 3.
type Backend struct {
// contains filtered or unexported fields
}
func NewBackend(r io.Reader, w io.Writer) *Backend
NewBackend creates a new Backend.
func (b *Backend) Flush() error
Flush writes any pending messages to the frontend (i.e. the client).
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 (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 (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 (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 (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 (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 (b *Backend) Untrace()
Untrace stops tracing.
type BackendKeyData struct { ProcessID uint32 SecretKey uint32 }
func (*BackendKeyData) Backend()
Backend identifies this message as sendable by the PostgreSQL backend.
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 (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 (src BackendKeyData) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
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 [8]byte
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 struct { DestinationPortal string PreparedStatement string ParameterFormatCodes []int16 Parameters [][]byte ResultFormatCodes []int16 }
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 (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()
Frontend identifies this message as sendable by a PostgreSQL frontend.
func (src Bind) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
func (dst *Bind) UnmarshalJSON(data []byte) error
UnmarshalJSON implements encoding/json.Unmarshaler.
type BindComplete struct{}
func (*BindComplete) Backend()
Backend identifies this message as sendable by the PostgreSQL backend.
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 (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 (src BindComplete) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
type CancelRequest struct { ProcessID uint32 SecretKey uint32 }
func (dst *CancelRequest) Decode(src []byte) error
func (src *CancelRequest) Encode(dst []byte) ([]byte, error)
Encode encodes src into dst. dst will include the 4 byte message length.
func (*CancelRequest) Frontend()
Frontend identifies this message as sendable by a PostgreSQL frontend.
func (src CancelRequest) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
type Close struct { ObjectType byte // 'S' = prepared statement, 'P' = portal Name string }
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 (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()
Frontend identifies this message as sendable by a PostgreSQL frontend.
func (src Close) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
func (dst *Close) UnmarshalJSON(data []byte) error
UnmarshalJSON implements encoding/json.Unmarshaler.
type CloseComplete struct{}
func (*CloseComplete) Backend()
Backend identifies this message as sendable by the PostgreSQL backend.
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 (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 (src CloseComplete) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
type CommandComplete struct { CommandTag []byte }
func (*CommandComplete) Backend()
Backend identifies this message as sendable by the PostgreSQL backend.
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 (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 (src CommandComplete) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
func (dst *CommandComplete) UnmarshalJSON(data []byte) error
UnmarshalJSON implements encoding/json.Unmarshaler.
type CopyBothResponse struct { OverallFormat byte ColumnFormatCodes []uint16 }
func (*CopyBothResponse) Backend()
Backend identifies this message as sendable by the PostgreSQL backend.
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 (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 (src CopyBothResponse) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
func (dst *CopyBothResponse) UnmarshalJSON(data []byte) error
UnmarshalJSON implements encoding/json.Unmarshaler.
type CopyData struct { Data []byte }
func (*CopyData) Backend()
Backend identifies this message as sendable by the PostgreSQL backend.
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 (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()
Frontend identifies this message as sendable by a PostgreSQL frontend.
func (src CopyData) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
func (dst *CopyData) UnmarshalJSON(data []byte) error
UnmarshalJSON implements encoding/json.Unmarshaler.
type CopyDone struct { }
func (*CopyDone) Backend()
Backend identifies this message as sendable by the PostgreSQL backend.
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 (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()
Frontend identifies this message as sendable by a PostgreSQL frontend.
func (src CopyDone) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
type CopyFail struct { Message string }
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 (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()
Frontend identifies this message as sendable by a PostgreSQL frontend.
func (src CopyFail) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
type CopyInResponse struct { OverallFormat byte ColumnFormatCodes []uint16 }
func (*CopyInResponse) Backend()
Backend identifies this message as sendable by the PostgreSQL backend.
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 (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 (src CopyInResponse) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
func (dst *CopyInResponse) UnmarshalJSON(data []byte) error
UnmarshalJSON implements encoding/json.Unmarshaler.
type CopyOutResponse struct { OverallFormat byte ColumnFormatCodes []uint16 }
func (*CopyOutResponse) Backend()
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 (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 (src CopyOutResponse) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
func (dst *CopyOutResponse) UnmarshalJSON(data []byte) error
UnmarshalJSON implements encoding/json.Unmarshaler.
type DataRow struct { Values [][]byte }
func (*DataRow) Backend()
Backend identifies this message as sendable by the PostgreSQL backend.
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 (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 (src DataRow) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
func (dst *DataRow) UnmarshalJSON(data []byte) error
UnmarshalJSON implements encoding/json.Unmarshaler.
type Describe struct { ObjectType byte // 'S' = prepared statement, 'P' = portal Name string }
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 (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()
Frontend identifies this message as sendable by a PostgreSQL frontend.
func (src Describe) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
func (dst *Describe) UnmarshalJSON(data []byte) error
UnmarshalJSON implements encoding/json.Unmarshaler.
type EmptyQueryResponse struct{}
func (*EmptyQueryResponse) Backend()
Backend identifies this message as sendable by the PostgreSQL backend.
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 (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 (src EmptyQueryResponse) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
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()
Backend identifies this message as sendable by the PostgreSQL backend.
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 (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 (src ErrorResponse) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
func (dst *ErrorResponse) UnmarshalJSON(data []byte) error
UnmarshalJSON implements encoding/json.Unmarshaler.
type ExceededMaxBodyLenErr struct { MaxExpectedBodyLen int ActualBodyLen int }
func (e *ExceededMaxBodyLenErr) Error() string
type Execute struct { Portal string MaxRows uint32 }
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 (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()
Frontend identifies this message as sendable by a PostgreSQL frontend.
func (src Execute) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
type FieldDescription struct { Name []byte TableOID uint32 TableAttributeNumber uint16 DataTypeOID uint32 DataTypeSize int16 TypeModifier int32 Format int16 }
func (fd FieldDescription) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
type Flush struct{}
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 (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()
Frontend identifies this message as sendable by a PostgreSQL frontend.
func (src Flush) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
Frontend acts as a client for the PostgreSQL wire protocol version 3.
type Frontend struct {
// contains filtered or unexported fields
}
func NewFrontend(r io.Reader, w io.Writer) *Frontend
NewFrontend creates a new Frontend.
func (f *Frontend) Flush() error
Flush writes any pending messages to the backend (i.e. the server).
func (f *Frontend) GetAuthType() uint32
GetAuthType returns the authType used in the current state of the frontend. See SetAuthType for more information.
func (f *Frontend) ReadBufferLen() int
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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (f *Frontend) Untrace()
Untrace stops tracing.
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 struct { Function uint32 ArgFormatCodes []uint16 Arguments [][]byte ResultFormatCode uint16 }
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 (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()
Frontend identifies this message as sendable by a PostgreSQL frontend.
type FunctionCallResponse struct { Result []byte }
func (*FunctionCallResponse) Backend()
Backend identifies this message as sendable by the PostgreSQL backend.
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 (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 (src FunctionCallResponse) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
func (dst *FunctionCallResponse) UnmarshalJSON(data []byte) error
UnmarshalJSON implements encoding/json.Unmarshaler.
type GSSEncRequest struct { }
func (dst *GSSEncRequest) Decode(src []byte) error
func (src *GSSEncRequest) Encode(dst []byte) ([]byte, error)
Encode encodes src into dst. dst will include the 4 byte message length.
func (*GSSEncRequest) Frontend()
Frontend identifies this message as sendable by a PostgreSQL frontend.
func (src GSSEncRequest) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
type GSSResponse struct { Data []byte }
func (g *GSSResponse) Decode(data []byte) error
func (g *GSSResponse) Encode(dst []byte) ([]byte, error)
func (g *GSSResponse) Frontend()
Frontend identifies this message as sendable by a PostgreSQL frontend.
func (g *GSSResponse) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
func (g *GSSResponse) UnmarshalJSON(data []byte) error
UnmarshalJSON implements encoding/json.Unmarshaler.
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 struct{}
func (*NoData) Backend()
Backend identifies this message as sendable by the PostgreSQL backend.
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 (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 (src NoData) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
type NoticeResponse ErrorResponse
func (*NoticeResponse) Backend()
Backend identifies this message as sendable by the PostgreSQL backend.
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 (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 struct { PID uint32 Channel string Payload string }
func (*NotificationResponse) Backend()
Backend identifies this message as sendable by the PostgreSQL backend.
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 (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 (src NotificationResponse) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
type ParameterDescription struct { ParameterOIDs []uint32 }
func (*ParameterDescription) Backend()
Backend identifies this message as sendable by the PostgreSQL backend.
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 (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 (src ParameterDescription) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
type ParameterStatus struct { Name string Value string }
func (*ParameterStatus) Backend()
Backend identifies this message as sendable by the PostgreSQL backend.
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 (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 (ps ParameterStatus) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
type Parse struct { Name string Query string ParameterOIDs []uint32 }
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 (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()
Frontend identifies this message as sendable by a PostgreSQL frontend.
func (src Parse) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
type ParseComplete struct{}
func (*ParseComplete) Backend()
Backend identifies this message as sendable by the PostgreSQL backend.
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 (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 (src ParseComplete) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
type PasswordMessage struct { Password string }
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 (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()
Frontend identifies this message as sendable by a PostgreSQL frontend.
func (*PasswordMessage) InitialResponse()
Frontend identifies this message as an authentication response.
func (src PasswordMessage) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
type PortalSuspended struct{}
func (*PortalSuspended) Backend()
Backend identifies this message as sendable by the PostgreSQL backend.
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 (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 (src PortalSuspended) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
type Query struct { String string }
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 (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()
Frontend identifies this message as sendable by a PostgreSQL frontend.
func (src Query) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
type ReadyForQuery struct { TxStatus byte }
func (*ReadyForQuery) Backend()
Backend identifies this message as sendable by the PostgreSQL backend.
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 (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 (src ReadyForQuery) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
func (dst *ReadyForQuery) UnmarshalJSON(data []byte) error
UnmarshalJSON implements encoding/json.Unmarshaler.
type RowDescription struct { Fields []FieldDescription }
func (*RowDescription) Backend()
Backend identifies this message as sendable by the PostgreSQL backend.
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 (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 (src RowDescription) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
func (dst *RowDescription) UnmarshalJSON(data []byte) error
UnmarshalJSON implements encoding/json.Unmarshaler.
type SASLInitialResponse struct { AuthMechanism string Data []byte }
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 (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()
Frontend identifies this message as sendable by a PostgreSQL frontend.
func (src SASLInitialResponse) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
func (dst *SASLInitialResponse) UnmarshalJSON(data []byte) error
UnmarshalJSON implements encoding/json.Unmarshaler.
type SASLResponse struct { Data []byte }
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 (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()
Frontend identifies this message as sendable by a PostgreSQL frontend.
func (src SASLResponse) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
func (dst *SASLResponse) UnmarshalJSON(data []byte) error
UnmarshalJSON implements encoding/json.Unmarshaler.
type SSLRequest struct { }
func (dst *SSLRequest) Decode(src []byte) error
func (src *SSLRequest) Encode(dst []byte) ([]byte, error)
Encode encodes src into dst. dst will include the 4 byte message length.
func (*SSLRequest) Frontend()
Frontend identifies this message as sendable by a PostgreSQL frontend.
func (src SSLRequest) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
type StartupMessage struct { ProtocolVersion uint32 Parameters map[string]string }
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 (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()
Frontend identifies this message as sendable by a PostgreSQL frontend.
func (src StartupMessage) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
type Sync struct{}
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 (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()
Frontend identifies this message as sendable by a PostgreSQL frontend.
func (src Sync) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
type Terminate struct{}
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 (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()
Frontend identifies this message as sendable by a PostgreSQL frontend.
func (src Terminate) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
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 }