[libgda] SQLite: only return the IMPACTED_ROWS on INSERT, UPDATE or DELETE statements
- From: Vivien Malerba <vivien src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] SQLite: only return the IMPACTED_ROWS on INSERT, UPDATE or DELETE statements
- Date: Sat, 3 Jul 2010 18:03:36 +0000 (UTC)
commit 5b8092d7d032ad4a5be20d2e339a9958f741c950
Author: Vivien Malerba <malerba gnome-db org>
Date: Sat Jul 3 17:06:00 2010 +0200
SQLite: only return the IMPACTED_ROWS on INSERT, UPDATE or DELETE statements
libgda/sqlite/gda-sqlite-provider.c | 44 +++++++++++++++++++++++------------
1 files changed, 29 insertions(+), 15 deletions(-)
---
diff --git a/libgda/sqlite/gda-sqlite-provider.c b/libgda/sqlite/gda-sqlite-provider.c
index 649bed0..669b3ad 100644
--- a/libgda/sqlite/gda-sqlite-provider.c
+++ b/libgda/sqlite/gda-sqlite-provider.c
@@ -2642,32 +2642,26 @@ gda_sqlite_provider_statement_execute (GdaServerProvider *provider, GdaConnectio
return NULL;
}
- GObject *set;
gchar *str = NULL;
- GdaHolder *holder;
- GValue *value;
- GSList *list;
- holder = gda_holder_new (G_TYPE_INT);
- g_object_set ((GObject*) holder, "id", "IMPACTED_ROWS", NULL);
- g_value_set_int ((value = gda_value_new (G_TYPE_INT)), changes);
- gda_holder_take_value (holder, value, NULL);
- list = g_slist_append (NULL, holder);
- set = (GObject*) gda_set_new (list);
- g_slist_free (list);
- g_object_unref (holder);
-
- if (! g_ascii_strncasecmp (_GDA_PSTMT (ps)->sql, "DELETE", 6))
+ gboolean count_changes = FALSE;
+
+ if (! g_ascii_strncasecmp (_GDA_PSTMT (ps)->sql, "DELETE", 6)) {
+ count_changes = TRUE;
str = g_strdup_printf ("DELETE %d (see SQLite documentation for a \"DELETE * FROM table\" query)",
changes);
+ }
else if (! g_ascii_strncasecmp (_GDA_PSTMT (ps)->sql, "INSERT", 6)) {
sqlite3_int64 last_id;
+ count_changes = TRUE;
last_id = SQLITE3_CALL (sqlite3_last_insert_rowid) (handle);
str = g_strdup_printf ("INSERT %lld %d", last_id, changes);
if (last_inserted_row)
*last_inserted_row = make_last_inserted_set (cnc, stmt, last_id);
}
- else if (!g_ascii_strncasecmp (_GDA_PSTMT (ps)->sql, "UPDATE", 6))
+ else if (!g_ascii_strncasecmp (_GDA_PSTMT (ps)->sql, "UPDATE", 6)) {
+ count_changes = TRUE;
str = g_strdup_printf ("UPDATE %d", changes);
+ }
else if (*(_GDA_PSTMT (ps)->sql)) {
gchar *tmp = g_ascii_strup (_GDA_PSTMT (ps)->sql, -1);
for (str = tmp; *str && (*str != ' ') && (*str != '\t') &&
@@ -2681,6 +2675,7 @@ gda_sqlite_provider_statement_execute (GdaServerProvider *provider, GdaConnectio
else
str = tmp;
}
+
if (str) {
event = gda_connection_event_new (GDA_CONNECTION_EVENT_NOTICE);
gda_connection_event_set_description (event, str);
@@ -2691,6 +2686,25 @@ gda_sqlite_provider_statement_execute (GdaServerProvider *provider, GdaConnectio
SQLITE3_CALL (sqlite3_reset) (ps->sqlite_stmt);
if (new_ps)
g_object_unref (ps);
+
+ GObject *set;
+ if (count_changes) {
+ GdaHolder *holder;
+ GValue *value;
+ GSList *list;
+
+ holder = gda_holder_new (G_TYPE_INT);
+ g_object_set ((GObject*) holder, "id", "IMPACTED_ROWS", NULL);
+ g_value_set_int ((value = gda_value_new (G_TYPE_INT)), changes);
+ gda_holder_take_value (holder, value, NULL);
+ list = g_slist_append (NULL, holder);
+ set = (GObject*) gda_set_new (list);
+ g_slist_free (list);
+ g_object_unref (holder);
+ }
+ else
+ set = (GObject*) gda_set_new (NULL);
+
return set;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]