more sql logging

This commit is contained in:
SJ 2015-07-24 15:01:22 +02:00
parent ed0a8bafd5
commit 394ff81ac6
6 changed files with 14 additions and 12 deletions

View File

@ -14,7 +14,7 @@
#define VERSION "1.2.0-master"
#define BUILD 914
#define BUILD 915
#define HOSTID "mailarchiver"

View File

@ -92,7 +92,7 @@ void update_counters(struct session_data *sdata, struct __data *data, struct __c
//if(cfg->verbosity >= _LOG_DEBUG) syslog(LOG_PRIORITY, "%s: update counters: %s", sdata->ttmpfile, buf);
p_query(sdata, buf);
p_query(sdata, buf, cfg);
}
}
@ -115,7 +115,7 @@ void update_counters(struct session_data *sdata, struct __data *data, struct __c
else {
#endif
snprintf(buf, SMALLBUFSIZE-1, "UPDATE `%s` SET `rcvd`=`rcvd`+%llu, `virus`=`virus`+%llu, `duplicate`=`duplicate`+%llu, `ignore`=`ignore`+%llu, `size`=`size`+%llu, `stored_size`=`stored_size`+%llu", SQL_COUNTER_TABLE, counters->c_rcvd, counters->c_virus, counters->c_duplicate, counters->c_ignore, counters->c_size, counters->c_stored_size);
p_query(sdata, buf);
p_query(sdata, buf, cfg);
#ifdef HAVE_MEMCACHED
}

View File

@ -188,12 +188,12 @@ int add_new_folder(struct session_data *sdata, struct __data *data, char *folder
}
void update_import_job_stat(struct session_data *sdata, struct __data *data){
void update_import_job_stat(struct session_data *sdata, struct __data *data, struct __config *cfg){
char buf[SMALLBUFSIZE];
snprintf(buf, sizeof(buf)-1, "update import set status=%d, started=%ld, updated=%ld, finished=%ld, total=%d, imported=%d where id=%d", data->import->status, data->import->started, data->import->updated, data->import->finished, data->import->total_messages, data->import->processed_messages, data->import->import_job_id);
p_query(sdata, buf);
p_query(sdata, buf, cfg);
}

View File

@ -47,7 +47,9 @@ void p_bind_init(struct __data *data){
}
void p_query(struct session_data *sdata, char *s){
void p_query(struct session_data *sdata, char *s, struct __config *cfg){
if(cfg->verbosity >= _LOG_DEBUG) syslog(LOG_PRIORITY, "%s: p_query=%s", sdata->ttmpfile, s);
mysql_real_query(&(sdata->mysql), s, strlen(s));
}
@ -210,7 +212,7 @@ int p_get_affected_rows(MYSQL_STMT *stmt){
int prepare_sql_statement(struct session_data *sdata, MYSQL_STMT **stmt, char *s, struct __config *cfg){
if(cfg->verbosity >= _LOG_DEBUG) syslog(LOG_PRIORITY, "%s: sql=%s", sdata->ttmpfile, s);
if(cfg->verbosity >= _LOG_DEBUG) syslog(LOG_PRIORITY, "%s: prepare statement=%s", sdata->ttmpfile, s);
*stmt = mysql_stmt_init(&(sdata->mysql));
if(!*stmt){

View File

@ -94,7 +94,7 @@ int remove_message_frame_files(char *s, char *update_meta_sql, struct session_da
if(dryrun == 1){
printf("running sql query: *%s*\n\n", update_meta_sql);
} else {
p_query(sdata, update_meta_sql);
p_query(sdata, update_meta_sql, cfg);
}
@ -188,7 +188,7 @@ int remove_attachments(char *in, struct session_data *sdata, struct __data *data
if(dryrun == 1){
printf("delete sql: *%s*\n", delete_attachment_stmt);
} else {
p_query(sdata, delete_attachment_stmt);
p_query(sdata, delete_attachment_stmt, cfg);
}
}
@ -221,7 +221,7 @@ int remove_attachments(char *in, struct session_data *sdata, struct __data *data
if(dryrun == 1){
printf("delete sql: *%s*\n", delete_attachment_stmt);
} else {
p_query(sdata, delete_attachment_stmt);
p_query(sdata, delete_attachment_stmt, cfg);
}
}
@ -402,7 +402,7 @@ int main(int argc, char **argv){
if(purged_size > 100){
snprintf(buf, sizeof(buf)-1, "UPDATE `%s` SET size = size - %ld", SQL_COUNTER_TABLE, purged_size);
if(dryrun == 0) p_query(&sdata, buf);
if(dryrun == 0) p_query(&sdata, buf, &cfg);
}

View File

@ -9,7 +9,7 @@
int open_database(struct session_data *sdata, struct __config *cfg);
void close_database(struct session_data *sdata);
int prepare_sql_statement(struct session_data *sdata, MYSQL_STMT **stmt, char *s, struct __config *cfg);
void p_query(struct session_data *sdata, char *s);
void p_query(struct session_data *sdata, char *s, struct __config *cfg);
int p_exec_query(struct session_data *sdata, MYSQL_STMT *stmt, struct __data *data);
int p_store_results(struct session_data *sdata, MYSQL_STMT *stmt, struct __data *data);
int p_fetch_results(MYSQL_STMT *stmt);