pgrx_jsonb
pgrx_jsonb · Proof-of-concept pgrx functions for iterating PostgreSQL JSONB internals and reconstructing JSON values
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 100912 | pgrx_jsonb | pgrx_jsonb | 0.0.0 | FUNC | MIT | Rust |
PostgreSQL · 11, 12, 13, 14, 15, 16
Usage
Sources:
pgrx_jsonb is a proof of concept for iterating PostgreSQL’s internal JSONB representation from Rust/pgrx. Upstream explicitly says not to use it for anything important. Its three demonstration functions are useful only when studying extension internals.
Core Workflow
Install it only in a disposable development database and compare the demonstration paths:
The first function walks the low-level representation and serializes it, while the other two report whether the top-level value is an object through different code paths.
Important Objects
jsonb_to_textconverts a JSONB value to text through the prototype iterator.jsonb_testchecks for an object through the custom low-level iterator.jsonb_test2performs the comparison using pgrx’s higher-level JSONB wrapper.
Safety and Compatibility Notes
The iterator relies on PostgreSQL internal JSONB APIs and contains assertions, unwraps, panics, and unimplemented branches for some token types. Unsupported data can raise an error or terminate the backend process. The cataloged version is 0.0.0 and the project has no stable compatibility promise. Use PostgreSQL’s built-in JSONB functions or maintained pgrx APIs in real extensions.