Interface to encoder/decoder for postgresql wire-protocol
See alsoinclude/protocol.hrl
.
packet_type() = byte()
see protocol.hrl -type packet_type(Exact) :: Exact. % TODO: uncomment when OTP-18 is dropped
abstract datatype: row_decoder()
build_decoder/2 | Build decoder for DataRow. |
decode_columns/3 | decode RowDescription column information. |
decode_complete/1 | decode CcommandComplete msg. |
decode_data/2 | decode row data. |
decode_error/1 | decode ErrorResponse See http://www.postgresql.org/docs/current/interactive/protocol-error-fields.html |
decode_message/1 | tries to extract single postgresql packet from TCP stream. |
decode_parameters/2 | decode ParameterDescription. |
decode_strings/1 | decode multiple null-terminated string. |
encode_bind/4 | encodes Bind packet. |
encode_close/2 | encodes Close packet. |
encode_command/1 | Encode iodata with size-prefix (used for StartupMessage and SSLRequest packets). |
encode_command/2 | Encode PG command with type and size prefix. |
encode_describe/2 | encodes Describe packet. |
encode_execute/2 | encodes Execute packet. |
encode_flush/0 | encodes Flush packet. |
encode_formats/1 | encode expected column formats. |
encode_parameters/2 | encode parameters for 'Bind'. |
encode_parse/3 | encodes 'Parse' packet. |
encode_query/1 | encodes simple 'Query' packet. |
encode_standby_status_update/3 | encode replication status message. |
encode_sync/0 | encodes Sync packet. |
encode_types/2 | encode types. |
format/2 | Returns 1 if Codec knows how to decode binary format of the type provided and 0 otherwise. |
build_decoder(Columns::[epgsql:column()], Codec::epgsql_binary:codec()) -> row_decoder()
Build decoder for DataRow
decode_columns(Count::non_neg_integer(), Bin::binary(), Codec::epgsql_binary:codec()) -> [epgsql:column()]
decode RowDescription column information
decode_complete(Bin) -> any()
decode CcommandComplete msg
decode_data(Bin::binary(), X2::row_decoder()) -> tuple()
decode row data
decode_error(Bin::binary()) -> epgsql:query_error()
decode ErrorResponse See http://www.postgresql.org/docs/current/interactive/protocol-error-fields.html
decode_message(Bin::binary()) -> {packet_type(), binary(), binary()} | binary()
tries to extract single postgresql packet from TCP stream
decode_parameters(X1::binary(), Codec::epgsql_binary:codec()) -> [epgsql_oid_db:type_info() | {unknown_oid, epgsql_oid_db:oid()}]
decode ParameterDescription
decode_strings(Bin::binary()) -> [binary(), ...]
decode multiple null-terminated string
encode_bind(PortalName::iodata(), StmtName::iodata(), BinParams::iodata(), BinFormats::iodata()) -> {packet_type(), iodata()}
BinParams: see encode_parameters/2
.
BinFormats: see encode_formats/1
encodes Bind
packet.
encode_close(What::byte() | statement | portal, Name::iodata()) -> {packet_type(), iodata()}
What: see encode_describe/2
encodes Close
packet.
CloseComplete
response
encode_command(Data) -> any()
Encode iodata with size-prefix (used for StartupMessage
and SSLRequest
packets)
encode_command(Type::packet_type(), Data::iodata()) -> iodata()
Encode PG command with type and size prefix
encode_describe(What::byte() | statement | portal, Name::iodata()) -> {packet_type(), iodata()}
What: might be ?PORTAL
(results in RowDescription
response) or ?PREPARED_STATEMENT
(results in ParameterDescription
followed by RowDescription
or NoData
response)
encodes Describe
packet.
encode_execute(PortalName::iodata(), MaxRows::non_neg_integer()) -> {packet_type(), iodata()}
PortalName: might be an empty string (anonymous portal) or name of the named portal
MaxRows: how many rows server should send (0 means all of them)
encodes Execute
packet.
MaxRows
packets of DataRow
type followed by CommandComplete
(when no
more rows are available) or PortalSuspend
(repeated Execute
will return more rows)
encode_flush() -> {packet_type(), iodata()}
encodes Flush
packet.
encode_formats(Columns::[epgsql:column()]) -> binary()
encode expected column formats
encode_parameters(Parameters::[], Codec::epgsql_binary:codec()) -> iolist()
encode parameters for 'Bind'
encode_parse(Name::iodata(), SQL::iodata(), ColumnEncoding::iodata()) -> {packet_type(), iodata()}
ColumnEncoding: see encode_types/2
encodes 'Parse' packet.
Results inParseComplete
response.
encode_query(SQL) -> any()
encodes simple 'Query' packet.
encode_standby_status_update(ReceivedLSN, FlushedLSN, AppliedLSN) -> any()
encode replication status message
encode_sync() -> {packet_type(), iodata()}
encodes Sync
packet.
ReadyForQuery
response
encode_types(Types, Codec) -> any()
encode types
format(Column, Codec) -> any()
Returns 1 if Codec knows how to decode binary format of the type provided and 0 otherwise
Generated by EDoc