99 *
1010 *
1111 * IDENTIFICATION
12- * $PostgreSQL: pgsql/src/backend/access/common/indextuple.c,v 1.72 2004/12/31 21:59:07 pgsql Exp $
12+ * $PostgreSQL: pgsql/src/backend/access/common/indextuple.c,v 1.73 2005/03/21 01:23:55 tgl Exp $
1313 *
1414 *-------------------------------------------------------------------------
1515 */
2828 */
2929
3030/* ----------------
31- * index_formtuple
31+ * index_form_tuple
3232 * ----------------
3333 */
3434IndexTuple
35- index_formtuple (TupleDesc tupleDescriptor ,
36- Datum * value ,
37- char * null )
35+ index_form_tuple (TupleDesc tupleDescriptor ,
36+ Datum * values ,
37+ bool * isnull )
3838{
3939 char * tp ; /* tuple pointer */
4040 IndexTuple tuple ; /* return tuple */
@@ -47,7 +47,7 @@ index_formtuple(TupleDesc tupleDescriptor,
4747 int numberOfAttributes = tupleDescriptor -> natts ;
4848
4949#ifdef TOAST_INDEX_HACK
50- Datum untoasted_value [INDEX_MAX_KEYS ];
50+ Datum untoasted_values [INDEX_MAX_KEYS ];
5151 bool untoasted_free [INDEX_MAX_KEYS ];
5252#endif
5353
@@ -62,41 +62,41 @@ index_formtuple(TupleDesc tupleDescriptor,
6262 {
6363 Form_pg_attribute att = tupleDescriptor -> attrs [i ];
6464
65- untoasted_value [i ] = value [i ];
65+ untoasted_values [i ] = values [i ];
6666 untoasted_free [i ] = false;
6767
6868 /* Do nothing if value is NULL or not of varlena type */
69- if (null [i ] != ' ' || att -> attlen != -1 )
69+ if (isnull [i ] || att -> attlen != -1 )
7070 continue ;
7171
7272 /*
7373 * If value is stored EXTERNAL, must fetch it so we are not
7474 * depending on outside storage. This should be improved someday.
7575 */
76- if (VARATT_IS_EXTERNAL (value [i ]))
76+ if (VARATT_IS_EXTERNAL (values [i ]))
7777 {
78- untoasted_value [i ] = PointerGetDatum (
78+ untoasted_values [i ] = PointerGetDatum (
7979 heap_tuple_fetch_attr (
80- (varattrib * ) DatumGetPointer (value [i ])));
80+ (varattrib * ) DatumGetPointer (values [i ])));
8181 untoasted_free [i ] = true;
8282 }
8383
8484 /*
8585 * If value is above size target, and is of a compressible
8686 * datatype, try to compress it in-line.
8787 */
88- if (VARATT_SIZE (untoasted_value [i ]) > TOAST_INDEX_TARGET &&
89- !VARATT_IS_EXTENDED (untoasted_value [i ]) &&
88+ if (VARATT_SIZE (untoasted_values [i ]) > TOAST_INDEX_TARGET &&
89+ !VARATT_IS_EXTENDED (untoasted_values [i ]) &&
9090 (att -> attstorage == 'x' || att -> attstorage == 'm' ))
9191 {
92- Datum cvalue = toast_compress_datum (untoasted_value [i ]);
92+ Datum cvalue = toast_compress_datum (untoasted_values [i ]);
9393
9494 if (DatumGetPointer (cvalue ) != NULL )
9595 {
9696 /* successful compression */
9797 if (untoasted_free [i ])
98- pfree (DatumGetPointer (untoasted_value [i ]));
99- untoasted_value [i ] = cvalue ;
98+ pfree (DatumGetPointer (untoasted_values [i ]));
99+ untoasted_values [i ] = cvalue ;
100100 untoasted_free [i ] = true;
101101 }
102102 }
@@ -105,7 +105,7 @@ index_formtuple(TupleDesc tupleDescriptor,
105105
106106 for (i = 0 ; i < numberOfAttributes ; i ++ )
107107 {
108- if (null [i ] != ' ' )
108+ if (isnull [i ])
109109 {
110110 hasnull = true;
111111 break ;
@@ -117,41 +117,42 @@ index_formtuple(TupleDesc tupleDescriptor,
117117
118118 hoff = IndexInfoFindDataOffset (infomask );
119119#ifdef TOAST_INDEX_HACK
120- size = hoff + ComputeDataSize (tupleDescriptor , untoasted_value , null );
120+ size = hoff + heap_compute_data_size (tupleDescriptor ,
121+ untoasted_values , isnull );
121122#else
122- size = hoff + ComputeDataSize (tupleDescriptor , value , null );
123+ size = hoff + heap_compute_data_size (tupleDescriptor ,
124+ values , isnull );
123125#endif
124126 size = MAXALIGN (size ); /* be conservative */
125127
126128 tp = (char * ) palloc0 (size );
127129 tuple = (IndexTuple ) tp ;
128130
129- DataFill ((char * ) tp + hoff ,
130- tupleDescriptor ,
131+ heap_fill_tuple (tupleDescriptor ,
131132#ifdef TOAST_INDEX_HACK
132- untoasted_value ,
133+ untoasted_values ,
133134#else
134- value ,
135+ values ,
135136#endif
136- null ,
137- & tupmask ,
138- (hasnull ? (bits8 * ) tp + sizeof (* tuple ) : NULL ));
137+ isnull ,
138+ (char * ) tp + hoff ,
139+ & tupmask ,
140+ (hasnull ? (bits8 * ) tp + sizeof (* tuple ) : NULL ));
139141
140142#ifdef TOAST_INDEX_HACK
141143 for (i = 0 ; i < numberOfAttributes ; i ++ )
142144 {
143145 if (untoasted_free [i ])
144- pfree (DatumGetPointer (untoasted_value [i ]));
146+ pfree (DatumGetPointer (untoasted_values [i ]));
145147 }
146148#endif
147149
148150 /*
149- * We do this because DataFill wants to initialize a "tupmask" which
150- * is used for HeapTuples, but we want an indextuple infomask. The
151- * only relevant info is the "has variable attributes" field. We have
152- * already set the hasnull bit above.
151+ * We do this because heap_fill_tuple wants to initialize a "tupmask"
152+ * which is used for HeapTuples, but we want an indextuple infomask.
153+ * The only relevant info is the "has variable attributes" field.
154+ * We have already set the hasnull bit above.
153155 */
154-
155156 if (tupmask & HEAP_HASVARWIDTH )
156157 infomask |= INDEX_VAR_MASK ;
157158
0 commit comments