[libgda] data-select: modernization using G_DEFINE/G_DECLARE



commit a0e544ec531c412025e13ed566f906f7dd42e710
Author: Daniel Espinosa Ortiz <esodan gmail com>
Date:   Wed Feb 13 15:08:56 2019 -0600

    data-select: modernization using G_DEFINE/G_DECLARE

 libgda/gda-data-select.c | 1391 ++++++++++++++++++++++------------------------
 libgda/gda-data-select.h |   75 +--
 2 files changed, 708 insertions(+), 758 deletions(-)
---
diff --git a/libgda/gda-data-select.c b/libgda/gda-data-select.c
index 8045c17b6..4f10c821d 100644
--- a/libgda/gda-data-select.c
+++ b/libgda/gda-data-select.c
@@ -96,11 +96,39 @@ typedef struct {
        gint                    current_prow_row;
 } PrivateShareable;
 
+
+/* GdaDataModel interface */
+static void                 gda_data_select_data_model_init (GdaDataModelIface *iface);
+static gint                 gda_data_select_get_n_rows      (GdaDataModel *model);
+static gint                 gda_data_select_get_n_columns   (GdaDataModel *model);
+static GdaColumn           *gda_data_select_describe_column (GdaDataModel *model, gint col);
+static GdaDataModelAccessFlags gda_data_select_get_access_flags(GdaDataModel *model);
+static const GValue        *gda_data_select_get_value_at    (GdaDataModel *model, gint col, gint row, GError 
**error);
+static GdaValueAttribute    gda_data_select_get_attributes_at (GdaDataModel *model, gint col, gint row);
+
+static GdaDataModelIter    *gda_data_select_create_iter     (GdaDataModel *model);
+static gboolean             gda_data_select_iter_next       (GdaDataModel *model, GdaDataModelIter *iter);
+static gboolean             gda_data_select_iter_prev       (GdaDataModel *model, GdaDataModelIter *iter);
+static gboolean             gda_data_select_iter_at_row     (GdaDataModel *model, GdaDataModelIter *iter, 
gint row);
+
+static gboolean             gda_data_select_set_value_at    (GdaDataModel *model, gint col, gint row,
+                                                            const GValue *value, GError **error);
+static gboolean             gda_data_select_set_values      (GdaDataModel *model, gint row, GList *values,
+                                                            GError **error);
+static gint                 gda_data_select_append_values   (GdaDataModel *model, const GList *values, 
GError **error);
+static gboolean             gda_data_select_remove_row      (GdaDataModel *model, gint row, GError **error);
+
+static void                 gda_data_select_freeze          (GdaDataModel *model);
+static void                 gda_data_select_thaw            (GdaDataModel *model);
+static gboolean             gda_data_select_get_notify      (GdaDataModel *model);
+static GError             **gda_data_select_get_exceptions  (GdaDataModel *model);
+
+
 /*
  * Getting a GdaRow from a model row:
  * [model row] ==(model->index)==> [index in model->rows] ==(model->rows)==> [GdaRow pointer]
  */
-struct _GdaDataSelectPrivate {
+typedef struct {
        GdaConnection          *cnc;
        GdaWorker              *worker;
        GdaDataModelIter       *iter;
@@ -111,7 +139,11 @@ struct _GdaDataSelectPrivate {
   GdaPStmt               *prep_stmt; /* use the "prepared-stmt" property to set this */
        gint                    nb_stored_rows; /* number of GdaRow objects currently stored */
        gint                    advertized_nrows; /* set when the number of rows becomes known, -1 until then 
*/
-};
+} GdaDataSelectPrivate;
+
+G_DEFINE_TYPE_WITH_CODE (GdaDataSelect, gda_data_select, G_TYPE_OBJECT,
+                                                                                                
G_ADD_PRIVATE (GdaDataSelect)
+                                                                                                
G_IMPLEMENT_INTERFACE (GDA_TYPE_DATA_MODEL, gda_data_select_data_model_init))
 
 /* properties */
 enum
@@ -148,7 +180,6 @@ GQuark gda_data_select_error_quark (void)
 }
 
 static void gda_data_select_class_init (GdaDataSelectClass *klass);
-static void gda_data_select_init       (GdaDataSelect *model, GdaDataSelectClass *klass);
 static void gda_data_select_dispose    (GObject *object);
 static void gda_data_select_finalize   (GObject *object);
 
@@ -182,35 +213,6 @@ static gboolean vector_set_value_at (GdaDataSelect *imodel, BVector *bv,
                                      GError **error);
 
 
-/* GdaDataModel interface */
-static void                 gda_data_select_data_model_init (GdaDataModelIface *iface);
-static gint                 gda_data_select_get_n_rows      (GdaDataModel *model);
-static gint                 gda_data_select_get_n_columns   (GdaDataModel *model);
-static GdaColumn           *gda_data_select_describe_column (GdaDataModel *model, gint col);
-static GdaDataModelAccessFlags gda_data_select_get_access_flags(GdaDataModel *model);
-static const GValue        *gda_data_select_get_value_at    (GdaDataModel *model, gint col, gint row, GError 
**error);
-static GdaValueAttribute    gda_data_select_get_attributes_at (GdaDataModel *model, gint col, gint row);
-
-static GdaDataModelIter    *gda_data_select_create_iter     (GdaDataModel *model);
-static gboolean             gda_data_select_iter_next       (GdaDataModel *model, GdaDataModelIter *iter);
-static gboolean             gda_data_select_iter_prev       (GdaDataModel *model, GdaDataModelIter *iter);
-static gboolean             gda_data_select_iter_at_row     (GdaDataModel *model, GdaDataModelIter *iter, 
gint row);
-
-static gboolean             gda_data_select_set_value_at    (GdaDataModel *model, gint col, gint row,
-                                                            const GValue *value, GError **error);
-static gboolean             gda_data_select_set_values      (GdaDataModel *model, gint row, GList *values,
-                                                            GError **error);
-static gint                 gda_data_select_append_values   (GdaDataModel *model, const GList *values, 
GError **error);
-static gboolean             gda_data_select_remove_row      (GdaDataModel *model, gint row, GError **error);
-
-static void                 gda_data_select_freeze          (GdaDataModel *model);
-static void                 gda_data_select_thaw            (GdaDataModel *model);
-static gboolean             gda_data_select_get_notify      (GdaDataModel *model);
-static GError             **gda_data_select_get_exceptions  (GdaDataModel *model);
-
-static GObjectClass *parent_class = NULL;
-
-
 G_DEFINE_TYPE(GdaDataSelectIter, gda_data_select_iter, GDA_TYPE_DATA_MODEL_ITER)
 
 static gboolean gda_data_select_iter_move_to_row (GdaDataModelIter *iter, gint row);
