JSONB Set Operations

When manipulating JSON collections of varying structure, it may be the case that an item is defined in some of the documents but not all. PostgreSQL provides the lax mode for this purpose, where the argument null_value_treatment determines the behavior in the case a function returns a NULL value. The argument can take one of the following values: 'raise_exception', 'use_json_null', 'delete_key', 'return_target', where 'use_json_null' is the default value. In PostgreSQL the lax mode is supported only for update (not query) operations with the function jsonb_set_lax. In MobilityDB, we kept the same semantics for the corresponding function jsonbsetSetLax, but we enabled similar behavior for all JSON operations that may return a null value, except that we replaced the value 'return_target' with 'return_null', since the former is not meaningful for set operations. For operators such as ->, the default value 'use_json_null' is used and cannot be changed, whereas for the corresponding functions jsonbsetObjectField, the last argument specifies the behavior in the case the function returns NULL. We illustrate this behavior for function jsonbsetObjectField below.