| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com> |
| Cc: | murasovb(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org |
| Subject: | Re: BUG #19906: Backend crash (signal 11) creating a LANGUAGE sql function that returns a composite type from a sub- |
| Date: | 2026-11-16 19:28:59 |
| Message-ID: | 126458.1794857339@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com> writes:
> The crash can be fixed by checking for pstate not being NULL in
> coerce_record_to_complex(), which makes it error out with "cannot cast
> type record to t". But I'm unsure if we should do just that, or rather
> teach check_sql_fn_retval() to expand the whole-row Var so that this
> works like s::t?
Yeah, I was just looking at this too. It's been a crash case since
v13, and before that you got
ERROR: return type mismatch in function declared to return t
DETAIL: Final statement returns record instead of integer at column 1.
CONTEXT: SQL function "m1"
So it's never worked, and there's been no complaints to speak of,
and it's easy to work around:
CREATE FUNCTION m1() RETURNS TABLE (x t) LANGUAGE sql
AS $$ SELECT s::t FROM (SELECT t.* FROM t) s $$;
So I think that putting in a defense against null pstate in
coerce_record_to_complex() is sufficient. Making it work would be
very very tedious (I don't think we have any prefab code that
would be suitable) and evidently there's no demand.
Actually the annoying part of this is that we ought to change the
comments elsewhere in parse_coerce.c that say that pstate is only
used to return data about Param types, because that's evidently a
lie (and has been since well before v13...).
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2026-11-16 19:31:58 | Re: BUG #19905: loread() with length near INT_MAX: "invalid memory alloc request size" (int32 overflow) |
| Previous Message | Andres Freund | 2026-11-16 19:14:32 | Re: Two bugs around ALTER TYPE |