{"id":16799259,"url":"https://github.com/steve-chavez/pg_bzip","last_synced_at":"2026-05-17T12:05:52.269Z","repository":{"id":212706496,"uuid":"730049504","full_name":"steve-chavez/pg_bzip","owner":"steve-chavez","description":"Bzip compression and decompression for Postgres","archived":false,"fork":false,"pushed_at":"2023-12-17T22:50:05.000Z","size":1876,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-04-14T14:42:33.451Z","etag":null,"topics":["bzip","bzip2","c","compression","decompression","postgres","postgresql","postgresql-extension"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/steve-chavez.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-12-11T05:03:06.000Z","updated_at":"2025-02-14T04:11:42.000Z","dependencies_parsed_at":"2023-12-15T18:55:46.795Z","dependency_job_id":"40642f06-c0b2-4c43-8ef9-76b0608cbc8d","html_url":"https://github.com/steve-chavez/pg_bzip","commit_stats":null,"previous_names":["steve-chavez/pg_bzip"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/steve-chavez/pg_bzip","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steve-chavez%2Fpg_bzip","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steve-chavez%2Fpg_bzip/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steve-chavez%2Fpg_bzip/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steve-chavez%2Fpg_bzip/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/steve-chavez","download_url":"https://codeload.github.com/steve-chavez/pg_bzip/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steve-chavez%2Fpg_bzip/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33137831,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-17T09:28:26.183Z","status":"ssl_error","status_checked_at":"2026-05-17T09:27:52.702Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bzip","bzip2","c","compression","decompression","postgres","postgresql","postgresql-extension"],"created_at":"2024-10-13T09:28:22.366Z","updated_at":"2026-05-17T12:05:52.240Z","avatar_url":"https://github.com/steve-chavez.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pg_bzip\n\n## Motivation\n\nIf you get data compressed as bzip2, whether through [HTTP](https://github.com/pramsey/pgsql-http) or from a file, it's convenient to decompress it in SQL.\n`pg_bzip` does that, it provides functions to decompress and compress data using bzip2.\n\n## Functions\n\n- `bzcat(data bytea) returns bytea`\n\n  This function mimics the [bzcat](https://linux.die.net/man/1/bzcat) command, which decompresses data using bzip2.\n\n  For this example, we'll use the native [pg_read_binary_file](https://pgpedia.info/p/pg_read_binary_file.html) to read from a file.\n\n  ```sql\n  select convert_from(bzcat(pg_read_binary_file('/path/to/all_movies.csv.bz2')), 'utf8') as contents;\n\n                                                                    contents\n  --------------------------------------------------------------------------------------------------------------------------------------------\n   \"id\",\"name\",\"parent_id\",\"date\"                                                                                                            +\n   \"2\",\"Ariel\",\"8384\",\"1988-10-21\"                                                                                                           +\n   \"3\",\"Varjoja paratiisissa\",\"8384\",\"1986-10-17\"                                                                                            +\n   \"4\",\"État de siège\",\\N,\"1972-12-30\"                                                                                                       +\n   \"5\",\"Four Rooms\",\\N,\"1995-12-22\"                                                                                                          +\n   \"6\",\"Judgment Night\",\\N,\"1993-10-15\"                                                                                                      +\n   \"8\",\"Megacities - Life in Loops\",\\N,\"2006-01-01\"                                                                                          +\n   \"9\",\"Sonntag, im August\",\\N,\"2004-09-22\"                                                                                                  +\n   \"11\",\"Star Wars: Episode IV – A New Hope\",\"10\",\"1977-05-25\"                                                                               +\n   \"12\",\"Finding Nemo\",\"112246\",\"2003-05-30\"                                                                                                 +\n   ...\n   ....\n   .....\n  ```\n\n- `bzip2(data bytea, compression_level int default 9) returns bytea`\n\n  This function is a simplified version of the [bzip2](https://linux.die.net/man/1/bzip2) command. It compresses data using bzip2.\n\n  For this example we'll use `fio_writefile` from [pgsql-fio](https://github.com/csimsek/pgsql-fio), which offers a convenient way to write a file from SQL.\n\n  ```sql\n  select fio_writefile('/path/to/my_text.bz2', bzip2(repeat('my text to be compressed', 1000)::bytea)) as writesize;\n\n   writesize\n  -----------\n         109\n  ```\n\n## Installation\n\nbzip2 is required. Under Debian/Ubuntu you can get it with\n\n```bash\nsudo apt install libbz2-dev\n```\n\nThen on this repo\n\n```bash\nmake \u0026\u0026 make install\n```\n\nNow on SQL you can do:\n\n```sql\nCREATE EXTENSION bzip;\n```\n\n`pg_bzip` is tested to work on PostgreSQL \u003e= 12.\n\n## Development\n\n[Nix](https://nixos.org/download.html) is used to get an isolated and reproducible enviroment with multiple postgres versions.\n\n```bash\n# enter the Nix environment\n$ nix-shell\n\n# to run the tests\n$ with-pg-16 make installcheck\n\n# to interact with the isolated pg\n$ with-pg-16 psql\n\n# you can choose the pg version\n$ with-pg-15 psql\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsteve-chavez%2Fpg_bzip","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsteve-chavez%2Fpg_bzip","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsteve-chavez%2Fpg_bzip/lists"}