Skip to content

bzip

Bzip compression and decompression

pg_bzip · Bzip compression and decompression

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
4020bzippg_bzip1.0.0UTILMITC
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--s-d--NoYesNoYesnono

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXTPIGSTY1.0.019 18 17 16 15pg_bzip-
RPMPIGSTY1.0.019 18 17 16 15pg_bzip_$v-
DEBPIGSTY1.0.019 18 17 16 15postgresql-$v-bzip-
Linux / PGPG19PG18PG17PG16PG15
el8.x86_64N/APIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0
el8.aarch64N/APIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0
el9.x86_64PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0
el9.aarch64PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0
el10.x86_64PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0
el10.aarch64PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0
d12.x86_64PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0
d12.aarch64PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0
d13.x86_64PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0
d13.aarch64PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0
u22.x86_64PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0
u22.aarch64PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0
u24.x86_64PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0
u24.aarch64PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0
u26.x86_64PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0
u26.aarch64PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0PIGSTY 1.0.0

Source

pig build pkg pg_bzip;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install pg_bzip;		# install by package name
pig install bzip;		# install by extension name

pig install bzip -v 19;   # install for PG 19
pig install bzip -v 18;   # install for PG 18
pig install bzip -v 17;   # install for PG 17
pig install bzip -v 16;   # install for PG 16
pig install bzip -v 15;   # install for PG 15

Create this extension with:

CREATE EXTENSION bzip;

Usage

bzip: Bzip compression and decompression

Functions

  • bzcat(data bytea) returns bytea – Decompress bzip2 data, similar to the bzcat command.
  • bzip2(data bytea, compression_level int default 9) returns bytea – Compress data using bzip2.

Examples

Decompress a bzip2-compressed file:

SELECT convert_from(bzcat(pg_read_binary_file('/path/to/data.csv.bz2')), 'utf8') AS contents;

Compress data with bzip2:

SELECT bzip2(repeat('my text to be compressed', 1000)::bytea) AS compressed;

Compress with a custom compression level (1-9):

SELECT bzip2('some data'::bytea, 5);

Table reader