pg

package
v0.0.0-...-d5c0da9 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const AuthenticationRequestMessageType = 'R'

AuthenticationRequestMessageType identifies authentication request message.

View Source
const BackendKeyDataMessageType = 'K'

BackendKeyDataMessageType identifies BackendKeyDataMessage message.

View Source
const CommandCompleteMessageType = 'C'

CommandCompleteMessageType identifies CommandCompleteMessage message.

View Source
const DataRowMessageType = 'D'

DataRowMessageType identifies DataRowMessage message.

View Source
const DefaultProtocolVersion = 196608

DefaultProtocolVersion is a default protocol version of PostgreSQL since version 7.

View Source
const EmptyQueryResponseMessageType = 'I'

EmptyQueryResponseMessageType identifies EmptyQueryResponseMessage message.

View Source
const ErrorResponseMessageType = 'E'

ErrorResponseMessageType identifies ErrorResponseMessageType message.

View Source
const NegotiateProtocolVersionMessageType = 'v'

NegotiateProtocolVersionMessageType identifies NegotiateProtocolVersionMessage message.

View Source
const NoticeResponseMessageType = 'N'

NoticeResponseMessageType identifies NoticeResponseMessageType message.

View Source
const ParameterStatusMessageType = 'S'

QueryMessageType identifies ParameterStatusMessage message.

View Source
const PasswordMessageType = 'p'

PasswordMessageType identifies PasswordMessage message.

View Source
const QueryMessageType = 'Q'

QueryMessageType identifies QueryMessage message.

View Source
const ReadyForQueryMessageType = 'Z'

ReadyForQueryMessageType identifies ReadyForQueryMessage message.

View Source
const RowDescriptionMessageType = 'T'

RowDescriptionMessageType identifies RowDescriptionMessage message.

View Source
const SSLRequestMagic = 80877103

SSLRequestMagic is magic protocol version that client is using to request a SSL session.

View Source
const TerminateMessageType = 'X'

TerminateMessageType identifies TerminateMessage message.

Variables

View Source
var (
	// ErrMalformedMessage is returned when message cannot be parsed.
	ErrMalformedMessage = errors.New("pg: malformed message")
)
View Source
var (
	// ErrunsupportedAuthenticationRequest is returned when ParseAuthenticationRequestMessage
	// cannot handle unknown auth status.
	ErrunsupportedAuthenticationRequest = errors.New("pg: unsupported auth request from a backend")
)

Functions

This section is empty.

Types

type AuthenticationCleartextPasswordMessage

type AuthenticationCleartextPasswordMessage struct{}

AuthenticationCleartextPasswordMessage is sent by a backend when a clear-text password is required.

func (*AuthenticationCleartextPasswordMessage) Frame

Frame serializes the message into a network frame.

type AuthenticationGSSContinueMessage

type AuthenticationGSSContinueMessage struct {
	// GSSAPI or SSPI authentication data.
	Data []byte
}

AuthenticationGSSContinueMessage is sent by a frontend to authenticate with GSSAPI or SSPI.

func (*AuthenticationGSSContinueMessage) Frame

Frame serializes the message into a network frame.

type AuthenticationGSSMessage

type AuthenticationGSSMessage struct{}

AuthenticationGSSMessage is sent by a backend when GSSAPI authentication is required.

func (*AuthenticationGSSMessage) Frame

func (m *AuthenticationGSSMessage) Frame() Frame

Frame serializes the message into a network frame.

type AuthenticationKerberosV5Message

type AuthenticationKerberosV5Message struct{}

AuthenticationKerberosV5Message is sent by a backend when Kerberos V5 authentication is required.

func (*AuthenticationKerberosV5Message) Frame

Frame serializes the message into a network frame.

type AuthenticationMD5PasswordMessage

type AuthenticationMD5PasswordMessage struct {
	// The salt to use when encrypting the password.
	Salt [4]byte
}

AuthenticationMD5PasswordMessage is sent by a backend when an MD5-encrypted password is required.

