[tracker/db-cursor-bytes: 1/2] libtracker-db: Add a "length" parameter to tracker_db_cursor_string



commit 8f3e0239c3f9fdab2d7d960cbe5b2397b4be82cf
Author: Adrien Bustany <abustany gnome org>
Date:   Mon Jun 14 12:16:43 2010 -0400

    libtracker-db: Add a "length" parameter to tracker_db_cursor_string

 src/libtracker-db/tracker-db-interface-sqlite.c |   11 +++++++++--
 src/libtracker-db/tracker-db-interface.h        |    3 ++-
 src/libtracker-db/tracker-db-manager.c          |    2 +-
 3 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/src/libtracker-db/tracker-db-interface-sqlite.c b/src/libtracker-db/tracker-db-interface-sqlite.c
index 9051548..009bec1 100644
--- a/src/libtracker-db/tracker-db-interface-sqlite.c
+++ b/src/libtracker-db/tracker-db-interface-sqlite.c
@@ -1209,9 +1209,16 @@ tracker_db_cursor_get_double (TrackerDBCursor *cursor,  guint column)
 
 
 const gchar*
-tracker_db_cursor_get_string (TrackerDBCursor *cursor,  guint column)
+tracker_db_cursor_get_string (TrackerDBCursor *cursor,  guint column, gint *length)
 {
-	return (const gchar *) sqlite3_column_text (cursor->stmt, column);
+	if (length) {
+		sqlite3_value *val = sqlite3_column_value (cursor->stmt, column);
+
+		*length = sqlite3_value_bytes (val);
+		return (const gchar *) sqlite3_value_text (val);
+	} else {
+		return (const gchar *) sqlite3_column_text (cursor->stmt, column);
+	}
 }
 
 
diff --git a/src/libtracker-db/tracker-db-interface.h b/src/libtracker-db/tracker-db-interface.h
index 5bb0117..0d2f255 100644
--- a/src/libtracker-db/tracker-db-interface.h
+++ b/src/libtracker-db/tracker-db-interface.h
@@ -145,7 +145,8 @@ void                tracker_db_cursor_get_value            (TrackerDBCursor
                                                             guint                column,
                                                             GValue              *value);
 const gchar*        tracker_db_cursor_get_string           (TrackerDBCursor     *cursor,
-                                                            guint                column);
+                                                            guint                column,
+                                                            gint                *length);
 gint                tracker_db_cursor_get_int              (TrackerDBCursor     *cursor,
                                                             guint                column);
 gdouble             tracker_db_cursor_get_double           (TrackerDBCursor     *cursor,
diff --git a/src/libtracker-db/tracker-db-manager.c b/src/libtracker-db/tracker-db-manager.c
index e777ed7..2d42da1 100644
--- a/src/libtracker-db/tracker-db-manager.c
+++ b/src/libtracker-db/tracker-db-manager.c
@@ -886,7 +886,7 @@ tracker_db_manager_init (TrackerDBManagerFlags  flags,
 
 				if (cursor) {
 					if (tracker_db_cursor_iter_next (cursor, NULL)) {
-						if (g_strcmp0 (tracker_db_cursor_get_string (cursor, 0), "ok") != 0) {
+						if (g_strcmp0 (tracker_db_cursor_get_string (cursor, 0, NULL), "ok") != 0) {
 							must_recreate = TRUE;
 						}
 					}



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