Re: BUG #15940: json_populate_recordset fails with ERROR: record type has not been registered

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Merlin Moncure <mmoncure(at)gmail(dot)com>, Dmitry Dolgov <9erthalion6(at)gmail(dot)com>, yarexeray(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #15940: json_populate_recordset fails with ERROR: record type has not been registered
Date: 2019-08-19 22:04:25
Message-ID: 30049.1566252265@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Michael Paquier <michael(at)paquier(dot)xyz> writes:
> On Tue, Aug 06, 2019 at 02:53:45PM -0500, Merlin Moncure wrote:
>> For posterity I agree that OP was essentially exploiting undefined, or
>> at least poorly defined, behavior. For my money, I'd advise using
>> this function for cases where you don't want to use an in place type,
>> just a column list:

> If I were to change something here, that would be this error string
> exposed to the user. With the current error, there is no real way
> that the user knows what is wrong and why he/she should not do that.
> Could it be possible to add some recommendation for example on top of
> an error "cannot do that because blah"?

I concluded that we'd better restore the former behavior, or people
will complain that this is a regression. We can however do better
than the "record type has not been registered" error, at least for
the case where the error is being thrown at runtime. I went with

ERROR: could not determine row type for result of json_populate_record
HINT: Provide a non-null record argument, or call the function in the FROM clause using a column definition list.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2019-08-20 06:52:12 BUG #15967: Sequence generation using NEXTVAL() fails on 64bit systems
Previous Message Bansal, Abhishek (Abhishek) 2019-08-19 20:30:54 RE: Postgresql Query