func (*AuthenticationMD5PasswordMessage) Frame

Frame serializes the message into a network frame.

type AuthenticationOkMessage

type AuthenticationOkMessage struct{}

AuthenticationOkMessage is sent by a backend when the authentication was successful.

func (*AuthenticationOkMessage) Frame

func (m *AuthenticationOkMessage) Frame() Frame

Frame serializes the message into a network frame.

type AuthenticationRequestMessage

type AuthenticationRequestMessage interface {
	Message
}

AuthenticationRequestMessage is one of backend authentication requests.

func ParseAuthenticationRequestMessage

func ParseAuthenticationRequestMessage(frame Frame) (AuthenticationRequestMessage, error)

ParseAuthenticationRequestMessage parses authentication request from a network frame.

type AuthenticationSCMCredentialMessage

type AuthenticationSCMCredentialMessage struct{}

AuthenticationSCMCredentialMessage is sent by a backend when an SCM credentials message is required.

func (*AuthenticationSCMCredentialMessage) Frame

Frame serializes the message into a network frame.

type AuthenticationSSPIMessage

type AuthenticationSSPIMessage struct{}

AuthenticationSSPIMessage is sent by a backend when SSPI authentication is required.

func (*AuthenticationSSPIMessage) Frame

func (m *AuthenticationSSPIMessage) Frame() Frame

Frame serializes the message into a network frame.

type BackendKeyDataMessage

type BackendKeyDataMessage struct {
	// The process ID of this backend.
	ProcessID int32

	// The secret key of this backend.
	Key int32
}

BackendKeyDataMessage is sent by a backend to tell frontend about secret-key data. The frontend must save these values if it wishes to be able to issue CancelRequestMessage later.

func ParseBackendKeyDataMessage

func ParseBackendKeyDataMessage(frame Frame) (*BackendKeyDataMessage, error)

ParseBackendKeyDataMessage parses BackendKeyDataMessage from a network frame.

func (*BackendKeyDataMessage) Frame

func (m *BackendKeyDataMessage) Frame() Frame

Frame serializes the message into a network frame.

type CommandCompleteMessage

type CommandCompleteMessage struct {
	// The command tag. This is usually a single word that identifies which SQL command was completed.
	Tag string
}

CommandCompleteMessage sent by a backend to notify frontend about successful command execution.

func ParseCommandCompleteMessage

func ParseCommandCompleteMessage(frame Frame) (*CommandCompleteMessage, error)

ParseCommandCompleteMessage parses CommandCompleteMessage from a network frame.

func (*CommandCompleteMessage) Frame

func (m *CommandCompleteMessage) Frame() Frame

Frame serializes the message into a network frame.

type Conn

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

Conn is a wrapper around net.Conn that allows us to send/receive PostgreSQL messages.

func NewConn

func NewConn(conn net.Conn) *Conn

NewConn initializes new pg.Conn.

func (*Conn) Close

func (h *Conn) Close() error

Close closes the underlying net.Conn.

func (*Conn) RecvMessage

func (h *Conn) RecvMessage() (Message, error)

RecvMessage receives PostgreSQL message from the underlying network connection.

func (*Conn) RecvStartupMessage

func (h *Conn) RecvStartupMessage() (*StartupMessage, error)

RecvStartupMessage receives StartupMessage from the underlying network connection.

func (*Conn) SendByte

func (h *Conn) SendByte(c byte) error

SendByte sends given byte over the network.

func (*Conn) SendMessage

func (h *Conn) SendMessage(msg Message) error

SendMessage sends given message over the network.

func (*Conn) Unwrap

func (h *Conn) Unwrap() net.Conn

Unwrap returns the underlying net.Conn.

type ConnectionParams

type ConnectionParams map[string]string

ConnectionParams is a map containing PostgreSQL connection parameters.

func ParseDatabaseURI

func ParseDatabaseURI(connString string) (ConnectionParams, error)

