On Sun, Mar 10, 2024 at 10:57 PM jian he <jian.universal...@gmail.com> wrote: > > one more issue.
Hi one more documentation issue. after applied V42, 0001 to 0003, there are 11 appearance of `FORMAT JSON` in functions-json.html still not a single place explained what it is for. json_query ( context_item, path_expression [ PASSING { value AS varname } [, ...]] [ RETURNING data_type [ FORMAT JSON [ ENCODING UTF8 ] ] ] [ { WITHOUT | WITH { CONDITIONAL | [UNCONDITIONAL] } } [ ARRAY ] WRAPPER ] [ { KEEP | OMIT } QUOTES [ ON SCALAR STRING ] ] [ { ERROR | NULL | EMPTY { [ ARRAY ] | OBJECT } | DEFAULT expression } ON EMPTY ] [ { ERROR | NULL | EMPTY { [ ARRAY ] | OBJECT } | DEFAULT expression } ON ERROR ]) FORMAT JSON seems just a syntax sugar or for compatibility in json_query. but it returns an error when the returning type category is not TYPCATEGORY_STRING. for example, even the following will return an error. ` CREATE TYPE regtest_comptype AS (b text); SELECT JSON_QUERY(jsonb '{"a":{"b":"c"}}', '$.a' RETURNING regtest_comptype format json); ` seems only types in[0] will not generate an error, when specifying FORMAT JSON in JSON_QUERY. so it actually does something, not a syntax sugar? [0] https://www.postgresql.org/docs/current/datatype-character.html