跳转到主要内容

documentdb_core

微软DocumentDB的核心API层实现

概览

扩展包名版本分类许可证语言
documentdb1.2SIMMITC
ID扩展名BinLibLoadCreateTrustReloc模式
9000documentdb否是是是否否documentdb_api
9010documentdb_core否是是是否否documentdb_core
9030documentdb_extended_rum否是是是否是documentdb_extended_rum_catalog

SQL 1.0-0; RPM external RUM dependency only on PG15-17.

版本

类型仓库版本PG 大版本包名依赖
EXTPIGSTY1.21817161514documentdb-
RPMPIGSTY1.21817161514documentdb_$vpostgresql$v-contrib, pg_cron_$v, pgvector_$v, rum_$v, postgis37_$v
DEBPIGSTY1.21817161514postgresql-$v-documentdbpostgresql-$v-cron, postgresql-$v-pgvector, postgresql-$v-rum, postgresql-$v-postgis-3
OS / PGPG19PG18PG17PG16PG15
el8.x86_64N/APIGSTY 1.2PIGSTY 1.2PIGSTY 1.2PIGSTY 1.2
el8.aarch64N/APIGSTY 1.2PIGSTY 1.2PIGSTY 1.2PIGSTY 1.2
el9.x86_64PIGSTY 1.2PIGSTY 1.2PIGSTY 1.2PIGSTY 1.2PIGSTY 1.2
el9.aarch64PIGSTY 1.2PIGSTY 1.2PIGSTY 1.2PIGSTY 1.2PIGSTY 1.2
el10.x86_64PIGSTY 1.2PIGSTY 1.2PIGSTY 1.2PIGSTY 1.2PIGSTY 1.2
el10.aarch64PIGSTY 1.2PIGSTY 1.2PIGSTY 1.2PIGSTY 1.2PIGSTY 1.2
d12.x86_64PIGSTY 1.2PIGSTY 1.2PIGSTY 1.2PIGSTY 1.2PIGSTY 0.117
d12.aarch64PIGSTY 1.2PIGSTY 1.2PIGSTY 1.2PIGSTY 1.2PIGSTY 0.117
d13.x86_64PIGSTY 1.2PGDG 1.2PGDG 1.2PGDG 1.2PGDG 1.2
d13.aarch64PIGSTY 1.2PGDG 1.2PGDG 1.2PGDG 1.2PGDG 1.2
u22.x86_64PIGSTY 1.2PIGSTY 1.2PIGSTY 1.2PIGSTY 1.2PIGSTY 0.117
u22.aarch64PIGSTY 1.2PIGSTY 1.2PIGSTY 1.2PIGSTY 1.2PIGSTY 0.117
u24.x86_64PIGSTY 1.2PIGSTY 1.2PIGSTY 1.2PIGSTY 1.2PIGSTY 0.117
u24.aarch64PIGSTY 1.2PIGSTY 1.2PIGSTY 1.2PIGSTY 1.2PIGSTY 0.117
u26.x86_64PIGSTY 1.2PGDG 1.2PGDG 1.2PGDG 1.2PGDG 1.2
u26.aarch64PIGSTY 1.2PGDG 1.2PGDG 1.2PGDG 1.2PGDG 1.2

构建

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

pig build pkg documentdb         # 构建 RPM / DEB 包

安装

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

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

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

安装
pig install documentdb;          # 当前活跃 PG 版本安装
pig
pig ext install -y documentdb -v 19  # PG 19
pig ext install -y documentdb -v 18  # PG 18
pig ext install -y documentdb -v 17  # PG 17
pig ext install -y documentdb -v 16  # PG 16
pig ext install -y documentdb -v 15  # PG 15
dnf
dnf install -y documentdb_19       # PG 19
dnf install -y documentdb_18       # PG 18
dnf install -y documentdb_17       # PG 17
dnf install -y documentdb_16       # PG 16
dnf install -y documentdb_15       # PG 15
apt
apt install -y postgresql-19-documentdb   # PG 19
apt install -y postgresql-18-documentdb   # PG 18
apt install -y postgresql-17-documentdb   # PG 17
apt install -y postgresql-16-documentdb   # PG 16
apt install -y postgresql-15-documentdb   # PG 15

预加载配置:

shared_preload_libraries = 'pg_documentdb_core';

创建扩展:

CREATE EXTENSION documentdb_core;

用法

来源:

documentdb_core 是DocumentDB使用的低层BSON类型和操作符层。通常它作为 documentdb 的依赖项安装,自身不提供集合CRUD、MongoDB网络协议或网关。

配置与安装

必须通过 shared_preload_libraries 加载 pg_documentdb_core,然后重启PostgreSQL:

shared_preload_libraries = 'pg_documentdb_core'

对于完整的单节点堆栈,官方助手还会预加载 pg_cron 和 pg_documentdb。在常规部署中安装父扩展:

CREATE EXTENSION documentdb CASCADE;

直接安装仅适用于低层BSON工作:

CREATE EXTENSION documentdb_core;

该扩展为超级用户专用且不可重定位。

BSON 工作流

SELECT '{"name":"Ada","score":42}'::documentdb_core.bson;

SELECT documentdb_core.bson_get_value_text(
  '{"name":"Ada","score":42}'::documentdb_core.bson,
  'name'
);

除非 documentdb_core 在 search_path 中,否则请显式使用模式限定名。

重要对象

  • documentdb_core.bson 存储BSON文档。
  • documentdb_core.bsonquery 表示用于DocumentDB计划器和操作符层的BSON查询值。
  • documentdb_core.bsonsequence 表示BSON值序列。
  • bson_get_value 和 bson_get_value_text,通过 -> 和 ->> 也暴露出来,从BSON文档中提取路径。
  • bson_from_bytea, bson_to_bytea, bson_json_to_bson 和 bson_to_json_string 支持序列化边界。
  • bson_btree_ops 和 bson_hash_ops 提供更高层所需的比较和哈希支持。

操作边界

BSON比较、索引和数值语义遵循DocumentDB的实现,不应假设与PostgreSQL jsonb 匹配。大多数对象是 documentdb 的基础架构;寻求集合和MongoDB命令的应用程序应使用父扩展或网关而非直接构建在内部类型上。

使用 SQL 扩展版本 1.0-0,并与其他 DocumentDB 组件保持匹配。核心层仍提供 BSON 基础能力,集合操作和网关工作流由上层扩展承担。

DocumentDB 1.2 变化

1.2 源码将 documentdb_core 的 SQL 版本设为 1.2-0,并提供 1.0 → 1.1 → 1.2 升级链。备份数据后,应按官方包或容器流程,与 API 和索引组件一起升级;不支持将升级后的数据降回 1.0。bson_build_document 现在可把 timestamptz 转成毫秒精度 BSON 日期。排序规则仍需显式设置 documentdb_core.enableCollation = on,关闭时也会拒绝显式 simple 排序规则。启用后应测试受比较语义影响的应用查询。

这个页面对您有帮助吗?

表格阅读器