ParseDatabaseURL parses given PostgreSQL connection string in URI format and returns connection params as a map. See the documentation: https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING

type DataFormat

type DataFormat int16

DataFormat is a code for PostgreSQL data format.

const (
	DataFormatText   DataFormat = 0 // Plain text
	DataFormatBinary DataFormat = 1 // Binary representation
)

type DataRowMessage

type DataRowMessage struct {
	// Row raw values. To decode them you need RowDescriptionMessage.
	Values [][]byte
}

DataRowMessage represents a single data row sent by a backend as a query result. RowDescriptionMessage always precedes the DataRowMessage.

func ParseDataRowMessage

func ParseDataRowMessage(frame Frame) (*DataRowMessage, error)

ParseRowDescriptionMessage parses RowDescriptionMessage from a network frame.

func (*DataRowMessage) Frame

func (m *DataRowMessage) Frame() Frame

Frame serializes the message into a network frame.

type EmptyQueryResponseMessage

type EmptyQueryResponseMessage struct{}

EmptyQueryResponseMessage is sent by a backend as a response to an empty query string.

func ParseEmptyQueryResponseMessage

func ParseEmptyQueryResponseMessage(frame Frame) (*EmptyQueryResponseMessage, error)

ParseEmptyQueryResponseMessage parses EmptyQueryResponseMessage from a network frame.

func (*EmptyQueryResponseMessage) Frame

func (m *EmptyQueryResponseMessage) Frame() Frame

Frame serializes the message into a network frame.

type ErrorResponseMessage

type ErrorResponseMessage struct {
	// One of more fields with error info
	Fields []*MessageField
}

ErrorResponseMessage is sent by a backend when an error occurs.

func ParseErrorResponseMessage

func ParseErrorResponseMessage(frame Frame) (*ErrorResponseMessage, error)

ParseErrorResponseMessage parses ErrorResponseMessage from a network frame.

func (*ErrorResponseMessage) Frame

func (m *ErrorResponseMessage) Frame() Frame

Frame serializes the message into a network frame.

type FieldDescriptor

type FieldDescriptor struct {
	// The field name.
	Name string

	// If the field can be identified as a column of a specific table, the object ID of the table; otherwise zero.
	TableOID oid.Oid

	// If the field can be identified as a column of a specific table, the attribute number of the column; otherwise zero.
	ColumnIndex int16

	// The object ID of the field's data type.
	DataTypeOID oid.Oid

	// The data type size (see pg_type.typlen). Note that negative values denote variable-width types.
	DataTypeSize int16

	// The type modifier (see pg_attribute.atttypmod). The meaning of the modifier is type-specific.
	DataTypeModifier int32

	// The format code being used for the field. Currently will be zero (text) or one (binary). In a RowDescription
	// returned from the statement variant of Describe, the format code is not yet known and will always be zero.
	Format DataFormat
}

FieldDescriptor describes a field of a DataRow.

type Frame

type Frame interface {
	// MessageType returns this frame's message type.
	MessageType() byte

	// MessageBody returns message body bytes.
	MessageBody() []byte

	// Bytes returns raw bytes of the frame ready to be sent over the network.
	Bytes() []byte
}

A Frame is a raw PostgreSQL message sent/received over the network to/from client/DB. See https://www.postgresql.org/docs/9.6/protocol-overview.html#PROTOCOL-MESSAGE-CONCEPTS for details. All frame types must implement this interface.

type GenericMessage

type GenericMessage struct {
	Type byte   // Message type
	Body []byte // Message raw bytes
}

GenericMessage represents any PostgreSQL message that we don't want to process.

func ParseGenericMessage

func ParseGenericMessage(frame Frame) (*GenericMessage, error)

ParseGenericMessage parses GenericMessage from a network frame.

func (*GenericMessage) Frame

func (m *GenericMessage) Frame() Frame

Frame serializes the message into a network frame.

type Message

type Message interface {
	// Frame serializes the message into a network frame.
	Frame() Frame
}

