Re: [HACKERS] [PATCH] Generic type subscripting - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [HACKERS] [PATCH] Generic type subscripting
Date
Msg-id 113221.1608238237@sss.pgh.pa.us
Whole thread Raw
In response to Re: [HACKERS] [PATCH] Generic type subscripting  (Chapman Flack <chap@anastigmatix.net>)
Responses Re: [HACKERS] [PATCH] Generic type subscripting
List pgsql-hackers
Chapman Flack <chap@anastigmatix.net> writes:
> On 12/17/20 14:28, Tom Lane wrote:
>> If you're imagining that js['n'] and js['v'] would emit different
>> datatypes, forget it.  That would require knowing at parse time
>> what the structure of the json object will be at run time.

> Would it be feasible to analyze that as something like an implicit
> 'treat as' with the type of the assignment target?

TBH, I think that expending any great amount of effort in that direction
would be a big waste of effort.  We already have strongly-typed
composite types.  The use-case for json is where you *don't* have
ironclad guarantees about what the structure of the data is.

As for doing it implicitly, that is still going to fall foul of the
fundamental problem, which is that we don't have the info at parse
time.  Examples with constant values for the json input are not what
to look at, because they'll just mislead you as to what's possible.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Justin Pryzby
Date:
Subject: Re: New Table Access Methods for Multi and Single Inserts
Next
From: Chapman Flack
Date:
Subject: Re: [HACKERS] [PATCH] Generic type subscripting