epgsql.hrl 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. -type epgsql_type() :: atom() | {array, atom()} | {unknown_oid, integer()}.
  2. -record(column, {name :: binary(),
  3. type :: epgsql_type(),
  4. size :: -1 | pos_integer(),
  5. modifier :: -1 | pos_integer(),
  6. format :: integer()}).
  7. -record(statement, {name :: string(),
  8. columns :: [#column{}],
  9. types :: [epgsql_type()]}).
  10. -record(error, {severity :: fatal | error | atom(), %TODO: concretize
  11. code :: binary(),
  12. message :: binary(),
  13. extra :: [{detail, binary()}
  14. | {hint, binary()}
  15. | {position, binary()}]}).
  16. -type connection() :: pid().
  17. -type connect_option() :: {database, string()}
  18. | {port, inet:port_number()}
  19. | {ssl, boolean() | required}
  20. | {ssl_opts, list()} % ssl:option(), see OTP ssl_api.hrl
  21. | {timeout, timeout()}
  22. | {async, pid()}.
  23. -type connect_error() :: #error{}.
  24. -type query_error() :: #error{}.
  25. -type bind_param() ::
  26. null
  27. | boolean()
  28. | string()
  29. | binary()
  30. | integer()
  31. | float()
  32. | calendar:date()
  33. | calendar:time() %actualy, `Seconds' may be float()
  34. | calendar:datetime()
  35. | {calendar:time(), Days::non_neg_integer(), Months::non_neg_integer()}
  36. | [bind_param()]. %array (maybe nested)
  37. -type squery_row() :: {binary()}.
  38. -type equery_row() :: {bind_param()}.
  39. -type ok_reply(RowType) :: {ok, [#column{}], [RowType]} % SELECT
  40. | {ok, non_neg_integer()} % UPDATE / INSERT
  41. | {ok, non_neg_integer(), [#column{}], [RowType]}. % UPDATE / INSERT + RETURNING