[libgda/cnn: 1/7] Save Work



commit b9e4f97d7f98204825820b22d27340290b92c067
Author: Daniel Espinosa <esodan gmail com>
Date:   Mon Sep 3 10:52:37 2018 -0500

    Save Work

 NEWS                                               |    7 +
 libgda/gda-connection.c                            | 1641 ++++++++++++++------
 libgda/gda-connection.h                            |  148 +-
 libgda/gda-data-model.c                            |    2 +-
 libgda/gda-data-select.c                           |   18 -
 libgda/gda-data-select.h                           |    1 -
 libgda/gda-decl.h                                  |    4 -
 libgda/gda-meta-store.c                            |   22 +-
 libgda/gda-meta-store.h                            |    7 +-
 libgda/gda-server-operation.c                      |  413 +----
 libgda/gda-server-operation.h                      |    9 -
 libgda/gda-statement.c                             |   79 +-
 libgda/gda-statement.h                             |   11 +-
 libgda/gda-util.c                                  |    4 +-
 libgda/handlers/gda-handler-string.c               |   33 -
 libgda/handlers/gda-handler-string.h               |    1 -
 libgda/sql-parser/gda-statement-struct-decl.h      |   18 -
 libgda/sql-parser/gda-statement-struct.c           |   57 +-
 libgda/sql-parser/gda-statement-struct.h           |    4 +-
 providers/postgres/gda-postgres-ddl.c              |    2 +-
 providers/postgres/gda-postgres-provider.c         |    2 +-
 providers/skel-implementation/capi/gda-capi-ddl.c  |    2 +-
 .../skel-implementation/capi/gda-capi-provider.c   |    2 +-
 23 files changed, 1337 insertions(+), 1150 deletions(-)
---
diff --git a/NEWS b/NEWS
index 74fde9a13..d44866c5c 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,11 @@
 libgda 5.91.0
+ - Removing private structs from public API
+ - Removed gda_meta_store_sql_identifier_quote(), use gda_connection_quote_sql_identifier() instead
+ - Removed gda_meta_store_get_internal_connection() from public API
+ - Added API for GdaConnection for GdaMetaContext requiring it
+ - Removed API for GdaMetaContext using GdaConnection objects
+ - Added gda_connection_statement_to_sql() replacing gda_statement_to_sql_extended()
+ - Changed API for gda_statement_to_sql() and removed gda_statement_to_sql_extended()
  - GdaSet ported to use g_autoptr() and remove public private struct
  - Fixed segfaults
  - Fixed open connections to SQLite, PostgreSQL and MySQL providers
diff --git a/libgda/gda-connection.c b/libgda/gda-connection.c
index e7a0ab5c2..364cb7984 100644
--- a/libgda/gda-connection.c
+++ b/libgda/gda-connection.c
@@ -71,6 +71,7 @@
 #include <libgda/gda-debug-macros.h>
 #include <libgda/gda-data-handler.h>
 #include <thread-wrapper/itsignaler.h>
+#include "gda-statement-extra.h"
 
 #include <glib/gstdio.h>
 #include <fcntl.h>
@@ -85,7 +86,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 +121,13 @@ 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,
@@ -183,7 +185,7 @@ dump_exec_params (GdaConnection *cnc, GdaStatement *stmt, GdaSet *params)
        if (params && (debug_level & 8)) {
                GSList *list;
                gchar *sql;
-               sql = gda_statement_to_sql_extended (stmt, cnc, params, GDA_STATEMENT_SQL_PARAMS_SHORT,
+               sql = gda_connection_statement_to_sql_extended (cnc, stmt, params, 
GDA_STATEMENT_SQL_PARAMS_SHORT,
                                                     NULL, NULL);
 #ifdef GDA_DEBUG
                g_print ("EVENT> COMMAND: parameters (on cnx %p) for statement [%s]\n", cnc, sql);
@@ -218,6 +220,8 @@ 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 +431,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);
@@ -474,63 +478,64 @@ gda_connection_dispose (GObject *object)
 
        /* free memory */
        gda_connection_close (cnc, NULL);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
 
-       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 +548,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_free (priv->dsn);
+       g_free (priv->cnc_string);
+       g_free (priv->auth_string);
 
-       g_rec_mutex_clear (&cnc->priv->rmutex);
-
-       g_free (cnc->priv);
-       cnc->priv = NULL;
+       g_rec_mutex_clear (&priv->rmutex);
 
        /* chain to parent class */
        parent_class->finalize (object);
@@ -619,125 +622,124 @@ gda_connection_set_property (GObject *object,
        GdaConnection *cnc;
 
         cnc = GDA_CONNECTION (object);
-        if (cnc->priv) {
-                switch (param_id) {
-                case PROP_DSN: {
-                       const gchar *datasource = g_value_get_string (value);
-                       GdaDsnInfo *dsn;
+        GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
+              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) {
-                               g_warning (_("Can't set the '%s' property when the connection is opened"),
-                                          pspec->name);
-                               gda_connection_unlock ((GdaLockable*) cnc);
-                               return;
-                       }
-                       
-                       dsn = gda_config_get_dsn_info (datasource);
-                       if (!dsn) {
-                               g_warning (_("No DSN named '%s' defined"), datasource);
-                               gda_connection_unlock ((GdaLockable*) cnc);
-                               return;
-                       }
-                       
-                       g_free (cnc->priv->dsn);
-                       cnc->priv->dsn = g_strdup (datasource);
+               gda_connection_lock ((GdaLockable*) cnc);
+               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;
+               }
+
+               dsn = gda_config_get_dsn_info (datasource);
+               if (!dsn) {
+                       g_warning (_("No DSN named '%s' defined"), datasource);
+                       gda_connection_unlock ((GdaLockable*) cnc);
+                       return;
+               }
+
+               g_free (priv->dsn);
+               priv->dsn = g_strdup (datasource);
 #ifdef GDA_DEBUG_signal
-                       g_print (">> 'DSN_CHANGED' from %s\n", __FUNCTION__);
+               g_print (">> 'DSN_CHANGED' from %s\n", __FUNCTION__);
 #endif
-                       g_signal_emit (G_OBJECT (cnc), gda_connection_signals[DSN_CHANGED], 0);
+               g_signal_emit (G_OBJECT (cnc), gda_connection_signals[DSN_CHANGED], 0);
 #ifdef GDA_DEBUG_signal
-                       g_print ("<< 'DSN_CHANGED' from %s\n", __FUNCTION__);
+               g_print ("<< 'DSN_CHANGED' from %s\n", __FUNCTION__);
 #endif
+               gda_connection_unlock ((GdaLockable*) cnc);
+                      break;
+       }
+              case PROP_CNC_STRING:
+               gda_connection_lock ((GdaLockable*) cnc);
+               if (priv->provider_data) {
+                       g_warning (_("Can't set the '%s' property when the connection is opened"),
+                                  pspec->name);
                        gda_connection_unlock ((GdaLockable*) cnc);
-                        break;
+                       return;
                }
-                case PROP_CNC_STRING:
-                       gda_connection_lock ((GdaLockable*) cnc);
-                       if (cnc->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;
-                       if (g_value_get_string (value)) 
-                               cnc->priv->cnc_string = g_strdup (g_value_get_string (value));
+               g_free (priv->cnc_string);
+               priv->cnc_string = NULL;
+               if (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 (priv->provider_data) {
+                       g_warning (_("Can't set the '%s' property when the connection is opened"),
+                                  pspec->name);
                        gda_connection_unlock ((GdaLockable*) cnc);
-                        break;
-                case PROP_PROVIDER_OBJ:
-                       gda_connection_lock ((GdaLockable*) cnc);
-                       if (cnc->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);
+                       return;
+               }
+                      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));
-                       gda_connection_unlock ((GdaLockable*) cnc);
-                        break;
-                case PROP_AUTH_STRING:
-                       gda_connection_lock ((GdaLockable*) cnc);
-                       if (cnc->priv->provider_data) {
-                               g_warning (_("Can't set the '%s' property when the connection is opened"),
-                                          pspec->name);
-                               gda_connection_unlock ((GdaLockable*) cnc);
-                               return;
-                       }
-                       else {
-                               const gchar *str = g_value_get_string (value);
-                               g_free (cnc->priv->auth_string);
-                               cnc->priv->auth_string = NULL;
-                               if (str)
-                                       cnc->priv->auth_string = g_strdup (str);
-                       }
-                       gda_connection_unlock ((GdaLockable*) cnc);
-                        break;
-                case PROP_OPTIONS: {
-                       GdaConnectionOptions flags;
-                       flags = g_value_get_flags (value);
-                       gda_connection_lock ((GdaLockable*) cnc);
-                       if (cnc->priv->provider_data &&
-                           ((flags & (~GDA_CONNECTION_OPTIONS_SQL_IDENTIFIERS_CASE_SENSITIVE)) !=
-                            (cnc->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->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 (priv->provider_data) {
+                       g_warning (_("Can't set the '%s' property when the connection is opened"),
+                                  pspec->name);
                        gda_connection_unlock ((GdaLockable*) cnc);
-                       break;
+                       return;
                }
-               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;
-                       }
-                       cnc->priv->meta_store = g_value_get_object (value);
-                       if (cnc->priv->meta_store)
-                               g_object_ref (cnc->priv->meta_store);
-                       gda_connection_unlock ((GdaLockable*) cnc);
-                       break;
-               case PROP_EVENTS_HISTORY_SIZE:
-                       gda_connection_lock ((GdaLockable*) cnc);
-                       change_events_array_max_size (cnc, g_value_get_int (value));
+               else {
+                       const gchar *str = g_value_get_string (value);
+                       g_free (priv->auth_string);
+                       priv->auth_string = NULL;
+                       if (str)
+                               priv->auth_string = g_strdup (str);
+               }
+               gda_connection_unlock ((GdaLockable*) cnc);
+                      break;
+              case PROP_OPTIONS: {
+               GdaConnectionOptions flags;
+               flags = g_value_get_flags (value);
+               gda_connection_lock ((GdaLockable*) cnc);
+               if (priv->provider_data &&
+                   ((flags & (~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);
-                       break;
-               case PROP_EXEC_TIMES:
-                       cnc->priv->exec_times = g_value_get_boolean (value);
-                       break;
-               case PROP_EXEC_SLOWDOWN:
-                       cnc->priv->exec_slowdown = g_value_get_uint (value);
-                       break;
-                }
-        }      
+                       return;
+               }
+               priv->options = flags;
+               gda_connection_unlock ((GdaLockable*) cnc);
+               break;
+       }
+       case PROP_META_STORE:
+               gda_connection_lock ((GdaLockable*) cnc);
+               if (priv->meta_store) {
+                       g_object_unref (priv->meta_store);
+                       priv->meta_store = NULL;
+               }
+               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:
+               gda_connection_lock ((GdaLockable*) cnc);
+               change_events_array_max_size (cnc, g_value_get_int (value));
+               gda_connection_unlock ((GdaLockable*) cnc);
+               break;
+       case PROP_EXEC_TIMES:
+               priv->exec_times = g_value_get_boolean (value);
+               break;
+       case PROP_EXEC_SLOWDOWN:
+               priv->exec_slowdown = g_value_get_uint (value);
+               break;
+              }
 }
 
 static void
@@ -748,41 +750,40 @@ gda_connection_get_property (GObject *object,
 {
        GdaConnection *cnc;
 
-        cnc = GDA_CONNECTION (object);
-        if (cnc->priv) {
-                switch (param_id) {
-                case PROP_DSN:
-                       g_value_set_string (value, cnc->priv->dsn);
-                        break;
-                case PROP_CNC_STRING:
-                       g_value_set_string (value, cnc->priv->cnc_string);
-                       break;
-                case PROP_PROVIDER_OBJ:
-                       g_value_set_object (value, (GObject*) cnc->priv->provider_obj);
-                        break;
-                case PROP_AUTH_STRING:
-                       g_value_set_string (value, cnc->priv->auth_string);
-                        break;
-                case PROP_OPTIONS:
-                       g_value_set_flags (value, cnc->priv->options);
-                       break;
-               case PROP_META_STORE:
-                       g_value_set_object (value, cnc->priv->meta_store);
-                       break;
-               case PROP_EVENTS_HISTORY_SIZE:
-                       g_value_set_int (value, cnc->priv->events_array_size);
-                       break;
-               case PROP_EXEC_TIMES:
-                       g_value_set_boolean (value, cnc->priv->exec_times);
-                       break;
-               case PROP_EXEC_SLOWDOWN:
-                       g_value_set_uint (value, cnc->priv->exec_slowdown);
-                       break;
-               default:
-                       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
-                       break;
-                }
-        }      
+      cnc = GDA_CONNECTION (object);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
+              switch (param_id) {
+              case PROP_DSN:
+               g_value_set_string (value, priv->dsn);
+                      break;
+              case PROP_CNC_STRING:
+               g_value_set_string (value, priv->cnc_string);
+               break;
+              case PROP_PROVIDER_OBJ:
+               g_value_set_object (value, (GObject*) priv->provider_obj);
+                      break;
+              case PROP_AUTH_STRING:
+               g_value_set_string (value, priv->auth_string);
+                      break;
+              case PROP_OPTIONS:
+               g_value_set_flags (value, priv->options);
+               break;
+       case PROP_META_STORE:
+               g_value_set_object (value, priv->meta_store);
+               break;
+       case PROP_EVENTS_HISTORY_SIZE:
+               g_value_set_int (value, priv->events_array_size);
+               break;
+       case PROP_EXEC_TIMES:
+               g_value_set_boolean (value, priv->exec_times);
+               break;
+       case PROP_EXEC_SLOWDOWN:
+               g_value_set_uint (value, priv->exec_slowdown);
+               break;
+       default:
+               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+               break;
+              }
 }
 
 /**
@@ -824,16 +825,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 +879,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);
@@ -1328,9 +1331,10 @@ compute_params_and_auth_quarks (GdaConnection *cnc, GdaQuarkList **out_params, G
        *out_auth = NULL;
 
        gda_connection_lock ((GdaLockable*) cnc);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (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 +1342,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 +1366,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 +1407,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 +1419,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 +1451,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 +1467,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 +1498,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 +1559,10 @@ 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;
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
+       if (priv->provider_data)
+               return priv->provider_data->worker;
+       return NULL;
 }
 
 /*
@@ -1566,7 +1573,7 @@ _gda_connection_get_worker (GdaConnection *cnc)
 guint
 _gda_connection_get_exec_slowdown (GdaConnection *cnc)
 {
-       return cnc->priv->exec_slowdown;
+       return gda_connection_get_instance_private (cnc)->exec_slowdown;
 }
 
 static void
@@ -1601,10 +1608,11 @@ _gda_connection_declare_closed (GdaConnection *cnc)
 {
        if (!cnc)
                return;
+       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 +1626,17 @@ _gda_connection_declare_closed (GdaConnection *cnc)
 void
 _gda_connection_set_status (GdaConnection *cnc, GdaConnectionStatus status)
 {
-       if (!cnc || (cnc->priv->status == status))
+       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);*/
 }
 
 /**
@@ -1647,17 +1656,18 @@ gda_connection_increase_usage (GdaConnection *cnc)
 {
        if (!cnc)
                return;
+       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);*/
        }
 }
 
@@ -1678,17 +1688,18 @@ gda_connection_decrease_usage (GdaConnection *cnc)
 {
        if (!cnc)
                return;
+       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);*/
        }
 }
 
