protocol

package
v0.0.0-...-79bc9d6 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BMESSAGE_ROW_DESCRIPTION  = 84
	BMESSAGE_AUTH             = 82
	BMESSAGE_PARAMETER_STATUS = 83
	BMESSAGE_BACKEND_KEY_DATA = 75
	BMESSAGE_READY_FOR_QUERY  = 90
	BMESSAGE_NO_DATA          = 110
	BMESSAGE_DATA_ROW         = 68
	BMESSAGE_COMMAND_COMPLETE = 67
	BMESSAGE_ERROR_RESPONSE   = 69
)

Backend Postgres Message kinds

View Source
const (
	AUTH_OK            = 0
	AUTH_MD5_PASSWORD  = 5
	AUTH_SASL          = 10
	AUTH_SASL_CONTINUE = 11
	AUTH_SASL_FINAL    = 12
)
View Source
const (
	NOTICE_KIND_SEVERITY_NONLOCALIZED = "Severity Nonlocalized"
	NOTICE_KIND_SEVERITY_LOCALIZED    = "Severity Localized"
	NOTICE_KIND_CODE                  = "Code"
	NOTICE_KIND_MESSAGE               = "Message"
	NOTICE_KIND_DETAIL                = "Detail"
	NOTICE_KIND_HINT                  = "Hint"
	NOTICE_KIND_POSITION              = "Position"
	NOTICE_KIND_INTERNAL_POSITION     = "Internal Position"
	NOTICE_KIND_INTERNAL_QUERY        = "Internal Query"
	NOTICE_KIND_WHERE                 = "Where"
	NOTICE_KIND_SCHEMA_NAME           = "Schema Name"
	NOTICE_KIND_TABLE_NAME            = "Table Name"
	NOTICE_KIND_COLUMN_NAME           = "Column Name"
	NOTICE_KIND_DATA_TYPE_NAME        = "Data Type Name"
	NOTICE_KIND_CONSTRAINT_NAME       = "Constraint Name"
	NOTICE_KIND_FILE                  = "File"
	NOTICE_KIND_LINE                  = "Line"
	NOTICE_KIND_ROUTINE               = "Routine"
)
View Source
const (
	FMESSAGE_STARTUP   = -1
	FMESSAGE_QUERY     = 81
	FMESSAGE_TERMINATE = 88
	FMESSAGE_PASSWORD  = 112
	FMESSAGE_CANCEL    = -2
	FMESSAGE_SASL      = 112
)

Frontend PgMessage kinds

