|
|
5e6360 |
diff --git a/addressbook/libedata-book/e-book-sqlite.c b/addressbook/libedata-book/e-book-sqlite.c
|
|
|
5e6360 |
index e3770fe..64449db 100644
|
|
|
5e6360 |
--- a/addressbook/libedata-book/e-book-sqlite.c
|
|
|
5e6360 |
+++ b/addressbook/libedata-book/e-book-sqlite.c
|
|
|
5e6360 |
@@ -246,7 +246,7 @@ ebsql_init_debug (void)
|
|
|
5e6360 |
} \
|
|
|
5e6360 |
} G_STMT_END
|
|
|
5e6360 |
|
|
|
5e6360 |
-#define FOLDER_VERSION 8
|
|
|
5e6360 |
+#define FOLDER_VERSION 9
|
|
|
5e6360 |
#define INSERT_MULTI_STMT_BYTES 128
|
|
|
5e6360 |
#define COLUMN_DEFINITION_BYTES 32
|
|
|
5e6360 |
#define GENERATED_QUERY_BYTES 1024
|
|
|
5e6360 |
@@ -2075,7 +2075,7 @@ format_multivalues (EBookSqlite *ebsql)
|
|
|
5e6360 |
}
|
|
|
5e6360 |
}
|
|
|
5e6360 |
|
|
|
5e6360 |
- return g_string_free (string, FALSE);
|
|
|
5e6360 |
+ return g_string_free (string, string->len == 0);
|
|
|
5e6360 |
}
|
|
|
5e6360 |
|
|
|
5e6360 |
/* Called with the lock held and inside a transaction */
|
|
|
5e6360 |
@@ -2109,6 +2109,23 @@ ebsql_add_folder (EBookSqlite *ebsql,
|
|
|
5e6360 |
return success;
|
|
|
5e6360 |
}
|
|
|
5e6360 |
|
|
|
5e6360 |
+static gboolean
|
|
|
5e6360 |
+ebsql_email_list_exists (EBookSqlite *ebsql)
|
|
|
5e6360 |
+{
|
|
|
5e6360 |
+ gint n_tables = 0;
|
|
|
5e6360 |
+ gboolean success;
|
|
|
5e6360 |
+
|
|
|
5e6360 |
+ success = ebsql_exec_printf (
|
|
|
5e6360 |
+ ebsql, "SELECT count(*) FROM sqlite_master WHERE type='table' AND name='%q_email_list';",
|
|
|
5e6360 |
+ get_count_cb, &n_tables, NULL, NULL,
|
|
|
5e6360 |
+ ebsql->priv->folderid);
|
|
|
5e6360 |
+
|
|
|
5e6360 |
+ if (!success)
|
|
|
5e6360 |
+ return FALSE;
|
|
|
5e6360 |
+
|
|
|
5e6360 |
+ return n_tables == 1;
|
|
|
5e6360 |
+}
|
|
|
5e6360 |
+
|
|
|
5e6360 |
/* Called with the lock held and inside a transaction */
|
|
|
5e6360 |
static gboolean
|
|
|
5e6360 |
ebsql_introspect_summary (EBookSqlite *ebsql,
|
|
|
5e6360 |
@@ -2225,6 +2242,19 @@ ebsql_introspect_summary (EBookSqlite *ebsql,
|
|
|
5e6360 |
if (!success)
|
|
|
5e6360 |
goto introspect_summary_finish;
|
|
|
5e6360 |
|
|
|
5e6360 |
+ if (!multivalues || !*multivalues) {
|
|
|
5e6360 |
+ g_free (multivalues);
|
|
|
5e6360 |
+ multivalues = NULL;
|
|
|
5e6360 |
+
|
|
|
5e6360 |
+ /* The migration from a previous version didn't store this default multivalue
|
|
|
5e6360 |
+ reference, thus the next backend open (not the immediate one after migration),
|
|
|
5e6360 |
+ didn't know about this table, which has a FOREIGN KEY constraint, thus an item
|
|
|
5e6360 |
+ delete caused a 'FOREIGN KEY constraint failed' error.
|
|
|
5e6360 |
+ */
|
|
|
5e6360 |
+ if (ebsql_email_list_exists (ebsql))
|
|
|
5e6360 |
+ multivalues = g_strdup ("email;prefix");
|
|
|
5e6360 |
+ }
|
|
|
5e6360 |
+
|
|
|
5e6360 |
if (multivalues) {
|
|
|
5e6360 |
gchar **fields = g_strsplit (multivalues, ":", 0);
|
|
|
5e6360 |
|
|
|
5e6360 |
@@ -2524,6 +2554,20 @@ ebsql_init_aux_tables (EBookSqlite *ebsql,
|
|
|
5e6360 |
field->aux_table));
|
|
|
5e6360 |
}
|
|
|
5e6360 |
|
|
|
5e6360 |
+ if (success) {
|
|
|
5e6360 |
+ gchar *multivalues;
|
|
|
5e6360 |
+
|
|
|
5e6360 |
+ multivalues = format_multivalues (ebsql);
|
|
|
5e6360 |
+
|
|
|
5e6360 |
+ success = ebsql_exec_printf (
|
|
|
5e6360 |
+ ebsql,
|
|
|
5e6360 |
+ "UPDATE folders SET multivalues=%Q WHERE folder_id=%Q",
|
|
|
5e6360 |
+ NULL, NULL, NULL, error,
|
|
|
5e6360 |
+ multivalues, ebsql->priv->folderid);
|
|
|
5e6360 |
+
|
|
|
5e6360 |
+ g_free (multivalues);
|
|
|
5e6360 |
+ }
|
|
|
5e6360 |
+
|
|
|
5e6360 |
EBSQL_NOTE (
|
|
|
5e6360 |
SCHEMA,
|
|
|
5e6360 |
g_printerr (
|
|
|
5e6360 |
@@ -2770,7 +2814,7 @@ ebsql_init_locale (EBookSqlite *ebsql,
|
|
|
5e6360 |
/* Check if we need to relocalize */
|
|
|
5e6360 |
if (success) {
|
|
|
5e6360 |
/* Need to relocalize the whole thing if the schema has been upgraded to version 7 */
|
|
|
5e6360 |
- if (previous_schema >= 1 && previous_schema < 7)
|
|
|
5e6360 |
+ if (previous_schema >= 1 && previous_schema < 9)
|
|
|
5e6360 |
relocalize_needed = TRUE;
|
|
|
5e6360 |
|
|
|
5e6360 |
/* We may need to relocalize for a country code change */
|