Module epgsql

This module defines the epgsql behaviour.
Required callback functions: handle_x_log_data/4.

Data Types

bind_param()

bind_param() = null | boolean() | string() | binary() | integer() | float() | pg_date() | pg_time() | pg_datetime() | pg_interval() | {[{binary(), binary() | null}]} | [bind_param()]

cb_state()

cb_state() = term()

connect_error()

connect_error() = #error{} | {unsupported_auth_method, atom()} | invalid_authorization_specification | invalid_password

connect_option()

connect_option() = {host, host()} | {username, string()} | {password, string()} | {database, DBName::string()} | {port, PortNum::inet:port_number()} | {ssl, IsEnabled::boolean() | required} | {ssl_opts, SslOptions::[ssl:ssl_option()]} | {timeout, TimeoutMs::timeout()} | {async, Receiver::pid() | atom()} | {replication, Replication::string()}

connect_opts()

connect_opts() = [connect_option()] | #{host => host(), username => string(), password => string(), database => string(), port => inet:port_number(), ssl => boolean() | required, ssl_opts => [ssl:ssl_option()], timeout => timeout(), async => pid(), replication => string()}

connect_opts()

connect_opts() = [connect_option()] | #{host => host(), username => string(), password => string(), database => string(), port => inet:port_number(), ssl => boolean() | required, ssl_opts => [ssl:ssl_option()], timeout => timeout(), async => pid(), replication => string()}

connection()

connection() = pid()

equery_row()

equery_row() = tuple()

tuple of bind_param().

error_reply()

error_reply() = {error, query_error()}

host()

host() = inet:ip_address() | inet:hostname()

lsn()

lsn() = integer()

ok_reply()

