Documentation
¶
Index ¶
- Constants
- Variables
- func CreateAuthenticationOk() []byte
- func CreateBackendKeyData(processID, secretKey int32) []byte
- func CreateCommandComplete(tag string) []byte
- func CreateMessage(msgType byte, payload []byte) []byte
- func CreateParameterDescription(numParams uint16, paramTypes []uint32) []byte
- func CreateParameterStatus(name, value string) []byte
- func CreateReadyForQuery(status byte) []byte
- func ParseQuery(msg *Message) string
- func ParseStartupMessage(msg *Message) map[string]string
- func WriteMessage(conn net.Conn, msgType byte, payload []byte) error
- type Message
- type Proxy
- type ResultHandler
- func (r *ResultHandler) SendCommandComplete(conn net.Conn, tag string) error
- func (r *ResultHandler) SendDataRow(conn net.Conn, columns []string, values map[string]interface{}) error
- func (r *ResultHandler) SendEmptyResultSet(conn net.Conn, columns []string) error
- func (r *ResultHandler) SendResultSet(conn net.Conn, columns []string, rows []map[string]interface{}) error
- func (r *ResultHandler) SendRowDescription(conn net.Conn, columns []string) error
- type StartupHandler
Constants ¶
const ( // Frontend (client) messages MsgQuery = 'Q' MsgParse = 'P' MsgBind = 'B' MsgExecute = 'E' MsgSync = 'S' MsgTerminate = 'X' MsgDescribe = 'D' MsgClose = 'C' MsgFlush = 'H' MsgSSLRequest = 0 // Special case MsgStartup = 0 // Special case // Backend (server) messages MsgAuthentication = 'R' MsgParameterStatus = 'S' MsgBackendKeyData = 'K' MsgReadyForQuery = 'Z' MsgRowDescription = 'T' MsgDataRow = 'D' MsgCommandComplete = 'C' MsgErrorResponse = 'E' MsgNoticeResponse = 'N' MsgParseComplete = '1' MsgBindComplete = '2' MsgCloseComplete = '3' MsgNoData = 'n' MsgPortalSuspended = 's' MsgParameterDescription = 't' )
Message types for Frontend/Backend protocol
const ( AuthOK = 0 AuthKerberosV5 = 2 AuthCleartextPassword = 3 AuthMD5Password = 5 AuthSCMCredential = 6 AuthGSS = 7 AuthGSSContinue = 8 AuthSSPI = 9 AuthSASL = 10 )
Authentication types
Variables ¶
var SSLRequest = []byte{0x00, 0x00, 0x00, 0x08, 0x04, 0xD2, 0x16, 0x2F}
SSLRequest magic number
Functions ¶
func CreateAuthenticationOk ¶
func CreateAuthenticationOk() []byte
CreateAuthenticationOk creates AuthenticationOk message
func CreateBackendKeyData ¶
CreateBackendKeyData creates BackendKeyData message
func CreateCommandComplete ¶
CreateCommandComplete creates CommandComplete message
func CreateMessage ¶
CreateMessage creates a message with given type and payload
func CreateParameterDescription ¶
CreateParameterDescription creates ParameterDescription message numParams is the number of parameters, paramTypes are the OIDs of the parameter types
func CreateParameterStatus ¶
CreateParameterStatus creates ParameterStatus message
func CreateReadyForQuery ¶
CreateReadyForQuery creates ReadyForQuery message status: 'I' = Idle, 'T' = In transaction, 'E' = Failed transaction
func ParseStartupMessage ¶
ParseStartupMessage parses startup message parameters
Types ¶
type Message ¶
Message represents a PostgreSQL protocol message
func ReadMessage ¶
ReadMessage reads a complete message from the connection Returns nil, nil if it's an SSL request
func ReadRegularMessage ¶
ReadRegularMessage reads a regular (non-startup) message
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
type ResultHandler ¶
type ResultHandler struct{}
ResultHandler generates PostgreSQL result set messages
func NewResultHandler ¶
func NewResultHandler() *ResultHandler
func (*ResultHandler) SendCommandComplete ¶
func (r *ResultHandler) SendCommandComplete(conn net.Conn, tag string) error
SendCommandComplete sends just CommandComplete for non-SELECT operations
func (*ResultHandler) SendDataRow ¶
func (r *ResultHandler) SendDataRow(conn net.Conn, columns []string, values map[string]interface{}) error
SendDataRow sends a single DataRow message
func (*ResultHandler) SendEmptyResultSet ¶
func (r *ResultHandler) SendEmptyResultSet(conn net.Conn, columns []string) error
SendEmptyResultSet sends an empty result set
func (*ResultHandler) SendResultSet ¶
func (r *ResultHandler) SendResultSet(conn net.Conn, columns []string, rows []map[string]interface{}) error
SendResultSet sends a complete result set to the client
func (*ResultHandler) SendRowDescription ¶
func (r *ResultHandler) SendRowDescription(conn net.Conn, columns []string) error
SendRowDescription sends RowDescription message
type StartupHandler ¶
type StartupHandler struct{}
StartupHandler manages the connection startup phase
func NewStartupHandler ¶
func NewStartupHandler() *StartupHandler
func (*StartupHandler) HandleStartup ¶
HandleStartup handles the initial connection phase Returns true if connection should proceed, false if it should be closed
func (*StartupHandler) HandleStartupWithReader ¶
func (h *StartupHandler) HandleStartupWithReader(reader *bufio.Reader, conn net.Conn) (map[string]string, error)
HandleStartupWithReader handles startup using a provided buffered reader