diff options
-rw-r--r-- | Changes | 2 | ||||
-rw-r--r-- | src/mysql.c | 44 | ||||
-rw-r--r-- | version.log | 6 |
3 files changed, 20 insertions, 32 deletions
@@ -2,7 +2,7 @@ Anope Version S V N -------------------- Provided by Anope Dev. <dev@anope.org> - 2006 08/09 F Fixed port checking when using command line switches. [#575] -08/14 F Fixed db_mysql_query for better robustness. [ #00] +08/14 F Fixed db_mysql_query for better robustness. [#585] Provided by Trystan <trystan@nomadirc.net> - 2006 08/20 F Fixed several compiler warnings. [#586] diff --git a/src/mysql.c b/src/mysql.c index c96f1de14..c7dfc8fbe 100644 --- a/src/mysql.c +++ b/src/mysql.c @@ -121,11 +121,12 @@ int db_mysql_open() int db_mysql_query(char *sql) { - int result, lcv; + int lcv; char *s; if (!do_mysql) { - return -1; + /* Error is 1 */ + return 1; } if (debug) { @@ -138,43 +139,26 @@ int db_mysql_query(char *sql) /* Try as many times as configured in MysqlRetries */ for (lcv = 0; lcv < MysqlRetries; lcv++) { - if (db_mysql_open()) { - - /* Attempt to run query */ - result = mysql_query(mysql, sql); - if (result) { - switch (mysql_errno(mysql)) { - case CR_COMMANDS_OUT_OF_SYNC: - case CR_SERVER_GONE_ERROR: - case CR_UNKNOWN_ERROR: - case CR_SERVER_LOST: - - /* If we get here, we could not run the query */ - log_perror("Unable to run query: %s\n", - mysql_error(mysql)); - - break; - - default: - - /* Success... return result */ - return (result); + if (db_mysql_open() && (!mysql_query(mysql, sql))) { + + /* Success is 0 */ + return 0; - } - } else { - /* Non-error */ - return (result); - } } + /* If we get here, we could not run the query */ + log_perror("Unable to run query: %s\n", mysql_error(mysql)); + /* Wait for MysqlRetryGap seconds and try again */ sleep(MysqlRetryGap); } + /* Unable to run the query */ db_mysql_error(MYSQL_ERROR, "query"); - return (0); + /* Error is 1 */ + return 1; } @@ -255,7 +239,7 @@ char *db_mysql_secure(char *pass) } #else - if (!pass) { + if (pass) { snprintf(epass, sizeof(epass), "''"); } else if ((!MysqlSecure) || (strcmp(MysqlSecure, "") == 0)) { snprintf(epass, sizeof(epass), "'%s'", pass); diff --git a/version.log b/version.log index f06fe72f8..f907f1421 100644 --- a/version.log +++ b/version.log @@ -9,10 +9,14 @@ VERSION_MAJOR="1" VERSION_MINOR="7" VERSION_PATCH="15" VERSION_EXTRA="-svn" -VERSION_BUILD="1137" +VERSION_BUILD="1138" # $Log$ # +# BUILD : 1.7.15 (1138) +# BUGS : 585 +# NOTES : Another attempt at fixing db_mysql_query() +# # BUILD : 1.7.15 (1137) # BUGS : n/a # NOTES : Another try at better mysql query. |