@@ -261,7 +263,6 @@ gda_data_select_iter_set_value_at (GdaDataModelIter *iter, gint col,
        g_object_get (G_OBJECT (iter), "data-model", &imodel, NULL);
        g_return_val_if_fail (imodel, FALSE);
 
-       g_return_val_if_fail (imodel->priv, FALSE);
        g_return_val_if_fail (check_data_model_for_updates (imodel, col, value, error), FALSE);
 
        /* BVector */
@@ -274,54 +275,11 @@ gda_data_select_iter_set_value_at (GdaDataModelIter *iter, gint col,
        return vector_set_value_at (imodel, bv, iter, G_MININT, error);
 }
 
-/**
- * gda_data_select_get_type:
- *
- * Returns: the #GType of GdaDataSelect.
- */
-GType
-gda_data_select_get_type (void)
-{
-       static GType type = 0;
-
-       if (G_UNLIKELY (type == 0)) {
-               static GMutex registering;
-               static const GTypeInfo info = {
-                       sizeof (GdaDataSelectClass),
-                       (GBaseInitFunc) NULL,
-                       (GBaseFinalizeFunc) NULL,
-                       (GClassInitFunc) gda_data_select_class_init,
-                       NULL,
-                       NULL,
-                       sizeof (GdaDataSelect),
-                       0,
-                       (GInstanceInitFunc) gda_data_select_init,
-                       0
-               };
-
-               static const GInterfaceInfo data_model_info = {
-                       (GInterfaceInitFunc) gda_data_select_data_model_init,
-                       NULL,
-                       NULL
-               };
-
-               g_mutex_lock (&registering);
-               if (type == 0) {
-                       type = g_type_register_static (G_TYPE_OBJECT, "GdaDataSelect", &info, 
G_TYPE_FLAG_ABSTRACT);
-                       g_type_add_interface_static (type, GDA_TYPE_DATA_MODEL, &data_model_info);
-               }
-               g_mutex_unlock (&registering);
-       }
-       return type;
-}
-
 static void
 gda_data_select_class_init (GdaDataSelectClass *klass)
 {
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-       parent_class = g_type_class_peek_parent (klass);
-
        /* properties */
        object_class->set_property = gda_data_select_set_property;
         object_class->get_property = gda_data_select_get_property;
@@ -424,60 +382,61 @@ gda_data_select_data_model_init (GdaDataModelIface *iface)
 }
 
 static void
-gda_data_select_init (GdaDataSelect *model, G_GNUC_UNUSED GdaDataSelectClass *klass)
+gda_data_select_init (GdaDataSelect *model)
 {
        ModType i;
-
-       model->priv = g_new0 (GdaDataSelectPrivate, 1);
-       model->priv->cnc = NULL;
-       model->priv->worker = NULL;
-       model->priv->exceptions = NULL;
-       model->priv->sh = g_new0 (PrivateShareable, 1);
-       model->priv->sh-> notify_changes = TRUE;
-       model->priv->sh->rows = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
-       model->priv->sh->index = g_hash_table_new_full (g_int_hash, g_int_equal, g_free, NULL);
-       model->priv->prep_stmt = NULL;
-       model->priv->sh->columns = NULL;
-       model->priv->nb_stored_rows = 0;
-       model->priv->advertized_nrows = -1; /* unknown number of rows */
-
-       model->priv->sh->sel_stmt = NULL;
-       model->priv->sh->ext_params = NULL;
-       model->priv->sh->reset_with_ext_params_change = FALSE;
-
-       model->priv->sh->iter_row = G_MININT;
-       model->priv->ext_params_changed_sig_id = 0;
-        model->priv->iter = NULL;
-
-       model->priv->sh->modif_internals = g_new0 (GdaDataSelectInternals, 1);
-       model->priv->sh->modif_internals->safely_locked = FALSE;
-       model->priv->sh->modif_internals->unique_row_condition = NULL;
-       model->priv->sh->modif_internals->insert_to_select_mapping = NULL;
-       model->priv->sh->modif_internals->modif_set = NULL;
-       model->priv->sh->modif_internals->exec_set = NULL;
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (model);
+
+       priv->cnc = NULL;
+       priv->worker = NULL;
+       priv->exceptions = NULL;
+       priv->sh = g_new0 (PrivateShareable, 1);
+       priv->sh-> notify_changes = TRUE;
+       priv->sh->rows = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
+       priv->sh->index = g_hash_table_new_full (g_int_hash, g_int_equal, g_free, NULL);
+       priv->prep_stmt = NULL;
+       priv->sh->columns = NULL;
+       priv->nb_stored_rows = 0;
+       priv->advertized_nrows = -1; /* unknown number of rows */
+
+       priv->sh->sel_stmt = NULL;
+       priv->sh->ext_params = NULL;
+       priv->sh->reset_with_ext_params_change = FALSE;
+
+       priv->sh->iter_row = G_MININT;
+       priv->ext_params_changed_sig_id = 0;
+       priv->iter = NULL;
+
+       priv->sh->modif_internals = g_new0 (GdaDataSelectInternals, 1);
+       priv->sh->modif_internals->safely_locked = FALSE;
+       priv->sh->modif_internals->unique_row_condition = NULL;
+       priv->sh->modif_internals->insert_to_select_mapping = NULL;
+       priv->sh->modif_internals->modif_set = NULL;
+       priv->sh->modif_internals->exec_set = NULL;
        for (i = FIRST_QUERY; i < NB_QUERIES; i++) {
-               model->priv->sh->modif_internals->modif_params[i] = NULL;
-               model->priv->sh->modif_internals->modif_stmts[i] = NULL;
-               model->priv->sh->modif_internals->cols_mod[i] = NULL;
+               priv->sh->modif_internals->modif_params[i] = NULL;
+               priv->sh->modif_internals->modif_stmts[i] = NULL;
+               priv->sh->modif_internals->cols_mod[i] = NULL;
        }
-       model->priv->sh->modif_internals->upd_stmts = NULL;
-       model->priv->sh->modif_internals->ins_stmts = NULL;
-       model->priv->sh->modif_internals->one_row_select_stmt = NULL;
+       priv->sh->modif_internals->upd_stmts = NULL;
+       priv->sh->modif_internals->ins_stmts = NULL;
+       priv->sh->modif_internals->one_row_select_stmt = NULL;
 
-       model->priv->sh->upd_rows = NULL;
-       model->priv->sh->del_rows = NULL;
+       priv->sh->upd_rows = NULL;
+       priv->sh->del_rows = NULL;
 
-       model->priv->sh->ref_count = 1;
+       priv->sh->ref_count = 1;
 
-       model->priv->sh->current_prow = NULL;
-       model->priv->sh->current_prow_row = -1;
+       priv->sh->current_prow = NULL;
+       priv->sh->current_prow_row = -1;
 }
 
 static void
 ext_params_holder_changed_cb (G_GNUC_UNUSED GdaSet *paramlist, G_GNUC_UNUSED GdaHolder *param,
                              GdaDataSelect *model)
 {
-       if (model->priv->sh->reset_with_ext_params_change) {
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (model);
+       if (priv->sh->reset_with_ext_params_change) {
                GError *error = NULL;
                if (! gda_data_select_rerun (model, &error)) {
                        g_warning (_("Could not re-run SELECT statement: %s"),
@@ -490,62 +449,63 @@ ext_params_holder_changed_cb (G_GNUC_UNUSED GdaSet *paramlist, G_GNUC_UNUSED Gda
 static void
 free_private_shared_data (GdaDataSelect *model)
 {
-       if (model->priv->sh == NULL)
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (model);
+       if (priv->sh == NULL)
                return;
 
-       model->priv->sh->ref_count --;
-       if (model->priv->sh->ref_count == 0) {
+       priv->sh->ref_count --;
+       if (priv->sh->ref_count == 0) {
 
-               if (model->priv->sh->sel_stmt) {
-                       g_object_unref (model->priv->sh->sel_stmt);
-                       model->priv->sh->sel_stmt = NULL;
+               if (priv->sh->sel_stmt) {
+                       g_object_unref (priv->sh->sel_stmt);
+                       priv->sh->sel_stmt = NULL;
                }
 
-               if (model->priv->sh->ext_params) {
-                       if (model->priv->ext_params_changed_sig_id) {
-                               g_signal_handler_disconnect (model->priv->sh->ext_params,
-                                                            model->priv->ext_params_changed_sig_id);
-                               model->priv->ext_params_changed_sig_id = 0;
+               if (priv->sh->ext_params) {
+                       if (priv->ext_params_changed_sig_id) {
+                               g_signal_handler_disconnect (priv->sh->ext_params,
+                                                            priv->ext_params_changed_sig_id);
+                               priv->ext_params_changed_sig_id = 0;
                        }
 
-                       g_object_unref (model->priv->sh->ext_params);
-                       model->priv->sh->ext_params = NULL;
+                       g_object_unref (priv->sh->ext_params);
+                       priv->sh->ext_params = NULL;
                }
 
-               if (model->priv->sh->modif_internals) {
-                       _gda_data_select_internals_free (model->priv->sh->modif_internals);
-                       model->priv->sh->modif_internals = NULL;
+               if (priv->sh->modif_internals) {
+                       _gda_data_select_internals_free (priv->sh->modif_internals);
+                       priv->sh->modif_internals = NULL;
                }
 
-               if (model->priv->sh->upd_rows) {
-                       g_hash_table_destroy (model->priv->sh->upd_rows);
-                       model->priv->sh->upd_rows = NULL;
+               if (priv->sh->upd_rows) {
+                       g_hash_table_destroy (priv->sh->upd_rows);
+                       priv->sh->upd_rows = NULL;
                }
 
-               if (model->priv->sh->del_rows) {
-                       g_array_free (model->priv->sh->del_rows, TRUE);
-                       model->priv->sh->del_rows = NULL;
+               if (priv->sh->del_rows) {
+                       g_array_free (priv->sh->del_rows, TRUE);
+                       priv->sh->del_rows = NULL;
                }
-               if (model->priv->sh->rows) {
-                       g_ptr_array_unref (model->priv->sh->rows);
-                       model->priv->sh->rows = NULL;
+               if (priv->sh->rows) {
+                       g_ptr_array_unref (priv->sh->rows);
+                       priv->sh->rows = NULL;
                }
-               if (model->priv->sh->index) {
-                       g_hash_table_destroy (model->priv->sh->index);
-                       model->priv->sh->index = NULL;
+               if (priv->sh->index) {
+                       g_hash_table_destroy (priv->sh->index);
+                       priv->sh->index = NULL;
                }
-               if (model->priv->sh->columns) {
-                       g_slist_free_full (model->priv->sh->columns, (GDestroyNotify) g_object_unref);
-                       model->priv->sh->columns = NULL;
+               if (priv->sh->columns) {
+                       g_slist_free_full (priv->sh->columns, (GDestroyNotify) g_object_unref);
+                       priv->sh->columns = NULL;
                }
 
-               if (model->priv->sh->current_prow) {
-                       g_object_unref (model->priv->sh->current_prow);
-                       model->priv->sh->current_prow = NULL;
+               if (priv->sh->current_prow) {
+                       g_object_unref (priv->sh->current_prow);
+                       priv->sh->current_prow = NULL;
                }
 
-               g_free (model->priv->sh);
-               model->priv->sh = NULL;
+               g_free (priv->sh);
+               priv->sh = NULL;
        }
 }
 
@@ -553,39 +513,40 @@ static void
 gda_data_select_dispose (GObject *object)
 {
        GdaDataSelect *model = (GdaDataSelect *) object;
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (model);
 
        /* free memory */
-       if (model->priv) {
-               if (model->priv->exceptions) {
-                       g_ptr_array_unref (model->priv->exceptions);
-                       model->priv->exceptions = NULL;
+       if (priv) {
+               if (priv->exceptions) {
+                       g_ptr_array_unref (priv->exceptions);
+                       priv->exceptions = NULL;
                }
-               if (model->priv->worker) {
-                       gda_worker_unref (model->priv->worker);
-                       model->priv->worker = NULL;
+               if (priv->worker) {
+                       gda_worker_unref (priv->worker);
+                       priv->worker = NULL;
                }
-               if (model->priv->iter) {
-                       g_object_unref (model->priv->iter);
-                       model->priv->iter = NULL;
+               if (priv->iter) {
+                       g_object_unref (priv->iter);
+                       priv->iter = NULL;
                }
-               if (model->priv->prep_stmt) {
-                       g_object_unref (model->priv->prep_stmt);
-                       model->priv->prep_stmt = NULL;
+               if (priv->prep_stmt) {
+                       g_object_unref (priv->prep_stmt);
+                       priv->prep_stmt = NULL;
                }
-               if (model->priv->ext_params_changed_sig_id) {
-                       g_signal_handler_disconnect (model->priv->sh->ext_params,
-                                                    model->priv->ext_params_changed_sig_id);
-                       model->priv->ext_params_changed_sig_id = 0;
+               if (priv->ext_params_changed_sig_id) {
+                       g_signal_handler_disconnect (priv->sh->ext_params,
+                                                    priv->ext_params_changed_sig_id);
+                       priv->ext_params_changed_sig_id = 0;
                }
                free_private_shared_data (model);
-               if (model->priv->cnc) {
-                       g_object_unref (model->priv->cnc);
-                       model->priv->cnc = NULL;
+               if (priv->cnc) {
+                       g_object_unref (priv->cnc);
+                       priv->cnc = NULL;
                }
        }
 
        /* chain to parent class */
-       parent_class->dispose (object);
+       G_OBJECT_CLASS(gda_data_select_parent_class)->dispose (object);
 }
 
 /*
@@ -601,13 +562,16 @@ gda_data_select_dispose (GObject *object)
  * On the slave side, what happens is:
  *    - "free" slave->priv->sh
  *    - slave->priv->sh = master->priv->sh
+ * FIXME: this features should be removed to improve thread safety
  */
 void
-_gda_data_select_share_private_data (GdaDataSelect *master, GdaDataSelect *slave)
+_gda_data_select_share_private_data (GdaDataSelect *model, GdaDataSelect *slave)
 {
-       master->priv->sh->ref_count ++;
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (model);
+       GdaDataSelectPrivate *privs = gda_data_select_get_instance_private (slave);
+       priv->sh->ref_count ++;
        free_private_shared_data (slave);
-       slave->priv->sh = master->priv->sh;
+       privs->sh = priv->sh;
 }
 
 /*
@@ -618,9 +582,10 @@ void
 _gda_data_select_update_usage_flags (GdaDataSelect *model, GdaDataModelAccessFlags flags)
 {
        GdaDataModelAccessFlags eflags;
-       eflags = model->priv->sh->usage_flags;
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (model);
+       eflags = priv->sh->usage_flags;
        eflags |= flags & (GDA_STATEMENT_MODEL_OFFLINE | GDA_STATEMENT_MODEL_ALLOW_NOPARAM);
-       model->priv->sh->usage_flags = eflags;
+       priv->sh->usage_flags = eflags;
 }
 
 void
@@ -687,24 +652,17 @@ _gda_data_select_internals_free (GdaDataSelectInternals *inter)
 static void
 gda_data_select_finalize (GObject *object)
 {
-       GdaDataSelect *model = (GdaDataSelect *) object;
-
-       /* free memory */
-       if (model->priv) {
-               g_free (model->priv);
-               model->priv = NULL;
-       }
-
        /* chain to parent class */
-       parent_class->finalize (object);
+       G_OBJECT_CLASS (gda_data_select_parent_class)->finalize (object);
 }
 
 GdaDataSelectInternals *
 _gda_data_select_internals_steal (GdaDataSelect *model)
 {
        GdaDataSelectInternals *inter;
-       inter = model->priv->sh->modif_internals;
-       model->priv->sh->modif_internals = NULL;
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (model);
+       inter = priv->sh->modif_internals;
+       priv->sh->modif_internals = NULL;
 
        return inter;
 }
@@ -712,43 +670,45 @@ _gda_data_select_internals_steal (GdaDataSelect *model)
 void
 _gda_data_select_internals_paste (GdaDataSelect *model, GdaDataSelectInternals *inter)
 {
-       if (model->priv->sh->modif_internals)
-               _gda_data_select_internals_free (model->priv->sh->modif_internals);
-       model->priv->sh->modif_internals = inter;
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (model);
+       if (priv->sh->modif_internals)
+               _gda_data_select_internals_free (priv->sh->modif_internals);
+       priv->sh->modif_internals = inter;
 }
 
 static void
 create_columns (GdaDataSelect *model)
 {
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (model);
        gint i;
        ModType m;
-       if (model->priv->sh->columns) {
-               g_slist_free_full (model->priv->sh->columns, (GDestroyNotify) g_object_unref);
-               model->priv->sh->columns = NULL;
+       if (priv->sh->columns) {
+               g_slist_free_full (priv->sh->columns, (GDestroyNotify) g_object_unref);
+               priv->sh->columns = NULL;
        }
        for (m = FIRST_QUERY; m < NB_QUERIES; m++) {
-               g_free (model->priv->sh->modif_internals->cols_mod[m]);
-               model->priv->sh->modif_internals->cols_mod[m] = NULL;
+               g_free (priv->sh->modif_internals->cols_mod[m]);
+               priv->sh->modif_internals->cols_mod[m] = NULL;
        }
-       if (!model->priv->prep_stmt)
+       if (!priv->prep_stmt)
                return;
 
-       if (model->priv->prep_stmt->ncols < 0)
+       if (priv->prep_stmt->ncols < 0)
                g_error (_("INTERNAL implementation error: unknown number of columns in GdaPStmt, \nset 
number of columns before using with GdaDataSelect"));
-       if (model->priv->prep_stmt->tmpl_columns) {
+       if (priv->prep_stmt->tmpl_columns) {
                /* copy template columns */
                GSList *list;
-               for (list = model->priv->prep_stmt->tmpl_columns; list; list = list->next)
-                       model->priv->sh->columns = g_slist_append (model->priv->sh->columns, g_object_ref 
(list->data));
+               for (list = priv->prep_stmt->tmpl_columns; list; list = list->next)
+                       priv->sh->columns = g_slist_append (priv->sh->columns, g_object_ref (list->data));
        }
        else {
                /* create columns */
-               for (i = 0; i < model->priv->prep_stmt->ncols; i++) {
+               for (i = 0; i < priv->prep_stmt->ncols; i++) {
                        GdaColumn *gda_col;
                        gda_col = gda_column_new ();
-                       if (model->priv->prep_stmt->types)
-                               gda_column_set_g_type (gda_col, model->priv->prep_stmt->types [i]);
-                       model->priv->sh->columns = g_slist_append (model->priv->sh->columns, gda_col);
+                       if (priv->prep_stmt->types)
+                               gda_column_set_g_type (gda_col, priv->prep_stmt->types [i]);
+                       priv->sh->columns = g_slist_append (priv->sh->columns, gda_col);
                }
        }
 }
@@ -759,90 +719,91 @@ gda_data_select_set_property (GObject *object,
                              const GValue *value,
                              GParamSpec *pspec)
 {
-       GdaDataSelect *model = (GdaDataSelect *) object;
-       if (model->priv) {
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (GDA_DATA_SELECT (object));
+       if (priv) {
                switch (param_id) {
                case PROP_CNC:
-                       model->priv->cnc = g_value_get_object (value);
-                       if (model->priv->cnc) {
-                               g_object_ref (model->priv->cnc);
-                               model->priv->worker = _gda_connection_get_worker (model->priv->cnc);
-                               g_assert (model->priv->worker);
-                               gda_worker_ref (model->priv->worker);
+                       priv->cnc = g_value_get_object (value);
+                       if (priv->cnc) {
+                               g_object_ref (priv->cnc);
+                               priv->worker = _gda_connection_get_worker (priv->cnc);
+                               g_assert (priv->worker);
+                               gda_worker_ref (priv->worker);
                        }
                        break;
                case PROP_PREP_STMT:
-                       if (model->priv->prep_stmt)
-                               g_object_unref (model->priv->prep_stmt);
-                       model->priv->prep_stmt = g_value_get_object (value);
-                       if (model->priv->prep_stmt) {
+                       if (priv->prep_stmt)
+                               g_object_unref (priv->prep_stmt);
+                       priv->prep_stmt = g_value_get_object (value);
+                       if (priv->prep_stmt) {
                                GdaStatement *sel_stmt;
-                               g_object_ref (model->priv->prep_stmt);
-                               sel_stmt = gda_pstmt_get_gda_statement (model->priv->prep_stmt);
+                               g_object_ref (priv->prep_stmt);
+                               sel_stmt = gda_pstmt_get_gda_statement (priv->prep_stmt);
                                if (sel_stmt &&
                                    gda_statement_get_statement_type (sel_stmt) == GDA_SQL_STATEMENT_SELECT) {
-                                       model->priv->sh->sel_stmt = gda_statement_copy (sel_stmt);
+                                       priv->sh->sel_stmt = gda_statement_copy (sel_stmt);
                                        g_object_unref (sel_stmt);
                                                }
                        }
-                       create_columns (model);
+                       create_columns (GDA_DATA_SELECT (object));
                        break;
                case PROP_FLAGS: {
-                       GdaDataModelAccessFlags flags = g_value_get_uint (value);
-                       if (!(flags & GDA_DATA_MODEL_ACCESS_RANDOM) &&
-                           (flags & GDA_DATA_MODEL_ACCESS_CURSOR_BACKWARD))
-                               flags = GDA_DATA_MODEL_ACCESS_CURSOR;
-                       model->priv->sh->usage_flags = flags;
+                               GdaDataModelAccessFlags flags = g_value_get_uint (value);
+                               if (!(flags & GDA_DATA_MODEL_ACCESS_RANDOM) &&
+                                         (flags & GDA_DATA_MODEL_ACCESS_CURSOR_BACKWARD)) {
+                                       flags = GDA_DATA_MODEL_ACCESS_CURSOR;
+                               }
+                               priv->sh->usage_flags = flags;
+                       }
                        break;
-               }
                case PROP_ALL_STORED:
                        if (g_value_get_boolean (value))
-                               gda_data_select_prepare_for_offline (model, NULL);
+                               gda_data_select_prepare_for_offline (GDA_DATA_SELECT (object), NULL);
                        break;
                case PROP_PARAMS: {
                        GdaSet *set;
                        set = g_value_get_object (value);
                        if (set) {
-                               model->priv->sh->ext_params = g_object_ref (set);
-                               model->priv->ext_params_changed_sig_id =
-                                       g_signal_connect (model->priv->sh->ext_params, "holder-changed",
-                                                         G_CALLBACK (ext_params_holder_changed_cb), model);
-                               model->priv->sh->modif_internals->exec_set = gda_set_copy (set);
+                               priv->sh->ext_params = g_object_ref (set);
+                               priv->ext_params_changed_sig_id =
+                                       g_signal_connect (priv->sh->ext_params, "holder-changed",
+                                                         G_CALLBACK (ext_params_holder_changed_cb), 
GDA_DATA_SELECT (object));
+                               priv->sh->modif_internals->exec_set = gda_set_copy (set);
                        }
                        break;
                }
                case PROP_INS_QUERY:
-                       if (model->priv->sh->modif_internals->modif_stmts [INS_QUERY])
-                               g_object_unref (model->priv->sh->modif_internals->modif_stmts [INS_QUERY]);
-                       model->priv->sh->modif_internals->modif_stmts [INS_QUERY] = g_value_get_object 
(value);
-                       if (model->priv->sh->modif_internals->modif_stmts [INS_QUERY])
-                               g_object_ref (model->priv->sh->modif_internals->modif_stmts [INS_QUERY]);
-                       g_free (model->priv->sh->modif_internals->cols_mod [INS_QUERY]);
-                       model->priv->sh->modif_internals->cols_mod[INS_QUERY] = NULL;
+                       if (priv->sh->modif_internals->modif_stmts [INS_QUERY])
+                               g_object_unref (priv->sh->modif_internals->modif_stmts [INS_QUERY]);
+                       priv->sh->modif_internals->modif_stmts [INS_QUERY] = g_value_get_object (value);
+                       if (priv->sh->modif_internals->modif_stmts [INS_QUERY])
+                               g_object_ref (priv->sh->modif_internals->modif_stmts [INS_QUERY]);
+                       g_free (priv->sh->modif_internals->cols_mod [INS_QUERY]);
+                       priv->sh->modif_internals->cols_mod[INS_QUERY] = NULL;
                        break;
                case PROP_DEL_QUERY:
-                       if (model->priv->sh->modif_internals->modif_stmts [DEL_QUERY])
-                               g_object_unref (model->priv->sh->modif_internals->modif_stmts [DEL_QUERY]);
-                       model->priv->sh->modif_internals->modif_stmts [DEL_QUERY] = g_value_get_object 
(value);
-                       if (model->priv->sh->modif_internals->modif_stmts [DEL_QUERY])
-                               g_object_ref (model->priv->sh->modif_internals->modif_stmts [DEL_QUERY]);
-                       g_free (model->priv->sh->modif_internals->cols_mod[DEL_QUERY]);
-                       model->priv->sh->modif_internals->cols_mod[DEL_QUERY] = NULL;
+                       if (priv->sh->modif_internals->modif_stmts [DEL_QUERY])
+                               g_object_unref (priv->sh->modif_internals->modif_stmts [DEL_QUERY]);
+                       priv->sh->modif_internals->modif_stmts [DEL_QUERY] = g_value_get_object (value);
+                       if (priv->sh->modif_internals->modif_stmts [DEL_QUERY])
+                               g_object_ref (priv->sh->modif_internals->modif_stmts [DEL_QUERY]);
+                       g_free (priv->sh->modif_internals->cols_mod[DEL_QUERY]);
+                       priv->sh->modif_internals->cols_mod[DEL_QUERY] = NULL;
                        break;
                case PROP_UPD_QUERY:
-                       if (model->priv->sh->modif_internals->modif_stmts [UPD_QUERY])
-                               g_object_unref (model->priv->sh->modif_internals->modif_stmts [UPD_QUERY]);
-                       model->priv->sh->modif_internals->modif_stmts [UPD_QUERY] = g_value_get_object 
(value);
-                       if (model->priv->sh->modif_internals->modif_stmts [UPD_QUERY])
-                               g_object_ref (model->priv->sh->modif_internals->modif_stmts [UPD_QUERY]);
-                       g_free (model->priv->sh->modif_internals->cols_mod[UPD_QUERY]);
-                       model->priv->sh->modif_internals->cols_mod[UPD_QUERY] = NULL;
+                       if (priv->sh->modif_internals->modif_stmts [UPD_QUERY])
+                               g_object_unref (priv->sh->modif_internals->modif_stmts [UPD_QUERY]);
+                       priv->sh->modif_internals->modif_stmts [UPD_QUERY] = g_value_get_object (value);
+                       if (priv->sh->modif_internals->modif_stmts [UPD_QUERY])
+                               g_object_ref (priv->sh->modif_internals->modif_stmts [UPD_QUERY]);
+                       g_free (priv->sh->modif_internals->cols_mod[UPD_QUERY]);
+                       priv->sh->modif_internals->cols_mod[UPD_QUERY] = NULL;
                        break;
                case PROP_RESET_WITH_EXT_PARAM:
-                       model->priv->sh->reset_with_ext_params_change = g_value_get_boolean (value);
+                       priv->sh->reset_with_ext_params_change = g_value_get_boolean (value);
                        break;
                case PROP_EXEC_DELAY:
-                       model->priv->exec_time = g_value_get_double (value);
+                       priv->exec_time = g_value_get_double (value);
                        break;
                default:
                        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
@@ -858,46 +819,47 @@ gda_data_select_get_property (GObject *object,
                              GParamSpec *pspec)
 {
        GdaDataSelect *model = (GdaDataSelect *) object;
-       if (model->priv) {
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (model);
+       if (priv) {
                switch (param_id) {
                case PROP_CNC:
-                       g_value_set_object (value, model->priv->cnc);
+                       g_value_set_object (value, priv->cnc);
                        break;
                case PROP_PREP_STMT:
-                       g_value_set_object (value, model->priv->prep_stmt);
+                       g_value_set_object (value, priv->prep_stmt);
                        break;
                case PROP_FLAGS:
-                       g_value_set_uint (value, model->priv->sh->usage_flags);
+                       g_value_set_uint (value, priv->sh->usage_flags);
                        break;
                case PROP_ALL_STORED:
-                       if (!model->priv->sh->usage_flags & GDA_DATA_MODEL_ACCESS_RANDOM)
+                       if (!(priv->sh->usage_flags & GDA_DATA_MODEL_ACCESS_RANDOM))
                                g_warning ("Cannot set the 'store-all-rows' property when access mode is 
cursor based");
                        else {
-                               if ((model->priv->advertized_nrows < 0) && CLASS (model)->fetch_nb_rows)
+                               if ((priv->advertized_nrows < 0) && CLASS (model)->fetch_nb_rows)
                                        _gda_data_select_fetch_nb_rows (model);
-                               g_value_set_boolean (value, model->priv->nb_stored_rows == 
model->priv->advertized_nrows);
+                               g_value_set_boolean (value, priv->nb_stored_rows == priv->advertized_nrows);
                        }
                        break;
                case PROP_PARAMS:
-                       g_value_set_object (value, model->priv->sh->modif_internals->exec_set);
+                       g_value_set_object (value, priv->sh->modif_internals->exec_set);
                        break;
                case PROP_INS_QUERY:
-                       g_value_set_object (value, model->priv->sh->modif_internals->modif_stmts [INS_QUERY]);
+                       g_value_set_object (value, priv->sh->modif_internals->modif_stmts [INS_QUERY]);
                        break;
                case PROP_DEL_QUERY:
-                       g_value_set_object (value, model->priv->sh->modif_internals->modif_stmts [DEL_QUERY]);
+                       g_value_set_object (value, priv->sh->modif_internals->modif_stmts [DEL_QUERY]);
                        break;
                case PROP_UPD_QUERY:
-                       g_value_set_object (value, model->priv->sh->modif_internals->modif_stmts [UPD_QUERY]);
+                       g_value_set_object (value, priv->sh->modif_internals->modif_stmts [UPD_QUERY]);
                        break;
                case PROP_SEL_STMT:
                        g_value_set_object (value, check_acceptable_statement (model, NULL));
                        break;
                case PROP_RESET_WITH_EXT_PARAM:
-                       g_value_set_boolean (value, model->priv->sh->reset_with_ext_params_change);
+                       g_value_set_boolean (value, priv->sh->reset_with_ext_params_change);
                        break;
                case PROP_EXEC_DELAY:
-                       g_value_set_double (value, model->priv->exec_time);
+                       g_value_set_double (value, priv->exec_time);
                        break;
                default:
                        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
@@ -922,6 +884,7 @@ gda_data_select_take_row (GdaDataSelect *model, GdaRow *row, gint rownum)
 {
        g_return_if_fail (GDA_IS_DATA_SELECT (model));
        g_return_if_fail (GDA_IS_ROW (row));
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (model);
 
        gint tmp, *ptr;
        GdaRow *erow;
@@ -929,7 +892,7 @@ gda_data_select_take_row (GdaDataSelect *model, GdaRow *row, gint rownum)
        g_return_if_fail (GDA_IS_ROW (row));
 
        tmp = rownum;
-       erow = g_hash_table_lookup (model->priv->sh->index, &tmp);
+       erow = g_hash_table_lookup (priv->sh->index, &tmp);
        if (erow) {
                if (row != erow)
                        g_object_unref (row);
@@ -938,10 +901,10 @@ gda_data_select_take_row (GdaDataSelect *model, GdaRow *row, gint rownum)
 
        ptr = g_new (gint, 2);
        ptr [0] = rownum;
-       ptr [1] = model->priv->sh->rows->len;
-       g_hash_table_insert (model->priv->sh->index, ptr, ptr+1);
-       g_ptr_array_add (model->priv->sh->rows, row);
-       model->priv->nb_stored_rows = model->priv->sh->rows->len;
+       ptr [1] = priv->sh->rows->len;
+       g_hash_table_insert (priv->sh->index, ptr, ptr+1);
+       g_ptr_array_add (priv->sh->rows, row);
+       priv->nb_stored_rows = priv->sh->rows->len;
 }
 
 /**
@@ -958,12 +921,12 @@ gda_data_select_get_stored_row (GdaDataSelect *model, gint rownum)
 {
        gint irow, *ptr;
        g_return_val_if_fail (GDA_IS_DATA_SELECT (model), NULL);
-       g_return_val_if_fail (model->priv, NULL);
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (model);
 
        irow = rownum;
-       ptr = g_hash_table_lookup (model->priv->sh->index, &irow);
+       ptr = g_hash_table_lookup (priv->sh->index, &irow);
        if (ptr)
-               return g_ptr_array_index (model->priv->sh->rows, *ptr);
+               return g_ptr_array_index (priv->sh->rows, *ptr);
        else
                return NULL;
 }
@@ -981,9 +944,9 @@ 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);
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (model);
 
-       return model->priv->cnc;
+       return priv->cnc;
 }
 
 /**
@@ -1003,62 +966,63 @@ gda_data_select_set_columns (GdaDataSelect *model, GSList *columns)
 {
        ModType m;
        g_return_if_fail (GDA_IS_DATA_SELECT (model));
-       g_return_if_fail (model->priv);
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (model);
 
-       if (model->priv->sh->columns) {
-               g_slist_free_full (model->priv->sh->columns, (GDestroyNotify) g_object_unref);
-               model->priv->sh->columns = NULL;
+       if (priv->sh->columns) {
+               g_slist_free_full (priv->sh->columns, (GDestroyNotify) g_object_unref);
+               priv->sh->columns = NULL;
        }
        for (m = FIRST_QUERY; m < NB_QUERIES; m++) {
-               g_free (model->priv->sh->modif_internals->cols_mod[m]);
-               model->priv->sh->modif_internals->cols_mod[m] = NULL;
+               g_free (priv->sh->modif_internals->cols_mod[m]);
+               priv->sh->modif_internals->cols_mod[m] = NULL;
        }
-       model->priv->sh->columns = columns;
+       priv->sh->columns = columns;
 }
 
 /*
- * Add the +/-<col num> holders to model->priv->sh->modif_internals->modif_set
+ * Add the +/-<col num> holders to priv->sh->modif_internals->modif_set
  */
 static gboolean
 compute_modif_set (GdaDataSelect *model, GError **error)
 {
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (model);
        gint i;
 
-       if (model->priv->sh->modif_internals->modif_set) {
-               g_object_unref (model->priv->sh->modif_internals->modif_set);
-               model->priv->sh->modif_internals->modif_set = NULL;
+       if (priv->sh->modif_internals->modif_set) {
+               g_object_unref (priv->sh->modif_internals->modif_set);
+               priv->sh->modif_internals->modif_set = NULL;
        }
-       if (model->priv->sh->modif_internals->exec_set)
-               model->priv->sh->modif_internals->modif_set = gda_set_copy 
(model->priv->sh->modif_internals->exec_set);
+       if (priv->sh->modif_internals->exec_set)
+               priv->sh->modif_internals->modif_set = gda_set_copy (priv->sh->modif_internals->exec_set);
        else
-               model->priv->sh->modif_internals->modif_set = gda_set_new (NULL);
+               priv->sh->modif_internals->modif_set = gda_set_new (NULL);
 
        for (i = 0; i < NB_QUERIES; i++) {
-               if (model->priv->sh->modif_internals->modif_params [i]) {
-                       g_slist_free (model->priv->sh->modif_internals->modif_params [i]);
-                       model->priv->sh->modif_internals->modif_params [i] = NULL;
+               if (priv->sh->modif_internals->modif_params [i]) {
+                       g_slist_free (priv->sh->modif_internals->modif_params [i]);
+                       priv->sh->modif_internals->modif_params [i] = NULL;
                }
        }
 
        for (i = 0; i < NB_QUERIES; i++) {
                GdaSet *set;
-               if (! model->priv->sh->modif_internals->modif_stmts [i])
+               if (! priv->sh->modif_internals->modif_stmts [i])
                        continue;
-               if (! gda_statement_get_parameters (model->priv->sh->modif_internals->modif_stmts [i], &set, 
error)) {
-                       g_object_unref (model->priv->sh->modif_internals->modif_set);
-                       model->priv->sh->modif_internals->modif_set = NULL;
+               if (! gda_statement_get_parameters (priv->sh->modif_internals->modif_stmts [i], &set, error)) 
{
+                       g_object_unref (priv->sh->modif_internals->modif_set);
+                       priv->sh->modif_internals->modif_set = NULL;
                        return FALSE;
                }
 
-               gda_set_merge_with_set (model->priv->sh->modif_internals->modif_set, set);
+               gda_set_merge_with_set (priv->sh->modif_internals->modif_set, set);
 
                GSList *list;
                for (list = gda_set_get_holders (set); list; list = list->next) {
                        GdaHolder *holder;
-                       holder = gda_set_get_holder (model->priv->sh->modif_internals->modif_set,
+                       holder = gda_set_get_holder (priv->sh->modif_internals->modif_set,
                                                     gda_holder_get_id ((GdaHolder*) list->data));
-                       model->priv->sh->modif_internals->modif_params [i] =
-                               g_slist_prepend (model->priv->sh->modif_internals->modif_params [i], holder);
+                       priv->sh->modif_internals->modif_params [i] =
+                               g_slist_prepend (priv->sh->modif_internals->modif_params [i], holder);
                }
                g_object_unref (set);
        }
@@ -1066,13 +1030,13 @@ compute_modif_set (GdaDataSelect *model, GError **error)
 #ifdef GDA_DEBUG_NO
        GSList *list;
        g_print ("-------\n");
-       for (list = model->priv->sh->modif_internals->modif_set->holders; list; list = list->next) {
+       for (list = priv->sh->modif_internals->modif_set->holders; list; list = list->next) {
                GdaHolder *h = GDA_HOLDER (list->data);
                g_print ("=> holder '%s'\n", gda_holder_get_id (h));
        }
        for (i = 0; i < NB_QUERIES; i++) {
                g_print ("   MOD %d\n", i);
-               for (list = model->priv->sh->modif_internals->modif_params [i]; list; list = list->next) {
+               for (list = priv->sh->modif_internals->modif_params [i]; list; list = list->next) {
                        GdaHolder *h = GDA_HOLDER (list->data);
                        g_print ("\t=> holder '%s'\n", gda_holder_get_id (h));
                }
@@ -1131,13 +1095,13 @@ gda_data_select_set_modification_statement_sql (GdaDataSelect *model, const gcha
        gboolean retval;
 
        g_return_val_if_fail (GDA_IS_DATA_SELECT (model), FALSE);
-       g_return_val_if_fail (model->priv, FALSE);
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (model);
 
        /* check the original SELECT statement which was executed is not a compound statement */
        if (! check_acceptable_statement (model, error))
                return FALSE;
 
-       parser = gda_connection_create_parser (model->priv->cnc);
+       parser = gda_connection_create_parser (priv->cnc);
        if (!parser)
                parser = gda_sql_parser_new ();
 
@@ -1167,17 +1131,18 @@ static GdaStatement *
 check_acceptable_statement (GdaDataSelect *model, GError **error)
 {
        GdaStatement *sel_stmt;
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (model);
 
-       if (model->priv->sh->sel_stmt)
-               return model->priv->sh->sel_stmt;
+       if (priv->sh->sel_stmt)
+               return priv->sh->sel_stmt;
 
-       if (! model->priv->prep_stmt) {
+       if (! priv->prep_stmt) {
                g_set_error (error, GDA_DATA_SELECT_ERROR, GDA_DATA_SELECT_MODIFICATION_STATEMENT_ERROR,
                             "%s", _("Internal error: the \"prepared-stmt\" property has not been set"));
                return NULL;
        }
 
-       sel_stmt = gda_pstmt_get_gda_statement (model->priv->prep_stmt);
+       sel_stmt = gda_pstmt_get_gda_statement (priv->prep_stmt);
        if (! sel_stmt) {
                g_set_error (error, GDA_DATA_SELECT_ERROR, GDA_DATA_SELECT_MODIFICATION_STATEMENT_ERROR,
                              "%s", _("Can't get the prepared statement's actual statement"));
@@ -1190,9 +1155,9 @@ check_acceptable_statement (GdaDataSelect *model, GError **error)
                return NULL;
        }
 
-       model->priv->sh->sel_stmt = gda_statement_copy (sel_stmt);
+       priv->sh->sel_stmt = gda_statement_copy (sel_stmt);
        g_object_unref (sel_stmt);
-       return model->priv->sh->sel_stmt;
+       return priv->sh->sel_stmt;
 }
 
 /**
@@ -1257,8 +1222,8 @@ gda_data_select_set_modification_statement (GdaDataSelect *model, GdaStatement *
        gboolean coltypeschanged = FALSE;
 
        g_return_val_if_fail (GDA_IS_DATA_SELECT (model), FALSE);
-       g_return_val_if_fail (model->priv, FALSE);
        g_return_val_if_fail (GDA_IS_STATEMENT (mod_stmt), FALSE);
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (model);
 
        /* check the original SELECT statement which was executed is not a compound statement */
        if (! check_acceptable_statement (model, error))
@@ -1298,14 +1263,14 @@ gda_data_select_set_modification_statement (GdaDataSelect *model, GdaStatement *
 
                mtype = DEL_QUERY;
 
-               /* if there is no WHERE part, then use model->priv->sh->modif_internals->unique_row_condition 
if set */
+               /* if there is no WHERE part, then use priv->sh->modif_internals->unique_row_condition if set 
*/
                g_object_get (G_OBJECT (mod_stmt), "structure", &sqlst, NULL);
                g_assert (sqlst);
                del = (GdaSqlStatementDelete*) sqlst->contents;
                if (!del->cond) {
-                       if (model->priv->sh->modif_internals->unique_row_condition) {
-                               /* copy model->priv->sh->modif_internals->unique_row_condition */
-                               del->cond = gda_sql_expr_copy 
(model->priv->sh->modif_internals->unique_row_condition);
+                       if (priv->sh->modif_internals->unique_row_condition) {
+                               /* copy priv->sh->modif_internals->unique_row_condition */
+                               del->cond = gda_sql_expr_copy 
(priv->sh->modif_internals->unique_row_condition);
                                GDA_SQL_ANY_PART (del->cond)->parent = GDA_SQL_ANY_PART (del);
                                g_object_set (G_OBJECT (mod_stmt), "structure", sqlst, NULL);
                        }
@@ -1317,10 +1282,10 @@ gda_data_select_set_modification_statement (GdaDataSelect *model, GdaStatement *
                        }
                }
                else {
-                       if (model->priv->sh->modif_internals->unique_row_condition) {
-                               /* replace WHERE with model->priv->sh->modif_internals->unique_row_condition 
*/
+                       if (priv->sh->modif_internals->unique_row_condition) {
+                               /* replace WHERE with priv->sh->modif_internals->unique_row_condition */
                                gda_sql_expr_free (del->cond);
-                               del->cond = gda_sql_expr_copy 
(model->priv->sh->modif_internals->unique_row_condition);
+                               del->cond = gda_sql_expr_copy 
(priv->sh->modif_internals->unique_row_condition);
                                GDA_SQL_ANY_PART (del->cond)->parent = GDA_SQL_ANY_PART (del);
                                g_object_set (G_OBJECT (mod_stmt), "structure", sqlst, NULL);
                        }
@@ -1338,14 +1303,14 @@ gda_data_select_set_modification_statement (GdaDataSelect *model, GdaStatement *
 
                mtype = UPD_QUERY;
 
-               /* if there is no WHERE part, then use model->priv->sh->modif_internals->unique_row_condition 
if set */
+               /* if there is no WHERE part, then use priv->sh->modif_internals->unique_row_condition if set 
*/
                g_object_get (G_OBJECT (mod_stmt), "structure", &sqlst, NULL);
                g_assert (sqlst);
                upd = (GdaSqlStatementUpdate*) sqlst->contents;
                if (!upd->cond) {
-                       if (model->priv->sh->modif_internals->unique_row_condition) {
-                               /* copy model->priv->sh->modif_internals->unique_row_condition */
-                               upd->cond = gda_sql_expr_copy 
(model->priv->sh->modif_internals->unique_row_condition);
+                       if (priv->sh->modif_internals->unique_row_condition) {
+                               /* copy priv->sh->modif_internals->unique_row_condition */
+                               upd->cond = gda_sql_expr_copy 
(priv->sh->modif_internals->unique_row_condition);
                                GDA_SQL_ANY_PART (upd->cond)->parent = GDA_SQL_ANY_PART (upd);
                                g_object_set (G_OBJECT (mod_stmt), "structure", sqlst, NULL);
                        }
@@ -1357,10 +1322,10 @@ gda_data_select_set_modification_statement (GdaDataSelect *model, GdaStatement *
                        }
                }
                else {
-                       if (model->priv->sh->modif_internals->unique_row_condition) {
-                               /* replace WHERE with model->priv->sh->modif_internals->unique_row_condition 
*/
+                       if (priv->sh->modif_internals->unique_row_condition) {
+                               /* replace WHERE with priv->sh->modif_internals->unique_row_condition */
                                gda_sql_expr_free (upd->cond);
-                               upd->cond = gda_sql_expr_copy 
(model->priv->sh->modif_internals->unique_row_condition);
+                               upd->cond = gda_sql_expr_copy 
(priv->sh->modif_internals->unique_row_condition);
                                GDA_SQL_ANY_PART (upd->cond)->parent = GDA_SQL_ANY_PART (upd);
                                g_object_set (G_OBJECT (mod_stmt), "structure", sqlst, NULL);
                        }
@@ -1381,22 +1346,22 @@ gda_data_select_set_modification_statement (GdaDataSelect *model, GdaStatement *
                        return FALSE;
 
                /* check that all the parameters required to execute @mod_stmt are in
-                * model->priv->sh->modif_internals->modif_set */
+                * priv->sh->modif_internals->modif_set */
                GdaSet *params;
                GSList *list, *params_to_add = NULL;
                if (! gda_statement_get_parameters (mod_stmt, &params, error))
                        return FALSE;
-               if (! model->priv->sh->modif_internals->modif_set) {
-                       if (model->priv->sh->modif_internals->exec_set)
-                               model->priv->sh->modif_internals->modif_set = gda_set_copy 
(model->priv->sh->modif_internals->exec_set);
+               if (! priv->sh->modif_internals->modif_set) {
+                       if (priv->sh->modif_internals->exec_set)
+                               priv->sh->modif_internals->modif_set = gda_set_copy 
(priv->sh->modif_internals->exec_set);
                        else
-                               model->priv->sh->modif_internals->modif_set = gda_set_new (NULL);
+                               priv->sh->modif_internals->modif_set = gda_set_new (NULL);
                }
 
                for (list = gda_set_get_holders (params); list; list = list->next) {
                        GdaHolder *holder = GDA_HOLDER (list->data);
                        GdaHolder *eholder;
-                       eholder = gda_set_get_holder (model->priv->sh->modif_internals->modif_set,
+                       eholder = gda_set_get_holder (priv->sh->modif_internals->modif_set,
                                                      gda_holder_get_id (holder));
                        if (!eholder) {
                                gint num;
@@ -1456,38 +1421,38 @@ gda_data_select_set_modification_statement (GdaDataSelect *model, GdaStatement *
                                        gda_column_set_g_type (gdacol, gda_holder_get_g_type (holder));
                                        coltypeschanged = TRUE;
                                }
-                               if (model->priv->prep_stmt && model->priv->prep_stmt->types &&
-                                   (model->priv->prep_stmt->types [num] == GDA_TYPE_NULL))
-                                       model->priv->prep_stmt->types [num] = gda_holder_get_g_type (holder);
+                               if (priv->prep_stmt && priv->prep_stmt->types &&
+                                   (priv->prep_stmt->types [num] == GDA_TYPE_NULL))
+                                       priv->prep_stmt->types [num] = gda_holder_get_g_type (holder);
                        }
                }
 
                /* all ok, accept the modif statement */
-               if (model->priv->sh->modif_internals->modif_stmts[mtype]) {
-                       g_object_unref (model->priv->sh->modif_internals->modif_stmts[mtype]);
-                       model->priv->sh->modif_internals->modif_stmts[mtype] = NULL;
+               if (priv->sh->modif_internals->modif_stmts[mtype]) {
+                       g_object_unref (priv->sh->modif_internals->modif_stmts[mtype]);
+                       priv->sh->modif_internals->modif_stmts[mtype] = NULL;
                }
-               model->priv->sh->modif_internals->modif_stmts[mtype] = mod_stmt;
+               priv->sh->modif_internals->modif_stmts[mtype] = mod_stmt;
                g_object_ref (mod_stmt);
                ModType m;
                for (m = FIRST_QUERY; m < NB_QUERIES; m++) {
-                       g_free (model->priv->sh->modif_internals->cols_mod[m]);
-                       model->priv->sh->modif_internals->cols_mod[m] = NULL;
+                       g_free (priv->sh->modif_internals->cols_mod[m]);
+                       priv->sh->modif_internals->cols_mod[m] = NULL;
                }
 
                if (params_to_add) {
                        for (list = params_to_add; list; list = list->next) {
-                               gda_set_add_holder (model->priv->sh->modif_internals->modif_set,
+                               gda_set_add_holder (priv->sh->modif_internals->modif_set,
                                                    GDA_HOLDER (list->data));
-                               model->priv->sh->modif_internals->modif_params[mtype] =
-                                       g_slist_prepend 
(model->priv->sh->modif_internals->modif_params[mtype],
+                               priv->sh->modif_internals->modif_params[mtype] =
+                                       g_slist_prepend (priv->sh->modif_internals->modif_params[mtype],
                                                         list->data);
                        }
                        g_slist_free (params_to_add);
                }
                g_object_unref (params);
 
-               /* prepare model->priv->sh->modif_internals->modif_set */
+               /* prepare priv->sh->modif_internals->modif_set */
                if (!compute_modif_set (model, error))
                        return FALSE;
        }
@@ -1500,8 +1465,8 @@ gda_data_select_set_modification_statement (GdaDataSelect *model, GdaStatement *
 #ifdef GDA_DEBUG_NO
        GSList *hlist;
        g_print ("SET MODIF QUERY\n");
-       if (model->priv->sh->modif_internals->modif_set) {
-               for (hlist = model->priv->sh->modif_internals->modif_set->holders; hlist;
+       if (priv->sh->modif_internals->modif_set) {
+               for (hlist = priv->sh->modif_internals->modif_set->holders; hlist;
                     hlist = hlist->next) {
                        GdaHolder *h = GDA_HOLDER (hlist->data);
                        const GValue *defval;
@@ -1570,31 +1535,31 @@ gda_data_select_compute_modification_statements_ext (GdaDataSelect *model,
        gboolean retval = TRUE;
        GdaStatement *modif_stmts[NB_QUERIES];
        g_return_val_if_fail (GDA_IS_DATA_SELECT (model), FALSE);
-       g_return_val_if_fail (model->priv, FALSE);
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (model);
 
        stmt = check_acceptable_statement (model, error);
        if (!stmt)
                return FALSE;
 
-       if (!model->priv->cnc) {
+       if (!priv->cnc) {
                g_set_error (error, GDA_DATA_SELECT_ERROR, GDA_DATA_SELECT_CONNECTION_ERROR,
                              "%s", _("No connection to use"));
                return FALSE;
        }
        for (mtype = FIRST_QUERY; mtype < NB_QUERIES; mtype++) {
-               if (model->priv->sh->modif_internals->modif_stmts[mtype]) {
-                       g_object_unref (model->priv->sh->modif_internals->modif_stmts[mtype]);
-                       model->priv->sh->modif_internals->modif_stmts[mtype] = NULL;
+               if (priv->sh->modif_internals->modif_stmts[mtype]) {
+                       g_object_unref (priv->sh->modif_internals->modif_stmts[mtype]);
+                       priv->sh->modif_internals->modif_stmts[mtype] = NULL;
                }
-               g_free (model->priv->sh->modif_internals->cols_mod[mtype]);
-               model->priv->sh->modif_internals->cols_mod[mtype] = NULL;
+               g_free (priv->sh->modif_internals->cols_mod[mtype]);
+               priv->sh->modif_internals->cols_mod[mtype] = NULL;
        }
 
-       retval = gda_compute_dml_statements (model->priv->cnc, stmt,
+       retval = gda_compute_dml_statements (priv->cnc, stmt,
                                             cond_type == GDA_DATA_SELECT_COND_PK ? TRUE : FALSE,
                                             &(modif_stmts[INS_QUERY]),
                                             NULL, NULL, error);
-       retval = gda_compute_dml_statements (model->priv->cnc, stmt,
+       retval = gda_compute_dml_statements (priv->cnc, stmt,
                                             cond_type == GDA_DATA_SELECT_COND_PK ? TRUE : FALSE,
                                             NULL,
                                             &(modif_stmts[UPD_QUERY]),
@@ -1622,8 +1587,8 @@ gda_data_select_compute_modification_statements_ext (GdaDataSelect *model,
                        g_object_unref (modif_stmts[mtype]);
                        modif_stmts[mtype] = NULL;
                }
-               g_free (model->priv->sh->modif_internals->cols_mod[mtype]);
-               model->priv->sh->modif_internals->cols_mod[mtype] = NULL;
+               g_free (priv->sh->modif_internals->cols_mod[mtype]);
+               priv->sh->modif_internals->cols_mod[mtype] = NULL;
        }
 
        return retval;
@@ -1664,13 +1629,13 @@ gda_data_select_set_row_selection_condition  (GdaDataSelect *model, GdaSqlExpr *
        gboolean valid;
 
        g_return_val_if_fail (GDA_IS_DATA_SELECT (model), FALSE);
-       g_return_val_if_fail (model->priv, FALSE);
        g_return_val_if_fail (expr, FALSE);
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (model);
 
        if (!check_acceptable_statement (model, error))
                return FALSE;
 
-       if (model->priv->sh->modif_internals->unique_row_condition) {
+       if (priv->sh->modif_internals->unique_row_condition) {
                g_set_error (error, GDA_DATA_SELECT_ERROR, GDA_DATA_SELECT_MODIFICATION_STATEMENT_ERROR,
                              "%s", _("Unique row condition has already been specified"));
                return FALSE;
@@ -1682,7 +1647,7 @@ gda_data_select_set_row_selection_condition  (GdaDataSelect *model, GdaSqlExpr *
        if (!valid)
                return FALSE;
 
-       model->priv->sh->modif_internals->unique_row_condition = gda_sql_expr_copy (expr);
+       priv->sh->modif_internals->unique_row_condition = gda_sql_expr_copy (expr);
        return TRUE;
 }
 
@@ -1720,18 +1685,18 @@ gda_data_select_set_row_selection_condition_sql (GdaDataSelect *model, const gch
        GdaSqlStatementSelect *selstmt;
 
        g_return_val_if_fail (GDA_IS_DATA_SELECT (model), FALSE);
-       g_return_val_if_fail (model->priv, FALSE);
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (model);
 
        if (!check_acceptable_statement (model, error))
                return FALSE;
 
-       if (model->priv->sh->modif_internals->unique_row_condition) {
+       if (priv->sh->modif_internals->unique_row_condition) {
                g_set_error (error, GDA_DATA_SELECT_ERROR, GDA_DATA_SELECT_MODIFICATION_STATEMENT_ERROR,
                              "%s", _("Unique row condition has already been specified"));
                return FALSE;
        }
 
-       parser = gda_connection_create_parser (model->priv->cnc);
+       parser = gda_connection_create_parser (priv->cnc);
        if (!parser)
                parser = gda_sql_parser_new ();
 
@@ -1792,13 +1757,13 @@ gda_data_select_compute_row_selection_condition (GdaDataSelect *model, GError **
        GValue *nvalue = NULL;
 
        g_return_val_if_fail (GDA_IS_DATA_SELECT (model), FALSE);
-       g_return_val_if_fail (model->priv, FALSE);
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (model);
 
        stmt = check_acceptable_statement (model, error);
        if (!stmt)
                return FALSE;
 
-       if (!model->priv->cnc) {
+       if (!priv->cnc) {
                g_set_error (error, GDA_DATA_SELECT_ERROR, GDA_DATA_SELECT_CONNECTION_ERROR,
                              "%s", _("No connection to use"));
                return FALSE;
@@ -1824,7 +1789,7 @@ gda_data_select_compute_row_selection_condition (GdaDataSelect *model, GError **
                goto out;
        }
        g_value_set_string ((nvalue = gda_value_new (G_TYPE_STRING)), target->table_name);
-       mstruct = (GdaMetaStruct*) g_object_new (GDA_TYPE_META_STRUCT, "meta-store", 
gda_connection_get_meta_store (model->priv->cnc), "features", GDA_META_STRUCT_FEATURE_NONE, NULL);
+       mstruct = (GdaMetaStruct*) g_object_new (GDA_TYPE_META_STRUCT, "meta-store", 
gda_connection_get_meta_store (priv->cnc), "features", GDA_META_STRUCT_FEATURE_NONE, NULL);
        dbo = gda_meta_struct_complement (mstruct, GDA_META_DB_TABLE, NULL, NULL, nvalue, error);
        if (!dbo)
                goto out;
@@ -1847,20 +1812,18 @@ gda_data_select_compute_row_selection_condition (GdaDataSelect *model, GError **
 static gint
 gda_data_select_get_n_rows (GdaDataModel *model)
 {
-       GdaDataSelect *imodel;
        gint retval;
 
-       imodel = GDA_DATA_SELECT (model);
-       g_return_val_if_fail (imodel->priv, 0);
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (GDA_DATA_SELECT (model));
 
-       retval = imodel->priv->advertized_nrows;
-       if ((imodel->priv->advertized_nrows < 0) &&
-           (imodel->priv->sh->usage_flags & GDA_DATA_MODEL_ACCESS_RANDOM) &&
+       retval = priv->advertized_nrows;
+       if ((priv->advertized_nrows < 0) &&
+           (priv->sh->usage_flags & GDA_DATA_MODEL_ACCESS_RANDOM) &&
            CLASS (model)->fetch_nb_rows)
-               retval = _gda_data_select_fetch_nb_rows (imodel);
+               retval = _gda_data_select_fetch_nb_rows (GDA_DATA_SELECT (model));
 
-       if ((retval > 0) && (imodel->priv->sh->del_rows))
-               retval -= imodel->priv->sh->del_rows->len;
+       if ((retval > 0) && (priv->sh->del_rows))
+               retval -= priv->sh->del_rows->len;
        return retval;
 }
 
@@ -1869,51 +1832,46 @@ gda_data_select_get_n_columns (GdaDataModel *model)
 {
        GdaDataSelect *imodel;
 
-       imodel = GDA_DATA_SELECT (model);
-       g_return_val_if_fail (imodel->priv, 0);
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (GDA_DATA_SELECT (model));
 
-       if (imodel->priv->prep_stmt)
-               return imodel->priv->prep_stmt->ncols;
+       if (priv->prep_stmt)
+               return priv->prep_stmt->ncols;
 
-       return g_slist_length (imodel->priv->sh->columns);
+       return g_slist_length (priv->sh->columns);
 }
 
 static GdaColumn *
 gda_data_select_describe_column (GdaDataModel *model, gint col)
 {
-       GdaDataSelect *imodel;
-
-       imodel = GDA_DATA_SELECT (model);
-       g_return_val_if_fail (imodel->priv, NULL);
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (GDA_DATA_SELECT (model));
 
-       return g_slist_nth_data (imodel->priv->sh->columns, col);
+       return g_slist_nth_data (priv->sh->columns, col);
 }
 
 static GdaDataModelAccessFlags
 gda_data_select_get_access_flags (GdaDataModel *model)
 {
-       GdaDataSelect *imodel;
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (GDA_DATA_SELECT (model));
        GdaDataModelAccessFlags flags = 0;
 
-       imodel = GDA_DATA_SELECT (model);
-       g_return_val_if_fail (imodel->priv, 0);
+       g_return_val_if_fail (priv, 0);
 
-       if (imodel->priv->sh->usage_flags & GDA_DATA_MODEL_ACCESS_RANDOM)
+       if (priv->sh->usage_flags & GDA_DATA_MODEL_ACCESS_RANDOM)
                flags = GDA_DATA_MODEL_ACCESS_RANDOM;
-       else if (imodel->priv->sh->usage_flags & GDA_DATA_MODEL_ACCESS_CURSOR_FORWARD) {
-               if (imodel->priv->sh->usage_flags & GDA_DATA_MODEL_ACCESS_CURSOR_BACKWARD)
+       else if (priv->sh->usage_flags & GDA_DATA_MODEL_ACCESS_CURSOR_FORWARD) {
+               if (priv->sh->usage_flags & GDA_DATA_MODEL_ACCESS_CURSOR_BACKWARD)
                        flags = GDA_DATA_MODEL_ACCESS_CURSOR;
                else
                        flags = GDA_DATA_MODEL_ACCESS_CURSOR_FORWARD;
        }
 
-       if (! imodel->priv->sh->modif_internals->safely_locked &&
-           (imodel->priv->sh->usage_flags & GDA_DATA_MODEL_ACCESS_RANDOM)) {
-               if (imodel->priv->sh->modif_internals->modif_stmts [UPD_QUERY])
+       if (! priv->sh->modif_internals->safely_locked &&
+           (priv->sh->usage_flags & GDA_DATA_MODEL_ACCESS_RANDOM)) {
+               if (priv->sh->modif_internals->modif_stmts [UPD_QUERY])
                        flags |= GDA_DATA_MODEL_ACCESS_UPDATE;
-               if (imodel->priv->sh->modif_internals->modif_stmts [INS_QUERY])
+               if (priv->sh->modif_internals->modif_stmts [INS_QUERY])
                        flags |= GDA_DATA_MODEL_ACCESS_INSERT;
-               if (imodel->priv->sh->modif_internals->modif_stmts [DEL_QUERY])
+               if (priv->sh->modif_internals->modif_stmts [DEL_QUERY])
                        flags |= GDA_DATA_MODEL_ACCESS_DELETE;
        }
 
@@ -1929,12 +1887,13 @@ external_to_internal_row (GdaDataSelect *model, gint ext_row, GError **error)
 {
        gint nrows;
        gint int_row = ext_row;
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (model);
 
        /* row number alteration: deleted rows */
-       if (model->priv->sh->del_rows) {
+       if (priv->sh->del_rows) {
                gint i;
-               for (i = 0; (guint)i < model->priv->sh->del_rows->len; i++) {
-                       gint indexed = g_array_index (model->priv->sh->del_rows, gint, i);
+               for (i = 0; (guint)i < priv->sh->del_rows->len; i++) {
+                       gint indexed = g_array_index (priv->sh->del_rows, gint, i);
                        if (indexed <= ext_row + i)
                                int_row += 1;
                        else
@@ -1943,8 +1902,8 @@ external_to_internal_row (GdaDataSelect *model, gint ext_row, GError **error)
        }
 
        /* check row number validity */
-       nrows = model->priv->advertized_nrows < 0 ? gda_data_select_get_n_rows ((GdaDataModel*) model) :
-               model->priv->advertized_nrows;
+       nrows = priv->advertized_nrows < 0 ? gda_data_select_get_n_rows ((GdaDataModel*) model) :
+               priv->advertized_nrows;
        if ((ext_row < 0) || ((nrows >= 0) && (int_row >= nrows))) {
                gint n;
                n = gda_data_select_get_n_rows ((GdaDataModel*) model);
@@ -1974,9 +1933,10 @@ static void foreach_func_dump (gpointer key, gpointer value, gpointer dummy)
 }
 static void dump_d (GdaDataSelect *model)
 {
-       if (model->priv->sh->upd_rows) {
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (model);
+       if (priv->sh->upd_rows) {
                g_print ("Delayed SELECT for data model %p:\n", model);
-               g_hash_table_foreach (model->priv->sh->upd_rows, foreach_func_dump, NULL);
+               g_hash_table_foreach (priv->sh->upd_rows, foreach_func_dump, NULL);
        }
 }
 #endif
@@ -1986,13 +1946,11 @@ gda_data_select_get_value_at (GdaDataModel *model, gint col, gint row, GError **
 {
        GdaRow *prow;
        gint int_row;
-       GdaDataSelect *imodel;
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (GDA_DATA_SELECT (model));
 
-       imodel = (GdaDataSelect *) model;
-       g_return_val_if_fail (imodel->priv, NULL);
 
        /* available only if GDA_DATA_MODEL_ACCESS_RANDOM */
-       if (! (imodel->priv->sh->usage_flags & GDA_DATA_MODEL_ACCESS_RANDOM)) {
+       if (! (priv->sh->usage_flags & GDA_DATA_MODEL_ACCESS_RANDOM)) {
                g_set_error (error, GDA_DATA_MODEL_ERROR, GDA_DATA_MODEL_ACCESS_ERROR,
                              "%s", _("Data model does only support random access"));
                return NULL;
@@ -2005,7 +1963,7 @@ gda_data_select_get_value_at (GdaDataModel *model, gint col, gint row, GError **
                 return NULL;
        }
 
-       int_row = external_to_internal_row (imodel, row, NULL);
+       int_row = external_to_internal_row (GDA_DATA_SELECT (model), row, NULL);
        if (int_row < 0) {
                gint n;
                n = gda_data_select_get_n_rows ( model);
@@ -2022,8 +1980,8 @@ gda_data_select_get_value_at (GdaDataModel *model, gint col, gint row, GError **
 #ifdef GDA_DEBUG_NO
        dump_d (imodel);
 #endif
-       if (imodel->priv->sh->upd_rows)
-               dstmt = g_hash_table_lookup (imodel->priv->sh->upd_rows, &int_row);
+       if (priv->sh->upd_rows)
+               dstmt = g_hash_table_lookup (priv->sh->upd_rows, &int_row);
        if (dstmt) {
                if (! dstmt->row) {
                        if (dstmt->exec_error) {
@@ -2041,14 +1999,14 @@ gda_data_select_get_value_at (GdaDataModel *model, gint col, gint row, GError **
                                return NULL;
                        }
                        GType *types = NULL;
-                       if (imodel->priv->prep_stmt && imodel->priv->prep_stmt->types) {
-                               types = g_new (GType, imodel->priv->prep_stmt->ncols + 1);
-                               memcpy (types, imodel->priv->prep_stmt->types, /* Flawfinder: ignore */
-                                       sizeof (GType) * imodel->priv->prep_stmt->ncols);
-                               types [imodel->priv->prep_stmt->ncols] = G_TYPE_NONE;
+                       if (priv->prep_stmt && priv->prep_stmt->types) {
+                               types = g_new (GType, priv->prep_stmt->ncols + 1);
+                               memcpy (types, priv->prep_stmt->types, /* Flawfinder: ignore */
+                                       sizeof (GType) * priv->prep_stmt->ncols);
+                               types [priv->prep_stmt->ncols] = G_TYPE_NONE;
                        }
                        /*g_print ("*** Executing DelayedSelectStmt %p\n", dstmt);*/
-                       tmpmodel = gda_connection_statement_execute_select_full (imodel->priv->cnc,
+                       tmpmodel = gda_connection_statement_execute_select_full (priv->cnc,
                                                                                 dstmt->select,
                                                                                 dstmt->params,
                                                                                 
GDA_STATEMENT_MODEL_RANDOM_ACCESS,
@@ -2062,7 +2020,7 @@ gda_data_select_get_value_at (GdaDataModel *model, gint col, gint row, GError **
                                              "%s", _("Unable to retrieve data after modifications, no 
further modification will be allowed"));
                                if (error)
                                        g_propagate_error (error, g_error_copy (dstmt->exec_error));
-                               imodel->priv->sh->modif_internals->safely_locked = TRUE;
+                               priv->sh->modif_internals->safely_locked = TRUE;
                                return NULL;
                        }
 
@@ -2073,7 +2031,7 @@ gda_data_select_get_value_at (GdaDataModel *model, gint col, gint row, GError **
                                             "%s", _("Unable to retrieve data after modifications, no further 
modification will be allowed"));
                                if (error)
                                        g_propagate_error (error, g_error_copy (dstmt->exec_error));
-                               imodel->priv->sh->modif_internals->safely_locked = TRUE;
+                               priv->sh->modif_internals->safely_locked = TRUE;
                                return NULL;
                        }
 
@@ -2104,7 +2062,7 @@ gda_data_select_get_value_at (GdaDataModel *model, gint col, gint row, GError **
                                                if (error)
                                                        g_propagate_error (error,
                                                                           g_error_copy (dstmt->exec_error));
-                                               imodel->priv->sh->modif_internals->safely_locked = TRUE;
+                                               priv->sh->modif_internals->safely_locked = TRUE;
                                                return NULL;
                                        }
                                }
@@ -2119,9 +2077,9 @@ gda_data_select_get_value_at (GdaDataModel *model, gint col, gint row, GError **
                        prow = dstmt->row;
        }
        else {
-               prow = gda_data_select_get_stored_row (imodel, int_row);
+               prow = gda_data_select_get_stored_row (GDA_DATA_SELECT (model), int_row);
                if (!prow && CLASS (model)->fetch_random)
-                       _gda_data_select_fetch_random (imodel, &prow, int_row, error);
+                       _gda_data_select_fetch_random (GDA_DATA_SELECT (model), &prow, int_row, error);
        }
        if (!prow)
                return NULL;
@@ -2137,13 +2095,11 @@ static GdaValueAttribute
 gda_data_select_get_attributes_at (GdaDataModel *model, gint col, gint row)
 {
        GdaValueAttribute flags = GDA_VALUE_ATTR_IS_UNCHANGED;
-       GdaDataSelect *imodel;
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (GDA_DATA_SELECT (model));
 
-       imodel = (GdaDataSelect *) model;
-       g_return_val_if_fail (imodel->priv, 0);
-       GdaColumn *gdacol = g_slist_nth_data (imodel->priv->sh->columns, col);
+       GdaColumn *gdacol = g_slist_nth_data (priv->sh->columns, col);
 
-       if (imodel->priv->sh->modif_internals->safely_locked)
+       if (priv->sh->modif_internals->safely_locked)
                flags = GDA_VALUE_ATTR_NO_MODIF;
        else {
                GdaStatement *stmt = NULL;
@@ -2154,28 +2110,28 @@ gda_data_select_get_attributes_at (GdaDataModel *model, gint col, gint row)
                }
                else
                        m = UPD_QUERY;
-               stmt = imodel->priv->sh->modif_internals->modif_stmts [m];
+               stmt = priv->sh->modif_internals->modif_stmts [m];
                gboolean nomod = TRUE;
                if (stmt) {
-                       if (! imodel->priv->sh->modif_internals->cols_mod [m]) {
+                       if (! priv->sh->modif_internals->cols_mod [m]) {
                                GdaSet *set;
                                gint ncols;
-                               ncols = g_slist_length (imodel->priv->sh->columns);
-                               imodel->priv->sh->modif_internals->cols_mod[m] = g_new0 (gboolean, ncols);
+                               ncols = g_slist_length (priv->sh->columns);
+                               priv->sh->modif_internals->cols_mod[m] = g_new0 (gboolean, ncols);
                                if (gda_statement_get_parameters (stmt, &set, NULL) && set) {
                                        gchar *tmp;
                                        gint i;
                                        for (i = 0; i < ncols; i++) {
                                                tmp = g_strdup_printf ("+%d", i);
                                                if (gda_set_get_holder (set, tmp))
-                                                       imodel->priv->sh->modif_internals->cols_mod[m][i] = 
TRUE;
+                                                       priv->sh->modif_internals->cols_mod[m][i] = TRUE;
                                                g_free (tmp);
                                        }
                                        g_object_unref (set);
                                }
                        }
                        if (gdacol)
-                               nomod = ! imodel->priv->sh->modif_internals->cols_mod[m][col];
+                               nomod = ! priv->sh->modif_internals->cols_mod[m][col];
                }
                if (nomod)
                        flags |= GDA_VALUE_ATTR_NO_MODIF;
@@ -2193,23 +2149,20 @@ gda_data_select_get_attributes_at (GdaDataModel *model, gint col, gint row)
 static GdaDataModelIter *
 gda_data_select_create_iter (GdaDataModel *model)
 {
-       GdaDataSelect *imodel;
-
-       imodel = (GdaDataSelect *) model;
-       g_return_val_if_fail (imodel->priv, 0);
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (GDA_DATA_SELECT (model));
 
-       if (imodel->priv->sh->usage_flags & GDA_DATA_MODEL_ACCESS_RANDOM) {
+       if (priv->sh->usage_flags & GDA_DATA_MODEL_ACCESS_RANDOM) {
                return GDA_DATA_MODEL_ITER (g_object_new (GDA_TYPE_DATA_SELECT_ITER,
                                                          "data-model", model, NULL));
        }
        else {
                /* Create the iter if necessary, or just return the existing iter: */
-               if (imodel->priv->iter == NULL) {
-                       imodel->priv->iter = GDA_DATA_MODEL_ITER (g_object_new (GDA_TYPE_DATA_SELECT_ITER,
+               if (priv->iter == NULL) {
+                       priv->iter = GDA_DATA_MODEL_ITER (g_object_new (GDA_TYPE_DATA_SELECT_ITER,
                                                                                "data-model", model, NULL));
-                       imodel->priv->sh->iter_row = -1;
+                       priv->sh->iter_row = -1;
                }
-               return imodel->priv->iter;
+               return priv->iter;
        }
 }
 
@@ -2217,42 +2170,39 @@ static void update_iter (GdaDataSelect *imodel, GdaRow *prow);
 static gboolean
 gda_data_select_iter_next (GdaDataModel *model, GdaDataModelIter *iter)
 {
-       GdaDataSelect *imodel;
        GdaRow *prow = NULL;
        gint target_iter_row;
        gint int_row;
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (GDA_DATA_SELECT (model));
 
-       imodel = (GdaDataSelect *) model;
-       g_return_val_if_fail (imodel->priv, FALSE);
-
-       if (imodel->priv->sh->usage_flags & GDA_DATA_MODEL_ACCESS_RANDOM)
+       if (priv->sh->usage_flags & GDA_DATA_MODEL_ACCESS_RANDOM)
                return gda_data_model_iter_move_next_default (model, iter);
 
        g_return_val_if_fail (CLASS (model)->fetch_next, FALSE);
        g_return_val_if_fail (iter, FALSE);
 
-       if (imodel->priv->sh->iter_row == G_MAXINT) {
+       if (priv->sh->iter_row == G_MAXINT) {
                gda_data_model_iter_invalidate_contents (iter);
                return FALSE;
        }
-       else if (imodel->priv->sh->iter_row == G_MININT)
+       else if (priv->sh->iter_row == G_MININT)
                target_iter_row = 0;
        else
-               target_iter_row = imodel->priv->sh->iter_row + 1;
+               target_iter_row = priv->sh->iter_row + 1;
 
-       int_row = external_to_internal_row (imodel, target_iter_row, NULL);
-       prow = gda_data_select_get_stored_row (imodel, int_row);
+       int_row = external_to_internal_row (GDA_DATA_SELECT (model), target_iter_row, NULL);
+       prow = gda_data_select_get_stored_row (GDA_DATA_SELECT (model), int_row);
        if (!prow)
-               _gda_data_select_fetch_next (imodel, &prow, int_row, NULL);
+               _gda_data_select_fetch_next (GDA_DATA_SELECT (model), &prow, int_row, NULL);
 
        if (prow) {
-               imodel->priv->sh->iter_row = target_iter_row;
-                update_iter (imodel, prow);
+               priv->sh->iter_row = target_iter_row;
+                update_iter (GDA_DATA_SELECT (model), prow);
                return TRUE;
        }
        else {
                gda_data_model_iter_invalidate_contents (iter);
-               imodel->priv->sh->iter_row = G_MAXINT;
+               priv->sh->iter_row = G_MAXINT;
                g_object_set (G_OBJECT (iter), "current-row", -1, NULL);
                g_signal_emit_by_name (iter, "end-of-data");
                 return FALSE;
@@ -2262,102 +2212,98 @@ gda_data_select_iter_next (GdaDataModel *model, GdaDataModelIter *iter)
 static gboolean
 gda_data_select_iter_prev (GdaDataModel *model, GdaDataModelIter *iter)
 {
-       GdaDataSelect *imodel;
        GdaRow *prow = NULL;
        gint target_iter_row;
        gint int_row;
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (GDA_DATA_SELECT (model));
 
-       imodel = (GdaDataSelect *) model;
-       g_return_val_if_fail (imodel->priv, FALSE);
-
-       if (imodel->priv->sh->usage_flags & GDA_DATA_MODEL_ACCESS_RANDOM)
+       if (priv->sh->usage_flags & GDA_DATA_MODEL_ACCESS_RANDOM)
                return gda_data_model_iter_move_prev_default (model, iter);
 
        g_return_val_if_fail (iter, FALSE);
 
-        if (imodel->priv->sh->iter_row <= 0)
-                goto prev_error;
-        else if (imodel->priv->sh->iter_row == G_MAXINT) {
-                g_assert (imodel->priv->advertized_nrows >= 0);
-                target_iter_row = imodel->priv->advertized_nrows - 1;
-        }
-        else
-                target_iter_row = imodel->priv->sh->iter_row - 1;
+       if (priv->sh->iter_row <= 0)
+               goto prev_error;
+       else if (priv->sh->iter_row == G_MAXINT) {
+               g_assert (priv->advertized_nrows >= 0);
+               target_iter_row = priv->advertized_nrows - 1;
+       }
+       else
+               target_iter_row = priv->sh->iter_row - 1;
 
-       int_row = external_to_internal_row (imodel, target_iter_row, NULL);
-       prow = gda_data_select_get_stored_row (imodel, int_row);
+       int_row = external_to_internal_row (GDA_DATA_SELECT (model), target_iter_row, NULL);
+       prow = gda_data_select_get_stored_row (GDA_DATA_SELECT (model), int_row);
        if (!prow) {
                if (! CLASS (model)->fetch_prev) {
                        gda_data_model_iter_invalidate_contents (iter);
                        return FALSE;
                }
-               _gda_data_select_fetch_prev (imodel, &prow, int_row, NULL);
+               _gda_data_select_fetch_prev (GDA_DATA_SELECT (model), &prow, int_row, NULL);
        }
 
        if (prow) {
-               imodel->priv->sh->iter_row = target_iter_row;
-                update_iter (imodel, prow);
+               priv->sh->iter_row = target_iter_row;
+               update_iter (GDA_DATA_SELECT (model), prow);
                return TRUE;
        }
 
  prev_error:
-        g_object_set (G_OBJECT (iter), "current-row", -1, NULL);
-        imodel->priv->sh->iter_row = G_MININT;
+       g_object_set (G_OBJECT (iter), "current-row", -1, NULL);
+       priv->sh->iter_row = G_MININT;
        gda_data_model_iter_invalidate_contents (iter);
-        return FALSE;
+       return FALSE;
 }
 
 static gboolean
 gda_data_select_iter_at_row (GdaDataModel *model, GdaDataModelIter *iter, gint row)
 {
-       GdaDataSelect *imodel;
        GdaRow *prow = NULL;
        gint int_row;
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (GDA_DATA_SELECT (model));
 
-       imodel = (GdaDataSelect *) model;
-       g_return_val_if_fail (imodel->priv, FALSE);
+       g_return_val_if_fail (priv, FALSE);
 
-       if (imodel->priv->sh->usage_flags & GDA_DATA_MODEL_ACCESS_RANDOM)
+       if (priv->sh->usage_flags & GDA_DATA_MODEL_ACCESS_RANDOM)
                return gda_data_model_iter_move_to_row_default (model, iter, row);
 
        g_return_val_if_fail (iter, FALSE);
 
-       int_row = external_to_internal_row (imodel, row, NULL);
-       if (imodel->priv->sh->current_prow && (imodel->priv->sh->current_prow_row == row))
-               prow = imodel->priv->sh->current_prow;
+       int_row = external_to_internal_row (GDA_DATA_SELECT (model), row, NULL);
+       if (priv->sh->current_prow && (priv->sh->current_prow_row == row))
+               prow = priv->sh->current_prow;
        else
-               prow = gda_data_select_get_stored_row (imodel, int_row);
+               prow = gda_data_select_get_stored_row (GDA_DATA_SELECT (model), int_row);
 
        if (prow) {
-               imodel->priv->sh->iter_row = row;
-               update_iter (imodel, prow);
+               priv->sh->iter_row = row;
+               update_iter (GDA_DATA_SELECT (model), prow);
                return TRUE;
        }
        else {
                if (CLASS (model)->fetch_at) {
-                       _gda_data_select_fetch_at (imodel, &prow, int_row, NULL);
+                       _gda_data_select_fetch_at (GDA_DATA_SELECT (model), &prow, int_row, NULL);
                        if (prow) {
-                               imodel->priv->sh->iter_row = row;
-                               update_iter (imodel, prow);
+                               priv->sh->iter_row = row;
+                               update_iter (GDA_DATA_SELECT (model), prow);
                                return TRUE;
                        }
                        else {
                                g_object_set (G_OBJECT (iter), "current-row", -1, NULL);
-                               imodel->priv->sh->iter_row = G_MININT;
+                               priv->sh->iter_row = G_MININT;
                                gda_data_model_iter_invalidate_contents (iter);
                                return FALSE;
                        }
                }
                else {
                        /* implementation of fetch_at() is optional */
-                       if (imodel->priv->sh->iter_row < row) {
+                       if (priv->sh->iter_row < row) {
                                for (; gda_data_model_iter_get_row (iter) < row; ) {
                                        if (! gda_data_model_iter_move_next (iter))
                                                return FALSE;
                                }
                                return gda_data_model_iter_get_row (iter) == row ? TRUE : FALSE;
                        }
-                       else if (imodel->priv->sh->iter_row > row) {
+                       else if (priv->sh->iter_row > row) {
                                for (; gda_data_model_iter_get_row (iter) > row; ) {
                                        if (! gda_data_model_iter_move_prev (iter))
                                                return FALSE;
@@ -2373,8 +2319,9 @@ gda_data_select_iter_at_row (GdaDataModel *model, GdaDataModelIter *iter, gint r
 static void
 update_iter (GdaDataSelect *imodel, GdaRow *prow)
 {
-        gint i;
-       GdaDataModelIter *iter = imodel->priv->iter;
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (GDA_DATA_SELECT (imodel));
+       gint i;
+       GdaDataModelIter *iter = priv->iter;
        GSList *plist;
        gboolean update_model;
 
@@ -2391,7 +2338,7 @@ update_iter (GdaDataSelect *imodel, GdaRow *prow)
 
                if (!gda_row_value_is_valid_e (prow, value, &lerror)) {
                        /*g_print (_("%s(%p) [%d] Could not change iter's value for column %d: %s"),
-                                __FUNCTION__, iter, imodel->priv->sh->iter_row, i,
+                                __FUNCTION__, iter, priv->sh->iter_row, i,
                                 lerror && lerror->message ? lerror->message : _("No detail"));*/
                        gda_holder_force_invalid_e ((GdaHolder*) plist->data, lerror);
                }
@@ -2417,24 +2364,24 @@ update_iter (GdaDataSelect *imodel, GdaRow *prow)
                }
         }
 
-       g_object_set (G_OBJECT (iter), "current-row", imodel->priv->sh->iter_row, NULL);
+       g_object_set (G_OBJECT (iter), "current-row", priv->sh->iter_row, NULL);
        if (update_model)
                g_object_set (G_OBJECT (iter), "update-model", update_model, NULL);
 
-       if (prow != imodel->priv->sh->current_prow) {
-               if (imodel->priv->sh->current_prow) {
-                       g_object_unref (imodel->priv->sh->current_prow);
-                       imodel->priv->sh->current_prow = NULL;
+       if (prow != priv->sh->current_prow) {
+               if (priv->sh->current_prow) {
+                       g_object_unref (priv->sh->current_prow);
+                       priv->sh->current_prow = NULL;
                }
-               imodel->priv->sh->current_prow = g_object_ref (prow);
+               priv->sh->current_prow = g_object_ref (prow);
        }
-       imodel->priv->sh->current_prow_row = imodel->priv->sh->iter_row;
+       priv->sh->current_prow_row = priv->sh->iter_row;
 
-       /*g_print ("%s(%p), current-row =>%d advertized_nrows => %d\n", __FUNCTION__, imodel, 
imodel->priv->sh->iter_row, imodel->advertized_nrows);*/
+       /*g_print ("%s(%p), current-row =>%d advertized_nrows => %d\n", __FUNCTION__, imodel, 
priv->sh->iter_row, iadvertized_nrows);*/
 }
 
 /*
- * creates a derivative of the model->priv->sh->modif_internals->modif_stmts [UPD_QUERY] statement
+ * creates a derivative of the priv->sh->modif_internals->modif_stmts [UPD_QUERY] statement
  * where only the columns where @bv->data[colnum] is not 0 are updated.
  *
  * Returns: a new #GdaStatement, or %NULL
@@ -2445,10 +2392,11 @@ compute_single_update_stmt (GdaDataSelect *model, BVector *bv, GError **error)
        GdaSqlStatement *sqlst;
        GdaSqlStatementUpdate *upd;
        GdaStatement *updstmt = NULL;
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (model);
 
        /* get a copy of complete UPDATE stmt */
-       g_assert (model->priv->sh->modif_internals->modif_stmts [UPD_QUERY]);
-       g_object_get (G_OBJECT (model->priv->sh->modif_internals->modif_stmts [UPD_QUERY]), "structure", 
&sqlst, NULL);
+       g_assert (priv->sh->modif_internals->modif_stmts [UPD_QUERY]);
+       g_object_get (G_OBJECT (priv->sh->modif_internals->modif_stmts [UPD_QUERY]), "structure", &sqlst, 
NULL);
        g_assert (sqlst);
        g_free (sqlst->sql);
        sqlst->sql = NULL;
@@ -2527,7 +2475,7 @@ compute_single_update_stmt (GdaDataSelect *model, BVector *bv, GError **error)
 }
 
 /*
- * creates a derivative of the model->priv->sh->modif_internals->modif_stmts [INS_QUERY] statement
+ * creates a derivative of the priv->sh->modif_internals->modif_stmts [INS_QUERY] statement
  * where only the columns where @bv->data[colnum] is not 0 are not mentioned.
  *
  * Returns: a new #GdaStatement, or %NULL
@@ -2538,10 +2486,11 @@ compute_single_insert_stmt (GdaDataSelect *model, BVector *bv, GError **error)
        GdaSqlStatement *sqlst;
        GdaSqlStatementInsert *ins;
        GdaStatement *insstmt = NULL;
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (model);
 
        /* get a copy of complete INSERT stmt */
-       g_assert (model->priv->sh->modif_internals->modif_stmts [INS_QUERY]);
-       g_object_get (G_OBJECT (model->priv->sh->modif_internals->modif_stmts [INS_QUERY]), "structure", 
&sqlst, NULL);
+       g_assert (priv->sh->modif_internals->modif_stmts [INS_QUERY]);
+       g_object_get (G_OBJECT (priv->sh->modif_internals->modif_stmts [INS_QUERY]), "structure", &sqlst, 
NULL);
        g_assert (sqlst);
        g_free (sqlst->sql);
        sqlst->sql = NULL;
@@ -2636,21 +2585,22 @@ compute_single_select_stmt (GdaDataSelect *model, GError **error)
        GdaStatement *ret_stmt = NULL;
        GdaSqlStatement *sel_sqlst;
        GdaSqlExpr *row_cond = NULL;
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (model);
 
-       sel_stmt = model->priv->sh->sel_stmt;
+       sel_stmt = priv->sh->sel_stmt;
        if (! sel_stmt) {
                g_set_error (error, GDA_DATA_SELECT_ERROR, GDA_DATA_SELECT_MODIFICATION_STATEMENT_ERROR,
                              "%s", _("Internal error: can't get the prepared statement's actual statement"));
                return NULL;
        }
 
-       if (model->priv->sh->modif_internals->unique_row_condition)
-               row_cond = gda_sql_expr_copy (model->priv->sh->modif_internals->unique_row_condition);
-       else if (model->priv->sh->modif_internals->modif_stmts [DEL_QUERY]) {
+       if (priv->sh->modif_internals->unique_row_condition)
+               row_cond = gda_sql_expr_copy (priv->sh->modif_internals->unique_row_condition);
+       else if (priv->sh->modif_internals->modif_stmts [DEL_QUERY]) {
                GdaStatement *del_stmt;
                GdaSqlStatement *del_sqlst;
                GdaSqlStatementDelete *del;
-               del_stmt = model->priv->sh->modif_internals->modif_stmts [DEL_QUERY];
+               del_stmt = priv->sh->modif_internals->modif_stmts [DEL_QUERY];
 
                g_object_get (G_OBJECT (del_stmt), "structure", &del_sqlst, NULL);
                del = (GdaSqlStatementDelete*) del_sqlst->contents;
@@ -2662,11 +2612,11 @@ compute_single_select_stmt (GdaDataSelect *model, GError **error)
                        row_cond = NULL;
                }
        }
-       else if (model->priv->sh->modif_internals->modif_stmts [UPD_QUERY]) {
+       else if (priv->sh->modif_internals->modif_stmts [UPD_QUERY]) {
                GdaStatement *upd_stmt;
                GdaSqlStatement *upd_sqlst;
                GdaSqlStatementUpdate *upd;
-               upd_stmt = model->priv->sh->modif_internals->modif_stmts [UPD_QUERY];
+               upd_stmt = priv->sh->modif_internals->modif_stmts [UPD_QUERY];
 
                g_object_get (G_OBJECT (upd_stmt), "structure", &upd_sqlst, NULL);
                upd = (GdaSqlStatementUpdate*) upd_sqlst->contents;
@@ -2762,21 +2712,22 @@ vector_set_value_at (GdaDataSelect *imodel, BVector *bv, GdaDataModelIter *iter,
        gchar *str;
        GdaStatement *stmt;
        gboolean free_bv = TRUE;
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (GDA_DATA_SELECT (imodel));
 
        /* arguments check */
        g_assert (bv);
 
-       if (imodel->priv->sh->modif_internals->safely_locked) {
+       if (priv->sh->modif_internals->safely_locked) {
                g_set_error (error, GDA_DATA_SELECT_ERROR, GDA_DATA_SELECT_SAFETY_LOCKED_ERROR,
                              "%s", _("Modifications are not allowed anymore"));
                return FALSE;
        }
-       if (!iter && ! (imodel->priv->sh->usage_flags & GDA_DATA_MODEL_ACCESS_RANDOM)) {
+       if (!iter && ! (priv->sh->usage_flags & GDA_DATA_MODEL_ACCESS_RANDOM)) {
                g_set_error (error, GDA_DATA_MODEL_ERROR, GDA_DATA_MODEL_ACCESS_ERROR,
                             "%s", _("Data model does only support random access"));
                return FALSE;
        }
-       if (! imodel->priv->sh->modif_internals->modif_stmts [UPD_QUERY]) {
+       if (! priv->sh->modif_internals->modif_stmts [UPD_QUERY]) {
                g_set_error (error, GDA_DATA_SELECT_ERROR, 
GDA_DATA_SELECT_MISSING_MODIFICATION_STATEMENT_ERROR,
                             "%s", _("No UPDATE statement provided"));
                return FALSE;
@@ -2790,15 +2741,15 @@ vector_set_value_at (GdaDataSelect *imodel, BVector *bv, GdaDataModelIter *iter,
                return FALSE;
 
        /* compute UPDATE statement */
-       if (! imodel->priv->sh->modif_internals->upd_stmts)
-               imodel->priv->sh->modif_internals->upd_stmts = g_hash_table_new_full ((GHashFunc) 
bvector_hash, (GEqualFunc) bvector_equal,
+       if (! priv->sh->modif_internals->upd_stmts)
+               priv->sh->modif_internals->upd_stmts = g_hash_table_new_full ((GHashFunc) bvector_hash, 
(GEqualFunc) bvector_equal,
                                                                 (GDestroyNotify) bvector_free, 
g_object_unref);
-       stmt = g_hash_table_lookup (imodel->priv->sh->modif_internals->upd_stmts, bv);
+       stmt = g_hash_table_lookup (priv->sh->modif_internals->upd_stmts, bv);
        if (! stmt) {
                stmt = compute_single_update_stmt (imodel, bv, error);
                if (stmt) {
                        free_bv = FALSE;
-                       g_hash_table_insert (imodel->priv->sh->modif_internals->upd_stmts, bv, stmt);
+                       g_hash_table_insert (priv->sh->modif_internals->upd_stmts, bv, stmt);
                }
                else {
                        bvector_free (bv);
@@ -2810,7 +2761,7 @@ vector_set_value_at (GdaDataSelect *imodel, BVector *bv, GdaDataModelIter *iter,
        ncols = gda_data_select_get_n_columns ((GdaDataModel*) imodel);
        for (i = 0; i < ncols; i++) {
                str = g_strdup_printf ("-%d", i);
-               holder = gda_set_get_holder (imodel->priv->sh->modif_internals->modif_set, str);
+               holder = gda_set_get_holder (priv->sh->modif_internals->modif_set, str);
                g_free (str);
                if (holder) {
                        const GValue *cvalue;
@@ -2841,8 +2792,8 @@ vector_set_value_at (GdaDataSelect *imodel, BVector *bv, GdaDataModelIter *iter,
        gchar *sql;
        GError *lerror = NULL;
        sql = gda_statement_to_sql_extended (stmt,
-                                            imodel->priv->cnc,
-                                            imodel->priv->sh->modif_internals->modif_set,
+                                            priv->cnc,
+                                            priv->sh->modif_internals->modif_set,
                                             GDA_STATEMENT_SQL_PRETTY, NULL,
                                             &lerror);
        g_print ("%s(): SQL=> %s\n", __FUNCTION__, sql);
@@ -2851,25 +2802,25 @@ vector_set_value_at (GdaDataSelect *imodel, BVector *bv, GdaDataModelIter *iter,
        g_free (sql);
 #endif
 
-       if (gda_connection_statement_execute_non_select (imodel->priv->cnc, stmt,
-                                                        imodel->priv->sh->modif_internals->modif_set,
+       if (gda_connection_statement_execute_non_select (priv->cnc, stmt,
+                                                        priv->sh->modif_internals->modif_set,
                                                         NULL, error) == -1)
                return FALSE;
 
        /* mark that this row has been modified */
        DelayedSelectStmt *dstmt;
        dstmt = g_new0 (DelayedSelectStmt, 1);
-       if (! imodel->priv->sh->modif_internals->one_row_select_stmt)
-               imodel->priv->sh->modif_internals->one_row_select_stmt = compute_single_select_stmt (imodel, 
error);
-       if (imodel->priv->sh->modif_internals->one_row_select_stmt) {
-               dstmt->select = g_object_ref (imodel->priv->sh->modif_internals->one_row_select_stmt);
+       if (! priv->sh->modif_internals->one_row_select_stmt)
+               priv->sh->modif_internals->one_row_select_stmt = compute_single_select_stmt (imodel, error);
+       if (priv->sh->modif_internals->one_row_select_stmt) {
+               dstmt->select = g_object_ref (priv->sh->modif_internals->one_row_select_stmt);
                gda_statement_get_parameters (dstmt->select, &(dstmt->params), NULL);
                if (dstmt->params) {
                        GSList *list;
                        gboolean allok = TRUE;
 
                        /* overwrite old values with new values if some have been provided */
-                       for (list = gda_set_get_holders (imodel->priv->sh->modif_internals->modif_set); list;
+                       for (list = gda_set_get_holders (priv->sh->modif_internals->modif_set); list;
                             list = list->next) {
                                GdaHolder *h = (GdaHolder*) list->data;
                                gint res;
@@ -2878,7 +2829,7 @@ vector_set_value_at (GdaDataSelect *imodel, BVector *bv, GdaDataModelIter *iter,
                                    param_name_to_int (gda_holder_get_id (h), &res, &old) &&
                                    !old) {
                                        str = g_strdup_printf ("-%d", res);
-                                       holder = gda_set_get_holder 
(imodel->priv->sh->modif_internals->modif_set,
+                                       holder = gda_set_get_holder (priv->sh->modif_internals->modif_set,
                                                                     str);
                                        g_free (str);
                                        if (holder &&
@@ -2892,7 +2843,7 @@ vector_set_value_at (GdaDataSelect *imodel, BVector *bv, GdaDataModelIter *iter,
                        for (list = gda_set_get_holders (dstmt->params); list && allok; list = list->next) {
                                GdaHolder *holder = GDA_HOLDER (list->data);
                                GdaHolder *eholder;
-                               eholder = gda_set_get_holder (imodel->priv->sh->modif_internals->modif_set,
+                               eholder = gda_set_get_holder (priv->sh->modif_internals->modif_set,
                                                              gda_holder_get_id (holder));
                                if (!eholder ||
                                    ! gda_holder_set_value (holder, gda_holder_get_value (eholder), NULL)) {
@@ -2908,13 +2859,13 @@ vector_set_value_at (GdaDataSelect *imodel, BVector *bv, GdaDataModelIter *iter,
                }
        }
        dstmt->row = NULL;
-       if (! imodel->priv->sh->upd_rows)
-               imodel->priv->sh->upd_rows = g_hash_table_new_full (g_int_hash, g_int_equal,
+       if (! priv->sh->upd_rows)
+               priv->sh->upd_rows = g_hash_table_new_full (g_int_hash, g_int_equal,
                                                                g_free,
                                                                (GDestroyNotify) delayed_select_stmt_free);
        gint *tmp = g_new (gint, 1);
        *tmp = int_row;
-       g_hash_table_insert (imodel->priv->sh->upd_rows, tmp, dstmt);
+       g_hash_table_insert (priv->sh->upd_rows, tmp, dstmt);
 #ifdef GDA_DEBUG_NO
        dump_d (imodel);
 #endif
@@ -2934,13 +2885,14 @@ check_data_model_for_updates (GdaDataSelect *imodel,
        gint ncols;
        GdaHolder *holder;
        gchar *str;
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (GDA_DATA_SELECT (imodel));
 
-       if (imodel->priv->sh->modif_internals->safely_locked) {
+       if (priv->sh->modif_internals->safely_locked) {
                g_set_error (error, GDA_DATA_SELECT_ERROR, GDA_DATA_SELECT_SAFETY_LOCKED_ERROR,
                             "%s", _("Modifications are not allowed anymore"));
                return FALSE;
        }
-       if (! imodel->priv->sh->modif_internals->modif_stmts [UPD_QUERY]) {
+       if (! priv->sh->modif_internals->modif_stmts [UPD_QUERY]) {
                g_set_error (error, GDA_DATA_SELECT_ERROR, 
GDA_DATA_SELECT_MISSING_MODIFICATION_STATEMENT_ERROR,
                             "%s", _("No UPDATE statement provided"));
                return FALSE;
@@ -2952,16 +2904,16 @@ check_data_model_for_updates (GdaDataSelect *imodel,
                             _("Column %d out of range (0-%d)"), col, ncols-1);
                return FALSE;
        }
-       /* invalidate all the imodel->priv->sh->modif_internals->modif_set's value holders */
+       /* invalidate all the priv->sh->modif_internals->modif_set's value holders */
        GSList *list;
-       for (list = gda_set_get_holders (imodel->priv->sh->modif_internals->modif_set); list; list = 
list->next) {
+       for (list = gda_set_get_holders (priv->sh->modif_internals->modif_set); list; list = list->next) {
                GdaHolder *h = (GdaHolder*) list->data;
                if (param_name_to_int (gda_holder_get_id (h), NULL, NULL))
                        gda_holder_force_invalid ((GdaHolder*) list->data);
        }
        /* give values to params for new value */
        str = g_strdup_printf ("+%d", col);
-       holder = gda_set_get_holder (imodel->priv->sh->modif_internals->modif_set, str);
+       holder = gda_set_get_holder (priv->sh->modif_internals->modif_set, str);
        g_free (str);
        if (! holder) {
                g_set_error (error, GDA_DATA_SELECT_ERROR,
@@ -2969,7 +2921,7 @@ check_data_model_for_updates (GdaDataSelect *imodel,
                             _("Column %d can't be modified"), col);
                return FALSE;
        }
-       if (g_slist_find (imodel->priv->sh->modif_internals->modif_params[UPD_QUERY], holder)) {
+       if (g_slist_find (priv->sh->modif_internals->modif_params[UPD_QUERY], holder)) {
                if (!gda_holder_set_value (holder, value, error))
                        return FALSE;
        }
@@ -2980,12 +2932,11 @@ check_data_model_for_updates (GdaDataSelect *imodel,
 static gboolean
 gda_data_select_set_value_at (GdaDataModel *model, gint col, gint row, const GValue *value, GError **error)
 {
-       GdaDataSelect *imodel;
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (GDA_DATA_SELECT (model));
 
-       imodel = (GdaDataSelect *) model;
-       g_return_val_if_fail (imodel->priv, FALSE);
-       g_return_val_if_fail (check_data_model_for_updates (imodel, col, value, error), FALSE);
-       if (! (imodel->priv->sh->usage_flags & GDA_DATA_MODEL_ACCESS_RANDOM)) {
+       g_return_val_if_fail (priv, FALSE);
+       g_return_val_if_fail (check_data_model_for_updates (GDA_DATA_SELECT (model), col, value, error), 
FALSE);
+       if (! (priv->sh->usage_flags & GDA_DATA_MODEL_ACCESS_RANDOM)) {
                g_set_error (error, GDA_DATA_MODEL_ERROR, GDA_DATA_MODEL_ACCESS_ERROR,
                             "%s", _("Data model does only support random access"));
                return FALSE;
@@ -2998,7 +2949,7 @@ gda_data_select_set_value_at (GdaDataModel *model, gint col, gint row, const GVa
        bv->data = g_new0 (guchar, bv->size);
        bv->data[col] = 1;
 
-       return vector_set_value_at (imodel, bv, NULL, row, error);
+       return vector_set_value_at (GDA_DATA_SELECT (model), bv, NULL, row, error);
 }
 
 static void
@@ -3018,18 +2969,17 @@ delayed_select_stmt_free (DelayedSelectStmt *dstmt)
 static gboolean
 gda_data_select_set_values (GdaDataModel *model, gint row, GList *values, GError **error)
 {
-       GdaDataSelect *imodel;
        gint i, ncols, nvalues;
        GdaHolder *holder;
        gchar *str;
        GList *list;
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (GDA_DATA_SELECT (model));
 
-       imodel = (GdaDataSelect *) model;
 
        /* arguments check */
-       g_return_val_if_fail (imodel->priv, FALSE);
+       g_return_val_if_fail (priv, FALSE);
 
-       if (! (imodel->priv->sh->usage_flags & GDA_DATA_MODEL_ACCESS_RANDOM)) {
+       if (! (priv->sh->usage_flags & GDA_DATA_MODEL_ACCESS_RANDOM)) {
                g_set_error (error, GDA_DATA_MODEL_ERROR, GDA_DATA_MODEL_ACCESS_ERROR,
                             "%s", _("Data model does only support random access"));
                return FALSE;
@@ -3062,9 +3012,9 @@ gda_data_select_set_values (GdaDataModel *model, gint row, GList *values, GError
                return TRUE;
        }
 
-       /* invalidate all the imodel->priv->sh->modif_internals->modif_set's value holders */
+       /* invalidate all the priv->sh->modif_internals->modif_set's value holders */
        GSList *slist;
-       for (slist = gda_set_get_holders (imodel->priv->sh->modif_internals->modif_set); slist; slist = 
slist->next) {
+       for (slist = gda_set_get_holders (priv->sh->modif_internals->modif_set); slist; slist = slist->next) {
                GdaHolder *h = (GdaHolder*) slist->data;
                if (param_name_to_int (gda_holder_get_id (h), NULL, NULL))
                        gda_holder_force_invalid ((GdaHolder*) slist->data);
@@ -3076,12 +3026,12 @@ gda_data_select_set_values (GdaDataModel *model, gint row, GList *values, GError
                        continue;
 
                str = g_strdup_printf ("+%d", i);
-               holder = gda_set_get_holder (imodel->priv->sh->modif_internals->modif_set, str);
+               holder = gda_set_get_holder (priv->sh->modif_internals->modif_set, str);
                g_free (str);
                if (!holder)
                        continue;
 
-               if (g_slist_find (imodel->priv->sh->modif_internals->modif_params[UPD_QUERY], holder)) {
+               if (g_slist_find (priv->sh->modif_internals->modif_params[UPD_QUERY], holder)) {
                        if (!gda_holder_set_value (holder, (GValue *) list->data, error)) {
                                bvector_free (bv);
                                return FALSE;
@@ -3091,33 +3041,32 @@ gda_data_select_set_values (GdaDataModel *model, gint row, GList *values, GError
                        gda_holder_force_invalid (holder);
        }
 
-       return vector_set_value_at (imodel, bv, NULL, row, error);
+       return vector_set_value_at (GDA_DATA_SELECT (model), bv, NULL, row, error);
 }
 
 static gint
 gda_data_select_append_values (GdaDataModel *model, const GList *values, GError **error)
 {
-       GdaDataSelect *imodel;
        gint row, int_row, i;
        GdaHolder *holder;
        gchar *str;
        const GList *list;
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (GDA_DATA_SELECT (model));
 
-       imodel = (GdaDataSelect *) model;
 
-       g_return_val_if_fail (imodel->priv, -1);
+       g_return_val_if_fail (priv, -1);
 
-       if (imodel->priv->sh->modif_internals->safely_locked) {
+       if (priv->sh->modif_internals->safely_locked) {
                g_set_error (error, GDA_DATA_SELECT_ERROR, GDA_DATA_SELECT_SAFETY_LOCKED_ERROR,
                             "%s", _("Modifications are not allowed anymore"));
                return -1;
        }
-       if (! (imodel->priv->sh->usage_flags & GDA_DATA_MODEL_ACCESS_RANDOM)) {
+       if (! (priv->sh->usage_flags & GDA_DATA_MODEL_ACCESS_RANDOM)) {
                g_set_error (error, GDA_DATA_MODEL_ERROR, GDA_DATA_MODEL_ACCESS_ERROR,
                             "%s", _("Data model does only support random access"));
                return -1;
        }
-       if (! imodel->priv->sh->modif_internals->modif_stmts [INS_QUERY]) {
+       if (! priv->sh->modif_internals->modif_stmts [INS_QUERY]) {
                g_set_error (error, GDA_DATA_SELECT_ERROR, 
GDA_DATA_SELECT_MISSING_MODIFICATION_STATEMENT_ERROR,
                             "%s", _("No INSERT statement provided"));
                return -1;
@@ -3129,12 +3078,12 @@ gda_data_select_append_values (GdaDataModel *model, const GList *values, GError
        }
 
        /* compute added row's number */
-       row = imodel->priv->advertized_nrows;
-       if (imodel->priv->sh->del_rows)
-               row -= imodel->priv->sh->del_rows->len;
-       imodel->priv->advertized_nrows++;
-       int_row = external_to_internal_row (imodel, row, error);
-       imodel->priv->advertized_nrows--;
+       row = priv->advertized_nrows;
+       if (priv->sh->del_rows)
+               row -= priv->sh->del_rows->len;
+       priv->advertized_nrows++;
+       int_row = external_to_internal_row (GDA_DATA_SELECT (model), row, error);
+       priv->advertized_nrows--;
 
        /* BVector */
        BVector *bv;
@@ -3160,17 +3109,17 @@ gda_data_select_append_values (GdaDataModel *model, const GList *values, GError
 
        /* compute INSERT statement */
        GdaStatement *stmt;
-       if (! imodel->priv->sh->modif_internals->ins_stmts)
-               imodel->priv->sh->modif_internals->ins_stmts = g_hash_table_new_full ((GHashFunc) 
bvector_hash,
+       if (! priv->sh->modif_internals->ins_stmts)
+               priv->sh->modif_internals->ins_stmts = g_hash_table_new_full ((GHashFunc) bvector_hash,
                                                                                  (GEqualFunc) bvector_equal,
                                                                                  (GDestroyNotify) 
bvector_free,
                                                                                  g_object_unref);
-       stmt = g_hash_table_lookup (imodel->priv->sh->modif_internals->ins_stmts, bv);
+       stmt = g_hash_table_lookup (priv->sh->modif_internals->ins_stmts, bv);
        if (! stmt) {
-               stmt = compute_single_insert_stmt (imodel, bv, error);
+               stmt = compute_single_insert_stmt (GDA_DATA_SELECT (model), bv, error);
                if (stmt) {
                        free_bv = FALSE;
-                       g_hash_table_insert (imodel->priv->sh->modif_internals->ins_stmts, bv, stmt);
+                       g_hash_table_insert (priv->sh->modif_internals->ins_stmts, bv, stmt);
                }
                else {
                        bvector_free (bv);
@@ -3184,13 +3133,13 @@ gda_data_select_append_values (GdaDataModel *model, const GList *values, GError
                        continue;
 
                str = g_strdup_printf ("+%d", i);
-               holder = gda_set_get_holder (imodel->priv->sh->modif_internals->modif_set, str);
+               holder = gda_set_get_holder (priv->sh->modif_internals->modif_set, str);
                g_free (str);
                if (! holder) {
                        /* ignore this value as it won't be used */
                        continue;
                }
-               if (!g_slist_find (imodel->priv->sh->modif_internals->modif_params[INS_QUERY], holder)) {
+               if (!g_slist_find (priv->sh->modif_internals->modif_params[INS_QUERY], holder)) {
                        gda_holder_force_invalid (holder);
                        continue;
                }
@@ -3210,8 +3159,8 @@ gda_data_select_append_values (GdaDataModel *model, const GList *values, GError
        gchar *sql;
        GError *lerror = NULL;
        sql = gda_statement_to_sql_extended (stmt,
-                                            imodel->priv->cnc,
-                                            imodel->priv->sh->modif_internals->modif_set,
+                                            priv->cnc,
+                                            priv->sh->modif_internals->modif_set,
                                             GDA_STATEMENT_SQL_PRETTY, NULL,
                                             &lerror);
        g_print ("%s(): SQL=> %s\n", __FUNCTION__, sql);
@@ -3225,30 +3174,30 @@ gda_data_select_append_values (GdaDataModel *model, const GList *values, GError
        g_free (sql);
 #endif
 
-       if (! imodel->priv->sh->modif_internals->one_row_select_stmt) {
-               imodel->priv->sh->modif_internals->one_row_select_stmt =
-                       compute_single_select_stmt (imodel, error);
+       if (! priv->sh->modif_internals->one_row_select_stmt) {
+               priv->sh->modif_internals->one_row_select_stmt =
+                       compute_single_select_stmt (GDA_DATA_SELECT (model), error);
        }
 
        GdaSet *last_insert;
-       if (gda_connection_statement_execute_non_select (imodel->priv->cnc, stmt,
-                                                        imodel->priv->sh->modif_internals->modif_set,
+       if (gda_connection_statement_execute_non_select (priv->cnc, stmt,
+                                                        priv->sh->modif_internals->modif_set,
                                                         &last_insert, error) == -1)
                return -1;
 
        /* mark that this row has been modified */
        DelayedSelectStmt *dstmt;
        dstmt = g_new0 (DelayedSelectStmt, 1);
-       if (last_insert && imodel->priv->sh->modif_internals->one_row_select_stmt) {
-               dstmt->select = g_object_ref (imodel->priv->sh->modif_internals->one_row_select_stmt);
+       if (last_insert && priv->sh->modif_internals->one_row_select_stmt) {
+               dstmt->select = g_object_ref (priv->sh->modif_internals->one_row_select_stmt);
                gda_statement_get_parameters (dstmt->select, &(dstmt->params), NULL);
                if (dstmt->params) {
                        GSList *list;
-                       if (! imodel->priv->sh->modif_internals->insert_to_select_mapping)
-                               imodel->priv->sh->modif_internals->insert_to_select_mapping =
+                       if (! priv->sh->modif_internals->insert_to_select_mapping)
+                               priv->sh->modif_internals->insert_to_select_mapping =
                                        compute_insert_select_params_mapping (dstmt->params, last_insert,
-                                                                             
imodel->priv->sh->modif_internals->unique_row_condition);
-                       if (imodel->priv->sh->modif_internals->insert_to_select_mapping) {
+                                                                             
priv->sh->modif_internals->unique_row_condition);
+                       if (priv->sh->modif_internals->insert_to_select_mapping) {
                                for (list = gda_set_get_holders (dstmt->params); list; list = list->next) {
                                        GdaHolder *holder = GDA_HOLDER (list->data);
                                        GdaHolder *eholder;
@@ -3257,7 +3206,7 @@ gda_data_select_append_values (GdaDataModel *model, const GList *values, GError
                                        g_assert (param_name_to_int (gda_holder_get_id (holder), &pos, NULL));
 
                                        eholder = g_slist_nth_data (gda_set_get_holders (last_insert),
-                                                                   
imodel->priv->sh->modif_internals->insert_to_select_mapping[pos]);
+                                                                   
priv->sh->modif_internals->insert_to_select_mapping[pos]);
                                        if (!eholder ||
                                            ! gda_holder_set_value (holder, gda_holder_get_value (eholder), 
error)) {
                                                g_object_unref (dstmt->params);
@@ -3274,18 +3223,18 @@ gda_data_select_append_values (GdaDataModel *model, const GList *values, GError
        }
 
        dstmt->row = NULL;
-       if (! imodel->priv->sh->upd_rows)
-               imodel->priv->sh->upd_rows = g_hash_table_new_full (g_int_hash, g_int_equal,
+       if (! priv->sh->upd_rows)
+               priv->sh->upd_rows = g_hash_table_new_full (g_int_hash, g_int_equal,
                                                                g_free,
                                                                (GDestroyNotify) delayed_select_stmt_free);
        gint *tmp = g_new (gint, 1);
        *tmp = int_row;
-       g_hash_table_insert (imodel->priv->sh->upd_rows, tmp, dstmt);
+       g_hash_table_insert (priv->sh->upd_rows, tmp, dstmt);
 #ifdef GDA_DEBUG_NO
-       dump_d (imodel);
+       dump_d (GDA_DATA_SELECT (model));
 #endif
-       imodel->priv->advertized_nrows++;
-       gda_data_model_row_inserted ((GdaDataModel *) imodel, row);
+       priv->advertized_nrows++;
+       gda_data_model_row_inserted ((GdaDataModel *) GDA_DATA_SELECT (model), row);
 
        return row;
 }
@@ -3294,43 +3243,41 @@ gda_data_select_append_values (GdaDataModel *model, const GList *values, GError
 static gboolean
 gda_data_select_remove_row (GdaDataModel *model, gint row, GError **error)
 {
-       GdaDataSelect *imodel;
        guint i, ncols;
        gint int_row, index;
        GdaHolder *holder;
        gchar *str;
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (GDA_DATA_SELECT (model));
 
-       imodel = (GdaDataSelect *) model;
+       g_return_val_if_fail (priv, FALSE);
 
-       g_return_val_if_fail (imodel->priv, FALSE);
-
-       if (imodel->priv->sh->modif_internals->safely_locked) {
+       if (priv->sh->modif_internals->safely_locked) {
                g_set_error (error, GDA_DATA_SELECT_ERROR, GDA_DATA_SELECT_SAFETY_LOCKED_ERROR,
                             "%s", _("Modifications are not allowed anymore"));
                return FALSE;
        }
-       if (! (imodel->priv->sh->usage_flags & GDA_DATA_MODEL_ACCESS_RANDOM)) {
+       if (! (priv->sh->usage_flags & GDA_DATA_MODEL_ACCESS_RANDOM)) {
                g_set_error (error, GDA_DATA_MODEL_ERROR, GDA_DATA_MODEL_ACCESS_ERROR,
                             "%s", _("Data model does only support random access"));
                return FALSE;
        }
-       if (! imodel->priv->sh->modif_internals->modif_stmts [DEL_QUERY]) {
+       if (! priv->sh->modif_internals->modif_stmts [DEL_QUERY]) {
                g_set_error (error, GDA_DATA_SELECT_ERROR, 
GDA_DATA_SELECT_MISSING_MODIFICATION_STATEMENT_ERROR,
                             "%s", _("No DELETE statement provided"));
                return FALSE;
        }
 
-       int_row = external_to_internal_row (imodel, row, error);
+       int_row = external_to_internal_row (GDA_DATA_SELECT (model), row, error);
        if (int_row < 0)
                return FALSE;
 
        ncols = gda_data_select_get_n_columns (model);
        for (i = 0; i < ncols; i++) {
                str = g_strdup_printf ("-%d", i);
-               holder = gda_set_get_holder (imodel->priv->sh->modif_internals->modif_set, str);
+               holder = gda_set_get_holder (priv->sh->modif_internals->modif_set, str);
                g_free (str);
                if (holder) {
-                       if (!g_slist_find (imodel->priv->sh->modif_internals->modif_params[DEL_QUERY],
+                       if (!g_slist_find (priv->sh->modif_internals->modif_params[DEL_QUERY],
                                           holder)) {
                                gda_holder_force_invalid (holder);
                                continue;
@@ -3347,9 +3294,9 @@ gda_data_select_remove_row (GdaDataModel *model, gint row, GError **error)
 #ifdef GDA_DEBUG_NO
        gchar *sql;
        GError *lerror = NULL;
-       sql = gda_statement_to_sql_extended (imodel->priv->sh->modif_internals->modif_stmts [DEL_QUERY],
-                                            imodel->priv->cnc,
-                                            imodel->priv->sh->modif_internals->modif_set,
+       sql = gda_statement_to_sql_extended (priv->sh->modif_internals->modif_stmts [DEL_QUERY],
+                                            priv->cnc,
+                                            priv->sh->modif_internals->modif_set,
                                             GDA_STATEMENT_SQL_PRETTY, NULL,
                                             &lerror);
        g_print ("%s(): SQL=> %s\n", __FUNCTION__, sql);
@@ -3357,20 +3304,20 @@ gda_data_select_remove_row (GdaDataModel *model, gint row, GError **error)
                g_print ("\tERR: %s\n", lerror && lerror->message ? lerror->message : "No detail");
        g_free (sql);
 #endif
-       if (gda_connection_statement_execute_non_select (imodel->priv->cnc,
-                                                        imodel->priv->sh->modif_internals->modif_stmts 
[DEL_QUERY],
-                                                        imodel->priv->sh->modif_internals->modif_set, NULL, 
error) == -1)
+       if (gda_connection_statement_execute_non_select (priv->cnc,
+                                                        priv->sh->modif_internals->modif_stmts [DEL_QUERY],
+                                                        priv->sh->modif_internals->modif_set, NULL, error) 
== -1)
                return FALSE;
 
        /* mark that this row has been removed */
-       if (!imodel->priv->sh->del_rows)
-               imodel->priv->sh->del_rows = g_array_new (FALSE, FALSE, sizeof (gint));
-       for (index = 0, i = 0; i < imodel->priv->sh->del_rows->len; i++, index++) {
-               if (g_array_index (imodel->priv->sh->del_rows, gint, i) >= int_row)
+       if (!priv->sh->del_rows)
+               priv->sh->del_rows = g_array_new (FALSE, FALSE, sizeof (gint));
+       for (index = 0, i = 0; i < priv->sh->del_rows->len; i++, index++) {
+               if (g_array_index (priv->sh->del_rows, gint, i) >= int_row)
                        break;
        }
 
-       g_array_insert_val (imodel->priv->sh->del_rows, index, int_row);
+       g_array_insert_val (priv->sh->del_rows, index, int_row);
        gda_data_model_row_removed (model, row);
 
        return TRUE;
@@ -3379,28 +3326,31 @@ gda_data_select_remove_row (GdaDataModel *model, gint row, GError **error)
 static void
 gda_data_select_freeze (GdaDataModel *model)
 {
-       ((GdaDataSelect *) model)->priv->sh->notify_changes = FALSE;
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (GDA_DATA_SELECT (model));
+       priv->sh->notify_changes = FALSE;
 }
 
 static void
 gda_data_select_thaw (GdaDataModel *model)
 {
-       ((GdaDataSelect *) model)->priv->sh->notify_changes = TRUE;
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (GDA_DATA_SELECT (model));
+       priv->sh->notify_changes = TRUE;
 }
 
 static gboolean
 gda_data_select_get_notify (GdaDataModel *model)
 {
-       return ((GdaDataSelect *) model)->priv->sh->notify_changes;
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (GDA_DATA_SELECT (model));
+       return priv->sh->notify_changes;
 }
 
 static GError **
 gda_data_select_get_exceptions (GdaDataModel *model)
 {
-       GdaDataSelect *sel;
-       sel =  GDA_DATA_SELECT (model);
-       if (sel->priv->exceptions && (sel->priv->exceptions->len > 0))
-               return (GError **) sel->priv->exceptions->pdata;
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (GDA_DATA_SELECT (model));
+
+       if (priv->exceptions && (priv->exceptions->len > 0))
+               return (GError **) priv->exceptions->pdata;
        else
                return NULL;
 }
@@ -3417,25 +3367,25 @@ gda_data_select_get_exceptions (GdaDataModel *model)
 void
 gda_data_select_add_exception (GdaDataSelect *model, GError *error)
 {
-       GdaDataSelect *sel;
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (GDA_DATA_SELECT (model));
 
        g_return_if_fail (GDA_IS_DATA_SELECT (model));
        g_return_if_fail (error);
        g_return_if_fail (error->message);
-       sel =  GDA_DATA_SELECT (model);
-       if (sel->priv->exceptions == NULL)
-               sel->priv->exceptions = g_ptr_array_new_with_free_func ((GDestroyNotify) g_error_free);
-       g_ptr_array_add (sel->priv->exceptions, error);
+
+       if (priv->exceptions == NULL)
+               priv->exceptions = g_ptr_array_new_with_free_func ((GDestroyNotify) g_error_free);
+       g_ptr_array_add (priv->exceptions, error);
 }
 
 /*
  * The following function creates a correspondance between the parameters required to
- * execute the model->one_row_select_stmt statement (GdaHolders named "-<num>", in ), and the GdaHolder
- * returned after having executed the model->modif_stmts[INS_QUERY] INSERT statement.
+ * execute the one_row_select_stmt statement (GdaHolders named "-<num>", in ), and the GdaHolder
+ * returned after having executed the modif_stmts[INS_QUERY] INSERT statement.
  *
  * The way of preceeding is:
- *   - for each parameter required by model->one_row_select_stmt statement (the @sel_params argument),
- *     use the model->priv->sh->modif_internals->unique_row_condition to get the name of the corresponding 
column (the GdaHolder's ID
+ *   - for each parameter required by one_row_select_stmt statement (the @sel_params argument),
+ *     use the priv->sh->modif_internals->unique_row_condition to get the name of the corresponding column 
(the GdaHolder's ID
  *     is "-<num1>" )
  *   - from the column name get the GdaHolder in the GdaSet retruned after the INSERT statement (the
  *     @ins_values argument) using the "name" property of each GdaHolder in the GdaSet (the GdaHolder's ID
@@ -3565,6 +3515,7 @@ set_column_properties_from_select_stmt (GdaDataSelect *model, GdaConnection *cnc
        GdaSqlStatementSelect *select;
        GdaSqlSelectTarget *target;
        GSList *fields, *columns;
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (model);
 
        g_object_get (G_OBJECT (sel_stmt), "structure", &sqlst, NULL);
        g_assert (sqlst->stmt_type == GDA_SQL_STATEMENT_SELECT);
@@ -3588,7 +3539,7 @@ set_column_properties_from_select_stmt (GdaDataSelect *model, GdaConnection *cnc
 
        /* FIXME: also set some column attributes using gda_column_set_attribute() */
 
-       for (fields = select->expr_list, columns = model->priv->sh->columns;
+       for (fields = select->expr_list, columns = priv->sh->columns;
             fields && columns;
             fields = fields->next) {
                GdaSqlSelectField *selfield = (GdaSqlSelectField*) fields->data;
@@ -3632,7 +3583,7 @@ set_column_properties_from_select_stmt (GdaDataSelect *model, GdaConnection *cnc
        }
        if (fields || columns)
                g_warning (_("Internal error: GdaDataSelect has %d GdaColumns, and SELECT statement has %d 
expressions"),
-                          g_slist_length (model->priv->sh->columns), g_slist_length (select->expr_list));
+                          g_slist_length (priv->sh->columns), g_slist_length (select->expr_list));
 
  out:
        gda_sql_statement_free (sqlst);
@@ -3655,19 +3606,19 @@ gda_data_select_compute_columns_attributes (GdaDataSelect *model, GError **error
        GdaStatement *sel_stmt;
 
        g_return_val_if_fail (GDA_IS_DATA_SELECT (model), FALSE);
-       g_return_val_if_fail (model->priv, FALSE);
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (model);
 
        sel_stmt = check_acceptable_statement (model, error);
        if (! sel_stmt)
                return FALSE;
 
-       if (!model->priv->cnc) {
+       if (!priv->cnc) {
                g_set_error (error, GDA_DATA_SELECT_ERROR, GDA_DATA_SELECT_CONNECTION_ERROR,
                             "%s", _("No connection to use"));
                return FALSE;
        }
 
-       set_column_properties_from_select_stmt (model, model->priv->cnc, sel_stmt);
+       set_column_properties_from_select_stmt (model, priv->cnc, sel_stmt);
 
        return TRUE;
 }
@@ -3691,21 +3642,23 @@ gda_data_select_rerun (GdaDataSelect *model, GError **error)
 
        GdaDataSelect *new_model;
        GdaStatement *select;
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (model);
 
        select = check_acceptable_statement (model, error);
        if (!select)
                return FALSE;
-       g_assert (model->priv->prep_stmt);
+       g_assert (priv->prep_stmt);
        GType *types = NULL;
-       if (model->priv->prep_stmt->types) {
-               types = g_new (GType, model->priv->prep_stmt->ncols + 1);
-               memcpy (types, model->priv->prep_stmt->types, /* Flawfinder: ignore */
-                       sizeof (GType) * model->priv->prep_stmt->ncols);
-               types [model->priv->prep_stmt->ncols] = G_TYPE_NONE;
-       }
-       new_model = (GdaDataSelect*) gda_connection_statement_execute_select_full (model->priv->cnc, select,
-                                                                                  
model->priv->sh->ext_params,
-                                                                                  
model->priv->sh->usage_flags | GDA_STATEMENT_MODEL_ALLOW_NOPARAM,
+
+       if (priv->prep_stmt->types) {
+               types = g_new (GType, priv->prep_stmt->ncols + 1);
+               memcpy (types, priv->prep_stmt->types, /* Flawfinder: ignore */
+                       sizeof (GType) * priv->prep_stmt->ncols);
+               types [priv->prep_stmt->ncols] = G_TYPE_NONE;
+       }
+       new_model = (GdaDataSelect*) gda_connection_statement_execute_select_full (priv->cnc, select,
+                                                                                  priv->sh->ext_params,
+                                                                                  priv->sh->usage_flags | 
GDA_STATEMENT_MODEL_ALLOW_NOPARAM,
                                                                                   types,
                                                                                   error);
        g_free (types);
@@ -3719,15 +3672,16 @@ gda_data_select_rerun (GdaDataSelect *model, GError **error)
 
        /* Raw model and new_model contents swap (except for the GObject part) */
        GdaDataSelect *old_model = new_model; /* renamed for code's readability */
-       if (old_model->priv->ext_params_changed_sig_id) {
-               g_signal_handler_disconnect (old_model->priv->sh->ext_params,
-                                            old_model->priv->ext_params_changed_sig_id);
-               old_model->priv->ext_params_changed_sig_id = 0;
+       GdaDataSelectPrivate *old_priv = gda_data_select_get_instance_private (old_model);
+       if (old_priv->ext_params_changed_sig_id) {
+               g_signal_handler_disconnect (old_priv->sh->ext_params,
+                                            old_priv->ext_params_changed_sig_id);
+               old_priv->ext_params_changed_sig_id = 0;
        }
-       if (model->priv->ext_params_changed_sig_id) {
-               g_signal_handler_disconnect (model->priv->sh->ext_params,
-                                            model->priv->ext_params_changed_sig_id);
-               model->priv->ext_params_changed_sig_id = 0;
+       if (priv->ext_params_changed_sig_id) {
+               g_signal_handler_disconnect (priv->sh->ext_params,
+                                            priv->ext_params_changed_sig_id);
+               priv->ext_params_changed_sig_id = 0;
        }
 
        GTypeQuery tq;
@@ -3745,27 +3699,27 @@ gda_data_select_rerun (GdaDataSelect *model, GError **error)
        /* we need to keep some data from the old model */
        GdaDataSelectInternals *mi;
 
-       model->priv->sh->reset_with_ext_params_change = old_model->priv->sh->reset_with_ext_params_change;
-       model->priv->sh->notify_changes = old_model->priv->sh->notify_changes;
-       mi = old_model->priv->sh->modif_internals;
-       old_model->priv->sh->modif_internals = model->priv->sh->modif_internals;
-       model->priv->sh->modif_internals = mi;
+       priv->sh->reset_with_ext_params_change = old_priv->sh->reset_with_ext_params_change;
+       priv->sh->notify_changes = old_priv->sh->notify_changes;
+       mi = old_priv->sh->modif_internals;
+       old_priv->sh->modif_internals = priv->sh->modif_internals;
+       priv->sh->modif_internals = mi;
 
-       copy = old_model->priv->sh->sel_stmt;
-       old_model->priv->sh->sel_stmt = model->priv->sh->sel_stmt;
-       model->priv->sh->sel_stmt = (GdaStatement*) copy;
+       copy = old_priv->sh->sel_stmt;
+       old_priv->sh->sel_stmt = priv->sh->sel_stmt;
+       priv->sh->sel_stmt = (GdaStatement*) copy;
 
-       if (model->priv->sh->ext_params)
-               model->priv->ext_params_changed_sig_id =
-                       g_signal_connect (model->priv->sh->ext_params, "holder-changed",
+       if (priv->sh->ext_params)
+               priv->ext_params_changed_sig_id =
+                       g_signal_connect (priv->sh->ext_params, "holder-changed",
                                          G_CALLBACK (ext_params_holder_changed_cb), model);
 
        /* keep the same GdaColumn pointers */
        GSList *l1, *l2;
-       l1 = old_model->priv->sh->columns;
-       old_model->priv->sh->columns = model->priv->sh->columns;
-       model->priv->sh->columns = l1;
-       for (l1 = model->priv->sh->columns, l2 = old_model->priv->sh->columns;
+       l1 = old_priv->sh->columns;
+       old_priv->sh->columns = priv->sh->columns;
+       priv->sh->columns = l1;
+       for (l1 = priv->sh->columns, l2 = old_priv->sh->columns;
             l1 && l2;
             l1 = l1->next, l2 = l2->next) {
                if ((gda_column_get_g_type ((GdaColumn*) l1->data) == GDA_TYPE_NULL) &&
@@ -3776,13 +3730,13 @@ gda_data_select_rerun (GdaDataSelect *model, GError **error)
 
        g_object_unref (old_model);
 
-       /* copy all the param's holders' values from model->priv->sh->ext_params to
-          to model->priv->sh->modif_internals->exec_set */
+       /* copy all the param's holders' values from priv->sh->ext_params to
+          to priv->sh->modif_internals->exec_set */
        GSList *list;
-       if (model->priv->sh->ext_params) {
-               for (list = gda_set_get_holders (model->priv->sh->ext_params); list; list = list->next) {
+       if (priv->sh->ext_params) {
+               for (list = gda_set_get_holders (priv->sh->ext_params); list; list = list->next) {
                        GdaHolder *h;
-                       h = gda_set_get_holder (model->priv->sh->modif_internals->exec_set,
+                       h = gda_set_get_holder (priv->sh->modif_internals->exec_set,
                                                gda_holder_get_id (list->data));
                        if (h) {
                                GError *lerror = NULL;
@@ -3835,15 +3789,16 @@ gboolean
 gda_data_select_prepare_for_offline (GdaDataSelect *model, GError **error)
 {
        g_return_val_if_fail (GDA_IS_DATA_SELECT (model), FALSE);
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (model);
 
        /* checks */
        gint i, ncols;
-       if (! (model->priv->sh->usage_flags & GDA_STATEMENT_MODEL_RANDOM_ACCESS)) {
+       if (! (priv->sh->usage_flags & GDA_STATEMENT_MODEL_RANDOM_ACCESS)) {
                g_set_error (error, GDA_DATA_SELECT_ERROR, GDA_DATA_SELECT_ACCESS_ERROR,
                             "%s", _("Data model does not support random access"));
                return FALSE;
        }
-       if (model->priv->sh->upd_rows || model->priv->sh->del_rows) {
+       if (priv->sh->upd_rows || priv->sh->del_rows) {
                g_set_error (error, GDA_DATA_SELECT_ERROR, GDA_DATA_SELECT_ACCESS_ERROR,
                             "%s", _("Data model has been modified"));
                return FALSE;
@@ -3860,17 +3815,17 @@ gda_data_select_prepare_for_offline (GdaDataSelect *model, GError **error)
        }
 
        /* fetching data */
-       if (model->priv->advertized_nrows < 0) {
+       if (priv->advertized_nrows < 0) {
                if (CLASS (model)->fetch_nb_rows)
                        _gda_data_select_fetch_nb_rows (model);
-               if (model->priv->advertized_nrows < 0) {
+               if (priv->advertized_nrows < 0) {
                        g_set_error (error, GDA_DATA_SELECT_ERROR, GDA_DATA_SELECT_ACCESS_ERROR,
                                     "%s", _("Can't get the number of rows of data model"));
                        return FALSE;
                }
        }
 
-       if (model->priv->nb_stored_rows != model->priv->advertized_nrows) {
+       if (priv->nb_stored_rows != priv->advertized_nrows) {
                if (CLASS (model)->store_all) {
                        if (! _gda_data_select_store_all (model, error))
                                return FALSE;
@@ -3878,8 +3833,8 @@ gda_data_select_prepare_for_offline (GdaDataSelect *model, GError **error)
        }
 
        /* final check/complement */
-       for (i = 0; i < model->priv->advertized_nrows; i++) {
-               if (!g_hash_table_lookup (model->priv->sh->index, &i)) {
+       for (i = 0; i < priv->advertized_nrows; i++) {
+               if (!g_hash_table_lookup (priv->sh->index, &i)) {
                        GdaRow *prow;
                        if (! _gda_data_select_fetch_at (model, &prow, i, error))
                                return FALSE;
@@ -3911,12 +3866,13 @@ worker_fetch_nb_rows (GdaDataSelect *model, GError **error)
 static gint
 _gda_data_select_fetch_nb_rows (GdaDataSelect *model)
 {
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (model);
        GMainContext *context;
-       context = gda_server_provider_get_real_main_context (model->priv->cnc);
+       context = gda_server_provider_get_real_main_context (priv->cnc);
 
        gint nbrows = -1;
        gint *result;
-       if (gda_worker_do_job (model->priv->worker, context, 0, (gpointer) &result, NULL,
+       if (gda_worker_do_job (priv->worker, context, 0, (gpointer) &result, NULL,
                               (GdaWorkerFunc) worker_fetch_nb_rows, model, NULL, NULL, NULL)) {
                nbrows = *result;
                g_slice_free (gint, result);
@@ -3950,8 +3906,9 @@ worker_fetch_random (WorkerData *data, GError **error)
 static gboolean
 _gda_data_select_fetch_random  (GdaDataSelect *model, GdaRow **prow, gint rownum, GError **error)
 {
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (model);
        GMainContext *context;
-       context = gda_server_provider_get_real_main_context (model->priv->cnc);
+       context = gda_server_provider_get_real_main_context (priv->cnc);
 
        WorkerData jdata;
        jdata.model = model;
@@ -3959,7 +3916,7 @@ _gda_data_select_fetch_random  (GdaDataSelect *model, GdaRow **prow, gint rownum
        jdata.rownum = rownum;
 
        gpointer result;
-       gda_worker_do_job (model->priv->worker, context, 0, &result, NULL,
+       gda_worker_do_job (priv->worker, context, 0, &result, NULL,
                           (GdaWorkerFunc) worker_fetch_random, &jdata, NULL, NULL, error);
        if (context)
                g_main_context_unref (context);
@@ -3983,11 +3940,12 @@ worker_store_all (GdaDataSelect *model, GError **error)
 static gboolean
 _gda_data_select_store_all (GdaDataSelect *model, GError **error)
 {
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (model);
        GMainContext *context;
-       context = gda_server_provider_get_real_main_context (model->priv->cnc);
+       context = gda_server_provider_get_real_main_context (priv->cnc);
 
        gpointer result;
-       gda_worker_do_job (model->priv->worker, context, 0, (gpointer) &result, NULL,
+       gda_worker_do_job (priv->worker, context, 0, (gpointer) &result, NULL,
                           (GdaWorkerFunc) worker_store_all, model, NULL, NULL, NULL);
        if (context)
                g_main_context_unref (context);
@@ -4011,8 +3969,9 @@ worker_fetch_next (WorkerData *data, GError **error)
 static gboolean
 _gda_data_select_fetch_next    (GdaDataSelect *model, GdaRow **prow, gint rownum, GError **error)
 {
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (model);
        GMainContext *context;
-       context = gda_server_provider_get_real_main_context (model->priv->cnc);
+       context = gda_server_provider_get_real_main_context (priv->cnc);
 
        WorkerData jdata;
        jdata.model = model;
@@ -4020,7 +3979,7 @@ _gda_data_select_fetch_next    (GdaDataSelect *model, GdaRow **prow, gint rownum
        jdata.rownum = rownum;
 
        gpointer result;
-       gda_worker_do_job (model->priv->worker, context, 0, &result, NULL,
+       gda_worker_do_job (priv->worker, context, 0, &result, NULL,
                           (GdaWorkerFunc) worker_fetch_next, &jdata, NULL, NULL, error);
        if (context)
                g_main_context_unref (context);
@@ -4044,8 +4003,9 @@ worker_fetch_prev (WorkerData *data, GError **error)
 static gboolean
 _gda_data_select_fetch_prev    (GdaDataSelect *model, GdaRow **prow, gint rownum, GError **error)
 {
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (model);
        GMainContext *context;
-       context = gda_server_provider_get_real_main_context (model->priv->cnc);
+       context = gda_server_provider_get_real_main_context (priv->cnc);
 
        WorkerData jdata;
        jdata.model = model;
@@ -4053,7 +4013,7 @@ _gda_data_select_fetch_prev    (GdaDataSelect *model, GdaRow **prow, gint rownum
        jdata.rownum = rownum;
 
        gpointer result;
-       gda_worker_do_job (model->priv->worker, context, 0, &result, NULL,
+       gda_worker_do_job (priv->worker, context, 0, &result, NULL,
                           (GdaWorkerFunc) worker_fetch_prev, &jdata, NULL, NULL, error);
        if (context)
                g_main_context_unref (context);
@@ -4077,8 +4037,9 @@ worker_fetch_at (WorkerData *data, GError **error)
 static gboolean
 _gda_data_select_fetch_at      (GdaDataSelect *model, GdaRow **prow, gint rownum, GError **error)
 {
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (model);
        GMainContext *context;
-       context = gda_server_provider_get_real_main_context (model->priv->cnc);
+       context = gda_server_provider_get_real_main_context (priv->cnc);
 
        WorkerData jdata;
        jdata.model = model;
@@ -4086,7 +4047,7 @@ _gda_data_select_fetch_at      (GdaDataSelect *model, GdaRow **prow, gint rownum
        jdata.rownum = rownum;
 
        gpointer result;
-       gda_worker_do_job (model->priv->worker, context, 0, &result, NULL,
+       gda_worker_do_job (priv->worker, context, 0, &result, NULL,
                           (GdaWorkerFunc) worker_fetch_at, &jdata, NULL, NULL, error);
        if (context)
                g_main_context_unref (context);
@@ -4095,20 +4056,28 @@ _gda_data_select_fetch_at      (GdaDataSelect *model, GdaRow **prow, gint rownum
 
 /* Private API for providers */
 GdaPStmt*
-_gda_data_select_get_prep_stmt (GdaDataSelect *model) {
-       return model->priv->prep_stmt;
+_gda_data_select_get_prep_stmt (GdaDataSelect *model)
+{
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (model);
+       return priv->prep_stmt;
 }
 
 gint
-_gda_data_select_get_nb_stored_rows (GdaDataSelect *model) {
-       return model->priv->nb_stored_rows;
+_gda_data_select_get_nb_stored_rows (GdaDataSelect *model)
+{
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (model);
+       return priv->nb_stored_rows;
 }
 
 gint
-_gda_data_select_get_advertized_nrows (GdaDataSelect *model) {
-       return model->priv->advertized_nrows;
+_gda_data_select_get_advertized_nrows (GdaDataSelect *model)
+{
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (model);
+       return priv->advertized_nrows;
 }
 void
-_gda_data_select_set_advertized_nrows (GdaDataSelect *model, gint n) {
-       model->priv->advertized_nrows = n;
+_gda_data_select_set_advertized_nrows (GdaDataSelect *model, gint n)
+{
+       GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (model);
+       priv->advertized_nrows = n;
 }
diff --git a/libgda/gda-data-select.h b/libgda/gda-data-select.h
index b69b53922..fd3fc934e 100644
--- a/libgda/gda-data-select.h
+++ b/libgda/gda-data-select.h
@@ -28,52 +28,8 @@
 G_BEGIN_DECLS
 
 #define GDA_TYPE_DATA_SELECT            (gda_data_select_get_type())
-#define GDA_DATA_SELECT(obj)            (G_TYPE_CHECK_INSTANCE_CAST (obj, GDA_TYPE_DATA_SELECT, 
GdaDataSelect))
-#define GDA_DATA_SELECT_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST (klass, GDA_TYPE_DATA_SELECT, 
GdaDataSelectClass))
-#define GDA_IS_DATA_SELECT(obj)         (G_TYPE_CHECK_INSTANCE_TYPE(obj, GDA_TYPE_DATA_SELECT))
-#define GDA_IS_DATA_SELECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GDA_TYPE_DATA_SELECT))
 
-typedef struct _GdaDataSelect        GdaDataSelect;
-typedef struct _GdaDataSelectClass   GdaDataSelectClass;
-typedef struct _GdaDataSelectPrivate GdaDataSelectPrivate;
-
-/* error reporting */
-extern GQuark gda_data_select_error_quark (void);
-#define GDA_DATA_SELECT_ERROR gda_data_select_error_quark ()
-
-typedef enum {
-       GDA_DATA_SELECT_MODIFICATION_STATEMENT_ERROR,
-       GDA_DATA_SELECT_MISSING_MODIFICATION_STATEMENT_ERROR,
-       GDA_DATA_SELECT_CONNECTION_ERROR,
-       GDA_DATA_SELECT_ACCESS_ERROR,
-       GDA_DATA_SELECT_SQL_ERROR,
-       GDA_DATA_SELECT_SAFETY_LOCKED_ERROR
-} GdaDataSelectError;
-
-/**
- * GdaDataSelectConditionType:
- * @GDA_DATA_SELECT_COND_PK: only primary key fields are used
- * @GDA_DATA_SELECT_COND_ALL_COLUMNS: all the columns of the tables are used
- *
- * Defines what criteria gda_data_select_compute_modification_statements_ext() uses
- * to uniquely identify a single row in a table when creating modification statements.
- */
-typedef enum {
-       GDA_DATA_SELECT_COND_PK,
-       GDA_DATA_SELECT_COND_ALL_COLUMNS
-} GdaDataSelectConditionType;
-
-struct _GdaDataSelect {
-       GObject           object;
-       GdaDataSelectPrivate *priv;
-
-       /*< private >*/
-       /* Padding for future expansion */
-       gpointer _gda_reserved1;
-       gpointer _gda_reserved2;
-       gpointer _gda_reserved3;
-       gpointer _gda_reserved4;
-};
+G_DECLARE_DERIVABLE_TYPE (GdaDataSelect, gda_data_select, GDA, DATA_SELECT, GObject)
 
 /*
  * Depending on model access flags, the implementations are:
@@ -108,6 +64,33 @@ struct _GdaDataSelectClass {
        void (*_gda_reserved4) (void);
 };
 
+
+/* error reporting */
+extern GQuark gda_data_select_error_quark (void);
+#define GDA_DATA_SELECT_ERROR gda_data_select_error_quark ()
+
+typedef enum {
+       GDA_DATA_SELECT_MODIFICATION_STATEMENT_ERROR,
+       GDA_DATA_SELECT_MISSING_MODIFICATION_STATEMENT_ERROR,
+       GDA_DATA_SELECT_CONNECTION_ERROR,
+       GDA_DATA_SELECT_ACCESS_ERROR,
+       GDA_DATA_SELECT_SQL_ERROR,
+       GDA_DATA_SELECT_SAFETY_LOCKED_ERROR
+} GdaDataSelectError;
+
+/**
+ * GdaDataSelectConditionType:
+ * @GDA_DATA_SELECT_COND_PK: only primary key fields are used
+ * @GDA_DATA_SELECT_COND_ALL_COLUMNS: all the columns of the tables are used
+ *
+ * Defines what criteria gda_data_select_compute_modification_statements_ext() uses
+ * to uniquely identify a single row in a table when creating modification statements.
+ */
+typedef enum {
+       GDA_DATA_SELECT_COND_PK,
+       GDA_DATA_SELECT_COND_ALL_COLUMNS
+} GdaDataSelectConditionType;
+
 /**
  * SECTION:gda-data-select
  * @short_description: Base class for data models returned by the execution of a SELECT statement
@@ -154,8 +137,6 @@ struct _GdaDataSelectClass {
  *  </mediaobject>
  */
 
-GType          gda_data_select_get_type                     (void) G_GNUC_CONST;
-
 gboolean       gda_data_select_set_row_selection_condition     (GdaDataSelect *model, GdaSqlExpr *expr, 
GError **error);
 gboolean       gda_data_select_set_row_selection_condition_sql (GdaDataSelect *model, const gchar 
*sql_where, GError **error);
 gboolean       gda_data_select_compute_row_selection_condition (GdaDataSelect *model, GError **error);


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