ok_reply(RowType) = {ok, ColumnsDescription::[#column{}], RowsValues::[RowType]} | {ok, Count::non_neg_integer()} | {ok, Count::non_neg_integer(), ColumnsDescription::[#column{}], RowsValues::[RowType]}

pg_date()

pg_date() = {Year::-4712..294276, Month::1..12, Day::1..31}

pg_datetime()

pg_datetime() = {pg_date(), pg_time()}

pg_interval()

pg_interval() = {pg_time(), Days::integer(), Months::integer()}

pg_time()

pg_time() = {Hour::0..24, Minute::0..59, Second::0..59 | float()}

query_error()

query_error() = #error{}

reply()

reply(RowType) = ok_reply(RowType) | error_reply()

sql_query()

sql_query() = string() | iodata()

squery_row()

squery_row() = tuple()

tuple of binary().

typed_param()

typed_param() = {epgsql_type(), bind_param()}

Function Index

bind/3
bind/4
cancel/1
close/1
close/2
close/3
connect/1
connect/2
connect/3
connect/4connects to Postgres where Host - host to connect to Username - username to connect as, defaults to $USER Password - optional password to authenticate with Opts - proplist of extra options returns {ok, Connection} otherwise {error, Reason}
connect/5
describe/2
describe/3
equery/2
equery/3
equery/4
execute/2
execute/3
execute/4
execute_batch/2
get_cmd_status/1Returns last command status message If multiple queries were executed using squery/2, separated by semicolon, only the last query's status will be available.
get_parameter/2
parse/2
parse/3
parse/4
prepared_query/3
set_notice_receiver/2
squery/2runs simple SqlQuery via given Connection
standby_status_update/3sends last flushed and applied WAL positions to the server in a standby status update message via given Connection
start_replication/5
start_replication/6instructs Postgres server to start streaming WAL for logical replication where Connection - connection in replication mode ReplicationSlot - the name of the replication slot to stream changes from Callback - Callback module which should have the callback functions implemented for message processing.
sync/1
sync_on_error/2
update_type_cache/1
update_type_cache/2
with_transaction/2

Function Details

bind/3

bind(C, Statement, Parameters) -> any()

bind/4

bind(C::connection(), Statement::#statement{}, PortalName::string(), Parameters::[bind_param()]) -> ok | {error, query_error()}

cancel/1

cancel(C::connection()) -> ok

close/1

close(C::connection()) -> ok

close/2

close(C, Statement) -> any()

close/3

close(C, Type, Name) -> any()

connect/1

connect(Settings0::connect_opts()) -> {ok, Connection::connection()} | {error, Reason::connect_error()}

connect/2

connect(Host, Opts) -> any()

connect/3

connect(Host, Username, Opts) -> any()

connect/4

connect(Host::host(), Username::string(), Password::string(), Opts::connect_opts()) -> {ok, Connection::connection()} | {error, Reason::connect_error()}

connects to Postgres where Host - host to connect to Username - username to connect as, defaults to $USER Password - optional password to authenticate with Opts - proplist of extra options returns {ok, Connection} otherwise {error, Reason}

connect/5

connect(C::connection(), Host::host(), Username::string(), Password::string(), Opts0::connect_opts()) -> {ok, Connection::connection()} | {error, Reason::connect_error()}

describe/2

describe(C, Statement) -> any()

describe/3

describe(C, X2, Name) -> any()

equery/2

equery(C, Sql) -> any()

equery/3

equery(C, Sql, Parameters) -> any()

equery/4

equery(C::connection(), Name::string(), Sql::sql_query(), Parameters::[bind_param()]) -> reply(equery_row())

execute/2

execute(C, S) -> any()

execute/3

execute(C, S, N) -> any()

execute/4

execute(C::connection(), Statement::#statement{}, PortalName::string(), N::non_neg_integer()) -> Reply

execute_batch/2

execute_batch(C::connection(), Batch::[{#statement{}, [bind_param()]}]) -> [reply(equery_row())]

get_cmd_status/1

get_cmd_status(C::connection()) -> {ok, Status}

Returns last command status message If multiple queries were executed using squery/2, separated by semicolon, only the last query's status will be available. See https://www.postgresql.org/docs/current/static/libpq-exec.html#LIBPQ-PQCMDSTATUS

get_parameter/2

get_parameter(C::connection(), Name::binary()) -> binary() | undefined

parse/2

parse(C, Sql) -> any()

parse/3

parse(C, Sql, Types) -> any()

parse/4

parse(C::connection(), Name::iolist(), Sql::sql_query(), Types::[epgsql_type()]) -> {ok, #statement{}} | {error, query_error()}

prepared_query/3

prepared_query(C::connection(), Name::string(), Parameters::[bind_param()]) -> reply(equery_row())

set_notice_receiver/2

set_notice_receiver(C::connection(), PidOrName::undefined | pid() | atom()) -> {ok, Previous::pid() | atom()}

squery/2

squery(Connection::connection(), SqlQuery::sql_query()) -> reply(squery_row()) | [reply(squery_row())]

runs simple SqlQuery via given Connection

standby_status_update/3

standby_status_update(Connection::connection(), FlushedLSN::lsn(), AppliedLSN::lsn()) -> ok | error_reply()

sends last flushed and applied WAL positions to the server in a standby status update message via given Connection

start_replication/5

start_replication(Connection, ReplicationSlot, Callback, CbInitState, WALPosition) -> any()

start_replication/6

start_replication(Connection::connection(), ReplicationSlot::string(), Callback, CbInitState::cb_state(), WALPosition::string(), PluginOpts::string()) -> ok | error_reply()

instructs Postgres server to start streaming WAL for logical replication where Connection - connection in replication mode ReplicationSlot - the name of the replication slot to stream changes from Callback - Callback module which should have the callback functions implemented for message processing. or a process which should be able to receive replication messages. CbInitState - Callback Module's initial state WALPosition - the WAL position XXX/XXX to begin streaming at. "0/0" to let the server determine the start point. PluginOpts - optional options passed to the slot's logical decoding plugin. For example: "option_name1 'value1', option_name2 'value2'" returns ok otherwise {error, Reason}

sync/1

sync(C) -> any()

sync_on_error/2

sync_on_error(C, Error) -> any()

update_type_cache/1

update_type_cache(C::connection()) -> ok

update_type_cache/2

update_type_cache(C::connection(), DynamicTypes::[binary()]) -> ok

with_transaction/2

with_transaction(C::connection(), F::fun((connection()) -> Reply)) -> Reply | {rollback, any()}


Generated by EDoc, Jan 22 2017, 01:13:11.