Skip to content

documentdb_core

Core API surface for DocumentDB on PostgreSQL

documentdb · Core API surface for DocumentDB on PostgreSQL

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
9010documentdb_coredocumentdb1.2SIMMITC
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--sLd--NoYesYesYesnono
SQL 1.2-0. RPM requires external RUM on PG15–17.

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXTPIGSTY1.219 18 17 16 15documentdb-
RPMPIGSTY1.219 18 17 16 15documentdb_$vpostgresql$v-contrib, pg_cron_$v, pgvector_$v, rum_$v, postgis37_$v
DEBPIGSTY1.219 18 17 16 15postgresql-$v-documentdbpostgresql-$v-cron, postgresql-$v-pgvector, postgresql-$v-rum, postgresql-$v-postgis-3
Linux / 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

Source

pig build pkg documentdb;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install documentdb;		# install by package name
pig install documentdb_core;		# install by extension name

pig install documentdb_core -v 19;   # install for PG 19
pig install documentdb_core -v 18;   # install for PG 18
pig install documentdb_core -v 17;   # install for PG 17
pig install documentdb_core -v 16;   # install for PG 16
pig install documentdb_core -v 15;   # install for PG 15

Config this extension to shared_preload_libraries:

shared_preload_libraries = 'pg_documentdb_core';

Create this extension with:

CREATE EXTENSION documentdb_core;

Usage

Sources:

documentdb_core is the low-level BSON type and operator layer used by DocumentDB. It is normally installed as a dependency of documentdb; by itself it does not provide collection CRUD, the MongoDB wire protocol, or the gateway.

Configure and Install

pg_documentdb_core must be loaded through shared_preload_libraries, followed by a PostgreSQL restart:

shared_preload_libraries = 'pg_documentdb_core'

For a complete single-node stack, the official helper also preloads pg_cron and pg_documentdb. Install the parent extension in normal deployments:

CREATE EXTENSION documentdb CASCADE;

Direct installation is useful only for low-level BSON work:

CREATE EXTENSION documentdb_core;

The extension is superuser-only and non-relocatable.

BSON Workflow

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

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

Use explicit schema qualification unless documentdb_core is in search_path.

Important Objects

  • documentdb_core.bson stores BSON documents.
  • documentdb_core.bsonquery represents BSON query values used by the DocumentDB planner and operator layer.
  • documentdb_core.bsonsequence represents sequences of BSON values.
  • bson_get_value and bson_get_value_text, also exposed through -> and ->>, extract a path from a BSON document.
  • bson_from_bytea, bson_to_bytea, bson_json_to_bson, and bson_to_json_string support serialization boundaries.
  • bson_btree_ops and bson_hash_ops provide comparison and hashing support required by higher layers.

Operational Boundaries

BSON comparison, indexing, and numeric semantics follow DocumentDB’s implementation and should not be assumed to match PostgreSQL jsonb. Most objects are infrastructure for documentdb; applications seeking collections and MongoDB commands should use the parent extension or gateway rather than building directly on internal types.

Use SQL extension version 1.0-0 with matching DocumentDB components. This core layer continues to supply BSON infrastructure; collection and gateway workflows belong to the parent extension.

DocumentDB 1.2 changes

The 1.2 source declares SQL version 1.2-0 for documentdb_core, with the supplied 1.0 → 1.1 → 1.2 update chain. Upgrade it together with the API and index components using the official package or container procedure, after backing up data; a downgrade of updated data to 1.0 is unsupported. bson_build_document now accepts timestamptz as a BSON date at millisecond precision. Collation remains opt-in through documentdb_core.enableCollation = on; explicit simple collation is also rejected while that setting is off. Application tests should check comparison-sensitive queries after enabling it.

Table reader