Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

PostgreSQL DBA (130)-Extension (pgsql-gzip)

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

This article briefly introduces the plug-in for PostgreSQL: pgsql-gzip. The plug-in can be used to encrypt and decrypt columns.

Installation

Clone code, compiling and installing

[pg12@localhost contrib] $git clone https://github.com/pramsey/pgsql-gzip.gitCloning into 'pgsql-gzip'...remote: Enumerating objects, done.remote: Counting objects: 100% (114), done.remote: Compressing objects: 100% (71), done.remote: Total 114 (delta 63), reused 81 (delta 35), pack-reused 0Receiving objects: 100% (114), 18.56 KiB | 0 bytes/s, done.Resolving deltas: 100% (63max 63) Done. [pg12@localhost contrib] $cd pgsql-gzip/ [pg12@localhost pgsql-gzip] $makegcc-std=gnu99-Wall-Wmissing-prototypes-Wpointer-arith-Wdeclaration-after-statement-Werror=vla-Wendif-labels-Wmissing-format-attribute-Wformat-security-fno-strict-aliasing-fwrapv-fexcess-precision=standard-gO0-DOPTIMIZER_DEBUG-G3-gdwarf-2-fPIC-I. -I. /-I/appdb/pg12/pg12.0/include/postgresql/server-I/appdb/pg12/pg12.0/include/postgresql/internal-D_GNU_SOURCE-I/usr/include/libxml2-c-o pg_gzip.o pg_gzip.c-MMD-MP-MF .deps / pg_gzip.Pogcc-std=gnu99-Wall-Wmissing-prototypes-Wpointer-arith-Wdeclaration-after-statement-Werror=vla-Wendif-labels-Wmissing-format-attribute-Wformat-security-fno-strict- Aliasing-fwrapv-fexcess-precision=standard-g-O0-DOPTIMIZER_DEBUG-G3-gdwarf-2-fPIC-shared-o gzip.so pg_gzip.o-L/appdb/pg12/pg12.0/lib-Wl -- as-needed-Wl,-rpath,'/appdb/pg12/pg12.0/lib' -- enable-new-dtags-lz [pg12@localhost pgsql-gzip] $make install/bin/mkdir-p'/ appdb/pg12/pg12.0/lib/postgresql'/bin/mkdir-p'/ appdb/pg12/pg12.0/share/postgresql/extension'/bin/mkdir-p'/ appdb/pg12/pg12.0/share/postgresql/extension'/bin/install-c-m 755 gzip.so'/ appdb/pg12/pg12.0/lib/postgresql/gzip.so'/bin/install -c-m 644. / / gzip.control'/ appdb/pg12/pg12.0/share/postgresql/extension/'/bin/install-c-m 644. / / gzip--1.0.sql'/ appdb/pg12/pg12.0/share/postgresql/extension/' [pg12@localhost pgsql-gzip] $make installcheck/appdb/pg12/pg12.0/lib/postgresql/pgxs/src/makefiles/../../src/test/regress/pg_regress-- inputdir=./-- bindir= '/ appdb/pg12/pg12.0/bin'-- dbname=contrib_regression gzip (using postmaster on Unix socket Default port) = dropping database "contrib_regression" = DROP DATABASE= creating database "contrib_regression" = CREATE DATABASEALTER DATABASE= running regression test queries = test gzip. Ok 253 ms= All 1 tests passed. = [pg12@localhost pgsql-gzip] $

Experience

Create an extension

[local]: 5432 pg12@testdb=# create extension gzippg12@testdb-#; CREATE EXTENSION [local]: 5432 pg12@testdb=#

The main functions include gzip and gunzip

[local]: 5432 pg12@testdb=#\ df gzip List of functions Schema | Name | Result data type | Argument data types | Type-+- -+-public | gzip | bytea | uncompressed bytea Compression_level integer DEFAULT'- 1'::integer | func public | gzip | bytea | uncompressed text Compression_level integer DEFAULT'- 1'::integer | func (2 rows) [local]: 5432 pg12@testdb=#\ df gunzip List of functions Schema | Name | Result data type | Argument data types | Type-+-- -public | gunzip | bytea | compressed bytea | func (1 row)

Compression / decompression

[local]: 5432 pg12@testdb=# select gzip ('Test data 123 Test') Gzip -\ x1f8b08000000000000037bb6b5fbc5faa9cfa66e78d6bbced0c8f819980b00299ee5af15000000 (1 row) [local]: 5432 pg12@testdb=# select gunzip ('\ x1f8b08000000000000037bb6b5fbc5faa9cfa66e78d6bbced0c8f819980b00299ee5af15000000'::bytea) Gunzip -\ xe6b58be8af95e695b0e68dae313233e6b58be8af95 (1 row) [local]: 5432 pg12@testdb=# select gunzip (gzip) Gunzip -\ xe6b58be8af95e695b0e68dae313233e6b58be8af95 (1 row) [local]: 5432 pg12@testdb=# [local]: 5432 pg12@testdb=# select 'Test data 123 Test':: bytea Bytea -\ xe6b58be8af95e695b0e68dae313233e6b58be8af95 (1 row) [local]: 5432 pg12@testdb=#

Opaque compression and decompression can be achieved through pgsql-gzip.

references

Pgsql-gzip

GZip in PostgreSQL

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report