From: Tim B. <tba...@us...> - 2008-01-02 04:25:07
|
Update of /cvsroot/aprsworld/parse In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv25123 Modified Files: db_mysql.c db_pgsql.c Log Message: * Cleanup to use VERBOSE macro definitions for improved readability. * All SQL debug printing is now enabled only with new VERBOSE_SQL macro. This allows us to debug the packet parser separate from the database handlers. Index: db_mysql.c =================================================================== RCS file: /cvsroot/aprsworld/parse/db_mysql.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** db_mysql.c 29 Jan 2007 21:44:24 -0000 1.6 --- db_mysql.c 2 Jan 2008 04:25:10 -0000 1.7 *************** *** 87,91 **** if ( NULL == mysql_real_connect (&mysql, host, username, password, database, (char *) NULL, 0, (char *) NULL)) { ! if (get_verbose() & 1) { fprintf (stderr, "Failed to connect to database: Error: %s\n", mysql_error (&mysql)); } --- 87,91 ---- if ( NULL == mysql_real_connect (&mysql, host, username, password, database, (char *) NULL, 0, (char *) NULL)) { ! if (get_verbose() & VERBOSE_ERRORS) { fprintf (stderr, "Failed to connect to database: Error: %s\n", mysql_error (&mysql)); } *************** *** 169,173 **** query(&sql_query,sql_buf,"INSERT"); ! if (get_verbose() & 2) printf ("%s;\n", sql_buf); if ( mysql_query (&mysql, sql_buf) ) --- 169,173 ---- query(&sql_query,sql_buf,"INSERT"); ! if (get_verbose() & VERBOSE_SQL) printf ("%s;\n", sql_buf); if ( mysql_query (&mysql, sql_buf) ) *************** *** 215,219 **** query(&sql_query,sql_buf,"INSERT"); ! if (get_verbose() & 2) printf ("%s;\n", sql_buf); --- 215,219 ---- query(&sql_query,sql_buf,"INSERT"); ! if (get_verbose() & VERBOSE_SQL) printf ("%s;\n", sql_buf); *************** *** 272,276 **** query(&sql_query,sql_buf,"INSERT"); ! if (get_verbose() & 2) printf ("%s;\n", sql_buf); --- 272,276 ---- query(&sql_query,sql_buf,"INSERT"); ! if (get_verbose() & VERBOSE_SQL) printf ("%s;\n", sql_buf); *************** *** 334,338 **** query(&sql_query,sql_buf,"REPLACE"); ! if (get_verbose() & 2) printf ("%s;\n", sql_buf); if ( mysql_query (&mysql, sql_buf) ) --- 334,338 ---- query(&sql_query,sql_buf,"REPLACE"); ! if (get_verbose() & VERBOSE_SQL) printf ("%s;\n", sql_buf); if ( mysql_query (&mysql, sql_buf) ) *************** *** 397,401 **** query(&sql_query,sql_buf,"INSERT"); ! if (get_verbose() & 2) printf ("%s;\n", sql_buf); --- 397,401 ---- query(&sql_query,sql_buf,"INSERT"); ! if (get_verbose() & VERBOSE_SQL) printf ("%s;\n", sql_buf); *************** *** 462,466 **** query(&sql_query,sql_buf,"REPLACE"); ! if (get_verbose() & 2) printf ("%s;\n", sql_buf); --- 462,466 ---- query(&sql_query,sql_buf,"REPLACE"); ! if (get_verbose() & VERBOSE_SQL) printf ("%s;\n", sql_buf); *************** *** 495,499 **** } else { // Let's not explode in case we missed something. retval = atoi(row[0]); ! if (get_verbose() & 4) printf ("Using qa_hosts id %s for %s\n", row[0], hostname); } --- 495,499 ---- } else { // Let's not explode in case we missed something. retval = atoi(row[0]); ! if (get_verbose() & VERBOSE_DEBUG) printf ("Using qa_hosts id %s for %s\n", row[0], hostname); } *************** *** 534,538 **** result = mysql_use_result (&mysql); while ( row = mysql_fetch_row (result) ) { ! if ( get_verbose() & 2 ) printf("%s has triggered: %s\n",callsign,row[1]); --- 534,538 ---- result = mysql_use_result (&mysql); while ( row = mysql_fetch_row (result) ) { ! if ( get_verbose() & VERBOSE_SQL ) printf("%s has triggered: %s\n",callsign,row[1]); *************** *** 543,547 **** if ( pid == 0 ) { struct passwd *pwd; ! if ( get_verbose() & 2 ) printf("\tattempting to run %s as %s in %s (pid=%d)\n",row[1],row[2],row[0],(int) getpid()); --- 543,547 ---- if ( pid == 0 ) { struct passwd *pwd; ! if ( get_verbose() & VERBOSE_SQL ) printf("\tattempting to run %s as %s in %s (pid=%d)\n",row[1],row[2],row[0],(int) getpid()); *************** *** 624,628 **** } while ( i<5 ); ! if ( get_verbose() & 4 ) { printf("Telemetry coefficients:\n"); for ( i=0 ; i<5 ; i++ ) { --- 624,628 ---- } while ( i<5 ); ! if ( get_verbose() & VERBOSE_DEBUG ) { printf("Telemetry coefficients:\n"); for ( i=0 ; i<5 ; i++ ) { *************** *** 639,643 **** a[4],b[4],c[4]); ! if ( get_verbose() & 4 ) printf("SQL: %sql_buf\n", sql_buf); --- 639,643 ---- a[4],b[4],c[4]); ! if ( get_verbose() & VERBOSE_SQL ) printf("SQL: %sql_buf\n", sql_buf); *************** *** 707,711 **** query(&sql_query,sql_buf,"INSERT"); ! if (get_verbose() & 2) printf ("%s;\n", sql_buf); --- 707,711 ---- query(&sql_query,sql_buf,"INSERT"); ! if (get_verbose() & VERBOSE_SQL) printf ("%s;\n", sql_buf); *************** *** 717,721 **** query(&sql_query,sql_buf,"REPLACE"); ! if (get_verbose() & 2) printf ("%s;\n", sql_buf); --- 717,721 ---- query(&sql_query,sql_buf,"REPLACE"); ! if (get_verbose() & VERBOSE_SQL) printf ("%s;\n", sql_buf); *************** *** 764,768 **** query(&sql_query,sql_buf,"REPLACE"); ! if (get_verbose() & 2) printf ("%s;\n", sql_buf); --- 764,768 ---- query(&sql_query,sql_buf,"REPLACE"); ! if (get_verbose() & VERBOSE_SQL) printf ("%s;\n", sql_buf); *************** *** 812,816 **** query(&sql_query,sql_buf,"INSERT"); ! if (get_verbose() & 2) printf ("%s;\n", sql_buf); --- 812,816 ---- query(&sql_query,sql_buf,"INSERT"); ! if (get_verbose() & VERBOSE_SQL) printf ("%s;\n", sql_buf); *************** *** 864,868 **** query(&sql_query,sql_buf,"INSERT"); ! if (get_verbose() & 2) printf ("%s;\n", sql_buf); --- 864,868 ---- query(&sql_query,sql_buf,"INSERT"); ! if (get_verbose() & VERBOSE_SQL) printf ("%s;\n", sql_buf); *************** *** 927,931 **** sql_insert_value(&sql_query, sql_buf); ! if ( get_verbose() & 1 ) printf("%sql_buf\n",table); --- 927,931 ---- sql_insert_value(&sql_query, sql_buf); ! if ( get_verbose() & VERBOSE_SQL ) printf("%sql_buf\n",table); *************** *** 949,953 **** query(&sql_query, sql_buf, "INSERT"); ! if (get_verbose() & 2) printf ("%s;\n", sql_buf); --- 949,953 ---- query(&sql_query, sql_buf, "INSERT"); ! if (get_verbose() & VERBOSE_SQL) printf ("%s;\n", sql_buf); *************** *** 964,968 **** if ( obj->kill ) { ! if ( get_verbose() & 2 ) { printf("---> Killing object %s\n",obj->name); --- 964,968 ---- if ( obj->kill ) { ! if ( get_verbose() & VERBOSE_SQL ) { printf("---> Killing object %s\n",obj->name); Index: db_pgsql.c =================================================================== RCS file: /cvsroot/aprsworld/parse/db_pgsql.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** db_pgsql.c 2 Jan 2008 03:32:46 -0000 1.8 --- db_pgsql.c 2 Jan 2008 04:25:10 -0000 1.9 *************** *** 79,83 **** int db_begin_txn() { ! if (get_verbose() & 2) printf("SQL: begin\n"); --- 79,83 ---- int db_begin_txn() { ! if (get_verbose() & VERBOSE_SQL) printf("SQL: begin\n"); *************** *** 100,104 **** int db_commit_txn() { ! if (get_verbose() & 2) printf("SQL: commit\n"); --- 100,104 ---- int db_commit_txn() { ! if (get_verbose() & VERBOSE_SQL) printf("SQL: commit\n"); *************** *** 118,122 **** int db_rollback_txn() { ! if (get_verbose() & 2) printf("SQL: rollback\n"); --- 118,122 ---- int db_rollback_txn() { ! if (get_verbose() & VERBOSE_SQL) printf("SQL: rollback\n"); *************** *** 162,166 **** sprintf(conninfo, "dbname=%s user=%s password=%s host=%s", database, username, password, host); ! if( get_verbose() & 4 ){ printf("%s\n",conninfo); } --- 162,166 ---- sprintf(conninfo, "dbname=%s user=%s password=%s host=%s", database, username, password, host); ! if( get_verbose() & VERBOSE_DEBUG ){ printf("%s\n",conninfo); } *************** *** 239,243 **** ); ! if (get_verbose() & 2) printf("SQL: %s\n", sql_buf); --- 239,243 ---- ); ! if (get_verbose() & VERBOSE_SQL) printf("SQL: %s\n", sql_buf); *************** *** 256,260 **** snprintf(sql_buf, 4096, "SELECT nextval('aprs_raw_seq')"); ! if (get_verbose() & 2) printf("SQL: %s\n", sql_buf); --- 256,260 ---- snprintf(sql_buf, 4096, "SELECT nextval('aprs_raw_seq')"); ! if (get_verbose() & VERBOSE_SQL) printf("SQL: %s\n", sql_buf); *************** *** 301,305 **** ); ! if (get_verbose() & 2) printf("SQL: %s\n", sql_buf); --- 301,305 ---- ); ! if (get_verbose() & VERBOSE_SQL) printf("SQL: %s\n", sql_buf); *************** *** 355,359 **** ); ! if (get_verbose() & 2) printf("SQL: %s\n", sql_buf); --- 355,359 ---- ); ! if (get_verbose() & VERBOSE_SQL) printf("SQL: %s\n", sql_buf); *************** *** 416,420 **** ! if (get_verbose() & 2) printf("SQL: %s\n", sql_buf); --- 416,420 ---- ! if (get_verbose() & VERBOSE_SQL) printf("SQL: %s\n", sql_buf); *************** *** 470,474 **** pos->latitude); ! if (get_verbose() & 2) printf("SQL: %s\n", sql_buf); --- 470,474 ---- pos->latitude); ! if (get_verbose() & VERBOSE_SQL) printf("SQL: %s\n", sql_buf); *************** *** 527,531 **** ); ! if (get_verbose() & 2) printf("SQL: %s\n", sql_buf); --- 527,531 ---- ); ! if (get_verbose() & VERBOSE_SQL) printf("SQL: %s\n", sql_buf); *************** *** 578,582 **** pos->latitude); ! if (get_verbose() & 2) printf("SQL: %s\n", sql_buf); --- 578,582 ---- pos->latitude); ! if (get_verbose() & VERBOSE_SQL) printf("SQL: %s\n", sql_buf); *************** *** 655,659 **** ! if (get_verbose() & 2) printf("SQL: %s\n", sql_buf); --- 655,659 ---- ! if (get_verbose() & VERBOSE_SQL) printf("SQL: %s\n", sql_buf); *************** *** 730,734 **** ); ! if (get_verbose() & 2) printf("SQL: %s\n", sql_buf); --- 730,734 ---- ); ! if (get_verbose() & VERBOSE_SQL) printf("SQL: %s\n", sql_buf); *************** *** 781,785 **** ); ! if (get_verbose() & 2) printf("SQL: %s\n", sql_buf); --- 781,785 ---- ); ! if (get_verbose() & VERBOSE_SQL) printf("SQL: %s\n", sql_buf); *************** *** 839,843 **** ); ! if (get_verbose() & 2) printf("SQL: %s\n", sql_buf); --- 839,843 ---- ); ! if (get_verbose() & VERBOSE_SQL) printf("SQL: %s\n", sql_buf); *************** *** 878,882 **** ); ! if (get_verbose() & 2) printf("SQL: %s\n", sql_buf); --- 878,882 ---- ); ! if (get_verbose() & VERBOSE_SQL) printf("SQL: %s\n", sql_buf); *************** *** 918,922 **** ); ! if (get_verbose() & 2) printf("SQL: %s\n", sql_buf); --- 918,922 ---- ); ! if (get_verbose() & VERBOSE_SQL) printf("SQL: %s\n", sql_buf); *************** *** 964,968 **** ); ! if (get_verbose() & 2) printf("SQL: %s\n", sql_buf); --- 964,968 ---- ); ! if (get_verbose() & VERBOSE_SQL) printf("SQL: %s\n", sql_buf); *************** *** 1016,1020 **** ); ! if (get_verbose() & 2) printf("SQL: %s\n", sql_buf); --- 1016,1020 ---- ); ! if (get_verbose() & VERBOSE_SQL) printf("SQL: %s\n", sql_buf); *************** *** 1161,1165 **** ); ! if (get_verbose() & 2) printf("SQL: %s\n", sql_buf); --- 1161,1165 ---- ); ! if (get_verbose() & VERBOSE_SQL) printf("SQL: %s\n", sql_buf); *************** *** 1215,1219 **** } while ( i<5 ); ! if ( get_verbose() & 4 ) { printf("Telemetry coefficients:\n"); for ( i=0 ; i<5 ; i++ ) { --- 1215,1219 ---- } while ( i<5 ); ! if ( get_verbose() & VERBOSE_DEBUG ) { printf("Telemetry coefficients:\n"); for ( i=0 ; i<5 ; i++ ) { *************** *** 1266,1270 **** a[4],b[4],c[4]); ! if (get_verbose() & 2) printf("SQL: %sql_buf\n", sql_buf); --- 1266,1270 ---- a[4],b[4],c[4]); ! if (get_verbose() & VERBOSE_SQL) printf("SQL: %sql_buf\n", sql_buf); *************** *** 1351,1355 **** ); ! if (get_verbose() & 2) printf("SQL: %s\n", sql_buf); --- 1351,1355 ---- ); ! if (get_verbose() & VERBOSE_SQL) printf("SQL: %s\n", sql_buf); *************** *** 1368,1372 **** snprintf(sql_buf, 4096, "delete from aprs_lastobject where source = '%s' and name = '%s'", postgres_escape(obj->source, strlen(obj->source), &newlen), postgres_escape(obj->name, strlen(obj->name), &newlen)); ! if (get_verbose() & 2) { printf("---> Killing object %s\n", obj->name); printf("SQL: %s\n", sql_buf); --- 1368,1372 ---- snprintf(sql_buf, 4096, "delete from aprs_lastobject where source = '%s' and name = '%s'", postgres_escape(obj->source, strlen(obj->source), &newlen), postgres_escape(obj->name, strlen(obj->name), &newlen)); ! if (get_verbose() & VERBOSE_SQL) { printf("---> Killing object %s\n", obj->name); printf("SQL: %s\n", sql_buf); *************** *** 1437,1441 **** ); ! if (get_verbose() & 2) printf("SQL: %s\n", sql_buf); --- 1437,1441 ---- ); ! if (get_verbose() & VERBOSE_SQL) printf("SQL: %s\n", sql_buf); *************** *** 1520,1524 **** ); ! if (get_verbose() & 2) printf("SQL: %s\n", sql_buf); --- 1520,1524 ---- ); ! if (get_verbose() & VERBOSE_SQL) printf("SQL: %s\n", sql_buf); *************** *** 1567,1571 **** ); ! if (get_verbose() & 2) printf("SQL: %s\n", sql_buf); --- 1567,1571 ---- ); ! if (get_verbose() & VERBOSE_SQL) printf("SQL: %s\n", sql_buf); *************** *** 1618,1622 **** ); ! if (get_verbose() & 2) printf("SQL: %s\n", sql_buf); --- 1618,1622 ---- ); ! if (get_verbose() & VERBOSE_SQL) printf("SQL: %s\n", sql_buf); *************** *** 1659,1663 **** ); ! if (get_verbose() & 2) printf("SQL: %s\n", sql_buf); --- 1659,1663 ---- ); ! if (get_verbose() & VERBOSE_SQL) printf("SQL: %s\n", sql_buf); |