freebsd-ports/mail/dbmail/files/patch-0003-Fix-IMAP-mailbox-maintanence
Muhammad Moinur Rahman 9eff14e488 mail/dbmail: adopt latest fixes from git:
- login_disabled option before starttls for pop3
- fix compiler warnings for GCC5
- Fix IMAP mailbox maintanence
- prevent assertion in p_string_erase
- improve crypt authentication, also don't segfault when spasswd is empty
- simplify log_query_time duration logic
- Disconnect IMAP clients if only few free FDs left
- Add primary key constraint to dbmail_authlog
- Rework temporary connection failures
- Give sensible default for retry 120s
- Add retries for binding and searching
- Bump search timeout to 60s
- Increase ldap timeout to 600s 10 mins
- Refactor deprecated functions
- Get timeout from config
- Remove redundant event_assign
- Remove deprecated non functioning g_mem_profile
- Add definition for authldap_free
- Revert inadvertent event_assign removal
- Reduce failed LDAP connection for search to error
- Update LDAP to non deprecated search
- Clear the ldap connection
- Update ldap deprecated unbind
- Fix typo
- Update to ldap_unbind_ext_s and remove redundant sigaction
- Rebalance commit rollback
- Ensure mailbox2dbmail is using Python 2
- Tidy mailbox2dbmail man page
- Update description of pid file location in server man page
- Boundaries fixups ordering of parts do not add newline on
- Prepend headers during delivery
- Allow for systems that don't use proc

PR:		210274
Submitted by:	fluffy
2017-02-24 21:15:52 +00:00

82 lines
2.9 KiB
Plaintext

From f2d27f8727ae4159d356d63c1af6ac1a60b1261a Mon Sep 17 00:00:00 2001
From: Pavlo Lavrenenko <Pavlo.Lavrenenko@portaone.com>
Date: Thu, 21 May 2015 11:42:56 +0300
Subject: [PATCH 03/33] Fix IMAP mailbox maintanence
Update message's mailbox id in a separate explicit transaction to prevent
SQLException: ORA-01453 error on the next db_begin_transaction() call
(see db_mailbox_seq_update() next to 'UPDATE dbmail_messages SET mailbox_idnr'
query).
---
src/dm_db.c | 6 ++++++
src/dm_db.h | 1 +
src/maintenance.c | 8 ++------
3 files changed, 9 insertions(+), 6 deletions(-)
diff --git src/dm_db.c src/dm_db.c
index feb0b34..313b33f 100644
--- src/dm_db.c
+++ src/dm_db.c
@@ -4290,6 +4290,12 @@ void db_message_set_seq(uint64_t message_id, uint64_t seq)
END_TRY;
}
+int db_move_message(uint64_t message_id, uint64_t mailbox_id)
+{
+ return db_update("UPDATE %smessages SET mailbox_idnr = %" PRIu64 " WHERE message_idnr = %" PRIu64 "",
+ DBPFX, mailbox_id, message_id);
+}
+
int db_rehash_store(void)
{
GList *ids = NULL;
diff --git src/dm_db.h src/dm_db.h
index 57aa256..84595d2 100644
--- src/dm_db.h
+++ src/dm_db.h
@@ -777,6 +777,7 @@ char * db_returning(const char *s);
uint64_t db_mailbox_seq_update(uint64_t mailbox_id, uint64_t message_id);
void db_message_set_seq(uint64_t message_id, uint64_t seq);
+int db_move_message(uint64_t message_id, uint64_t mailbox_id);
int db_rehash_store(void);
diff --git src/maintenance.c src/maintenance.c
index b4a020b..24b818c 100644
--- src/maintenance.c
+++ src/maintenance.c
@@ -1184,7 +1184,7 @@ int do_erase_old(int days, char * mbtrash_name)
/* Move message to Trash if the message is in INBOX mailbox and date less then passed date. */
int do_move_old (int days, char * mbinbox_name, char * mbtrash_name)
{
- Connection_T c; ResultSet_T r; ResultSet_T r1; PreparedStatement_T s; PreparedStatement_T s1; PreparedStatement_T s2;
+ Connection_T c; ResultSet_T r; ResultSet_T r1; PreparedStatement_T s; PreparedStatement_T s1;
int skip = 1;
char expire [DEF_FRAGSIZE];
uint64_t mailbox_to;
@@ -1200,9 +1200,7 @@ int do_move_old (int days, char * mbinbox_name, char * mbtrash_name)
"WHERE mb.name = ? AND msg.status < %d "
"AND phys.internal_date < %s",
DBPFX, DBPFX, DBPFX, MESSAGE_STATUS_DELETE, expire);
-
s1 = db_stmt_prepare(c, "SELECT mailbox_idnr FROM %smailboxes WHERE owner_idnr = ? AND name = ?", DBPFX);
- s2 = db_stmt_prepare(c, "UPDATE %smessages SET mailbox_idnr = ? WHERE message_idnr = ?", DBPFX);
db_stmt_set_str(s, 1, mbinbox_name);
@@ -1225,9 +1223,7 @@ int do_move_old (int days, char * mbinbox_name, char * mbtrash_name)
}
if (!skip) {
- db_stmt_set_u64(s2,1,mailbox_to);
- db_stmt_set_u64(s2,2,id);
- db_stmt_exec(s2);
+ db_move_message(id, mailbox_to);
db_mailbox_seq_update(mailbox_to, 0);
db_mailbox_seq_update(mailbox_from, 0);
}
--
2.10.1 (Apple Git-78)