@@ -1708,8 +1719,9 @@ gda_connection_get_status (GdaConnection *cnc)
 {
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), GDA_CONNECTION_STATUS_CLOSED);
        GdaConnectionStatus status;
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
        gda_connection_lock ((GdaLockable*) cnc);
-       status = cnc->priv->status;
+       status = priv->status;
        gda_connection_unlock ((GdaLockable*) cnc);
        return status;
 }
@@ -1727,7 +1739,7 @@ gda_connection_is_opened (GdaConnection *cnc)
 {
         g_return_val_if_fail (GDA_IS_CONNECTION (cnc), FALSE);
 
-       return cnc->priv->provider_data ? TRUE : FALSE;
+       return gda_connection_get_instance_private (cnc)->provider_data ? TRUE : FALSE;
 }
 
 
@@ -1744,7 +1756,7 @@ gda_connection_get_options (GdaConnection *cnc)
 {
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), -1);
 
-       return cnc->priv->options;
+       return gda_connection_get_instance_private (cnc)->options;
 }
 
 /**
@@ -1760,7 +1772,7 @@ gda_connection_get_provider (GdaConnection *cnc)
 {
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
 
-       return cnc->priv->provider_obj;
+       return  gda_connection_get_instance_private (cnc)->provider_obj;
 }
 
 /**
@@ -1775,10 +1787,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);
 }
 
 /**
@@ -1793,7 +1806,7 @@ gda_connection_get_dsn (GdaConnection *cnc)
 {
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
 
-       return (const gchar *) cnc->priv->dsn;
+       return (const gchar *) gda_connection_get_instance_private (cnc)->dsn;
 }
 
 /**
@@ -1813,7 +1826,7 @@ gda_connection_get_cnc_string (GdaConnection *cnc)
 {
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
 
-       return (const gchar *) cnc->priv->cnc_string;
+       return (const gchar *) gda_connection_get_instance_private (cnc)->cnc_string;
 }
 
 /**
@@ -1830,7 +1843,7 @@ gda_connection_get_authentication (GdaConnection *cnc)
        const gchar *str;
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
 
-       str = (const gchar *) cnc->priv->auth_string;
+       str = (const gchar *) gda_connection_get_instance_private (cnc)->auth_string;
        if (!str) 
                str = "";
        return str;
@@ -1857,9 +1870,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 +2539,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;
@@ -2546,9 +2561,10 @@ static void
 dump_events_array (GdaConnection *cnc)
 {
        gint i;
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
        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;
@@ -2583,28 +2599,29 @@ gda_connection_add_event (GdaConnection *cnc, GdaConnectionEvent *event)
 
        g_object_ref (cnc);
        gda_connection_lock ((GdaLockable*) cnc);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (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 +2701,10 @@ 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;
+       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 +2743,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 +2766,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 +2791,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);
 }
 
 /*
@@ -2783,28 +2804,29 @@ static void
 change_events_array_max_size (GdaConnection *cnc, gint size)
 {
        size ++; /* add 1 to compensate the "lost" slot when rotating the events array */
