Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions src/backend/commands/tablecmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -14316,14 +14316,14 @@ TryReuseIndex(Oid oldId, IndexStmt *stmt)
Form_pg_am accessMethodForm;
IndexAmRoutine *amRoutine;
char *accessMethodName;
Oid heapRelId = IndexGetRelation(oldId, false);
Relation heapRel = table_open(heapRelId, ShareLock);
Oid heapRelId = IndexGetRelation(oldId, false);
Relation heapRel = table_open(heapRelId, ShareLock);

stmt->oldNumber = irel->rd_locator.relNumber;
stmt->oldCreateSubid = irel->rd_createSubid;
stmt->oldFirstRelfilelocatorSubid = irel->rd_firstRelfilelocatorSubid;


/*
* look up the access method to call amreuse
*/
Expand All @@ -14332,8 +14332,9 @@ TryReuseIndex(Oid oldId, IndexStmt *stmt)
if (!HeapTupleIsValid(tuple))
{
/*
* Hack to provide more-or-less-transparent updating of old RTREE
* indexes to GiST: if RTREE is requested and not found, use GIST.
* Hack to provide more-or-less-transparent updating of old
* RTREE indexes to GiST: if RTREE is requested and not found,
* use GIST.
*/
if (strcmp(accessMethodName, "rtree") == 0)
{
Expand All @@ -14351,10 +14352,12 @@ TryReuseIndex(Oid oldId, IndexStmt *stmt)
}
accessMethodForm = (Form_pg_am) GETSTRUCT(tuple);
amRoutine = GetIndexAmRoutineWithTableAM(heapRel->rd_rel->relam, accessMethodForm->amhandler);
ReleaseSysCache(tuple);
table_close(heapRel, NoLock);

if(amRoutine->amreuse) {
(*amRoutine->amreuse)(irel);

if (amRoutine->amreuse)
{
(*amRoutine->amreuse) (irel);
}
}
index_close(irel, NoLock);
Expand Down