|
8 | 8 | *
|
9 | 9 | *
|
10 | 10 | * IDENTIFICATION
|
11 |
| - * $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.38 1999/01/24 05:40:47 tgl Exp $ |
| 11 | + * $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.39 1999/01/24 22:50:58 tgl Exp $ |
12 | 12 | *
|
13 | 13 | *-------------------------------------------------------------------------
|
14 | 14 | */
|
@@ -91,27 +91,24 @@ printtup(HeapTuple tuple, TupleDesc typeinfo)
|
91 | 91 | pq_putnchar("D", 1);
|
92 | 92 |
|
93 | 93 | /* ----------------
|
94 |
| - * send a bitmap of which attributes are null |
| 94 | + * send a bitmap of which attributes are not null |
95 | 95 | * ----------------
|
96 | 96 | */
|
97 | 97 | j = 0;
|
98 | 98 | k = 1 << 7;
|
99 |
| - for (i = 0; i < tuple->t_data->t_natts;) |
| 99 | + for (i = 0; i < tuple->t_data->t_natts; ++i) |
100 | 100 | {
|
101 |
| - i++; /* heap_getattr is a macro, so no |
102 |
| - * increment */ |
103 |
| - attr = heap_getattr(tuple, i, typeinfo, &isnull); |
104 |
| - if (!isnull) |
105 |
| - j |= k; |
| 101 | + if (! heap_attisnull(tuple, i + 1)) |
| 102 | + j |= k; /* set bit if not null */ |
106 | 103 | k >>= 1;
|
107 |
| - if (!(i & 7)) |
| 104 | + if (k == 0) /* end of byte? */ |
108 | 105 | {
|
109 | 106 | pq_putint(j, 1);
|
110 | 107 | j = 0;
|
111 | 108 | k = 1 << 7;
|
112 | 109 | }
|
113 | 110 | }
|
114 |
| - if (i & 7) |
| 111 | + if (k != (1 << 7)) /* flush last partial byte */ |
115 | 112 | pq_putint(j, 1);
|
116 | 113 |
|
117 | 114 | /* ----------------
|
@@ -243,27 +240,24 @@ printtup_internal(HeapTuple tuple, TupleDesc typeinfo)
|
243 | 240 | pq_putnchar("B", 1);
|
244 | 241 |
|
245 | 242 | /* ----------------
|
246 |
| - * send a bitmap of which attributes are null |
| 243 | + * send a bitmap of which attributes are not null |
247 | 244 | * ----------------
|
248 | 245 | */
|
249 | 246 | j = 0;
|
250 | 247 | k = 1 << 7;
|
251 |
| - for (i = 0; i < tuple->t_data->t_natts;) |
| 248 | + for (i = 0; i < tuple->t_data->t_natts; ++i) |
252 | 249 | {
|
253 |
| - i++; /* heap_getattr is a macro, so no |
254 |
| - * increment */ |
255 |
| - attr = heap_getattr(tuple, i, typeinfo, &isnull); |
256 |
| - if (!isnull) |
257 |
| - j |= k; |
| 250 | + if (! heap_attisnull(tuple, i + 1)) |
| 251 | + j |= k; /* set bit if not null */ |
258 | 252 | k >>= 1;
|
259 |
| - if (!(i & 7)) |
| 253 | + if (k == 0) /* end of byte? */ |
260 | 254 | {
|
261 | 255 | pq_putint(j, 1);
|
262 | 256 | j = 0;
|
263 | 257 | k = 1 << 7;
|
264 | 258 | }
|
265 | 259 | }
|
266 |
| - if (i & 7) |
| 260 | + if (k != (1 << 7)) /* flush last partial byte */ |
267 | 261 | pq_putint(j, 1);
|
268 | 262 |
|
269 | 263 | /* ----------------
|
|
0 commit comments