From: | Dmitry Dolgov <9erthalion6(at)gmail(dot)com> |
---|---|
To: | Michael Paquier <michael(at)paquier(dot)xyz> |
Cc: | 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-06 11:34:51 |
Message-ID: | CA+q6zcVYyjDEh9hkKi3eG81TBghMRjVySNA4gAsQU0q4gJPbFQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
> On Tue, Aug 6, 2019 at 9:32 AM Michael Paquier <michael(at)paquier(dot)xyz> wrote:
>
> On Tue, Aug 06, 2019 at 06:41:34AM +0000, PG Bug reporting form wrote:
> > Following query works fine in previous freebsd versions
> >
> > SELECT
> > id_item
> > FROM json_populate_recordset(null::record, '[{"id_item":776}]')
> > AS
> > (
> > id_item int
> > );
>
> This visibly is a regression between 11 and 10, and one bisect later
> here is the culprit:
> commit: 37a795a60b4f4b1def11c615525ec5e0e9449e05
> author: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
> date: Thu, 26 Oct 2017 13:47:45 -0400
> Support domains over composite types.
Looks like there are tests for such behaviour with exactly this error, is there
a chance it was a feature? But anyway before this change there was an
invocation of get_call_result_type in the branch
if (have_record_arg && PG_ARGISNULL(0))
Adding similar stuff to the current implementation make this error to disappear
for me and passes tests (except those where we actually expect this error):
--- a/src/backend/utils/adt/jsonfuncs.c
+++ b/src/backend/utils/adt/jsonfuncs.c
@@ -3647,7 +3647,19 @@ populate_recordset_worker(FunctionCallInfo
fcinfo, const char *funcname,
}
}
else
+ {
+ TupleDesc tupdesc;
+
rec = NULL;
+ if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("function returning record called in context "
+ "that cannot accept type record")));
+
+ cache->c.io.composite.base_typid = tupdesc->tdtypeid;
+ cache->c.io.composite.base_typmod = tupdesc->tdtypmod;
+ }
/* if the json is null send back an empty set */
if (PG_ARGISNULL(json_arg_num))
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2019-08-06 19:38:26 | Re: BUG #15940: json_populate_recordset fails with ERROR: record type has not been registered |
Previous Message | Kyotaro Horiguchi | 2019-08-06 08:11:40 | Re: BUG #15938: Corrupted WAL segment after crash recovery |