Index: camel-db.c
===================================================================
--- camel-db.c	(revision 10017)
+++ camel-db.c	(working copy)
@@ -1560,15 +1566,21 @@
 	gboolean first = TRUE;
 	GString *str = g_string_new ("DELETE FROM ");
 	GSList *iterator;
-	GString *ins_str = g_string_new ("INSERT OR REPLACE INTO Deletes (uid, mailbox, time) SELECT uid, ");
+	GString *ins_str = NULL;
+		
+	if (strcmp (field, "vuid") != 0)
+		ins_str = g_string_new ("INSERT OR REPLACE INTO Deletes (uid, mailbox, time) SELECT uid, ");
 
 	camel_db_begin_transaction (cdb, ex);
 
-	ret = camel_db_create_deleted_table (cdb, ex);
+	if (ins_str)
+		ret = camel_db_create_deleted_table (cdb, ex);
 
-	tab = sqlite3_mprintf ("%Q, strftime(\"%%s\", 'now') FROM %Q WHERE %s IN (", folder_name, folder_name, field);
-	g_string_append_printf (ins_str, "%s ", tab);
-	sqlite3_free (tab);
+	if (ins_str) {
+		tab = sqlite3_mprintf ("%Q, strftime(\"%%s\", 'now') FROM %Q WHERE %s IN (", folder_name, folder_name, field);
+		g_string_append_printf (ins_str, "%s ", tab);
+		sqlite3_free (tab);
+	}
 
 	tmp = sqlite3_mprintf ("%Q WHERE %s IN (", folder_name, field); 
 	g_string_append_printf (str, "%s ", tmp);
@@ -1584,30 +1596,33 @@
 
 		if (first == TRUE) {
 			g_string_append_printf (str, " %s ", tmp);
-			g_string_append_printf (ins_str, " %s ", tmp);
+			if (ins_str)
+				g_string_append_printf (ins_str, " %s ", tmp);	
 			first = FALSE;
 		} else {
 			g_string_append_printf (str, ", %s ", tmp);
-			g_string_append_printf (ins_str, ", %s ", tmp);
+			if (ins_str)
+				g_string_append_printf (ins_str, ", %s ", tmp);
 		}
 
 		sqlite3_free (tmp);
 	}
 
 	g_string_append (str, ")");
-	g_string_append (ins_str, ")");
+	if (ins_str) {
+		g_string_append (ins_str, ")");
+		ret = camel_db_add_to_transaction (cdb, ins_str->str, ex);
+		ret = camel_db_trim_deleted_table (cdb, ex);
+	}
 
-	ret = camel_db_add_to_transaction (cdb, ins_str->str, ex);
-
-	ret = camel_db_trim_deleted_table (cdb, ex);
-
 	ret = camel_db_add_to_transaction (cdb, str->str, ex);
 
 	ret = camel_db_end_transaction (cdb, ex);
 
 	CAMEL_DB_RELEASE_SQLITE_MEMORY;
 
-	g_string_free (ins_str, TRUE);
+	if (ins_str)
+		g_string_free (ins_str, TRUE);
 	g_string_free (str, TRUE);
 
 	return ret;
