IvorySQL (Oracle)

使用瀚高开源的 IvorySQL 内核,基于 PostgreSQL 集群实现 Oracle 语法/PLSQL 兼容性。

IvorySQL 是一个开源的“Oracle兼容” PostgreSQL 内核,由 瀚高 出品,使用 Apache 2.0 许可证。

当然这里的 Oracle 兼容是 Pl/SQL,语法,内置函数、数据类型、系统视图、MERGE 以及 GUC参数层面上的兼容, 不是 BabelfishopenHaloFerretDB 那种可以不改客户端驱动的缆协议兼容。 所以用户还是要使用 PostgreSQL 的客户端工具来访问 IvorySQL,但是可以使用 Oracle 兼容的语法。

目前 IvorySQL 最新版本 4.4 与 PostgreSQL 最新小版本 17.4 保持兼容,并且提供了主流 Linux 上的二进制 RPM/DEB 包。 而 Pigsty 提供了在 PG RDS 中将原生 PostgreSQL 替换为 IvorySQL 内核的选项。


快速上手

使用标准流程 安装 Pigsty,并使用 ivory 配置模板:

curl -fsSL https://repo.pigsty.cc/get | bash; cd ~/pigsty
./bootstrap              # 安装 Pigsty 依赖
./configure -c ivory     # 使用 IvorySQL 配置模板
./install.yml            # 使用剧本执行部署 

对于生产环境部署,您应当在执行 ./install.yml 进行部署前,编辑自动生成的 pigsty.yml 配置文件,修改密码等参数。

当前最新的 IvorySQL 4.4 等效于 PostgreSQL 17,任何兼容 PostgreSQL 线缆协议的客户端工具都可以访问 IvorySQL 集群。

不过,默认情况下,你可以使用 PostgreSQL 客户端从另一个 1521 端口访问,这种情况下默认使用 Oracle 兼容模式。


配置说明

在 Pigsty 中要使用 IvorySQL 内核,需要修改以下四个配置参数:

是的就是这么简单,你只需要在配置文件的全局变量中加上这四行,Pigsty 就会使用 IvorySQL 替换原生的 PostgreSQL 内核了

pg_mode: ivory                           # IvorySQL 兼容模式,使用 IvorySQL 的二进制
pg_packages: [ ivorysql, pgsql-common ]  # 安装 ivorysql,替换 pgsql-main 主内核
pg_libs: 'liboracle_parser, pg_stat_statements, auto_explain'  # 加载 Oracle 兼容扩展
repo_extra_packages: [ ivorysql ]        # 下载 ivorysql 软件包

IvorySQL 还提供了一系列 新增 GUC 参数变量,您可以在 pg_parameters 中指定。


扩展列表

绝大多数 PGSQL 模块的 扩展插件 (非纯 SQL 类)都无法直接在 IvorySQL 内核上使用,如果需要使用,请针对新内核从源码重新编译安装。

目前 IvorySQL 内核自带了以下 109 个扩展插件。

