[libgda] SQLite provider: more robust blob handling



commit 886b99819b6598132e337e4571ca055afbe24097
Author: Vivien Malerba <malerba gnome-db org>
Date:   Mon Sep 14 21:41:15 2009 +0200

    SQLite provider: more robust blob handling

 libgda/sqlite/gda-sqlite-provider.c  |    7 ++++++-
 libgda/sqlite/gda-sqlite-recordset.c |   21 +++++++++++++++++++++
 2 files changed, 27 insertions(+), 1 deletions(-)
---
diff --git a/libgda/sqlite/gda-sqlite-provider.c b/libgda/sqlite/gda-sqlite-provider.c
index c15a577..3d105c4 100644
--- a/libgda/sqlite/gda-sqlite-provider.c
+++ b/libgda/sqlite/gda-sqlite-provider.c
@@ -1720,7 +1720,12 @@ add_oid_columns (GdaStatement *stmt, GHashTable **out_hash, gint *out_nb_cols_ad
 		/* add to hash table */
 		add_index++;
 		g_hash_table_insert (hash, gda_sql_identifier_remove_quotes (g_strdup (name)),
-				     GINT_TO_POINTER (add_index)); /* ADDED 1 to column number, don't forget to remove 1 when using */
+				     GINT_TO_POINTER (add_index)); /* ADDED 1 to column number,
+								    * don't forget to remove 1 when using */
+		if (target->as)
+			g_hash_table_insert (hash, gda_sql_identifier_remove_quotes (g_strdup (target->table_name)),
+					     GINT_TO_POINTER (add_index)); /* ADDED 1 to column number,
+									    * don't forget to remove 1 when using */
 		nb_cols_added ++;
 	}
 
diff --git a/libgda/sqlite/gda-sqlite-recordset.c b/libgda/sqlite/gda-sqlite-recordset.c
index 958e87f..fc89df8 100644
--- a/libgda/sqlite/gda-sqlite-recordset.c
+++ b/libgda/sqlite/gda-sqlite-recordset.c
@@ -331,6 +331,27 @@ fetch_next_sqlite_row (GdaSqliteRecordset *model, gboolean do_store, GError **er
 
 			if (type == GDA_TYPE_NULL) {
 				type = fuzzy_get_gtype (cdata, ps, col);
+				if (type == GDA_TYPE_BLOB) {
+					/* extra check: make sure we have a rowid for this blob, or fallback to binary */
+					if (ps->rowid_hash) {
+						gint oidcol = 0;
+						const char *ctable;
+						ctable = sqlite3_column_name (ps->sqlite_stmt, real_col);
+						if (ctable)
+							oidcol = GPOINTER_TO_INT (g_hash_table_lookup (ps->rowid_hash,
+												       ctable));
+						if (oidcol == 0) {
+							ctable = sqlite3_column_table_name (ps->sqlite_stmt, real_col);
+							if (ctable)
+								oidcol = GPOINTER_TO_INT (g_hash_table_lookup (ps->rowid_hash, 
+													       ctable));
+						}
+						if (oidcol == 0)
+							type = GDA_TYPE_BINARY;
+					}
+					else
+						type = GDA_TYPE_BINARY;
+				}
 				if (type != GDA_TYPE_NULL) {
 					GdaColumn *column;
 					



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]