[libgda] Gda-SQL: avoid letting a transaction opened when not necessary
- From: Vivien Malerba <vivien src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] Gda-SQL: avoid letting a transaction opened when not necessary
- Date: Sat, 25 Sep 2010 18:41:06 +0000 (UTC)
commit e040ebbba6e6854127df8586d2e9ec0b6c59ddf0
Author: Vivien Malerba <malerba gnome-db org>
Date: Sat Sep 25 20:40:57 2010 +0200
Gda-SQL: avoid letting a transaction opened when not necessary
tools/command-exec.c | 7 +++++++
tools/command-exec.h | 2 ++
tools/gda-sql.c | 6 ++++--
3 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/tools/command-exec.c b/tools/command-exec.c
index 5b0cfa4..ee9ee46 100644
--- a/tools/command-exec.c
+++ b/tools/command-exec.c
@@ -117,6 +117,11 @@ gda_internal_command_exec_result_free (GdaInternalCommandResult *res)
case GDA_INTERNAL_COMMAND_RESULT_DATA_MODEL:
if (res->u.model)
g_object_unref (res->u.model);
+ if (! res->was_in_transaction_before_exec &&
+ res->cnc &&
+ gda_connection_get_transaction_status (res->cnc))
+ gda_connection_rollback_transaction (res->cnc, NULL, NULL);
+
break;
case GDA_INTERNAL_COMMAND_RESULT_SET:
if (res->u.set)
@@ -138,6 +143,8 @@ gda_internal_command_exec_result_free (GdaInternalCommandResult *res)
default:
break;
}
+ if (res->cnc)
+ g_object_unref (res->cnc);
g_free (res);
}
diff --git a/tools/command-exec.h b/tools/command-exec.h
index ed7bafe..47cabba 100644
--- a/tools/command-exec.h
+++ b/tools/command-exec.h
@@ -42,6 +42,8 @@ typedef enum {
typedef struct {
GdaInternalCommandResultType type;
+ GdaConnection *cnc;
+ gboolean was_in_transaction_before_exec;
union {
GdaDataModel *model;
GdaSet *set;
diff --git a/tools/gda-sql.c b/tools/gda-sql.c
index 9155293..0817ab0 100644
--- a/tools/gda-sql.c
+++ b/tools/gda-sql.c
@@ -1,5 +1,5 @@
/* GDA - SQL console
- * Copyright (C) 2007 - 2009 The GNOME Foundation.
+ * Copyright (C) 2007 - 2010 The GNOME Foundation.
*
* AUTHORS:
* Vivien Malerba <malerba gnome-db org>
@@ -1037,7 +1037,9 @@ execute_external_command (SqlConsole *console, const gchar *command, GError **er
}
}
- res = g_new0 (GdaInternalCommandResult, 1);
+ res = g_new0 (GdaInternalCommandResult, 1);
+ res->was_in_transaction_before_exec = gda_connection_get_transaction_status (cs->cnc) ? TRUE : FALSE;
+ res->cnc = g_object_ref (cs->cnc);
obj = gda_connection_statement_execute (cs->cnc, stmt, params,
GDA_STATEMENT_MODEL_RANDOM_ACCESS, NULL, error);
if (!obj) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]