[libgda] Correction for bug #740316
- From: Vivien Malerba <vivien src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] Correction for bug #740316
- Date: Wed, 19 Nov 2014 17:40:47 +0000 (UTC)
commit d15fa6ab6773c3d0dae678bd514906c2093a5f2f
Author: Vivien Malerba <malerba gnome-db org>
Date: Wed Nov 19 18:21:20 2014 +0100
Correction for bug #740316
libgda/gda-connection.c | 109 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 109 insertions(+), 0 deletions(-)
---
diff --git a/libgda/gda-connection.c b/libgda/gda-connection.c
index 624f135..4a57a81 100644
--- a/libgda/gda-connection.c
+++ b/libgda/gda-connection.c
@@ -1951,6 +1951,12 @@ gda_connection_insert_row_into_table (GdaConnection *cnc, const gchar *table, GE
g_return_val_if_fail (GDA_IS_CONNECTION (cnc), FALSE);
g_return_val_if_fail (table && *table, FALSE);
+ if (! gda_connection_is_opened (cnc)) {
+ g_set_error (error, GDA_CONNECTION_ERROR, GDA_CONNECTION_CLOSED_ERROR,
+ "%s", _("Connection is closed"));
+ return FALSE;
+ }
+
va_start (args, error);
while ((col_name = va_arg (args, gchar*))) {
clist = g_slist_prepend (clist, col_name);
@@ -2015,6 +2021,12 @@ gda_connection_insert_row_into_table_v (GdaConnection *cnc, const gchar *table,
g_return_val_if_fail (col_names, FALSE);
g_return_val_if_fail (g_slist_length (col_names) == g_slist_length (values), FALSE);
+ if (! gda_connection_is_opened (cnc)) {
+ g_set_error (error, GDA_CONNECTION_ERROR, GDA_CONNECTION_CLOSED_ERROR,
+ "%s", _("Connection is closed"));
+ return FALSE;
+ }
+
/* Construct insert query and list of GdaHolders */
sql_stm = gda_sql_statement_new (GDA_SQL_STATEMENT_INSERT);
ssi = (GdaSqlStatementInsert*) sql_stm->contents;
@@ -2121,6 +2133,12 @@ gda_connection_update_row_in_table (GdaConnection *cnc, const gchar *table,
g_return_val_if_fail (GDA_IS_CONNECTION (cnc), FALSE);
g_return_val_if_fail (table && *table, FALSE);
+ if (! gda_connection_is_opened (cnc)) {
+ g_set_error (error, GDA_CONNECTION_ERROR, GDA_CONNECTION_CLOSED_ERROR,
+ "%s", _("Connection is closed"));
+ return FALSE;
+ }
+
va_start (args, error);
while ((col_name = va_arg (args, gchar*))) {
clist = g_slist_prepend (clist, col_name);
@@ -2189,6 +2207,12 @@ gda_connection_update_row_in_table_v (GdaConnection *cnc, const gchar *table,
g_return_val_if_fail (col_names, FALSE);
g_return_val_if_fail (g_slist_length (col_names) == g_slist_length (values), FALSE);
+ if (! gda_connection_is_opened (cnc)) {
+ g_set_error (error, GDA_CONNECTION_ERROR, GDA_CONNECTION_CLOSED_ERROR,
+ "%s", _("Connection is closed"));
+ return FALSE;
+ }
+
/* Construct update query and list of GdaHolders */
sql_stm = gda_sql_statement_new (GDA_SQL_STATEMENT_UPDATE);
ssu = (GdaSqlStatementUpdate*) sql_stm->contents;
@@ -2327,6 +2351,12 @@ gda_connection_delete_row_from_table (GdaConnection *cnc, const gchar *table,
g_return_val_if_fail (GDA_IS_CONNECTION (cnc), FALSE);
g_return_val_if_fail (table && *table, FALSE);
+ if (! gda_connection_is_opened (cnc)) {
+ g_set_error (error, GDA_CONNECTION_ERROR, GDA_CONNECTION_CLOSED_ERROR,
+ "%s", _("Connection is closed"));
+ return FALSE;
+ }
+
/* Construct delete query and list of GdaHolders */
sql_stm = gda_sql_statement_new (GDA_SQL_STATEMENT_DELETE);
ssd = (GdaSqlStatementDelete*) sql_stm->contents;
@@ -2758,6 +2788,12 @@ gda_connection_batch_execute (GdaConnection *cnc, GdaBatch *batch, GdaSet *param
g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
g_return_val_if_fail (GDA_IS_BATCH (batch), NULL);
+ if (! gda_connection_is_opened (cnc)) {
+ g_set_error (error, GDA_CONNECTION_ERROR, GDA_CONNECTION_CLOSED_ERROR,
+ "%s", _("Connection is closed"));
+ return FALSE;
+ }
+
gda_connection_lock ((GdaLockable*) cnc);
cnc->priv->auto_clear_events = FALSE;
@@ -3304,6 +3340,12 @@ gda_connection_statement_execute_select_fullv (GdaConnection *cnc, GdaStatement
g_return_val_if_fail (cnc->priv->provider_obj, NULL);
g_return_val_if_fail (GDA_IS_STATEMENT (stmt), NULL);
+ if (! gda_connection_is_opened (cnc)) {
+ g_set_error (error, GDA_CONNECTION_ERROR, GDA_CONNECTION_CLOSED_ERROR,
+ "%s", _("Connection is closed"));
+ return NULL;
+ }
+
va_list ap;
GdaDataModel *model = NULL;
GType *types, *req_types;
@@ -3402,6 +3444,12 @@ gda_connection_statement_execute_select_full (GdaConnection *cnc, GdaStatement *
g_return_val_if_fail (cnc->priv->provider_obj, NULL);
g_return_val_if_fail (GDA_IS_STATEMENT (stmt), NULL);
+ if (! gda_connection_is_opened (cnc)) {
+ g_set_error (error, GDA_CONNECTION_ERROR, GDA_CONNECTION_CLOSED_ERROR,
+ "%s", _("Connection is closed"));
+ return NULL;
+ }
+
g_object_ref ((GObject*) cnc);
gda_connection_lock ((GdaLockable*) cnc);
@@ -3482,6 +3530,12 @@ gda_connection_repetitive_statement_execute (GdaConnection *cnc, GdaRepetitiveSt
g_return_val_if_fail (cnc->priv->provider_obj, NULL);
g_return_val_if_fail (GDA_IS_REPETITIVE_STATEMENT (rstmt), NULL);
+ if (! gda_connection_is_opened (cnc)) {
+ g_set_error (error, GDA_CONNECTION_ERROR, GDA_CONNECTION_CLOSED_ERROR,
+ "%s", _("Connection is closed"));
+ return NULL;
+ }
+
g_object_get (rstmt, "statement", &stmt, NULL);
g_return_val_if_fail (stmt, NULL);
@@ -3577,6 +3631,12 @@ gda_connection_begin_transaction (GdaConnection *cnc, const gchar *name, GdaTran
g_return_val_if_fail (GDA_IS_CONNECTION (cnc), FALSE);
g_return_val_if_fail (cnc->priv->provider_obj, FALSE);
+ if (! gda_connection_is_opened (cnc)) {
+ g_set_error (error, GDA_CONNECTION_ERROR, GDA_CONNECTION_CLOSED_ERROR,
+ "%s", _("Connection is closed"));
+ return FALSE;
+ }
+
return _gda_server_provider_begin_transaction (cnc->priv->provider_obj, cnc, name, level, error);
}
@@ -3598,6 +3658,12 @@ gda_connection_commit_transaction (GdaConnection *cnc, const gchar *name, GError
g_return_val_if_fail (GDA_IS_CONNECTION (cnc), FALSE);
g_return_val_if_fail (cnc->priv->provider_obj, FALSE);
+ if (! gda_connection_is_opened (cnc)) {
+ g_set_error (error, GDA_CONNECTION_ERROR, GDA_CONNECTION_CLOSED_ERROR,
+ "%s", _("Connection is closed"));
+ return FALSE;
+ }
+
return _gda_server_provider_commit_transaction (cnc->priv->provider_obj, cnc, name, error);
}
@@ -3620,6 +3686,12 @@ gda_connection_rollback_transaction (GdaConnection *cnc, const gchar *name, GErr
g_return_val_if_fail (GDA_IS_CONNECTION (cnc), FALSE);
g_return_val_if_fail (cnc->priv->provider_obj, FALSE);
+ if (! gda_connection_is_opened (cnc)) {
+ g_set_error (error, GDA_CONNECTION_ERROR, GDA_CONNECTION_CLOSED_ERROR,
+ "%s", _("Connection is closed"));
+ return FALSE;
+ }
+
return _gda_server_provider_rollback_transaction (cnc->priv->provider_obj, cnc, name, error);
}
@@ -3639,6 +3711,12 @@ gda_connection_add_savepoint (GdaConnection *cnc, const gchar *name, GError **er
g_return_val_if_fail (GDA_IS_CONNECTION (cnc), FALSE);
g_return_val_if_fail (cnc->priv->provider_obj, FALSE);
+ if (! gda_connection_is_opened (cnc)) {
+ g_set_error (error, GDA_CONNECTION_ERROR, GDA_CONNECTION_CLOSED_ERROR,
+ "%s", _("Connection is closed"));
+ return FALSE;
+ }
+
return _gda_server_provider_add_savepoint (cnc->priv->provider_obj, cnc, name, error);
}
@@ -3658,6 +3736,12 @@ gda_connection_rollback_savepoint (GdaConnection *cnc, const gchar *name, GError
g_return_val_if_fail (GDA_IS_CONNECTION (cnc), FALSE);
g_return_val_if_fail (cnc->priv->provider_obj, FALSE);
+ if (! gda_connection_is_opened (cnc)) {
+ g_set_error (error, GDA_CONNECTION_ERROR, GDA_CONNECTION_CLOSED_ERROR,
+ "%s", _("Connection is closed"));
+ return FALSE;
+ }
+
return _gda_server_provider_rollback_savepoint (cnc->priv->provider_obj, cnc, name, error);
}
@@ -3677,6 +3761,12 @@ gda_connection_delete_savepoint (GdaConnection *cnc, const gchar *name, GError *
g_return_val_if_fail (GDA_IS_CONNECTION (cnc), FALSE);
g_return_val_if_fail (cnc->priv->provider_obj, FALSE);
+ if (! gda_connection_is_opened (cnc)) {
+ g_set_error (error, GDA_CONNECTION_ERROR, GDA_CONNECTION_CLOSED_ERROR,
+ "%s", _("Connection is closed"));
+ return FALSE;
+ }
+
return _gda_server_provider_delete_savepoint (cnc->priv->provider_obj, cnc, name, error);
}
@@ -4611,6 +4701,11 @@ gda_connection_update_meta_store (GdaConnection *cnc, GdaMetaContext *context, G
g_return_val_if_fail (GDA_IS_CONNECTION (cnc), FALSE);
g_return_val_if_fail (cnc->priv->provider_obj, FALSE);
+ if (! gda_connection_is_opened (cnc)) {
+ g_set_error (error, GDA_CONNECTION_ERROR, GDA_CONNECTION_CLOSED_ERROR,
+ "%s", _("Connection is closed"));
+ return FALSE;
+ }
gda_connection_lock ((GdaLockable*) cnc);
/* Get or create the GdaMetaStore object */
@@ -5006,10 +5101,18 @@ gda_connection_get_meta_store_data (GdaConnection *cnc,
GdaConnectionMetaType meta_type,
GError **error, gint nb_filters, ...)
{
+ g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
+
GList* filters = NULL;
GdaDataModel* model = NULL;
gint i;
+ if (! gda_connection_is_opened (cnc)) {
+ g_set_error (error, GDA_CONNECTION_ERROR, GDA_CONNECTION_CLOSED_ERROR,
+ "%s", _("Connection is closed"));
+ return NULL;
+ }
+
if (nb_filters > 0) {
va_list ap;
va_start (ap, nb_filters);
@@ -5068,6 +5171,12 @@ gda_connection_get_meta_store_data_v (GdaConnection *cnc, GdaConnectionMetaType
g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
g_return_val_if_fail (cnc->priv->provider_obj, NULL);
+ if (! gda_connection_is_opened (cnc)) {
+ g_set_error (error, GDA_CONNECTION_ERROR, GDA_CONNECTION_CLOSED_ERROR,
+ "%s", _("Connection is closed"));
+ return FALSE;
+ }
+
/* Get or create the GdaMetaStore object */
store = gda_connection_get_meta_store (cnc);
g_assert (store);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]