Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/clientbase.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 12 additions & 3 deletions src/dm_db.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions src/dm_message.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down