Pavel Stehule <pavel.stehule@gmail.com> writes:
> čt 17. 12. 2020 v 19:49 odesílatel Tom Lane <tgl@sss.pgh.pa.us> napsal:
>> So ... what's the problem with that? Seems like what you should put
>> in and what you should get out should be the same type.
> I don't think so. For XML or JSON the target can be different, and it can
> safe one CAST
> DECLARE
> n int;
> v varchar;
> js jsonb default '{"n": 100, "v" : "Hello"};
> BEGIN
> n := js['n'];
> v := js['v'];
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.
But in any case, the discussion here is about the source datatype
for an assignment, which this example doesn't even contain.
regards, tom lane