mirror of
				https://bitbucket.org/jsuto/piler.git
				synced 2025-10-31 13:42:26 +01:00 
			
		
		
		
	sql errno fix
This commit is contained in:
		| @@ -7,6 +7,7 @@ | |||||||
|  |  | ||||||
| #ifdef NEED_MYSQL | #ifdef NEED_MYSQL | ||||||
|   #include <mysql.h> |   #include <mysql.h> | ||||||
|  |   #include <mysqld_error.h> | ||||||
| #endif | #endif | ||||||
| #ifdef NEED_PSQL | #ifdef NEED_PSQL | ||||||
|   #include <libpq-fe.h> |   #include <libpq-fe.h> | ||||||
| @@ -211,9 +212,9 @@ struct session_data { | |||||||
|    char ms_journal; |    char ms_journal; | ||||||
|    char import; |    char import; | ||||||
|    int journal_envelope_length, journal_bottom_length; |    int journal_envelope_length, journal_bottom_length; | ||||||
|  |    unsigned int sql_errno; | ||||||
| #ifdef NEED_MYSQL | #ifdef NEED_MYSQL | ||||||
|    MYSQL mysql; |    MYSQL mysql; | ||||||
|    unsigned int mysql_errno; |  | ||||||
| #endif | #endif | ||||||
| #ifdef NEED_PSQL | #ifdef NEED_PSQL | ||||||
|    PGconn *psql; |    PGconn *psql; | ||||||
|   | |||||||
| @@ -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){ |          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++; |          else n++; | ||||||
|       } |       } | ||||||
|   | |||||||
| @@ -510,9 +510,7 @@ void init_session_data(struct session_data *sdata, struct __config *cfg){ | |||||||
|    time(&(sdata->now)); |    time(&(sdata->now)); | ||||||
|    sdata->sent = sdata->delivered = sdata->retained = sdata->now; |    sdata->sent = sdata->delivered = sdata->retained = sdata->now; | ||||||
|  |  | ||||||
| #ifdef NEED_MYSQL |    sdata->sql_errno = 0; | ||||||
|    sdata->mysql_errno = 0; |  | ||||||
| #endif |  | ||||||
|  |  | ||||||
| #ifdef HAVE_TWEAK_SENT_TIME | #ifdef HAVE_TWEAK_SENT_TIME | ||||||
|    sdata->sent += cfg->tweak_sent_time_offset; |    sdata->sent += cfg->tweak_sent_time_offset; | ||||||
|   | |||||||
							
								
								
									
										10
									
								
								src/mysql.c
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								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]; |    unsigned long length[MAX_SQL_VARS]; | ||||||
|    int i, ret=ERR; |    int i, ret=ERR; | ||||||
|  |  | ||||||
|    sdata->mysql_errno = 0; |    sdata->sql_errno = 0; | ||||||
|    memset(bind, 0, sizeof(bind)); |    memset(bind, 0, sizeof(bind)); | ||||||
|  |  | ||||||
|    for(i=0; i<MAX_SQL_VARS; i++){ |    for(i=0; i<MAX_SQL_VARS; i++){ | ||||||
| @@ -106,14 +106,14 @@ int p_exec_query(struct session_data *sdata, MYSQL_STMT *stmt, struct __data *da | |||||||
|    } |    } | ||||||
|  |  | ||||||
|    if(mysql_stmt_bind_param(stmt, bind)){ |    if(mysql_stmt_bind_param(stmt, bind)){ | ||||||
|       sdata->mysql_errno = mysql_stmt_errno(stmt); |       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->mysql_errno); |       syslog(LOG_PRIORITY, "%s: mysql_stmt_bind_param() error: %s (errno: %d)", sdata->ttmpfile, mysql_stmt_error(stmt), sdata->sql_errno); | ||||||
|       goto CLOSE; |       goto CLOSE; | ||||||
|    } |    } | ||||||
|  |  | ||||||
|    if(mysql_stmt_execute(stmt)){ |    if(mysql_stmt_execute(stmt)){ | ||||||
|       sdata->mysql_errno = mysql_stmt_errno(stmt); |       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->mysql_errno); |       syslog(LOG_PRIORITY, "%s: mysql_stmt_execute error: *%s* (errno: %d)", sdata->ttmpfile, mysql_error(&(sdata->mysql)), sdata->sql_errno); | ||||||
|       goto CLOSE; |       goto CLOSE; | ||||||
|    } |    } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user