-       if (size == cnc->priv->events_array_size)
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
+       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 +2854,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 +2863,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 +2878,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 +2915,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,22 +2938,20 @@ 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);
+       return sql ? sql : gda_connection_statement_to_sql_extended (cnc, stmt, params, flags, params_used, 
error);
 }
 
 /**
@@ -2955,10 +2977,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);
 }
 
 /*
@@ -3035,6 +3058,7 @@ gda_connection_statement_execute_v (GdaConnection *cnc, GdaStatement *stmt, GdaS
        va_end (ap);
 
        g_object_ref ((GObject*) cnc);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
 
        gda_connection_lock ((GdaLockable*) cnc);
        _clear_connection_events (cnc);
@@ -3043,7 +3067,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 +3089,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 +3271,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 +3306,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 +3376,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 +3422,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 +3447,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 +3469,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 +3527,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 +3543,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 +3560,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 +3614,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 +3633,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 +3656,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 +3717,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 +3726,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 +3745,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 +3754,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 +3774,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 +3783,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 +3800,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 +3809,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 +3826,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 +3835,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 +3852,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 +3861,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 +3879,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 +3897,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 +4795,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 +4809,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 +4830,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 +4846,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 +4856,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 +4879,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 +4890,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 +4916,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 +4954,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 +4988,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 +5279,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 +5348,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 +5404,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);
 }
 
 /**
@@ -5395,10 +5437,11 @@ gda_connection_internal_transaction_started (GdaConnection *cnc, const gchar *pa
        st->isolation_level = isol_level;
 
        gda_connection_lock ((GdaLockable*) cnc);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (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 +5455,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);
@@ -5440,9 +5483,10 @@ gda_connection_internal_transaction_rolledback (GdaConnection *cnc, const gchar
        g_return_if_fail (GDA_IS_CONNECTION (cnc));
 
        gda_connection_lock ((GdaLockable*) cnc);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (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 +5494,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 +5509,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);
@@ -5493,9 +5537,10 @@ gda_connection_internal_transaction_committed (GdaConnection *cnc, const gchar *
        g_return_if_fail (GDA_IS_CONNECTION (cnc));
 
        gda_connection_lock ((GdaLockable*) cnc);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (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 +5548,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 +5563,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);
@@ -5546,8 +5591,9 @@ gda_connection_internal_savepoint_added (GdaConnection *cnc, const gchar *parent
        g_return_if_fail (GDA_IS_CONNECTION (cnc));
 
        gda_connection_lock ((GdaLockable*) cnc);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (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 +5608,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);
@@ -5590,8 +5636,9 @@ gda_connection_internal_savepoint_rolledback (GdaConnection *cnc, const gchar *s
        g_return_if_fail (GDA_IS_CONNECTION (cnc));
 
        gda_connection_lock ((GdaLockable*) cnc);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (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 +5653,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);
@@ -5634,8 +5681,9 @@ gda_connection_internal_savepoint_removed (GdaConnection *cnc, const gchar *svp_
        g_return_if_fail (GDA_IS_CONNECTION (cnc));
 
        gda_connection_lock ((GdaLockable*) cnc);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (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 +5698,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);
@@ -5677,6 +5725,7 @@ gda_connection_internal_statement_executed (GdaConnection *cnc, GdaStatement *st
                sqlst = _gda_statement_get_internal_struct (stmt);
                trans = (GdaSqlStatementTransaction*) sqlst->contents; /* warning: this may be inaccurate if 
stmt_type is not
                                                                          a transaction type, but the 
compiler does not care */
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
 
                switch (sqlst->stmt_type) {
                case GDA_SQL_STATEMENT_BEGIN:
@@ -5703,14 +5752,14 @@ 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);
                                else {
                                        gchar *sql;
-                                       sql = gda_statement_to_sql_extended (stmt, cnc, NULL, 
+                                       sql = gda_connection_statement_to_sql_extended (cnc, stmt, NULL,
                                                                             GDA_STATEMENT_SQL_PARAMS_SHORT,
                                                                             NULL, NULL);
                                        gda_transaction_status_add_event_sql (st, sql, error);
@@ -5725,8 +5774,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;
@@ -5750,13 +5799,14 @@ gda_connection_internal_change_transaction_state (GdaConnection *cnc,
        g_return_if_fail (GDA_IS_CONNECTION (cnc));
 
        gda_connection_lock ((GdaLockable*) cnc);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (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
@@ -5779,9 +5829,10 @@ gda_connection_internal_reset_transaction_status (GdaConnection *cnc)
        g_return_if_fail (GDA_IS_CONNECTION (cnc));
 
        gda_connection_lock ((GdaLockable*) cnc);
-       if (cnc->priv->trans_status) {
-               g_object_unref (cnc->priv->trans_status);
-               cnc->priv->trans_status = NULL;
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
+       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
@@ -5807,8 +5858,9 @@ prepared_stmts_stmt_reset_cb (GdaStatement *gda_stmt, GdaConnection *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);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
+       g_assert (priv->prepared_stmts);
+       g_hash_table_remove (priv->prepared_stmts, gda_stmt);
 
        gda_connection_unlock ((GdaLockable*) cnc);
 }
@@ -5824,9 +5876,10 @@ static void
 statement_weak_notify_cb (GdaConnection *cnc, GdaStatement *stmt)
 {
        gda_connection_lock ((GdaLockable*) cnc);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (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);
 }
@@ -5852,12 +5905,13 @@ gda_connection_add_prepared_statement (GdaConnection *cnc, GdaStatement *gda_stm
        g_return_if_fail (GDA_IS_PSTMT (prepared_stmt));
 
        gda_connection_lock ((GdaLockable*) cnc);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (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);
@@ -5885,8 +5939,9 @@ gda_connection_get_prepared_statement (GdaConnection *cnc, GdaStatement *gda_stm
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
 
        gda_connection_lock ((GdaLockable*) cnc);
-       if (cnc->priv->prepared_stmts) 
-               retval = g_hash_table_lookup (cnc->priv->prepared_stmts, gda_stmt);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
+       if (priv->prepared_stmts)
+               retval = g_hash_table_lookup (priv->prepared_stmts, gda_stmt);
        gda_connection_unlock ((GdaLockable*) cnc);
 
        return retval;
@@ -5933,7 +5988,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 +5997,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;
 
@@ -5953,10 +6009,11 @@ void
 _gda_connection_internal_set_worker_thread (GdaConnection *cnc, GThread *thread)
 {
        g_mutex_lock (&global_mutex);
-       if (cnc->priv->worker_thread && thread)
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
+       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 +6052,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"));
@@ -6016,10 +6074,11 @@ gda_connection_get_meta_store (GdaConnection *cnc)
 {
        g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
        gda_connection_lock ((GdaLockable*) cnc);
-       if (!cnc->priv->meta_store) {
-               cnc->priv->meta_store = gda_meta_store_new (NULL);
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
+       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 +6086,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 +6128,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 +6181,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 +6194,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 +6212,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;
@@ -6246,6 +6308,7 @@ static GSList *
 meta_data_context_from_statement (GdaConnection *cnc, GdaStatement *stmt, GdaSet *params)
 {
        gboolean ignore_create_drop = FALSE;
+       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
        if (GDA_IS_VCONNECTION_DATA_MODEL (cnc))
                /* meta data is updated when the virtual connection emits the
                 * "vtable-created" or "vtable-dropped" signals
@@ -6304,9 +6367,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 +6391,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 +6415,57 @@ 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))
+       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 +6482,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 +6494,9 @@ 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))
+       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 +6520,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 +6536,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 +6547,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);
 
@@ -6606,3 +6671,595 @@ gda_server_provider_connection_data_free (GdaServerProviderConnectionData *obj)
 }
 
 G_DEFINE_BOXED_TYPE(GdaServerProviderConnectionData, gda_server_provider_connection_data, 
gda_server_provider_connection_data_copy, gda_server_provider_connection_data_free)
+
+
+/**
+ * gda_connection_meta_context_set_column:
+ * @cnc: (nullable): a #GdaConnection to be used when identifier are normalized, or NULL
+ * @ctx: a #GdaMetaContext struct to add column/value pais to
+ * @column: (transfer none): the column's name
+ * @value: (transfer none): the column's value
+ *
+ * Sets a new column/value pair to the given context @ctx. Column, must be a column in the given table's
+ * name setted by #gda_meta_context_set_table () (a table in the <link linkend="information_schema">database
+ * schema</link>). If the given @column already exists it's value is overwrited.
+ *
+ * Column's name and value is copied and destroyed when #gda_meta_context_free is called.
+ *
+ * Since: 6.0
+ */
+void
+gda_connection_meta_context_set_column (GdaConnection *cnc, GdaMetaContext *ctx, const gchar* column, const 
GValue* value)
+{
+       g_return_if_fail (ctx && column && value);
+       GValue *v;
+       if (G_VALUE_HOLDS_STRING((GValue*)value)) {
+               v = gda_value_new (G_TYPE_STRING);
+               g_value_take_string (v, gda_sql_identifier_quote (g_value_get_string ((GValue*)value), cnc, 
NULL,
+                                                                               TRUE, FALSE));
+               g_hash_table_insert (ctx->columns, (gpointer) g_strdup (column), (gpointer) v);
+       }
+       else
+               g_hash_table_insert (ctx->columns, (gpointer) g_strdup (column), (gpointer) gda_value_copy 
(value));
+}
+
+
+/**
+ * gda_connection_meta_context_set_columns:
+ * @ctx: a #GdaMetaContext struct to set colums to
+ * @columns: (element-type utf8 GObject.Value): a #GHashTable with the table's columns' name and their values
+ * to use in context.
+ *
+ * Set columns to use in the context. The #GHashTable use column's name as key and a #GValue as value,
+ * to represent its value.
+ *
+ * @columns incements its reference counting. Is recommended to use #gda_meta_context_free in order to free 
them.
+ *
+ * Since: 6.0
+ */
+void
+gda_connection_meta_context_set_columns (GdaConnection *cnc, GdaMetaContext *ctx, GHashTable *columns)
+{
+       g_hash_table_unref (ctx->columns);
+       ctx->columns = g_hash_table_ref (columns);
+       // FIXME: Old but necesary initialization
+       // FIXME: Remove code that use column_names and column_values arrays
+       if (ctx->column_names)
+               g_free (ctx->column_names);
+       if (ctx->column_values)
+               g_free (ctx->column_values);
+       ctx->column_names = g_new (gchar*, g_hash_table_size (ctx->columns));
+       ctx->column_values = g_new (GValue*, g_hash_table_size (ctx->columns));
+
+       GHashTableIter iter;
+       gpointer key, value;
+       gint i = 0; // FIXME: Code to remove
+       g_hash_table_iter_init (&iter, ctx->columns);
+       while (g_hash_table_iter_next (&iter, &key, &value)) {
+               // Normalize identifier quote
+               if (G_VALUE_HOLDS_STRING((GValue*)value)) {
+                       GValue *v = gda_value_new (G_TYPE_STRING);
+                       g_value_take_string (v, gda_sql_identifier_quote (g_value_get_string 
((GValue*)value), cnc, NULL,
+                                                                                       TRUE, FALSE));
+                       g_hash_table_insert (ctx->columns, key, (gpointer) v);
+               }
+
+               // FIXME: Code to remove
+               ctx->column_names[i] = (gchar*) key;
+               ctx->column_values[i] = (GValue*) value;
+               i++;
+       }
+}
+
+/**
+ * gda_connection_statement_normalize:
+ * @cnc: a #GdaConnection object
+ * @stmt: a #GdaStatement object
+ * @error: a place to store errors, or %NULL
+ *
+ * "Normalizes" some parts of @stmt, see gda_sql_statement_normalize() for more
+ * information.
+ *
+ * Returns: TRUE if no error occurred
+ * Since: 6.0
+ */
+gboolean
+gda_connection_statement_normalize (GdaConnection *cnc, GdaStatement *stmt, GError **error)
+{
+       g_return_val_if_fail (GDA_IS_STATEMENT (stmt), FALSE);
+       g_return_val_if_fail (stmt->priv, FALSE);
+       g_return_val_if_fail (GDA_IS_CONNECTION (cnc), FALSE);
+
+       return gda_connection_sql_statement_normalize (cnc, gda_statement_get_sql_statement (stmt), error);
+}
+
+
+/**
+ * gda_connection_statement_to_sql_extended:
+ * @stmt: a #GdaStatement object
+ * @cnc: (allow-none): a #GdaConnection object, or %NULL
+ * @params: (allow-none): parameters contained in a single #GdaSet object, or %NULL
+ * @flags: a set of flags to control the rendering
+ * @params_used: (element-type GdaHolder) (out) (transfer container) (allow-none):a place to store the list 
of actual #GdaHolder objects in @params used to do the rendering, or %NULL
+ * @error: a place to store errors, or %NULL
+ *
+ * Renders @stmt as an SQL statement, with some control on how it is rendered.
+ *
+ * If @cnc is not %NULL, then the rendered SQL will better be suited to be used by @cnc (in particular
+ * it may include some SQL tweaks and/or proprietary extensions specific to the database engine used by 
@cnc):
+ * in this case the result is similar to calling gda_connection_statement_to_sql().
+ *
+ * Returns: (transfer full): a new string if no error occurred
+ */
+gchar *
+gda_connection_statement_to_sql_extended (GdaConnection *cnc, GdaStatement *stmt, GdaSet *params,
+                              GdaStatementSqlFlag flags,
+                              GSList **params_used, GError **error)
+{
+       g_return_val_if_fail (cnc != NULL, NULL);
+       g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
+       g_return_val_if_fail (gda_connection_is_opened (cnc), NULL);
+
+       return _gda_server_provider_statement_to_sql (gda_connection_get_provider (cnc), cnc,
+                                                                     stmt, params, flags,
+                                                                     params_used, error);
+}
+
+
+/**
+ * gda_connection_prepare_operation_create_table_v:
+ * @cnc: an opened connection
+ * @table_name: name of the table to create
+ * @error: a place to store errors, or %NULL
+ * @...: group of three arguments for column's name, column's #GType
+ * and a #GdaServerOperationCreateTableFlag flag, finished with %NULL
+ *
+ * Convenient funtion for table creation.
+ *
+ * For details about arguments see #gda_server_operation_prepare_create_table_v().
+ *
+ * Returns: (transfer full) (nullable): a #GdaServerOperation if no errors; NULL and set @error otherwise
+ *
+ * Since: 6.0
+ */
+G_GNUC_NULL_TERMINATED
+GdaServerOperation*
+gda_connection_prepare_operation_create_table_v (GdaConnection *cnc, const gchar *table_name, GError 
**error, ...)
+{
+       GdaServerOperation *op;
+
+       g_return_val_if_fail (gda_connection_is_opened (cnc), NULL);
+
+       va_list  args;
+       gchar   *arg;
+       GType    type;
+       GdaServerOperationCreateTableFlag flag;
+       gint refs;
+       GList *arguments = NULL;
+       GdaServerOperationCreateTableArg* argument;
+
+       va_start (args, error);
+       type = 0;
+       arg = NULL;
+       refs = -1;
+
+       while ((arg = va_arg (args, gchar*))) {
+               argument = gda_server_operation_create_table_arg_new ();
+               /* First argument for Column's name */
+               gda_server_operation_create_table_arg_set_column_name (argument, (const gchar*) arg);
+
+               /* Second to Define column's type */
+               type = va_arg (args, GType);
+               gda_server_operation_create_table_arg_set_column_type (argument, type);
+
+               /* Third for column's flags */
+               flag = va_arg (args, GdaServerOperationCreateTableFlag);
+               gda_server_operation_create_table_arg_set_flags (argument, flag);
+               if (flag & GDA_SERVER_OPERATION_CREATE_TABLE_FKEY_FLAG) {
+                       gint j;
+                       gint fields;
+                       gchar *fkey_table;
+                       gchar *fkey_ondelete;
+                       gchar *fkey_onupdate;
+
+                       refs++;
+                       GList *lfields = NULL;
+
+                       fkey_table = va_arg (args, gchar*);
+                       gda_server_operation_create_table_arg_set_fkey_table (argument, fkey_table);
+                       /* Get number of referenced fields */
+                       fields = va_arg (args, gint);
+
+                       for (j = 0; j < fields; j++) {
+                               gchar *field;
+                               GdaServerOperationCreateTableArgFKeyRefField *rfields;
+
+                               /* First pair arguments give local field and referenced field */
+                               field = va_arg (args, gchar*);
+                               rfields = gda_server_operation_create_table_arg_fkey_ref_field_new ();
+                               gda_server_operation_create_table_arg_fkey_ref_field_set_local_field 
(rfields, field);
+                               gda_server_operation_create_table_arg_fkey_ref_field_set_referenced_field 
(rfields, field);
+                               lfields = g_list_append (lfields, rfields);
+                       }
+                       gda_server_operation_create_table_arg_set_fkey_refs (argument, lfields);
+
+                       /* ON DELETE and ON UPDATE events constraints */
+                       fkey_ondelete = va_arg (args, gchar*);
+                       gda_server_operation_create_table_arg_set_fkey_ondelete (argument, fkey_ondelete);
+
+                       fkey_onupdate = va_arg (args, gchar*);
+                       gda_server_operation_create_table_arg_set_fkey_ondupdate (argument, fkey_onupdate);
+               }
+
+               arguments = g_list_append (arguments, argument);
+       }
+
+       va_end (args);
+
+       op = gda_connection_prepare_operation_create_table (cnc, table_name, arguments, error);
+       g_list_free_full (arguments, (GDestroyNotify) gda_server_operation_create_table_arg_free);
+       return op;
+}
+
+
+/**
+ * gda_connection_prepare_operation_create_table:
+ * @cnc: an opened connection
+ * @table_name: name of the table to create
+ * @arguments: (element-type GdaServerOperationCreateTableArg): list of arguments as 
#GdaServerOperationPrepareCreateTableArg containing column's name,
+ * column's #GType and a #GdaServerOperationCreateTableFlag flag
+ * @error: a place to store errors, or %NULL
+ *
+ * Add more arguments if the flag needs them:
+ *
+ * GDA_SERVER_OPERATION_CREATE_TABLE_FKEY_FLAG:
+ * <itemizedlist>
+ *   <listitem><para>string with the table's name referenced</para></listitem>
+ *   <listitem><para>an integer with the number pairs "local_field", "referenced_field"
+ *   used in the reference</para></listitem>
+ *   <listitem><para>Pairs of "local_field", "referenced_field" to use, must match
+ *    the number specified above.</para></listitem>
+ *   <listitem><para>a string with the action for ON DELETE; can be: "RESTRICT", "CASCADE",
+ *    "NO ACTION", "SET NULL" and "SET DEFAULT". Example: "ON UPDATE CASCADE".</para></listitem>
+ *   <listitem><para>a string with the action for ON UPDATE (see above).</para></listitem>
+ * </itemizedlist>
+ *
+ * Create a #GdaServerOperation object using an opened connection, taking three
+ * arguments, a column's name the column's GType and #GdaServerOperationCreateTableFlag
+ * flag, you need to finish the list using %NULL.
+ *
+ * You'll be able to modify the #GdaServerOperation object to add custom options
+ * to the operation. When finished call #gda_server_operation_perform_create_table
+ * or #gda_server_provider_perform_operation
+ * in order to execute the operation.
+ *
+ * Returns: (transfer full) (nullable): a #GdaServerOperation if no errors; NULL and set @error otherwise
+ *
+ * Since: 6.0
+ */
+GdaServerOperation*
+gda_connection_prepare_operation_create_table (GdaConnection *cnc, const gchar *table_name, GList 
*arguments, GError **error)
+{
+       GdaServerOperation *op;
+       GdaServerProvider *server;
+
+       g_return_val_if_fail (gda_connection_is_opened (cnc), NULL);
+
+       server = gda_connection_get_provider (cnc);
+
+       if (!table_name) {
+               g_set_error (error, GDA_SERVER_OPERATION_ERROR, GDA_SERVER_OPERATION_OBJECT_NAME_ERROR,
+                            "%s", _("Unspecified table name"));
+               return NULL;
+       }
+
+       if (gda_server_provider_supports_operation (server, cnc, GDA_SERVER_OPERATION_CREATE_TABLE, NULL)) {
+               gchar   *cname;
+               GType    type;
+               gchar   *dbms_type;
+               GdaServerOperationCreateTableFlag flag;
+               gint i;
+               gint refs;
+
+               op = gda_server_provider_create_operation (server, cnc,
+                                                          GDA_SERVER_OPERATION_CREATE_TABLE, NULL, error);
+               if (!GDA_IS_SERVER_OPERATION(op))
+                       return NULL;
+               if(!gda_server_operation_set_value_at (op, table_name, error, "/TABLE_DEF_P/TABLE_NAME")) {
+                       g_object_unref (op);
+                       return NULL;
+               }
+
+               type = 0;
+               cname = NULL;
+               i = 0;
+               refs = -1;
+
+               GList *l = arguments;
+               while (l != NULL) {
+                       GdaServerOperationCreateTableArg *argument;
+                       argument = (GdaServerOperationCreateTableArg*) l->data;
+                       cname = gda_server_operation_create_table_arg_get_column_name (argument);
+                       /* First argument for Column's name */
+                       if(!gda_server_operation_set_value_at (op, cname, error, "/FIELDS_A/@COLUMN_NAME/%d", 
i)) {
+                               g_object_unref (op);
+                               return NULL;
+                       }
+                       g_free (cname);
+
+                       /* Second to Define column's type */
+                       type = gda_server_operation_create_table_arg_get_column_type (argument);
+                       if (type == 0) {
+                               g_set_error (error, GDA_SERVER_OPERATION_ERROR, 
GDA_SERVER_OPERATION_INCORRECT_VALUE_ERROR,
+                                            "%s", _("Invalid type"));
+                               g_object_unref (op);
+                               return NULL;
+                       }
+                       dbms_type = (gchar *) gda_server_provider_get_default_dbms_type (server,
+                                                                                        cnc, type);
+                       if (!gda_server_operation_set_value_at (op, dbms_type, error, 
"/FIELDS_A/@COLUMN_TYPE/%d", i)){
+                               g_object_unref (op);
+                               return NULL;
+                       }
+
+                       /* Third for column's flags */
+                       flag = gda_server_operation_create_table_arg_get_flags (argument);
+                       if (flag & GDA_SERVER_OPERATION_CREATE_TABLE_PKEY_FLAG)
+                               if(!gda_server_operation_set_value_at (op, "TRUE", error, 
"/FIELDS_A/@COLUMN_PKEY/%d", i)){
+                                       g_object_unref (op);
+                                       return NULL;
+                               }
+                       if (flag & GDA_SERVER_OPERATION_CREATE_TABLE_NOT_NULL_FLAG)
+                               if(!gda_server_operation_set_value_at (op, "TRUE", error, 
"/FIELDS_A/@COLUMN_NNUL/%d", i)){
+                                       g_object_unref (op);
+                                       return NULL;
+                               }
+                       if (flag & GDA_SERVER_OPERATION_CREATE_TABLE_AUTOINC_FLAG)
+                               if (!gda_server_operation_set_value_at (op, "TRUE", error, 
"/FIELDS_A/@COLUMN_AUTOINC/%d", i)){
+                                       g_object_unref (op);
+                                       return NULL;
+                               }
+                       if (flag & GDA_SERVER_OPERATION_CREATE_TABLE_UNIQUE_FLAG)
+                               if(!gda_server_operation_set_value_at (op, "TRUE", error, 
"/FIELDS_A/@COLUMN_UNIQUE/%d", i)){
+                                       g_object_unref (op);
+                                       return NULL;
+                               }
+                       if (flag & GDA_SERVER_OPERATION_CREATE_TABLE_FKEY_FLAG) {
+                               gint j;
+                               gchar *fkey_table;
+                               gchar *fkey_ondelete;
+                               gchar *fkey_onupdate;
+
+                               fkey_table = gda_server_operation_create_table_arg_get_column_name (argument);
+                               if (!gda_server_operation_set_value_at (op, fkey_table, error,
+                                                                  "/FKEY_S/%d/FKEY_REF_TABLE", refs)){
+                                       g_object_unref (op);
+                                       return NULL;
+                               }
+
+                               refs++;
+                               GList* lr = gda_server_operation_create_table_arg_get_fkey_refs (argument);
+                               j = 0;
+
+                               while (lr) {
+                                       gchar *field, *rfield;
+                                       GdaServerOperationCreateTableArgFKeyRefField *ref;
+                                       ref = (GdaServerOperationCreateTableArgFKeyRefField*) l->data;
+
+                                       field = 
gda_server_operation_create_table_arg_fkey_ref_field_get_local_field (ref);
+                                       if(!gda_server_operation_set_value_at (op, field, error,
+                                                                          
"/FKEY_S/%d/FKEY_FIELDS_A/@FK_FIELD/%d", refs, j)){
+                                               g_object_unref (op);
+                                               return NULL;
+                                       }
+
+                                       rfield = 
gda_server_operation_create_table_arg_fkey_ref_field_get_referenced_field (ref);
+                                       if(!gda_server_operation_set_value_at (op, rfield, error,
+                                                                          
"/FKEY_S/%d/FKEY_FIELDS_A/@FK_REF_PK_FIELD/%d", refs, j)){
+                                               g_object_unref (op);
+                                               return NULL;
+                                       }
+                                       j++;
+                                       lr = g_list_next (lr);
+                               }
+
+                               fkey_ondelete = gda_server_operation_create_table_arg_get_fkey_ondelete 
(argument);
+                               if (!gda_server_operation_set_value_at (op, fkey_ondelete, error,
+                                                                  "/FKEY_S/%d/FKEY_ONDELETE", refs)){
+                                       g_object_unref (op);
+                                       return NULL;
+                               }
+                               fkey_onupdate = gda_server_operation_create_table_arg_get_fkey_onupdate 
(argument);
+                               if(!gda_server_operation_set_value_at (op, fkey_onupdate, error,
+                                                                  "/FKEY_S/%d/FKEY_ONUPDATE", refs)){
+                                       g_object_unref (op);
+                                       return NULL;
+                               }
+                       }
+
+                       l = g_list_next (l);
+                       i++;
+               }
+
+               g_object_set_data_full (G_OBJECT (op), "_gda_connection", g_object_ref (cnc), g_object_unref);
+
+               return op;
+       }
+       else {
+               g_set_error (error, GDA_SERVER_OPERATION_ERROR, GDA_SERVER_OPERATION_OBJECT_NAME_ERROR,
+                            "%s", _("CREATE TABLE operation is not supported by the database server"));
+               return NULL;
+       }
+}
+
+/**
+ * gda_connection_prepare_operation_drop_table:
+ * @cnc: an opened connection
+ * @table_name: name of the table to drop
+ * @error: a place to store errors, or %NULL
+ *
+ * This is just a convenient function to create a #GdaServerOperation to drop a
+ * table in an opened connection.
+ *
+ * Returns: (transfer full) (nullable): a new #GdaServerOperation or %NULL if couldn't create the 
opereration.
+ *
+ * Since: 6.0
+ */
+GdaServerOperation*
+gda_server_operation_prepare_drop_table (GdaConnection *cnc, const gchar *table_name, GError **error)
+{
+       GdaServerOperation *op;
+       GdaServerProvider *server;
+
+       server = gda_connection_get_provider (cnc);
+
+       op = gda_server_provider_create_operation (server, cnc,
+                                                  GDA_SERVER_OPERATION_DROP_TABLE, NULL, error);
+
+       if (GDA_IS_SERVER_OPERATION (op)) {
+               g_return_val_if_fail (table_name != NULL
+                                     || GDA_IS_CONNECTION (cnc)
+                                     || !gda_connection_is_opened (cnc), NULL);
+
+               if (gda_server_operation_set_value_at (op, table_name,
+                                                      error, "/TABLE_DESC_P/TABLE_NAME")) {
+                       g_object_set_data_full (G_OBJECT (op), "_gda_connection", g_object_ref (cnc), 
g_object_unref);
+                       return op;
+               }
+               else
+                       return NULL;
+       }
+       else
+               return NULL;
+}
+
+
+/**
+ * gda_connection_operation_get_sql_identifier_at:
+ * @cnc: a #GdaConnection
+ * @op: a #GdaServerOperation object
+ * @path_format: a complete path to a node (starting with "/")
+ * @error: (nullable): a place to store errors, or %NULL
+ * @...: arguments to use with @path_format to make a complete path
+ *
+ * This method is similar to gda_server_operation_get_value_at(), but for SQL identifiers: a new string
+ * is returned instead of a #GValue. Also the returned string is assumed to represents an SQL identifier
+ * and will correctly be quoted to be used with @cnc.
+ *
+ * Returns: (transfer full) (nullable): a new string, or %NULL if the value is undefined or
+ * if the @path is not defined or @path does not hold any value, or if the value held is not a string
+ * (in that last case a warning is shown).
+ *
+ * Since: 6.0
+ */
+gchar *
+gda_connection_operation_get_sql_identifier_at (GdaConnection *cnc, GdaServerOperation *op,
+                                           const gchar *path_format, GError **error, ...)
+{
+       g_return_val_if_fail (cnc != NULL, NULL);
+       g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
+       g_return_val_if_fail (GDA_IS_SERVER_OPERATION (op), NULL);
+
+       gchar *path, *ret;
+       va_list args;
+
+       /* build path */
+       va_start (args, error);
+       path = g_strdup_vprintf (path_format, args);
+       va_end (args);
+
+       ret = gda_connection_operation_get_sql_identifier_at_path (cnc, op, path, error);
+       g_free (path);
+
+       return ret;
+}
+
+
+
+/**
+ * gda_connection_operation_get_sql_identifier_at_path:
+ * @op: a #GdaServerOperation object
+ * @cnc: (nullable): a #GdaConnection, or %NULL
+ * @path: a complete path to a node (starting with "/")
+ * @error: (nullable): a place to store errors, or %NULL
+ *
+ * This method is similar to gda_server_operation_get_value_at(), but for SQL identifiers: a new string
+ * is returned instead of a #GValue. Also the returned string is assumed to represents an SQL identifier
+ * and will correctly be quoted to be used with @cnc.
+ *
+ * Returns: (transfer full) (nullable): a new string, or %NULL if the value is undefined or
+ * if the @path is not defined or @path does not hold any value, or if the value held is not a string or
+ * a valid SQL identifier.
+ *
+ * Since: 6.0
+ */
+gchar *
+gda_connection_operation_get_sql_identifier_at_path (GdaConnection *cnc, GdaServerOperation *op,
+                                                const gchar *path, GError **error)
+{
+       const GValue *value = NULL;
+       GdaConnectionOptions cncoptions = 0;
+
+       g_return_val_if_fail (GDA_IS_SERVER_OPERATION (op), NULL);
+
+       value = gda_server_operation_get_value_at_path (op, path);
+
+       if (!value || (G_VALUE_TYPE (value) == GDA_TYPE_NULL)) {
+               g_set_error (error, GDA_SERVER_OPERATION_ERROR, GDA_SERVER_OPERATION_INCORRECT_VALUE_ERROR,
+                            _("Wrong SQL identifier value"));
+               return NULL;
+       }
+
+       g_return_val_if_fail (G_VALUE_TYPE (value) == G_TYPE_STRING, NULL);
+
+       const gchar *str;
+       str = g_value_get_string (value);
+       if (!str || !*str) {
+               g_set_error (error, GDA_SERVER_OPERATION_ERROR, GDA_SERVER_OPERATION_INCORRECT_VALUE_ERROR,
+                            _("Wrong SQL identifier value"));
+               return NULL;
+       }
+
+       if (cnc)
+               g_object_get (G_OBJECT (cnc), "options", &cncoptions, NULL);
+       return gda_sql_identifier_quote (str, cnc, gda_connection_get_provider (cnc), FALSE,
+                                        cncoptions & GDA_CONNECTION_OPTIONS_SQL_IDENTIFIERS_CASE_SENSITIVE);
+}
+
+
+/**
+ * gda_connection_new_handler_string:
+ * @prov: a #GdaServerProvider object
+ * @cnc: (allow-none): a #GdaConnection object, or %NULL
+ *
+ * Creates a data handler for strings, which will use some specific methods implemented
+ * by the @prov object (possibly also @cnc).
+ *
+ * Returns: (type GdaHandlerString) (transfer full): the new object
+ */
+GdaDataHandler *
+gda_connection_new_handler_string (GdaConnection *cnc)
+{
+       GObject *obj;
+       GdaHandlerString *dh;
+       GdaServerProvider *prov;
+
+       g_return_val_if_fail (!cnc || GDA_IS_CONNECTION (cnc), NULL);
+
+       prov = gda_connection_get_provider (cnc);
+
+       g_return_val_if_fail (GDA_IS_SERVER_PROVIDER (prov), NULL);
+
+       obj = g_object_new (GDA_TYPE_HANDLER_STRING, NULL);
+       dh = (GdaHandlerString*) obj;
+
+       dh->prov = prov;
+       if (cnc)
+               dh->cnc = cnc;
+
+       g_object_add_weak_pointer (G_OBJECT (prov), (gpointer) &(dh->prov));
+       if (cnc)
+               g_object_add_weak_pointer (G_OBJECT (cnc), (gpointer) &(dh->cnc));
+
+       return (GdaDataHandler *) obj;
+}
diff --git a/libgda/gda-connection.h b/libgda/gda-connection.h
index e73923ef6..5d5dbe647 100644
--- a/libgda/gda-connection.h
+++ b/libgda/gda-connection.h
@@ -36,18 +36,63 @@
 #include <libgda/gda-data-model.h>
 #include <libgda/gda-connection-event.h>
 #include <libgda/gda-transaction-status.h>
-#include <libgda/gda-statement.h>
 #include <libgda/gda-meta-store.h>
 #include <libgda/gda-server-operation.h>
+#include <libgda/gda-statement.h>
+#include <sql-parser/gda-statement-struct.h>
 #include <libgda/gda-batch.h>
 
 G_BEGIN_DECLS
 
+/**
+ * GdaConnectionStatus:
+ * @GDA_CONNECTION_STATUS_CLOSED: the connection is closed (default status upon creation)
+ * @GDA_CONNECTION_STATUS_OPENING: the connection is currently being opened
+ * @GDA_CONNECTION_STATUS_IDLE: the connection is opened but not currently used
+ * @GDA_CONNECTION_STATUS_BUSY: the connection is opened and currently being used
+ *
+ * Indicates the current status of a connection. The possible status and the transitions between those status
+ * are indicated in the diagram below:
+ *  <mediaobject>
+ *    <imageobject role="html">
+ *      <imagedata fileref="connection-status.png" format="PNG" contentwidth="50mm"/>
+ *    </imageobject>
+ *    <textobject>
+ *      <phrase>GdaConnection's status and transitions between different status</phrase>
+ *    </textobject>
+ *  </mediaobject>
+ */
+typedef enum {
+       GDA_CONNECTION_STATUS_CLOSED,
+       GDA_CONNECTION_STATUS_OPENING,
+       GDA_CONNECTION_STATUS_IDLE,
+       GDA_CONNECTION_STATUS_BUSY
+} GdaConnectionStatus;
+
+
 #define GDA_TYPE_CONNECTION            (gda_connection_get_type())
-#define GDA_CONNECTION(obj)            (G_TYPE_CHECK_INSTANCE_CAST (obj, GDA_TYPE_CONNECTION, GdaConnection))
-#define GDA_CONNECTION_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST (klass, GDA_TYPE_CONNECTION, 
GdaConnectionClass))
-#define GDA_IS_CONNECTION(obj)         (G_TYPE_CHECK_INSTANCE_TYPE(obj, GDA_TYPE_CONNECTION))
-#define GDA_IS_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GDA_TYPE_CONNECTION))
+G_DECLARE_DERIVABLE_TYPE(GdaConnection, gda_connection, GDA, CONNECTION, GObject)
+
+
+struct _GdaConnectionClass {
+       GObjectClass          object_class;
+
+       /* signals */
+       void   (*status_changed)            (GdaConnection *obj, GdaConnectionStatus status);
+       void   (*error)                     (GdaConnection *cnc, GdaConnectionEvent *error);
+       void   (*opened)                    (GdaConnection *obj);
+       void   (*closed)                    (GdaConnection *obj);
+       void   (*dsn_changed)               (GdaConnection *obj);
+       void   (*transaction_status_changed)(GdaConnection *obj);
+
+
+       /*< private >*/
+       /* Padding for future expansion */
+       void (*_gda_reserved1) (void);
+       void (*_gda_reserved2) (void);
+       void (*_gda_reserved3) (void);
+       void (*_gda_reserved4) (void);
+};
 
 /* error reporting */
 extern GQuark gda_connection_error_quark (void);
@@ -96,56 +141,6 @@ typedef enum {
  * lock on the connection is being acquired.
  */
 
-struct _GdaConnection {
-       GObject               object;
-       GdaConnectionPrivate *priv;
-};
-
-/**
- * GdaConnectionStatus:
- * @GDA_CONNECTION_STATUS_CLOSED: the connection is closed (default status upon creation)
- * @GDA_CONNECTION_STATUS_OPENING: the connection is currently being opened
- * @GDA_CONNECTION_STATUS_IDLE: the connection is opened but not currently used
- * @GDA_CONNECTION_STATUS_BUSY: the connection is opened and currently being used
- *
- * Indicates the current status of a connection. The possible status and the transitions between those status
- * are indicated in the diagram below:
- *  <mediaobject>
- *    <imageobject role="html">
- *      <imagedata fileref="connection-status.png" format="PNG" contentwidth="50mm"/>
- *    </imageobject>
- *    <textobject>
- *      <phrase>GdaConnection's status and transitions between different status</phrase>
- *    </textobject>
- *  </mediaobject>
- */
-typedef enum {
-       GDA_CONNECTION_STATUS_CLOSED,
-       GDA_CONNECTION_STATUS_OPENING,
-       GDA_CONNECTION_STATUS_IDLE,
-       GDA_CONNECTION_STATUS_BUSY
-} GdaConnectionStatus;
-
-struct _GdaConnectionClass {
-       GObjectClass          object_class;
-
-       /* signals */
-       void   (*status_changed)            (GdaConnection *obj, GdaConnectionStatus status);
-       void   (*error)                     (GdaConnection *cnc, GdaConnectionEvent *error);
-        void   (*opened)                    (GdaConnection *obj);
-        void   (*closed)                    (GdaConnection *obj);
-       void   (*dsn_changed)               (GdaConnection *obj);
-       void   (*transaction_status_changed)(GdaConnection *obj);
-
-
-       /*< private >*/
-       /* Padding for future expansion */
-       void (*_gda_reserved1) (void);
-       void (*_gda_reserved2) (void);
-       void (*_gda_reserved3) (void);
-       void (*_gda_reserved4) (void);
-};
-
 /**
  * GdaConnectionOptions:
  * @GDA_CONNECTION_OPTIONS_NONE: no specific aspect
@@ -263,7 +258,25 @@ typedef enum {
 } GdaConnectionMetaType;
 
 
-GType                gda_connection_get_type             (void) G_GNUC_CONST;
+/**
+ * GdaSqlStatementCheckValidityData:
+ *
+ * Validation against a dictionary
+ */
+typedef struct {
+       GdaConnection *cnc;
+       GdaMetaStore  *store;
+       GdaMetaStruct *mstruct;
+
+       /*< private >*/
+       /* Padding for future expansion */
+       gpointer         _gda_reserved1;
+       gpointer         _gda_reserved2;
+       gpointer         _gda_reserved3;
+       gpointer         _gda_reserved4;
+} GdaSqlStatementCheckValidityData;
+
+
 GdaConnection       *gda_connection_open_from_dsn        (const gchar *dsn, const gchar *auth_string,
                                                          GdaConnectionOptions options, GError **error);
 GdaConnection       *gda_connection_open_from_string     (const gchar *provider_name,
@@ -295,7 +308,14 @@ GdaServerOperation  *gda_connection_create_operation     (GdaConnection *cnc, Gd
                                                           GdaSet *options, GError **error);
 
 gboolean             gda_connection_perform_operation    (GdaConnection *cnc, GdaServerOperation *op, GError 
**error);
-                                                          
+GdaServerOperation  *gda_connection_prepare_operation_create_table_v          (GdaConnection *cnc, const 
gchar *table_name, GError **error, ...);
+GdaServerOperation  *gda_connection_prepare_operation_create_table        (GdaConnection *cnc, const gchar 
*table_name, GList *arguments, GError **error);
+GdaServerOperation  *gda_connection_prepare_operation_drop_table            (GdaConnection *cnc, const gchar 
*table_name, GError **error);
+gchar               *gda_connection_operation_get_sql_identifier_at (GdaConnection *cnc,
+              GdaServerOperation *op, const gchar *path_format, GError **error, ...);
+gchar               *gda_connection_operation_get_sql_identifier_at_path (GdaConnection *cnc, 
GdaServerOperation *op,
+                                                const gchar *path, GError **error);
+
 const gchar         *gda_connection_get_dsn              (GdaConnection *cnc);
 const gchar         *gda_connection_get_cnc_string       (GdaConnection *cnc);
 const gchar         *gda_connection_get_authentication   (GdaConnection *cnc);
@@ -386,9 +406,19 @@ GdaDataModel        *gda_connection_get_meta_store_data  (GdaConnection *cnc, Gd
                                                          GError **error, gint nb_filters, ...);
 GdaDataModel        *gda_connection_get_meta_store_data_v(GdaConnection *cnc, GdaConnectionMetaType 
meta_type,
                                                          GList* filters, GError **error);
+void                 gda_connection_meta_context_set_column (GdaConnection *cnc,
+                GdaMetaContext *ctx, const gchar* column, const GValue* value);
+void                 gda_connection_meta_context_set_columns (GdaConnection *cnc,
+                GdaMetaContext *ctx, GHashTable *columns);
+
+
+gchar *              gda_connection_statement_to_sql_extended (GdaConnection *cnc,
+                GdaStatement *stmt, GdaSet *params,
+                GdaStatementSqlFlag flags,
+                GSList **params_used, GError **error);
+
 
-//void                 gda_connection_lock_with_context (GdaConnection *cnc, GMainContext *context);
-//void                 gda_connection_unlock (GdaConnection *cnc);
+GdaDataHandler      *gda_connection_new_handler_string (GdaConnection *cnc);
 
 G_END_DECLS
 
diff --git a/libgda/gda-data-model.c b/libgda/gda-data-model.c
index 4244ed463..1321b0e52 100644
--- a/libgda/gda-data-model.c
+++ b/libgda/gda-data-model.c
@@ -2601,7 +2601,7 @@ real_gda_data_model_dump_as_string (GdaDataModel *model, gboolean dump_attribute
                                                                        GdaServerProvider *prov;
                                                                        cnc = g_object_get_data (G_OBJECT 
(model), "cnc");
                                                                        if (!cnc && GDA_IS_DATA_SELECT 
(model))
-                                                                               cnc = 
gda_data_select_get_connection (GDA_DATA_SELECT (model));
+                                                                               g_object_get (G_OBJECT 
(model), "connection", &cnc, NULL);
                                                                        if (cnc) {
                                                                                prov = 
gda_connection_get_provider (cnc);
                                                                                dh = 
gda_server_provider_get_data_handler_g_type (prov, cnc,
diff --git a/libgda/gda-data-select.c b/libgda/gda-data-select.c
index 8e006305b..512e0527d 100644
--- a/libgda/gda-data-select.c
+++ b/libgda/gda-data-select.c
@@ -974,24 +974,6 @@ gda_data_select_get_stored_row (GdaDataSelect *model, gint rownum)
                return NULL;
 }
 
-/**
- * gda_data_select_get_connection:
- * @model: a #GdaDataSelect data model
- *
- * Get a pointer to the #GdaConnection object which was used when @model was created
- * (and which may be used internally by @model).
- *
- * Returns: (transfer none): a pointer to the #GdaConnection, or %NULL
- */
-GdaConnection *
-gda_data_select_get_connection (GdaDataSelect *model)
-{
-       g_return_val_if_fail (GDA_IS_DATA_SELECT (model), NULL);
-       g_return_val_if_fail (model->priv, NULL);
-
-       return model->priv->cnc;
-}
-
 /**
  * gda_data_select_set_columns:
  * @model: a #GdaDataSelect data model
diff --git a/libgda/gda-data-select.h b/libgda/gda-data-select.h
index 6d87eff85..5bda15df3 100644
--- a/libgda/gda-data-select.h
+++ b/libgda/gda-data-select.h
@@ -173,7 +173,6 @@ gboolean       gda_data_select_compute_modification_statements_ext (GdaDataSelec
                                                                    GError **error);
 
 gboolean       gda_data_select_compute_columns_attributes      (GdaDataSelect *model, GError **error);
-GdaConnection *gda_data_select_get_connection                  (GdaDataSelect *model);
 
 gboolean       gda_data_select_rerun                           (GdaDataSelect *model, GError **error);
 gboolean       gda_data_select_prepare_for_offline             (GdaDataSelect *model, GError **error);
diff --git a/libgda/gda-decl.h b/libgda/gda-decl.h
index 5ae3d292d..b2f993a2e 100644
--- a/libgda/gda-decl.h
+++ b/libgda/gda-decl.h
@@ -27,10 +27,6 @@
 typedef struct _GdaConfig GdaConfig;
 typedef struct _GdaConfigClass GdaConfigClass;
 
-typedef struct _GdaConnection        GdaConnection;
-typedef struct _GdaConnectionClass   GdaConnectionClass;
-typedef struct _GdaConnectionPrivate GdaConnectionPrivate;
-
 typedef struct _GdaConnectionEvent        GdaConnectionEvent;
 typedef struct _GdaConnectionEventClass   GdaConnectionEventClass;
 typedef struct _GdaConnectionEventPrivate GdaConnectionEventPrivate;
diff --git a/libgda/gda-meta-store.c b/libgda/gda-meta-store.c
index 885de4a57..1681b8e02 100644
--- a/libgda/gda-meta-store.c
+++ b/libgda/gda-meta-store.c
@@ -359,24 +359,23 @@ gda_meta_context_get_table (GdaMetaContext *ctx)
  * @ctx: a #GdaMetaContext struct to add column/value pais to
  * @column: (transfer none): the column's name
  * @value: (transfer none): the column's value
- * @cnc: (allow-none): a #GdaConnection to be used when identifier are normalized, or NULL
- * 
+ *
  * Sets a new column/value pair to the given context @ctx. Column, must be a column in the given table's
  * name setted by #gda_meta_context_set_table () (a table in the <link linkend="information_schema">database
  * schema</link>). If the given @column already exists it's value is overwrited.
  *
  * Column's name and value is copied and destroyed when #gda_meta_context_free is called.
  *
- * Since: 5.2
+ * Since: 6.0
  */
 void
-gda_meta_context_set_column (GdaMetaContext *ctx, const gchar* column, const GValue* value, GdaConnection 
*cnc)
+gda_meta_context_set_column (GdaMetaContext *ctx, const gchar* column, const GValue* value)
 {
        g_return_if_fail (ctx && column && value);
        GValue *v;
        if (G_VALUE_HOLDS_STRING((GValue*)value)) {
                v = gda_value_new (G_TYPE_STRING);
-               g_value_take_string (v, gda_sql_identifier_quote (g_value_get_string ((GValue*)value), cnc, 
NULL,
+               g_value_take_string (v, gda_sql_identifier_quote (g_value_get_string ((GValue*)value), NULL, 
NULL,
                                                                                TRUE, FALSE));
                g_hash_table_insert (ctx->columns, (gpointer) g_strdup (column), (gpointer) v);
        }
@@ -389,20 +388,17 @@ gda_meta_context_set_column (GdaMetaContext *ctx, const gchar* column, const GVa
  * @ctx: a #GdaMetaContext struct to set colums to
  * @columns: (element-type utf8 GObject.Value): a #GHashTable with the table's columns' name and their values
  * to use in context.
- * @cnc: (allow-none): a #GdaConnection to used to normalize identifiers quoting, or NULL
- * 
+ *
  * Set columns to use in the context. The #GHashTable use column's name as key and a #GValue as value,
  * to represent its value.
  * 
  * @columns incements its reference counting. Is recommended to use #gda_meta_context_free in order to free 
them.
  *
- * Since: 5.2
+ * Since: 6.0
  */
 void
-gda_meta_context_set_columns (GdaMetaContext *ctx, GHashTable *columns, GdaConnection *cnc)
+gda_meta_context_set_columns (GdaMetaContext *ctx, GHashTable *columns)
 {
-       g_return_if_fail (ctx && columns && cnc);
-       g_return_if_fail (GDA_IS_CONNECTION (cnc));
        g_hash_table_unref (ctx->columns);
        ctx->columns = g_hash_table_ref (columns);
        // FIXME: Old but necesary initialization
@@ -422,7 +418,7 @@ gda_meta_context_set_columns (GdaMetaContext *ctx, GHashTable *columns, GdaConne
                // Normalize identifier quote
                if (G_VALUE_HOLDS_STRING((GValue*)value)) {
                        GValue *v = gda_value_new (G_TYPE_STRING);
-                       g_value_take_string (v, gda_sql_identifier_quote (g_value_get_string 
((GValue*)value), cnc, NULL,
+                       g_value_take_string (v, gda_sql_identifier_quote (g_value_get_string 
((GValue*)value), NULL, NULL,
                                                                                        TRUE, FALSE));
                        g_hash_table_insert (ctx->columns, key, (gpointer) v);
                }
@@ -2922,7 +2918,9 @@ gchar *
 gda_meta_store_sql_identifier_quote (const gchar *id, GdaConnection *cnc)
 {
        GdaConnectionOptions cncoptions;
+       GdaConnection *cnc;
        g_return_val_if_fail (!cnc || GDA_IS_CONNECTION (cnc), NULL);
+       cnc = gda_meta_store_get_internal_connection ()
 
        g_object_get (G_OBJECT (cnc), "options", &cncoptions, NULL);
        return gda_sql_identifier_quote (id, cnc, NULL, TRUE,
diff --git a/libgda/gda-meta-store.h b/libgda/gda-meta-store.h
index b41ea8402..44a3fffa8 100644
--- a/libgda/gda-meta-store.h
+++ b/libgda/gda-meta-store.h
@@ -160,8 +160,6 @@ GdaMetaStore     *gda_meta_store_new_with_file            (const gchar *file_nam
 GdaMetaStore     *gda_meta_store_new                      (const gchar *cnc_string);
 gint              gda_meta_store_get_version              (GdaMetaStore *store);
 
-GdaConnection    *gda_meta_store_get_internal_connection  (GdaMetaStore *store);
-gchar            *gda_meta_store_sql_identifier_quote     (const gchar *id, GdaConnection *cnc);
 GdaDataModel     *gda_meta_store_extract                  (GdaMetaStore *store, const gchar *select_sql, 
GError **error, ...);
 GdaDataModel     *gda_meta_store_extract_v                (GdaMetaStore *store, const gchar *select_sql, 
GHashTable *vars, 
                                                           GError **error);
@@ -212,9 +210,8 @@ GdaMetaContext*   gda_meta_context_copy                   (GdaMetaContext *ctx);
 void              gda_meta_context_set_table              (GdaMetaContext *ctx, const gchar *table);
 const gchar*      gda_meta_context_get_table              (GdaMetaContext *ctx);
 void              gda_meta_context_set_column             (GdaMetaContext *ctx, const gchar* column, 
-                                                          const GValue* value, GdaConnection *cnc);
-void              gda_meta_context_set_columns            (GdaMetaContext *ctx, GHashTable *columns,
-                                                          GdaConnection *cnc);
+                                                          const GValue* value);
+void              gda_meta_context_set_columns            (GdaMetaContext *ctx, GHashTable *columns);
 void              gda_meta_context_free                   (GdaMetaContext *ctx);
 
 G_END_DECLS
diff --git a/libgda/gda-server-operation.c b/libgda/gda-server-operation.c
index e799a2908..8e503d41c 100644
--- a/libgda/gda-server-operation.c
+++ b/libgda/gda-server-operation.c
@@ -2154,25 +2154,22 @@ gda_server_operation_get_value_at (GdaServerOperation *op, const gchar *path_for
 /**
  * gda_server_operation_get_sql_identifier_at:
  * @op: a #GdaServerOperation object
- * @cnc: (nullable): a #GdaConnection, or %NULL
  * @prov: (nullable): a #GdaServerProvider, or %NULL
  * @path_format: a complete path to a node (starting with "/")
  * @error: (nullable): a place to store errors, or %NULL
  * @...: arguments to use with @path_format to make a complete path
  *
  * This method is similar to gda_server_operation_get_value_at(), but for SQL identifiers: a new string
- * is returned instead of a #GValue. Also the returned string is assumed to represents an SQL identifier
- * and will correctly be quoted to be used with @cnc, or @prov if @cnc is %NULL (a generic quoting rule
- * will be applied if both are %NULL).
+ * is returned instead of a #GValue.
  *
- * Returns: (transfer full): a new string, or %NULL if the value is undefined or
+ * Returns: (transfer full) (nullable): a new string, or %NULL if the value is undefined or
  * if the @path is not defined or @path does not hold any value, or if the value held is not a string
  * (in that last case a warning is shown).
  *
  * Since: 4.0.3
  */
 gchar *
-gda_server_operation_get_sql_identifier_at (GdaServerOperation *op, GdaConnection *cnc, GdaServerProvider 
*prov,
+gda_server_operation_get_sql_identifier_at (GdaServerOperation *op, GdaServerProvider *prov,
                                            const gchar *path_format, GError **error, ...)
 {
        gchar *path, *ret;
@@ -2185,7 +2182,7 @@ gda_server_operation_get_sql_identifier_at (GdaServerOperation *op, GdaConnectio
        path = g_strdup_vprintf (path_format, args);
        va_end (args);
 
-       ret = gda_server_operation_get_sql_identifier_at_path (op, cnc, prov, path, error);
+       ret = gda_server_operation_get_sql_identifier_at_path (op, prov, path, error);
        g_free (path);
 
        return ret;
@@ -2194,8 +2191,6 @@ gda_server_operation_get_sql_identifier_at (GdaServerOperation *op, GdaConnectio
 /**
  * gda_server_operation_get_sql_identifier_at_path: (rename-to gda_server_operation_get_sql_identifier_at)
  * @op: a #GdaServerOperation object
- * @cnc: (nullable): a #GdaConnection, or %NULL
- * @prov: (nullable): a #GdaServerProvider, or %NULL
  * @path: a complete path to a node (starting with "/")
  * @error: (nullable): a place to store errors, or %NULL
  *
@@ -2208,14 +2203,13 @@ gda_server_operation_get_sql_identifier_at (GdaServerOperation *op, GdaConnectio
  * if the @path is not defined or @path does not hold any value, or if the value held is not a string or
  * a valid SQL identifier.
  *
- * Since: 4.2.6
+ * Since: 6.0
  */
 gchar *
-gda_server_operation_get_sql_identifier_at_path (GdaServerOperation *op, GdaConnection *cnc, 
GdaServerProvider *prov,
+gda_server_operation_get_sql_identifier_at_path (GdaServerOperation *op,
                                                 const gchar *path, GError **error)
 {
        const GValue *value = NULL;
-       GdaConnectionOptions cncoptions = 0;
 
        g_return_val_if_fail (GDA_IS_SERVER_OPERATION (op), NULL);
 
@@ -2237,10 +2231,8 @@ gda_server_operation_get_sql_identifier_at_path (GdaServerOperation *op, GdaConn
                return NULL;
        }
 
-       if (cnc)
-               g_object_get (G_OBJECT (cnc), "options", &cncoptions, NULL);
-       return gda_sql_identifier_quote (str, cnc, prov, FALSE,
-                                        cncoptions & GDA_CONNECTION_OPTIONS_SQL_IDENTIFIERS_CASE_SENSITIVE);
+       return gda_sql_identifier_quote (str, NULL, NULL, FALSE,
+                                        GDA_CONNECTION_OPTIONS_SQL_IDENTIFIERS_CASE_SENSITIVE);
 }
 
 /**
@@ -3133,395 +3125,6 @@ gda_server_operation_create_table_arg_get_fkey_refs (GdaServerOperationCreateTab
        return arg->fkey_fields;
 }
 
-
-/**
- * gda_server_operation_prepare_create_table_v:
- * @cnc: an opened connection
- * @table_name: name of the table to create
- * @error: a place to store errors, or %NULL
- * @...: group of three arguments for column's name, column's #GType
- * and a #GdaServerOperationCreateTableFlag flag, finished with %NULL
- *
- * Convenient funtion for table creation.
- *
- * For details about arguments see #gda_server_operation_prepare_create_table_v().
- *
- * Returns: (transfer full) (nullable): a #GdaServerOperation if no errors; NULL and set @error otherwise
- *
- * Since: 4.2.3
- */
-G_GNUC_NULL_TERMINATED
-GdaServerOperation*
-gda_server_operation_prepare_create_table_v (GdaConnection *cnc, const gchar *table_name, GError **error, 
...)
-{
-       GdaServerOperation *op;
-
-       g_return_val_if_fail (gda_connection_is_opened (cnc), NULL);
-
-       va_list  args;
-       gchar   *arg;
-       GType    type;
-       GdaServerOperationCreateTableFlag flag;
-       gint refs;
-       GList *arguments = NULL;
-       GdaServerOperationCreateTableArg* argument;
-
-       va_start (args, error);
-       type = 0;
-       arg = NULL;
-       refs = -1;
-
-       while ((arg = va_arg (args, gchar*))) {
-               argument = gda_server_operation_create_table_arg_new ();
-               /* First argument for Column's name */
-               gda_server_operation_create_table_arg_set_column_name (argument, (const gchar*) arg);
-
-               /* Second to Define column's type */
-               type = va_arg (args, GType);
-               gda_server_operation_create_table_arg_set_column_type (argument, type);
-
-               /* Third for column's flags */
-               flag = va_arg (args, GdaServerOperationCreateTableFlag);
-               gda_server_operation_create_table_arg_set_flags (argument, flag);
-               if (flag & GDA_SERVER_OPERATION_CREATE_TABLE_FKEY_FLAG) {
-                       gint j;
-                       gint fields;
-                       gchar *fkey_table;
-                       gchar *fkey_ondelete;
-                       gchar *fkey_onupdate;
-
-                       refs++;
-                       GList *lfields = NULL;
-
-                       fkey_table = va_arg (args, gchar*);
-                       gda_server_operation_create_table_arg_set_fkey_table (argument, fkey_table);
-                       /* Get number of referenced fields */
-                       fields = va_arg (args, gint);
-
-                       for (j = 0; j < fields; j++) {
-                               gchar *field;
-                               GdaServerOperationCreateTableArgFKeyRefField *rfields;
-
-                               /* First pair arguments give local field and referenced field */
-                               field = va_arg (args, gchar*);
-                               rfields = gda_server_operation_create_table_arg_fkey_ref_field_new ();
-                               gda_server_operation_create_table_arg_fkey_ref_field_set_local_field 
(rfields, field);
-                               gda_server_operation_create_table_arg_fkey_ref_field_set_referenced_field 
(rfields, field);
-                               lfields = g_list_append (lfields, rfields);
-                       }
-                       gda_server_operation_create_table_arg_set_fkey_refs (argument, lfields);
-
-                       /* ON DELETE and ON UPDATE events constraints */
-                       fkey_ondelete = va_arg (args, gchar*);
-                       gda_server_operation_create_table_arg_set_fkey_ondelete (argument, fkey_ondelete);
-
-                       fkey_onupdate = va_arg (args, gchar*);
-                       gda_server_operation_create_table_arg_set_fkey_ondupdate (argument, fkey_onupdate);
-               }
-
-               arguments = g_list_append (arguments, argument);
-       }
-
-       va_end (args);
-
-       op = gda_server_operation_prepare_create_table (cnc, table_name, arguments, error);
-       g_list_free_full (arguments, (GDestroyNotify) gda_server_operation_create_table_arg_free);
-       return op;
-}
-
-/**
- * gda_server_operation_prepare_create_table:
- * @cnc: an opened connection
- * @table_name: name of the table to create
- * @arguments: (element-type GdaServerOperationCreateTableArg): list of arguments as 
#GdaServerOperationPrepareCreateTableArg containing column's name,
- * column's #GType and a #GdaServerOperationCreateTableFlag flag
- * @error: a place to store errors, or %NULL
- *
- * Add more arguments if the flag needs them:
- *
- * GDA_SERVER_OPERATION_CREATE_TABLE_FKEY_FLAG:
- * <itemizedlist>
- *   <listitem><para>string with the table's name referenced</para></listitem>
- *   <listitem><para>an integer with the number pairs "local_field", "referenced_field"
- *   used in the reference</para></listitem>
- *   <listitem><para>Pairs of "local_field", "referenced_field" to use, must match
- *    the number specified above.</para></listitem>
- *   <listitem><para>a string with the action for ON DELETE; can be: "RESTRICT", "CASCADE",
- *    "NO ACTION", "SET NULL" and "SET DEFAULT". Example: "ON UPDATE CASCADE".</para></listitem>
- *   <listitem><para>a string with the action for ON UPDATE (see above).</para></listitem>
- * </itemizedlist>
- *
- * Create a #GdaServerOperation object using an opened connection, taking three
- * arguments, a column's name the column's GType and #GdaServerOperationCreateTableFlag
- * flag, you need to finish the list using %NULL.
- *
- * You'll be able to modify the #GdaServerOperation object to add custom options
- * to the operation. When finished call #gda_server_operation_perform_create_table
- * or #gda_server_provider_perform_operation
- * in order to execute the operation.
- *
- * Returns: (transfer full) (nullable): a #GdaServerOperation if no errors; NULL and set @error otherwise
- *
- * Since: 6.0.0
- */
-GdaServerOperation*
-gda_server_operation_prepare_create_table (GdaConnection *cnc, const gchar *table_name, GList *arguments, 
GError **error)
-{
-       GdaServerOperation *op;
-       GdaServerProvider *server;
-
-       g_return_val_if_fail (gda_connection_is_opened (cnc), NULL);
-
-       server = gda_connection_get_provider (cnc);
-
-       if (!table_name) {
-               g_set_error (error, GDA_SERVER_OPERATION_ERROR, GDA_SERVER_OPERATION_OBJECT_NAME_ERROR,
-                            "%s", _("Unspecified table name"));
-               return NULL;
-       }
-
-       if (gda_server_provider_supports_operation (server, cnc, GDA_SERVER_OPERATION_CREATE_TABLE, NULL)) {
-               gchar   *cname;
-               GType    type;
-               gchar   *dbms_type;
-               GdaServerOperationCreateTableFlag flag;
-               gint i;
-               gint refs;
-
-               op = gda_server_provider_create_operation (server, cnc,
-                                                          GDA_SERVER_OPERATION_CREATE_TABLE, NULL, error);
-               if (!GDA_IS_SERVER_OPERATION(op))
-                       return NULL;
-               if(!gda_server_operation_set_value_at (op, table_name, error, "/TABLE_DEF_P/TABLE_NAME")) {
-                       g_object_unref (op);
-                       return NULL;
-               }
-
-               type = 0;
-               cname = NULL;
-               i = 0;
-               refs = -1;
-
-               GList *l = arguments;
-               while (l != NULL) {
-                       GdaServerOperationCreateTableArg *argument;
-                       argument = (GdaServerOperationCreateTableArg*) l->data;
-                       cname = gda_server_operation_create_table_arg_get_column_name (argument);
-                       /* First argument for Column's name */
-                       if(!gda_server_operation_set_value_at (op, cname, error, "/FIELDS_A/@COLUMN_NAME/%d", 
i)) {
-                               g_object_unref (op);
-                               return NULL;
-                       }
-                       g_free (cname);
-
-                       /* Second to Define column's type */
-                       type = gda_server_operation_create_table_arg_get_column_type (argument);
-                       if (type == 0) {
-                               g_set_error (error, GDA_SERVER_OPERATION_ERROR, 
GDA_SERVER_OPERATION_INCORRECT_VALUE_ERROR,
-                                            "%s", _("Invalid type"));
-                               g_object_unref (op);
-                               return NULL;
-                       }
-                       dbms_type = (gchar *) gda_server_provider_get_default_dbms_type (server,
-                                                                                        cnc, type);
-                       if (!gda_server_operation_set_value_at (op, dbms_type, error, 
"/FIELDS_A/@COLUMN_TYPE/%d", i)){
-                               g_object_unref (op);
-                               return NULL;
-                       }
-
-                       /* Third for column's flags */
-                       flag = gda_server_operation_create_table_arg_get_flags (argument);
-                       if (flag & GDA_SERVER_OPERATION_CREATE_TABLE_PKEY_FLAG)
-                               if(!gda_server_operation_set_value_at (op, "TRUE", error, 
"/FIELDS_A/@COLUMN_PKEY/%d", i)){
-                                       g_object_unref (op);
-                                       return NULL;
-                               }
-                       if (flag & GDA_SERVER_OPERATION_CREATE_TABLE_NOT_NULL_FLAG)
-                               if(!gda_server_operation_set_value_at (op, "TRUE", error, 
"/FIELDS_A/@COLUMN_NNUL/%d", i)){
-                                       g_object_unref (op);
-                                       return NULL;
-                               }
-                       if (flag & GDA_SERVER_OPERATION_CREATE_TABLE_AUTOINC_FLAG)
-                               if (!gda_server_operation_set_value_at (op, "TRUE", error, 
"/FIELDS_A/@COLUMN_AUTOINC/%d", i)){
-                                       g_object_unref (op);
-                                       return NULL;
-                               }
-                       if (flag & GDA_SERVER_OPERATION_CREATE_TABLE_UNIQUE_FLAG)
-                               if(!gda_server_operation_set_value_at (op, "TRUE", error, 
"/FIELDS_A/@COLUMN_UNIQUE/%d", i)){
-                                       g_object_unref (op);
-                                       return NULL;
-                               }
-                       if (flag & GDA_SERVER_OPERATION_CREATE_TABLE_FKEY_FLAG) {
-                               gint j;
-                               gchar *fkey_table;
-                               gchar *fkey_ondelete;
-                               gchar *fkey_onupdate;
-
-                               fkey_table = gda_server_operation_create_table_arg_get_column_name (argument);
-                               if (!gda_server_operation_set_value_at (op, fkey_table, error,
-                                                                  "/FKEY_S/%d/FKEY_REF_TABLE", refs)){
-                                       g_object_unref (op);
-                                       return NULL;
-                               }
-
-                               refs++;
-                               GList* lr = gda_server_operation_create_table_arg_get_fkey_refs (argument);
-                               j = 0;
-
-                               while (lr) {
-                                       gchar *field, *rfield;
-                                       GdaServerOperationCreateTableArgFKeyRefField *ref;
-                                       ref = (GdaServerOperationCreateTableArgFKeyRefField*) l->data;
-
-                                       field = 
gda_server_operation_create_table_arg_fkey_ref_field_get_local_field (ref);
-                                       if(!gda_server_operation_set_value_at (op, field, error,
-                                                                          
"/FKEY_S/%d/FKEY_FIELDS_A/@FK_FIELD/%d", refs, j)){
-                                               g_object_unref (op);
-                                               return NULL;
-                                       }
-
-                                       rfield = 
gda_server_operation_create_table_arg_fkey_ref_field_get_referenced_field (ref);
-                                       if(!gda_server_operation_set_value_at (op, rfield, error,
-                                                                          
"/FKEY_S/%d/FKEY_FIELDS_A/@FK_REF_PK_FIELD/%d", refs, j)){
-                                               g_object_unref (op);
-                                               return NULL;
-                                       }
-                                       j++;
-                                       lr = g_list_next (lr);
-                               }
-
-                               fkey_ondelete = gda_server_operation_create_table_arg_get_fkey_ondelete 
(argument);
-                               if (!gda_server_operation_set_value_at (op, fkey_ondelete, error,
-                                                                  "/FKEY_S/%d/FKEY_ONDELETE", refs)){
-                                       g_object_unref (op);
-                                       return NULL;
-                               }
-                               fkey_onupdate = gda_server_operation_create_table_arg_get_fkey_onupdate 
(argument);
-                               if(!gda_server_operation_set_value_at (op, fkey_onupdate, error,
-                                                                  "/FKEY_S/%d/FKEY_ONUPDATE", refs)){
-                                       g_object_unref (op);
-                                       return NULL;
-                               }
-                       }
-
-                       l = g_list_next (l);
-                       i++;
-               }
-
-               g_object_set_data_full (G_OBJECT (op), "_gda_connection", g_object_ref (cnc), g_object_unref);
-
-               return op;
-       }
-       else {
-               g_set_error (error, GDA_SERVER_OPERATION_ERROR, GDA_SERVER_OPERATION_OBJECT_NAME_ERROR,
-                            "%s", _("CREATE TABLE operation is not supported by the database server"));
-               return NULL;
-       }
-}
-
-
-/**
- * gda_server_operation_perform_create_table:
- * @op: a valid #GdaServerOperation
- * @error: a place to store errors, or %NULL
- *
- * Performs a prepared #GdaServerOperation to create a table. This could perform
- * an operation created by #gda_server_operation_prepare_create_table or any other using the
- * the #GdaServerOperation API.
- *
- * Returns: TRUE if the table was created; FALSE and set @error otherwise
- *
- * Since: 4.2.3
- */
-gboolean
-gda_server_operation_perform_create_table (GdaServerOperation *op, GError **error)
-{
-       GdaConnection *cnc;
-
-       g_return_val_if_fail (GDA_IS_SERVER_OPERATION (op), FALSE);
-       g_return_val_if_fail (gda_server_operation_get_op_type (op) == GDA_SERVER_OPERATION_CREATE_TABLE, 
FALSE);
-
-       cnc = g_object_get_data (G_OBJECT (op), "_gda_connection");
-       if (cnc)
-               return gda_server_provider_perform_operation (gda_connection_get_provider (cnc), cnc, op, 
error);
-       else {
-               g_warning ("Could not find operation's associated connection, "
-                          "did you use gda_connection_prepare_create_table() ?");
-               return FALSE;
-       }
-}
-
-/**
- * gda_server_operation_prepare_drop_table:
- * @cnc: an opened connection
- * @table_name: name of the table to drop
- * @error: a place to store errors, or %NULL
- *
- * This is just a convenient function to create a #GdaServerOperation to drop a
- * table in an opened connection.
- *
- * Returns: (transfer full) (nullable): a new #GdaServerOperation or %NULL if couldn't create the 
opereration.
- *
- * Since: 4.2.3
- */
-GdaServerOperation*
-gda_server_operation_prepare_drop_table (GdaConnection *cnc, const gchar *table_name, GError **error)
-{
-       GdaServerOperation *op;
-       GdaServerProvider *server;
-
-       server = gda_connection_get_provider (cnc);
-
-       op = gda_server_provider_create_operation (server, cnc,
-                                                  GDA_SERVER_OPERATION_DROP_TABLE, NULL, error);
-
-       if (GDA_IS_SERVER_OPERATION (op)) {
-               g_return_val_if_fail (table_name != NULL
-                                     || GDA_IS_CONNECTION (cnc)
-                                     || !gda_connection_is_opened (cnc), NULL);
-
-               if (gda_server_operation_set_value_at (op, table_name,
-                                                      error, "/TABLE_DESC_P/TABLE_NAME")) {
-                       g_object_set_data_full (G_OBJECT (op), "_gda_connection", g_object_ref (cnc), 
g_object_unref);
-                       return op;
-               }
-               else
-                       return NULL;
-       }
-       else
-               return NULL;
-}
-
-
-/**
- * gda_server_operation_perform_drop_table:
- * @op: a #GdaServerOperation object
- * @error: a place to store errors, or %NULL
- *
- * This is just a convenient function to perform a drop a table operation.
- *
- * Returns: TRUE if the table was dropped
- *
- * Since: 4.2.3
- */
-gboolean
-gda_server_operation_perform_drop_table (GdaServerOperation *op, GError **error)
-{
-       GdaConnection *cnc;
-
-       g_return_val_if_fail (GDA_IS_SERVER_OPERATION (op), FALSE);
-       g_return_val_if_fail (gda_server_operation_get_op_type (op) == GDA_SERVER_OPERATION_DROP_TABLE, 
FALSE);
-
-       cnc = g_object_get_data (G_OBJECT (op), "_gda_connection");
-       if (cnc)
-               return gda_server_provider_perform_operation (gda_connection_get_provider (cnc), cnc, op, 
error);
-       else {
-               g_warning ("Could not find operation's associated connection, "
-                          "did you use gda_server_operation_prepare_drop_table() ?");
-               return FALSE;
-       }
-}
-
 /**
  * gda_server_operation_perform:
  * @op: a #GdaServerOperation object
diff --git a/libgda/gda-server-operation.h b/libgda/gda-server-operation.h
index ee9476c3e..e443ebc61 100644
--- a/libgda/gda-server-operation.h
+++ b/libgda/gda-server-operation.h
@@ -206,11 +206,9 @@ GdaServerOperationNode    *gda_server_operation_get_node_info           (GdaServ
 const GValue              *gda_server_operation_get_value_at            (GdaServerOperation *op, const gchar 
*path_format, ...);
 const GValue              *gda_server_operation_get_value_at_path       (GdaServerOperation *op, const gchar 
*path);
 gchar                     *gda_server_operation_get_sql_identifier_at   (GdaServerOperation *op,
-                                                                        GdaConnection *cnc, 
GdaServerProvider *prov,
                                                                         const gchar *path_format, GError 
**error,
                                                                         ...);    
 gchar                     *gda_server_operation_get_sql_identifier_at_path (GdaServerOperation *op, 
-                                                                           GdaConnection *cnc, 
GdaServerProvider *prov,
                                                                            const gchar *path, GError 
**error);
 gboolean                   gda_server_operation_set_value_at            (GdaServerOperation *op, const gchar 
*value, 
                                                                         GError **error, const gchar 
*path_format, ...);
@@ -302,13 +300,6 @@ gchar*  gda_server_operation_create_table_arg_fkey_ref_field_get_referenced_fiel
 G_DEPRECATED_FOR(gda_server_operation_create_table_arg_fkey_ref_field_get_type)
 GType   gda_server_operation_create_table_arg_get_fkey_ref_field_get_type (void) G_GNUC_CONST;
 
-
-GdaServerOperation *gda_server_operation_prepare_create_table_v          (GdaConnection *cnc, const gchar 
*table_name, GError **error, ...);
-GdaServerOperation* gda_server_operation_prepare_create_table        (GdaConnection *cnc, const gchar 
*table_name, GList *arguments, GError **error);
-gboolean            gda_server_operation_perform_create_table          (GdaServerOperation *op, GError 
**error);
-GdaServerOperation *gda_server_operation_prepare_drop_table            (GdaConnection *cnc, const gchar 
*table_name, GError **error);
-gboolean            gda_server_operation_perform_drop_table            (GdaServerOperation *op, GError 
**error);
-
 G_END_DECLS
 
 #endif
diff --git a/libgda/gda-statement.c b/libgda/gda-statement.c
index cf6ba802c..6f9f9fabd 100644
--- a/libgda/gda-statement.c
+++ b/libgda/gda-statement.c
@@ -160,7 +160,7 @@ gda_statement_class_init (GdaStatementClass * klass)
                              G_SIGNAL_RUN_FIRST,
                              G_STRUCT_OFFSET (GdaStatementClass, checked),
                              NULL, NULL,
-                             _gda_marshal_VOID__OBJECT_BOOLEAN, G_TYPE_NONE,
+                             _gda_marshal_VOID__BOOLEAN, G_TYPE_NONE,
                              2, GDA_TYPE_CONNECTION, G_TYPE_BOOLEAN);
 
        klass->reset = NULL;
@@ -403,15 +403,23 @@ gda_statement_check_structure (GdaStatement *stmt, GError **error)
        return gda_sql_statement_check_structure (stmt->priv->internal_struct, error);
 }
 
+/**
+ * gda_statement_get_sql_statement:
+ * @stmt: a #GdaStatement
+ *
+ * Returns: internal #GdaSqlStatement structure
+ * Since: 6.0
+ */
+GdaSqlStatement*
+gda_statement_get_sql_statement (GdaStatement *stmt) {
+  return stmt->priv->internal_struct;
+}
+
 /**
  * gda_statement_check_validity:
  * @stmt: a #GdaStatement object
- * @cnc: (allow-none): a #GdaConnection object, or %NULL
  * @error: a place to store errors, or %NULL
  *
- * If @cnc is not %NULL then checks that every object (table, field, function) used in @stmt 
- * actually exists in @cnc's database
- *
  * If @cnc is %NULL, then cleans anything related to @cnc in @stmt.
  *
  * See gda_sql_statement_check_validity() for more information.
@@ -419,15 +427,14 @@ gda_statement_check_structure (GdaStatement *stmt, GError **error)
  * Returns: TRUE if every object actually exists in @cnc's database
  */
 gboolean
-gda_statement_check_validity (GdaStatement *stmt, GdaConnection *cnc, GError **error)
+gda_statement_check_validity (GdaStatement *stmt, GError **error)
 {
        gboolean retval;
        g_return_val_if_fail (GDA_IS_STATEMENT (stmt), FALSE);
        g_return_val_if_fail (stmt->priv, FALSE);
-       g_return_val_if_fail (!cnc || GDA_IS_CONNECTION (cnc), FALSE);
 
-       retval = gda_sql_statement_check_validity (stmt->priv->internal_struct, cnc, error);
-       g_signal_emit (stmt, gda_statement_signals [CHECKED], 0, cnc, retval);
+       retval = gda_sql_statement_check_validity (stmt->priv->internal_struct, error);
+       g_signal_emit (stmt, gda_statement_signals [CHECKED], 0, retval);
 
        return retval;
 }
@@ -444,13 +451,12 @@ gda_statement_check_validity (GdaStatement *stmt, GdaConnection *cnc, GError **e
  * Returns: TRUE if no error occurred
  */
 gboolean
-gda_statement_normalize (GdaStatement *stmt, GdaConnection *cnc, GError **error)
+gda_statement_normalize (GdaStatement *stmt, GError **error)
 {
        g_return_val_if_fail (GDA_IS_STATEMENT (stmt), FALSE);
        g_return_val_if_fail (stmt->priv, FALSE);
-       g_return_val_if_fail (GDA_IS_CONNECTION (cnc), FALSE);
 
-       return gda_sql_statement_normalize (stmt->priv->internal_struct, cnc, error);
+       return gda_sql_statement_normalize (stmt->priv->internal_struct, error);
 }
 
 /**
@@ -784,10 +790,7 @@ default_render_value (const GValue *value, GdaSqlRenderingContext *context, GErr
 {
        if (value && !gda_value_is_null (value)) {
                GdaDataHandler *dh;
-               if (context->provider)
-                       dh = gda_server_provider_get_data_handler_g_type (context->provider, context->cnc, 
G_VALUE_TYPE (value));
-               else                    
-                       dh = gda_data_handler_get_default (G_VALUE_TYPE (value));
+               dh = gda_data_handler_get_default (G_VALUE_TYPE (value));
 
                if (!dh) {
                        if (g_type_is_a (G_VALUE_TYPE (value), GDA_TYPE_DEFAULT))
@@ -841,45 +844,50 @@ default_render_value (const GValue *value, GdaSqlRenderingContext *context, GErr
                return g_strdup ("NULL");
 }
 
+
+GdaSqlRenderingContext *
+gda_statement_to_sql_prepare (GdaStatement *stmt, GdaSet *params,
+                              GdaStatementSqlFlag flags,
+                              GSList **params_used, GError **error)
+{
+       gchar *str;
+       GdaSqlRenderingContext context;
+
+       g_return_val_if_fail (GDA_IS_STATEMENT (stmt), NULL);
+
+       memset (&context, 0, sizeof (context));
+       context.params = params;
+       context.flags = flags;
+       return context;
+}
+
 /**
  * gda_statement_to_sql_extended:
  * @stmt: a #GdaStatement object
- * @cnc: (allow-none): a #GdaConnection object, or %NULL
- * @params: (allow-none): parameters contained in a single #GdaSet object, or %NULL
+ * @params: (nullable): parameters contained in a single #GdaSet object, or %NULL
  * @flags: a set of flags to control the rendering
- * @params_used: (element-type GdaHolder) (out) (transfer container) (allow-none):a place to store the list 
of actual #GdaHolder objects in @params used to do the rendering, or %NULL
+ * @params_used: (element-type GdaHolder) (out) (transfer container) (nullable):a place to store the list of 
actual #GdaHolder objects in @params used to do the rendering, or %NULL
  * @error: a place to store errors, or %NULL
  *
- * Renders @stmt as an SQL statement, with some control on how it is rendered.
- *
- * If @cnc is not %NULL, then the rendered SQL will better be suited to be used by @cnc (in particular
- * it may include some SQL tweaks and/or proprietary extensions specific to the database engine used by 
@cnc):
- * in this case the result is similar to calling gda_connection_statement_to_sql().
+ * Renders @stmt as an SQL statement, default internal representation. See gda_connection_statement_to_sql()
  *
  * Returns: (transfer full): a new string if no error occurred
+ * Since: 6.0
  */
 gchar *
-gda_statement_to_sql_extended (GdaStatement *stmt, GdaConnection *cnc, GdaSet *params,
-                              GdaStatementSqlFlag flags, 
+gda_statement_to_sql_extended (GdaStatement *stmt, GdaSet *params,
+                              GdaStatementSqlFlag flags,
                               GSList **params_used, GError **error)
 {
        gchar *str;
        GdaSqlRenderingContext context;
+       GdaDataHandler *dh;
 
        g_return_val_if_fail (GDA_IS_STATEMENT (stmt), NULL);
-       g_return_val_if_fail (stmt->priv, NULL);
 
        memset (&context, 0, sizeof (context));
        context.params = params;
        context.flags = flags;
-       if (cnc) {
-               if (gda_connection_is_opened (cnc))
-                       return _gda_server_provider_statement_to_sql (gda_connection_get_provider (cnc), cnc,
-                                                                     stmt, params, flags,
-                                                                     params_used, error);
-               else
-                       context.provider = gda_connection_get_provider (cnc);
-       }
 
        str = gda_statement_to_sql_real (stmt, &context, error);
 
@@ -894,6 +902,7 @@ gda_statement_to_sql_extended (GdaStatement *stmt, GdaConnection *cnc, GdaSet *p
                        *params_used = NULL;
                g_slist_free (context.params_used);
        }
+       g_object_unref (dh);
        return str;
 }
 
diff --git a/libgda/gda-statement.h b/libgda/gda-statement.h
index 9adf1028d..08d48e251 100644
--- a/libgda/gda-statement.h
+++ b/libgda/gda-statement.h
@@ -115,7 +115,7 @@ struct _GdaStatementClass
        GObjectClass         parent_class;
 
        /* signals */
-       void   (*checked)   (GdaStatement *stmt, GdaConnection *cnc, gboolean checked);
+       void   (*checked)   (GdaStatement *stmt, gboolean checked);
        void   (*reset)     (GdaStatement *stmt);
 
        /*< private >*/
@@ -156,16 +156,17 @@ GdaStatement       *gda_statement_copy                   (GdaStatement *orig);
 gchar              *gda_statement_serialize              (GdaStatement *stmt);
 
 gboolean            gda_statement_get_parameters         (GdaStatement *stmt, GdaSet **out_params, GError 
**error);
-#define             gda_statement_to_sql(stmt,params,error) gda_statement_to_sql_extended ((stmt), NULL, 
(params), GDA_STATEMENT_SQL_PARAMS_SHORT, NULL, (error))
-gchar              *gda_statement_to_sql_extended        (GdaStatement *stmt, GdaConnection *cnc, 
+#define             gda_statement_to_sql(stmt,params,error) gda_statement_to_sql_extended ((stmt), (params), 
GDA_STATEMENT_SQL_PARAMS_SHORT, NULL, (error))
+gchar              *gda_statement_to_sql_extended       (GdaStatement *stmt,
                                                          GdaSet *params, GdaStatementSqlFlag flags, 
                                                          GSList **params_used, GError **error);
 
 GdaSqlStatementType gda_statement_get_statement_type     (GdaStatement *stmt);
+GdaSqlStatement    *gda_statement_get_sql_statement      (GdaStatement *stmt);
 gboolean            gda_statement_is_useless             (GdaStatement *stmt);
 gboolean            gda_statement_check_structure        (GdaStatement *stmt, GError **error);
-gboolean            gda_statement_check_validity         (GdaStatement *stmt, GdaConnection *cnc, GError 
**error);
-gboolean            gda_statement_normalize              (GdaStatement *stmt, GdaConnection *cnc, GError 
**error);
+gboolean            gda_statement_check_validity         (GdaStatement *stmt, GError **error);
+gboolean            gda_statement_normalize              (GdaStatement *stmt, GError **error);
 
 G_END_DECLS
 
diff --git a/libgda/gda-util.c b/libgda/gda-util.c
index e3482c069..dbb9e5d1a 100644
--- a/libgda/gda-util.c
+++ b/libgda/gda-util.c
@@ -2364,8 +2364,8 @@ static gboolean _sql_identifier_needs_quotes (const gchar *str);
 /**
  * gda_sql_identifier_quote:
  * @id: an SQL identifier
- * @cnc: (allow-none): a #GdaConnection object, or %NULL
- * @prov: (allow-none): a #GdaServerProvider object, or %NULL
+ * @cnc: (nullable): a #GdaConnection object, or %NULL
+ * @prov: (nullable): a #GdaServerProvider object, or %NULL
  * @for_meta_store set to %TRUE if the returned string will be used in a #GdaMetaStore
  * @force_quotes: set to %TRUE to force the returned string to be quoted
  *
diff --git a/libgda/handlers/gda-handler-string.c b/libgda/handlers/gda-handler-string.c
index c8eb533e6..089e51f1b 100644
--- a/libgda/handlers/gda-handler-string.c
+++ b/libgda/handlers/gda-handler-string.c
@@ -58,39 +58,6 @@ gda_handler_string_new (void)
        return (GdaDataHandler *) obj;
 }
 
-/**
- * gda_handler_string_new_with_provider:
- * @prov: a #GdaServerProvider object
- * @cnc: (allow-none): a #GdaConnection object, or %NULL
- *
- * Creates a data handler for strings, which will use some specific methods implemented
- * by the @prov object (possibly also @cnc).
- *
- * Returns: (type GdaHandlerString) (transfer full): the new object
- */
-GdaDataHandler *
-gda_handler_string_new_with_provider (GdaServerProvider *prov, GdaConnection *cnc)
-{
-       GObject *obj;
-       GdaHandlerString *dh;
-
-       g_return_val_if_fail (GDA_IS_SERVER_PROVIDER (prov), NULL);
-       g_return_val_if_fail (!cnc || GDA_IS_CONNECTION (cnc), NULL);
-
-       obj = g_object_new (GDA_TYPE_HANDLER_STRING, NULL);
-       dh = (GdaHandlerString*) obj;
-
-       dh->prov = prov;
-       if (cnc)
-               dh->cnc = cnc;
-
-       g_object_add_weak_pointer (G_OBJECT (prov), (gpointer) &(dh->prov));
-       if (cnc)
-               g_object_add_weak_pointer (G_OBJECT (cnc), (gpointer) &(dh->cnc));
-
-       return (GdaDataHandler *) obj;
-}
-
 static gchar *
 gda_handler_string_get_sql_from_value (GdaDataHandler *iface, const GValue *value)
 {
diff --git a/libgda/handlers/gda-handler-string.h b/libgda/handlers/gda-handler-string.h
index 49757e767..4fe295797 100644
--- a/libgda/handlers/gda-handler-string.h
+++ b/libgda/handlers/gda-handler-string.h
@@ -42,7 +42,6 @@ G_DECLARE_FINAL_TYPE (GdaHandlerString, gda_handler_string, GDA, HANDLER_STRING,
  */
 
 GdaDataHandler *gda_handler_string_new               (void);
-GdaDataHandler *gda_handler_string_new_with_provider (GdaServerProvider *prov, GdaConnection *cnc);
 
 G_END_DECLS
 
diff --git a/libgda/sql-parser/gda-statement-struct-decl.h b/libgda/sql-parser/gda-statement-struct-decl.h
index 44afdbc58..4789e9960 100644
--- a/libgda/sql-parser/gda-statement-struct-decl.h
+++ b/libgda/sql-parser/gda-statement-struct-decl.h
@@ -270,24 +270,6 @@ typedef struct {
 #define GDA_TYPE_SQL_STATEMENT_CONTENTS_INFO gda_sql_statement_contents_info_get_type()
 GType gda_sql_statement_contents_info_get_type (void) G_GNUC_CONST;
 
-/**
- * GdaSqlStatementCheckValidityData:
- *
- * Validation against a dictionary
- */
-typedef struct {
-       GdaConnection *cnc;
-       GdaMetaStore  *store;
-       GdaMetaStruct *mstruct;
-
-       /*< private >*/
-       /* Padding for future expansion */
-       gpointer         _gda_reserved1;
-       gpointer         _gda_reserved2;
-       gpointer         _gda_reserved3;
-       gpointer         _gda_reserved4;
-} GdaSqlStatementCheckValidityData;
-
 G_END_DECLS
 
 #endif
diff --git a/libgda/sql-parser/gda-statement-struct.c b/libgda/sql-parser/gda-statement-struct.c
index 0dc9cbf27..91ce90f3c 100644
--- a/libgda/sql-parser/gda-statement-struct.c
+++ b/libgda/sql-parser/gda-statement-struct.c
@@ -330,15 +330,12 @@ static gboolean gda_sql_select_target_check_validity (GdaSqlSelectTarget *target
 /**
  * gda_sql_statement_check_validity:
  * @stmt: a #GdaSqlStatement pointer
- * @cnc: (nullable): a #GdaConnection object, or %NULL
  * @error: a place to store errors, or %NULL
  *
- * If @cnc is not %NULL, then checks that all the database objects referenced in the statement actually
- * exist in the connection's database (for example the table being updated in a UPDATE statement must exist 
in the
- * connection's database for the check to succeed). This method fills the @stmt-&gt;validity_meta_struct 
attribute.
+ * Checks statement structure.
  *
- * If @cnc is %NULL, then remove any information from a previous call to this method stored in @stmt. In 
this case,
- * the @stmt-&gt;validity_meta_struct attribute is cleared.
+ * Remove any information from a previous call to this method stored in @stmt.
+ * The @stmt-&gt;validity_meta_struct attribute is cleared.
  *
  * Also note that some parts of @stmt may be modified: for example leading and trailing spaces in aliases or
  * objects names will be removed.
@@ -346,10 +343,9 @@ static gboolean gda_sql_select_target_check_validity (GdaSqlSelectTarget *target
  * Returns: TRUE if no error occurred
  */
 gboolean
-gda_sql_statement_check_validity (GdaSqlStatement *stmt, GdaConnection *cnc, GError **error)
+gda_sql_statement_check_validity (GdaSqlStatement *stmt, GError **error)
 {
        g_return_val_if_fail (stmt, FALSE);
-       g_return_val_if_fail (!cnc || GDA_IS_CONNECTION (cnc), FALSE);
 
        /* check the structure first */
        if (!gda_sql_statement_check_structure (stmt, error))
@@ -358,27 +354,11 @@ gda_sql_statement_check_validity (GdaSqlStatement *stmt, GdaConnection *cnc, GEr
        /* clear any previous setting */
        gda_sql_statement_check_clean (stmt);
 
-       if (cnc) {
-               GdaSqlStatementCheckValidityData data;
-               gboolean retval;
-
-               /* prepare data */
-               data.cnc = cnc;
-               data.store = gda_connection_get_meta_store (cnc);
-               data.mstruct = gda_meta_struct_new (data.store, GDA_META_STRUCT_FEATURE_NONE);
-
-               /* attach the GdaMetaStruct to @stmt */
-               stmt->validity_meta_struct = data.mstruct;
-               retval = gda_sql_any_part_foreach (GDA_SQL_ANY_PART (stmt->contents),
-                                                  (GdaSqlForeachFunc) foreach_check_validity, &data, error);
-               return retval;
-       }
-       else
-               return TRUE;
+       return TRUE;
 }
 
 /**
- * gda_sql_statement_check_validity_m
+ * gda_sql_statement_check_validity_m:
  * @stmt: a #GdaSqlStatement pointer
  * @mstruct: (nullable): a #GdaMetaStruct object, or %NULL
  * @error: a place to store errors, or %NULL
@@ -1407,12 +1387,11 @@ gda_sql_any_part_foreach (GdaSqlAnyPart *node, GdaSqlForeachFunc func, gpointer
 }
 
 
-static gboolean foreach_normalize (GdaSqlAnyPart *node, GdaConnection *cnc, GError **error);
+static gboolean foreach_normalize (GdaSqlAnyPart *node, gpointer data, GError **error);
 
 /**
  * gda_sql_statement_normalize:
  * @stmt: a pointer to a #GdaSqlStatement structure
- * @cnc: (nullable): a #GdaConnection object, or %NULL
  * @error: a place to store errors, or %NULL
  *
  * "Normalizes" (in place) some parts of @stmt, which means @stmt may be modified.
@@ -1420,32 +1399,22 @@ static gboolean foreach_normalize (GdaSqlAnyPart *node, GdaConnection *cnc, GErr
  * #GdaSqlSelectField structure for each field in the referenced table.
  *
  * Returns: TRUE if no error occurred
+ * Since: 6.0
  */
 gboolean
-gda_sql_statement_normalize (GdaSqlStatement *stmt, GdaConnection *cnc, GError **error)
+gda_sql_statement_normalize (GdaSqlStatement *stmt, GError **error)
 {
-       gboolean retval;
        g_return_val_if_fail (stmt, FALSE);
 
-       if (!stmt->validity_meta_struct && !gda_sql_statement_check_validity (stmt, cnc, error))
+       if (!stmt->validity_meta_struct && !gda_sql_statement_check_validity (stmt, error))
                return FALSE;
 
-       retval = gda_sql_any_part_foreach (GDA_SQL_ANY_PART (stmt->contents),
-                                          (GdaSqlForeachFunc) foreach_normalize, cnc, error);
-#ifdef GDA_DEBUG
-       GError *lerror = NULL;
-       if (retval && !gda_sql_statement_check_validity (stmt, cnc, &lerror)) {
-               g_warning ("Internal error in %s(): statement is not valid anymore after: %s", __FUNCTION__,
-                          lerror && lerror->message ? lerror->message :  "No detail");
-               if (lerror)
-                       g_error_free (lerror);
-       }
-#endif
-       return retval;
+       return gda_sql_any_part_foreach (GDA_SQL_ANY_PART (stmt->contents),
+                                          (GdaSqlForeachFunc) foreach_normalize, NULL, error);
 }
 
 static gboolean
-foreach_normalize (GdaSqlAnyPart *node, G_GNUC_UNUSED GdaConnection *cnc, GError **error)
+foreach_normalize (GdaSqlAnyPart *node, gpointer data, GError **error)
 {
        if (!node) return TRUE;
 
diff --git a/libgda/sql-parser/gda-statement-struct.h b/libgda/sql-parser/gda-statement-struct.h
index d23dabee2..dce02b753 100644
--- a/libgda/sql-parser/gda-statement-struct.h
+++ b/libgda/sql-parser/gda-statement-struct.h
@@ -61,13 +61,13 @@ const gchar                 *gda_sql_statement_type_to_string (GdaSqlStatementTy
 GdaSqlStatementType          gda_sql_statement_string_to_type (const gchar *type);
 
 gboolean                     gda_sql_statement_check_structure (GdaSqlStatement *stmt, GError **error);
-gboolean                     gda_sql_statement_check_validity  (GdaSqlStatement *stmt, GdaConnection *cnc, 
GError **error);
+gboolean                     gda_sql_statement_check_validity  (GdaSqlStatement *stmt, GError **error);
 gboolean                     gda_sql_statement_check_validity_m (GdaSqlStatement *stmt,
                                                                 GdaMetaStruct *mstruct,
                                                                 GError **error);
 
 void                         gda_sql_statement_check_clean     (GdaSqlStatement *stmt);
-gboolean                     gda_sql_statement_normalize       (GdaSqlStatement *stmt, GdaConnection *cnc, 
GError **error);
+gboolean                     gda_sql_statement_normalize       (GdaSqlStatement *stmt, GError **error);
 
 GdaSqlStatementContentsInfo *gda_sql_statement_get_contents_infos (GdaSqlStatementType type) ;
 
diff --git a/providers/postgres/gda-postgres-ddl.c b/providers/postgres/gda-postgres-ddl.c
index 11f5a783e..9a763465a 100644
--- a/providers/postgres/gda-postgres-ddl.c
+++ b/providers/postgres/gda-postgres-ddl.c
@@ -1103,7 +1103,7 @@ gda_postgres_render_DROP_USER (GdaServerProvider *provider, GdaConnection *cnc,
        if (value && G_VALUE_HOLDS (value, G_TYPE_BOOLEAN) && g_value_get_boolean (value))
                g_string_append (string, " IF EXISTS");
 
-       tmp = gda_server_operation_get_sql_identifier_at (op, cnc, provider,
+       tmp = gda_connection_operation_get_sql_identifier_at (cnc, op, provider,
                                                          "/USER_DESC_P/USER_NAME", error);
        if (!tmp) {
                g_string_free (string, TRUE);
diff --git a/providers/postgres/gda-postgres-provider.c b/providers/postgres/gda-postgres-provider.c
index 5de4f2db1..12cd27bcd 100644
--- a/providers/postgres/gda-postgres-provider.c
+++ b/providers/postgres/gda-postgres-provider.c
@@ -1564,7 +1564,7 @@ gda_postgres_provider_statement_to_sql (GdaServerProvider *provider, GdaConnecti
                g_return_val_if_fail (gda_connection_get_provider (cnc) == provider, NULL);
        }
 
-       return gda_statement_to_sql_extended (stmt, NULL, params, flags, params_used, error);
+       return gda_statement_to_sql_extended (stmt, params, flags, params_used, error);
 }
 
 static gboolean
diff --git a/providers/skel-implementation/capi/gda-capi-ddl.c 
b/providers/skel-implementation/capi/gda-capi-ddl.c
index 30535b748..660ad00e1 100644
--- a/providers/skel-implementation/capi/gda-capi-ddl.c
+++ b/providers/skel-implementation/capi/gda-capi-ddl.c
@@ -43,7 +43,7 @@ gda_capi_render_CREATE_TABLE (GdaServerProvider *provider, GdaConnection *cnc,
        /* CREATE TABLE */
        string = g_string_new ("CREATE TABLE ");
 
-       tmp = gda_server_operation_get_sql_identifier_at (op, cnc, provider, "/TABLE_DEF_P/TABLE_NAME", 
error);
+       tmp = gda_connection_operation_get_sql_identifier_at (cnc, op, "/TABLE_DEF_P/TABLE_NAME", error);
        if (!tmp) {
                g_string_free (string, TRUE);
                return NULL;
diff --git a/providers/skel-implementation/capi/gda-capi-provider.c 
b/providers/skel-implementation/capi/gda-capi-provider.c
index bc12f4981..f891b46da 100644
--- a/providers/skel-implementation/capi/gda-capi-provider.c
+++ b/providers/skel-implementation/capi/gda-capi-provider.c
@@ -994,7 +994,7 @@ gda_capi_provider_statement_to_sql (GdaServerProvider *provider, GdaConnection *
 
        TO_IMPLEMENT;
 
-       return gda_statement_to_sql_extended (stmt, NULL, params, flags, params_used, error);
+       return gda_statement_to_sql_extended (stmt, params, flags, params_used, error);
 }
 
 /*


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