pgflate is a PostgreSQL extension that provides functions for deflating and inflating raw DEFLATE streams, with support for custom dictionaries.
- PostgreSQL headers, libraries and PGXS build infrastructure
pg_config
must be in yourPATH
- zlib
Run make
to build the extension.
Run make install
as root
(e.g. with sudo
) to install the extension.
The repository also contains the files for building a Debian package, which can
be done by running pg_buildext updatecontrol
followed by dpkg-buildpackage
.
I distribute pre-built versions for stable amd64 Debian using the
apt.postgresql.org repository in my personal APT repository. Run
apt-get install postgresql-PGVERSION-flate
as root after setting up the
repository.
Run CREATE EXTENSION flate
to install the extension in the current database.
Two functions are provided:
Function | Return Type |
---|---|
deflate(data bytea [, dictionary bytea [, level integer ]]) |
bytea |
inflate(data bytea [, dictionary bytea ]) |
bytea |
deflate
compresses the provided data
and returns a raw DEFLATE stream. A
preset dictionary
may also be provided. The default compression level
may
also be overriden, valid values range from 0
(no compression), 1
(best
speed) to 9
(best compression).
If you want to override the compression level without using a dictionary, set
dictionary
to NULL
.
inflate
decompresses the provided DEFLATE stream in data
and returns the
uncompressed data. A preset dictionary
, matching the dictionary used to
deflate the data, may also be provided.
gpe=# CREATE EXTENSION flate;
CREATE EXTENSION
gpe=# SELECT deflate('hello hello hello hello', 'hello', 9);
deflate
------------------
\xcb00110a182400
(1 row)
gpe=# SELECT convert_from(inflate('\xcb00110a182400', 'hello'), 'utf-8');
convert_from
-------------------------
hello hello hello hello
(1 row)
gpe=#
This project is available under the terms of the ISC license, which is similar
to the 2-clause BSD license. See the LICENSE
file for the copyright
information and licensing terms.