Message is a PostgreSQL message that a client and a DB sending to each other.

type MessageField

type MessageField struct {
	// A code identifying the field type.
	Type MessageFieldType

	// The field value.
	Value string
}

MessageField is used by ErrorResponseMessage and NoticeResponseMessage to store information about error / warning context.

type MessageFieldType

type MessageFieldType byte

MessageFieldType identifies a field. Here are all known codes fo protocol v3: https://www.postgresql.org/docs/9.6/protocol-error-fields.html

const (
	// Severity: the field contents are ERROR, FATAL, or PANIC (in an error message), or WARNING, NOTICE, DEBUG, INFO, or LOG (in a notice message), or a localized translation of one of these. Always present.
	MessageFieldSeverityLocalized MessageFieldType = 'S'

	// Severity: the field contents are ERROR, FATAL, or PANIC (in an error message), or WARNING, NOTICE, DEBUG, INFO, or LOG (in a notice message). This is identical to the S field except that the contents are never localized. This is present only in messages generated by PostgreSQL versions 9.6 and later.
	MessageFieldSeverity MessageFieldType = 'V'

	// Code: the SQLSTATE code for the error (see Appendix A). Not localizable. Always present.
	MessageFieldCode MessageFieldType = 'C'

	// Message: the primary human-readable error message. This should be accurate but terse (typically one line). Always present.
	MessageFieldMessage MessageFieldType = 'M'

	// Detail: an optional secondary error message carrying more detail about the problem. Might run to multiple lines.
	MessageFieldDetail MessageFieldType = 'D'

	// Hint: an optional suggestion what to do about the problem. This is intended to differ from Detail in that it offers advice (potentially inappropriate) rather than hard facts. Might run to multiple lines.
	MessageFieldHint MessageFieldType = 'H'

	// Position: the field value is a decimal ASCII integer, indicating an error cursor position as an index into the original query string. The first character has index 1, and positions are measured in characters not bytes.
	MessageFieldPosition MessageFieldType = 'P'

	// Internal position: this is defined the same as the P field, but it is used when the cursor position refers to an internally generated command rather than the one submitted by the client. The q field will always appear when this field appears.
	MessageFieldInternalPosition MessageFieldType = 'p'

	// Internal query: the text of a failed internally-generated command. This could be, for example, a SQL query issued by a PL/pgSQL function.
	MessageFieldInternalQuery MessageFieldType = 'q'

	// Where: an indication of the context in which the error occurred. Presently this includes a call stack traceback of active procedural language functions and internally-generated queries. The trace is one entry per line, most recent first.
	MessageFieldWhere MessageFieldType = 'W'

	// Schema name: if the error was associated with a specific database object, the name of the schema containing that object, if any.
	MessageFieldSchema MessageFieldType = 's'

	// Table name: if the error was associated with a specific table, the name of the table. (Refer to the schema name field for the name of the table's schema.)
	MessageFieldTable MessageFieldType = 't'

	// Column name: if the error was associated with a specific table column, the name of the column. (Refer to the schema and table name fields to identify the table.)
	MessageFieldColumn MessageFieldType = 'c'

	// Data type name: if the error was associated with a specific data type, the name of the data type. (Refer to the schema name field for the name of the data type's schema.)
	MessageFieldDataType MessageFieldType = 'd'

	// Constraint name: if the error was associated with a specific constraint, the name of the constraint. Refer to fields listed above for the associated table or domain. (For this purpose, indexes are treated as constraints, even if they weren't created with constraint syntax.)
	MessageFieldConstraint MessageFieldType = 'n'

	// File: the file name of the source-code location where the error was reported.
	MessageFieldFile MessageFieldType = 'F'

	// Line: the line number of the source-code location where the error was reported.
	MessageFieldLine MessageFieldType = 'L'

	// Routine: the name of the source-code routine reporting the error.
	MessageFieldRoutine MessageFieldType = 'R'
)

