Documentation ¶
Index ¶
- Variables
- type ColumnDescription
- type Encoder
- func (e *Encoder) BackendKeyData(pid, key int32) (Message, error)
- func (e *Encoder) CommandComplete(tag string) (Message, error)
- func (e *Encoder) Error(fields ...NoticeField) (Message, error)
- func (e *Encoder) GoError(err error) (Message, error)
- func (e *Encoder) NegotiateProtocolVersion(maxMinor int32, unrecognizedOptions ...string) (Message, error)
- func (e *Encoder) ReadyForQuery(status TransactionStatus) (Message, error)
- func (e *Encoder) RowDescription(cols ...ColumnDescription) (Message, error)
- func (e *Encoder) TextRow(row ...string) (Message, error)
- type Message
- type NoticeField
- type NoticeFieldType
- type Reader
- type TransactionStatus
- type Type
- type WireReader
- type WireWriter
- type Writer
Constants ¶
This section is empty.
Variables ¶
var AuthenticationOK = Message{ Type: TypeAuthentication, Data: []byte{0, 0, 0, 0}, }
AuthenticationOK is a message indicating that authentication has completed.
var ErrMessageTooBig = errors.New("message is too big")
ErrMessageTooBig is an error indicating that a message is too big to be sent or received.
Functions ¶
This section is empty.
Types ¶
type ColumnDescription ¶
type ColumnDescription struct { Name string TableID int32 //either a table/col id or 0 FieldID int16 //either a table/col id or 0 TypeID int32 //field type TypeLen int16 //size in bytes of field TypeModifier int32 //type modifer? Mode int16 //0=text 1=binary }
ColumnDescription is a description of a data column.
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
Encoder encodes messages.
func (*Encoder) BackendKeyData ¶
BackendKeyData encodes a Message with a cancellation key.
func (*Encoder) CommandComplete ¶
CommandComplete encodes a command completion message.
func (*Encoder) Error ¶
func (e *Encoder) Error(fields ...NoticeField) (Message, error)
Error encodes a Postgres error message.
func (*Encoder) NegotiateProtocolVersion ¶
func (e *Encoder) NegotiateProtocolVersion(maxMinor int32, unrecognizedOptions ...string) (Message, error)
NegotiateProtocolVersion encodes a protocol negotiation packet.
func (*Encoder) ReadyForQuery ¶
func (e *Encoder) ReadyForQuery(status TransactionStatus) (Message, error)
ReadyForQuery encodes a "ready for query" message.
func (*Encoder) RowDescription ¶
func (e *Encoder) RowDescription(cols ...ColumnDescription) (Message, error)
RowDescription describes the response rows from a query.
type NoticeField ¶
type NoticeField struct { Type NoticeFieldType Data string }
NoticeField is a field in an error or notice.
type NoticeFieldType ¶
type NoticeFieldType byte
NoticeFieldType indicates the type of a notice/error field. https://www.postgresql.org/docs/9.3/protocol-error-fields.html
const ( // NoticeFieldSeverity indicates the severity of a notice/error. NoticeFieldSeverity NoticeFieldType = 'S' // NoticeFieldMessage is a short human-readable error/notice message. NoticeFieldMessage NoticeFieldType = 'M' // NoticeFieldDetail is an optional extended description of the error. NoticeFieldDetail NoticeFieldType = 'D' // NoticeFieldHint is a suggestion of how to address the issue. NoticeFieldHint NoticeFieldType = 'H' )
type TransactionStatus ¶
type TransactionStatus byte
TransactionStatus is the current transaction state.
const ( // TransactionStatusIdle indicates that there is no active transaction. TransactionStatusIdle TransactionStatus = 'I' // TransactionStatusActive indicates that the connection currently has an active transaction. TransactionStatusActive TransactionStatus = 'T' // TransactionStatusFailed indicates that the connection currently has a failed transaction. TransactionStatusFailed TransactionStatus = 'E' )
type Type ¶
type Type byte
Type is a byte indicating the type of a Postgres message.
const ( // TypeAuthentication is a message used to transfer authentication info. TypeAuthentication Type = 'R' // TypeReadyForQuery is a message used to indicate that the server is ready for another query. TypeReadyForQuery Type = 'Z' // TypeCommandComplete is a message used to indicate that a query has completed. TypeCommandComplete Type = 'C' // TypeError is an error message. TypeError Type = 'E' // TypeRowDescription is a message indicating the column types of the result rows from a query. TypeRowDescription Type = 'T' // TypeDataRow is a message with the contents of a single row. TypeDataRow Type = 'D' // TypeTermination is a message indicating a request to terminate a connection. TypeTermination Type = 'X' // TypeNegotiateProtocolVersion is a message used when a client attempts to connect with a newer minor version than the server supports. TypeNegotiateProtocolVersion Type = 'v' // TypeSimpleQuery is a simple query request. TypeSimpleQuery Type = 'Q' // TypeBackendKeyData contains a cancellation key for the client to use later. TypeBackendKeyData Type = 'K' )
type WireReader ¶
type WireReader struct {
// contains filtered or unexported fields
}
WireReader reads messages in Postgres wire protocol format.
func NewWireReader ¶
func NewWireReader(r *bufio.Reader) *WireReader
NewWireReader returns a message reader that reads postgres wire protocol format.
func (*WireReader) ReadMessage ¶
func (r *WireReader) ReadMessage() (Message, error)
ReadMessage reads a single message off of the wire. The returned message is only valid until the next read call, as the data buffer may be re-used.
type WireWriter ¶
type WireWriter struct {
// contains filtered or unexported fields
}
WireWriter writes messages in Postgres wire protocol.
func NewWireWriter ¶
func NewWireWriter(w *bufio.Writer) *WireWriter
NewWireWriter returns a message writer that writes in postgres wire protocol format.
func (*WireWriter) Flush ¶
func (w *WireWriter) Flush() error
Flush writes any buffered data to the underlying stream.
func (*WireWriter) WriteMessage ¶
func (w *WireWriter) WriteMessage(message Message) error
WriteMessage writes a message onto the wire.