diff options
| author | Andrew Dunstan <andrew@dunslane.net> | 2015-05-31 20:34:10 -0400 |
|---|---|---|
| committer | Andrew Dunstan <andrew@dunslane.net> | 2015-05-31 20:34:10 -0400 |
| commit | 37def4224505f3a23a5eef000f0d05daea59c5b5 (patch) | |
| tree | 24ee85c2bdb98cc867245fadadc6b4f3fcc65165 /src/backend/catalog | |
| parent | 75f9d17638c9c6bec34f80326c35010c47924728 (diff) | |
| download | postgresql-37def4224505f3a23a5eef000f0d05daea59c5b5.tar.gz | |
Rename jsonb_replace to jsonb_set and allow it to add new values
The function is given a fourth parameter, which defaults to true. When
this parameter is true, if the last element of the path is missing
in the original json, jsonb_set creates it in the result and assigns it
the new value. If it is false then the function does nothing unless all
elements of the path are present, including the last.
Based on some original code from Dmitry Dolgov, heavily modified by me.
Catalog version bumped.
Diffstat (limited to 'src/backend/catalog')
| -rw-r--r-- | src/backend/catalog/system_views.sql | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/backend/catalog/system_views.sql b/src/backend/catalog/system_views.sql index 18921c4bc5..e82a53aee9 100644 --- a/src/backend/catalog/system_views.sql +++ b/src/backend/catalog/system_views.sql @@ -922,3 +922,11 @@ RETURNS interval LANGUAGE INTERNAL STRICT IMMUTABLE AS 'make_interval'; + +CREATE OR REPLACE FUNCTION + jsonb_set(jsonb_in jsonb, path text[] , replacement jsonb, + create_if_missing boolean DEFAULT true) +RETURNS jsonb +LANGUAGE INTERNAL +STRICT IMMUTABLE +AS 'jsonb_set'; |
