Skip to content

Commit 6107aa8

Browse files
committed
Fix ExecMakeTableFunctionResult to verify that all rows returned by a SRF
returning "record" actually do have the same rowtype. This is needed because the parser can't realistically enforce that they will all have the same typmod, as seen in a recent example from David Wheeler. Back-patch to 8.0, which is as far back as we have the notion of RECORD subtypes being distinguished by typmod. Wheeler's example depends on 8.4-and-up features, but I suspect there may be ways to provoke similar failures before 8.4.
1 parent e4b0858 commit 6107aa8

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/backend/executor/execQual.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.171.4.4 2007/02/06 17:35:41 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.171.4.5 2010/08/26 18:55:19 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1538,6 +1538,16 @@ ExecMakeTableFunctionResult(ExprState *funcexpr,
15381538

15391539
td = DatumGetHeapTupleHeader(result);
15401540

1541+
/*
1542+
* Verify all returned rows have same subtype; necessary in
1543+
* case the type is RECORD.
1544+
*/
1545+
if (HeapTupleHeaderGetTypeId(td) != tupdesc->tdtypeid ||
1546+
HeapTupleHeaderGetTypMod(td) != tupdesc->tdtypmod)
1547+
ereport(ERROR,
1548+
(errcode(ERRCODE_DATATYPE_MISMATCH),
1549+
errmsg("rows returned by function are not all of the same row type")));
1550+
15411551
/*
15421552
* tuplestore_puttuple needs a HeapTuple not a bare
15431553
* HeapTupleHeader, but it doesn't need all the fields.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy