mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +03:00
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
This commit is contained in:
@ -2229,7 +2229,7 @@ index_drop(Oid indexId, bool concurrent, bool concurrent_lock_mode)
|
|||||||
IndexInfo *
|
IndexInfo *
|
||||||
BuildIndexInfo(Relation index)
|
BuildIndexInfo(Relation index)
|
||||||
{
|
{
|
||||||
IndexInfo *ii = makeNode(IndexInfo);
|
IndexInfo *ii;
|
||||||
Form_pg_index indexStruct = index->rd_index;
|
Form_pg_index indexStruct = index->rd_index;
|
||||||
int i;
|
int i;
|
||||||
int numAtts;
|
int numAtts;
|
||||||
@ -2239,22 +2239,24 @@ BuildIndexInfo(Relation index)
|
|||||||
if (numAtts < 1 || numAtts > INDEX_MAX_KEYS)
|
if (numAtts < 1 || numAtts > INDEX_MAX_KEYS)
|
||||||
elog(ERROR, "invalid indnatts %d for index %u",
|
elog(ERROR, "invalid indnatts %d for index %u",
|
||||||
numAtts, RelationGetRelid(index));
|
numAtts, RelationGetRelid(index));
|
||||||
ii->ii_NumIndexAttrs = numAtts;
|
|
||||||
ii->ii_NumIndexKeyAttrs = indexStruct->indnkeyatts;
|
|
||||||
Assert(ii->ii_NumIndexKeyAttrs != 0);
|
|
||||||
Assert(ii->ii_NumIndexKeyAttrs <= ii->ii_NumIndexAttrs);
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create the node, fetching any expressions needed for expressional
|
||||||
|
* indexes and index predicate if any.
|
||||||
|
*/
|
||||||
|
ii = makeIndexInfo(indexStruct->indnatts,
|
||||||
|
indexStruct->indnkeyatts,
|
||||||
|
index->rd_rel->relam,
|
||||||
|
RelationGetIndexExpressions(index),
|
||||||
|
RelationGetIndexPredicate(index),
|
||||||
|
indexStruct->indisunique,
|
||||||
|
indexStruct->indisready,
|
||||||
|
false);
|
||||||
|
|
||||||
|
/* fill in attribute numbers */
|
||||||
for (i = 0; i < numAtts; i++)
|
for (i = 0; i < numAtts; i++)
|
||||||
ii->ii_IndexAttrNumbers[i] = indexStruct->indkey.values[i];
|
ii->ii_IndexAttrNumbers[i] = indexStruct->indkey.values[i];
|
||||||
|
|
||||||
/* fetch any expressions needed for expressional indexes */
|
|
||||||
ii->ii_Expressions = RelationGetIndexExpressions(index);
|
|
||||||
ii->ii_ExpressionsState = NIL;
|
|
||||||
|
|
||||||
/* fetch index predicate if any */
|
|
||||||
ii->ii_Predicate = RelationGetIndexPredicate(index);
|
|
||||||
ii->ii_PredicateState = NULL;
|
|
||||||
|
|
||||||
/* fetch exclusion constraint info if any */
|
/* fetch exclusion constraint info if any */
|
||||||
if (indexStruct->indisexclusion)
|
if (indexStruct->indisexclusion)
|
||||||
{
|
{
|
||||||
@ -2263,30 +2265,6 @@ BuildIndexInfo(Relation index)
|
|||||||
&ii->ii_ExclusionProcs,
|
&ii->ii_ExclusionProcs,
|
||||||
&ii->ii_ExclusionStrats);
|
&ii->ii_ExclusionStrats);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
ii->ii_ExclusionOps = NULL;
|
|
||||||
ii->ii_ExclusionProcs = NULL;
|
|
||||||
ii->ii_ExclusionStrats = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* other info */
|
|
||||||
ii->ii_Unique = indexStruct->indisunique;
|
|
||||||
ii->ii_ReadyForInserts = indexStruct->indisready;
|
|
||||||
/* assume not doing speculative insertion for now */
|
|
||||||
ii->ii_UniqueOps = NULL;
|
|
||||||
ii->ii_UniqueProcs = NULL;
|
|
||||||
ii->ii_UniqueStrats = NULL;
|
|
||||||
|
|
||||||
/* initialize index-build state to default */
|
|
||||||
ii->ii_Concurrent = false;
|
|
||||||
ii->ii_BrokenHotChain = false;
|
|
||||||
ii->ii_ParallelWorkers = 0;
|
|
||||||
|
|
||||||
/* set up for possible use by index AM */
|
|
||||||
ii->ii_Am = index->rd_rel->relam;
|
|
||||||
ii->ii_AmCache = NULL;
|
|
||||||
ii->ii_Context = CurrentMemoryContext;
|
|
||||||
|
|
||||||
return ii;
|
return ii;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user