pgpool_regclass
PGPool辅助扩展,RegClass替代
概览
| 扩展包名 | 版本 | 分类 | 许可证 | 语言 |
|---|---|---|---|---|
pgpool | 4.7.1 | ADMIN | PostgreSQL | C |
| ID | 扩展名 | Bin | Lib | Load | Create | Trust | Reloc | 模式 |
|---|---|---|---|---|---|---|---|---|
| 5900 | pgpool_adm | 否 | 否 | 否 | 是 | 否 | 否 | - |
| 5910 | pgpool_recovery | 否 | 否 | 否 | 是 | 否 | 否 | - |
| 5920 | pgpool_regclass | 否 | 否 | 否 | 是 | 否 | 否 | - |
| 相关扩展 | pg_repack pg_rewrite pg_squeeze pg_dirtyread pgfincore pg_cooldown |
|---|
版本
| 类型 | 仓库 | 版本 | PG 大版本 | 包名 | 依赖 |
|---|---|---|---|---|---|
| EXT | PGDG | 4.7.1 | 1817161514 | pgpool | - |
| RPM | PGDG | 4.7.1 | 1817161514 | pgpool-II-pg$v-extensions | - |
| DEB | PGDG | 4.7.1 | 1817161514 | postgresql-$v-pgpool2 | - |
| OS / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PGDG 4.7.1 | PGDG 4.7.1 | PGDG 4.7.1 | PGDG 4.7.1 | PGDG 4.7.1 |
| el8.aarch64 | PGDG 4.7.1 | PGDG 4.7.1 | PGDG 4.7.1 | PGDG 4.7.1 | PGDG 4.7.1 |
| el9.x86_64 | PGDG 4.7.1 | PGDG 4.7.1 | PGDG 4.7.1 | PGDG 4.7.1 | PGDG 4.7.1 |
| el9.aarch64 | PGDG 4.7.1 | PGDG 4.7.1 | PGDG 4.7.1 | PGDG 4.7.1 | PGDG 4.7.1 |
| el10.x86_64 | PGDG 4.7.1 | PGDG 4.7.1 | PGDG 4.7.1 | PGDG 4.7.1 | PGDG 4.7.1 |
| el10.aarch64 | PGDG 4.7.1 | PGDG 4.7.1 | PGDG 4.7.1 | PGDG 4.7.1 | PGDG 4.7.1 |
| d12.x86_64 | PGDG 4.7.1 | PGDG 4.7.1 | PGDG 4.7.1 | PGDG 4.7.1 | PGDG 4.7.1 |
| d12.aarch64 | PGDG 4.7.1 | PGDG 4.7.1 | PGDG 4.7.1 | PGDG 4.7.1 | PGDG 4.7.1 |
| d13.x86_64 | PGDG 4.7.1 | PGDG 4.7.1 | PGDG 4.7.1 | PGDG 4.7.1 | PGDG 4.7.1 |
| d13.aarch64 | PGDG 4.7.1 | PGDG 4.7.1 | PGDG 4.7.1 | PGDG 4.7.1 | PGDG 4.7.1 |
| u22.x86_64 | PGDG 4.7.1 | PGDG 4.7.1 | PGDG 4.7.1 | PGDG 4.7.1 | PGDG 4.7.1 |
| u22.aarch64 | PGDG 4.7.1 | PGDG 4.7.1 | PGDG 4.7.1 | PGDG 4.7.1 | PGDG 4.7.1 |
| u24.x86_64 | PGDG 4.7.1 | PGDG 4.7.1 | PGDG 4.7.1 | PGDG 4.7.1 | PGDG 4.7.1 |
| u24.aarch64 | PGDG 4.7.1 | PGDG 4.7.1 | PGDG 4.7.1 | PGDG 4.7.1 | PGDG 4.7.1 |
安装
您可以直接安装 pgpool 扩展包的预置二进制包,首先确保 PGDG 仓库已经添加并启用:
pig repo add pgdg -u # 添加 PGDG 仓库并更新缓存
使用 pig 或者是 apt/yum/dnf 安装扩展:
pig install pgpool; # 当前活跃 PG 版本安装
pig ext install -y pgpool -v 18 # PG 18
pig ext install -y pgpool -v 17 # PG 17
pig ext install -y pgpool -v 16 # PG 16
pig ext install -y pgpool -v 15 # PG 15
pig ext install -y pgpool -v 14 # PG 14
dnf install -y pgpool-II-pg18-extensions # PG 18
dnf install -y pgpool-II-pg17-extensions # PG 17
dnf install -y pgpool-II-pg16-extensions # PG 16
dnf install -y pgpool-II-pg15-extensions # PG 15
dnf install -y pgpool-II-pg14-extensions # PG 14
apt install -y postgresql-18-pgpool2 # PG 18
apt install -y postgresql-17-pgpool2 # PG 17
apt install -y postgresql-16-pgpool2 # PG 16
apt install -y postgresql-15-pgpool2 # PG 15
apt install -y postgresql-14-pgpool2 # PG 14
创建扩展:
CREATE EXTENSION pgpool_regclass;
用法
pgpool_regclass 扩展提供一个替代的 regclass 函数,由 Pgpool-II 内部使用,用于处理跨多个后端的关系名称解析。
函数
-- 将关系名称解析为其 OID,类似于 PostgreSQL 的 regclass 强制转换
SELECT pgpool_regclass('my_table');
SELECT pgpool_regclass('my_schema.my_table');
用途
在标准 PostgreSQL 中,将字符串转换为 regclass(例如 'my_table'::regclass)会将关系名称解析为 OID。然而,Pgpool-II 需要判断 SQL 语句引用的是临时表还是普通表,以正确路由查询。
pgpool_regclass 函数以普通函数调用(而非类型转换)的形式提供此解析能力,使 Pgpool-II 能够:
- 判断引用的表是否存在于后端
- 区分临时表和永久表以实现正确的查询路由
- 在连接池中正确处理带模式限定的表名
注意事项
- 此扩展主要由 Pgpool-II 内部使用,通常不由应用程序直接调用
- 应安装在 Pgpool-II 管理的所有 PostgreSQL 后端节点上
- 对于 Pgpool-II 3.0+,此函数有助于
check_temp_table功能