Skip to content

Commit 5e29ae8

Browse files
committed
Sync IvorySQL commit "Replace the pg_dialect control parameter with a core allow list"
1 parent b8f8e75 commit 5e29ae8

4 files changed

Lines changed: 8 additions & 101 deletions

File tree

CN/modules/ROOT/pages/master/ecosystem_components/pg_profile.adoc

Lines changed: 3 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pg_profile 是一个用于 PostgreSQL 数据库性能分析的扩展工具,主
99

1010
pg_profile 硬依赖 dblink 与 plpgsql(其自身完全由 SQL 和 PL/pgSQL 编写,无需任何外部库或软件);此外,建议安装 pg_stat_statements 扩展,以便在报告中获取 SQL 语句级别的统计信息。pg_profile 的版本与 PostgreSQL 的版本强相关,当前最高支持到 PG 18,具体的版本支持情况请查看 pg_profile 官方 github 仓库的 README.
1111

12-
IvorySQL 的 PG 模式和 Oracle 兼容模式都已经适配 pg_profile。需要注意的是,在 Oracle 兼容模式下,pg_profile 在编译前,需要手动修改扩展源码的 control.tpl 文件,增加一个配置项 `pg_dialect = true` ,否则无法正常安装。
12+
IvorySQL 的 PG 模式和 Oracle 兼容模式都已经适配 pg_profile。
1313

1414
项目地址:<https://github.com/zubkov-andrei/pg_profile>
1515

@@ -18,13 +18,6 @@ IvorySQL 的 PG 模式和 Oracle 兼容模式都已经适配 pg_profile。需要
1818
== 安装启用
1919

2020
=== 源码编译
21-
IvorySQL 的 Oracle 兼容模式下安装 pg_profile,需要先修改 pg_profile 的 control.tpl 文件,增加 `pg_dialect` 配置项:
22-
[literal]
23-
----
24-
# pg_profile/control.tpl
25-
pg_dialect = true
26-
----
27-
2821
执行源码编译和安装:
2922
[literal]
3023
----
@@ -34,15 +27,7 @@ make -C contrib/pg_stat_statements install
3427
make -C contrib/pg_profile install
3528
----
3629

37-
安装产物为 `pg_profile.control` 与 `pg_profile--4.11.sql`。IvorySQL 的 Oracle 兼容模式下,可检查生成的 `pg_profile.control` 文件已携带 `pg_dialect` 声明:
38-
[literal]
39-
----
40-
default_version = '4.11'
41-
requires = 'dblink,plpgsql'
42-
superuser = false
43-
44-
pg_dialect = true
45-
----
30+
安装产物为 `pg_profile.control` 与 `pg_profile--4.11.sql`。
4631

4732
=== 修改配置
4833
pg_profile 依赖的 pg_stat_statements 必须通过 `shared_preload_libraries` 在服务启动时加载。
@@ -77,16 +62,6 @@ SELECT extname, extversion FROM pg_extension WHERE extname = 'pg_profile';
7762
pg_profile | 4.11
7863
----
7964

80-
在 Oracle 兼容模式下,可执行下面的查询语句确认 pg_profile 的扩展函数已被固定到 PG 语法解析器:
81-
[literal]
82-
----
83-
SELECT proname, proconfig FROM pg_proc
84-
WHERE proname = 'take_sample' AND proconfig IS NOT NULL LIMIT 1;
85-
proname | proconfig
86-
-------------+-------------------------------------------------------------
87-
take_sample | {ivorysql.compatible_mode=pg,search_path=profile}
88-
----
89-
9065
== 使用流程
9166

9267
=== 创建样本
@@ -127,19 +102,4 @@ SELECT profile.get_report(1, 2);
127102
\o
128103
----
129104

