pgproto3
v5.13.0
Documentation
pkg.go.dev ↗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.
Constants
AuthTypeOk (10 declarations)
const ( AuthTypeOk = 0 AuthTypeCleartextPassword = 3 AuthTypeMD5Password = 5 AuthTypeSCMCreds = 6 AuthTypeGSS = 7 AuthTypeGSSCont = 8 AuthTypeSSPI = 9 AuthTypeSASL = 10 AuthTypeSASLContinue = 11 AuthTypeSASLFinal = 12 )
Authentication message type constants. See src/include/libpq/pqcomm.h for all constants.
TextFormat (2 declarations)
const ( TextFormat = 0 BinaryFormat = 1 )
ProtocolVersion30 (4 declarations)
const ( ProtocolVersion30 = 196608 // 3.0 ProtocolVersion32 = 196610 // 3.2 ProtocolVersionLatest = ProtocolVersion32 // Latest is 3.2 ProtocolVersionNumber = ProtocolVersion30 // Default is still 3.0 )
Types
AuthenticationCleartextPassword
type AuthenticationCleartextPassword struct{}
AuthenticationCleartextPassword is a message sent from the backend indicating that a clear-text password is required.
AuthenticationCleartextPassword.AuthenticationResponse
func (*AuthenticationCleartextPassword) AuthenticationResponse()
Backend identifies this message as an authentication response.
AuthenticationCleartextPassword.Backend
func (*AuthenticationCleartextPassword) Backend()
Backend identifies this message as sendable by the PostgreSQL backend.
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.
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.
AuthenticationCleartextPassword.MarshalJSON
func (src AuthenticationCleartextPassword) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
AuthenticationGSS
type AuthenticationGSS struct{}
AuthenticationGSS.AuthenticationResponse
func (a *AuthenticationGSS) AuthenticationResponse()
AuthenticationGSS.Backend
func (a *AuthenticationGSS) Backend()
AuthenticationGSS.Decode
func (a *AuthenticationGSS) Decode(src []byte) error
AuthenticationGSS.Encode
func (a *AuthenticationGSS) Encode(dst []byte) ([]byte, error)
AuthenticationGSS.MarshalJSON
func (a *AuthenticationGSS) MarshalJSON() ([]byte, error)
AuthenticationGSS.UnmarshalJSON
func (a *AuthenticationGSS) UnmarshalJSON(data []byte) error
AuthenticationGSSContinue
type AuthenticationGSSContinue struct {
Data []byte
}
AuthenticationGSSContinue.AuthenticationResponse
func (a *AuthenticationGSSContinue) AuthenticationResponse()
AuthenticationGSSContinue.Backend
func (a *AuthenticationGSSContinue) Backend()
AuthenticationGSSContinue.Decode
func (a *AuthenticationGSSContinue) Decode(src []byte) error
AuthenticationGSSContinue.Encode
func (a *AuthenticationGSSContinue) Encode(dst []byte) ([]byte, error)
AuthenticationGSSContinue.MarshalJSON
func (a *AuthenticationGSSContinue) MarshalJSON() ([]byte, error)
AuthenticationGSSContinue.UnmarshalJSON
func (a *AuthenticationGSSContinue) UnmarshalJSON(data []byte) error
AuthenticationMD5Password
type AuthenticationMD5Password struct {
Salt [4]byte
}
AuthenticationMD5Password is a message sent from the backend indicating that an MD5 hashed password is required.
AuthenticationMD5Password.AuthenticationResponse
func (*AuthenticationMD5Password) AuthenticationResponse()
Backend identifies this message as an authentication response.
AuthenticationMD5Password.Backend
func (*AuthenticationMD5Password) Backend()
Backend identifies this message as sendable by the PostgreSQL backend.
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.
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.
AuthenticationMD5Password.MarshalJSON
func (src AuthenticationMD5Password) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
AuthenticationMD5Password.UnmarshalJSON
func (dst *AuthenticationMD5Password) UnmarshalJSON(data []byte) error
UnmarshalJSON implements encoding/json.Unmarshaler.
AuthenticationOk
type AuthenticationOk struct{}
AuthenticationOk is a message sent from the backend indicating that authentication was successful.
AuthenticationOk.AuthenticationResponse
func (*AuthenticationOk) AuthenticationResponse()
Backend identifies this message as an authentication response.
AuthenticationOk.Backend
func (*AuthenticationOk) Backend()
Backend identifies this message as sendable by the PostgreSQL backend.
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.
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.
AuthenticationOk.MarshalJSON
func (src AuthenticationOk) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
AuthenticationResponseMessage
type AuthenticationResponseMessage interface {
BackendMessage
AuthenticationResponse() // no-op method to distinguish authentication responses
}
AuthenticationSASL
type AuthenticationSASL struct {
AuthMechanisms []string
}
AuthenticationSASL is a message sent from the backend indicating that SASL authentication is required.
AuthenticationSASL.AuthenticationResponse
func (*AuthenticationSASL) AuthenticationResponse()
Backend identifies this message as an authentication response.
AuthenticationSASL.Backend
func (*AuthenticationSASL) Backend()
Backend identifies this message as sendable by the PostgreSQL backend.