From 8c43300cccb626bae3ca84f4ae89c051f81190bb Mon Sep 17 00:00:00 2001
From: Tom Lane <tgl@sss.pgh.pa.us>
Date: Mon, 26 May 2003 17:51:38 +0000
Subject: [PATCH] Make sure printtup() always sends the number of columns
 previously advertised in RowDescription message.  Depending on the physical
 tuple's column count is not really correct, since according to heap_getattr()
 conventions the tuple may be short some columns, which will automatically get
 read as nulls.  Problem has been latent since forever, but was only exposed
 by recent change to skip a projection step in SELECT * FROM...

---
 src/backend/access/common/printtup.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c
index 1d2c6cc4f0a..29ed33c9f61 100644
--- a/src/backend/access/common/printtup.c
+++ b/src/backend/access/common/printtup.c
@@ -9,7 +9,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.73 2003/05/13 18:39:50 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.74 2003/05/26 17:51:38 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -286,7 +286,7 @@ printtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver *self)
 {
 	DR_printtup *myState = (DR_printtup *) self;
 	StringInfoData buf;
-	int			natts = tuple->t_data->t_natts;
+	int			natts = typeinfo->natts;
 	int			i;
 
 	/* Set or update my derived attribute info, if needed */
@@ -370,7 +370,7 @@ printtup_20(HeapTuple tuple, TupleDesc typeinfo, DestReceiver *self)
 {
 	DR_printtup *myState = (DR_printtup *) self;
 	StringInfoData buf;
-	int			natts = tuple->t_data->t_natts;
+	int			natts = typeinfo->natts;
 	int			i,
 				j,
 				k;
@@ -517,7 +517,7 @@ debugStartup(DestReceiver *self, int operation, TupleDesc typeinfo)
 void
 debugtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver *self)
 {
-	int			natts = tuple->t_data->t_natts;
+	int			natts = typeinfo->natts;
 	int			i;
 	Datum		origattr,
 				attr;
@@ -573,7 +573,7 @@ printtup_internal_20(HeapTuple tuple, TupleDesc typeinfo, DestReceiver *self)
 {
 	DR_printtup *myState = (DR_printtup *) self;
 	StringInfoData buf;
-	int			natts = tuple->t_data->t_natts;
+	int			natts = typeinfo->natts;
 	int			i,
 				j,
 				k;
-- 
GitLab