9
9
*
10
10
*
11
11
* 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 $
13
13
*
14
14
*-------------------------------------------------------------------------
15
15
*/
28
28
*/
29
29
30
30
/* ----------------
31
- * index_formtuple
31
+ * index_form_tuple
32
32
* ----------------
33
33
*/
34
34
IndexTuple
35
- index_formtuple (TupleDesc tupleDescriptor ,
36
- Datum * value ,
37
- char * null )
35
+ index_form_tuple (TupleDesc tupleDescriptor ,
36
+ Datum * values ,
37
+ bool * isnull )
38
38
{
39
39
char * tp ; /* tuple pointer */
40
40
IndexTuple tuple ; /* return tuple */
@@ -47,7 +47,7 @@ index_formtuple(TupleDesc tupleDescriptor,
47
47
int numberOfAttributes = tupleDescriptor -> natts ;
48
48
49
49
#ifdef TOAST_INDEX_HACK
50
- Datum untoasted_value [INDEX_MAX_KEYS ];
50
+ Datum untoasted_values [INDEX_MAX_KEYS ];
51
51
bool untoasted_free [INDEX_MAX_KEYS ];
52
52
#endif
53
53
@@ -62,41 +62,41 @@ index_formtuple(TupleDesc tupleDescriptor,
62
62
{
63
63
Form_pg_attribute att = tupleDescriptor -> attrs [i ];
64
64
65
- untoasted_value [i ] = value [i ];
65
+ untoasted_values [i ] = values [i ];
66
66
untoasted_free [i ] = false;
67
67
68
68
/* 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 )
70
70
continue ;
71
71
72
72
/*
73
73
* If value is stored EXTERNAL, must fetch it so we are not
74
74
* depending on outside storage. This should be improved someday.
75
75
*/
76
- if (VARATT_IS_EXTERNAL (value [i ]))
76
+ if (VARATT_IS_EXTERNAL (values [i ]))
77
77
{
78
- untoasted_value [i ] = PointerGetDatum (
78
+ untoasted_values [i ] = PointerGetDatum (
79
79
heap_tuple_fetch_attr (
80
- (varattrib * ) DatumGetPointer (value [i ])));
80
+ (varattrib * ) DatumGetPointer (values [i ])));
81
81
untoasted_free [i ] = true;
82
82
}
83
83
84
84
/*
85
85
* If value is above size target, and is of a compressible
86
86
* datatype, try to compress it in-line.
87
87
*/
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 ]) &&
90
90
(att -> attstorage == 'x' || att -> attstorage == 'm' ))
91
91
{
92
- Datum cvalue = toast_compress_datum (untoasted_value [i ]);
92
+ Datum cvalue = toast_compress_datum (untoasted_values [i ]);
93
93
94
94
if (DatumGetPointer (cvalue ) != NULL )
95
95
{
96
96
/* successful compression */
97
97
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 ;
100
100
untoasted_free [i ] = true;
101
101
}
102
102
}
@@ -105,7 +105,7 @@ index_formtuple(TupleDesc tupleDescriptor,
105
105
106
106
for (i = 0 ; i < numberOfAttributes ; i ++ )
107
107
{
108
- if (null [i ] != ' ' )
108
+ if (isnull [i ])
109
109
{
110
110
hasnull = true;
111
111
break ;
@@ -117,41 +117,42 @@ index_formtuple(TupleDesc tupleDescriptor,
117
117
118
118
hoff = IndexInfoFindDataOffset (infomask );
119
119
#ifdef TOAST_INDEX_HACK
120
- size = hoff + ComputeDataSize (tupleDescriptor , untoasted_value , null );
120
+ size = hoff + heap_compute_data_size (tupleDescriptor ,
121
+ untoasted_values , isnull );
121
122
#else
122
- size = hoff + ComputeDataSize (tupleDescriptor , value , null );
123
+ size = hoff + heap_compute_data_size (tupleDescriptor ,
124
+ values , isnull );
123
125
#endif
124
126
size = MAXALIGN (size ); /* be conservative */
125
127
126
128
tp = (char * ) palloc0 (size );
127
129
tuple = (IndexTuple ) tp ;
128
130
129
- DataFill ((char * ) tp + hoff ,
130
- tupleDescriptor ,
131
+ heap_fill_tuple (tupleDescriptor ,
131
132
#ifdef TOAST_INDEX_HACK
132
- untoasted_value ,
133
+ untoasted_values ,
133
134
#else
134
- value ,
135
+ values ,
135
136
#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 ));
139
141
140
142
#ifdef TOAST_INDEX_HACK
141
143
for (i = 0 ; i < numberOfAttributes ; i ++ )
142
144
{
143
145
if (untoasted_free [i ])
144
- pfree (DatumGetPointer (untoasted_value [i ]));
146
+ pfree (DatumGetPointer (untoasted_values [i ]));
145
147
}
146
148
#endif
147
149
148
150
/*
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.
153
155
*/
154
-
155
156
if (tupmask & HEAP_HASVARWIDTH )
156
157
infomask |= INDEX_VAR_MASK ;
157
158
0 commit comments