documentdb_core

微软DocumentDB的核心API层实现

概览

扩展包名版本分类许可证语言
documentdb0.114SIMMITC
ID扩展名BinLibLoadCreateTrustReloc模式
9000documentdb-
9010documentdb_core-
9020documentdb_distributed-
9030documentdb_extended_rum-
相关扩展mongo_fdw rum pg_jsonschema jsquery pg_cron postgis vector
下游依赖documentdb documentdb_distributed

版本

类型仓库版本PG 大版本包名依赖
EXTPIGSTY0.1141817161514documentdb-
RPMPIGSTY0.1141817161514documentdb_$vpostgresql$v-contrib, pg_cron_$v, pgvector_$v, rum_$v, postgis36_$v
DEBPIGSTY0.1141817161514postgresql-$v-documentdbpostgresql-$v-cron, postgresql-$v-pgvector, postgresql-$v-rum, postgresql-$v-postgis-3
OS / PGPG18PG17PG16PG15PG14
el8.x86_64PIGSTY 0.114PIGSTY 0.114PIGSTY 0.114PIGSTY 0.114N/A
el8.aarch64PIGSTY 0.114PIGSTY 0.114PIGSTY 0.114PIGSTY 0.114N/A
el9.x86_64PIGSTY 0.114PIGSTY 0.114PIGSTY 0.114PIGSTY 0.114N/A
el9.aarch64PIGSTY 0.114PIGSTY 0.114PIGSTY 0.114PIGSTY 0.114N/A
el10.x86_64PIGSTY 0.114PIGSTY 0.114PIGSTY 0.114PIGSTY 0.114N/A
el10.aarch64PIGSTY 0.114PIGSTY 0.114PIGSTY 0.114PIGSTY 0.114N/A
d12.x86_64PIGSTY 0.114PIGSTY 0.114PIGSTY 0.114PIGSTY 0.114N/A
d12.aarch64PIGSTY 0.114PIGSTY 0.114PIGSTY 0.114PIGSTY 0.114N/A
d13.x86_64PGDG 0.114PGDG 0.114PGDG 0.114PGDG 0.114N/A
d13.aarch64PGDG 0.114PGDG 0.114PGDG 0.114PGDG 0.114N/A
u22.x86_64PIGSTY 0.114PIGSTY 0.114PIGSTY 0.114PIGSTY 0.114N/A
u22.aarch64PIGSTY 0.114PIGSTY 0.114PIGSTY 0.114PIGSTY 0.114N/A
u24.x86_64PIGSTY 0.114PIGSTY 0.114PIGSTY 0.114PIGSTY 0.114N/A
u24.aarch64PIGSTY 0.114PIGSTY 0.114PIGSTY 0.114PIGSTY 0.114N/A
u26.x86_64PGDG 0.114PGDG 0.114PGDG 0.114PGDG 0.114N/A
u26.aarch64PGDG 0.114PGDG 0.114PGDG 0.114PGDG 0.114N/A

构建

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

pig build pkg documentdb         # 构建 RPM / DEB 包

安装

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

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

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

pig install documentdb;          # 当前活跃 PG 版本安装
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 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 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, pg_documentdb_core';

创建扩展

CREATE EXTENSION documentdb_core;

用法

来源:

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

配置与安装

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

shared_preload_libraries = 'pg_documentdb_core'

对于完整的单节点堆栈,官方助手还会预加载pg_cronpg_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_coresearch_path中,否则请显式使用模式限定名。

重要对象

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

操作边界

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

版本0.114-0保持documentdb_core与整个DocumentDB堆栈一致。上游变更日志未标识此发布单独的用户核心API迁移,因此没有新的独立工作流程声明。