mirror of https://github.com/citusdata/citus.git
Use PGIndexProcessor infra to find explicitly created indexes
parent
549ca4de6d
commit
91544d0191
|
@ -69,6 +69,9 @@ static char * GetRenameShardTriggerCommand(Oid shardRelationId, char *triggerNam
|
||||||
static void DropRelationTruncateTriggers(Oid relationId);
|
static void DropRelationTruncateTriggers(Oid relationId);
|
||||||
static char * GetDropTriggerCommand(Oid relationId, char *triggerName);
|
static char * GetDropTriggerCommand(Oid relationId, char *triggerName);
|
||||||
static List * GetRenameStatsCommandList(List *statsOidList, uint64 shardId);
|
static List * GetRenameStatsCommandList(List *statsOidList, uint64 shardId);
|
||||||
|
static void AppendExplicitIndexIdsToList(Form_pg_index indexForm,
|
||||||
|
List **explicitIndexIdList,
|
||||||
|
int flags);
|
||||||
static void DropDefaultExpressionsAndMoveOwnedSequenceOwnerships(Oid sourceRelationId,
|
static void DropDefaultExpressionsAndMoveOwnedSequenceOwnerships(Oid sourceRelationId,
|
||||||
Oid targetRelationId);
|
Oid targetRelationId);
|
||||||
static void DropDefaultColumnDefinition(Oid relationId, char *columnName);
|
static void DropDefaultColumnDefinition(Oid relationId, char *columnName);
|
||||||
|
@ -834,51 +837,25 @@ GetDropTriggerCommand(Oid relationId, char *triggerName)
|
||||||
List *
|
List *
|
||||||
GetExplicitIndexOidList(Oid relationId)
|
GetExplicitIndexOidList(Oid relationId)
|
||||||
{
|
{
|
||||||
int scanKeyCount = 1;
|
/* flags are not applicable for AppendExplicitIndexIdsToList */
|
||||||
ScanKeyData scanKey[1];
|
int flags = 0;
|
||||||
|
return ExecuteFunctionOnEachTableIndex(relationId, AppendExplicitIndexIdsToList,
|
||||||
|
flags);
|
||||||
|
}
|
||||||
|
|
||||||
PushOverrideEmptySearchPath(CurrentMemoryContext);
|
|
||||||
|
|
||||||
Relation pgIndex = table_open(IndexRelationId, AccessShareLock);
|
|
||||||
|
|
||||||
ScanKeyInit(&scanKey[0], Anum_pg_index_indrelid,
|
|
||||||
BTEqualStrategyNumber, F_OIDEQ, relationId);
|
|
||||||
|
|
||||||
bool useIndex = true;
|
|
||||||
SysScanDesc scanDescriptor = systable_beginscan(pgIndex, IndexIndrelidIndexId,
|
|
||||||
useIndex, NULL, scanKeyCount,
|
|
||||||
scanKey);
|
|
||||||
|
|
||||||
List *indexOidList = NIL;
|
|
||||||
|
|
||||||
HeapTuple heapTuple = systable_getnext(scanDescriptor);
|
|
||||||
while (HeapTupleIsValid(heapTuple))
|
|
||||||
{
|
|
||||||
Form_pg_index indexForm = (Form_pg_index) GETSTRUCT(heapTuple);
|
|
||||||
|
|
||||||
Oid indexId = indexForm->indexrelid;
|
|
||||||
|
|
||||||
bool indexImpliedByConstraint = IndexImpliedByAConstraint(indexForm);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Skip the indexes that are not implied by explicitly executing
|
* AppendExplicitIndexIdsToList adds the given index oid if it is
|
||||||
* a CREATE INDEX command.
|
* explicitly created on its relation.
|
||||||
*/
|
*/
|
||||||
if (!indexImpliedByConstraint)
|
static void
|
||||||
|
AppendExplicitIndexIdsToList(Form_pg_index indexForm, List **explicitIndexIdList,
|
||||||
|
int flags)
|
||||||
{
|
{
|
||||||
indexOidList = lappend_oid(indexOidList, indexId);
|
if (!IndexImpliedByAConstraint(indexForm))
|
||||||
|
{
|
||||||
|
*explicitIndexIdList = lappend_oid(*explicitIndexIdList, indexForm->indexrelid);
|
||||||
}
|
}
|
||||||
|
|
||||||
heapTuple = systable_getnext(scanDescriptor);
|
|
||||||
}
|
|
||||||
|
|
||||||
systable_endscan(scanDescriptor);
|
|
||||||
table_close(pgIndex, NoLock);
|
|
||||||
|
|
||||||
/* revert back to original search_path */
|
|
||||||
PopOverrideSearchPath();
|
|
||||||
|
|
||||||
return indexOidList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue