@@ -2229,7 +2229,7 @@ index_drop(Oid indexId, bool concurrent, bool concurrent_lock_mode)
22292229IndexInfo *
22302230BuildIndexInfo (Relation index )
22312231{
2232- IndexInfo * ii = makeNode ( IndexInfo ) ;
2232+ IndexInfo * ii ;
22332233 Form_pg_index indexStruct = index -> rd_index ;
22342234 int i ;
22352235 int numAtts ;
@@ -2239,22 +2239,24 @@ BuildIndexInfo(Relation index)
22392239 if (numAtts < 1 || numAtts > INDEX_MAX_KEYS )
22402240 elog (ERROR , "invalid indnatts %d for index %u" ,
22412241 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 );
22462242
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 */
22472257 for (i = 0 ; i < numAtts ; i ++ )
22482258 ii -> ii_IndexAttrNumbers [i ] = indexStruct -> indkey .values [i ];
22492259
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-
22582260 /* fetch exclusion constraint info if any */
22592261 if (indexStruct -> indisexclusion )
22602262 {
@@ -2263,30 +2265,6 @@ BuildIndexInfo(Relation index)
22632265 & ii -> ii_ExclusionProcs ,
22642266 & ii -> ii_ExclusionStrats );
22652267 }
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 ;
22902268
22912269 return ii ;
22922270}
0 commit comments