From 8b9ea0914465182d98e72e75376f6ca87b350d0d Mon Sep 17 00:00:00 2001 From: SJ Date: Thu, 10 Jul 2014 11:54:37 +0200 Subject: [PATCH] sql errno fix --- src/defs.h | 3 ++- src/message.c | 2 +- src/misc.c | 4 +--- src/mysql.c | 10 +++++----- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/defs.h b/src/defs.h index 4adfeb88..d85970c3 100644 --- a/src/defs.h +++ b/src/defs.h @@ -7,6 +7,7 @@ #ifdef NEED_MYSQL #include + #include #endif #ifdef NEED_PSQL #include @@ -211,9 +212,9 @@ struct session_data { char ms_journal; char import; int journal_envelope_length, journal_bottom_length; + unsigned int sql_errno; #ifdef NEED_MYSQL MYSQL mysql; - unsigned int mysql_errno; #endif #ifdef NEED_PSQL PGconn *psql; diff --git a/src/message.c b/src/message.c index 0312c137..dff97e5c 100644 --- a/src/message.c +++ b/src/message.c @@ -110,7 +110,7 @@ int store_recipients(struct session_data *sdata, struct __data *data, char *to, if(p_exec_query(sdata, data->stmt_insert_into_rcpt_table, data) == ERR){ - ret = ERR; + if(sdata->sql_errno != ER_DUP_ENTRY) ret = ERR; } else n++; } diff --git a/src/misc.c b/src/misc.c index 6dbfad7a..063eb46d 100644 --- a/src/misc.c +++ b/src/misc.c @@ -510,9 +510,7 @@ void init_session_data(struct session_data *sdata, struct __config *cfg){ time(&(sdata->now)); sdata->sent = sdata->delivered = sdata->retained = sdata->now; -#ifdef NEED_MYSQL - sdata->mysql_errno = 0; -#endif + sdata->sql_errno = 0; #ifdef HAVE_TWEAK_SENT_TIME sdata->sent += cfg->tweak_sent_time_offset; diff --git a/src/mysql.c b/src/mysql.c index 21aae40f..256efff6 100644 --- a/src/mysql.c +++ b/src/mysql.c @@ -57,7 +57,7 @@ int p_exec_query(struct session_data *sdata, MYSQL_STMT *stmt, struct __data *da unsigned long length[MAX_SQL_VARS]; int i, ret=ERR; - sdata->mysql_errno = 0; + sdata->sql_errno = 0; memset(bind, 0, sizeof(bind)); for(i=0; imysql_errno = mysql_stmt_errno(stmt); - syslog(LOG_PRIORITY, "%s: mysql_stmt_bind_param() error: %s (errno: %d)", sdata->ttmpfile, mysql_stmt_error(stmt), sdata->mysql_errno); + sdata->sql_errno = mysql_stmt_errno(stmt); + syslog(LOG_PRIORITY, "%s: mysql_stmt_bind_param() error: %s (errno: %d)", sdata->ttmpfile, mysql_stmt_error(stmt), sdata->sql_errno); goto CLOSE; } if(mysql_stmt_execute(stmt)){ - sdata->mysql_errno = mysql_stmt_errno(stmt); - syslog(LOG_PRIORITY, "%s: mysql_stmt_execute error: *%s* (errno: %d)", sdata->ttmpfile, mysql_error(&(sdata->mysql)), sdata->mysql_errno); + sdata->sql_errno = mysql_stmt_errno(stmt); + syslog(LOG_PRIORITY, "%s: mysql_stmt_execute error: *%s* (errno: %d)", sdata->ttmpfile, mysql_error(&(sdata->mysql)), sdata->sql_errno); goto CLOSE; }