mail-index-transaction.c revision a2cbf1d392ee983520451bc9b849a490f28ac298
2454dfa32c93c20a8522c6ed42fe057baaac9f9aStephan Bosch/* Copyright (C) 2003-2004 Timo Sirainen */
71df09024cea5f2faa93da3bb9513ee96ba6bf22Timo Sirainen/* Inside transaction we keep messages stored in sequences in uid fields.
71df09024cea5f2faa93da3bb9513ee96ba6bf22Timo Sirainen Before they're written to transaction log the sequences are changed to
5e327e031d1591f8bff17b67eba7139afbd36cddTimo Sirainen UIDs. This is because we're able to compress sequence ranges better. */
71df09024cea5f2faa93da3bb9513ee96ba6bf22Timo Sirainenvoid mail_index_transaction_reset(struct mail_index_transaction *t)
5e327e031d1591f8bff17b67eba7139afbd36cddTimo Sirainen struct mail_index_transaction_ext_hdr_update **ext_hdrs;
f36c4185474823594a78b3f252e79d8923522c36Timo Sirainen recs = array_get_modifiable(&t->ext_rec_updates, &count);
71df09024cea5f2faa93da3bb9513ee96ba6bf22Timo Sirainen for (i = 0; i < count; i++) {
71df09024cea5f2faa93da3bb9513ee96ba6bf22Timo Sirainen ext_hdrs = array_get_modifiable(&t->ext_hdr_updates, &count);
71df09024cea5f2faa93da3bb9513ee96ba6bf22Timo Sirainen for (i = 0; i < count; i++)
e60c3e17c656c53da60f0ac51aa15e9ef2742d77Stephan Bosch struct mail_index_transaction_keyword_update *u;
1e11a94ec50fc9b57eb2c859771c6a326ccaf86fAki Tuomi u = array_get_modifiable(&t->keyword_updates, &count);
71df09024cea5f2faa93da3bb9513ee96ba6bf22Timo Sirainen for (i = 0; i < count; i++) {
f36c4185474823594a78b3f252e79d8923522c36Timo Sirainen t->first_new_seq = mail_index_view_get_messages_count(t->view)+1;
5e327e031d1591f8bff17b67eba7139afbd36cddTimo Sirainen memset(t->pre_hdr_mask, 0, sizeof(t->pre_hdr_mask));
5e327e031d1591f8bff17b67eba7139afbd36cddTimo Sirainen memset(t->post_hdr_mask, 0, sizeof(t->post_hdr_mask));
71df09024cea5f2faa93da3bb9513ee96ba6bf22Timo Sirainen mail_cache_transaction_rollback(t->cache_trans_ctx);
71df09024cea5f2faa93da3bb9513ee96ba6bf22Timo Sirainenstatic void mail_index_transaction_free(struct mail_index_transaction *t)
71df09024cea5f2faa93da3bb9513ee96ba6bf22Timo Sirainenmail_index_transaction_get_view(struct mail_index_transaction *t)
71df09024cea5f2faa93da3bb9513ee96ba6bf22Timo Sirainenbool mail_index_transaction_is_expunged(struct mail_index_transaction *t,
107659c01b2359b0ee426bde020c8d4e29ede30dTimo Sirainenvoid mail_index_transaction_ref(struct mail_index_transaction *t)
107659c01b2359b0ee426bde020c8d4e29ede30dTimo Sirainenvoid mail_index_transaction_unref(struct mail_index_transaction **_t)
107659c01b2359b0ee426bde020c8d4e29ede30dTimo Sirainen if (--t->refcount == 0)
71df09024cea5f2faa93da3bb9513ee96ba6bf22Timo Sirainenbool mail_index_seq_array_lookup(const ARRAY_TYPE(seq_array) *array,
71df09024cea5f2faa93da3bb9513ee96ba6bf22Timo Sirainen /* we're probably appending it, check */
return TRUE;
return FALSE;
void *old_record)
return TRUE;
return FALSE;
for (i = 0; i < count; i++) {
unsigned int i, count;
for (i = 0; i < count; i++) {
unsigned int i, count;
for (i = 0; i < count; i++) {
FALSE);
struct uid_map {
const int max_days =
int i, days;
if (!t->appends_nonsorted)
for (i = 0; i < count; i++) {
for (i = 0; i < count; i++)
for (i = 0; i < count; i++)
ext_rec_array_count = 0;
for (j = 0; j < ext_rec_array_count; j++) {
unsigned int ext_count;
for (i = 0; i < ext_count; i++) {
(t->first_new_seq +
int ret;
if (mail_index_transaction_convert_to_uids(t) < 0)
return ret;
t->v.rollback(t);
struct mail_index_record *
if (t->last_new_seq != 0)
if (uid != 0) {
if (!t->appends_nonsorted &&
unsigned int i, count;
for (i = 0; i < count; i++) {
for (; i < count; i++) {
struct mail_transaction_flag_update u,
unsigned int count;
idx++;
tmp_update = u;
move = 0;
~u.remove_flags;
~u.add_flags;
switch (modify_type) {
case MODIFY_REPLACE:
case MODIFY_ADD:
case MODIFY_REMOVE:
unsigned int count;
memset(&u, 0, sizeof(u));
switch (modify_type) {
case MODIFY_REPLACE:
case MODIFY_ADD:
case MODIFY_REMOVE:
t->last_update_idx++;
last_update++;
count);
bool prepend)
if (prepend) {
unsigned int i, count;
for (i = 0; i < count; i++) {
return TRUE;
for (i = 0; i < count; i++) {
return TRUE;
for (i = 0; i < count; i++) {
if (ids[i] != 0)
return TRUE;
for (i = 0; i < count; i++) {
return TRUE;
return FALSE;
unsigned int count;
count = 0;
old_data_r)) {
struct mail_keywords *
const char *const keywords[])
struct mail_keywords *k;
unsigned int i, count;
if (count == 0) {
for (i = 0; i < count; i++) {
struct mail_keywords *
struct mail_keywords *k;
unsigned int count;
if (count == 0) {
struct mail_index_transaction_keyword_update *u;
unsigned int i, ku_count;
switch (modify_type) {
case MODIFY_ADD:
case MODIFY_REMOVE:
case MODIFY_REPLACE:
&ku_count);
for (i = 0; i < ku_count; i++) {
struct mail_index_transaction *
struct mail_index_transaction *t;
t->v = trans_vfuncs;
t->first_new_seq =