pg_erlang_term
is a PostgreSQL extension that adds a new data type erlang_term
for storing and working with arbitrary Erlang terms.
The terms are stored in the Erlang External Term format internally and are sent unmodified over the network when using binary input/output (Postgrex does this).
pg_erlang_term
depends on the ei
library which is included in Erlang/OTP.
Build and install pg_erlang_term
like so:
$ make
$ sudo make install
and optionally:
$ make installcheck
and then in PostgreSQL:
CREATE EXTENSION pg_erlang_term;
The textual representation of Erlang terms is currently handled by ei_s_print_term
for decoding and ei_x_format
for encoding.
These functions have some limitations and may not be able represent all kinds of Erlang terms.
Note that Ecto+Postgrex uses binary input/output which does not have these problems.