https://github.com/grahamedgecombe/pgflate
PostgreSQL module for raw DEFLATE compression/decompression with preset dictionary support
https://github.com/grahamedgecombe/pgflate
deflate postgresql zlib
Last synced: 10 months ago
JSON representation
PostgreSQL module for raw DEFLATE compression/decompression with preset dictionary support
- Host: GitHub
- URL: https://github.com/grahamedgecombe/pgflate
- Owner: grahamedgecombe
- License: isc
- Created: 2017-01-20T19:36:27.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-10-05T16:43:36.000Z (over 8 years ago)
- Last Synced: 2025-04-11T02:04:13.546Z (about 1 year ago)
- Topics: deflate, postgresql, zlib
- Language: C
- Homepage: https://www.grahamedgecombe.com/projects/pgflate
- Size: 11.7 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.markdown
- License: LICENSE
Awesome Lists containing this project
README
# pgflate
## Introduction
pgflate is a PostgreSQL extension that provides functions for deflating and
inflating raw DEFLATE streams, with support for custom dictionaries.
## Prerequisites
* PostgreSQL headers, libraries and PGXS build infrastructure
* `pg_config` must be in your `PATH`
* zlib
## Building
Run `make` to build the extension.
## Installation
Run `make install` as `root` (e.g. with `sudo`) to install the extension.
## Debian package
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][pgapt] repository in my [personal APT repository][apt]. Run
`apt-get install postgresql-PGVERSION-flate` as root after setting up the
repository.
## Usage
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.
## Example
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=#
## License
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.
[pgapt]: https://wiki.postgresql.org/wiki/Apt
[apt]: https://www.grahamedgecombe.com/apt-repository