Skip to content

Commit acbbeff

Browse files
committed
Clean up some ugly coding (hardwired constants) in index_formtuple.
1 parent 33e5a4d commit acbbeff

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

src/backend/access/common/indextuple.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/access/common/indextuple.c,v 1.44 2000/07/22 11:18:45 wieck Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/access/common/indextuple.c,v 1.45 2000/09/23 22:40:12 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -46,8 +46,8 @@ index_formtuple(TupleDesc tupleDescriptor,
4646
uint16 tupmask = 0;
4747
int numberOfAttributes = tupleDescriptor->natts;
4848
#ifdef TOAST_INDEX_HACK
49-
Datum untoasted_value[MaxHeapAttributeNumber];
50-
bool untoasted_free[MaxHeapAttributeNumber];
49+
Datum untoasted_value[INDEX_MAX_KEYS];
50+
bool untoasted_free[INDEX_MAX_KEYS];
5151
#endif
5252

5353
if (numberOfAttributes > INDEX_MAX_KEYS)
@@ -79,10 +79,14 @@ index_formtuple(TupleDesc tupleDescriptor,
7979
}
8080
}
8181
#endif
82-
for (i = 0; i < numberOfAttributes && !hasnull; i++)
82+
83+
for (i = 0; i < numberOfAttributes; i++)
8384
{
8485
if (null[i] != ' ')
86+
{
8587
hasnull = true;
88+
break;
89+
}
8690
}
8791

8892
if (hasnull)
@@ -122,23 +126,21 @@ index_formtuple(TupleDesc tupleDescriptor,
122126
/*
123127
* We do this because DataFill wants to initialize a "tupmask" which
124128
* is used for HeapTuples, but we want an indextuple infomask. The
125-
* only "relevent" info is the "has variable attributes" field, which
126-
* is in mask position 0x02. We have already set the null mask above.
129+
* only relevant info is the "has variable attributes" field.
130+
* We have already set the hasnull bit above.
127131
*/
128132

129-
if (tupmask & 0x02)
133+
if (tupmask & HEAP_HASVARLENA)
130134
infomask |= INDEX_VAR_MASK;
131135

132136
/*
133-
* Here we make sure that we can actually hold the size. We also want
134-
* to make sure that size is not aligned oddly. This actually is a
135-
* rather odd way to make sure the size is not too large overall.
137+
* Here we make sure that the size will fit in the field reserved for
138+
* it in t_info.
136139
*/
137140

138-
if (size & 0xE000)
141+
if ((size & INDEX_SIZE_MASK) != size)
139142
elog(ERROR, "index_formtuple: data takes %d bytes: too big", size);
140143

141-
142144
infomask |= size;
143145

144146
/* ----------------

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