package pgproto3
Import Path
github.com/jackc/pgx/v5/pgproto3 (on go.dev)
Dependency Relation
imports 14 packages, and imported by one package
Involved Source 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
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.
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
negotiate_protocol_version.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
Package-Level Type Names (total 65, in which 60 are exported)
AuthenticationCleartextPassword is a message sent from the backend indicating that a clear-text password is required.
Backend identifies this message as an authentication response.
Backend identifies this message as sendable by the PostgreSQL backend.
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.
Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
MarshalJSON implements encoding/json.Marshaler.
*AuthenticationCleartextPassword : AuthenticationResponseMessage
*AuthenticationCleartextPassword : BackendMessage
*AuthenticationCleartextPassword : Message
AuthenticationCleartextPassword : encoding/json.Marshaler
(*AuthenticationGSS) AuthenticationResponse()
(*AuthenticationGSS) Backend()
(*AuthenticationGSS) Decode(src []byte) error
(*AuthenticationGSS) Encode(dst []byte) ([]byte, error)
(*AuthenticationGSS) MarshalJSON() ([]byte, error)
(*AuthenticationGSS) UnmarshalJSON(data []byte) error
*AuthenticationGSS : AuthenticationResponseMessage
*AuthenticationGSS : BackendMessage
*AuthenticationGSS : Message
*AuthenticationGSS : encoding/json.Marshaler
*AuthenticationGSS : encoding/json.Unmarshaler
Data []byte
(*AuthenticationGSSContinue) AuthenticationResponse()
(*AuthenticationGSSContinue) Backend()
(*AuthenticationGSSContinue) Decode(src []byte) error
(*AuthenticationGSSContinue) Encode(dst []byte) ([]byte, error)
(*AuthenticationGSSContinue) MarshalJSON() ([]byte, error)
(*AuthenticationGSSContinue) UnmarshalJSON(data []byte) error
*AuthenticationGSSContinue : AuthenticationResponseMessage
*AuthenticationGSSContinue : BackendMessage
*AuthenticationGSSContinue : Message
*AuthenticationGSSContinue : encoding/json.Marshaler
*AuthenticationGSSContinue : encoding/json.Unmarshaler
func github.com/jackc/pgx/v5/pgconn.(*PgConn).rxGSSContinue() (*AuthenticationGSSContinue, error)
AuthenticationMD5Password is a message sent from the backend indicating that an MD5 hashed password is required.
Salt [4]byte
Backend identifies this message as an authentication response.
Backend identifies this message as sendable by the PostgreSQL backend.
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.
Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
MarshalJSON implements encoding/json.Marshaler.
UnmarshalJSON implements encoding/json.Unmarshaler.
*AuthenticationMD5Password : AuthenticationResponseMessage
*AuthenticationMD5Password : BackendMessage
*AuthenticationMD5Password : Message
AuthenticationMD5Password : encoding/json.Marshaler
*AuthenticationMD5Password : encoding/json.Unmarshaler
AuthenticationOk is a message sent from the backend indicating that authentication was successful.
Backend identifies this message as an authentication response.
Backend identifies this message as sendable by the PostgreSQL backend.
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.
Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
MarshalJSON implements encoding/json.Marshaler.
*AuthenticationOk : AuthenticationResponseMessage
*AuthenticationOk : BackendMessage
*AuthenticationOk : Message
AuthenticationOk : encoding/json.Marshaler
// no-op method to distinguish authentication responses
// no-op method to distinguish frontend from backend methods
Decode is allowed and expected to retain a reference to data after
returning (unlike encoding.BinaryUnmarshaler).
Encode appends itself to dst and returns the new buffer.
*AuthenticationCleartextPassword
*AuthenticationGSS
*AuthenticationGSSContinue
*AuthenticationMD5Password
*AuthenticationOk
*AuthenticationSASL
*AuthenticationSASLContinue
*AuthenticationSASLFinal
AuthenticationResponseMessage : BackendMessage
AuthenticationResponseMessage : Message
AuthenticationSASL is a message sent from the backend indicating that SASL authentication is required.
AuthMechanisms []string
Backend identifies this message as an authentication response.
Backend identifies this message as sendable by the PostgreSQL backend.
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.
Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
MarshalJSON implements encoding/json.Marshaler.
*AuthenticationSASL : AuthenticationResponseMessage
*AuthenticationSASL : BackendMessage
*AuthenticationSASL : Message
AuthenticationSASL : encoding/json.Marshaler
AuthenticationSASLContinue is a message sent from the backend containing a SASL challenge.
Data []byte
Backend identifies this message as an authentication response.
Backend identifies this message as sendable by the PostgreSQL backend.
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.
Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
MarshalJSON implements encoding/json.Marshaler.
UnmarshalJSON implements encoding/json.Unmarshaler.
*AuthenticationSASLContinue : AuthenticationResponseMessage
*AuthenticationSASLContinue : BackendMessage
*AuthenticationSASLContinue : Message
AuthenticationSASLContinue : encoding/json.Marshaler
*AuthenticationSASLContinue : encoding/json.Unmarshaler
func github.com/jackc/pgx/v5/pgconn.(*PgConn).rxSASLContinue() (*AuthenticationSASLContinue, error)
AuthenticationSASLFinal is a message sent from the backend indicating a SASL authentication has completed.
Data []byte
Backend identifies this message as an authentication response.
Backend identifies this message as sendable by the PostgreSQL backend.
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.
Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
MarshalJSON implements encoding/json.Unmarshaler.
UnmarshalJSON implements encoding/json.Unmarshaler.
*AuthenticationSASLFinal : AuthenticationResponseMessage
*AuthenticationSASLFinal : BackendMessage
*AuthenticationSASLFinal : Message
AuthenticationSASLFinal : encoding/json.Marshaler
*AuthenticationSASLFinal : encoding/json.Unmarshaler
func github.com/jackc/pgx/v5/pgconn.(*PgConn).rxSASLFinal() (*AuthenticationSASLFinal, error)
Backend acts as a server for the PostgreSQL wire protocol version 3.
_close Close
authType uint32
Frontend message flyweights
bodyLen int
cancelRequest CancelRequest
copyData CopyData
copyDone CopyDone
copyFail CopyFail
cr *chunkReader
describe Describe
encodeError error
execute Execute
flush Flush
functionCall FunctionCall
gssEncRequest GSSEncRequest
// maxBodyLen is the maximum length of a message body in octets. If a message body exceeds this length, Receive will return an error.
msgType byte
parse Parse
partialMsg bool
query Query
sslRequest SSLRequest
startupMessage StartupMessage
sync Sync
terminate Terminate
tracer is used to trace messages when Send or Receive is called. This means an outbound message is traced
before it is actually transmitted (i.e. before Flush).
w io.Writer
wbuf []byte
Flush writes any pending messages to the frontend (i.e. the client).
Receive receives a message from the frontend. The returned message is only valid until the next call to Receive.
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.
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.
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.
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.
Trace starts tracing the message traffic to w. It writes in a similar format to that produced by the libpq function
PQtrace.
Untrace stops tracing.
func NewBackend(r io.Reader, w io.Writer) *Backend
ProcessID uint32
SecretKey []byte
Backend identifies this message as sendable by the PostgreSQL backend.
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.
Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
MarshalJSON implements encoding/json.Marshaler.
UnmarshalJSON implements encoding/json.Unmarshaler.
*BackendKeyData : BackendMessage
*BackendKeyData : Message
BackendKeyData : encoding/json.Marshaler
*BackendKeyData : encoding/json.Unmarshaler
BackendMessage is a message sent by the backend (i.e. the server).
// no-op method to distinguish frontend from backend methods
Decode is allowed and expected to retain a reference to data after
returning (unlike encoding.BinaryUnmarshaler).
Encode appends itself to dst and returns the new buffer.
*AuthenticationCleartextPassword
*AuthenticationGSS
*AuthenticationGSSContinue
*AuthenticationMD5Password
*AuthenticationOk
AuthenticationResponseMessage (interface)
*AuthenticationSASL
*AuthenticationSASLContinue
*AuthenticationSASLFinal
*BackendKeyData
*BindComplete
*CloseComplete
*CommandComplete
*CopyBothResponse
*CopyData
*CopyDone
*CopyInResponse
*CopyOutResponse
*DataRow
*EmptyQueryResponse
*ErrorResponse
*FunctionCallResponse
*NegotiateProtocolVersion
*NoData
*NoticeResponse
*NotificationResponse
*ParameterDescription
*ParameterStatus
*ParseComplete
*PortalSuspended
*ReadyForQuery
*RowDescription
BackendMessage : Message
func (*Frontend).Receive() (BackendMessage, error)
func github.com/jackc/pgx/v5/pgconn.(*PgConn).ReceiveMessage(ctx context.Context) (BackendMessage, error)
func (*Frontend).findAuthenticationMessageType(src []byte) (BackendMessage, error)
func github.com/jackc/pgx/v5/pgconn.(*MultiResultReader).receiveMessage() (BackendMessage, error)
func github.com/jackc/pgx/v5/pgconn.(*PgConn).peekMessage() (BackendMessage, error)
func github.com/jackc/pgx/v5/pgconn.(*PgConn).receiveMessage() (BackendMessage, error)
func github.com/jackc/pgx/v5/pgconn.(*Pipeline).receiveMessage() (BackendMessage, error)
func github.com/jackc/pgx/v5/pgconn.(*ResultReader).receiveMessage() (msg BackendMessage, err error)
func (*Backend).Send(msg BackendMessage)
func github.com/jackc/pgx/v5/pgconn.(*Pipeline).handleUnexpectedMessage(errStr string, msg BackendMessage) error
( BigEndianBuf) Int16(n int16) []byte
( BigEndianBuf) Int32(n int32) []byte
( BigEndianBuf) Int64(n int64) []byte
( BigEndianBuf) Uint16(n uint16) []byte
( BigEndianBuf) Uint32(n uint32) []byte
DestinationPortal string
ParameterFormatCodes []int16
Parameters [][]byte
PreparedStatement string
ResultFormatCodes []int16
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.
Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
Frontend identifies this message as sendable by a PostgreSQL frontend.
MarshalJSON implements encoding/json.Marshaler.
UnmarshalJSON implements encoding/json.Unmarshaler.
*Bind : FrontendMessage
*Bind : Message
Bind : encoding/json.Marshaler
*Bind : encoding/json.Unmarshaler
func (*Frontend).SendBind(msg *Bind)
Backend identifies this message as sendable by the PostgreSQL backend.
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.
Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
MarshalJSON implements encoding/json.Marshaler.
*BindComplete : BackendMessage
*BindComplete : Message
BindComplete : encoding/json.Marshaler
ProcessID uint32
SecretKey []byte
(*CancelRequest) Decode(src []byte) error
Encode encodes src into dst. dst will include the 4 byte message length.
Frontend identifies this message as sendable by a PostgreSQL frontend.
MarshalJSON implements encoding/json.Marshaler.
UnmarshalJSON implements encoding/json.Unmarshaler.
*CancelRequest : FrontendMessage
*CancelRequest : Message
CancelRequest : encoding/json.Marshaler
*CancelRequest : encoding/json.Unmarshaler
Name string
// 'S' = prepared statement, 'P' = portal
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.
Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
Frontend identifies this message as sendable by a PostgreSQL frontend.
MarshalJSON implements encoding/json.Marshaler.
UnmarshalJSON implements encoding/json.Unmarshaler.
*Close : FrontendMessage
*Close : Message
Close : encoding/json.Marshaler
*Close : encoding/json.Unmarshaler
func (*Frontend).SendClose(msg *Close)
Backend identifies this message as sendable by the PostgreSQL backend.
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.
Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
MarshalJSON implements encoding/json.Marshaler.
*CloseComplete : BackendMessage
*CloseComplete : Message
CloseComplete : encoding/json.Marshaler
CommandTag []byte
Backend identifies this message as sendable by the PostgreSQL backend.
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.
Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
MarshalJSON implements encoding/json.Marshaler.
UnmarshalJSON implements encoding/json.Unmarshaler.
*CommandComplete : BackendMessage
*CommandComplete : Message
CommandComplete : encoding/json.Marshaler
*CommandComplete : encoding/json.Unmarshaler
ColumnFormatCodes []uint16
OverallFormat byte
Backend identifies this message as sendable by the PostgreSQL backend.
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.
Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
MarshalJSON implements encoding/json.Marshaler.
UnmarshalJSON implements encoding/json.Unmarshaler.
*CopyBothResponse : BackendMessage
*CopyBothResponse : Message
CopyBothResponse : encoding/json.Marshaler
*CopyBothResponse : encoding/json.Unmarshaler
Data []byte
Backend identifies this message as sendable by the PostgreSQL backend.
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.
Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
Frontend identifies this message as sendable by a PostgreSQL frontend.
MarshalJSON implements encoding/json.Marshaler.
UnmarshalJSON implements encoding/json.Unmarshaler.
*CopyData : BackendMessage
*CopyData : FrontendMessage
*CopyData : Message
CopyData : encoding/json.Marshaler
*CopyData : encoding/json.Unmarshaler
Backend identifies this message as sendable by the PostgreSQL backend.
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.
Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
Frontend identifies this message as sendable by a PostgreSQL frontend.
MarshalJSON implements encoding/json.Marshaler.
*CopyDone : BackendMessage
*CopyDone : FrontendMessage
*CopyDone : Message
CopyDone : encoding/json.Marshaler
Message string
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.
Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
Frontend identifies this message as sendable by a PostgreSQL frontend.
MarshalJSON implements encoding/json.Marshaler.
*CopyFail : FrontendMessage
*CopyFail : Message
CopyFail : encoding/json.Marshaler
ColumnFormatCodes []uint16
OverallFormat byte
Backend identifies this message as sendable by the PostgreSQL backend.
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.
Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
MarshalJSON implements encoding/json.Marshaler.
UnmarshalJSON implements encoding/json.Unmarshaler.
*CopyInResponse : BackendMessage
*CopyInResponse : Message
CopyInResponse : encoding/json.Marshaler
*CopyInResponse : encoding/json.Unmarshaler
ColumnFormatCodes []uint16
OverallFormat byte
(*CopyOutResponse) Backend()
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.
Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
MarshalJSON implements encoding/json.Marshaler.
UnmarshalJSON implements encoding/json.Unmarshaler.
*CopyOutResponse : BackendMessage
*CopyOutResponse : Message
CopyOutResponse : encoding/json.Marshaler
*CopyOutResponse : encoding/json.Unmarshaler
Values [][]byte
Backend identifies this message as sendable by the PostgreSQL backend.
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.
Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
MarshalJSON implements encoding/json.Marshaler.
UnmarshalJSON implements encoding/json.Unmarshaler.
*DataRow : BackendMessage
*DataRow : Message
DataRow : encoding/json.Marshaler
*DataRow : encoding/json.Unmarshaler
Name string
// 'S' = prepared statement, 'P' = portal
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.
Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
Frontend identifies this message as sendable by a PostgreSQL frontend.
MarshalJSON implements encoding/json.Marshaler.
UnmarshalJSON implements encoding/json.Unmarshaler.
*Describe : FrontendMessage
*Describe : Message
Describe : encoding/json.Marshaler
*Describe : encoding/json.Unmarshaler
func (*Frontend).SendDescribe(msg *Describe)
Backend identifies this message as sendable by the PostgreSQL backend.
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.
Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
MarshalJSON implements encoding/json.Marshaler.
*EmptyQueryResponse : BackendMessage
*EmptyQueryResponse : Message
EmptyQueryResponse : encoding/json.Marshaler
Code string
ColumnName string
ConstraintName string
DataTypeName string
Detail string
File string
Hint string
InternalPosition int32
InternalQuery string
Line int32
Message string
Position int32
Routine string
SchemaName string
Severity string
// only in 9.6 and greater
TableName string
UnknownFields map[byte]string
Where string
Backend identifies this message as sendable by the PostgreSQL backend.
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.
Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
MarshalJSON implements encoding/json.Marshaler.
UnmarshalJSON implements encoding/json.Unmarshaler.
(*ErrorResponse) appendFields(dst []byte) []byte
*ErrorResponse : BackendMessage
*ErrorResponse : Message
ErrorResponse : encoding/json.Marshaler
*ErrorResponse : encoding/json.Unmarshaler
func github.com/jackc/pgx/v5/pgconn.ErrorResponseToPgError(msg *ErrorResponse) *pgconn.PgError
ActualBodyLen int
MaxExpectedBodyLen int
(*ExceededMaxBodyLenErr) Error() string
*ExceededMaxBodyLenErr : error
MaxRows uint32
Portal string
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.
Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
Frontend identifies this message as sendable by a PostgreSQL frontend.
MarshalJSON implements encoding/json.Marshaler.
*Execute : FrontendMessage
*Execute : Message
Execute : encoding/json.Marshaler
func (*Frontend).SendExecute(msg *Execute)
DataTypeOID uint32
DataTypeSize int16
Format int16
Name []byte
TableAttributeNumber uint16
TableOID uint32
TypeModifier int32
MarshalJSON implements encoding/json.Marshaler.
FieldDescription : encoding/json.Marshaler
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.
Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
Frontend identifies this message as sendable by a PostgreSQL frontend.
MarshalJSON implements encoding/json.Marshaler.
*Flush : FrontendMessage
*Flush : Message
Flush : encoding/json.Marshaler
Frontend acts as a client for the PostgreSQL wire protocol version 3.
authType uint32
authenticationCleartextPassword AuthenticationCleartextPassword
authenticationGSS AuthenticationGSS
authenticationGSSContinue AuthenticationGSSContinue
authenticationMD5Password AuthenticationMD5Password
Backend message flyweights
authenticationSASL AuthenticationSASL
authenticationSASLContinue AuthenticationSASLContinue
authenticationSASLFinal AuthenticationSASLFinal
backendKeyData BackendKeyData
bindComplete BindComplete
bodyLen int
closeComplete CloseComplete
commandComplete CommandComplete
copyBothResponse CopyBothResponse
copyData CopyData
copyDone CopyDone
copyInResponse CopyInResponse
copyOutResponse CopyOutResponse
cr *chunkReader
dataRow DataRow
emptyQueryResponse EmptyQueryResponse
encodeError error
errorResponse ErrorResponse
functionCallResponse FunctionCallResponse
// maxBodyLen is the maximum length of a message body in octets. If a message body exceeds this length, Receive will return an error.
msgType byte
negotiateProtocolVersion NegotiateProtocolVersion
noData NoData
noticeResponse NoticeResponse
notificationResponse NotificationResponse
parameterDescription ParameterDescription
parameterStatus ParameterStatus
parseComplete ParseComplete
partialMsg bool
portalSuspended PortalSuspended
readyForQuery ReadyForQuery
rowDescription RowDescription
tracer is used to trace messages when Send or Receive is called. This means an outbound message is traced
before it is actually transmitted (i.e. before Flush). It is safe to change this variable when the Frontend is
idle. Setting and unsetting tracer provides equivalent functionality to PQtrace and PQuntrace in libpq.
w io.Writer
wbuf []byte
Flush writes any pending messages to the backend (i.e. the server).
GetAuthType returns the authType used in the current state of the frontend.
See SetAuthType for more information.
(*Frontend) ReadBufferLen() int
Receive receives a message from the backend. The returned message is only valid until the next call to Receive.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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 a corrupted server that sends
messages with incorrect length, which can cause memory exhaustion.
The default value is 0.
If maxBodyLen is 0, then no maximum is enforced.
Trace starts tracing the message traffic to w. It writes in a similar format to that produced by the libpq function
PQtrace.
Untrace stops tracing.
(*Frontend) findAuthenticationMessageType(src []byte) (BackendMessage, error)
func NewFrontend(r io.Reader, w io.Writer) *Frontend
func github.com/jackc/pgx/v5/pgconn.(*PgConn).Frontend() *Frontend
FrontendMessage is a message sent by the frontend (i.e. the client).
Decode is allowed and expected to retain a reference to data after
returning (unlike encoding.BinaryUnmarshaler).
Encode appends itself to dst and returns the new buffer.
// no-op method to distinguish frontend from backend methods
*Bind
*CancelRequest
*Close
*CopyData
*CopyDone
*CopyFail
*Describe
*Execute
*Flush
*FunctionCall
*GSSEncRequest
*GSSResponse
*Parse
*PasswordMessage
*Query
*SASLInitialResponse
*SASLResponse
*SSLRequest
*StartupMessage
*Sync
*Terminate
FrontendMessage : Message
func (*Backend).Receive() (FrontendMessage, error)
func (*Backend).ReceiveStartupMessage() (FrontendMessage, error)
func (*Frontend).Send(msg FrontendMessage)
ArgFormatCodes []uint16
Arguments [][]byte
Function uint32
ResultFormatCode uint16
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.
Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
Frontend identifies this message as sendable by a PostgreSQL frontend.
*FunctionCall : FrontendMessage
*FunctionCall : Message
Result []byte
Backend identifies this message as sendable by the PostgreSQL backend.
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.
Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
MarshalJSON implements encoding/json.Marshaler.
UnmarshalJSON implements encoding/json.Unmarshaler.
*FunctionCallResponse : BackendMessage
*FunctionCallResponse : Message
FunctionCallResponse : encoding/json.Marshaler
*FunctionCallResponse : encoding/json.Unmarshaler
(*GSSEncRequest) Decode(src []byte) error
Encode encodes src into dst. dst will include the 4 byte message length.
Frontend identifies this message as sendable by a PostgreSQL frontend.
MarshalJSON implements encoding/json.Marshaler.
*GSSEncRequest : FrontendMessage
*GSSEncRequest : Message
GSSEncRequest : encoding/json.Marshaler
Data []byte
(*GSSResponse) Decode(data []byte) error
(*GSSResponse) Encode(dst []byte) ([]byte, error)
Frontend identifies this message as sendable by a PostgreSQL frontend.
MarshalJSON implements encoding/json.Marshaler.
UnmarshalJSON implements encoding/json.Unmarshaler.
*GSSResponse : FrontendMessage
*GSSResponse : Message
*GSSResponse : encoding/json.Marshaler
*GSSResponse : encoding/json.Unmarshaler
Message is the interface implemented by an object that can decode and encode
a particular PostgreSQL message.
Decode is allowed and expected to retain a reference to data after
returning (unlike encoding.BinaryUnmarshaler).
Encode appends itself to dst and returns the new buffer.
*AuthenticationCleartextPassword
*AuthenticationGSS
*AuthenticationGSSContinue
*AuthenticationMD5Password
*AuthenticationOk
AuthenticationResponseMessage (interface)
*AuthenticationSASL
*AuthenticationSASLContinue
*AuthenticationSASLFinal
*BackendKeyData
BackendMessage (interface)
*Bind
*BindComplete
*CancelRequest
*Close
*CloseComplete
*CommandComplete
*CopyBothResponse
*CopyData
*CopyDone
*CopyFail
*CopyInResponse
*CopyOutResponse
*DataRow
*Describe
*EmptyQueryResponse
*ErrorResponse
*Execute
*Flush
FrontendMessage (interface)
*FunctionCall
*FunctionCallResponse
*GSSEncRequest
*GSSResponse
*NegotiateProtocolVersion
*NoData
*NoticeResponse
*NotificationResponse
*ParameterDescription
*ParameterStatus
*Parse
*ParseComplete
*PasswordMessage
*PortalSuspended
*Query
*ReadyForQuery
*RowDescription
*SASLInitialResponse
*SASLResponse
*SSLRequest
*StartupMessage
*Sync
*Terminate
NewestMinorProtocol uint32
UnrecognizedOptions []string
Backend identifies this message as sendable by the PostgreSQL backend.
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.
Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
MarshalJSON implements encoding/json.Marshaler.
UnmarshalJSON implements encoding/json.Unmarshaler.
*NegotiateProtocolVersion : BackendMessage
*NegotiateProtocolVersion : Message
NegotiateProtocolVersion : encoding/json.Marshaler
*NegotiateProtocolVersion : encoding/json.Unmarshaler
Backend identifies this message as sendable by the PostgreSQL backend.
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.
Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
MarshalJSON implements encoding/json.Marshaler.
*NoData : BackendMessage
*NoData : Message
NoData : encoding/json.Marshaler
Code string
ColumnName string
ConstraintName string
DataTypeName string
Detail string
File string
Hint string
InternalPosition int32
InternalQuery string
Line int32
Message string
Position int32
Routine string
SchemaName string
Severity string
// only in 9.6 and greater
TableName string
UnknownFields map[byte]string
Where string
Backend identifies this message as sendable by the PostgreSQL backend.
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.
Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
*NoticeResponse : BackendMessage
*NoticeResponse : Message
func github.com/jackc/pgx/v5/pgconn.noticeResponseToNotice(msg *NoticeResponse) *pgconn.Notice
Channel string
PID uint32
Payload string
Backend identifies this message as sendable by the PostgreSQL backend.
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.
Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
MarshalJSON implements encoding/json.Marshaler.
*NotificationResponse : BackendMessage
*NotificationResponse : Message
NotificationResponse : encoding/json.Marshaler
ParameterOIDs []uint32
Backend identifies this message as sendable by the PostgreSQL backend.
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.
Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
MarshalJSON implements encoding/json.Marshaler.
*ParameterDescription : BackendMessage
*ParameterDescription : Message
ParameterDescription : encoding/json.Marshaler
Name string
Value string
Backend identifies this message as sendable by the PostgreSQL backend.
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.
Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
MarshalJSON implements encoding/json.Marshaler.
*ParameterStatus : BackendMessage
*ParameterStatus : Message
ParameterStatus : encoding/json.Marshaler
Name string
ParameterOIDs []uint32
Query string
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.
Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
Frontend identifies this message as sendable by a PostgreSQL frontend.
MarshalJSON implements encoding/json.Marshaler.
*Parse : FrontendMessage
*Parse : Message
Parse : encoding/json.Marshaler
func (*Frontend).SendParse(msg *Parse)
Backend identifies this message as sendable by the PostgreSQL backend.
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.
Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
MarshalJSON implements encoding/json.Marshaler.
*ParseComplete : BackendMessage
*ParseComplete : Message
ParseComplete : encoding/json.Marshaler
Password string
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.
Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
Frontend identifies this message as sendable by a PostgreSQL frontend.
InitialResponse identifies this message as an authentication response.
MarshalJSON implements encoding/json.Marshaler.
*PasswordMessage : FrontendMessage
*PasswordMessage : Message
PasswordMessage : encoding/json.Marshaler
Backend identifies this message as sendable by the PostgreSQL backend.
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.
Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
MarshalJSON implements encoding/json.Marshaler.
*PortalSuspended : BackendMessage
*PortalSuspended : Message
PortalSuspended : encoding/json.Marshaler
String string
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.
Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
Frontend identifies this message as sendable by a PostgreSQL frontend.
MarshalJSON implements encoding/json.Marshaler.
*Query : FrontendMessage
*Query : Message
Query : encoding/json.Marshaler
func (*Frontend).SendQuery(msg *Query)
TxStatus byte
Backend identifies this message as sendable by the PostgreSQL backend.
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.
Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
MarshalJSON implements encoding/json.Marshaler.
UnmarshalJSON implements encoding/json.Unmarshaler.
*ReadyForQuery : BackendMessage
*ReadyForQuery : Message
ReadyForQuery : encoding/json.Marshaler
*ReadyForQuery : encoding/json.Unmarshaler
Fields []FieldDescription
Backend identifies this message as sendable by the PostgreSQL backend.
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.
Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
MarshalJSON implements encoding/json.Marshaler.
UnmarshalJSON implements encoding/json.Unmarshaler.
*RowDescription : BackendMessage
*RowDescription : Message
RowDescription : encoding/json.Marshaler
*RowDescription : encoding/json.Unmarshaler
func github.com/jackc/pgx/v5/pgconn.convertRowDescription(dst []pgconn.FieldDescription, rd *RowDescription)
AuthMechanism string
Data []byte
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.
Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
Frontend identifies this message as sendable by a PostgreSQL frontend.
MarshalJSON implements encoding/json.Marshaler.
UnmarshalJSON implements encoding/json.Unmarshaler.
*SASLInitialResponse : FrontendMessage
*SASLInitialResponse : Message
SASLInitialResponse : encoding/json.Marshaler
*SASLInitialResponse : encoding/json.Unmarshaler
Data []byte
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.
Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
Frontend identifies this message as sendable by a PostgreSQL frontend.
MarshalJSON implements encoding/json.Marshaler.
UnmarshalJSON implements encoding/json.Unmarshaler.
*SASLResponse : FrontendMessage
*SASLResponse : Message
SASLResponse : encoding/json.Marshaler
*SASLResponse : encoding/json.Unmarshaler
(*SSLRequest) Decode(src []byte) error
Encode encodes src into dst. dst will include the 4 byte message length.
Frontend identifies this message as sendable by a PostgreSQL frontend.
MarshalJSON implements encoding/json.Marshaler.
*SSLRequest : FrontendMessage
*SSLRequest : Message
SSLRequest : encoding/json.Marshaler
Parameters map[string]string
ProtocolVersion uint32
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.
Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
Frontend identifies this message as sendable by a PostgreSQL frontend.
MarshalJSON implements encoding/json.Marshaler.
*StartupMessage : FrontendMessage
*StartupMessage : Message
StartupMessage : encoding/json.Marshaler
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.
Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
Frontend identifies this message as sendable by a PostgreSQL frontend.
MarshalJSON implements encoding/json.Marshaler.
*Sync : FrontendMessage
*Sync : Message
Sync : encoding/json.Marshaler
func (*Frontend).SendSync(msg *Sync)
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.
Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
Frontend identifies this message as sendable by a PostgreSQL frontend.
MarshalJSON implements encoding/json.Marshaler.
*Terminate : FrontendMessage
*Terminate : Message
Terminate : encoding/json.Marshaler
TracerOptions controls tracing behavior. It is roughly equivalent to the libpq function PQsetTraceFlags.
RegressMode redacts fields that may be vary between executions.
SuppressTimestamps prevents printing of timestamps.
func (*Backend).Trace(w io.Writer, options TracerOptions)
func (*Frontend).Trace(w io.Writer, options TracerOptions)
Package-Level Functions (total 9, in which 2 are exported)
NewBackend creates a new Backend.
NewFrontend creates a new Frontend.
Package-Level Constants (total 21, in which 15 are exported)
Authentication message type constants.
See src/include/libpq/pqcomm.h for all
constants.
Authentication message type constants.
See src/include/libpq/pqcomm.h for all
constants.
Authentication message type constants.
See src/include/libpq/pqcomm.h for all
constants.
Authentication message type constants.
See src/include/libpq/pqcomm.h for all
constants.
Authentication message type constants.
See src/include/libpq/pqcomm.h for all
constants.
Authentication message type constants.
See src/include/libpq/pqcomm.h for all
constants.
Authentication message type constants.
See src/include/libpq/pqcomm.h for all
constants.
Authentication message type constants.
See src/include/libpq/pqcomm.h for all
constants.
Authentication message type constants.
See src/include/libpq/pqcomm.h for all
constants.
Authentication message type constants.
See src/include/libpq/pqcomm.h for all
constants.
const BinaryFormat = 1 const ProtocolVersion30 = 196608 // 3.0 const ProtocolVersion32 = 196610 // 3.2 const ProtocolVersionNumber = 196608 // Default is still 3.0 const TextFormat = 0 The pages are generated with Golds v0.7.6. (GOOS=linux GOARCH=amd64)