From 19085116eeecfde0a3fc1611eaffccc35bcec204 Mon Sep 17 00:00:00 2001 From: Noah Misch Date: Wed, 26 Jun 2013 20:00:08 -0400 Subject: Cooperate with the Valgrind instrumentation framework. Valgrind "client requests" in aset.c and mcxt.c teach Valgrind and its Memcheck tool about the PostgreSQL allocator. This makes Valgrind roughly as sensitive to memory errors involving palloc chunks as it is to memory errors involving malloc chunks. Further client requests in PageAddItem() and printtup() verify that all bits being added to a buffer page or furnished to an output function are predictably-defined. Those tests catch failures of C-language functions to fully initialize the bits of a Datum, which in turn stymie optimizations that rely on _equalConst(). Define the USE_VALGRIND symbol in pg_config_manual.h to enable these additions. An included "suppression file" silences nominal errors we don't plan to fix. Reviewed in earlier versions by Peter Geoghegan and Korry Douglas. --- src/backend/tcop/postgres.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/backend/tcop/postgres.c') diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index 31ea31304b4..ad258b74fd9 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -69,6 +69,7 @@ #include "tcop/tcopprot.h" #include "tcop/utility.h" #include "utils/lsyscache.h" +#include "utils/memdebug.h" #include "utils/memutils.h" #include "utils/ps_status.h" #include "utils/snapmgr.h" @@ -846,6 +847,10 @@ exec_simple_query(const char *query_string) TRACE_POSTGRESQL_QUERY_START(query_string); +#ifdef USE_VALGRIND + VALGRIND_PRINTF("statement: %s\n", query_string); +#endif + /* * We use save_log_statement_stats so ShowUsage doesn't report incorrect * results because ResetUsage wasn't called. -- cgit v1.2.3