diff options
author | Robert Haas <rhaas@postgresql.org> | 2011-04-07 16:43:39 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2011-04-07 16:43:39 -0400 |
commit | 56c7140ca813ba4c7ecb122a1d2b1268e705d092 (patch) | |
tree | 423b2f82331a9d219a8cc5f9d32698ba6d628a23 /src | |
parent | 73d9a908140e709b4cb12a8d2257a11baaec974f (diff) | |
download | postgresql-56c7140ca813ba4c7ecb122a1d2b1268e705d092.tar.gz postgresql-56c7140ca813ba4c7ecb122a1d2b1268e705d092.zip |
Tweaks for SSI out-of-shared memory behavior.
If we call hash_search() with HASH_ENTER, it will bail out rather than
return NULL, so it's redundant to check for NULL again in the caller.
Thus, in cases where we believe it's impossible for the hash table to run
out of slots anyway, we can simplify the code slightly.
On the flip side, in cases where it's theoretically possible to run out of
space, we don't want to rely on dynahash.c to throw an error; instead,
we pass HASH_ENTER_NULL and throw the error ourselves if a NULL comes
back, so that we can provide a more descriptive error message.
Kevin Grittner
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/storage/lmgr/predicate.c | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c index 5096ea0c1c1..46b86546ee0 100644 --- a/src/backend/storage/lmgr/predicate.c +++ b/src/backend/storage/lmgr/predicate.c @@ -1604,12 +1604,7 @@ RegisterPredicateLockingXid(const TransactionId xid) sxid = (SERIALIZABLEXID *) hash_search(SerializableXidHash, &sxidtag, HASH_ENTER, &found); - if (!sxid) - /* This should not be possible, based on allocation. */ - ereport(ERROR, - (errcode(ERRCODE_OUT_OF_MEMORY), - errmsg("out of shared memory"))); - + Assert(sxid != NULL); Assert(!found); /* Initialize the structure. */ @@ -2045,7 +2040,7 @@ CreatePredicateLock(const PREDICATELOCKTARGETTAG *targettag, target = (PREDICATELOCKTARGET *) hash_search_with_hash_value(PredicateLockTargetHash, targettag, targettaghash, - HASH_ENTER, &found); + HASH_ENTER_NULL, &found); if (!target) ereport(ERROR, (errcode(ERRCODE_OUT_OF_MEMORY), @@ -2060,7 +2055,7 @@ CreatePredicateLock(const PREDICATELOCKTARGETTAG *targettag, lock = (PREDICATELOCK *) hash_search_with_hash_value(PredicateLockHash, &locktag, PredicateLockHashCodeFromTargetHashCode(&locktag, targettaghash), - HASH_ENTER, &found); + HASH_ENTER_NULL, &found); if (!lock) ereport(ERROR, (errcode(ERRCODE_OUT_OF_MEMORY), @@ -3251,7 +3246,7 @@ ReleaseOneSerializableXact(SERIALIZABLEXACT *sxact, bool partial, predlock = hash_search_with_hash_value(PredicateLockHash, &tag, PredicateLockHashCodeFromTargetHashCode(&tag, targettaghash), - HASH_ENTER, &found); + HASH_ENTER_NULL, &found); if (!predlock) ereport(ERROR, (errcode(ERRCODE_OUT_OF_MEMORY), @@ -4301,10 +4296,7 @@ predicatelock_twophase_recover(TransactionId xid, uint16 info, sxid = (SERIALIZABLEXID *) hash_search(SerializableXidHash, &sxidtag, HASH_ENTER, &found); - if (!sxid) - ereport(ERROR, - (errcode(ERRCODE_OUT_OF_MEMORY), - errmsg("out of shared memory"))); + Assert(sxid != NULL); Assert(!found); sxid->myXact = (SERIALIZABLEXACT *) sxact; |