IvorySQL 中可用的扩展插件列表
扩展名 版本 说明
amcheck 1.4 functions for verifying relation integrity
autoinc 1.0 functions for autoincrementing fields
bloom 1.0 bloom access method - signature file based index
bool_plperl 1.0 transform between bool and plperl
bool_plperlu 1.0 transform between bool and plperlu
btree_gin 1.3 support for indexing common datatypes in GIN
btree_gist 1.7 support for indexing common datatypes in GiST
citext 1.6 data type for case-insensitive character strings
cube 1.5 data type for multidimensional cubes
dblink 1.2 connect to other PostgreSQL databases from within a database
dict_int 1.0 text search dictionary template for integers
dict_xsyn 1.0 text search dictionary template for extended synonym processing
dummy_index_am 1.0 dummy_index_am - index access method template
dummy_seclabel 1.0 Test code for SECURITY LABEL feature
earthdistance 1.2 calculate great-circle distances on the surface of the Earth
file_fdw 1.0 foreign-data wrapper for flat file access
fuzzystrmatch 1.2 determine similarities and distance between strings
hstore 1.8 data type for storing sets of (key, value) pairs
hstore_plperl 1.0 transform between hstore and plperl
hstore_plperlu 1.0 transform between hstore and plperlu
hstore_plpython3u 1.0 transform between hstore and plpython3u
injection_points 1.0 Test code for injection points
insert_username 1.0 functions for tracking who changed a table
intagg 1.1 integer aggregator and enumerator (obsolete)
intarray 1.5 functions, operators, and index support for 1-D arrays of integers
isn 1.2 data types for international product numbering standards
ivorysql_ora 1.0 Oracle Compatible extenison on Postgres Database
jsonb_plperl 1.0 transform between jsonb and plperl
jsonb_plperlu 1.0 transform between jsonb and plperlu
jsonb_plpython3u 1.0 transform between jsonb and plpython3u
lo 1.1 Large Object maintenance
ltree 1.3 data type for hierarchical tree-like structures
ltree_plpython3u 1.0 transform between ltree and plpython3u
moddatetime 1.0 functions for tracking last modification time
ora_btree_gin 1.0 support for indexing oracle datatypes in GIN
ora_btree_gist 1.0 support for oracle indexing common datatypes in GiST
pageinspect 1.12 inspect the contents of database pages at a low level
pg_buffercache 1.5 examine the shared buffer cache
pg_freespacemap 1.2 examine the free space map (FSM)
pg_get_functiondef 1.0 Get function’s definition
pg_prewarm 1.2 prewarm relation data
pg_stat_statements 1.11 track planning and execution statistics of all SQL statements executed
pg_surgery 1.0 extension to perform surgery on a damaged relation
pg_trgm 1.6 text similarity measurement and index searching based on trigrams
pg_visibility 1.2 examine the visibility map (VM) and page-level visibility info
pg_walinspect 1.1 functions to inspect contents of PostgreSQL Write-Ahead Log
pgcrypto 1.3 cryptographic functions
pgrowlocks 1.2 show row-level locking information
pgstattuple 1.5 show tuple-level statistics
plisql 1.0 PL/iSQL procedural language
plperl 1.0 PL/Perl procedural language
plperlu 1.0 PL/PerlU untrusted procedural language
plpgsql 1.0 PL/pgSQL procedural language
plpython3u 1.0 PL/Python3U untrusted procedural language
plsample 1.0 PL/Sample
pltcl 1.0 PL/Tcl procedural language
pltclu 1.0 PL/TclU untrusted procedural language
postgres_fdw 1.1 foreign-data wrapper for remote PostgreSQL servers
refint 1.0 functions for implementing referential integrity (obsolete)
seg 1.4 data type for representing line segments or floating-point intervals
spgist_name_ops 1.0 Test opclass for SP-GiST
sslinfo 1.2 information about SSL certificates
tablefunc 1.0 functions that manipulate whole tables, including crosstab
tcn 1.0 Triggered change notifications
test_bloomfilter 1.0 Test code for Bloom filter library
test_copy_callbacks 1.0 Test code for COPY callbacks
test_custom_rmgrs 1.0 Test code for custom WAL resource managers
test_ddl_deparse 1.0 Test code for DDL deparse feature
test_dsa 1.0 Test code for dynamic shared memory areas
test_dsm_registry 1.0 Test code for the DSM registry
test_ext1 1.0 Test extension 1
test_ext2 1.0 Test extension 2
test_ext3 1.0 Test extension 3
test_ext4 1.0 Test extension 4
test_ext5 1.0 Test extension 5
test_ext6 1.0 test_ext6
test_ext7 1.0 Test extension 7
test_ext8 1.0 Test extension 8
test_ext9 1.0 test_ext9
test_ext_cine 1.0 Test extension using CREATE IF NOT EXISTS
test_ext_cor 1.0 Test extension using CREATE OR REPLACE
test_ext_cyclic1 1.0 Test extension cyclic 1
test_ext_cyclic2 1.0 Test extension cyclic 2
test_ext_evttrig 1.0 Test extension - event trigger
test_ext_extschema 1.0 test @extschema@
test_ext_req_schema1 1.0 Required extension to be referenced
test_ext_req_schema2 1.0 Test schema referencing of required extensions
test_ext_req_schema3 1.0 Test schema referencing of 2 required extensions
test_ext_set_schema 1.0 Test ALTER EXTENSION SET SCHEMA
test_ginpostinglist 1.0 Test code for ginpostinglist.c
test_integerset 1.0 Test code for integerset
test_lfind 1.0 Test code for optimized linear search functions
test_parser 1.0 example of a custom parser for full-text search
test_pg_dump 1.0 Test pg_dump with an extension
test_predtest 1.0 Test code for optimizer/util/predtest.c
test_radixtree 1.0 Test code for radix tree
test_rbtree 1.0 Test code for red-black tree library
test_regex 1.0 Test code for backend/regex/
test_resowner 1.0 Test code for ResourceOwners
test_shm_mq 1.0 Test code for shared memory message queues
test_slru 1.0 Test code for SLRU
test_tidstore 1.0 Test code for tidstore
tsm_system_rows 1.0 TABLESAMPLE method which accepts number of rows as a limit
tsm_system_time 1.0 TABLESAMPLE method which accepts time in milliseconds as a limit
unaccent 1.1 text search dictionary that removes accents
uuid-ossp 1.1 generate universally unique identifiers (UUIDs)
worker_spi 1.0 Sample background worker
xid_wraparound 1.0 Tests for XID wraparound
xml2 1.1 XPath querying and XSLT

备注说明

  • 目前 IvorySQL 的软件包位于 pigsty-infra 仓库,而非 pigsty-pgsqlpigsty-ivory 仓库。

  • IvorySQL 4.4 的默认 FHS 发生改变,请从老版本升级上来的用户留意。

  • IvorySQL 4.4 需要 gibc 版本 >= 2.17 即可,目前 Pigsty 支持的系统版本都满足这个条件

  • 最后一个支持 EL7 的 IvorySQL 版本为 3.3,对应 PostgreSQL 16.3,目前 IvorySQL 4.x 已经不再提供对 EL7 的支持了。

  • Pigsty 不对使用 IvorySQL 内核承担任何质保责任,使用此内核遇到的任何问题与需求请联系原厂解决。


最后修改 2025-04-09: add faq (e2e8ec5)