本文簡(jiǎn)單介紹了PostgreSQL的插件:pgsql-gzip。該插件可用于對(duì)列進(jìn)行加密和解密。

創(chuàng)新互聯(lián)公司2013年開(kāi)創(chuàng)至今,是專(zhuān)業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項(xiàng)目成都網(wǎng)站建設(shè)、網(wǎng)站制作網(wǎng)站策劃,項(xiàng)目實(shí)施與項(xiàng)目整合能力。我們以讓每一個(gè)夢(mèng)想脫穎而出為使命,1280元綦江做網(wǎng)站,已為上家服務(wù),為綦江各地企業(yè)和個(gè)人服務(wù),聯(lián)系電話:18980820575
安裝
clone代碼,編譯安裝
[pg12@localhost contrib]$ git clone https://github.com/pramsey/pgsql-gzip.git
Cloning into 'pgsql-gzip'...
remote: Enumerating objects: 114, done.
remote: Counting objects: 100% (114/114), done.
remote: Compressing objects: 100% (71/71), done.
remote: Total 114 (delta 63), reused 81 (delta 35), pack-reused 0
Receiving objects: 100% (114/114), 18.56 KiB | 0 bytes/s, done.
Resolving deltas: 100% (63/63), done.
[pg12@localhost contrib]$ cd pgsql-gzip/
[pg12@localhost pgsql-gzip]$ make
gcc -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 -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.Po
gcc -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 DATABASE
ALTER DATABASE
============== running regression test queries ==============
test gzip ... ok 253 ms
=====================
All 1 tests passed.
=====================
[pg12@localhost pgsql-gzip]$
體驗(yàn)
創(chuàng)建擴(kuò)展
[local]:5432 pg12@testdb=# create extension gzip
pg12@testdb-# ;
CREATE EXTENSION
[local]:5432 pg12@testdb=#
主要的函數(shù)包括gzip和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)
壓縮/解壓
[local]:5432 pg12@testdb=# select gzip('測(cè)試數(shù)據(jù)123測(cè)試');
gzip
----------------------------------------------------------------------------------
\x1f8b08000000000000037bb6b5fbc5faa9cfa66e78d6bbced0c8f819980b00299ee5af15000000
(1 row)
[local]:5432 pg12@testdb=# select gunzip('\x1f8b08000000000000037bb6b5fbc5faa9cfa66e78d6bbced0c8f819980b00299ee5af15000000'::bytea);
gunzip
----------------------------------------------
\xe6b58be8af95e695b0e68dae313233e6b58be8af95
(1 row)
[local]:5432 pg12@testdb=# select gunzip(gzip('測(cè)試數(shù)據(jù)123測(cè)試'));
gunzip
----------------------------------------------
\xe6b58be8af95e695b0e68dae313233e6b58be8af95
(1 row)
[local]:5432 pg12@testdb=#
[local]:5432 pg12@testdb=# select '測(cè)試數(shù)據(jù)123測(cè)試'::bytea;
bytea
----------------------------------------------
\xe6b58be8af95e695b0e68dae313233e6b58be8af95
(1 row)
[local]:5432 pg12@testdb=#
通過(guò)pgsql-gzip可實(shí)現(xiàn)非透明的壓縮和解壓。
參考資料
pgsql-gzip
GZip in PostgreSQL
網(wǎng)站標(biāo)題:PostgreSQLDBA(130)-Extension(pgsql-gzip)
瀏覽路徑:http://chinadenli.net/article10/pgjigo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站排名、用戶(hù)體驗(yàn)、虛擬主機(jī)、、動(dòng)態(tài)網(wǎng)站、網(wǎng)站設(shè)計(jì)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)