Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xT2O5-000000003YH-13r9 for pgsql-bugs@arkaria.postgresql.org; Mon, 16 Nov 2026 19:29:09 +0000 Received: from localhost ([127.0.0.1]:33246 helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xT2O4-00000000wmi-2YDD for pgsql-bugs@arkaria.postgresql.org; Mon, 16 Nov 2026 19:29:08 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]:56286) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xT2O4-00000000wmZ-1WPR for pgsql-bugs@lists.postgresql.org; Mon, 16 Nov 2026 19:29:08 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xT2Ny-000000002eQ-1RHJ for pgsql-bugs@lists.postgresql.org; Mon, 16 Nov 2026 19:29:08 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.18.1/8.18.1) with ESMTP id 6AGJSxbA126459; Mon, 16 Nov 2026 14:28:59 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 sss.pgh.pa.us 6AGJSxbA126459 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sss.pgh.pa.us; s=default; t=1794857339; bh=u2hGVeck2Z1Zxv8B4zr601rtixVdgRlBXVnMcIF7hY8=; h=From:To:cc:Subject:In-reply-to:References:Date:From; b=jlwv4hJmR7OFBNc0h+zncUt70lJNU75Yg+pnIwZbXBskktUyYvHG/f+We2UvkXYVh BzEGUo0FmZTP/Y9/i5cBl0Bp9NHnPPgPawy1YbKAzL2/NahkR/a/8elQ6dBB/f1NiE 3K3srEzTOiQcnmDqjJWxO1B9WmxBAKH0/sBsj9kc= From: Tom Lane To: Ayush Tiwari cc: murasovb@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #19906: Backend crash (signal 11) creating a LANGUAGE sql function that returns a composite type from a sub- In-reply-to: References: <19906-229033275b593ef0@postgresql.org> Comments: In-reply-to Ayush Tiwari message dated "Tue, 17 Nov 2026 00:26:09 +0530" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <126457.1794857339.1@sss.pgh.pa.us> Date: Mon, 16 Nov 2026 14:28:59 -0500 Message-ID: <126458.1794857339@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Ayush Tiwari 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