omni_json

Omnigres JSON工具箱

概览

扩展包名版本分类许可证语言
omnigres0.1.1FEATApache-2.0C
ID扩展名BinLibLoadCreateTrustReloc模式
2940omniomni
2941omni_authomni_auth
2942omni_awsomni_aws
2943omni_cloudeventsomni_cloudevents
2944omni_containersomni_containers
2945omni_credentialsomni_credentials
2948omni_emailomni_email
2949omni_httpomni_http
2950omni_httpcomni_httpc
2951omni_httpdomni_httpd
2952omni_id-
2953omni_jsonomni_json
2954omni_kubeomni_kube
2955omni_ledgeromni_ledger
2956omni_manifestomni_manifest
2957omni_mimetypesomni_mimetypes
2958omni_osomni_os
2959omni_polyfillomni_polyfill
2960omni_pythonomni_python
2961omni_regex-
2962omni_restomni_rest
2963omni_schemaomni_schema
2964omni_seqomni_seq
2965omni_serviceomni_service
2966omni_sessionomni_session
2968omni_sqlomni_sql
2969omni_sqliteomni_sqlite
2970omni_testomni_test
2971omni_txnomni_txn
2972omni_typesomni_types
2973omni_varomni_var
2974omni_vfsomni_vfs
2975omni_vfs_types_v1omni_vfs_types_v1
2976omni_webomni_web
2977omni_workeromni_worker
2978omni_xmlomni_xml
2979omni_yamlomni_yaml

版本

类型仓库版本PG 大版本包名依赖
EXTPIGSTY0.1.11817161514omnigres-
RPMPIGSTY0.1.11817161514omnigres_$v-
DEBPIGSTY0.1.11817161514postgresql-$v-omnigres-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64PIGSTY MISSPIGSTY 20250120PIGSTY 20250120PIGSTY 20250120PIGSTY 20250120
el8.aarch64PIGSTY MISSPIGSTY 20250120PIGSTY 20250120PIGSTY 20250120PIGSTY 20250120
el9.x86_64PIGSTY MISSPIGSTY 20250507PIGSTY 20250507PIGSTY 20250507PIGSTY 20250507
el9.aarch64PIGSTY MISSPIGSTY 20250507PIGSTY 20250507PIGSTY 20250507PIGSTY 20250507
el10.x86_64PIGSTY MISSPIGSTY MISSPIGSTY MISSPIGSTY MISSPIGSTY MISS
el10.aarch64PIGSTY MISSPIGSTY MISSPIGSTY MISSPIGSTY MISSPIGSTY MISS
d12.x86_64PIGSTY MISSPIGSTY 20250120PIGSTY 20250120PIGSTY 20250120PIGSTY 20250120
d12.aarch64PIGSTY MISSPIGSTY 20250120PIGSTY 20250120PIGSTY 20250120PIGSTY 20250120
d13.x86_64PIGSTY 20251108PIGSTY 20251108PIGSTY 20251108PIGSTY 20251108PIGSTY 20251108
d13.aarch64PIGSTY 20251108PIGSTY 20251108PIGSTY 20251108PIGSTY 20251108PIGSTY 20251108
u22.x86_64PIGSTY MISSPIGSTY 20250120PIGSTY 20250120PIGSTY 20250120PIGSTY 20250120
u22.aarch64PIGSTY MISSPIGSTY 20250120PIGSTY 20250120PIGSTY 20250120PIGSTY 20250120
u24.x86_64PIGSTY 20251108PIGSTY 20251108PIGSTY 20251108PIGSTY 20251108PIGSTY 20251108
u24.aarch64PIGSTY 20251108PIGSTY 20251108PIGSTY 20251108PIGSTY 20251108PIGSTY 20251108

构建

您可以使用 pig build 命令构建 omnigres 扩展的 RPM / DEB 包:

pig build pkg omnigres         # 构建 RPM / DEB 包

安装

您可以直接安装 omnigres 扩展包的预置二进制包,首先确保 PGDGPIGSTY 仓库已经添加并启用:

pig repo add pgsql -u          # 添加仓库并更新缓存

使用 pig 或者是 apt/yum/dnf 安装扩展:

pig install omnigres;          # 当前活跃 PG 版本安装
pig ext install -y omnigres -v 18  # PG 18
pig ext install -y omnigres -v 17  # PG 17
pig ext install -y omnigres -v 16  # PG 16
pig ext install -y omnigres -v 15  # PG 15
pig ext install -y omnigres -v 14  # PG 14
dnf install -y omnigres_18       # PG 18
dnf install -y omnigres_17       # PG 17
dnf install -y omnigres_16       # PG 16
dnf install -y omnigres_15       # PG 15
dnf install -y omnigres_14       # PG 14
apt install -y postgresql-18-omnigres   # PG 18
apt install -y postgresql-17-omnigres   # PG 17
apt install -y postgresql-16-omnigres   # PG 16
apt install -y postgresql-15-omnigres   # PG 15
apt install -y postgresql-14-omnigres   # PG 14

创建扩展

CREATE EXTENSION omni_json;

用法

omni_json: JSON 工具箱

omni_json 扩展提供表到 JSON 的映射功能,支持在行转换为 JSON 时进行自定义变换。

定义表映射

SELECT omni_json.define_table_mapping(example, '{}');

列重命名

SELECT omni_json.define_table_mapping(example, '{
    "columns": { "dob": { "path": "date_of_birth" } }
}');

嵌套键

SELECT omni_json.define_table_mapping(example, '{
    "columns": {
        "first_name": { "path": ["name", "first"] },
        "last_name":  { "path": ["name", "last"] }
    }
}');

列排除

SELECT omni_json.define_table_mapping(example, '{
    "columns": { "dob": { "exclude": true } }
}');

列变换

输入(JSON 到记录)和输出(记录到 JSON)变换:

{
    "columns": {
        "password": {
            "transform": {
                "input":  { "type": "text", "function": "encrypt_password" },
                "output": { "type": "text", "function": "mask_password" }
            }
        }
    }
}

以 JSON 形式查询

SELECT to_jsonb(products.*) FROM products;

从 JSON 插入

INSERT INTO people (dob, first_name, last_name)
    (SELECT dob, first_name, last_name
     FROM jsonb_populate_record(null::people,
         '{"first_name": "Jane", "last_name": "Doe", "dob": "1981-12-12"}'));

最后修改 2026-03-14: update extension metadata (953cbd0)