Skip to content

Commit 69edf4f

Browse files
committed
Refactor BuildIndexInfo() with the new makeIndexInfo()
This portion of the code got forgotten in 7cce159 which has introduced a new routine to build this node, and this finishes the unification of the places where IndexInfo is initialized. Author: Michael Paquier Discussion: https://postgr.es/m/20190801041322.GA3435@paquier.xyz
1 parent 2abd7ae commit 69edf4f

File tree

1 file changed

+15
-37
lines changed

1 file changed

+15
-37
lines changed

src/backend/catalog/index.c

Lines changed: 15 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2229,7 +2229,7 @@ index_drop(Oid indexId, bool concurrent, bool concurrent_lock_mode)
22292229
IndexInfo *
22302230
BuildIndexInfo(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

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