Changeset View
Changeset View
Standalone View
Standalone View
mail/dbmail/files/patch-010-mysql57-workaround
- This file was added.
Property | Old Value | New Value |
---|---|---|
fbsd:nokeywords | null | yes \ No newline at end of property |
svn:eol-style | null | native \ No newline at end of property |
svn:mime-type | null | text/plain \ No newline at end of property |
diff --git src/clientbase.c src/clientbase.c | |||||
index a8804876..663b233b 100644 | |||||
--- src/clientbase.c | |||||
+++ src/clientbase.c | |||||
@@ -515,9 +515,13 @@ void ci_authlog_init(ClientBase_T *client, const char *service, const char *user | |||||
db_stmt_set_int(s, 6, atoi(client->dst_port)); | |||||
db_stmt_set_str(s, 7, status); | |||||
- r = db_stmt_query(s); | |||||
- | |||||
- if(strcmp(AUTHLOG_ERR,status)!=0) client->authlog_id = db_insert_result(c, r); | |||||
+ if (db_params.db_driver == DM_DRIVER_ORACLE || db_params.db_driver == DM_DRIVER_MYSQL) { | |||||
+ db_stmt_exec(s); | |||||
+ if(strcmp(AUTHLOG_ERR,status)!=0) client->authlog_id = db_get_pk(c, "authlog"); | |||||
+ } else { | |||||
+ r = db_stmt_query(s); | |||||
+ if(strcmp(AUTHLOG_ERR,status)!=0) client->authlog_id = db_insert_result(c, r); | |||||
+ } | |||||
CATCH(SQLException) | |||||
LOG_SQLERROR; | |||||
FINALLY | |||||
diff --git src/dm_db.c src/dm_db.c | |||||
index 429d0aef..1250bcf0 100644 | |||||
--- src/dm_db.c | |||||
+++ src/dm_db.c | |||||
@@ -516,6 +516,11 @@ inline gboolean db_stmt_exec(PreparedStatement_T s) | |||||
inline ResultSet_T db_stmt_query(PreparedStatement_T s) | |||||
{ | |||||
+ // with prepared INSERT statements and mysql 5.7.? | |||||
+ // better stick to db_stmt_exec() and db_get_pk() | |||||
+ // due to CURSOR_TYPE_READ_ONLY issue | |||||
+ // (see mysql bug #85105 and libzdb issue #21) | |||||
+ | |||||
return PreparedStatement_executeQuery(s); | |||||
} | |||||
@@ -587,7 +592,11 @@ uint64_t db_get_pk(Connection_T c, const char *table) | |||||
{ | |||||
ResultSet_T r; | |||||
uint64_t id = 0; | |||||
- r = db_query(c, "SELECT sq_%s%s.CURRVAL FROM DUAL", DBPFX, table); | |||||
+ if (db_params.db_driver == DM_DRIVER_MYSQL) { | |||||
+ r = db_query(c, "SELECT LAST_INSERT_ID()"); | |||||
+ } else { | |||||
+ r = db_query(c, "SELECT sq_%s%s.CURRVAL FROM DUAL", DBPFX, table); | |||||
+ } | |||||
if (db_result_next(r)) | |||||
id = db_result_get_u64(r, 0); | |||||
assert(id); | |||||
@@ -2637,7 +2646,7 @@ int db_createmailbox(const char * name, uint64_t owner_idnr, uint64_t * mailbox_ | |||||
db_stmt_set_str(s,1,simple_name); | |||||
db_stmt_set_u64(s,2,owner_idnr); | |||||
- if (db_params.db_driver == DM_DRIVER_ORACLE) { | |||||
+ if (db_params.db_driver == DM_DRIVER_ORACLE || db_params.db_driver == DM_DRIVER_MYSQL) { | |||||
db_stmt_exec(s); | |||||
*mailbox_idnr = db_get_pk(c, "mailboxes"); | |||||
} else { | |||||
@@ -3974,7 +3983,7 @@ int db_user_create(const char *username, const char *password, const char *encty | |||||
db_stmt_set_str(s, 6, encoding); | |||||
} | |||||
g_free(frag); | |||||
- if (db_params.db_driver == DM_DRIVER_ORACLE) { | |||||
+ if (db_params.db_driver == DM_DRIVER_ORACLE || db_params.db_driver == DM_DRIVER_MYSQL) { | |||||
db_stmt_exec(s); | |||||
id = db_get_pk(c, "users"); | |||||
} else { | |||||
diff --git src/dm_message.c src/dm_message.c | |||||
index 82b0656b..0082d4c9 100644 | |||||
--- src/dm_message.c | |||||
+++ src/dm_message.c | |||||
@@ -191,7 +191,7 @@ static uint64_t blob_insert(const char *buf, const char *hash) | |||||
db_stmt_set_str(s, 1, hash); | |||||
db_stmt_set_blob(s, 2, buf, l); | |||||
db_stmt_set_int(s, 3, l); | |||||
- if (db_params.db_driver == DM_DRIVER_ORACLE) { | |||||
+ if (db_params.db_driver == DM_DRIVER_ORACLE || db_params.db_driver == DM_DRIVER_MYSQL) { | |||||
db_stmt_exec(s); | |||||
id = db_get_pk(c, "mimeparts"); | |||||
} else { | |||||
@@ -1451,7 +1451,7 @@ static int _header_name_get_id(const DbmailMessage *self, const char *header, ui | |||||
db_stmt_set_str(s,1,safe_header); | |||||
- if (db_params.db_driver == DM_DRIVER_ORACLE) { | |||||
+ if (db_params.db_driver == DM_DRIVER_ORACLE || db_params.db_driver == DM_DRIVER_MYSQL) { | |||||
db_stmt_exec(s); | |||||
*tmp = db_get_pk(c, "headername"); | |||||
} else { | |||||
@@ -1534,7 +1534,7 @@ static uint64_t _header_value_insert(Connection_T c, const char *value, const ch | |||||
if (datesize) | |||||
db_stmt_set_str(s, 4, datefield); | |||||
- if (db_params.db_driver == DM_DRIVER_ORACLE) { | |||||
+ if (db_params.db_driver == DM_DRIVER_ORACLE || db_params.db_driver == DM_DRIVER_MYSQL) { | |||||
db_stmt_exec(s); | |||||
id = db_get_pk(c, "headervalue"); | |||||
} else { | |||||