mirror of
https://github.com/postgres/postgres.git
synced 2025-05-02 11:44:50 +03:00
Re-pgindent catcache.c after previous commit.
Discussion: https://postgr.es/m/1393953.1698353013@sss.pgh.pa.us Discussion: https://postgr.es/m/CAGjhLkOoBEC9mLsnB42d3CO1vcMx71MLSEuigeABbQ8oRdA6gw@mail.gmail.com
This commit is contained in:
parent
db122d426a
commit
7ceeb57bad
196
src/backend/utils/cache/catcache.c
vendored
196
src/backend/utils/cache/catcache.c
vendored
@ -1369,34 +1369,34 @@ SearchCatCacheMiss(CatCache *cache,
|
|||||||
cur_skey[2].sk_argument = v3;
|
cur_skey[2].sk_argument = v3;
|
||||||
cur_skey[3].sk_argument = v4;
|
cur_skey[3].sk_argument = v4;
|
||||||
|
|
||||||
scandesc = systable_beginscan(relation,
|
scandesc = systable_beginscan(relation,
|
||||||
cache->cc_indexoid,
|
cache->cc_indexoid,
|
||||||
IndexScanOK(cache, cur_skey),
|
IndexScanOK(cache, cur_skey),
|
||||||
NULL,
|
NULL,
|
||||||
nkeys,
|
nkeys,
|
||||||
cur_skey);
|
cur_skey);
|
||||||
|
|
||||||
ct = NULL;
|
ct = NULL;
|
||||||
stale = false;
|
stale = false;
|
||||||
|
|
||||||
while (HeapTupleIsValid(ntp = systable_getnext(scandesc)))
|
while (HeapTupleIsValid(ntp = systable_getnext(scandesc)))
|
||||||
{
|
|
||||||
ct = CatalogCacheCreateEntry(cache, ntp, scandesc, NULL,
|
|
||||||
hashValue, hashIndex);
|
|
||||||
/* upon failure, we must start the scan over */
|
|
||||||
if (ct == NULL)
|
|
||||||
{
|
{
|
||||||
stale = true;
|
ct = CatalogCacheCreateEntry(cache, ntp, scandesc, NULL,
|
||||||
break;
|
hashValue, hashIndex);
|
||||||
|
/* upon failure, we must start the scan over */
|
||||||
|
if (ct == NULL)
|
||||||
|
{
|
||||||
|
stale = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/* immediately set the refcount to 1 */
|
||||||
|
ResourceOwnerEnlargeCatCacheRefs(CurrentResourceOwner);
|
||||||
|
ct->refcount++;
|
||||||
|
ResourceOwnerRememberCatCacheRef(CurrentResourceOwner, &ct->tuple);
|
||||||
|
break; /* assume only one match */
|
||||||
}
|
}
|
||||||
/* immediately set the refcount to 1 */
|
|
||||||
ResourceOwnerEnlargeCatCacheRefs(CurrentResourceOwner);
|
|
||||||
ct->refcount++;
|
|
||||||
ResourceOwnerRememberCatCacheRef(CurrentResourceOwner, &ct->tuple);
|
|
||||||
break; /* assume only one match */
|
|
||||||
}
|
|
||||||
|
|
||||||
systable_endscan(scandesc);
|
systable_endscan(scandesc);
|
||||||
} while (stale);
|
} while (stale);
|
||||||
|
|
||||||
table_close(relation, AccessShareLock);
|
table_close(relation, AccessShareLock);
|
||||||
@ -1656,95 +1656,95 @@ SearchCatCacheList(CatCache *cache,
|
|||||||
cur_skey[2].sk_argument = v3;
|
cur_skey[2].sk_argument = v3;
|
||||||
cur_skey[3].sk_argument = v4;
|
cur_skey[3].sk_argument = v4;
|
||||||
|
|
||||||
scandesc = systable_beginscan(relation,
|
scandesc = systable_beginscan(relation,
|
||||||
cache->cc_indexoid,
|
cache->cc_indexoid,
|
||||||
IndexScanOK(cache, cur_skey),
|
IndexScanOK(cache, cur_skey),
|
||||||
NULL,
|
NULL,
|
||||||
nkeys,
|
nkeys,
|
||||||
cur_skey);
|
cur_skey);
|
||||||
|
|
||||||
/* The list will be ordered iff we are doing an index scan */
|
/* The list will be ordered iff we are doing an index scan */
|
||||||
ordered = (scandesc->irel != NULL);
|
ordered = (scandesc->irel != NULL);
|
||||||
|
|
||||||
stale = false;
|
stale = false;
|
||||||
|
|
||||||
while (HeapTupleIsValid(ntp = systable_getnext(scandesc)))
|
while (HeapTupleIsValid(ntp = systable_getnext(scandesc)))
|
||||||
{
|
|
||||||
uint32 hashValue;
|
|
||||||
Index hashIndex;
|
|
||||||
bool found = false;
|
|
||||||
dlist_head *bucket;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* See if there's an entry for this tuple already.
|
|
||||||
*/
|
|
||||||
ct = NULL;
|
|
||||||
hashValue = CatalogCacheComputeTupleHashValue(cache, cache->cc_nkeys, ntp);
|
|
||||||
hashIndex = HASH_INDEX(hashValue, cache->cc_nbuckets);
|
|
||||||
|
|
||||||
bucket = &cache->cc_bucket[hashIndex];
|
|
||||||
dlist_foreach(iter, bucket)
|
|
||||||
{
|
{
|
||||||
ct = dlist_container(CatCTup, cache_elem, iter.cur);
|
uint32 hashValue;
|
||||||
|
Index hashIndex;
|
||||||
if (ct->dead || ct->negative)
|
bool found = false;
|
||||||
continue; /* ignore dead and negative entries */
|
dlist_head *bucket;
|
||||||
|
|
||||||
if (ct->hash_value != hashValue)
|
|
||||||
continue; /* quickly skip entry if wrong hash val */
|
|
||||||
|
|
||||||
if (!ItemPointerEquals(&(ct->tuple.t_self), &(ntp->t_self)))
|
|
||||||
continue; /* not same tuple */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Found a match, but can't use it if it belongs to another
|
* See if there's an entry for this tuple already.
|
||||||
* list already
|
|
||||||
*/
|
*/
|
||||||
if (ct->c_list)
|
ct = NULL;
|
||||||
continue;
|
hashValue = CatalogCacheComputeTupleHashValue(cache, cache->cc_nkeys, ntp);
|
||||||
|
hashIndex = HASH_INDEX(hashValue, cache->cc_nbuckets);
|
||||||
|
|
||||||
found = true;
|
bucket = &cache->cc_bucket[hashIndex];
|
||||||
break; /* A-OK */
|
dlist_foreach(iter, bucket)
|
||||||
}
|
|
||||||
|
|
||||||
if (!found)
|
|
||||||
{
|
|
||||||
/* We didn't find a usable entry, so make a new one */
|
|
||||||
ct = CatalogCacheCreateEntry(cache, ntp, scandesc, NULL,
|
|
||||||
hashValue, hashIndex);
|
|
||||||
/* upon failure, we must start the scan over */
|
|
||||||
if (ct == NULL)
|
|
||||||
{
|
{
|
||||||
|
ct = dlist_container(CatCTup, cache_elem, iter.cur);
|
||||||
|
|
||||||
|
if (ct->dead || ct->negative)
|
||||||
|
continue; /* ignore dead and negative entries */
|
||||||
|
|
||||||
|
if (ct->hash_value != hashValue)
|
||||||
|
continue; /* quickly skip entry if wrong hash val */
|
||||||
|
|
||||||
|
if (!ItemPointerEquals(&(ct->tuple.t_self), &(ntp->t_self)))
|
||||||
|
continue; /* not same tuple */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Release refcounts on any items we already had. We dare
|
* Found a match, but can't use it if it belongs to
|
||||||
* not try to free them if they're now unreferenced, since
|
* another list already
|
||||||
* an error while doing that would result in the PG_CATCH
|
|
||||||
* below doing extra refcount decrements. Besides, we'll
|
|
||||||
* likely re-adopt those items in the next iteration, so
|
|
||||||
* it's not worth complicating matters to try to get rid
|
|
||||||
* of them.
|
|
||||||
*/
|
*/
|
||||||
foreach(ctlist_item, ctlist)
|
if (ct->c_list)
|
||||||
{
|
continue;
|
||||||
ct = (CatCTup *) lfirst(ctlist_item);
|
|
||||||
Assert(ct->c_list == NULL);
|
found = true;
|
||||||
Assert(ct->refcount > 0);
|
break; /* A-OK */
|
||||||
ct->refcount--;
|
|
||||||
}
|
|
||||||
/* Reset ctlist in preparation for new try */
|
|
||||||
ctlist = NIL;
|
|
||||||
stale = true;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!found)
|
||||||
|
{
|
||||||
|
/* We didn't find a usable entry, so make a new one */
|
||||||
|
ct = CatalogCacheCreateEntry(cache, ntp, scandesc, NULL,
|
||||||
|
hashValue, hashIndex);
|
||||||
|
/* upon failure, we must start the scan over */
|
||||||
|
if (ct == NULL)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Release refcounts on any items we already had. We
|
||||||
|
* dare not try to free them if they're now
|
||||||
|
* unreferenced, since an error while doing that would
|
||||||
|
* result in the PG_CATCH below doing extra refcount
|
||||||
|
* decrements. Besides, we'll likely re-adopt those
|
||||||
|
* items in the next iteration, so it's not worth
|
||||||
|
* complicating matters to try to get rid of them.
|
||||||
|
*/
|
||||||
|
foreach(ctlist_item, ctlist)
|
||||||
|
{
|
||||||
|
ct = (CatCTup *) lfirst(ctlist_item);
|
||||||
|
Assert(ct->c_list == NULL);
|
||||||
|
Assert(ct->refcount > 0);
|
||||||
|
ct->refcount--;
|
||||||
|
}
|
||||||
|
/* Reset ctlist in preparation for new try */
|
||||||
|
ctlist = NIL;
|
||||||
|
stale = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Careful here: add entry to ctlist, then bump its refcount */
|
||||||
|
/* This way leaves state correct if lappend runs out of memory */
|
||||||
|
ctlist = lappend(ctlist, ct);
|
||||||
|
ct->refcount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Careful here: add entry to ctlist, then bump its refcount */
|
systable_endscan(scandesc);
|
||||||
/* This way leaves state correct if lappend runs out of memory */
|
|
||||||
ctlist = lappend(ctlist, ct);
|
|
||||||
ct->refcount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
systable_endscan(scandesc);
|
|
||||||
} while (stale);
|
} while (stale);
|
||||||
|
|
||||||
table_close(relation, AccessShareLock);
|
table_close(relation, AccessShareLock);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user