Skip to content

Commit 07908c9

Browse files
committed
Ensure that the Datum generated from a whole-row Var contains valid
type ID information even when it's a record type. This is needed to handle whole-row Vars referencing subquery outputs. Per example from Richard Huxton.
1 parent 32fcfcd commit 07908c9

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/backend/access/common/heaptuple.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
*
1818
* IDENTIFICATION
19-
* $PostgreSQL: pgsql/src/backend/access/common/heaptuple.c,v 1.100 2005/10/15 02:49:08 momjian Exp $
19+
* $PostgreSQL: pgsql/src/backend/access/common/heaptuple.c,v 1.101 2005/10/19 18:18:32 tgl Exp $
2020
*
2121
*-------------------------------------------------------------------------
2222
*/
@@ -27,6 +27,7 @@
2727
#include "access/tuptoaster.h"
2828
#include "catalog/pg_type.h"
2929
#include "executor/tuptable.h"
30+
#include "utils/typcache.h"
3031

3132

3233
/* ----------------------------------------------------------------
@@ -603,11 +604,18 @@ heap_getsysattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
603604
*
604605
* We have to make a copy of the tuple so we can safely insert the
605606
* Datum overhead fields, which are not set in on-disk tuples.
607+
*
608+
* It's possible that the passed tupleDesc is a record type that
609+
* hasn't been "blessed" yet, so cover that case.
606610
*/
607611
case InvalidAttrNumber:
608612
{
609613
HeapTupleHeader dtup;
610614

615+
if (tupleDesc->tdtypeid == RECORDOID &&
616+
tupleDesc->tdtypmod < 0)
617+
assign_record_type_typmod(tupleDesc);
618+
611619
dtup = (HeapTupleHeader) palloc(tup->t_len);
612620
memcpy((char *) dtup, (char *) tup->t_data, tup->t_len);
613621

src/backend/executor/execQual.c

Lines changed: 2 additions & 2 deletions
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.181 2005/10/15 02:49:16 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.182 2005/10/19 18:18:33 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -3180,7 +3180,7 @@ ExecInitExpr(Expr *node, PlanState *parent)
31803180
{
31813181
/* generic record, use runtime type assignment */
31823182
rstate->tupdesc = ExecTypeFromExprList(rowexpr->args);
3183-
rstate->tupdesc = BlessTupleDesc(rstate->tupdesc);
3183+
BlessTupleDesc(rstate->tupdesc);
31843184
}
31853185
else
31863186
{

0 commit comments

Comments
 (0)