130-
以上函数在 Oracle 模式会话(Oracle 端口/1521)中调用方式与结果完全一致。
131-
132-
== 注意事项
133-
134-
=== 适配说明
135-
IvorySQL 在 PG 模式下可直接安装使用 pg_profile 扩展,但在 Oracle 兼容模式下需要在编译时为 pg_profile 的 control.tpl 文件增加 `pg_dialect` 配置项,以启用 PG 语法解析器,避免安装失败。
136-
137-
=== 适配边界
138-
`pg_dialect` 适配机制保护的是扩展自身的代码;调用方会话中书写的 SQL 仍按会话方言解析。在 Oracle 模式会话中调用 pg_profile 时,语句里用户自己的表达式需符合 Oracle 模式语法,例如:
139-
[literal]
140-
----
141-
-- Oracle 会话中:PG 风格 interval 字面量会在会话解析期报错
142-
SELECT profile.set_server_size_sampling('local', current_time - interval '10 minute', ...); -- 错误
143-
144-
-- 应使用会话方言可接受的写法,或在 PG 模式会话中执行管理操作
145-
----
105+
以上函数在 Oracle 模式会话(Oracle 端口/1521)中调用方式与结果完全一致。

CN/modules/ROOT/pages/master/ecosystem_components/pg_repack.adoc

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
== 概述
88
pg_repack 是 PostgreSQL 的一个扩展,用于在线重整表和索引、消除存储膨胀。它能达到与 `VACUUM FULL` 类似的效果,回收空间,但几乎不阻塞业务读写。
99

10-
IvorySQL 的 PG 模式和 Oracle 兼容模式都已经适配 pg_repack。需要注意的是,在 Oracle 兼容模式下,pg_repack 在编译前,需要手动修改扩展源码的 lib/pg_repack.control.in 文件,增加一个配置项 `pg_dialect = true` ,否则无法正常安装。
10+
IvorySQL 的 PG 模式和 Oracle 兼容模式都已经适配 pg_repack。
1111

1212
项目地址:<https://github.com/reorg/pg_repack>
1313

@@ -47,13 +47,6 @@ VACUUM FULL 因没有"重写期间的并发变更捕获机制",重写整表时
4747
git clone --branch ver_1.5.3 https://github.com/reorg/pg_repack.git
4848
----
4949

50-
IvorySQL 的 Oracle 兼容模式下安装 pg_repack,需要先修改 pg_repack 的 lib/pg_repack.control.in 文件,增加一个配置项 `pg_dialect = true`:
51-
[literal]
52-
----
53-
# pg_repack/lib/pg_repack.control.in
54-
pg_dialect = true
55-
----
56-
5750
执行编译和安装:
5851
[literal]
5952
----

EN/modules/ROOT/pages/master/ecosystem_components/pg_profile.adoc

Lines changed: 3 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pg_profile is an extension tool for PostgreSQL database performance analysis. It
99

1010
pg_profile hard-depends on two extensions: dblink and plpgsql (it is written entirely in SQL and PL/pgSQL and requires no external libraries or software). Additionally, it is recommended to install the pg_stat_statements extension to obtain SQL statement-level statistics in the reports. The version of pg_profile is strongly tied to the version of PostgreSQL, currently supporting up to PG 18. For the specific version support, please refer to the README in the official pg_profile github repository.
1111

12-
Both the PG mode and Oracle compatibility mode of IvorySQL have been adapted for pg_profile. Note that in Oracle compatibility mode, before compiling pg_profile, you need to manually modify the control.tpl file in the extension source code to add a configuration item `pg_dialect = true`, otherwise the installation will fail.
12+
Both the PG mode and Oracle compatibility mode of IvorySQL have been adapted for pg_profile.
1313

1414
Project address: <https://github.com/zubkov-andrei/pg_profile>
1515

@@ -18,12 +18,6 @@ License: PostgreSQL License
1818
== Installation and Enabling
1919

2020
=== Source Code Compilation
21-
To install pg_profile in IvorySQL's Oracle compatibility mode, you need to first modify the control.tpl file of pg_profile to add the `pg_dialect` configuration item:
22-
[literal]
23-
----
24-
# pg_profile/control.tpl
25-
pg_dialect = true
26-
----
2721

2822
Perform source code compilation and installation:
2923
[literal]
@@ -34,15 +28,7 @@ make -C contrib/pg_stat_statements install
3428
make -C contrib/pg_profile install
3529
----
3630

