/* We need to find the index that has indisclustered set. */
foreach(index, RelationGetIndexList(rel))
{
- HeapTuple idxtuple;
- Form_pg_index indexForm;
-
indexOid = lfirst_oid(index);
- idxtuple = SearchSysCache1(INDEXRELID,
- ObjectIdGetDatum(indexOid));
- if (!HeapTupleIsValid(idxtuple))
- elog(ERROR, "cache lookup failed for index %u", indexOid);
- indexForm = (Form_pg_index) GETSTRUCT(idxtuple);
- if (indexForm->indisclustered)
- {
- ReleaseSysCache(idxtuple);
+ if (get_index_isclustered(indexOid))
break;
- }
- ReleaseSysCache(idxtuple);
indexOid = InvalidOid;
}
*/
if (recheck)
{
- HeapTuple tuple;
- Form_pg_index indexForm;
-
/* Check that the user still owns the relation */
if (!pg_class_ownercheck(tableOid, GetUserId()))
{
/*
* Check that the index is still the one with indisclustered set.
*/
- tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(indexOid));
- if (!HeapTupleIsValid(tuple)) /* probably can't happen */
- {
- relation_close(OldHeap, AccessExclusiveLock);
- pgstat_progress_end_command();
- return;
- }
- indexForm = (Form_pg_index) GETSTRUCT(tuple);
- if (!indexForm->indisclustered)
+ if (!get_index_isclustered(indexOid))
{
- ReleaseSysCache(tuple);
relation_close(OldHeap, AccessExclusiveLock);
pgstat_progress_end_command();
return;
}
- ReleaseSysCache(tuple);
}
}
*/
if (OidIsValid(indexOid))
{
- indexTuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(indexOid));
- if (!HeapTupleIsValid(indexTuple))
- elog(ERROR, "cache lookup failed for index %u", indexOid);
- indexForm = (Form_pg_index) GETSTRUCT(indexTuple);
-
- if (indexForm->indisclustered)
- {
- ReleaseSysCache(indexTuple);
+ if (get_index_isclustered(indexOid))
return;
- }
-
- ReleaseSysCache(indexTuple);
}
/*