@@ -2229,7 +2229,7 @@ index_drop(Oid indexId, bool concurrent, bool concurrent_lock_mode)
2229
2229
IndexInfo *
2230
2230
BuildIndexInfo (Relation index )
2231
2231
{
2232
- IndexInfo * ii = makeNode ( IndexInfo ) ;
2232
+ IndexInfo * ii ;
2233
2233
Form_pg_index indexStruct = index -> rd_index ;
2234
2234
int i ;
2235
2235
int numAtts ;
@@ -2239,22 +2239,24 @@ BuildIndexInfo(Relation index)
2239
2239
if (numAtts < 1 || numAtts > INDEX_MAX_KEYS )
2240
2240
elog (ERROR , "invalid indnatts %d for index %u" ,
2241
2241
numAtts , RelationGetRelid (index ));
2242
- ii -> ii_NumIndexAttrs = numAtts ;
2243
- ii -> ii_NumIndexKeyAttrs = indexStruct -> indnkeyatts ;
2244
- Assert (ii -> ii_NumIndexKeyAttrs != 0 );
2245
- Assert (ii -> ii_NumIndexKeyAttrs <= ii -> ii_NumIndexAttrs );
2246
2242
2243
+ /*
2244
+ * Create the node, fetching any expressions needed for expressional
2245
+ * indexes and index predicate if any.
2246
+ */
2247
+ ii = makeIndexInfo (indexStruct -> indnatts ,
2248
+ indexStruct -> indnkeyatts ,
2249
+ index -> rd_rel -> relam ,
2250
+ RelationGetIndexExpressions (index ),
2251
+ RelationGetIndexPredicate (index ),
2252
+ indexStruct -> indisunique ,
2253
+ indexStruct -> indisready ,
2254
+ false);
2255
+
2256
+ /* fill in attribute numbers */
2247
2257
for (i = 0 ; i < numAtts ; i ++ )
2248
2258
ii -> ii_IndexAttrNumbers [i ] = indexStruct -> indkey .values [i ];
2249
2259
2250
- /* fetch any expressions needed for expressional indexes */
2251
- ii -> ii_Expressions = RelationGetIndexExpressions (index );
2252
- ii -> ii_ExpressionsState = NIL ;
2253
-
2254
- /* fetch index predicate if any */
2255
- ii -> ii_Predicate = RelationGetIndexPredicate (index );
2256
- ii -> ii_PredicateState = NULL ;
2257
-
2258
2260
/* fetch exclusion constraint info if any */
2259
2261
if (indexStruct -> indisexclusion )
2260
2262
{
@@ -2263,30 +2265,6 @@ BuildIndexInfo(Relation index)
2263
2265
& ii -> ii_ExclusionProcs ,
2264
2266
& ii -> ii_ExclusionStrats );
2265
2267
}
2266
- else
2267
- {
2268
- ii -> ii_ExclusionOps = NULL ;
2269
- ii -> ii_ExclusionProcs = NULL ;
2270
- ii -> ii_ExclusionStrats = NULL ;
2271
- }
2272
-
2273
- /* other info */
2274
- ii -> ii_Unique = indexStruct -> indisunique ;
2275
- ii -> ii_ReadyForInserts = indexStruct -> indisready ;
2276
- /* assume not doing speculative insertion for now */
2277
- ii -> ii_UniqueOps = NULL ;
2278
- ii -> ii_UniqueProcs = NULL ;
2279
- ii -> ii_UniqueStrats = NULL ;
2280
-
2281
- /* initialize index-build state to default */
2282
- ii -> ii_Concurrent = false;
2283
- ii -> ii_BrokenHotChain = false;
2284
- ii -> ii_ParallelWorkers = 0 ;
2285
-
2286
- /* set up for possible use by index AM */
2287
- ii -> ii_Am = index -> rd_rel -> relam ;
2288
- ii -> ii_AmCache = NULL ;
2289
- ii -> ii_Context = CurrentMemoryContext ;
2290
2268
2291
2269
return ii ;
2292
2270
}
0 commit comments