• Tom Lane's avatar
    Fix corner-case behaviors in JSON/JSONB field extraction operators. · 41dd50e8
    Tom Lane authored
    Cause the path extraction operators to return their lefthand input,
    not NULL, if the path array has no elements.  This seems more consistent
    since the case ought to correspond to applying the simple extraction
    operator (->) zero times.
    
    Cause other corner cases in field/element/path extraction to return NULL
    rather than failing.  This behavior is arguably more useful than throwing
    an error, since it allows an expression index using these operators to be
    built even when not all values in the column are suitable for the
    extraction being indexed.  Moreover, we already had multiple
    inconsistencies between the path extraction operators and the simple
    extraction operators, as well as inconsistencies between the JSON and
    JSONB code paths.  Adopt a uniform rule of returning NULL rather than
    throwing an error when the JSON input does not have a structure that
    permits the request to be satisfied.
    
    Back-patch to 9.4.  Update the release notes to list this as a behavior
    change since 9.3.
    41dd50e8
json.sgml 22.3 KB