diff --git a/checkin_notes b/checkin_notes index 2f36b32197..927aaf164e 100644 --- a/checkin_notes +++ b/checkin_notes @@ -2436,3 +2436,10 @@ David 2 Apr 2010 sched/ credit.cpp + +David 2 Apr 2010 + - backend: make "print queries" a runtime instead of compile-time + decision (bool g_print_queries) + + db/ + db_base.cpp,h diff --git a/db/db_base.cpp b/db/db_base.cpp index 83cd8b577f..dd4cee1487 100644 --- a/db/db_base.cpp +++ b/db/db_base.cpp @@ -30,10 +30,7 @@ #include "fcgi_stdio.h" #endif -// uncomment the following to print all queries. -// Useful for low-level debugging - -//#define SHOW_QUERIES +bool g_print_queries = false; DB_CONN::DB_CONN() { mysql = 0; @@ -115,9 +112,9 @@ int DB_CONN::set_isolation_level(ISOLATION_LEVEL level) { int DB_CONN::do_query(const char* p) { int retval; -#ifdef SHOW_QUERIES - fprintf(stderr, "query: %s\n", p); -#endif + if (g_print_queries) { + fprintf(stderr, "query: %s\n", p); + } retval = mysql_query(mysql, p); if (retval) { fprintf(stderr, "Database error: %s\nquery=%s\n", error_string(), p); diff --git a/db/db_base.h b/db/db_base.h index c8fa8e8437..f10e72745b 100644 --- a/db/db_base.h +++ b/db/db_base.h @@ -22,6 +22,8 @@ #include #include +extern bool g_print_queries; + // if SQL columns are not 'not null', you must use these safe_atoi, safe_atof // instead of atoi, atof, since the strings returned by MySQL may be NULL. //