Skip to content

jsonb_set_lax

Backport of PostgreSQL 13 jsonb_set_lax for PostgreSQL 9.5 through 12

jsonb_set_lax · Backport of PostgreSQL 13 jsonb_set_lax for PostgreSQL 9.5 through 12

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
100556jsonb_set_laxjsonb_set_lax1.0.0FUNCPostgreSQLC

PostgreSQL · 10, 11, 12

Usage

Sources:

jsonb_set_lax backports PostgreSQL 13’s same-named function to PostgreSQL 9.5 through 12. It changes how an SQL NULL replacement is handled: use_json_null, delete_key, return_target, or raise_exception can be selected.

CREATE EXTENSION jsonb_set_lax;
SELECT jsonb_set_lax('{"a":1}'::jsonb, '{a}', NULL, true, 'use_json_null');
SELECT jsonb_set_lax('{"a":1}'::jsonb, '{a}', NULL, true, 'delete_key');

The extension installs into pg_catalog and is not relocatable. Its source deliberately refuses PostgreSQL 13 and later, where the core implementation should be used instead. Distinguish SQL NULL from JSON null, validate the treatment string, and test missing paths and arrays before migrating logic between this backport and a newer server.

Table reader