epgsql.hrl 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. %% See https://www.postgresql.org/docs/current/protocol-message-formats.html
  2. %% Description of `RowDescription' packet
  3. -record(column, {
  4. %% field name
  5. name :: binary(),
  6. %% name of the field data type
  7. type :: epgsql:epgsql_type(),
  8. %% OID of the field's data type
  9. oid :: non_neg_integer(),
  10. %% data type size (see pg_type.typlen). negative values denote variable-width types
  11. size :: -1 | pos_integer(),
  12. %% type modifier (see pg_attribute.atttypmod). meaning of the modifier is type-specific
  13. modifier :: -1 | pos_integer(),
  14. %% format code being used for the field during server->client transmission.
  15. %% Currently will be zero (text) or one (binary).
  16. format :: integer(),
  17. %% If the field can be identified as a column of a specific table, the OID of the table; otherwise zero.
  18. %% SELECT relname FROM pg_catalog.pg_class WHERE oid=<table_oid>
  19. table_oid :: non_neg_integer(),
  20. %% If table_oid is not zero, the attribute number of the column; otherwise zero.
  21. %% SELECT attname FROM pg_catalog.pg_attribute
  22. %% WHERE attrelid=<table_oid> AND attnum=<table_attr_number>
  23. table_attr_number :: pos_integer()
  24. }).
  25. -record(statement, {
  26. name :: string(),
  27. columns :: [#column{}],
  28. types :: [epgsql:epgsql_type()],
  29. parameter_info :: [epgsql_oid_db:oid_entry()]
  30. }).
  31. %% See https://www.postgresql.org/docs/current/protocol-error-fields.html
  32. -record(error, {
  33. % see client_min_messages config option
  34. severity :: debug | log | info | notice | warning | error | fatal | panic,
  35. code :: binary(), % See https://www.postgresql.org/docs/current/errcodes-appendix.html
  36. codename :: atom(),
  37. message :: binary(),
  38. extra :: [{severity | detail | hint | position | internal_position | internal_query
  39. | where | schema_name | table_name | column_name | data_type_name
  40. | constraint_name | file | line | routine,
  41. binary()}]
  42. }).