sql/json query function JsonBehavior default expression's collation may differ from returning type's collation - Mailing list pgsql-hackers

From jian he
Subject sql/json query function JsonBehavior default expression's collation may differ from returning type's collation
Date
Msg-id CACJufxHVwYYSyiVQ6o+PsRX6zQ7rAFinh_fv1kCfTsT1xG4Zeg@mail.gmail.com
Whole thread Raw
List pgsql-hackers
hi.

create domain d1 as text collate case_insensitive;
select json_value('{"a": "A"}', '$.a' returning d1 default 'C' on
empty) = 'a'; --return true
select json_value('{"a": "A"}', '$.c' returning d1 default 'A' on
empty) = 'a'; --return true

select json_value('{"a": "A"}', '$.c' returning d1 default 'A' collate
"C" on empty) = 'a';
currently the above query will produce an error:
ERROR:  unrecognized node type: 31
this error message needs to be fixed.

however, if no error is raised, should the query return true or false?
if not error out, It also means that the collation of the json_value expression
is determined at runtime, which makes it unsuitable for use in index creation or
check constraints.

overall, raising an error if the collation of the
JsonBehavior DEFAULT clause differs from that of the RETURNING clause
is the best option.

what do you think?



pgsql-hackers by date:

Previous
From: Fujii Masao
Date:
Subject: Re: Requested WAL segment xxx has already been removed
Next
From: Andres Freund
Date:
Subject: Re: Changing shared_buffers without restart