nolint:lll

type NegotiateProtocolVersionMessage

type NegotiateProtocolVersionMessage struct {
	// Newest minor protocol version supported by the backend for the major protocol version requested by the frontend.
	SupportedProtocolVersion int32

	// List of protocol options not recognized by the backend.
	UnrecognizedOptions []string
}

NegotiateProtocolVersionMessage is sent by a backend when it does not support the minor protocol version requested by the frontend.

func ParseNegotiateProtocolVersionMessage

func ParseNegotiateProtocolVersionMessage(frame Frame) (*NegotiateProtocolVersionMessage, error)

ParseNegotiateProtocolVersionMessage parses NegotiateProtocolVersionMessage from a network frame.

func (*NegotiateProtocolVersionMessage) Frame

Frame serializes the message into a network frame.

type NoticeResponseMessage

type NoticeResponseMessage struct {
	// One of more fields with notice info
	Fields []*MessageField
}

NoticeResponseMessage is sent by a backend when some kind of non-critical warning occurs.

func ParseNoticeResponseMessage

func ParseNoticeResponseMessage(frame Frame) (*NoticeResponseMessage, error)

PnoticerrorResponseMessage parses NoticeResponseMessage from a network frame.

func (*NoticeResponseMessage) Frame

func (m *NoticeResponseMessage) Frame() Frame

Frame serializes the message into a network frame.

type ParameterStatusMessage

type ParameterStatusMessage struct {
	// The name of the run-time parameter being reported.
	Name string

	// The current value of the parameter.
	Value string
}

ParameterStatusMessage informs a frontend about the current (initial) setting of backend parameters.

func ParseParameterStatusMessage

func ParseParameterStatusMessage(frame Frame) (*ParameterStatusMessage, error)

ParseParameterStatusMessage parses ParameterStatusMessage from a network frame.

func (*ParameterStatusMessage) Frame

func (m *ParameterStatusMessage) Frame() Frame

Frame serializes the message into a network frame.

type PasswordMessage

type PasswordMessage struct {
	// The password (encrypted, if requested).
	Password string
}

PasswordMessage is sent by a frontend in response to authentication request.

func ParsePasswordMessage

func ParsePasswordMessage(frame Frame) (*PasswordMessage, error)

PasswordMessage parses PasswordMessage from a network frame.

func (*PasswordMessage) Frame

func (m *PasswordMessage) Frame() Frame

Frame serializes the message into a network frame.

type QueryMessage

type QueryMessage struct {
	// SQL query
	Query string
}

QueryMessage represents a simple SQL query sent by a frontend.

func ParseQueryMessage

func ParseQueryMessage(frame Frame) (*QueryMessage, error)

ParseQueryMessage parses QueryMessage from a network frame.

func (*QueryMessage) Frame

func (m *QueryMessage) Frame() Frame

Frame serializes the message into a network frame.

type ReadBuffer

type ReadBuffer []byte

ReadBuffer provides bufio.Scanner-like API to decode PG data types described here: https://www.postgresql.org/docs/9.6/protocol-message-types.html

NB: buffer is read-only! You cannot reset the state!

func (*ReadBuffer) Inspect

func (b *ReadBuffer) Inspect() string

Inspect returns content of the buffer as a hex dump for debug purposes.

func (*ReadBuffer) Len

func (b *ReadBuffer) Len() int

Len returns the number of bytes left in the buffer.

func (*ReadBuffer) ReadByte

func (b *ReadBuffer) ReadByte() (byte, error)

ReadByte reads and returns the next byte from the buffer. The byte is removed from the buffer afterwards. If no byte is available, it returns error io.EOF.

func (*ReadBuffer) ReadBytes

func (b *ReadBuffer) ReadBytes(n int) ([]byte, error)

ReadBytes reads and returns exactly n bytes from the buffer. The bytes are removed from the buffer afterwards. If there are not enough bytes in the buffer available, it returns error io.EOF and does not advance.

