[libgda] connection: removed private from public API



commit 5e681d43f65649c7dbe1419155a674938336aee3
Author: Daniel Espinosa <esodan gmail com>
Date:   Thu Sep 6 12:23:09 2018 -0500

    connection: removed private from public API

 libgda/gda-connection.c | 871 ++++++++++++++++++++++++++----------------------
 libgda/gda-connection.h |   1 -
 libgda/gda-decl.h       |   1 -
 3 files changed, 480 insertions(+), 393 deletions(-)
---
diff --git a/libgda/gda-connection.c b/libgda/gda-connection.c
index c253025d2..2485e49e5 100644
--- a/libgda/gda-connection.c
+++ b/libgda/gda-connection.c
@@ -85,7 +85,7 @@ static GHashTable *all_context_hash = NULL; /* key = a #GThread, value = a #GMai
  * event, considering that the events are reseted after each statement execution */
 #define EVENTS_ARRAY_SIZE 5
 
-struct _GdaConnectionPrivate {
+typedef struct {
        GdaServerProvider    *provider_obj;
        GdaConnectionOptions  options; /* ORed flags */
        gchar                *dsn;
@@ -120,12 +120,14 @@ struct _GdaConnectionPrivate {
 
        gboolean              exec_times;
        guint                 exec_slowdown;
-};
+} GdaConnectionPrivate;
+
+#define gda_connection_get_instance_private(obj) G_TYPE_INSTANCE_GET_PRIVATE(obj, GDA_TYPE_CONNECTION, 
GdaConnectionPrivate)
 
 static void add_exec_time_to_object (GObject *obj, GTimer *timer);
 
 static void gda_connection_class_init (GdaConnectionClass *klass);
-static void gda_connection_init       (GdaConnection *cnc, GdaConnectionClass *klass);
+static void gda_connection_init       (GdaConnection *cnc);
 static void gda_connection_dispose    (GObject *object);
 static void gda_connection_finalize   (GObject *object);
 static void gda_connection_set_property (GObject *object,
@@ -218,6 +220,7 @@ gda_connection_class_init (GdaConnectionClass *klass)
 
        parent_class = g_type_class_peek_parent (klass);
 
+       g_type_class_add_private (object_class, sizeof (GdaConnectionPrivate));
        /**
         * GdaConnection::error:
         * @cnc: the #GdaConnection
@@ -427,40 +430,40 @@ all_context_hash_func (GThread *key, GMainContext *context, GHashTable *copyto)
 }
 
 static void
-gda_connection_init (GdaConnection *cnc, G_GNUC_UNUSED GdaConnectionClass *klass)
+gda_connection_init (GdaConnection *cnc)
 {
        g_return_if_fail (GDA_IS_CONNECTION (cnc));
 
-       cnc->priv = g_new0 (GdaConnectionPrivate, 1);
-       g_rec_mutex_init (&cnc->priv->rmutex);
-       cnc->priv->provider_obj = NULL;
-       cnc->priv->dsn = NULL;
-       cnc->priv->cnc_string = NULL;
-       cnc->priv->auth_string = NULL;
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
+       g_rec_mutex_init (&priv->rmutex);
+       priv->provider_obj = NULL;
+       priv->dsn = NULL;
+       priv->cnc_string = NULL;
+       priv->auth_string = NULL;
        if (all_context_hash) {
                g_mutex_lock (&global_mutex);
-               cnc->priv->context_hash = g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify) 
g_main_context_unref);
-               g_hash_table_foreach (all_context_hash, (GHFunc) all_context_hash_func, 
cnc->priv->context_hash);
+               priv->context_hash = g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify) 
g_main_context_unref);
+               g_hash_table_foreach (all_context_hash, (GHFunc) all_context_hash_func, priv->context_hash);
                g_mutex_unlock (&global_mutex);
        }
        else
-               cnc->priv->context_hash = NULL;
-       cnc->priv->auto_clear_events = TRUE;
-       cnc->priv->events_array_size = EVENTS_ARRAY_SIZE;
-       cnc->priv->events_array = g_new0 (GdaConnectionEvent*, EVENTS_ARRAY_SIZE);
-       cnc->priv->events_array_full = FALSE;
-       cnc->priv->events_array_next = 0;
-       cnc->priv->status = GDA_CONNECTION_STATUS_CLOSED;
-       cnc->priv->busy_count = 0;
-       cnc->priv->trans_status = NULL; /* no transaction yet */
-       cnc->priv->prepared_stmts = NULL;
+               priv->context_hash = NULL;
+       priv->auto_clear_events = TRUE;
+       priv->events_array_size = EVENTS_ARRAY_SIZE;
+       priv->events_array = g_new0 (GdaConnectionEvent*, EVENTS_ARRAY_SIZE);
+       priv->events_array_full = FALSE;
+       priv->events_array_next = 0;
+       priv->status = GDA_CONNECTION_STATUS_CLOSED;
+       priv->busy_count = 0;
+       priv->trans_status = NULL; /* no transaction yet */
+       priv->prepared_stmts = NULL;
 
-       cnc->priv->trans_meta_context = NULL;
-       cnc->priv->provider_data = NULL;
-       cnc->priv->worker_thread = NULL;
+       priv->trans_meta_context = NULL;
+       priv->provider_data = NULL;
+       priv->worker_thread = NULL;
 
-       cnc->priv->exec_times = FALSE;
-       cnc->priv->exec_slowdown = 0;
+       priv->exec_times = FALSE;
+       priv->exec_slowdown = 0;
 }
 
 static void auto_update_meta_context_free (GdaMetaContext *context);
@@ -471,66 +474,67 @@ gda_connection_dispose (GObject *object)
        GdaConnection *cnc = (GdaConnection *) object;
 
        g_return_if_fail (GDA_IS_CONNECTION (cnc));
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
 
        /* free memory */
        gda_connection_close (cnc, NULL);
 
