- backend: make "print queries" a runtime instead of compile-time

decision (bool g_print_queries)


svn path=/trunk/boinc/; revision=21065
This commit is contained in:
David Anderson 2010-04-03 00:02:38 +00:00
parent 54dce55e98
commit a5c2f98481
3 changed files with 13 additions and 7 deletions

View File

@ -2436,3 +2436,10 @@ David 2 Apr 2010
sched/ sched/
credit.cpp 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

View File

@ -30,10 +30,7 @@
#include "fcgi_stdio.h" #include "fcgi_stdio.h"
#endif #endif
// uncomment the following to print all queries. bool g_print_queries = false;
// Useful for low-level debugging
//#define SHOW_QUERIES
DB_CONN::DB_CONN() { DB_CONN::DB_CONN() {
mysql = 0; mysql = 0;
@ -115,9 +112,9 @@ int DB_CONN::set_isolation_level(ISOLATION_LEVEL level) {
int DB_CONN::do_query(const char* p) { int DB_CONN::do_query(const char* p) {
int retval; int retval;
#ifdef SHOW_QUERIES if (g_print_queries) {
fprintf(stderr, "query: %s\n", p); fprintf(stderr, "query: %s\n", p);
#endif }
retval = mysql_query(mysql, p); retval = mysql_query(mysql, p);
if (retval) { if (retval) {
fprintf(stderr, "Database error: %s\nquery=%s\n", error_string(), p); fprintf(stderr, "Database error: %s\nquery=%s\n", error_string(), p);

View File

@ -22,6 +22,8 @@
#include <string> #include <string>
#include <mysql.h> #include <mysql.h>
extern bool g_print_queries;
// if SQL columns are not 'not null', you must use these safe_atoi, safe_atof // 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. // instead of atoi, atof, since the strings returned by MySQL may be NULL.
// //