Documentation
¶
Index ¶
Constants ¶
const DefaultBufferSize = 1 << 24 // 16777216 bytes
DefaultBufferSize represents the default buffer size whenever the buffer size is not set or a negative value is presented.
const MaxPreparedStatementArgs = math.MaxUint16
MaxPreparedStatementArgs is the maximum number of arguments a prepared statement can have when prepared via the Postgres wire protocol. This is not documented by Postgres, but is a consequence of the fact that a 16-bit integer in the wire format is used to indicate the number of values to bind during prepared statement execution.
Variables ¶
var ErrInsufficientData = errors.New("insufficient data")
ErrInsufficientData is thrown when there is insufficient data available inside the given message to unmarshal into a given type.
var ErrMessageSizeExceeded = MessageSizeExceeded{Message: "maximum message size exceeded"}
ErrMessageSizeExceeded is thrown when the maximum message size is exceeded.
var ErrMissingNulTerminator = errors.New("NUL terminator not found")
ErrMissingNulTerminator is thrown when no NUL terminator is found when interperating a message property as a string.
Functions ¶
func EncodeBoolean ¶
EncodeBoolean returns a string value ("on"/"off") representing the given boolean value
func NewInsufficientData ¶
NewInsufficientData constructs a new error message wrapping the ErrInsufficientData type with additional metadata.
func NewMessageSizeExceeded ¶
NewMessageSizeExceeded constructs a new error message wrapping the ErrMaxMessageSizeExceeded type with additional metadata.
func NewMissingNulTerminator ¶
func NewMissingNulTerminator() error
NewMissingNulTerminator constructs a new error message wrapping the ErrMissingNulTerminator type with additional metadata.
Types ¶
type BufferedReader ¶
type BufferedReader interface {
io.Reader
ReadString(delim byte) (string, error)
ReadByte() (byte, error)
}
BufferedReader extended io.Reader with some convenience methods.
type MessageSizeExceeded ¶
MessageSizeExceeded represents a error implementation which could be used to indicate that the message size limit has been exceeded. The message size and maximum message length could be included inside the struct.
func UnwrapMessageSizeExceeded ¶
func UnwrapMessageSizeExceeded(err error) (result MessageSizeExceeded, _ bool)
UnwrapMessageSizeExceeded attempts to unwrap the given error as MessageSizeExceeded. A boolean is returned indicating whether the error contained a MessageSizeExceeded message.
func (MessageSizeExceeded) Error ¶
func (err MessageSizeExceeded) Error() string
func (MessageSizeExceeded) Is ¶
func (err MessageSizeExceeded) Is(target error) bool
type PrepareType ¶
type PrepareType byte
PrepareType represents a subtype for prepare messages.
const ( // PrepareStatement represents a prepared statement. PrepareStatement PrepareType = 'S' // PreparePortal represents a portal. PreparePortal PrepareType = 'P' )
type Reader ¶
type Reader interface {
GetString() (string, error)
GetBytes(int) ([]byte, error)
GetUint16() (uint16, error)
GetUint32() (uint32, error)
GetPrepareType() (PrepareType, error)
ReadTypedMsg() (types.ClientMessage, int, error)
ReadUntypedMsg() (int, error)
Slurp(size int) error
//
ResetReader(size int)
PeekMsg() []byte
}
Reader provides a convenient way to read pgwire protocol messages
func CreateTestReader ¶
func CreateTestReader(msg []byte, buffer BufferedReader) Reader
type ServerErrFieldType ¶
type ServerErrFieldType byte
ServerErrFieldType represents the error fields.
const ( ServerErrFieldSeverity ServerErrFieldType = 'S' ServerErrFieldSQLState ServerErrFieldType = 'C' ServerErrFieldMsgPrimary ServerErrFieldType = 'M' ServerErrFieldDetail ServerErrFieldType = 'D' ServerErrFieldHint ServerErrFieldType = 'H' ServerErrFieldSrcFile ServerErrFieldType = 'F' ServerErrFieldSrcLine ServerErrFieldType = 'L' ServerErrFieldSrcFunction ServerErrFieldType = 'R' ServerErrFieldConstraintName ServerErrFieldType = 'n' )
http://www.postgresql.org/docs/current/static/protocol-error-fields.html
type Writer ¶
type Writer interface {
Start(types.ServerMessage)
AddByte(byte)
AddInt16(int16) int
AddInt32(int32) int
AddBytes([]byte) int
AddString(string) int
Bytes() []byte
Error() error
End() error
Reset()
AddNullTerminate()
SetError(error)
}
Writer provides a convenient way to write pgwire protocol messages