Re: finish TODOs in to_json_is_immutable, to_jsonb_is_immutable also add tests on it - Mailing list pgsql-hackers

From Vaibhav Dalvi
Subject Re: finish TODOs in to_json_is_immutable, to_jsonb_is_immutable also add tests on it
Date
Msg-id CA+vB=AELb=QjnpJRJC=m_uz=PGuRNgDJjazBvLbmOWuCgUqHQA@mail.gmail.com
Whole thread Raw
In response to Re: finish TODOs in to_json_is_immutable, to_jsonb_is_immutable also add tests on it  (jian he <jian.universality@gmail.com>)
List pgsql-hackers
Hi Jian,

Thanks for working on this. The patch looks good, but I have a few observations:

1. Index creation fails for range types regardless of the base data type:

postgres=# create type range_int as range(subtype=int);
CREATE TYPE
postgres=# create table range_table(r1 range_int);
CREATE TABLE
postgres=# create index on range_table(json_array(r1 returning jsonb));
ERROR: functions in index expression must be marked IMMUTABLE

I believe this is because range_out is a stable function. Consequently, the following
code snippet in to_jsonb_is_immutable may be redundant, or should simply return
false without recursing for the sub-type:

+ else if (att_typtype == TYPTYPE_RANGE)
+ {
+ to_jsonb_is_immutable(get_range_subtype(typoid), contain_mutable);
+ }

2. Regarding the function names to_jsonb_is_immutable and to_json_is_immutable:
since these do not return a boolean value, "is" may no longer be appropriate. Perhaps
something like to_jsonb_check_mutable would be more accurate?

Best regards,
Vaibhav Dalvi
EnterpriseDB

pgsql-hackers by date:

Previous
From: Frits Hoogland
Date:
Subject: Re: static tracepoints in pgstat_report_wait_start/end
Next
From: Jim Jones
Date:
Subject: Re: ALTER TABLE: warn when actions do not recurse to partitions