37-
The installation artifacts are `pg_profile.control` and `pg_profile--4.11.sql`. In IvorySQL's Oracle compatibility mode, you can verify that the generated `pg_profile.control` file carries the `pg_dialect` declaration:
38-
[literal]
39-
----
40-
default_version = '4.11'
41-
requires = 'dblink,plpgsql'
42-
superuser = false
43-
44-
pg_dialect = true
45-
----
31+
The installation artifacts are `pg_profile.control` and `pg_profile--4.11.sql`.
4632

4733
=== Modify Configuration
4834
The pg_stat_statements that pg_profile depends on must be loaded at server startup via `shared_preload_libraries`.
@@ -77,16 +63,6 @@ SELECT extname, extversion FROM pg_extension WHERE extname = 'pg_profile';
7763
pg_profile | 4.11
7864
----
7965

80-
In Oracle compatibility mode, you can run the following query to confirm that the extension functions of pg_profile have been pinned to the PG syntax parser:
81-
[literal]
82-
----
83-
SELECT proname, proconfig FROM pg_proc
84-
WHERE proname = 'take_sample' AND proconfig IS NOT NULL LIMIT 1;
85-
proname | proconfig
86-
-------------+-------------------------------------------------------------
87-
take_sample | {ivorysql.compatible_mode=pg,search_path=profile}
88-
----
89-
9066
== Usage Workflow
9167

9268
=== Create Samples
@@ -127,19 +103,4 @@ SELECT profile.get_report(1, 2);
127103
\o
128104
----
129105

130-
The above functions are invoked and produce identical results in an Oracle mode session (Oracle port/1521).
131-
132-
== Notes
133-
134-
=== Adaptation Description
135-
IvorySQL can directly install and use the pg_profile extension in PG mode. However, in Oracle compatibility mode, you need to add the `pg_dialect` configuration item to the control.tpl file of pg_profile at compile time to enable the PG syntax parser and avoid installation failure.
136-
137-
=== Adaptation Boundary
138-
The `pg_dialect` adaptation mechanism protects the extension's own code; the SQL written in the caller's session is still parsed according to the session dialect. When calling pg_profile in an Oracle mode session, the user's own expressions in the statements must conform to Oracle mode syntax, for example:
139-
[literal]
140-
----
141-
-- In an Oracle session: PG-style interval literals will cause an error during session parsing
142-
SELECT profile.set_server_size_sampling('local', current_time - interval '10 minute', ...); -- ERROR
143-
144-
-- Use a syntax acceptable to the session dialect, or perform management operations in a PG mode session
145-
----
106+
The above functions are invoked and produce identical results in an Oracle mode session (Oracle port/1521).

EN/modules/ROOT/pages/master/ecosystem_components/pg_repack.adoc

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
== Overview
88
pg_repack is an extension for PostgreSQL used to rebuild tables and indexes online and eliminate storage bloat. It can achieve effects similar to `VACUUM FULL` (reclaiming space), while barely blocking business read/write operations.
99

10-
Both the PG mode and Oracle compatibility mode of IvorySQL have been adapted for pg_repack. Note that in Oracle compatibility mode, before compiling pg_repack, you need to manually modify the lib/pg_repack.control.in file in the extension source code to add a configuration item `pg_dialect = true`, otherwise the installation will fail.
10+
Both the PG mode and Oracle compatibility mode of IvorySQL have been adapted for pg_repack.
1111

1212
Github: <https://github.com/reorg/pg_repack>
1313

@@ -47,13 +47,6 @@ Pull the pg_repack source code:
4747
git clone --branch ver_1.5.3 https://github.com/reorg/pg_repack.git
4848
----
4949

50-
To install pg_repack in IvorySQL's Oracle compatibility mode, you need to first modify the lib/pg_repack.control.in file of pg_repack to add the `pg_dialect` configuration item:
51-
[literal]
52-
----
53-
# pg_repack/lib/pg_repack.control.in
54-
pg_dialect = true
55-
----
56-
5750
Perform compilation and installation:
5851
[literal]
5952
----

0 commit comments

Comments
 (0)