func (*ReadBuffer) ReadInt16

func (b *ReadBuffer) ReadInt16() (int16, error)

ReadInt16 decodes a 16-bit signed integer and advances the buffer over it. If there are not enough bytes in the buffer available, it returns error io.EOF and does not advance.

func (*ReadBuffer) ReadInt16Array

func (b *ReadBuffer) ReadInt16Array(k int) ([]int16, error)

ReadInt16Array decodes an array of k 16-bit signed integers and advances the buffer over it. If there are not enough bytes in the buffer available, it returns error io.EOF and does not advance.

func (*ReadBuffer) ReadInt32

func (b *ReadBuffer) ReadInt32() (int32, error)

ReadInt32 decodes a 32-bit signed integer and advances the buffer over it. If there are not enough bytes in the buffer available, it returns error io.EOF and does not advance.

func (*ReadBuffer) ReadInt32Array

func (b *ReadBuffer) ReadInt32Array(k int) ([]int32, error)

ReadInt32Array decodes an array of k 32-bit signed integers and advances the buffer over it. If there are not enough bytes in the buffer available, it returns error io.EOF and does not advance.

func (*ReadBuffer) ReadString

func (b *ReadBuffer) ReadString() (string, error)

ReadString reads a null-terminated string and advances the buffer over it. If there is no terminator present in the buffer, it returns error and does not advance.

type ReadyForQueryMessage

type ReadyForQueryMessage struct {
	// Current backend transaction status
	TxStatus TxStatus
}

ReadyForQueryMessage is sent whenever the backend is ready for a new query cycle.

func ParseReadyForQueryMessage

func ParseReadyForQueryMessage(frame Frame) (*ReadyForQueryMessage, error)

ParseReadyForQueryMessage parses ReadyForQueryMessage from a network frame.

func (*ReadyForQueryMessage) Frame

func (m *ReadyForQueryMessage) Frame() Frame

Frame serializes the message into a network frame.

type RowDescriptionMessage

type RowDescriptionMessage struct {
	// List of fields to be returned
	Fields []*FieldDescriptor
}

RowDescriptionMessage represents a message sent by a backend to describe query result fields.

func ParseRowDescriptionMessage

func ParseRowDescriptionMessage(frame Frame) (*RowDescriptionMessage, error)

ParseRowDescriptionMessage parses RowDescriptionMessage from a network frame.

func (*RowDescriptionMessage) Frame

func (m *RowDescriptionMessage) Frame() Frame

Frame serializes the message into a network frame.

type StandardFrame

type StandardFrame []byte

StandardFrame conveys arbitrary PostgreSQL message. The first byte of a frame identifies the message type, and the next four bytes specify the length of the the attached message (this length count includes itself, but not the message-type byte).

func NewStandardFrame

func NewStandardFrame(messageType byte, messageBody []byte) StandardFrame

NewStandardFrame initializes a new StandardFrame with the given type and message.

func ReadStandardFrame

func ReadStandardFrame(r io.Reader) (StandardFrame, error)

ReadStandardFrame reads a standard frame from the given reader.

func (StandardFrame) Bytes

func (f StandardFrame) Bytes() []byte

Bytes returns this frame as a slice of bytes.

func (StandardFrame) MessageBody

func (f StandardFrame) MessageBody() []byte

MessageBody returns bytes of the message.

func (StandardFrame) MessageType

func (f StandardFrame) MessageType() byte

MessageType returns type of the message.

type StartupFrame

type StartupFrame []byte

StartupFrame conveys StartupMessage — the first message a client sends to begin a session with a DB. The only difference between a StandardFrame and a StartupFrame is that the latter doesn't have a message type as the first byte of the frame header. It is exist in PG protocol for historical reason.

func NewStartupFrame

func NewStartupFrame(messageBody []byte) StartupFrame

NewStartupFrame initializes a new StartupFrame with the given message.

func ReadStartupFrame

func ReadStartupFrame(r io.Reader) (StartupFrame, error)

