diff options
author | Andres Freund <andres@anarazel.de> | 2014-06-20 11:06:42 +0200 |
---|---|---|
committer | Andres Freund <andres@anarazel.de> | 2014-06-20 11:09:17 +0200 |
commit | 3bdcf6a5a7555035810e2ba2b8a0fb04dc5c66b8 (patch) | |
tree | ca974ea8843cb59f1ea8616f0f742e9faa5e8dbe /src/backend/utils/cache | |
parent | 45b0f357235236dd3198f8abcca277adc0d7459a (diff) | |
download | postgresql-3bdcf6a5a7555035810e2ba2b8a0fb04dc5c66b8.tar.gz postgresql-3bdcf6a5a7555035810e2ba2b8a0fb04dc5c66b8.zip |
Don't allow to disable backend assertions via the debug_assertions GUC.
The existance of the assert_enabled variable (backing the
debug_assertions GUC) reduced the amount of knowledge some static code
checkers (like coverity and various compilers) could infer from the
existance of the assertion. That could have been solved by optionally
removing the assertion_enabled variable from the Assert() et al macros
at compile time when some special macro is defined, but the resulting
complication doesn't seem to be worth the gain from having
debug_assertions. Recompiling is fast enough.
The debug_assertions GUC is still available, but readonly, as it's
useful when diagnosing problems. The commandline/client startup option
-A, which previously also allowed to enable/disable assertions, has
been removed as it doesn't serve a purpose anymore.
While at it, reduce code duplication in bufmgr.c and localbuf.c
assertions checking for spurious buffer pins. That code had to be
reindented anyway to cope with the assert_enabled removal.
Diffstat (limited to 'src/backend/utils/cache')
-rw-r--r-- | src/backend/utils/cache/catcache.c | 51 | ||||
-rw-r--r-- | src/backend/utils/cache/relfilenodemap.c | 1 |
2 files changed, 24 insertions, 28 deletions
diff --git a/src/backend/utils/cache/catcache.c b/src/backend/utils/cache/catcache.c index 954b435bffa..4dd6753c82f 100644 --- a/src/backend/utils/cache/catcache.c +++ b/src/backend/utils/cache/catcache.c @@ -553,41 +553,38 @@ void AtEOXact_CatCache(bool isCommit) { #ifdef USE_ASSERT_CHECKING - if (assert_enabled) + slist_iter cache_iter; + + slist_foreach(cache_iter, &CacheHdr->ch_caches) { - slist_iter cache_iter; + CatCache *ccp = slist_container(CatCache, cc_next, cache_iter.cur); + dlist_iter iter; + int i; - slist_foreach(cache_iter, &CacheHdr->ch_caches) + /* Check CatCLists */ + dlist_foreach(iter, &ccp->cc_lists) { - CatCache *ccp = slist_container(CatCache, cc_next, cache_iter.cur); - dlist_iter iter; - int i; + CatCList *cl; - /* Check CatCLists */ - dlist_foreach(iter, &ccp->cc_lists) - { - CatCList *cl; + cl = dlist_container(CatCList, cache_elem, iter.cur); + Assert(cl->cl_magic == CL_MAGIC); + Assert(cl->refcount == 0); + Assert(!cl->dead); + } - cl = dlist_container(CatCList, cache_elem, iter.cur); - Assert(cl->cl_magic == CL_MAGIC); - Assert(cl->refcount == 0); - Assert(!cl->dead); - } + /* Check individual tuples */ + for (i = 0; i < ccp->cc_nbuckets; i++) + { + dlist_head *bucket = &ccp->cc_bucket[i]; - /* Check individual tuples */ - for (i = 0; i < ccp->cc_nbuckets; i++) + dlist_foreach(iter, bucket) { - dlist_head *bucket = &ccp->cc_bucket[i]; - - dlist_foreach(iter, bucket) - { - CatCTup *ct; + CatCTup *ct; - ct = dlist_container(CatCTup, cache_elem, iter.cur); - Assert(ct->ct_magic == CT_MAGIC); - Assert(ct->refcount == 0); - Assert(!ct->dead); - } + ct = dlist_container(CatCTup, cache_elem, iter.cur); + Assert(ct->ct_magic == CT_MAGIC); + Assert(ct->refcount == 0); + Assert(!ct->dead); } } } diff --git a/src/backend/utils/cache/relfilenodemap.c b/src/backend/utils/cache/relfilenodemap.c index 557ff6148d0..1e8429c64c3 100644 --- a/src/backend/utils/cache/relfilenodemap.c +++ b/src/backend/utils/cache/relfilenodemap.c @@ -220,7 +220,6 @@ RelidByRelfilenode(Oid reltablespace, Oid relfilenode) found = true; #ifdef USE_ASSERT_CHECKING - if (assert_enabled) { bool isnull; Oid check; |