postgres

package
v0.0.0-...-5e61f33 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package postgres provides tools to parsing of in-flight / forwarded PostgreSQL packets.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotImplemented indicates a method or message type is not implemented.
	ErrNotImplemented = errors.New("not implemented")
	// ErrParsingClientMessage indicates a failure occurred when parsing a TCP
	// packet as a PostgreSQL client message.
	ErrParsingClientMessage = errors.New("failed to parse TCP packet as PostgesSQL client message")
	// ErrParsingServerMessage indicates a failure occurred when parsing a TCP
	// packet as a PostgreSQL server message.
	ErrParsingServerMessage = errors.New("failed to parse TCP packet as PostgesSQL server message")
)

Functions

func DescribeBackendMessage

func DescribeBackendMessage(chunk []byte) (string, error)

DescribeBackendMessage tries to determine the **type** of backend message based on the first few bytes of the TCP chunk.

func ParseChunk

func ParseChunk(chunk []byte) (pgproto3.FrontendMessage, error)

ParseChunk parses a TCP packet as a PostgreSQL packet. This assumes a discrete TCP packet contains exactly one PostgreSQL packet, but this assumption may be revisted at a later time.

See: - https://godoc.org/github.com/jackc/pgproto3 - https://www.postgresql.org/docs/13/protocol-message-formats.html

Types

type Byte1pMessage

type Byte1pMessage struct {
	Data string
}

Byte1pMessage is a stand-in for the four different message formats that all share `Byte1('p')`: - `GSSResponse` - `Byte1pMessage` - `SASLInitialResponse` - `SASLResponse`

func (*Byte1pMessage) Decode

func (bm *Byte1pMessage) 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 (*Byte1pMessage) Encode

func (bm *Byte1pMessage) Encode(dst []byte) []byte

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

func (*Byte1pMessage) Frontend

func (*Byte1pMessage) Frontend()

Frontend identifies this message as sendable by a PostgreSQL frontend.

Jump to

Keyboard shortcuts

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