Re: pgsql: Add more SQL/JSON constructor functions - Mailing list pgsql-hackers

From jian he
Subject Re: pgsql: Add more SQL/JSON constructor functions
Date
Msg-id CACJufxEo4sUjKCYtda0_qt9tazqqKPmF1cqhW9KBOUeJFqQd2g@mail.gmail.com
Whole thread Raw
In response to Re: pgsql: Add more SQL/JSON constructor functions  (Amit Langote <amitlangote09@gmail.com>)
Responses Re: pgsql: Add more SQL/JSON constructor functions
List pgsql-hackers
we still have problem in transformJsonBehavior

currently transformJsonBehavior:
SELECT JSON_VALUE(jsonb '1234', '$' RETURNING bit(3)  DEFAULT 010111 ON ERROR);
ERROR:  cannot cast behavior expression of type text to bit
LINE 1: ...VALUE(jsonb '1234', '$' RETURNING bit(3)  DEFAULT 010111 ON ...

here, 010111 will default to int4, so "cannot cast behavior expression
of type text to bit"
is wrong?
also int4/int8 can be explicitly cast to bit(3), in this case, it
should return 111.


Also, do we want to deal with bit data type's typmod like we did for
string type in transformJsonBehavior?
like:
SELECT JSON_VALUE(jsonb '"111"', '$'  RETURNING bit(3) default '1111' on error);
should return error:
ERROR:  bit string length 2 does not match type bit(3)
or success

The attached patch makes it return an error, similar to what we did
for the fixed length string type.

Attachment

pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: Pluggable cumulative statistics
Next
From: Jeff Davis
Date:
Subject: Re: Built-in CTYPE provider