ReadStartupFrame reads start-up frame from the given reader.

func (StartupFrame) Bytes

func (f StartupFrame) Bytes() []byte

Bytes returns this frame as a slice of bytes.

func (StartupFrame) MessageBody

func (f StartupFrame) MessageBody() []byte

MessageBody returns bytes of a message containing within this frame.

func (StartupFrame) MessageType

func (f StartupFrame) MessageType() byte

MessageType returns 0x00 since StartupFrame doesn't have message type.

type StartupMessage

type StartupMessage struct {
	ProtocolVersion int32
	Parameters      []*StartupMessageParameter // NB: we want to preserve order so we can't use map here
}

StartupMessage represents the first message a client sends to the DB after establishing a connection. This message includes the names of the user and of the database the user wants to connect to; it also identifies the particular protocol version to be used as well as any additional run-time parameters.

func ParseStartupMessage

func ParseStartupMessage(frame Frame) (*StartupMessage, error)

ParseStartupMessage parses StartupMessage from a network frame.

func (*StartupMessage) Frame

func (m *StartupMessage) Frame() Frame

Frame serializes the message into a network frame.

func (*StartupMessage) GetParameter

func (m *StartupMessage) GetParameter(name string) string

GetParameter returns parameter value by its name. If parameter is not set it returns an empty string.

type StartupMessageParameter

type StartupMessageParameter struct {
	Name  string
	Value string
}

StartupMessageParameter represents run-time parameter in a StartupMessage.

type TerminateMessage

type TerminateMessage struct{}

TerminateMessage is sent by a frontend to terminate the session.

func ParseTerminateMessage

func ParseTerminateMessage(frame Frame) (*TerminateMessage, error)

ParseQueryMessage parses QueryMessage from a network frame.

func (*TerminateMessage) Frame

func (m *TerminateMessage) Frame() Frame

Frame serializes the message into a network frame.

type TxStatus

type TxStatus byte

TxStatus represents transaction status code.

const (
	TxStatusIdle   TxStatus = 'I' // Not in a transaction block
	TxStatusActive TxStatus = 'T' // In a transaction block
	TxStatusFailed TxStatus = 'E' // Failed transaction block
)

type WriteBuffer

type WriteBuffer []byte

WriteBuffer provides bufio.Scanner-like API to encode PG data types described here: https://www.postgresql.org/docs/9.6/protocol-message-types.html

func (*WriteBuffer) Inspect

func (b *WriteBuffer) Inspect() string

Inspect returns content of the buffer as a hex dump for debug purposes.

func (*WriteBuffer) Len

func (b *WriteBuffer) Len() int

Len returns the number of bytes in the buffer.

func (*WriteBuffer) WriteByte

func (b *WriteBuffer) WriteByte(c byte)

WriteByte appends given byte to the buffer.

func (*WriteBuffer) WriteBytes

func (b *WriteBuffer) WriteBytes(v []byte)

WriteBytes appends given bytes to the buffer.

func (*WriteBuffer) WriteInt16

func (b *WriteBuffer) WriteInt16(num int16)

WriteInt16 encodes a 16-bit signed integer and appends it to the buffer.

func (*WriteBuffer) WriteInt16Array

func (b *WriteBuffer) WriteInt16Array(arr []int16)

WriteInt16Array encodes an array of 16-bit signed integers and append it into the buffer.

func (*WriteBuffer) WriteInt32

func (b *WriteBuffer) WriteInt32(num int32)

WriteInt32 encodes a 32-bit signed integer and appends it to the buffer.

func (*WriteBuffer) WriteInt32Array

func (b *WriteBuffer) WriteInt32Array(arr []int32)

WriteInt32Array encodes an array of 32-bit signed integers and append it into the buffer.

func (*WriteBuffer) WriteString

func (b *WriteBuffer) WriteString(str string)

WriteString encodes and appends given string to the buffer.

Jump to

Keyboard shortcuts

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