Module epgsql_wire

Interface to encoder/decoder for postgresql wire-protocol

Description

Interface to encoder/decoder for postgresql wire-protocol

See also include/protocol.hrl.

Data Types

packet_type()

packet_type() = byte()

see protocol.hrl -type packet_type(Exact) :: Exact. % TODO: uncomment when OTP-18 is dropped

row_decoder()

abstract datatype: row_decoder()

Function Index

build_decoder/2Build decoder for DataRow.
decode_columns/3decode RowDescription column information.
decode_complete/1decode CcommandComplete msg.
decode_data/2decode row data.
decode_error/1decode ErrorResponse See http://www.postgresql.org/docs/current/interactive/protocol-error-fields.html
decode_message/1tries to extract single postgresql packet from TCP stream.
decode_parameters/2decode ParameterDescription.
decode_strings/1decode multiple null-terminated string.
encode_bind/4encodes Bind packet.
encode_close/2encodes Close packet.
encode_command/1Encode iodata with size-prefix (used for StartupMessage and SSLRequest packets).
encode_command/2Encode PG command with type and size prefix.
encode_describe/2encodes Describe packet.
encode_execute/2encodes Execute packet.
encode_flush/0encodes Flush packet.
encode_formats/1encode expected column formats.
encode_parameters/2encode parameters for 'Bind'.
encode_parse/3encodes 'Parse' packet.
encode_query/1encodes simple 'Query' packet.
encode_standby_status_update/3encode replication status message.
encode_sync/0encodes Sync packet.
encode_types/2encode types.
format/2Returns 1 if Codec knows how to decode binary format of the type provided and 0 otherwise.

Function Details

build_decoder/2

build_decoder(Columns::[epgsql:column()], Codec::epgsql_binary:codec()) -> row_decoder()

Build decoder for DataRow

decode_columns/3

decode_columns(Count::non_neg_integer(), Bin::binary(), Codec::epgsql_binary:codec()) -> [epgsql:column()]

decode RowDescription column information

decode_complete/1

decode_complete(Bin) -> any()

decode CcommandComplete msg

decode_data/2

decode_data(Bin::binary(), X2::row_decoder()) -> tuple()

decode row data

decode_error/1

decode_error(Bin::binary()) -> epgsql:query_error()

decode ErrorResponse See http://www.postgresql.org/docs/current/interactive/protocol-error-fields.html

decode_message/1

decode_message(Bin::binary()) -> {packet_type(), binary(), binary()} | binary()

tries to extract single postgresql packet from TCP stream

decode_parameters/2

decode_parameters(X1::binary(), Codec::epgsql_binary:codec()) -> [epgsql_oid_db:type_info() | {unknown_oid, epgsql_oid_db:oid()}]

decode ParameterDescription

decode_strings/1

decode_strings(Bin::binary()) -> [binary(), ...]

decode multiple null-terminated string

encode_bind/4

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/2

encode_close(What::byte() | statement | portal, Name::iodata()) -> {packet_type(), iodata()}

What: see encode_describe/2

encodes Close packet.

Results in CloseComplete response

encode_command/1

encode_command(Data) -> any()

Encode iodata with size-prefix (used for StartupMessage and SSLRequest packets)

encode_command/2

encode_command(Type::packet_type(), Data::iodata()) -> iodata()

Encode PG command with type and size prefix

encode_describe/2

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/2

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.

Results in 0 or up to MaxRows packets of DataRow type followed by CommandComplete (when no more rows are available) or PortalSuspend (repeated Execute will return more rows)

encode_flush/0

encode_flush() -> {packet_type(), iodata()}

encodes Flush packet.

It doesn't cause any specific response packet, but tells PostgreSQL server to flush it's send network buffers

encode_formats/1

encode_formats(Columns::[epgsql:column()]) -> binary()

encode expected column formats

encode_parameters/2

encode_parameters(Parameters::[], Codec::epgsql_binary:codec()) -> iolist()

encode parameters for 'Bind'

encode_parse/3

encode_parse(Name::iodata(), SQL::iodata(), ColumnEncoding::iodata()) -> {packet_type(), iodata()}

ColumnEncoding: see encode_types/2

encodes 'Parse' packet.

Results in ParseComplete response.

encode_query/1

encode_query(SQL) -> any()

encodes simple 'Query' packet.

encode_standby_status_update/3

encode_standby_status_update(ReceivedLSN, FlushedLSN, AppliedLSN) -> any()

encode replication status message

encode_sync/0

encode_sync() -> {packet_type(), iodata()}

encodes Sync packet.

Results in ReadyForQuery response

encode_types/2

encode_types(Types, Codec) -> any()

encode types

format/2

format(Column, Codec) -> any()

Returns 1 if Codec knows how to decode binary format of the type provided and 0 otherwise


Generated by EDoc