123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213openTypesmoduletypeS=sigtypetmoduleIo:sigtype'atvalreturn:'a->'atval(>>=):'at->('a->'bt)->'btvalcatch:(unit->'at)->(exn->'at)->'atvalprotect:(unit->'at)->finally:(unit->unitt)->'atend(** Connect to the database. The normal [$PGDATABASE], etc. environment
variables are available.
[max_message_length] is the maximum message length accepted from the back-end.
The default is [Sys.max_string_length], which means that we will try to
read as much data from the back-end as we can, and this may cause us to
run out of memory (particularly on 64 bit machines), causing a
possible denial of service. You may want to set this to a smaller
size to avoid this happening. *)valconnect:?host:string->?port:int->?user:string->?password:string->?database:string->?unix_domain_socket_dir:string->?verbose:int->?max_message_length:int->unit->tIo.t(** Close the database handle. You must call this after you have
finished with the handle, or else you will get leaked file
descriptors. *)valclose:t->unitIo.t(** Calls [connect], passes the DB handle to the callback, then calls
[close]. This is the preferred way to use this library since it cleans up
after itself. *)valwith_conn:?host:string->?port:int->?user:string->?password:string->?database:string->?unix_domain_socket_dir:string->?verbose:int->?max_message_length:int->(t->'aIo.t)->'aIo.t(** Ping the database. If the database is not available, some sort of
exception will be thrown. *)valping:t->unitIo.t(** This function is a wrapper of [ping] that returns a boolean instead of
raising an exception. *)valalive:t->boolIo.t(** Start a transaction. *)valbegin_work:?isolation:Isolation.t->?access:Access.t->?deferrable:bool->t->tIo.t(** Commit a transaction. Throws an exception if no transaction is open.
Use [with_transaction] when possible. *)valcommit:t->unitIo.t(** Rollback a transaction. Throws an exception if no transaction is open.
Use [with_transaction] when possible. *)valrollback:t->unitIo.t(** [with_transaction db ?isolation ?access ?deferrable f] wraps your
function [f] inside a transactional block.
See [begin_work] for a description of [isolation], [access], and
[deferrable].
If [f] throws an exception, the transaction will be rolled back. Otherwise
the transaction will be commited. It is an error to call [commit] or
[rollback] manually inside of this function. *)valwith_transaction:?isolation:Isolation.t->?access:Access.t->?deferrable:bool->t->(t->'bIo.t)->'bIo.tmodulePrepared:sigtypes[@@derivingsexp_of](** [prepare ?name ?types conn ~query] prepares the statement [query] and
sets the parameter types to [types].
If no [name] is given, a random name will be generated.
If no types are given, then the PostgreSQL engine infers types. *)valprepare:?name:string->?types:oidlist->t->query:string->sIo.t(** [close_statement t] closes a prepared statement and frees
up any resources. *)valclose:s->unitIo.t(** [prepare] a query, execute [f], and then [close_statement] *)valwith_prepare:?name:string->?types:oidlist->t->query:string->f:(s->'aIo.t)->'aIo.t(** [execute conn ~params t] executes the given prepared statement, with
the given parameters [params], returning the result rows (if any).
There are several steps involved at the protocol layer:
(1) a "portal" is created from the statement, binding the
parameters in the statement (Bind).
(2) the portal is executed (Execute).
(3) we synchronise the connection (Sync).
The optional [?portal] parameter may be used to name the portal
created in step (1) above (otherwise the unnamed portal is used).
This is only important if you want to call {!describe_portal}
to find out the result types. *)valexecute:?portal:string->s->params:paramlist->rowlistIo.t(** [execute_unit ?portal s ?params] same as execute, but intended
for database calls that have side-affects rather than returning results *)valexecute_unit:?portal:string->s->params:paramlist->unitIo.tvalexecute_fold:?portal:string->s->params:paramlist->init:'accum->f:('accum->row->'accumIo.t)->'accumIo.tvalexecute_iter:?portal:string->s->params:paramlist->f:(row->unitIo.t)->unitIo.tvalexecute_map:?portal:string->s->params:paramlist->f:(row->'aIo.t)->'alistIo.tvalexecute_many:s->params:paramlistlist->rowlistlistIo.t(** [describe_statement t] describes the statement's parameter types and
result types. *)valdescribe:s->(params_description*Result_desc.tlistoption)Io.t(** [close_portal conn ?portal ()] closes a portal and frees up any
resources. *)valclose_portal:?portal:string->s->unitIo.t(** [describe_portal conn ?portal ()] describes the named or unnamed
portal's result types. *)valdescribe_portal:?portal:string->s->Result_desc.tlistoptionIo.tend(** [execute conn ?params query] prepares and executes the statement
[query] and returns the result. *)valexecute:?params:row->t->string->rowlistIo.t(** [execute_unit conn ?params query ] same as execute, but intended
for database calls that have side-affects rather than returning results *)valexecute_unit:?params:row->t->string->unitIo.tvalexecute_fold:?params:paramlist->t->string->init:'accum->f:('accum->row->'accumIo.t)->'accumIo.tvalexecute_map:?params:paramlist->t->string->f:(row->'aIo.t)->'alistIo.tvalexecute_iter:?params:paramlist->t->string->f:(row->unitIo.t)->unitIo.t(** Prepares a query as in [execute] and then executes it once per set of
parameters in [params]. This is more efficient than calling [execute]
in a loop because the query is only prepared once. *)valexecute_many:t->query:string->params:paramlistlist->rowlistlistIo.t(** [simple_query conn query] executes the command(s) in the given [query]
and returns a list of query results (i.e. if you run two queries, you
will get a list with two elements: the results of the first query
followed by the results of the second query. *)valsimple_query:t->string->rowlistlistIo.tend