View Source
const (
	CANCEL_REQUEST_CODE int = 80877102
)
View Source
const (
	SUPPORTED_PROTOCOL_VERSION = 196608
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthenticationMD5PasswordPgMessage

type AuthenticationMD5PasswordPgMessage struct {
	Salt []byte
	// contains filtered or unexported fields
}

func BuildAuthenticationMD5PasswordPgMessage

func BuildAuthenticationMD5PasswordPgMessage(salt []byte) *AuthenticationMD5PasswordPgMessage

func (*AuthenticationMD5PasswordPgMessage) Pack

func (*AuthenticationMD5PasswordPgMessage) Unpack

Postgres Message interface implementation for AuthenticationMD5PasswordPgMessage

type AuthenticationOkPgMessage

type AuthenticationOkPgMessage struct{}

AuthenticationOkPgMessage represents the message sent by the server to indicate that the authentication was successful

func BuildAuthenticationOkPgMessage

func BuildAuthenticationOkPgMessage() *AuthenticationOkPgMessage

Build a new AuthenticationOkPgMessage

func (*AuthenticationOkPgMessage) Pack

func (m *AuthenticationOkPgMessage) Pack() []byte

func (*AuthenticationOkPgMessage) Unpack

Postgres Message interface implementation for AuthenticationOkPgMessage

type AuthenticationSASLContinuePgMessage

type AuthenticationSASLContinuePgMessage struct {
	Data []byte
}

AuthenticationSASLContinuePgMessage represents the message sent by the server to continue the SASL authentication process

func BuildAuthenticationSASLContinuePgMessage

func BuildAuthenticationSASLContinuePgMessage(data []byte) *AuthenticationSASLContinuePgMessage

func (*AuthenticationSASLContinuePgMessage) Pack

func (*AuthenticationSASLContinuePgMessage) Unpack

Postgres Message interface implementation for AuthenticationSASLContinuePgMessage

type AuthenticationSASLFinalPgMessage

type AuthenticationSASLFinalPgMessage struct {
	Data []byte
}

AuthenticationSASLFinalPgMessage represents the message sent by the server to indicate that the SASL authentication process is complete

func BuildAuthenticationSASLFinalPgMessage

func BuildAuthenticationSASLFinalPgMessage(data []byte) *AuthenticationSASLFinalPgMessage

func (*AuthenticationSASLFinalPgMessage) Pack

func (*AuthenticationSASLFinalPgMessage) Unpack

Postgres Message interface implementation for AuthenticationSASLFinalPgMessage

type AuthenticationSASLPgMessage

type AuthenticationSASLPgMessage struct {
	AuthMechanisms []string
}

AuthenticationSASLPgMessage represents the message sent by the server to indicate that the client should use SASL authentication

func BuildAuthenticationSASLPgMessage

func BuildAuthenticationSASLPgMessage(authMechanisms []string) *AuthenticationSASLPgMessage

func (*AuthenticationSASLPgMessage) Pack

func (m *AuthenticationSASLPgMessage) Pack() []byte

func (*AuthenticationSASLPgMessage) Unpack

Postgres Message interface implementation for AuthenticationSASLPgMessage

type BackendKeyDataPgMessage

type BackendKeyDataPgMessage struct {
	Pid       int
	SecretKey int
}

BackendKeyDataPgMessage represents the message sent by the server to inform the client of the process id and secret key

func BuildBackendKeyDataPgMessage

func BuildBackendKeyDataPgMessage(processID int, secretKey int) *BackendKeyDataPgMessage

func (*BackendKeyDataPgMessage) Pack

func (m *BackendKeyDataPgMessage) Pack() []byte

func (*BackendKeyDataPgMessage) Unpack

Postgres Message interface implementation for BackendKeyDataPgMessage

type CancelRequestPgMessage

type CancelRequestPgMessage struct {
	BackendPid int
	BackendKey int
}

CancelRequestPgMessage represents the message sent by the client to cancel a query

func BuildCancelRequestPgMessage

func BuildCancelRequestPgMessage(backendPid int, backendKey int) *CancelRequestPgMessage

func (*CancelRequestPgMessage) Pack

func (m *CancelRequestPgMessage) Pack() []byte

PgMessage interface implementation for CancelRequestPgMessage

func (*CancelRequestPgMessage) Unpack

type CommandCompletePgMessage

type CommandCompletePgMessage struct {
	Command string
}

CommandCompletePgMessage represents the message sent by the server to indicate that a command has been completed

func BuildCommandCompletePgMessage

func BuildCommandCompletePgMessage(command string) *CommandCompletePgMessage

func (*CommandCompletePgMessage) Pack

func (m *CommandCompletePgMessage) Pack() []byte

func (*CommandCompletePgMessage) Unpack

Message interface implementation for CommandCompletePgMessage

type DataRowPgMessage

type DataRowPgMessage struct {
	Values [][]byte
}

DataRowPgMessage represents the message sent by the server to send a row of data

func BuildDataRowPgMessage

func BuildDataRowPgMessage(values [][]byte) *DataRowPgMessage

func (*DataRowPgMessage) Pack

func (m *DataRowPgMessage) Pack() []byte

func (*DataRowPgMessage) Unpack

func (m *DataRowPgMessage) Unpack(message *RawPgMessage) (*DataRowPgMessage, error)

PostgresMessage interface implementation for DataRowPgMessage

type ErrorField

type ErrorField struct {
	Type  byte
	Value string
}

func (ErrorField) Pack

func (e ErrorField) Pack() []byte

type ErrorResponsePgMessage

type ErrorResponsePgMessage struct {
	Fields map[string]ErrorField
}

ErrorResponsePgMessage represents the message sent by the server to indicate that an error occurred

func BuildErrorResponsePgMessage

func BuildErrorResponsePgMessage(params map[string]string) *ErrorResponsePgMessage

func MakeConnectionErrorMessages

func MakeConnectionErrorMessages(
	message string,
	detail string,
	code string,
	routine string,
) *ErrorResponsePgMessage

func (*ErrorResponsePgMessage) Error

func (m *ErrorResponsePgMessage) Error() string

func (*ErrorResponsePgMessage) GetErrorResponseField

func (m *ErrorResponsePgMessage) GetErrorResponseField(kind string) string

func (*ErrorResponsePgMessage) Pack

func (m *ErrorResponsePgMessage) Pack() []byte

func (*ErrorResponsePgMessage) Unpack

type FieldDescription

type FieldDescription struct {
	Name string
	// contains filtered or unexported fields
}

FieldDescription represents the description of a field in a row

func (FieldDescription) Pack

func (d FieldDescription) Pack() []byte

type NoDataPgMessage

type NoDataPgMessage struct{}

NoDataPgMessage represents the message sent by the server to indicate that there is no data to return

func BuildNoDataPgMessage

func BuildNoDataPgMessage() *NoDataPgMessage

func (*NoDataPgMessage) Pack

func (m *NoDataPgMessage) Pack() []byte

func (*NoDataPgMessage) Unpack

func (m *NoDataPgMessage) Unpack(message *RawPgMessage) (*NoDataPgMessage, error)

Postgres Message interface implementation for NoDataPgMessage

type ParameterStatusPgMessage

type ParameterStatusPgMessage struct {
	Name  string
	Value string
}

ParameterStatusPgMessage represents the message sent by the server to inform the client of sever parameter values

func BuildParameterStatusPgMessage

func BuildParameterStatusPgMessage(name string, value string) *ParameterStatusPgMessage

func (*ParameterStatusPgMessage) Pack

func (m *ParameterStatusPgMessage) Pack() []byte

func (*ParameterStatusPgMessage) Unpack

Postgres Message interface implementation for ParameterStatusPgMessage

type PasswordPgMessage

type PasswordPgMessage struct {
	Password string
}

PasswordPgMessage represents the message sent by the client to authenticate

func BuildPasswordMessage

func BuildPasswordMessage(password string) *PasswordPgMessage

func (PasswordPgMessage) Pack

func (m PasswordPgMessage) Pack() []byte

func (*PasswordPgMessage) Unpack

func (m *PasswordPgMessage) Unpack(message *RawPgMessage) (*PasswordPgMessage, error)

PgMessage interface implementation for PasswordPgMessage

type PgMessage

type PgMessage interface {
	Unpack(*RawPgMessage) (*PgMessage, error)
	Pack() []byte
}

A Interface for message types in the postgres protocol

type QueryPgMessage

type QueryPgMessage struct {
	Query string
}

QueryPgMessage represents the message sent by the client to query the database

func BuildQueryMessage

func BuildQueryMessage(query string) *QueryPgMessage

func (QueryPgMessage) Pack

func (m QueryPgMessage) Pack() []byte

func (*QueryPgMessage) Unpack

func (m *QueryPgMessage) Unpack(message *RawPgMessage) (*QueryPgMessage, error)

PgMessage interface implementation for QueryPgMessage

type RawPgMessage

type RawPgMessage struct {
	Kind   int
	Length int
	Data   []byte
}

RawPgMessage is a low level representation of a message containing the kind of message, the length of the message and the raw bytes. Generally we read a raw message from a connection and then Unpack it into a higher level message

RawPgMessage still implements the Message interface as it can be useful to pass it around generically

func GetRawPgMessage

func GetRawPgMessage(conn io.Reader) (*RawPgMessage, error)

Reads a raw message from a connection

func GetRawStartupPgMessage

func GetRawStartupPgMessage(conn net.Conn) (*RawPgMessage, error)

func (RawPgMessage) Pack

func (rm RawPgMessage) Pack() []byte

func (RawPgMessage) Unpack

func (rm RawPgMessage) Unpack(data []byte) RawPgMessage

Message interface implementation for RawPgMessage

type ReadyForQueryPgMessage

type ReadyForQueryPgMessage struct {
	TransactionStatus byte
}

ReadyForQueryPgMessage represents the message sent by the server to indicate that the server is ready to accept a new query

func BuildReadyForQueryPgMessage

func BuildReadyForQueryPgMessage(status byte) *ReadyForQueryPgMessage

func (*ReadyForQueryPgMessage) Pack

func (m *ReadyForQueryPgMessage) Pack() []byte

func (*ReadyForQueryPgMessage) Unpack

Postgres Message interface implementation for ReadyForQueryPgMessage

type RowDescriptionPgMessage

type RowDescriptionPgMessage struct {
	Fields []FieldDescription
}

RowDescriptionPgMessage represents the message sent by the server to describe the fields of a row

func BuildRowDescriptionPgMessage

func BuildRowDescriptionPgMessage(fieldsMap map[string][]int) *RowDescriptionPgMessage

Build a new RowDescriptionPgMessage

func (RowDescriptionPgMessage) Pack

func (m RowDescriptionPgMessage) Pack() []byte

func (*RowDescriptionPgMessage) Unpack

PostgresMessage interface implementation for RowDescriptionPgMessage

type SASLInitialResponsePgMessage

type SASLInitialResponsePgMessage struct {
	Mechanism string
	Response  []byte
}

SASLInitialResponsePgMessage represents the message sent by the client to authenticate using SASL

func BuildSASLInitialResponseMessage

func BuildSASLInitialResponseMessage(mechanism string, response []byte) *SASLInitialResponsePgMessage

func (SASLInitialResponsePgMessage) Pack

func (*SASLInitialResponsePgMessage) Unpack

PgMessage interface implementation for SASLInitialResponsePgMessage

type SASLResponsePgMessage

type SASLResponsePgMessage struct {
	Response []byte
}

SASLResponsePgMessage represents the message sent by the client to authenticate using SASL

func BuildSASLResponseMessage

func BuildSASLResponseMessage(response []byte) *SASLResponsePgMessage

func (SASLResponsePgMessage) Pack

func (m SASLResponsePgMessage) Pack() []byte

func (*SASLResponsePgMessage) Unpack

PgMessage interface implementation for SASLResponsePgMessage

type StartupPgMessage

type StartupPgMessage struct {
	ProtocolVersion int
	User            string
	Database        string
	Options         map[string]string
}

StartupPgMessage represents the message sent by the client to start the connection

func BuildStartupMessage

func BuildStartupMessage(user string, database string) *StartupPgMessage

func (StartupPgMessage) Pack

func (m StartupPgMessage) Pack() []byte

func (*StartupPgMessage) Unpack

func (m *StartupPgMessage) Unpack(message *RawPgMessage) (*StartupPgMessage, error)

PgMessage interface implementation for StartupPgMessage

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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