finish TODOs in to_json_is_immutable, to_jsonb_is_immutable also add tests on it

jian he <jian.universality@gmail.com>

From: jian he <jian.universality@gmail.com>
To: PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2025-05-19T01:09:18Z
Lists: pgsql-hackers

Attachments

hi.

somehow, I accidentally saw the TODOs (commits [3]) on jsonb.c and json.c
for functions: to_json_is_immutable and to_jsonb_is_immutable.
The attached patch is to finalize these TODOs.

per coverage [1], [2],  there was zero coverage for these two functions.
so I also added extensive tests on it.

[1] https://coverage.postgresql.org/src/backend/utils/adt/jsonb.c.gcov.html
[2] https://coverage.postgresql.org/src/backend/utils/adt/json.c.gcov.html
[3] https://git.postgresql.org/cgit/postgresql.git/commit/?id=7081ac46ace8c459966174400b53418683c9fe5c

Commits

  1. make immutability tests in to_json and to_jsonb complete

  2. Include error location in errors from ComputeIndexAttrs().

  3. SQL/JSON: add standard JSON constructor functions