git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 84bc2b1)
Remove useless Asserts in Result Cache code
Fri, 2 Apr 2021 21:41:43 +0000 (10:41 +1300)
Fri, 2 Apr 2021 21:41:43 +0000 (10:41 +1300)
Testing if an unsigned variable is >= 0 is pretty pointless.

There's likely enough code in remove_cache_entry() to verify the cache
memory accounting is correct in assert enabled builds. These Asserts
were not adding much extra cover, even if they had been checking >= 0 on a
signed variable.

Reported-by: Andres Freund
Discussion: https://postgr.es/m/20210402204734.6mo3nfacnljlicgn@alap3.anarazel.de


diff --git a/src/backend/executor/nodeResultCache.c b/src/backend/executor/nodeResultCache.c
index c8de818c8ca1888f17f24d19b9bbed4b02c77a0e..99a2045681b059563ca01e8b3497ff728b173a75 100644 (file)
--- a/src/backend/executor/nodeResultCache.c
+++ b/src/backend/executor/nodeResultCache.c
@@ -286,8 +286,6 @@ entry_purge_tuples(ResultCacheState *rcstate, ResultCacheEntry *entry)
/* Update the memory accounting */
rcstate->mem_used -= freed_mem;
-
- Assert(rcstate->mem_used >= 0);
}
/*
@@ -346,8 +344,6 @@ remove_cache_entry(ResultCacheState *rcstate, ResultCacheEntry *entry)
*/
rcstate->mem_used -= EMPTY_ENTRY_MEMORY_BYTES(entry);
- Assert(rcstate->mem_used >= 0);
-
/* Remove the entry from the cache */
resultcache_delete_item(rcstate->hashtable, entry);
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /