summaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/jsonfuncs.c
diff options
context:
space:
mode:
authorAndrew Dunstan2015-06-08 00:46:00 +0000
committerAndrew Dunstan2015-06-08 00:46:00 +0000
commitb81c7b4098f52e64df89efe1461ba00a54649a10 (patch)
tree924db92137a235ef088724a3a967799f13da38a8 /src/backend/utils/adt/jsonfuncs.c
parentd23a3a603b8eed5e8e34b193d43e9ca5f380ef3f (diff)
Desupport jsonb subscript deletion on objects
Supporting deletion of JSON pairs within jsonb objects using an array-style integer subscript allowed for surprising outcomes. This was mostly due to the implementation-defined ordering of pairs within objects for jsonb. It also seems desirable to make jsonb integer subscript deletion consistent with the 9.4 era general purpose integer subscripting operator for jsonb (although that operator returns NULL when an object is encountered, while we prefer here to throw an error). Peter Geoghegan, following discussion on -hackers.
Diffstat (limited to 'src/backend/utils/adt/jsonfuncs.c')
-rw-r--r--src/backend/utils/adt/jsonfuncs.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/backend/utils/adt/jsonfuncs.c b/src/backend/utils/adt/jsonfuncs.c
index f87ba77e3e..c14d3f73fc 100644
--- a/src/backend/utils/adt/jsonfuncs.c
+++ b/src/backend/utils/adt/jsonfuncs.c
@@ -3400,6 +3400,11 @@ jsonb_delete_idx(PG_FUNCTION_ARGS)
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("cannot delete from scalar")));
+ if (JB_ROOT_IS_OBJECT(in))
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("cannot delete from object using integer subscript")));
+
if (JB_ROOT_COUNT(in) == 0)
PG_RETURN_JSONB(in);