OSDN Git Service

Make sure printtup() always sends the number of columns previously
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 26 May 2003 17:51:38 +0000 (17:51 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 26 May 2003 17:51:38 +0000 (17:51 +0000)
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

index 1d2c6cc..29ed33c 100644 (file)
@@ -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;