-       if (cnc->priv->context_hash) {
-               g_hash_table_destroy (cnc->priv->context_hash);
-               cnc->priv->context_hash = NULL;
+       if (priv->context_hash) {
+               g_hash_table_destroy (priv->context_hash);
+               priv->context_hash = NULL;
        }
 
        /* get rid of prepared statements to avoid problems */
-       if (cnc->priv->prepared_stmts) {
-               g_hash_table_foreach (cnc->priv->prepared_stmts, 
+       if (priv->prepared_stmts) {
+               g_hash_table_foreach (priv->prepared_stmts,
                                      (GHFunc) prepared_stms_foreach_func, cnc);
-               g_hash_table_destroy (cnc->priv->prepared_stmts);
-               cnc->priv->prepared_stmts = NULL;
+               g_hash_table_destroy (priv->prepared_stmts);
+               priv->prepared_stmts = NULL;
        }
 
-       if (cnc->priv->provider_obj) {
-               _gda_server_provider_handlers_clear_for_cnc (cnc->priv->provider_obj, cnc);
-               g_object_unref (G_OBJECT (cnc->priv->provider_obj));
-               cnc->priv->provider_obj = NULL;
+       if (priv->provider_obj) {
+               _gda_server_provider_handlers_clear_for_cnc (priv->provider_obj, cnc);
+               g_object_unref (G_OBJECT (priv->provider_obj));
+               priv->provider_obj = NULL;
        }
 
-       if (cnc->priv->events_list) {
-               g_list_foreach (cnc->priv->events_list, (GFunc) g_object_unref, NULL);
-               g_list_free (cnc->priv->events_list);
-               cnc->priv->events_list = NULL;
+       if (priv->events_list) {
+               g_list_foreach (priv->events_list, (GFunc) g_object_unref, NULL);
+               g_list_free (priv->events_list);
+               priv->events_list = NULL;
        }
 
-       if (cnc->priv->events_array) {
+       if (priv->events_array) {
                gint i;
-               for (i = 0; i < cnc->priv->events_array_size ; i++) {
+               for (i = 0; i < priv->events_array_size ; i++) {
                        GdaConnectionEvent *ev;
-                       ev = cnc->priv->events_array [i];
+                       ev = priv->events_array [i];
                        if (ev)
                                g_object_unref (ev);
                }
-               g_free (cnc->priv->events_array);
-               cnc->priv->events_array = NULL;
+               g_free (priv->events_array);
+               priv->events_array = NULL;
        }
 
-       if (cnc->priv->trans_status) {
-               g_object_unref (cnc->priv->trans_status);
-               cnc->priv->trans_status = NULL;
+       if (priv->trans_status) {
+               g_object_unref (priv->trans_status);
+               priv->trans_status = NULL;
        }
 
-       if (cnc->priv->meta_store != NULL) {
-               g_object_unref (cnc->priv->meta_store);
-               cnc->priv->meta_store = NULL;
+       if (priv->meta_store != NULL) {
+               g_object_unref (priv->meta_store);
+               priv->meta_store = NULL;
        }
 
-       if (cnc->priv->trans_meta_context) {
+       if (priv->trans_meta_context) {
                gsize i;
-               for (i = 0; i < cnc->priv->trans_meta_context->len; i++) {
+               for (i = 0; i < priv->trans_meta_context->len; i++) {
                        GdaMetaContext *context;
-                       context = g_array_index (cnc->priv->trans_meta_context, GdaMetaContext*, i);
+                       context = g_array_index (priv->trans_meta_context, GdaMetaContext*, i);
                        auto_update_meta_context_free (context);
                }
-               g_array_free (cnc->priv->trans_meta_context, TRUE);
-               cnc->priv->trans_meta_context = NULL;
+               g_array_free (priv->trans_meta_context, TRUE);
+               priv->trans_meta_context = NULL;
        }
 
        /* chain to parent class */
@@ -543,16 +547,14 @@ gda_connection_finalize (GObject *object)
        GdaConnection *cnc = (GdaConnection *) object;
 
        g_return_if_fail (GDA_IS_CONNECTION (cnc));
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
 
        /* free memory */
-       g_free (cnc->priv->dsn);
-       g_free (cnc->priv->cnc_string);
-       g_free (cnc->priv->auth_string);
-
-       g_rec_mutex_clear (&cnc->priv->rmutex);
+       g_free (priv->dsn);
+       g_free (priv->cnc_string);
+       g_free (priv->auth_string);
 
-       g_free (cnc->priv);
-       cnc->priv = NULL;
+       g_rec_mutex_clear (&priv->rmutex);
 
        /* chain to parent class */
        parent_class->finalize (object);
@@ -619,14 +621,15 @@ gda_connection_set_property (GObject *object,
        GdaConnection *cnc;
 
         cnc = GDA_CONNECTION (object);
-        if (cnc->priv) {
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
+        if (priv) {
                 switch (param_id) {
                 case PROP_DSN: {
                        const gchar *datasource = g_value_get_string (value);
                        GdaDsnInfo *dsn;
 
                        gda_connection_lock ((GdaLockable*) cnc);
-                       if (cnc->priv->provider_data) {
+                       if (priv->provider_data) {
                                g_warning (_("Can't set the '%s' property when the connection is opened"),
                                           pspec->name);
                                gda_connection_unlock ((GdaLockable*) cnc);
@@ -640,8 +643,8 @@ gda_connection_set_property (GObject *object,
                                return;
                        }
                        
-                       g_free (cnc->priv->dsn);
-                       cnc->priv->dsn = g_strdup (datasource);
+                       g_free (priv->dsn);
+                       priv->dsn = g_strdup (datasource);
 #ifdef GDA_DEBUG_signal
                        g_print (">> 'DSN_CHANGED' from %s\n", __FUNCTION__);
 #endif
@@ -654,36 +657,36 @@ gda_connection_set_property (GObject *object,
                }
                 case PROP_CNC_STRING:
                        gda_connection_lock ((GdaLockable*) cnc);
-                       if (cnc->priv->provider_data) {
+                       if (priv->provider_data) {
                                g_warning (_("Can't set the '%s' property when the connection is opened"),
                                           pspec->name);
                                gda_connection_unlock ((GdaLockable*) cnc);
                                return;
                        }
-                       g_free (cnc->priv->cnc_string);
-                       cnc->priv->cnc_string = NULL;
+                       g_free (priv->cnc_string);
+                       priv->cnc_string = NULL;
                        if (g_value_get_string (value)) 
-                               cnc->priv->cnc_string = g_strdup (g_value_get_string (value));
+                               priv->cnc_string = g_strdup (g_value_get_string (value));
                        gda_connection_unlock ((GdaLockable*) cnc);
                         break;
                 case PROP_PROVIDER_OBJ:
                        gda_connection_lock ((GdaLockable*) cnc);
-                       if (cnc->priv->provider_data) {
+                       if (priv->provider_data) {
                                g_warning (_("Can't set the '%s' property when the connection is opened"),
                                           pspec->name);
                                gda_connection_unlock ((GdaLockable*) cnc);
                                return;
                        }
-                        if (cnc->priv->provider_obj)
-                               g_object_unref (cnc->priv->provider_obj);
+                        if (priv->provider_obj)
+                               g_object_unref (priv->provider_obj);
 
-                       cnc->priv->provider_obj = g_value_get_object (value);
-                       g_object_ref (G_OBJECT (cnc->priv->provider_obj));
+                       priv->provider_obj = g_value_get_object (value);
+                       g_object_ref (G_OBJECT (priv->provider_obj));
                        gda_connection_unlock ((GdaLockable*) cnc);
                         break;
                 case PROP_AUTH_STRING:
                        gda_connection_lock ((GdaLockable*) cnc);
-                       if (cnc->priv->provider_data) {
+                       if (priv->provider_data) {
                                g_warning (_("Can't set the '%s' property when the connection is opened"),
                                           pspec->name);
                                gda_connection_unlock ((GdaLockable*) cnc);
@@ -691,10 +694,10 @@ gda_connection_set_property (GObject *object,
                        }
                        else {
                                const gchar *str = g_value_get_string (value);
-                               g_free (cnc->priv->auth_string);
-                               cnc->priv->auth_string = NULL;
+                               g_free (priv->auth_string);
+                               priv->auth_string = NULL;
                                if (str)
-                                       cnc->priv->auth_string = g_strdup (str);
+                                       priv->auth_string = g_strdup (str);
                        }
                        gda_connection_unlock ((GdaLockable*) cnc);
                         break;
@@ -702,27 +705,27 @@ gda_connection_set_property (GObject *object,
                        GdaConnectionOptions flags;
                        flags = g_value_get_flags (value);
                        gda_connection_lock ((GdaLockable*) cnc);
-                       if (cnc->priv->provider_data &&
+                       if (priv->provider_data &&
                            ((flags & (~GDA_CONNECTION_OPTIONS_SQL_IDENTIFIERS_CASE_SENSITIVE)) !=
-                            (cnc->priv->options & 
(~GDA_CONNECTION_OPTIONS_SQL_IDENTIFIERS_CASE_SENSITIVE)))) {
+                            (priv->options & (~GDA_CONNECTION_OPTIONS_SQL_IDENTIFIERS_CASE_SENSITIVE)))) {
                                g_warning (_("Can't set the '%s' property once the connection is opened"),
                                           pspec->name);
                                gda_connection_unlock ((GdaLockable*) cnc);
                                return;
                        }
-                       cnc->priv->options = flags;
+                       priv->options = flags;
                        gda_connection_unlock ((GdaLockable*) cnc);
                        break;
                }
                case PROP_META_STORE:
                        gda_connection_lock ((GdaLockable*) cnc);
-                       if (cnc->priv->meta_store) {
-                               g_object_unref (cnc->priv->meta_store);
-                               cnc->priv->meta_store = NULL;
+                       if (priv->meta_store) {
+                               g_object_unref (priv->meta_store);
+                               priv->meta_store = NULL;
                        }
-                       cnc->priv->meta_store = g_value_get_object (value);
-                       if (cnc->priv->meta_store)
-                               g_object_ref (cnc->priv->meta_store);
+                       priv->meta_store = g_value_get_object (value);
+                       if (priv->meta_store)
+                               g_object_ref (priv->meta_store);
                        gda_connection_unlock ((GdaLockable*) cnc);
                        break;
                case PROP_EVENTS_HISTORY_SIZE:
@@ -731,10 +734,10 @@ gda_connection_set_property (GObject *object,
                        gda_connection_unlock ((GdaLockable*) cnc);
                        break;
                case PROP_EXEC_TIMES:
-                       cnc->priv->exec_times = g_value_get_boolean (value);
+                       priv->exec_times = g_value_get_boolean (value);
                        break;
                case PROP_EXEC_SLOWDOWN:
-                       cnc->priv->exec_slowdown = g_value_get_uint (value);
+                       priv->exec_slowdown = g_value_get_uint (value);
                        break;
                 }
         }      
@@ -749,34 +752,35 @@ gda_connection_get_property (GObject *object,
        GdaConnection *cnc;
 
         cnc = GDA_CONNECTION (object);
-        if (cnc->priv) {
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
+        if (priv) {
                 switch (param_id) {
                 case PROP_DSN:
-                       g_value_set_string (value, cnc->priv->dsn);
+                       g_value_set_string (value, priv->dsn);
                         break;
                 case PROP_CNC_STRING:
-                       g_value_set_string (value, cnc->priv->cnc_string);
+                       g_value_set_string (value, priv->cnc_string);
                        break;
                 case PROP_PROVIDER_OBJ:
-                       g_value_set_object (value, (GObject*) cnc->priv->provider_obj);
+                       g_value_set_object (value, (GObject*) priv->provider_obj);
                         break;
                 case PROP_AUTH_STRING:
-                       g_value_set_string (value, cnc->priv->auth_string);
+                       g_value_set_string (value, priv->auth_string);
                         break;
                 case PROP_OPTIONS:
-                       g_value_set_flags (value, cnc->priv->options);
+                       g_value_set_flags (value, priv->options);
                        break;
                case PROP_META_STORE:
-                       g_value_set_object (value, cnc->priv->meta_store);
+                       g_value_set_object (value, priv->meta_store);
                        break;
                case PROP_EVENTS_HISTORY_SIZE:
-                       g_value_set_int (value, cnc->priv->events_array_size);
+                       g_value_set_int (value, priv->events_array_size);
                        break;
                case PROP_EXEC_TIMES:
-                       g_value_set_boolean (value, cnc->priv->exec_times);
+                       g_value_set_boolean (value, priv->exec_times);
                        break;
                case PROP_EXEC_SLOWDOWN:
-                       g_value_set_uint (value, cnc->priv->exec_slowdown);
+                       g_value_set_uint (value, priv->exec_slowdown);
                        break;
                default:
                        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
@@ -824,16 +828,17 @@ gda_connection_set_main_context (GdaConnection *cnc, GThread *thread, GMainConte
 
        if (cnc) {
                g_return_if_fail (GDA_IS_CONNECTION (cnc));
+               GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
                if (context) {
-                       if (! cnc->priv->context_hash)
-                               cnc->priv->context_hash = g_hash_table_new_full (NULL, NULL, NULL,
+                       if (! priv->context_hash)
+                               priv->context_hash = g_hash_table_new_full (NULL, NULL, NULL,
                                                                                 (GDestroyNotify) 
g_main_context_unref);
                        g_main_context_ref (context);
-                       g_hash_table_insert (cnc->priv->context_hash, thread, g_main_context_ref (context));
+                       g_hash_table_insert (priv->context_hash, thread, g_main_context_ref (context));
                        g_main_context_unref (context);
                }
-               else if (cnc->priv->context_hash)
-                       g_hash_table_remove (cnc->priv->context_hash, thread);
+               else if (priv->context_hash)
+                       g_hash_table_remove (priv->context_hash, thread);
        }
        else {
                if (context) {
@@ -877,9 +882,10 @@ gda_connection_get_main_context (GdaConnection *cnc, GThread *thread)
 
        if (cnc) {
                g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
+               GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
                g_mutex_lock (&global_mutex);
-               if (cnc->priv->context_hash)
-                       context = g_hash_table_lookup (cnc->priv->context_hash, thread);
+               if (priv->context_hash)
+                       context = g_hash_table_lookup (priv->context_hash, thread);
                if (!context && all_context_hash)
                        context = g_hash_table_lookup (all_context_hash, thread);
                g_mutex_unlock (&global_mutex);
@@ -1321,6 +1327,8 @@ gda_connection_open_sqlite (const gchar *directory, const gchar *filename, gbool
 static gboolean
 compute_params_and_auth_quarks (GdaConnection *cnc, GdaQuarkList **out_params, GdaQuarkList **out_auth, 
GError **error)
 {
+       g_return_val_if_fail (GDA_IS_CONNECTION (cnc), FALSE);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
        GdaDsnInfo *dsn_info = NULL;
        GdaQuarkList *params, *auth;
 
@@ -1330,7 +1338,7 @@ compute_params_and_auth_quarks (GdaConnection *cnc, GdaQuarkList **out_params, G
        gda_connection_lock ((GdaLockable*) cnc);
 
        /* provider test */
-       if (!cnc->priv->provider_obj) {
+       if (!priv->provider_obj) {
                g_set_error (error, GDA_CONNECTION_ERROR, GDA_CONNECTION_NO_PROVIDER_SPEC_ERROR,
                              "%s", _("No provider specified"));
                gda_connection_unlock ((GdaLockable*) cnc);
@@ -1338,22 +1346,22 @@ compute_params_and_auth_quarks (GdaConnection *cnc, GdaQuarkList **out_params, G
        }
 
        /* connection string */
-       if (cnc->priv->dsn) {
+       if (priv->dsn) {
                /* get the data source info */
-               dsn_info = gda_config_get_dsn_info (cnc->priv->dsn);
+               dsn_info = gda_config_get_dsn_info (priv->dsn);
                if (!dsn_info) {
-                       gda_log_error (_("Data source %s not found in configuration"), cnc->priv->dsn);
+                       gda_log_error (_("Data source %s not found in configuration"), priv->dsn);
                        g_set_error (error, GDA_CONNECTION_ERROR, GDA_CONNECTION_DSN_NOT_FOUND_ERROR,
-                                    _("Data source %s not found in configuration"), cnc->priv->dsn);
+                                    _("Data source %s not found in configuration"), priv->dsn);
                        gda_connection_unlock ((GdaLockable*) cnc);
                        return FALSE;
                }
 
-               g_free (cnc->priv->cnc_string);
-               cnc->priv->cnc_string = g_strdup (dsn_info->cnc_string);
+               g_free (priv->cnc_string);
+               priv->cnc_string = g_strdup (dsn_info->cnc_string);
        }
        else {
-               if (!cnc->priv->cnc_string) {
+               if (!priv->cnc_string) {
                        gda_log_error (_("No DSN or connection string specified"));
                        g_set_error (error, GDA_CONNECTION_ERROR, GDA_CONNECTION_NO_CNC_SPEC_ERROR,
                                      "%s", _("No DSN or connection string specified"));
@@ -1362,18 +1370,18 @@ compute_params_and_auth_quarks (GdaConnection *cnc, GdaQuarkList **out_params, G
                }
                /* try to see if connection string has the <provider>://<rest of the string> format */
        }
-       params = gda_quark_list_new_from_string (cnc->priv->cnc_string);
+       params = gda_quark_list_new_from_string (priv->cnc_string);
 
        /* authentication string */
        char *real_auth_string;
-       if (cnc->priv->auth_string)
-               real_auth_string = g_strdup (cnc->priv->auth_string);
+       if (priv->auth_string)
+               real_auth_string = g_strdup (priv->auth_string);
        else {
                if (dsn_info && dsn_info->auth_string)
                        real_auth_string = g_strdup (dsn_info->auth_string);
                else 
                        /* look for authentication parameters in cnc string */
-                       real_auth_string = g_strdup (cnc->priv->cnc_string);
+                       real_auth_string = g_strdup (priv->cnc_string);
        }
        auth = gda_quark_list_new_from_string (real_auth_string);
        g_free (real_auth_string);
@@ -1403,6 +1411,7 @@ gboolean
 gda_connection_open (GdaConnection *cnc, GError **error)
 {
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), FALSE);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
 
        /* don't do anything if connection is already opened */
        if (gda_connection_is_opened (cnc))
@@ -1414,9 +1423,9 @@ gda_connection_open (GdaConnection *cnc, GError **error)
 
        /* try to open the connection, with the "active waiting" at this point */
        gboolean opened;
-       opened = _gda_server_provider_open_connection_sync (cnc->priv->provider_obj, cnc, params, auth, 
error);
+       opened = _gda_server_provider_open_connection_sync (priv->provider_obj, cnc, params, auth, error);
 
-       if (opened && !cnc->priv->provider_data) {
+       if (opened && !priv->provider_data) {
                g_warning ("Internal error: connection reported as opened, yet no provider data set");
                opened = FALSE;
        }
@@ -1446,6 +1455,7 @@ guint
 gda_connection_open_async (GdaConnection *cnc, GdaConnectionOpenFunc callback, gpointer data, GError **error)
 {
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), 0);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
 
        /* return an error if connection is already opened */
        if (gda_connection_is_opened (cnc)) {
@@ -1461,7 +1471,7 @@ gda_connection_open_async (GdaConnection *cnc, GdaConnectionOpenFunc callback, g
        /* try to open the connection */
        gboolean submitted;
        guint job_id;
-       submitted = _gda_server_provider_open_connection_async (cnc->priv->provider_obj, cnc, params, auth,
+       submitted = _gda_server_provider_open_connection_async (priv->provider_obj, cnc, params, auth,
                                                                callback, data, &job_id, error);
        return submitted ? job_id : 0;
 }
@@ -1492,51 +1502,52 @@ gboolean
 gda_connection_close (GdaConnection *cnc, GError **error)
 {
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), FALSE);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
 
-       if (! cnc->priv->provider_data)
+       if (! priv->provider_data)
                return TRUE;
 
        g_object_ref (cnc);
        gda_connection_lock ((GdaLockable*) cnc);
 
-       if (! cnc->priv->provider_data) {
+       if (! priv->provider_data) {
                /* connection already closed */
                g_object_unref (cnc);
                gda_connection_unlock ((GdaLockable*) cnc);
                return TRUE;
        }
 
-       if (cnc->priv->meta_store &&
-           cnc->priv->trans_meta_context &&
+       if (priv->meta_store &&
+           priv->trans_meta_context &&
            gda_connection_get_transaction_status (cnc)) {
                GdaConnection *mscnc;
-               mscnc = gda_meta_store_get_internal_connection (cnc->priv->meta_store);
+               mscnc = gda_meta_store_get_internal_connection (priv->meta_store);
                if (cnc != mscnc) {
                        gsize i;
-                       for (i = 0; i < cnc->priv->trans_meta_context->len; i++) {
+                       for (i = 0; i < priv->trans_meta_context->len; i++) {
                                GdaMetaContext *context;
                                GError *lerror = NULL;
-                               context = g_array_index (cnc->priv->trans_meta_context, GdaMetaContext*, i);
+                               context = g_array_index (priv->trans_meta_context, GdaMetaContext*, i);
                                if (! gda_connection_update_meta_store (cnc, context, &lerror))
                                        add_connection_event_from_error (cnc, &lerror);
                                auto_update_meta_context_free (context);
                        }
-                       g_array_free (cnc->priv->trans_meta_context, TRUE);
-                       cnc->priv->trans_meta_context = NULL;
+                       g_array_free (priv->trans_meta_context, TRUE);
+                       priv->trans_meta_context = NULL;
                }
        }
 
        /* get rid of prepared statements to avoid problems */
-       if (cnc->priv->prepared_stmts) {
-               g_hash_table_foreach (cnc->priv->prepared_stmts, 
+       if (priv->prepared_stmts) {
+               g_hash_table_foreach (priv->prepared_stmts,
                                      (GHFunc) prepared_stms_foreach_func, cnc);
-               g_hash_table_destroy (cnc->priv->prepared_stmts);
-               cnc->priv->prepared_stmts = NULL;
+               g_hash_table_destroy (priv->prepared_stmts);
+               priv->prepared_stmts = NULL;
        }
 
        /* really close connection */
        gboolean retval;
-       retval = _gda_server_provider_close_connection (cnc->priv->provider_obj, cnc, error);
+       retval = _gda_server_provider_close_connection (priv->provider_obj, cnc, error);
 
        gda_connection_unlock ((GdaLockable*) cnc);
        g_object_unref (cnc);
@@ -1552,10 +1563,11 @@ gda_connection_close (GdaConnection *cnc, GError **error)
 GdaWorker *
 _gda_connection_get_worker (GdaConnection *cnc)
 {
-       if (cnc->priv->provider_data)
-               return cnc->priv->provider_data->worker;
-       else
-               return NULL;
+       g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
+       if (priv->provider_data)
+               return priv->provider_data->worker;
+       return NULL;
 }
 
 /*
@@ -1566,7 +1578,9 @@ _gda_connection_get_worker (GdaConnection *cnc)
 guint
 _gda_connection_get_exec_slowdown (GdaConnection *cnc)
 {
-       return cnc->priv->exec_slowdown;
+       g_return_val_if_fail (GDA_IS_CONNECTION (cnc), 0);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
+       return priv->exec_slowdown;
 }
 
 static void
@@ -1599,12 +1613,12 @@ assert_status_transaction (GdaConnectionStatus old, GdaConnectionStatus new)
 void
 _gda_connection_declare_closed (GdaConnection *cnc)
 {
-       if (!cnc)
-               return;
+       g_return_if_fail (cnc != NULL);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
 
-       g_return_if_fail (cnc->priv->status == GDA_CONNECTION_STATUS_IDLE);
+       g_return_if_fail (priv->status == GDA_CONNECTION_STATUS_IDLE);
 
-       assert_status_transaction (cnc->priv->status, GDA_CONNECTION_STATUS_CLOSED);
+       assert_status_transaction (priv->status, GDA_CONNECTION_STATUS_CLOSED);
        g_signal_emit (G_OBJECT (cnc), gda_connection_signals[STATUS_CHANGED], 0, 
GDA_CONNECTION_STATUS_CLOSED);
 }
 
@@ -1618,16 +1632,18 @@ _gda_connection_declare_closed (GdaConnection *cnc)
 void
 _gda_connection_set_status (GdaConnection *cnc, GdaConnectionStatus status)
 {
-       if (!cnc || (cnc->priv->status == status))
+       g_return_if_fail (cnc != NULL);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
+       if (!cnc || (priv->status == status))
                return;
        if ((status == GDA_CONNECTION_STATUS_CLOSED) ||
            (status == GDA_CONNECTION_STATUS_OPENING))
-               g_return_if_fail (cnc->priv->busy_count == 0);
+               g_return_if_fail (priv->busy_count == 0);
        g_return_if_fail (status != GDA_CONNECTION_STATUS_BUSY);
-       assert_status_transaction (cnc->priv->status, status);
-       cnc->priv->status = status;
+       assert_status_transaction (priv->status, status);
+       priv->status = status;
        g_signal_emit (G_OBJECT (cnc), gda_connection_signals[STATUS_CHANGED], 0, status);
-       /*g_print ("CNC %p status is %d\n", cnc, cnc->priv->status);*/
+       /*g_print ("CNC %p status is %d\n", cnc, priv->status);*/
 }
 
 /**
@@ -1645,19 +1661,19 @@ _gda_connection_set_status (GdaConnection *cnc, GdaConnectionStatus status)
 void
 gda_connection_increase_usage (GdaConnection *cnc)
 {
-       if (!cnc)
-               return;
+       g_return_if_fail (cnc != NULL);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
 
-       g_return_if_fail ((cnc->priv->status == GDA_CONNECTION_STATUS_IDLE) ||
-                         (cnc->priv->status == GDA_CONNECTION_STATUS_BUSY) ||
-                         (cnc->priv->status == GDA_CONNECTION_STATUS_OPENING));
+       g_return_if_fail ((priv->status == GDA_CONNECTION_STATUS_IDLE) ||
+                         (priv->status == GDA_CONNECTION_STATUS_BUSY) ||
+                         (priv->status == GDA_CONNECTION_STATUS_OPENING));
 
-       cnc->priv->busy_count ++;
-       if (cnc->priv->status == GDA_CONNECTION_STATUS_IDLE) {
-               assert_status_transaction (cnc->priv->status, GDA_CONNECTION_STATUS_BUSY);
-               cnc->priv->status = GDA_CONNECTION_STATUS_BUSY;
+       priv->busy_count ++;
+       if (priv->status == GDA_CONNECTION_STATUS_IDLE) {
+               assert_status_transaction (priv->status, GDA_CONNECTION_STATUS_BUSY);
+               priv->status = GDA_CONNECTION_STATUS_BUSY;
                g_signal_emit (G_OBJECT (cnc), gda_connection_signals[STATUS_CHANGED], 0, 
GDA_CONNECTION_STATUS_BUSY);
-               /*g_print ("CNC %p status is %d\n", cnc, cnc->priv->status);*/
+               /*g_print ("CNC %p status is %d\n", cnc, priv->status);*/
        }
 }
 
@@ -1676,19 +1692,19 @@ gda_connection_increase_usage (GdaConnection *cnc)
 void
 gda_connection_decrease_usage (GdaConnection *cnc)
 {
-       if (!cnc)
-               return;
+       g_return_if_fail (cnc != NULL);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
 
-       g_assert (cnc->priv->busy_count > 0);
-       g_return_if_fail ((cnc->priv->status == GDA_CONNECTION_STATUS_BUSY) ||
-                         (cnc->priv->status == GDA_CONNECTION_STATUS_OPENING));
+       g_assert (priv->busy_count > 0);
+       g_return_if_fail ((priv->status == GDA_CONNECTION_STATUS_BUSY) ||
+                         (priv->status == GDA_CONNECTION_STATUS_OPENING));
 
-       cnc->priv->busy_count --;
-       if ((cnc->priv->busy_count == 0) && (cnc->priv->status == GDA_CONNECTION_STATUS_BUSY)) {
-               assert_status_transaction (cnc->priv->status, GDA_CONNECTION_STATUS_IDLE);
-               cnc->priv->status = GDA_CONNECTION_STATUS_IDLE;
+       priv->busy_count --;
+       if ((priv->busy_count == 0) && (priv->status == GDA_CONNECTION_STATUS_BUSY)) {
+               assert_status_transaction (priv->status, GDA_CONNECTION_STATUS_IDLE);
+               priv->status = GDA_CONNECTION_STATUS_IDLE;
                g_signal_emit (G_OBJECT (cnc), gda_connection_signals[STATUS_CHANGED], 0, 
GDA_CONNECTION_STATUS_IDLE);
-               /*g_print ("CNC %p status is %d\n", cnc, cnc->priv->status);*/
+               /*g_print ("CNC %p status is %d\n", cnc, priv->status);*/
        }
 }
 
@@ -1707,9 +1723,10 @@ GdaConnectionStatus
 gda_connection_get_status (GdaConnection *cnc)
 {
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), GDA_CONNECTION_STATUS_CLOSED);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
        GdaConnectionStatus status;
        gda_connection_lock ((GdaLockable*) cnc);
-       status = cnc->priv->status;
+       status = priv->status;
        gda_connection_unlock ((GdaLockable*) cnc);
        return status;
 }
@@ -1725,9 +1742,10 @@ gda_connection_get_status (GdaConnection *cnc)
 gboolean
 gda_connection_is_opened (GdaConnection *cnc)
 {
-        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), FALSE);
+       g_return_val_if_fail (GDA_IS_CONNECTION (cnc), FALSE);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
 
-       return cnc->priv->provider_data ? TRUE : FALSE;
+       return priv->provider_data ? TRUE : FALSE;
 }
 
 
@@ -1743,8 +1761,9 @@ GdaConnectionOptions
 gda_connection_get_options (GdaConnection *cnc)
 {
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), -1);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
 
-       return cnc->priv->options;
+       return priv->options;
 }
 
 /**
@@ -1759,8 +1778,9 @@ GdaServerProvider *
 gda_connection_get_provider (GdaConnection *cnc)
 {
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
 
-       return cnc->priv->provider_obj;
+       return priv->provider_obj;
 }
 
 /**
@@ -1775,10 +1795,11 @@ const gchar *
 gda_connection_get_provider_name (GdaConnection *cnc)
 {
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
-       if (!cnc->priv->provider_obj)
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
+       if (!priv->provider_obj)
                return NULL;
 
-       return gda_server_provider_get_name (cnc->priv->provider_obj);
+       return gda_server_provider_get_name (priv->provider_obj);
 }
 
 /**
@@ -1792,8 +1813,9 @@ const gchar *
 gda_connection_get_dsn (GdaConnection *cnc)
 {
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
 
-       return (const gchar *) cnc->priv->dsn;
+       return (const gchar *) priv->dsn;
 }
 
 /**
@@ -1812,8 +1834,9 @@ const gchar *
 gda_connection_get_cnc_string (GdaConnection *cnc)
 {
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
 
-       return (const gchar *) cnc->priv->cnc_string;
+       return (const gchar *) priv->cnc_string;
 }
 
 /**
@@ -1829,8 +1852,9 @@ gda_connection_get_authentication (GdaConnection *cnc)
 {
        const gchar *str;
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
 
-       str = (const gchar *) cnc->priv->auth_string;
+       str = (const gchar *) priv->auth_string;
        if (!str) 
                str = "";
        return str;
@@ -1857,9 +1881,10 @@ gda_connection_get_date_format (GdaConnection *cnc, GDateDMY *out_first,
                                GError **error)
 {
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), FALSE);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
 
        GdaDataHandler *dh;
-       dh = gda_server_provider_get_data_handler_g_type (cnc->priv->provider_obj, cnc, G_TYPE_DATE);
+       dh = gda_server_provider_get_data_handler_g_type (priv->provider_obj, cnc, G_TYPE_DATE);
        if (!dh) {
                g_set_error (error, GDA_SERVER_PROVIDER_ERROR, 
GDA_SERVER_PROVIDER_METHOD_NON_IMPLEMENTED_ERROR,
                             "%s", _("Provider does not provide a GdaDataHandler for dates"));
@@ -2525,17 +2550,18 @@ GdaConnectionEvent *
 gda_connection_point_available_event (GdaConnection *cnc, GdaConnectionEventType type)
 {
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
 
        /* ownership is transfered to the caller ! */
 
        GdaConnectionEvent *eev;
-       eev = cnc->priv->events_array [cnc->priv->events_array_next];
+       eev = priv->events_array [priv->events_array_next];
        if (!eev)
                eev = GDA_CONNECTION_EVENT (g_object_new (GDA_TYPE_CONNECTION_EVENT,
                                                          "type", (int)type, NULL));
        else {
                gda_connection_event_set_event_type (eev, type);
-               cnc->priv->events_array [cnc->priv->events_array_next] = NULL;
+               priv->events_array [priv->events_array_next] = NULL;
        }
 
        return eev;
@@ -2545,10 +2571,12 @@ gda_connection_point_available_event (GdaConnection *cnc, GdaConnectionEventType
 static void
 dump_events_array (GdaConnection *cnc)
 {
+       g_return_if_fail (GDA_IS_CONNECTION (cnc));
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
        gint i;
        g_print ("=== Array dump for %p ===\n", cnc);
-       for (i = 0; i < cnc->priv->events_array_size; i++) {
-               g_print ("   [%d] => %p\n", i, cnc->priv->events_array [i]);
+       for (i = 0; i < priv->events_array_size; i++) {
+               g_print ("   [%d] => %p\n", i, priv->events_array [i]);
        }
 
        const GList *list;
@@ -2580,31 +2608,32 @@ gda_connection_add_event (GdaConnection *cnc, GdaConnectionEvent *event)
 {
        g_return_if_fail (GDA_IS_CONNECTION (cnc));
        g_return_if_fail (GDA_IS_CONNECTION_EVENT (event));
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
 
        g_object_ref (cnc);
        gda_connection_lock ((GdaLockable*) cnc);
 
        /* clear external list of events */
-       if (cnc->priv->events_list) {
-               g_list_foreach (cnc->priv->events_list, (GFunc) g_object_unref, NULL);
-               g_list_free (cnc->priv->events_list);
-               cnc->priv->events_list = NULL;
+       if (priv->events_list) {
+               g_list_foreach (priv->events_list, (GFunc) g_object_unref, NULL);
+               g_list_free (priv->events_list);
+               priv->events_list = NULL;
        }
 
        /* add event, ownership is transfered to @cnc */
        GdaConnectionEvent *eev;
-       eev = cnc->priv->events_array [cnc->priv->events_array_next];
+       eev = priv->events_array [priv->events_array_next];
        if (eev != event) {
                if (eev)
                        g_object_unref (eev);
-               cnc->priv->events_array [cnc->priv->events_array_next] = event;
+               priv->events_array [priv->events_array_next] = event;
        }
 
        /* handle indexes */
-       cnc->priv->events_array_next ++;
-       if (cnc->priv->events_array_next == cnc->priv->events_array_size) {
-               cnc->priv->events_array_next = 0;
-               cnc->priv->events_array_full = TRUE;
+       priv->events_array_next ++;
+       if (priv->events_array_next == priv->events_array_size) {
+               priv->events_array_next = 0;
+               priv->events_array_full = TRUE;
        }
 
        if (debug_level > 0) {
@@ -2684,9 +2713,11 @@ gda_connection_add_event_string (GdaConnection *cnc, const gchar *str, ...)
 static void
 _clear_connection_events (GdaConnection *locked_cnc)
 {
-       if (locked_cnc->priv->auto_clear_events) {
-               locked_cnc->priv->events_array_full = FALSE;
-               locked_cnc->priv->events_array_next = 0;
+       g_return_if_fail (GDA_IS_CONNECTION (locked_cnc));
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (locked_cnc);
+       if (priv->auto_clear_events) {
+               priv->events_array_full = FALSE;
+               priv->events_array_next = 0;
        }
 }
 
@@ -2725,9 +2756,10 @@ gda_connection_create_operation (GdaConnection *cnc, GdaServerOperationType type
                                  GdaSet *options, GError **error)
 {
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
-       g_return_val_if_fail (cnc->priv->provider_obj, NULL);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
+       g_return_val_if_fail (priv->provider_obj, NULL);
 
-       return gda_server_provider_create_operation (cnc->priv->provider_obj, cnc, type, options, error);
+       return gda_server_provider_create_operation (priv->provider_obj, cnc, type, options, error);
 }
 
 /**
@@ -2747,12 +2779,13 @@ gda_connection_perform_operation (GdaConnection *cnc, GdaServerOperation *op, GE
 {
        gboolean retval;
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), FALSE);
-       g_return_val_if_fail (cnc->priv->provider_obj, FALSE);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
+       g_return_val_if_fail (priv->provider_obj, FALSE);
        g_return_val_if_fail (GDA_IS_SERVER_OPERATION (op), FALSE);
 
-       cnc->priv->auto_clear_events = FALSE;
-       retval = gda_server_provider_perform_operation (cnc->priv->provider_obj, cnc, op, error);
-       cnc->priv->auto_clear_events = TRUE;
+       priv->auto_clear_events = FALSE;
+       retval = gda_server_provider_perform_operation (priv->provider_obj, cnc, op, error);
+       priv->auto_clear_events = TRUE;
        return retval;
 }
 
@@ -2771,9 +2804,10 @@ GdaSqlParser *
 gda_connection_create_parser (GdaConnection *cnc)
 {
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
-       g_return_val_if_fail (cnc->priv->provider_obj, NULL);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
+       g_return_val_if_fail (priv->provider_obj, NULL);
 
-       return gda_server_provider_create_parser (cnc->priv->provider_obj, cnc);
+       return gda_server_provider_create_parser (priv->provider_obj, cnc);
 }
 
 /*
@@ -2782,29 +2816,31 @@ gda_connection_create_parser (GdaConnection *cnc)
 static void
 change_events_array_max_size (GdaConnection *cnc, gint size)
 {
+       g_return_if_fail (GDA_IS_CONNECTION (cnc));
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
        size ++; /* add 1 to compensate the "lost" slot when rotating the events array */
-       if (size == cnc->priv->events_array_size)
+       if (size == priv->events_array_size)
                return;
 
-       if (size > cnc->priv->events_array_size) {
+       if (size > priv->events_array_size) {
                gint i;
-               cnc->priv->events_array = g_renew (GdaConnectionEvent*, cnc->priv->events_array,
+               priv->events_array = g_renew (GdaConnectionEvent*, priv->events_array,
                                                   size);
-               for (i = cnc->priv->events_array_size; i < size; i++)
-                       cnc->priv->events_array [i] = NULL;
+               for (i = priv->events_array_size; i < size; i++)
+                       priv->events_array [i] = NULL;
        }
        else if (size >= EVENTS_ARRAY_SIZE) {
                gint i;
-               for (i = size; i < cnc->priv->events_array_size; i++) {
-                       if (cnc->priv->events_array [i])
-                               g_object_unref (cnc->priv->events_array [i]);
+               for (i = size; i < priv->events_array_size; i++) {
+                       if (priv->events_array [i])
+                               g_object_unref (priv->events_array [i]);
                }
-               cnc->priv->events_array = g_renew (GdaConnectionEvent*, cnc->priv->events_array,
+               priv->events_array = g_renew (GdaConnectionEvent*, priv->events_array,
                                                   size);
        }
-       cnc->priv->events_array_size = size;
-       cnc->priv->events_array_full = FALSE;
-       cnc->priv->events_array_next = 0;
+       priv->events_array_size = size;
+       priv->events_array_full = FALSE;
+       priv->events_array_next = 0;
 }
 
 /**
@@ -2832,6 +2868,7 @@ gda_connection_batch_execute (GdaConnection *cnc, GdaBatch *batch, GdaSet *param
        GSList *retlist = NULL, *stmt_list;
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
        g_return_val_if_fail (GDA_IS_BATCH (batch), NULL);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
 
        if (! gda_connection_is_opened (cnc)) {
                g_set_error (error, GDA_CONNECTION_ERROR, GDA_CONNECTION_CLOSED_ERROR,
@@ -2840,9 +2877,9 @@ gda_connection_batch_execute (GdaConnection *cnc, GdaBatch *batch, GdaSet *param
        }
 
        gda_connection_lock ((GdaLockable*) cnc);
-       cnc->priv->auto_clear_events = FALSE;
+       priv->auto_clear_events = FALSE;
 
-       /* increase the size of cnc->priv->events_array to be able to store all the
+       /* increase the size of priv->events_array to be able to store all the
         * connection events */
        stmt_list = (GSList*) gda_batch_get_statements (batch);
        change_events_array_max_size (cnc, g_slist_length (stmt_list) * 2);
@@ -2855,7 +2892,7 @@ gda_connection_batch_execute (GdaConnection *cnc, GdaBatch *batch, GdaSet *param
                        break;
                retlist = g_slist_prepend (retlist, obj);
        }
-       cnc->priv->auto_clear_events = TRUE;
+       priv->auto_clear_events = TRUE;
        gda_connection_unlock ((GdaLockable*) cnc);
        
        return g_slist_reverse (retlist);
@@ -2892,9 +2929,10 @@ gda_connection_quote_sql_identifier (GdaConnection *cnc, const gchar *id)
 {
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
        g_return_val_if_fail (id, NULL);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
 
        return gda_sql_identifier_quote (id, cnc, NULL, FALSE,
-                                        cnc->priv->options & 
GDA_CONNECTION_OPTIONS_SQL_IDENTIFIERS_CASE_SENSITIVE);
+                                        priv->options & 
GDA_CONNECTION_OPTIONS_SQL_IDENTIFIERS_CASE_SENSITIVE);
 }
 
 /**
@@ -2914,19 +2952,19 @@ gchar *
 gda_connection_statement_to_sql (GdaConnection *cnc, GdaStatement *stmt, GdaSet *params, GdaStatementSqlFlag 
flags,
                                 GSList **params_used, GError **error)
 {
-       if (cnc) {
-               g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
-               g_return_val_if_fail (cnc->priv->provider_obj, NULL);
-       }
        g_return_val_if_fail (GDA_IS_STATEMENT (stmt), NULL);
 
        gchar *sql = NULL;
+
        if (cnc) {
+               g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
+               GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
+               g_return_val_if_fail (priv->provider_obj, NULL);
                if (gda_connection_is_opened (cnc))
-                       sql = _gda_server_provider_statement_to_sql (cnc->priv->provider_obj, cnc, stmt, 
params, flags,
+                       sql = _gda_server_provider_statement_to_sql (priv->provider_obj, cnc, stmt, params, 
flags,
                                                                     params_used, error);
                else
-                       sql = _gda_server_provider_statement_to_sql (cnc->priv->provider_obj, NULL, stmt, 
params, flags,
+                       sql = _gda_server_provider_statement_to_sql (priv->provider_obj, NULL, stmt, params, 
flags,
                                                                     params_used, error);
        }
        return sql ? sql : gda_statement_to_sql_extended (stmt, cnc, params, flags, params_used, error);
@@ -2955,10 +2993,11 @@ gboolean
 gda_connection_statement_prepare (GdaConnection *cnc, GdaStatement *stmt, GError **error)
 {
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), FALSE);
-       g_return_val_if_fail (cnc->priv->provider_obj, FALSE);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
+       g_return_val_if_fail (priv->provider_obj, FALSE);
        g_return_val_if_fail (GDA_IS_STATEMENT (stmt), FALSE);
 
-       return _gda_server_provider_statement_prepare (cnc->priv->provider_obj, cnc, stmt, error);
+       return _gda_server_provider_statement_prepare (priv->provider_obj, cnc, stmt, error);
 }
 
 /*
@@ -3026,6 +3065,8 @@ static GObject *
 gda_connection_statement_execute_v (GdaConnection *cnc, GdaStatement *stmt, GdaSet *params, 
                                    GdaStatementModelUsage model_usage, GdaSet **last_inserted_row, GError 
**error, ...)
 {
+       g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
        va_list ap;
        GObject *obj = NULL;
        GType *types, *req_types;
@@ -3043,7 +3084,7 @@ gda_connection_statement_execute_v (GdaConnection *cnc, GdaStatement *stmt, GdaS
        if (last_inserted_row) 
                *last_inserted_row = NULL;
 
-       if (!cnc->priv->provider_data) {
+       if (!priv->provider_data) {
                g_set_error (error, GDA_CONNECTION_ERROR, GDA_CONNECTION_CLOSED_ERROR,
                             _("Connection is closed"));
                g_object_unref ((GObject*) cnc);
@@ -3065,10 +3106,10 @@ gda_connection_statement_execute_v (GdaConnection *cnc, GdaStatement *stmt, GdaS
                model_usage |= GDA_STATEMENT_MODEL_RANDOM_ACCESS;
 
        dump_exec_params (cnc, stmt, params);
-       if (cnc->priv->exec_times)
+       if (priv->exec_times)
                timer = g_timer_new ();
 
-       obj = _gda_server_provider_statement_execute (cnc->priv->provider_obj, cnc, stmt, params, model_usage,
+       obj = _gda_server_provider_statement_execute (priv->provider_obj, cnc, stmt, params, model_usage,
                                                      req_types ? req_types : types, last_inserted_row, 
error);
        if (timer)
                g_timer_stop (timer);
@@ -3247,7 +3288,8 @@ gda_connection_statement_execute (GdaConnection *cnc, GdaStatement *stmt, GdaSet
                                  GdaStatementModelUsage model_usage, GdaSet **last_inserted_row, GError 
**error)
 {
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
-       g_return_val_if_fail (cnc->priv->provider_obj, NULL);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
+       g_return_val_if_fail (priv->provider_obj, NULL);
        g_return_val_if_fail (GDA_IS_STATEMENT (stmt), NULL);
 
        return gda_connection_statement_execute_v (cnc, stmt, params, model_usage, last_inserted_row, error, 
-1);
@@ -3281,7 +3323,8 @@ gda_connection_statement_execute_non_select (GdaConnection *cnc, GdaStatement *s
 {
        GdaSet *set;
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), -1);
-       g_return_val_if_fail (cnc->priv->provider_obj, -1);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
+       g_return_val_if_fail (priv->provider_obj, -1);
        g_return_val_if_fail (GDA_IS_STATEMENT (stmt), -1);
 
        if ((gda_statement_get_statement_type (stmt) == GDA_SQL_STATEMENT_SELECT) ||
@@ -3350,7 +3393,8 @@ gda_connection_statement_execute_select (GdaConnection *cnc, GdaStatement *stmt,
        GdaDataModel *model;
 
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
-       g_return_val_if_fail (cnc->priv->provider_obj, NULL);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
+       g_return_val_if_fail (priv->provider_obj, NULL);
        g_return_val_if_fail (GDA_IS_STATEMENT (stmt), NULL);
 
        model = (GdaDataModel *) gda_connection_statement_execute_v (cnc, stmt, params, 
@@ -3395,7 +3439,8 @@ gda_connection_statement_execute_select_fullv (GdaConnection *cnc, GdaStatement
                                               GError **error, ...)
 {
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
-       g_return_val_if_fail (cnc->priv->provider_obj, NULL);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
+       g_return_val_if_fail (priv->provider_obj, NULL);
        g_return_val_if_fail (GDA_IS_STATEMENT (stmt), NULL);
 
        if (! gda_connection_is_opened (cnc)) {
@@ -3419,7 +3464,7 @@ gda_connection_statement_execute_select_fullv (GdaConnection *cnc, GdaStatement
        _clear_connection_events (cnc);
        gda_connection_unlock ((GdaLockable*) cnc);
 
-       if (!cnc->priv->provider_data) {
+       if (!priv->provider_data) {
                g_set_error (error, GDA_CONNECTION_ERROR, GDA_CONNECTION_CLOSED_ERROR,
                             _("Connection is closed"));
                g_object_unref ((GObject*) cnc);
@@ -3441,10 +3486,10 @@ gda_connection_statement_execute_select_fullv (GdaConnection *cnc, GdaStatement
                model_usage |= GDA_STATEMENT_MODEL_RANDOM_ACCESS;
 
        dump_exec_params (cnc, stmt, params);
-       if (cnc->priv->exec_times)
+       if (priv->exec_times)
                timer = g_timer_new ();
 
-       model = (GdaDataModel*) _gda_server_provider_statement_execute (cnc->priv->provider_obj, cnc, stmt, 
params, model_usage,
+       model = (GdaDataModel*) _gda_server_provider_statement_execute (priv->provider_obj, cnc, stmt, 
params, model_usage,
                                                                        req_types ? req_types : types, NULL, 
error);
        if (timer)
                g_timer_stop (timer);
@@ -3499,7 +3544,8 @@ gda_connection_statement_execute_select_full (GdaConnection *cnc, GdaStatement *
        GTimer *timer = NULL;
 
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
-       g_return_val_if_fail (cnc->priv->provider_obj, NULL);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
+       g_return_val_if_fail (priv->provider_obj, NULL);
        g_return_val_if_fail (GDA_IS_STATEMENT (stmt), NULL);
 
        if (! gda_connection_is_opened (cnc)) {
@@ -3514,7 +3560,7 @@ gda_connection_statement_execute_select_full (GdaConnection *cnc, GdaStatement *
        _clear_connection_events (cnc);
        gda_connection_unlock ((GdaLockable*) cnc);
        
-       if (!cnc->priv->provider_data) {
+       if (!priv->provider_data) {
                g_set_error (error, GDA_CONNECTION_ERROR, GDA_CONNECTION_CLOSED_ERROR,
                             _("Connection is closed"));
                g_object_unref ((GObject*) cnc);
@@ -3531,10 +3577,10 @@ gda_connection_statement_execute_select_full (GdaConnection *cnc, GdaStatement *
                model_usage |= GDA_STATEMENT_MODEL_RANDOM_ACCESS;
 
        dump_exec_params (cnc, stmt, params);
-       if (cnc->priv->exec_times)
+       if (priv->exec_times)
                timer = g_timer_new ();
 
-       model = (GdaDataModel*) _gda_server_provider_statement_execute (cnc->priv->provider_obj, cnc, stmt, 
params, model_usage,
+       model = (GdaDataModel*) _gda_server_provider_statement_execute (priv->provider_obj, cnc, stmt, 
params, model_usage,
                                                                        req_types ? req_types : col_types, 
NULL, error);
        if (timer)
                g_timer_stop (timer);
@@ -3585,7 +3631,8 @@ gda_connection_repetitive_statement_execute (GdaConnection *cnc, GdaRepetitiveSt
        GdaStatement *stmt;
 
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
-       g_return_val_if_fail (cnc->priv->provider_obj, NULL);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
+       g_return_val_if_fail (priv->provider_obj, NULL);
        g_return_val_if_fail (GDA_IS_REPETITIVE_STATEMENT (rstmt), NULL);
 
        if (! gda_connection_is_opened (cnc)) {
@@ -3603,7 +3650,7 @@ gda_connection_repetitive_statement_execute (GdaConnection *cnc, GdaRepetitiveSt
        _clear_connection_events (cnc);
        gda_connection_unlock ((GdaLockable*) cnc);
 
-       if (!cnc->priv->provider_data) {
+       if (!priv->provider_data) {
                g_set_error (error, GDA_CONNECTION_ERROR, GDA_CONNECTION_CLOSED_ERROR,
                             _("Connection is closed"));
                g_object_unref ((GObject*) cnc);
@@ -3626,10 +3673,10 @@ gda_connection_repetitive_statement_execute (GdaConnection *cnc, GdaRepetitiveSt
                GTimer *timer = NULL;
 
                dump_exec_params (cnc, stmt, (GdaSet*) list->data);
-               if (cnc->priv->exec_times)
+               if (priv->exec_times)
                        timer = g_timer_new ();
 
-               obj = _gda_server_provider_statement_execute (cnc->priv->provider_obj, cnc, stmt, GDA_SET 
(list->data),
+               obj = _gda_server_provider_statement_execute (priv->provider_obj, cnc, stmt, GDA_SET 
(list->data),
                                                              model_usage, req_types ? req_types : col_types,
                                                              NULL, &lerror);
                if (timer)
@@ -3687,7 +3734,8 @@ gda_connection_begin_transaction (GdaConnection *cnc, const gchar *name, GdaTran
                                  GError **error)
 {
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), FALSE);
-       g_return_val_if_fail (cnc->priv->provider_obj, FALSE);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
+       g_return_val_if_fail (priv->provider_obj, FALSE);
 
        if (! gda_connection_is_opened (cnc)) {
                g_set_error (error, GDA_CONNECTION_ERROR, GDA_CONNECTION_CLOSED_ERROR,
@@ -3695,7 +3743,7 @@ gda_connection_begin_transaction (GdaConnection *cnc, const gchar *name, GdaTran
                return FALSE;
        }
 
-       return _gda_server_provider_begin_transaction (cnc->priv->provider_obj, cnc, name, level, error);
+       return _gda_server_provider_begin_transaction (priv->provider_obj, cnc, name, level, error);
 }
 
 /**
@@ -3714,7 +3762,8 @@ gboolean
 gda_connection_commit_transaction (GdaConnection *cnc, const gchar *name, GError **error)
 {
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), FALSE);
-       g_return_val_if_fail (cnc->priv->provider_obj, FALSE);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
+       g_return_val_if_fail (priv->provider_obj, FALSE);
 
        if (! gda_connection_is_opened (cnc)) {
                g_set_error (error, GDA_CONNECTION_ERROR, GDA_CONNECTION_CLOSED_ERROR,
@@ -3722,7 +3771,7 @@ gda_connection_commit_transaction (GdaConnection *cnc, const gchar *name, GError
                return FALSE;
        }
 
-       return _gda_server_provider_commit_transaction (cnc->priv->provider_obj, cnc, name, error);
+       return _gda_server_provider_commit_transaction (priv->provider_obj, cnc, name, error);
 }
 
 /**
@@ -3742,7 +3791,8 @@ gboolean
 gda_connection_rollback_transaction (GdaConnection *cnc, const gchar *name, GError **error)
 {
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), FALSE);
-       g_return_val_if_fail (cnc->priv->provider_obj, FALSE);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
+       g_return_val_if_fail (priv->provider_obj, FALSE);
 
        if (! gda_connection_is_opened (cnc)) {
                g_set_error (error, GDA_CONNECTION_ERROR, GDA_CONNECTION_CLOSED_ERROR,
@@ -3750,7 +3800,7 @@ gda_connection_rollback_transaction (GdaConnection *cnc, const gchar *name, GErr
                return FALSE;
        }
 
-       return _gda_server_provider_rollback_transaction (cnc->priv->provider_obj, cnc, name, error);
+       return _gda_server_provider_rollback_transaction (priv->provider_obj, cnc, name, error);
 }
 
 /**
@@ -3767,7 +3817,8 @@ gboolean
 gda_connection_add_savepoint (GdaConnection *cnc, const gchar *name, GError **error)
 {
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), FALSE);
-       g_return_val_if_fail (cnc->priv->provider_obj, FALSE);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
+       g_return_val_if_fail (priv->provider_obj, FALSE);
 
        if (! gda_connection_is_opened (cnc)) {
                g_set_error (error, GDA_CONNECTION_ERROR, GDA_CONNECTION_CLOSED_ERROR,
@@ -3775,7 +3826,7 @@ gda_connection_add_savepoint (GdaConnection *cnc, const gchar *name, GError **er
                return FALSE;
        }
 
-       return _gda_server_provider_add_savepoint (cnc->priv->provider_obj, cnc, name, error);
+       return _gda_server_provider_add_savepoint (priv->provider_obj, cnc, name, error);
 }
 
 /**
@@ -3792,7 +3843,8 @@ gboolean
 gda_connection_rollback_savepoint (GdaConnection *cnc, const gchar *name, GError **error)
 {
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), FALSE);
-       g_return_val_if_fail (cnc->priv->provider_obj, FALSE);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
+       g_return_val_if_fail (priv->provider_obj, FALSE);
 
        if (! gda_connection_is_opened (cnc)) {
                g_set_error (error, GDA_CONNECTION_ERROR, GDA_CONNECTION_CLOSED_ERROR,
@@ -3800,7 +3852,7 @@ gda_connection_rollback_savepoint (GdaConnection *cnc, const gchar *name, GError
                return FALSE;
        }
 
-       return _gda_server_provider_rollback_savepoint (cnc->priv->provider_obj, cnc, name, error);
+       return _gda_server_provider_rollback_savepoint (priv->provider_obj, cnc, name, error);
 }
 
 /**
@@ -3817,7 +3869,8 @@ gboolean
 gda_connection_delete_savepoint (GdaConnection *cnc, const gchar *name, GError **error)
 {
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), FALSE);
-       g_return_val_if_fail (cnc->priv->provider_obj, FALSE);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
+       g_return_val_if_fail (priv->provider_obj, FALSE);
 
        if (! gda_connection_is_opened (cnc)) {
                g_set_error (error, GDA_CONNECTION_ERROR, GDA_CONNECTION_CLOSED_ERROR,
@@ -3825,7 +3878,7 @@ gda_connection_delete_savepoint (GdaConnection *cnc, const gchar *name, GError *
                return FALSE;
        }
 
-       return _gda_server_provider_delete_savepoint (cnc->priv->provider_obj, cnc, name, error);
+       return _gda_server_provider_delete_savepoint (priv->provider_obj, cnc, name, error);
 }
 
 /**
@@ -3843,8 +3896,9 @@ GdaTransactionStatus *
 gda_connection_get_transaction_status (GdaConnection *cnc)
 {
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
 
-       return cnc->priv->trans_status;
+       return priv->trans_status;
 }
 
 /**
@@ -3860,9 +3914,10 @@ gboolean
 gda_connection_supports_feature (GdaConnection *cnc, GdaConnectionFeature feature)
 {
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), FALSE);
-       g_return_val_if_fail (cnc->priv->provider_obj, FALSE);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
+       g_return_val_if_fail (priv->provider_obj, FALSE);
 
-       return gda_server_provider_supports_feature (cnc->priv->provider_obj, cnc, feature);
+       return gda_server_provider_supports_feature (priv->provider_obj, cnc, feature);
 }
 
 /* builds a list of #GdaMetaContext contexts templates: contexts which have a non NULL table_name,
@@ -4757,7 +4812,8 @@ gda_connection_update_meta_store (GdaConnection *cnc, GdaMetaContext *context, G
        GdaMetaStore *store;
 
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), FALSE);
-       g_return_val_if_fail (cnc->priv->provider_obj, FALSE);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
+       g_return_val_if_fail (priv->provider_obj, FALSE);
 
        if (! gda_connection_is_opened (cnc)) {
                g_set_error (error, GDA_CONNECTION_ERROR, GDA_CONNECTION_CLOSED_ERROR,
@@ -4770,12 +4826,12 @@ gda_connection_update_meta_store (GdaConnection *cnc, GdaMetaContext *context, G
        store = gda_connection_get_meta_store (cnc);
        g_assert (store);
 
-       guint real_slowdown = cnc->priv->exec_slowdown;
+       guint real_slowdown = priv->exec_slowdown;
        if (real_slowdown > 0) {
                /* we don't honor the exec slowdown during meta data updates, it would complicate
                 * the code quite a lot (slowdown is done in the worker thread) and it's only
                 * for debug purposes */
-               cnc->priv->exec_slowdown = 0;
+               priv->exec_slowdown = 0;
        }
 
        gda_connection_increase_usage (cnc); /* USAGE ++ */
@@ -4791,7 +4847,7 @@ gda_connection_update_meta_store (GdaConnection *cnc, GdaMetaContext *context, G
                if (!lcontext) {
                        gda_connection_decrease_usage (cnc); /* USAGE -- */
                        gda_connection_unlock ((GdaLockable*) cnc);
-                       cnc->priv->exec_slowdown = real_slowdown;
+                       priv->exec_slowdown = real_slowdown;
                        return FALSE;
                }
                /* alter local context because "_tables" and "_views" always go together so only
@@ -4807,7 +4863,7 @@ gda_connection_update_meta_store (GdaConnection *cnc, GdaMetaContext *context, G
                                gda_connection_decrease_usage (cnc); /* USAGE -- */
                                gda_connection_unlock ((GdaLockable*) cnc);
                                g_propagate_error (error, lerror);
-                               cnc->priv->exec_slowdown = real_slowdown;
+                               priv->exec_slowdown = real_slowdown;
                                return FALSE;
                        }
                }
@@ -4817,7 +4873,7 @@ gda_connection_update_meta_store (GdaConnection *cnc, GdaMetaContext *context, G
                                gda_connection_decrease_usage (cnc); /* USAGE -- */
                                gda_connection_unlock ((GdaLockable*) cnc);
                                g_propagate_error (error, lerror);
-                               cnc->priv->exec_slowdown = real_slowdown;
+                               priv->exec_slowdown = real_slowdown;
                                return FALSE;
                        }
                }
@@ -4840,7 +4896,7 @@ gda_connection_update_meta_store (GdaConnection *cnc, GdaMetaContext *context, G
                DownstreamCallbackData cbd;
                gboolean retval = TRUE;
                
-               cbd.prov = cnc->priv->provider_obj;
+               cbd.prov = priv->provider_obj;
                cbd.cnc = cnc;
                cbd.error = NULL;
                cbd.context_templates = g_slist_concat (g_slist_append (up_templates, lcontext), 
dn_templates);
@@ -4851,7 +4907,7 @@ gda_connection_update_meta_store (GdaConnection *cnc, GdaMetaContext *context, G
 
                signal_id = g_signal_connect (store, "suggest-update",
                                              G_CALLBACK (suggest_update_cb_downstream), &cbd);
-               retval = local_meta_update (cnc->priv->provider_obj, cnc, 
+               retval = local_meta_update (priv->provider_obj, cnc,
                                            (GdaMetaContext*) (cbd.context_templates->data), error);
                g_signal_handler_disconnect (store, signal_id);
 
@@ -4877,7 +4933,7 @@ gda_connection_update_meta_store (GdaConnection *cnc, GdaMetaContext *context, G
 
                gda_connection_decrease_usage (cnc); /* USAGE -- */
                gda_connection_unlock ((GdaLockable*) cnc);
-               cnc->priv->exec_slowdown = real_slowdown;
+               priv->exec_slowdown = real_slowdown;
                return retval;
        }
        else {
@@ -4915,13 +4971,13 @@ gda_connection_update_meta_store (GdaConnection *cnc, GdaMetaContext *context, G
                        {"_table_indexes", "_indexes_tab", GDA_SERVER_META__INDEXES_TAB},
                        {"_index_column_usage", "_index_cols", GDA_SERVER_META__INDEX_COLS}
                };
-               GdaServerProvider *provider = cnc->priv->provider_obj;
+               GdaServerProvider *provider = priv->provider_obj;
                gboolean retval;
 
                if (! _gda_meta_store_begin_data_reset (store, error)) {
                        gda_connection_decrease_usage (cnc); /* USAGE -- */
                        gda_connection_unlock ((GdaLockable*) cnc);
-                       cnc->priv->exec_slowdown = real_slowdown;
+                       priv->exec_slowdown = real_slowdown;
                        return FALSE;
                }
 
@@ -4949,14 +5005,14 @@ gda_connection_update_meta_store (GdaConnection *cnc, GdaMetaContext *context, G
                retval = _gda_meta_store_finish_data_reset (store, error);
                gda_connection_decrease_usage (cnc); /* USAGE -- */
                gda_connection_unlock ((GdaLockable*) cnc);
-               cnc->priv->exec_slowdown = real_slowdown;
+               priv->exec_slowdown = real_slowdown;
                return retval;
 
        onerror:
                gda_connection_decrease_usage (cnc); /* USAGE -- */
                gda_connection_unlock ((GdaLockable*) cnc);
                _gda_meta_store_cancel_data_reset (store, NULL);
-               cnc->priv->exec_slowdown = real_slowdown;
+               priv->exec_slowdown = real_slowdown;
                return FALSE;
        }
 }
@@ -5240,7 +5296,8 @@ gda_connection_get_meta_store_data_v (GdaConnection *cnc, GdaConnectionMetaType
        GList* node;
 
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
-       g_return_val_if_fail (cnc->priv->provider_obj, NULL);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
+       g_return_val_if_fail (priv->provider_obj, NULL);
 
        if (! gda_connection_is_opened (cnc)) {
                g_set_error (error, GDA_CONNECTION_ERROR, GDA_CONNECTION_CLOSED_ERROR,
@@ -5308,45 +5365,46 @@ const GList *
 gda_connection_get_events (GdaConnection *cnc)
 {
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
 
-       if (cnc->priv->events_list)
-               return cnc->priv->events_list;
+       if (priv->events_list)
+               return priv->events_list;
        
 
        /* a new list of the GdaConnectionEvent objects is created, the
         * ownership of each GdaConnectionEvent object is transfered to the list */
        GList *list = NULL;
-       if (cnc->priv->events_array_full) {
+       if (priv->events_array_full) {
                gint i;
-               for (i = cnc->priv->events_array_next + 1; ; i++) {
-                       if (i == cnc->priv->events_array_size)
+               for (i = priv->events_array_next + 1; ; i++) {
+                       if (i == priv->events_array_size)
                                i = 0;
-                       if (i == cnc->priv->events_array_next)
+                       if (i == priv->events_array_next)
                                break;
                        GdaConnectionEvent *ev;
-                       ev = cnc->priv->events_array [i];
-                       cnc->priv->events_array [i] = NULL;
+                       ev = priv->events_array [i];
+                       priv->events_array [i] = NULL;
                        g_assert (ev);
                        list = g_list_prepend (list, ev);
                }
        }
        else {
                gint i;
-               for (i = 0; i < cnc->priv->events_array_next; i++) {
+               for (i = 0; i < priv->events_array_next; i++) {
                        GdaConnectionEvent *ev;
-                       ev = cnc->priv->events_array [i];
+                       ev = priv->events_array [i];
                        g_assert (ev);
                        list = g_list_prepend (list, ev);
-                       cnc->priv->events_array [i] = NULL;
+                       priv->events_array [i] = NULL;
                }
        }
-       cnc->priv->events_list = g_list_reverse (list);
+       priv->events_list = g_list_reverse (list);
 
        /* reset events */
-       cnc->priv->events_array_full = FALSE;
-       cnc->priv->events_array_next = 0;
+       priv->events_array_full = FALSE;
+       priv->events_array_next = 0;
 
-       return cnc->priv->events_list;
+       return priv->events_list;
 }
 
 /**
@@ -5363,10 +5421,11 @@ gda_connection_value_to_sql_string (GdaConnection *cnc, GValue *from)
 {
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), FALSE);
        g_return_val_if_fail (from != NULL, FALSE);
-       g_return_val_if_fail (cnc->priv->provider_obj, FALSE);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
+       g_return_val_if_fail (priv->provider_obj, FALSE);
 
        /* execute the command on the provider */
-       return gda_server_provider_value_to_sql_string (cnc->priv->provider_obj, cnc, from);
+       return gda_server_provider_value_to_sql_string (priv->provider_obj, cnc, from);
 }
 
 /**
@@ -5390,15 +5449,16 @@ gda_connection_internal_transaction_started (GdaConnection *cnc, const gchar *pa
        GdaTransactionStatus *parent, *st;
 
        g_return_if_fail (GDA_IS_CONNECTION (cnc));
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
 
        st = gda_transaction_status_new (trans_name);
        st->isolation_level = isol_level;
 
        gda_connection_lock ((GdaLockable*) cnc);
 
-       parent = gda_transaction_status_find (cnc->priv->trans_status, parent_trans, NULL);
+       parent = gda_transaction_status_find (priv->trans_status, parent_trans, NULL);
        if (!parent)
-               cnc->priv->trans_status = st;
+               priv->trans_status = st;
        else {
                gda_transaction_status_add_event_sub (parent, st);
                g_object_unref (st);
@@ -5412,8 +5472,8 @@ gda_connection_internal_transaction_started (GdaConnection *cnc, const gchar *pa
 #endif
 
 #ifdef GDA_DEBUG_NO
-       if (cnc->priv->trans_status)
-               gda_transaction_status_dump (cnc->priv->trans_status, 5);
+       if (priv->trans_status)
+               gda_transaction_status_dump (priv->trans_status, 5);
 #endif
 
        gda_connection_unlock ((GdaLockable*) cnc);
@@ -5438,11 +5498,12 @@ gda_connection_internal_transaction_rolledback (GdaConnection *cnc, const gchar
        GdaTransactionStatusEvent *ev = NULL;
 
        g_return_if_fail (GDA_IS_CONNECTION (cnc));
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
 
        gda_connection_lock ((GdaLockable*) cnc);
 
-       if (cnc->priv->trans_status)
-               st = gda_transaction_status_find (cnc->priv->trans_status, trans_name, &ev);
+       if (priv->trans_status)
+               st = gda_transaction_status_find (priv->trans_status, trans_name, &ev);
        if (st) {
                if (ev) {
                        /* there is a parent transaction */
@@ -5450,8 +5511,8 @@ gda_connection_internal_transaction_rolledback (GdaConnection *cnc, const gchar
                }
                else {
                        /* no parent transaction */
-                       g_object_unref (cnc->priv->trans_status);
-                       cnc->priv->trans_status = NULL;
+                       g_object_unref (priv->trans_status);
+                       priv->trans_status = NULL;
                }
 #ifdef GDA_DEBUG_signal
                g_print (">> 'TRANSACTION_STATUS_CHANGED' from %s\n", __FUNCTION__);
@@ -5465,8 +5526,8 @@ gda_connection_internal_transaction_rolledback (GdaConnection *cnc, const gchar
                g_warning (_("Connection transaction status tracking: no transaction exists for %s"), 
"ROLLBACK");
        }
 #ifdef GDA_DEBUG_NO
-       if (cnc->priv->trans_status)
-               gda_transaction_status_dump (cnc->priv->trans_status, 5);
+       if (priv->trans_status)
+               gda_transaction_status_dump (priv->trans_status, 5);
 #endif
 
        gda_connection_unlock ((GdaLockable*) cnc);
@@ -5491,11 +5552,12 @@ gda_connection_internal_transaction_committed (GdaConnection *cnc, const gchar *
        GdaTransactionStatusEvent *ev = NULL;
 
        g_return_if_fail (GDA_IS_CONNECTION (cnc));
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
 
        gda_connection_lock ((GdaLockable*) cnc);
 
-       if (cnc->priv->trans_status)
-               st = gda_transaction_status_find (cnc->priv->trans_status, trans_name, &ev);
+       if (priv->trans_status)
+               st = gda_transaction_status_find (priv->trans_status, trans_name, &ev);
        if (st) {
                if (ev) {
                        /* there is a parent transaction */
@@ -5503,8 +5565,8 @@ gda_connection_internal_transaction_committed (GdaConnection *cnc, const gchar *
                }
                else {
                        /* no parent transaction */
-                       g_object_unref (cnc->priv->trans_status);
-                       cnc->priv->trans_status = NULL;
+                       g_object_unref (priv->trans_status);
+                       priv->trans_status = NULL;
                }
 #ifdef GDA_DEBUG_signal
                g_print (">> 'TRANSACTION_STATUS_CHANGED' from %s\n", __FUNCTION__);
@@ -5518,8 +5580,8 @@ gda_connection_internal_transaction_committed (GdaConnection *cnc, const gchar *
                g_warning (_("Connection transaction status tracking: no transaction exists for %s"), 
"COMMIT");
        }
 #ifdef GDA_DEBUG_NO
-       if (cnc->priv->trans_status)
-               gda_transaction_status_dump (cnc->priv->trans_status, 5);
+       if (priv->trans_status)
+               gda_transaction_status_dump (priv->trans_status, 5);
 #endif
 
        gda_connection_unlock ((GdaLockable*) cnc);
@@ -5544,10 +5606,11 @@ gda_connection_internal_savepoint_added (GdaConnection *cnc, const gchar *parent
        GdaTransactionStatus *st;
 
        g_return_if_fail (GDA_IS_CONNECTION (cnc));
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
 
        gda_connection_lock ((GdaLockable*) cnc);
 
-       st = gda_transaction_status_find (cnc->priv->trans_status, parent_trans, NULL);
+       st = gda_transaction_status_find (priv->trans_status, parent_trans, NULL);
        if (st) {
                gda_transaction_status_add_event_svp (st, svp_name);
 #ifdef GDA_DEBUG_signal
@@ -5562,8 +5625,8 @@ gda_connection_internal_savepoint_added (GdaConnection *cnc, const gchar *parent
                g_warning (_("Connection transaction status tracking: no transaction exists for %s"), "ADD 
SAVEPOINT");
        }
 #ifdef GDA_DEBUG_NO
-       if (cnc->priv->trans_status)
-               gda_transaction_status_dump (cnc->priv->trans_status, 5);
+       if (priv->trans_status)
+               gda_transaction_status_dump (priv->trans_status, 5);
 #endif
 
        gda_connection_unlock ((GdaLockable*) cnc);
@@ -5588,10 +5651,11 @@ gda_connection_internal_savepoint_rolledback (GdaConnection *cnc, const gchar *s
        GdaTransactionStatusEvent *ev = NULL;
 
        g_return_if_fail (GDA_IS_CONNECTION (cnc));
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
 
        gda_connection_lock ((GdaLockable*) cnc);
 
-       st = gda_transaction_status_find (cnc->priv->trans_status, svp_name, &ev);
+       st = gda_transaction_status_find (priv->trans_status, svp_name, &ev);
        if (st) {
                gda_transaction_status_free_events (st, ev, TRUE);
 #ifdef GDA_DEBUG_signal
@@ -5606,8 +5670,8 @@ gda_connection_internal_savepoint_rolledback (GdaConnection *cnc, const gchar *s
                g_warning (_("Connection transaction status tracking: no transaction exists for %s"), 
"ROLLBACK SAVEPOINT");
        }
 #ifdef GDA_DEBUG_NO
-       if (cnc->priv->trans_status)
-               gda_transaction_status_dump (cnc->priv->trans_status, 5);
+       if (priv->trans_status)
+               gda_transaction_status_dump (priv->trans_status, 5);
 #endif 
 
        gda_connection_unlock ((GdaLockable*) cnc);
@@ -5632,10 +5696,11 @@ gda_connection_internal_savepoint_removed (GdaConnection *cnc, const gchar *svp_
        GdaTransactionStatusEvent *ev = NULL;
 
        g_return_if_fail (GDA_IS_CONNECTION (cnc));
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
 
        gda_connection_lock ((GdaLockable*) cnc);
 
-       st = gda_transaction_status_find (cnc->priv->trans_status, svp_name, &ev);
+       st = gda_transaction_status_find (priv->trans_status, svp_name, &ev);
        if (st) {
                gda_transaction_status_free_events (st, ev, FALSE);
 #ifdef GDA_DEBUG_signal
@@ -5650,8 +5715,8 @@ gda_connection_internal_savepoint_removed (GdaConnection *cnc, const gchar *svp_
                g_warning (_("Connection transaction status tracking: no transaction exists for %s"), "REMOVE 
SAVEPOINT");
        }
 #ifdef GDA_DEBUG_NO
-       if (cnc->priv->trans_status)
-               gda_transaction_status_dump (cnc->priv->trans_status, 5);
+       if (priv->trans_status)
+               gda_transaction_status_dump (priv->trans_status, 5);
 #endif
 
        gda_connection_unlock ((GdaLockable*) cnc);
@@ -5671,6 +5736,8 @@ void
 gda_connection_internal_statement_executed (GdaConnection *cnc, GdaStatement *stmt,
                                            G_GNUC_UNUSED GdaSet *params, GdaConnectionEvent *error)
 {
+       g_return_if_fail (GDA_IS_CONNECTION (cnc));
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
        if (!error || (error && (gda_connection_event_get_event_type (error) != GDA_CONNECTION_EVENT_ERROR))) 
{
                const GdaSqlStatement *sqlst;
                GdaSqlStatementTransaction *trans;
@@ -5703,8 +5770,8 @@ gda_connection_internal_statement_executed (GdaConnection *cnc, GdaStatement *st
                        
                        gda_connection_lock ((GdaLockable*) cnc);
 
-                       if (cnc->priv->trans_status)
-                               st = gda_transaction_status_find_current (cnc->priv->trans_status, NULL, 
FALSE);
+                       if (priv->trans_status)
+                               st = gda_transaction_status_find_current (priv->trans_status, NULL, FALSE);
                        if (st) {
                                if (sqlst->sql)
                                        gda_transaction_status_add_event_sql (st, sqlst->sql, error);
@@ -5725,8 +5792,8 @@ gda_connection_internal_statement_executed (GdaConnection *cnc, GdaStatement *st
                        g_print ("<< 'TRANSACTION_STATUS_CHANGED' from %s\n", __FUNCTION__);
 #endif
 #ifdef GDA_DEBUG_NO
-                       if (cnc->priv->trans_status)
-                               gda_transaction_status_dump (cnc->priv->trans_status, 5);
+                       if (priv->trans_status)
+                               gda_transaction_status_dump (priv->trans_status, 5);
 #endif
                        gda_connection_unlock ((GdaLockable*) cnc);
                        break;
@@ -5748,15 +5815,16 @@ gda_connection_internal_change_transaction_state (GdaConnection *cnc,
                                                  GdaTransactionStatusState newstate)
 {
        g_return_if_fail (GDA_IS_CONNECTION (cnc));
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
 
        gda_connection_lock ((GdaLockable*) cnc);
 
-       g_return_if_fail (cnc->priv->trans_status);
+       g_return_if_fail (priv->trans_status);
 
-       if (cnc->priv->trans_status->state == newstate)
+       if (priv->trans_status->state == newstate)
                return;
 
-       cnc->priv->trans_status->state = newstate;
+       priv->trans_status->state = newstate;
 #ifdef GDA_DEBUG_signal
        g_print (">> 'TRANSACTION_STATUS_CHANGED' from %s\n", __FUNCTION__);
 #endif
@@ -5777,11 +5845,12 @@ void
 gda_connection_internal_reset_transaction_status (GdaConnection *cnc)
 {
        g_return_if_fail (GDA_IS_CONNECTION (cnc));
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
 
        gda_connection_lock ((GdaLockable*) cnc);
-       if (cnc->priv->trans_status) {
-               g_object_unref (cnc->priv->trans_status);
-               cnc->priv->trans_status = NULL;
+       if (priv->trans_status) {
+               g_object_unref (priv->trans_status);
+               priv->trans_status = NULL;
 #ifdef GDA_DEBUG_signal
                g_print (">> 'TRANSACTION_STATUS_CHANGED' from %s\n", __FUNCTION__);
 #endif
@@ -5803,12 +5872,14 @@ static void statement_weak_notify_cb (GdaConnection *cnc, GdaStatement *stmt);
 static void 
 prepared_stmts_stmt_reset_cb (GdaStatement *gda_stmt, GdaConnection *cnc)
 {
+       g_return_if_fail (GDA_IS_CONNECTION (cnc));
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
        gda_connection_lock ((GdaLockable*) cnc);
 
        g_signal_handlers_disconnect_by_func (gda_stmt, G_CALLBACK (prepared_stmts_stmt_reset_cb), cnc);
        g_object_weak_unref (G_OBJECT (gda_stmt), (GWeakNotify) statement_weak_notify_cb, cnc);
-       g_assert (cnc->priv->prepared_stmts);
-       g_hash_table_remove (cnc->priv->prepared_stmts, gda_stmt);
+       g_assert (priv->prepared_stmts);
+       g_hash_table_remove (priv->prepared_stmts, gda_stmt);
 
        gda_connection_unlock ((GdaLockable*) cnc);
 }
@@ -5823,10 +5894,12 @@ prepared_stms_foreach_func (GdaStatement *gda_stmt, G_GNUC_UNUSED GdaPStmt *prep
 static void
 statement_weak_notify_cb (GdaConnection *cnc, GdaStatement *stmt)
 {
+       g_return_if_fail (GDA_IS_CONNECTION (cnc));
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
        gda_connection_lock ((GdaLockable*) cnc);
 
-       g_assert (cnc->priv->prepared_stmts);
-       g_hash_table_remove (cnc->priv->prepared_stmts, stmt);
+       g_assert (priv->prepared_stmts);
+       g_hash_table_remove (priv->prepared_stmts, stmt);
 
        gda_connection_unlock ((GdaLockable*) cnc);
 }
@@ -5850,14 +5923,15 @@ gda_connection_add_prepared_statement (GdaConnection *cnc, GdaStatement *gda_stm
        g_return_if_fail (GDA_IS_CONNECTION (cnc));
        g_return_if_fail (GDA_IS_STATEMENT (gda_stmt));
        g_return_if_fail (GDA_IS_PSTMT (prepared_stmt));
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
 
        gda_connection_lock ((GdaLockable*) cnc);
 
-       if (!cnc->priv->prepared_stmts)
-               cnc->priv->prepared_stmts = g_hash_table_new_full (g_direct_hash, g_direct_equal,
+       if (!priv->prepared_stmts)
+               priv->prepared_stmts = g_hash_table_new_full (g_direct_hash, g_direct_equal,
                                                                   NULL, g_object_unref);
-       g_hash_table_remove (cnc->priv->prepared_stmts, gda_stmt);
-       g_hash_table_insert (cnc->priv->prepared_stmts, gda_stmt, g_object_ref (prepared_stmt));
+       g_hash_table_remove (priv->prepared_stmts, gda_stmt);
+       g_hash_table_insert (priv->prepared_stmts, gda_stmt, g_object_ref (prepared_stmt));
        
        /* destroy the prepared statement if gda_stmt is destroyed, or changes */
        g_object_weak_ref (G_OBJECT (gda_stmt), (GWeakNotify) statement_weak_notify_cb, cnc);
@@ -5883,10 +5957,11 @@ gda_connection_get_prepared_statement (GdaConnection *cnc, GdaStatement *gda_stm
        GdaPStmt *retval = NULL;
 
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
 
        gda_connection_lock ((GdaLockable*) cnc);
-       if (cnc->priv->prepared_stmts) 
-               retval = g_hash_table_lookup (cnc->priv->prepared_stmts, gda_stmt);
+       if (priv->prepared_stmts)
+               retval = g_hash_table_lookup (priv->prepared_stmts, gda_stmt);
        gda_connection_unlock ((GdaLockable*) cnc);
 
        return retval;
@@ -5933,7 +6008,8 @@ gda_connection_internal_set_provider_data (GdaConnection *cnc, GdaServerProvider
 
        g_return_if_fail (GDA_IS_CONNECTION (cnc));
        g_return_if_fail ((data && destroy_func) || (!data && !destroy_func));
-       if (cnc->priv->provider_data && data) {
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
+       if (priv->provider_data && data) {
                g_warning ("Changing the provider's data is not allowed during the lifetime of a connection");
                return;
        }
@@ -5941,7 +6017,7 @@ gda_connection_internal_set_provider_data (GdaConnection *cnc, GdaServerProvider
        if (!data)
                gda_connection_lock ((GdaLockable*) cnc);
 
-       cnc->priv->provider_data = data;
+       priv->provider_data = data;
        if (data)
                data->provider_data_destroy_func = destroy_func;
 
@@ -5952,11 +6028,13 @@ gda_connection_internal_set_provider_data (GdaConnection *cnc, GdaServerProvider
 void
 _gda_connection_internal_set_worker_thread (GdaConnection *cnc, GThread *thread)
 {
+       g_return_if_fail (GDA_IS_CONNECTION (cnc));
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
        g_mutex_lock (&global_mutex);
-       if (cnc->priv->worker_thread && thread)
+       if (priv->worker_thread && thread)
                g_warning ("Trying to overwriting connection's associated internal thread");
        else
-               cnc->priv->worker_thread = thread;
+               priv->worker_thread = thread;
        g_mutex_unlock (&global_mutex);
 }
 
@@ -5995,8 +6073,9 @@ gda_connection_internal_get_provider_data_error (GdaConnection *cnc, GError **er
 {
        gpointer retval;
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
 
-       retval = cnc->priv->provider_data;
+       retval = priv->provider_data;
        if (!retval)
                g_set_error (error, GDA_CONNECTION_ERROR, GDA_CONNECTION_CLOSED_ERROR,
                              _("Connection is closed"));
@@ -6015,11 +6094,12 @@ GdaMetaStore *
 gda_connection_get_meta_store (GdaConnection *cnc)
 {
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
        gda_connection_lock ((GdaLockable*) cnc);
-       if (!cnc->priv->meta_store) {
-               cnc->priv->meta_store = gda_meta_store_new (NULL);
+       if (!priv->meta_store) {
+               priv->meta_store = gda_meta_store_new (NULL);
                GdaConnection *scnc;
-               scnc = gda_meta_store_get_internal_connection (cnc->priv->meta_store);
+               scnc = gda_meta_store_get_internal_connection (priv->meta_store);
                if ((scnc != cnc) &&
                    gda_connection_get_main_context (cnc, NULL) &&
                    ! gda_connection_get_main_context (scnc, NULL))
@@ -6027,7 +6107,7 @@ gda_connection_get_meta_store (GdaConnection *cnc)
        }
        gda_connection_unlock ((GdaLockable*) cnc);
 
-       return cnc->priv->meta_store;
+       return priv->meta_store;
 }
 
 /* Note about the GdaConnection's locking mechanism:
@@ -6069,8 +6149,9 @@ static void
 gda_connection_lock (GdaLockable *lockable)
 {
        GdaConnection *cnc = (GdaConnection *) lockable;
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
 
-       if (cnc->priv->worker_thread == g_thread_self ()) {
+       if (priv->worker_thread == g_thread_self ()) {
                /* the sitation here is that the connection _has been_ locked by the
                 * calling thread of the GdaWorker, and as we are in the worker thread
                 * of the GdaWorker, we don't need to lock it again: it would be useless because
@@ -6121,7 +6202,7 @@ gda_connection_lock (GdaLockable *lockable)
                itsignaler_unref (its);
        }
        else
-               g_rec_mutex_lock (& cnc->priv->rmutex);
+               g_rec_mutex_lock (& priv->rmutex);
 }
 
 /*
@@ -6134,13 +6215,14 @@ static gboolean
 gda_connection_trylock (GdaLockable *lockable)
 {
        GdaConnection *cnc = (GdaConnection *) lockable;
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
 
-       if (cnc->priv->worker_thread == g_thread_self ()) {
+       if (priv->worker_thread == g_thread_self ()) {
                /* See gda_connection_lock() for explanations */
                return TRUE;
        }
 
-       return g_rec_mutex_trylock (& cnc->priv->rmutex);
+       return g_rec_mutex_trylock (& priv->rmutex);
 }
 
 /*
@@ -6151,14 +6233,15 @@ static void
 gda_connection_unlock  (GdaLockable *lockable)
 {
        GdaConnection *cnc = (GdaConnection *) lockable;
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
 
-       if (cnc->priv->worker_thread == g_thread_self ()) {
+       if (priv->worker_thread == g_thread_self ()) {
                /* See gda_connection_lock() for explanations */
                return;
        }
 
        /* help other threads locking the connection */
-       g_rec_mutex_unlock (& cnc->priv->rmutex);
+       g_rec_mutex_unlock (& priv->rmutex);
        g_mutex_lock (&global_mutex);
        if (lock_its_list) {
                ITSignaler *its;
@@ -6245,6 +6328,8 @@ get_next_word (gchar *str, gboolean for_ident, gchar **out_next)
 static GSList *
 meta_data_context_from_statement (GdaConnection *cnc, GdaStatement *stmt, GdaSet *params)
 {
+       g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
        gboolean ignore_create_drop = FALSE;
        if (GDA_IS_VCONNECTION_DATA_MODEL (cnc))
                /* meta data is updated when the virtual connection emits the
@@ -6304,9 +6389,9 @@ meta_data_context_from_statement (GdaConnection *cnc, GdaStatement *stmt, GdaSet
                        context->column_names = g_new0 (gchar *, 1);
                        context->column_names[0] = "table_name";
                        context->column_values = g_new0 (GValue *, 1);
-                       tmp = gda_sql_identifier_quote (tname, cnc, cnc->priv->provider_obj,
+                       tmp = gda_sql_identifier_quote (tname, cnc, priv->provider_obj,
                                                        TRUE,
-                                                       cnc->priv->options & 
GDA_CONNECTION_OPTIONS_SQL_IDENTIFIERS_CASE_SENSITIVE);
+                                                       priv->options & 
GDA_CONNECTION_OPTIONS_SQL_IDENTIFIERS_CASE_SENSITIVE);
                        g_value_take_string ((context->column_values[0] = gda_value_new (G_TYPE_STRING)),
                                             tmp);
                        clist = g_slist_prepend (clist, context);
@@ -6328,9 +6413,9 @@ meta_data_context_from_statement (GdaConnection *cnc, GdaStatement *stmt, GdaSet
                                context->column_names = g_new0 (gchar *, 1);
                                context->column_names[0] = "table_name";
                                context->column_values = g_new0 (GValue *, 1);
-                               tmp = gda_sql_identifier_quote (tname, cnc, cnc->priv->provider_obj,
+                               tmp = gda_sql_identifier_quote (tname, cnc, priv->provider_obj,
                                                                TRUE,
-                                                               cnc->priv->options & 
GDA_CONNECTION_OPTIONS_SQL_IDENTIFIERS_CASE_SENSITIVE);
+                                                               priv->options & 
GDA_CONNECTION_OPTIONS_SQL_IDENTIFIERS_CASE_SENSITIVE);
                                g_value_take_string ((context->column_values[0] = gda_value_new 
(G_TYPE_STRING)),
                                                     tmp);
                                clist = g_slist_prepend (clist, context);
@@ -6352,56 +6437,58 @@ meta_data_context_from_statement (GdaConnection *cnc, GdaStatement *stmt, GdaSet
 static void
 update_meta_store_after_statement_exec (GdaConnection *cnc, GdaStatement *stmt, GdaSet *params)
 {
-       if (! cnc->priv->meta_store ||
-           ! (cnc->priv->options & GDA_CONNECTION_OPTIONS_AUTO_META_DATA))
+       g_return_if_fail (GDA_IS_CONNECTION (cnc));
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
+       if (! priv->meta_store ||
+           ! (priv->options & GDA_CONNECTION_OPTIONS_AUTO_META_DATA))
                return;
 
        GdaSqlStatementType type;
        type = gda_statement_get_statement_type (stmt);
        if (type == GDA_SQL_STATEMENT_BEGIN) {
-               /* initialize cnc->priv->trans_meta_context if meta store's connection is not @cnc */
+               /* initialize priv->trans_meta_context if meta store's connection is not @cnc */
                GdaConnection *mscnc;
-               mscnc = gda_meta_store_get_internal_connection (cnc->priv->meta_store);
+               mscnc = gda_meta_store_get_internal_connection (priv->meta_store);
                if (cnc != mscnc) {
-                       g_assert (! cnc->priv->trans_meta_context);
-                       cnc->priv->trans_meta_context = g_array_new (FALSE, FALSE, sizeof (GdaMetaContext*));
+                       g_assert (! priv->trans_meta_context);
+                       priv->trans_meta_context = g_array_new (FALSE, FALSE, sizeof (GdaMetaContext*));
                }
                return;
        }
        else if (type == GDA_SQL_STATEMENT_ROLLBACK) {
                /* re-run all the meta store updates started since the BEGIN */
                GdaConnection *mscnc;
-               mscnc = gda_meta_store_get_internal_connection (cnc->priv->meta_store);
+               mscnc = gda_meta_store_get_internal_connection (priv->meta_store);
                if (cnc != mscnc) {
                        gsize i;
-                       g_assert (cnc->priv->trans_meta_context);
-                       for (i = 0; i < cnc->priv->trans_meta_context->len; i++) {
+                       g_assert (priv->trans_meta_context);
+                       for (i = 0; i < priv->trans_meta_context->len; i++) {
                                GdaMetaContext *context;
                                GError *lerror = NULL;
-                               context = g_array_index (cnc->priv->trans_meta_context, GdaMetaContext*, i);
+                               context = g_array_index (priv->trans_meta_context, GdaMetaContext*, i);
                                if (! gda_connection_update_meta_store (cnc, context, &lerror))
                                        add_connection_event_from_error (cnc, &lerror);
                                auto_update_meta_context_free (context);
                        }
-                       g_array_free (cnc->priv->trans_meta_context, TRUE);
-                       cnc->priv->trans_meta_context = NULL;
+                       g_array_free (priv->trans_meta_context, TRUE);
+                       priv->trans_meta_context = NULL;
                }
                return;
        }
        else if (type == GDA_SQL_STATEMENT_COMMIT) {
                /* get rid of the meta store updates */
                GdaConnection *mscnc;
-               mscnc = gda_meta_store_get_internal_connection (cnc->priv->meta_store);
+               mscnc = gda_meta_store_get_internal_connection (priv->meta_store);
                if (cnc != mscnc) {
                        gsize i;
-                       g_assert (cnc->priv->trans_meta_context);
-                       for (i = 0; i < cnc->priv->trans_meta_context->len; i++) {
+                       g_assert (priv->trans_meta_context);
+                       for (i = 0; i < priv->trans_meta_context->len; i++) {
                                GdaMetaContext *context;
-                               context = g_array_index (cnc->priv->trans_meta_context, GdaMetaContext*, i);
+                               context = g_array_index (priv->trans_meta_context, GdaMetaContext*, i);
                                auto_update_meta_context_free (context);
                        }
-                       g_array_free (cnc->priv->trans_meta_context, TRUE);
-                       cnc->priv->trans_meta_context = NULL;
+                       g_array_free (priv->trans_meta_context, TRUE);
+                       priv->trans_meta_context = NULL;
                }
                return;
        }
@@ -6418,8 +6505,8 @@ update_meta_store_after_statement_exec (GdaConnection *cnc, GdaStatement *stmt,
                        if (! gda_connection_update_meta_store (cnc, context, &lerror))
                                add_connection_event_from_error (cnc, &lerror);
                        
-                       if (cnc->priv->trans_meta_context)
-                               g_array_prepend_val (cnc->priv->trans_meta_context, context);
+                       if (priv->trans_meta_context)
+                               g_array_prepend_val (priv->trans_meta_context, context);
                        else
                                auto_update_meta_context_free (context);
                }
@@ -6430,8 +6517,10 @@ update_meta_store_after_statement_exec (GdaConnection *cnc, GdaStatement *stmt,
 void
 _gda_connection_signal_meta_table_update (GdaConnection *cnc, const gchar *table_name)
 {
-       if (! cnc->priv->meta_store ||
-           ! (cnc->priv->options & GDA_CONNECTION_OPTIONS_AUTO_META_DATA))
+       g_return_if_fail (GDA_IS_CONNECTION (cnc));
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
+       if (! priv->meta_store ||
+           ! (priv->options & GDA_CONNECTION_OPTIONS_AUTO_META_DATA))
                return;
 
        GdaMetaContext *context;
@@ -6455,14 +6544,14 @@ _gda_connection_signal_meta_table_update (GdaConnection *cnc, const gchar *table
                context->column_names[0] = "table_schema";
                context->column_names[1] = "table_name";
                context->column_values = g_new0 (GValue *, context->size);
-               tmp = gda_sql_identifier_quote (split[0], cnc, cnc->priv->provider_obj,
+               tmp = gda_sql_identifier_quote (split[0], cnc, priv->provider_obj,
                                                TRUE,
-                                               cnc->priv->options & 
GDA_CONNECTION_OPTIONS_SQL_IDENTIFIERS_CASE_SENSITIVE);
+                                               priv->options & 
GDA_CONNECTION_OPTIONS_SQL_IDENTIFIERS_CASE_SENSITIVE);
                g_value_take_string ((context->column_values[0] = gda_value_new (G_TYPE_STRING)),
                                     tmp);
-               tmp = gda_sql_identifier_quote (split[1], cnc, cnc->priv->provider_obj,
+               tmp = gda_sql_identifier_quote (split[1], cnc, priv->provider_obj,
                                                TRUE,
-                                               cnc->priv->options & 
GDA_CONNECTION_OPTIONS_SQL_IDENTIFIERS_CASE_SENSITIVE);
+                                               priv->options & 
GDA_CONNECTION_OPTIONS_SQL_IDENTIFIERS_CASE_SENSITIVE);
                g_value_take_string ((context->column_values[1] = gda_value_new (G_TYPE_STRING)),
                                     tmp);
        }
@@ -6471,9 +6560,9 @@ _gda_connection_signal_meta_table_update (GdaConnection *cnc, const gchar *table
                context->column_names = g_new0 (gchar *, context->size);
                context->column_names[0] = "table_name";
                context->column_values = g_new0 (GValue *, context->size);
-               tmp = gda_sql_identifier_quote (split[0], cnc, cnc->priv->provider_obj,
+               tmp = gda_sql_identifier_quote (split[0], cnc, priv->provider_obj,
                                                TRUE,
-                                               cnc->priv->options & 
GDA_CONNECTION_OPTIONS_SQL_IDENTIFIERS_CASE_SENSITIVE);
+                                               priv->options & 
GDA_CONNECTION_OPTIONS_SQL_IDENTIFIERS_CASE_SENSITIVE);
                g_value_take_string ((context->column_values[0] = gda_value_new (G_TYPE_STRING)),
                                     tmp);
        }
@@ -6482,8 +6571,8 @@ _gda_connection_signal_meta_table_update (GdaConnection *cnc, const gchar *table
        if (! gda_connection_update_meta_store (cnc, context, &lerror))
                add_connection_event_from_error (cnc, &lerror);
        
-       if (cnc->priv->trans_meta_context)
-               g_array_prepend_val (cnc->priv->trans_meta_context, context);
+       if (priv->trans_meta_context)
+               g_array_prepend_val (priv->trans_meta_context, context);
        else
                auto_update_meta_context_free (context);
 
diff --git a/libgda/gda-connection.h b/libgda/gda-connection.h
index 642d80ea4..a1282449d 100644
--- a/libgda/gda-connection.h
+++ b/libgda/gda-connection.h
@@ -99,7 +99,6 @@ typedef enum {
 
 struct _GdaConnection {
        GObject               object;
-       GdaConnectionPrivate *priv;
 };
 
 /**
diff --git a/libgda/gda-decl.h b/libgda/gda-decl.h
index 3c4c780ec..a3fef63ed 100644
--- a/libgda/gda-decl.h
+++ b/libgda/gda-decl.h
@@ -29,7 +29,6 @@ typedef struct _GdaConfigClass GdaConfigClass;
 
 typedef struct _GdaConnection        GdaConnection;
 typedef struct _GdaConnectionClass   GdaConnectionClass;
-typedef struct _GdaConnectionPrivate GdaConnectionPrivate;
 
 typedef struct _GdaConnectionEvent        GdaConnectionEvent;
 typedef struct _GdaConnectionEventClass   GdaConnectionEventClass;



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