[libgda] GdaSqlitePStmt: removed plublic fields from GObject struct



commit 8120f0d4336d8a952af66e2280f9f10cfd5a829d
Author: Daniel Espinosa Ortiz <esodan gmail com>
Date:   Wed Feb 27 18:14:20 2019 -0600

    GdaSqlitePStmt: removed plublic fields from GObject struct

 libgda/sqlite/gda-sqlite-provider.c  |  79 ++++++++--------
 libgda/sqlite/gda-sqlite-pstmt.c     | 177 ++++++++++++++++++++++++-----------
 libgda/sqlite/gda-sqlite-pstmt.h     |  35 ++++---
 libgda/sqlite/gda-sqlite-recordset.c | 108 ++++++++++-----------
 libgda/sqlite/gda-symbols-util.c     |   2 +
 libgda/sqlite/gda-symbols-util.h     |   1 +
 6 files changed, 236 insertions(+), 166 deletions(-)
---
diff --git a/libgda/sqlite/gda-sqlite-provider.c b/libgda/sqlite/gda-sqlite-provider.c
index d7335209b..07be81afc 100644
--- a/libgda/sqlite/gda-sqlite-provider.c
+++ b/libgda/sqlite/gda-sqlite-provider.c
@@ -2926,12 +2926,12 @@ real_prepare (GdaServerProvider *provider, GdaConnection *cnc, GdaStatement *stm
                g_object_unref (params);
 
        /* create a prepared statement object */
-       ps = _gda_sqlite_pstmt_new (sqlite_stmt);
+       ps = _gda_sqlite_pstmt_new (GDA_SQLITE_PROVIDER (provider), sqlite_stmt);
        gda_pstmt_set_gda_statement (_GDA_PSTMT (ps), stmt);
        gda_pstmt_set_param_ids (_GDA_PSTMT (ps), param_ids);
        gda_pstmt_set_sql (_GDA_PSTMT (ps), sql);
-       ps->rowid_hash = hash;
-       ps->nb_rowid_columns = nb_rows_added;
+       _gda_sqlite_pstmt_set_rowid_hash (ps, hash);
+       _gda_sqlite_pstmt_set_nb_rowid_columns (ps, nb_rows_added);
        g_object_unref (real_stmt);
        /*g_print ("%s(%s) => GdaSqlitePStmt %p\n", __FUNCTION__, sql, ps);*/
        return ps;
@@ -3318,7 +3318,7 @@ gda_sqlite_provider_statement_execute (GdaServerProvider *provider, GdaConnectio
                        }
 
                        /* create a SQLitePreparedStatement */
-                       ps = _gda_sqlite_pstmt_new (sqlite_stmt);
+                       ps = _gda_sqlite_pstmt_new (GDA_SQLITE_PROVIDER (provider), sqlite_stmt);
                        gda_pstmt_set_sql (_GDA_PSTMT (ps), sql);
 
                        new_ps = TRUE;
@@ -3326,7 +3326,7 @@ gda_sqlite_provider_statement_execute (GdaServerProvider *provider, GdaConnectio
                else
                        ps = (GdaSqlitePStmt *) gda_connection_get_prepared_statement (cnc, stmt);
        }
-       else if (ps->stmt_used) {
+       else if (_gda_sqlite_pstmt_get_is_used (ps)) {
                /* Don't use @ps => prepare stmt again */
                GdaSqlitePStmt *nps;
                nps = real_prepare (provider, cnc, stmt, error);
@@ -3338,7 +3338,7 @@ gda_sqlite_provider_statement_execute (GdaServerProvider *provider, GdaConnectio
        }
 
        /* check that prepared stmt is not NULL, to avoid a crash */
-       if (!ps->sqlite_stmt) {
+       if (!_gda_sqlite_pstmt_get_stmt (ps)) {
                GdaConnectionEvent *event;
                const char *errmsg;
 
@@ -3355,8 +3355,8 @@ gda_sqlite_provider_statement_execute (GdaServerProvider *provider, GdaConnectio
        }
 
        /* reset prepared stmt */
-       if ((SQLITE3_CALL (sqlite3_reset) (ps->sqlite_stmt) != SQLITE_OK) ||
-           (SQLITE3_CALL (sqlite3_clear_bindings) (ps->sqlite_stmt) != SQLITE_OK)) {
+       if ((SQLITE3_CALL (sqlite3_reset) (_gda_sqlite_pstmt_get_stmt (ps)) != SQLITE_OK) ||
+           (SQLITE3_CALL (sqlite3_clear_bindings) (_gda_sqlite_pstmt_get_stmt (ps)) != SQLITE_OK)) {
                GdaConnectionEvent *event;
                const char *errmsg;
 
@@ -3402,7 +3402,7 @@ gda_sqlite_provider_statement_execute (GdaServerProvider *provider, GdaConnectio
                if (!h) {
                        if (allow_noparam) {
                                /* bind param to NULL */
-                               SQLITE3_CALL (sqlite3_bind_null) (ps->sqlite_stmt, i);
+                               SQLITE3_CALL (sqlite3_bind_null) (_gda_sqlite_pstmt_get_stmt (ps), i);
                                empty_rs = TRUE;
                                continue;
                        }
@@ -3422,7 +3422,7 @@ gda_sqlite_provider_statement_execute (GdaServerProvider *provider, GdaConnectio
                if (!gda_holder_is_valid (h)) {
                        if (allow_noparam) {
                                /* bind param to NULL */
-                               SQLITE3_CALL (sqlite3_bind_null) (ps->sqlite_stmt, i);
+                               SQLITE3_CALL (sqlite3_bind_null) (_gda_sqlite_pstmt_get_stmt (ps), i);
                                empty_rs = TRUE;
                                continue;
                        }
@@ -3472,7 +3472,7 @@ gda_sqlite_provider_statement_execute (GdaServerProvider *provider, GdaConnectio
                if (!value || gda_value_is_null (value)) {
                        GdaStatement *rstmt;
                        if (! gda_rewrite_statement_for_null_parameters (stmt, params, &rstmt, error))
-                               SQLITE3_CALL (sqlite3_bind_null) (ps->sqlite_stmt, i);
+                               SQLITE3_CALL (sqlite3_bind_null) (_gda_sqlite_pstmt_get_stmt (ps), i);
                        else if (!rstmt)
                                return NULL;
                        else {
@@ -3525,38 +3525,38 @@ gda_sqlite_provider_statement_execute (GdaServerProvider *provider, GdaConnectio
                        }
                }
                else if (G_VALUE_TYPE (value) == G_TYPE_STRING)
-                       SQLITE3_CALL (sqlite3_bind_text) (ps->sqlite_stmt, i,
+                       SQLITE3_CALL (sqlite3_bind_text) (_gda_sqlite_pstmt_get_stmt (ps), i,
                                                          g_value_get_string (value), -1, SQLITE_TRANSIENT);
                else if (G_VALUE_TYPE (value) == GDA_TYPE_TEXT) {
                        GdaText *text = (GdaText*) g_value_get_boxed (value);
                        const gchar *tstr = gda_text_get_string (text);
-                       SQLITE3_CALL (sqlite3_bind_text) (ps->sqlite_stmt, i,
+                       SQLITE3_CALL (sqlite3_bind_text) (_gda_sqlite_pstmt_get_stmt (ps), i,
                                                          tstr, -1, SQLITE_TRANSIENT);
     }
                else if (G_VALUE_TYPE (value) == G_TYPE_INT)
-                       SQLITE3_CALL (sqlite3_bind_int) (ps->sqlite_stmt, i, g_value_get_int (value));
+                       SQLITE3_CALL (sqlite3_bind_int) (_gda_sqlite_pstmt_get_stmt (ps), i, g_value_get_int 
(value));
                else if (G_VALUE_TYPE (value) == G_TYPE_LONG)
-                       SQLITE3_CALL (sqlite3_bind_int) (ps->sqlite_stmt, i, g_value_get_long (value));
+                       SQLITE3_CALL (sqlite3_bind_int) (_gda_sqlite_pstmt_get_stmt (ps), i, g_value_get_long 
(value));
                else if (G_VALUE_TYPE (value) == G_TYPE_DOUBLE)
-                       SQLITE3_CALL (sqlite3_bind_double) (ps->sqlite_stmt, i, g_value_get_double (value));
+                       SQLITE3_CALL (sqlite3_bind_double) (_gda_sqlite_pstmt_get_stmt (ps), i, 
g_value_get_double (value));
                else if (G_VALUE_TYPE (value) == G_TYPE_FLOAT)
-                       SQLITE3_CALL (sqlite3_bind_double) (ps->sqlite_stmt, i, g_value_get_float (value));
+                       SQLITE3_CALL (sqlite3_bind_double) (_gda_sqlite_pstmt_get_stmt (ps), i, 
g_value_get_float (value));
                else if (G_VALUE_TYPE (value) == G_TYPE_UINT)
-                       SQLITE3_CALL (sqlite3_bind_int) (ps->sqlite_stmt, i, g_value_get_uint (value));
+                       SQLITE3_CALL (sqlite3_bind_int) (_gda_sqlite_pstmt_get_stmt (ps), i, g_value_get_uint 
(value));
                else if (G_VALUE_TYPE (value) == G_TYPE_BOOLEAN)
-                       SQLITE3_CALL (sqlite3_bind_int) (ps->sqlite_stmt, i, g_value_get_boolean (value) ? 1 
: 0);
+                       SQLITE3_CALL (sqlite3_bind_int) (_gda_sqlite_pstmt_get_stmt (ps), i, 
g_value_get_boolean (value) ? 1 : 0);
                else if (G_VALUE_TYPE (value) == G_TYPE_INT64)
-                       SQLITE3_CALL (sqlite3_bind_int64) (ps->sqlite_stmt, i, g_value_get_int64 (value));
+                       SQLITE3_CALL (sqlite3_bind_int64) (_gda_sqlite_pstmt_get_stmt (ps), i, 
g_value_get_int64 (value));
                else if (G_VALUE_TYPE (value) == G_TYPE_UINT64)
-                       SQLITE3_CALL (sqlite3_bind_int64) (ps->sqlite_stmt, i, g_value_get_uint64 (value));
+                       SQLITE3_CALL (sqlite3_bind_int64) (_gda_sqlite_pstmt_get_stmt (ps), i, 
g_value_get_uint64 (value));
                else if (G_VALUE_TYPE (value) == GDA_TYPE_SHORT)
-                       SQLITE3_CALL (sqlite3_bind_int) (ps->sqlite_stmt, i, gda_value_get_short (value));
+                       SQLITE3_CALL (sqlite3_bind_int) (_gda_sqlite_pstmt_get_stmt (ps), i, 
gda_value_get_short (value));
                else if (G_VALUE_TYPE (value) == GDA_TYPE_USHORT)
-                       SQLITE3_CALL (sqlite3_bind_int) (ps->sqlite_stmt, i, gda_value_get_ushort (value));
+                       SQLITE3_CALL (sqlite3_bind_int) (_gda_sqlite_pstmt_get_stmt (ps), i, 
gda_value_get_ushort (value));
                else if (G_VALUE_TYPE (value) == G_TYPE_CHAR)
-                       SQLITE3_CALL (sqlite3_bind_int) (ps->sqlite_stmt, i, g_value_get_schar (value));
+                       SQLITE3_CALL (sqlite3_bind_int) (_gda_sqlite_pstmt_get_stmt (ps), i, 
g_value_get_schar (value));
                else if (G_VALUE_TYPE (value) == G_TYPE_UCHAR)
-                       SQLITE3_CALL (sqlite3_bind_int) (ps->sqlite_stmt, i, g_value_get_uchar (value));
+                       SQLITE3_CALL (sqlite3_bind_int) (_gda_sqlite_pstmt_get_stmt (ps), i, 
g_value_get_uchar (value));
                else if (G_VALUE_TYPE (value) == GDA_TYPE_BLOB) {
                        glong blob_len;
                        GdaBlob *blob = (GdaBlob*) gda_value_get_blob (value);
@@ -3594,7 +3594,7 @@ gda_sqlite_provider_statement_execute (GdaServerProvider *provider, GdaConnectio
                        pb->blob = blob;
                        blobs_list = g_slist_prepend (blobs_list, pb);
 
-                       if (SQLITE3_CALL (sqlite3_bind_zeroblob) (ps->sqlite_stmt, i, (int) blob_len) !=
+                       if (SQLITE3_CALL (sqlite3_bind_zeroblob) (_gda_sqlite_pstmt_get_stmt (ps), i, (int) 
blob_len) !=
                            SQLITE_OK) {
                                event = gda_connection_point_available_event (cnc, 
GDA_CONNECTION_EVENT_ERROR);
                                gda_connection_event_set_description (event,
@@ -3606,7 +3606,7 @@ gda_sqlite_provider_statement_execute (GdaServerProvider *provider, GdaConnectio
                }
                else if (G_VALUE_TYPE (value) == GDA_TYPE_BINARY) {
                        GdaBinary *bin = (GdaBinary *) gda_value_get_binary (value);
-                       SQLITE3_CALL (sqlite3_bind_blob) (ps->sqlite_stmt, i,
+                       SQLITE3_CALL (sqlite3_bind_blob) (_gda_sqlite_pstmt_get_stmt (ps), i,
                                                          gda_binary_get_data (bin), gda_binary_get_size 
(bin), SQLITE_TRANSIENT);
                }
                else if (G_VALUE_TYPE (value) == GDA_TYPE_TIME) {
@@ -3634,7 +3634,7 @@ gda_sqlite_provider_statement_execute (GdaServerProvider *provider, GdaConnectio
 
                        if (tofree)
                                gda_time_free (gtime);
-                       SQLITE3_CALL (sqlite3_bind_text) (ps->sqlite_stmt, i, g_string_free (string, FALSE), 
-1, g_free);
+                       SQLITE3_CALL (sqlite3_bind_text) (_gda_sqlite_pstmt_get_stmt (ps), i, g_string_free 
(string, FALSE), -1, g_free);
                }
                else if (G_VALUE_TYPE (value) == G_TYPE_DATE) {
                        gchar *str;
@@ -3643,7 +3643,7 @@ gda_sqlite_provider_statement_execute (GdaServerProvider *provider, GdaConnectio
                        ts = g_value_get_boxed (value);
                        str = g_strdup_printf ("%4d-%02d-%02d", g_date_get_year (ts),
                                               g_date_get_month (ts), g_date_get_day (ts));
-                       SQLITE3_CALL (sqlite3_bind_text) (ps->sqlite_stmt, i, str, -1, g_free);
+                       SQLITE3_CALL (sqlite3_bind_text) (_gda_sqlite_pstmt_get_stmt (ps), i, str, -1, 
g_free);
                }
                else if (g_type_is_a (G_VALUE_TYPE (value), G_TYPE_DATE_TIME)) {
                        GDateTime *timestamp;
@@ -3663,13 +3663,13 @@ gda_sqlite_provider_statement_execute (GdaServerProvider *provider, GdaConnectio
                        if (tofree)
                                g_date_time_unref (timestamp);
 
-                       SQLITE3_CALL (sqlite3_bind_text) (ps->sqlite_stmt, i, string, -1, g_free);
+                       SQLITE3_CALL (sqlite3_bind_text) (_gda_sqlite_pstmt_get_stmt (ps), i, string, -1, 
g_free);
                }
                else if (G_VALUE_TYPE (value) == GDA_TYPE_NUMERIC) {
                        const GdaNumeric *gdan;
 
                        gdan = gda_value_get_numeric (value);
-                       SQLITE3_CALL (sqlite3_bind_text) (ps->sqlite_stmt, i, 
gda_numeric_get_string((GdaNumeric*)gdan), -1, SQLITE_TRANSIENT);
+                       SQLITE3_CALL (sqlite3_bind_text) (_gda_sqlite_pstmt_get_stmt (ps), i, 
gda_numeric_get_string((GdaNumeric*)gdan), -1, SQLITE_TRANSIENT);
                }
                else {
                        gchar *str;
@@ -3762,14 +3762,14 @@ gda_sqlite_provider_statement_execute (GdaServerProvider *provider, GdaConnectio
                }
 
                 /* actually execute the command */
-                handle = SQLITE3_CALL (sqlite3_db_handle) (ps->sqlite_stmt);
-                status = SQLITE3_CALL (sqlite3_step) (ps->sqlite_stmt);
+                handle = SQLITE3_CALL (sqlite3_db_handle) (_gda_sqlite_pstmt_get_stmt (ps));
+                status = SQLITE3_CALL (sqlite3_step) (_gda_sqlite_pstmt_get_stmt (ps));
                 guint tries = 0;
                 while (status == SQLITE_BUSY) {
                         if (gda_statement_get_statement_type (stmt) == GDA_SQL_STATEMENT_COMMIT) {
                                 break;
                         }
-                        status = SQLITE3_CALL (sqlite3_step) (ps->sqlite_stmt);
+                        status = SQLITE3_CALL (sqlite3_step) (_gda_sqlite_pstmt_get_stmt (ps));
                         if (tries == 10) {
                                 break;
                         }
@@ -3779,7 +3779,7 @@ gda_sqlite_provider_statement_execute (GdaServerProvider *provider, GdaConnectio
                 if (status != SQLITE_DONE) {
                         if (SQLITE3_CALL (sqlite3_errcode) (handle) != SQLITE_OK) {
                                const char *errmsg;
-                                SQLITE3_CALL (sqlite3_reset) (ps->sqlite_stmt);
+                                SQLITE3_CALL (sqlite3_reset) (_gda_sqlite_pstmt_get_stmt (ps));
 
                                errmsg = SQLITE3_CALL (sqlite3_errmsg) (handle);
                                 event = gda_connection_point_available_event (cnc, 
GDA_CONNECTION_EVENT_ERROR);
@@ -3813,7 +3813,7 @@ gda_sqlite_provider_statement_execute (GdaServerProvider *provider, GdaConnectio
                        event = fill_blob_data (cnc, params, cdata, ps, blobs_list, error);
                        if (event) {
                                /* an error occurred */
-                               SQLITE3_CALL (sqlite3_reset) (ps->sqlite_stmt);
+                               SQLITE3_CALL (sqlite3_reset) (_gda_sqlite_pstmt_get_stmt (ps));
                                if (new_ps)
                                        g_object_unref (ps);
                                if (transaction_started)
@@ -3864,7 +3864,7 @@ gda_sqlite_provider_statement_execute (GdaServerProvider *provider, GdaConnectio
                                                                             gda_connection_add_event (cnc, 
event);
                        }
                        gda_connection_internal_statement_executed (cnc, stmt, params, event);
-                       SQLITE3_CALL (sqlite3_reset) (ps->sqlite_stmt);
+                       SQLITE3_CALL (sqlite3_reset) (_gda_sqlite_pstmt_get_stmt (ps));
                        if (new_ps)
                                g_object_unref (ps);
 
@@ -4269,10 +4269,7 @@ gda_sqlite_free_cnc_data (SqliteConnectionData *cdata)
                return;
 
        if (cdata->connection) {
-               gint status = SQLITE3_CALL (sqlite3_close) (cdata->connection);
-               if (status == SQLITE_BUSY) {
-                       g_warning (_("SQLite: Connection data has been destroyed, but connection is BUSY, so 
was not closed"));
-               }
+               SQLITE3_CALL (sqlite3_close_v2) (cdata->connection);
        }
        g_free (cdata->file);
        if (cdata->types_hash)
diff --git a/libgda/sqlite/gda-sqlite-pstmt.c b/libgda/sqlite/gda-sqlite-pstmt.c
index 48e4cb785..e3598a1bb 100644
--- a/libgda/sqlite/gda-sqlite-pstmt.c
+++ b/libgda/sqlite/gda-sqlite-pstmt.c
@@ -23,89 +23,160 @@
 #include "gda-sqlite.h"
 #include <string.h>
 
-static void gda_sqlite_pstmt_class_init (GdaSqlitePStmtClass *klass);
-static void gda_sqlite_pstmt_init       (GdaSqlitePStmt *pstmt, GdaSqlitePStmtClass *klass);
-static void gda_sqlite_pstmt_finalize    (GObject *object);
+static void _gda_sqlite_pstmt_dispose    (GObject *object);
 
-static GObjectClass *parent_class = NULL;
+typedef struct {
+       GWeakRef        provider;
+       sqlite3_stmt   *sqlite_stmt;
+       gboolean        stmt_used; /* TRUE if a recorset already uses this prepared statement,
+                                   * necessary because only one recordset can use sqlite_stmt at a time */
+       GHashTable      *rowid_hash;
+       gint             nb_rowid_columns;
+} GdaSqlitePStmtPrivate;
 
-/**
- * _gda_sqlite_pstmt_get_type
- *
- * Returns: the #GType of GdaSqlitePStmt.
- */
-GType
-_gda_sqlite_pstmt_get_type (void)
-{
-       static GType type = 0;
-
-       if (G_UNLIKELY (type == 0)) {
-               static GMutex registering;
-               static const GTypeInfo info = {
-                       sizeof (GdaSqlitePStmtClass),
-                       (GBaseInitFunc) NULL,
-                       (GBaseFinalizeFunc) NULL,
-                       (GClassInitFunc) gda_sqlite_pstmt_class_init,
-                       NULL,
-                       NULL,
-                       sizeof (GdaSqlitePStmt),
-                       0,
-                       (GInstanceInitFunc) gda_sqlite_pstmt_init,
-                       0
-               };
-
-               g_mutex_lock (&registering);
-               if (type == 0)
-                       type = g_type_register_static (GDA_TYPE_PSTMT, CLASS_PREFIX "PStmt", &info, 0);
-               g_mutex_unlock (&registering);
-       }
-       return type;
-}
+G_DEFINE_TYPE_WITH_PRIVATE (GdaSqlitePStmt, _gda_sqlite_pstmt, GDA_TYPE_PSTMT)
 
 static void 
-gda_sqlite_pstmt_class_init (GdaSqlitePStmtClass *klass)
+_gda_sqlite_pstmt_class_init (GdaSqlitePStmtClass *klass)
 {
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
-       parent_class = g_type_class_peek_parent (klass);
 
        /* virtual functions */
-       object_class->finalize = gda_sqlite_pstmt_finalize;
+       object_class->finalize = _gda_sqlite_pstmt_dispose;
 }
 
 static void
-gda_sqlite_pstmt_init (GdaSqlitePStmt *pstmt, G_GNUC_UNUSED GdaSqlitePStmtClass *klass)
+_gda_sqlite_pstmt_init (GdaSqlitePStmt *pstmt)
 {
-       g_return_if_fail (GDA_IS_PSTMT (pstmt));
-       pstmt->sqlite_stmt = NULL;
-       pstmt->stmt_used = FALSE;
-       pstmt->rowid_hash = NULL;
-       pstmt->nb_rowid_columns = 0;
+       GdaSqlitePStmtPrivate *priv = _gda_sqlite_pstmt_get_instance_private (pstmt);
+       priv->sqlite_stmt = NULL;
+       priv->stmt_used = FALSE;
+       priv->rowid_hash = NULL;
+       priv->nb_rowid_columns = 0;
+       g_weak_ref_init (&priv->provider, NULL);
 }
 
 static void
-gda_sqlite_pstmt_finalize (GObject *object)
+_gda_sqlite_pstmt_dispose (GObject *object)
 {
        GdaSqlitePStmt *pstmt = (GdaSqlitePStmt *) object;
+       GdaSqlitePStmtPrivate *priv = _gda_sqlite_pstmt_get_instance_private (pstmt);
 
        g_return_if_fail (GDA_IS_PSTMT (pstmt));
 
        /* free memory */
-       if (pstmt->sqlite_stmt) 
-               SQLITE3_CALL (sqlite3_finalize) (pstmt->sqlite_stmt);
+       if (priv->sqlite_stmt != NULL) {
+               SQLITE3_CALL (sqlite3_finalize) (priv->sqlite_stmt);
+               priv->sqlite_stmt = NULL;
+       }
 
-       if (pstmt->rowid_hash)
-               g_hash_table_destroy (pstmt->rowid_hash);
+       if (priv->rowid_hash != NULL) {
+               g_hash_table_destroy (priv->rowid_hash);
+               priv->rowid_hash = NULL;
+       }
 
        /* chain to parent class */
-       parent_class->finalize (object);
+       G_OBJECT_CLASS (_gda_sqlite_pstmt_parent_class)->finalize (object);
 }
 
 GdaSqlitePStmt *
-_gda_sqlite_pstmt_new (sqlite3_stmt *sqlite_stmt)
+_gda_sqlite_pstmt_new (GdaSqliteProvider *provider, sqlite3_stmt *sqlite_stmt)
 {
        GdaSqlitePStmt *pstmt;
 
        pstmt = (GdaSqlitePStmt*) g_object_new (GDA_TYPE_SQLITE_PSTMT, NULL);
-       pstmt->sqlite_stmt = sqlite_stmt;
+
+       GdaSqlitePStmtPrivate *priv = _gda_sqlite_pstmt_get_instance_private (pstmt);
+
+       priv->sqlite_stmt = sqlite_stmt;
+       g_weak_ref_set (&priv->provider, provider);
        return pstmt;
 }
+
+/**
+ * Returns: (transfer full): current #GdaSqliteProvider
+ */
+GdaSqliteProvider*
+_gda_sqlite_pstmt_get_provider (GdaSqlitePStmt *pstmt)
+{
+       g_return_val_if_fail (pstmt != NULL, NULL);
+       g_return_val_if_fail (GDA_IS_SQLITE_PSTMT (pstmt), NULL);
+       GdaSqlitePStmtPrivate *priv = _gda_sqlite_pstmt_get_instance_private (pstmt);
+
+       return g_weak_ref_get (&priv->provider);
+}
+sqlite3_stmt*
+_gda_sqlite_pstmt_get_stmt (GdaSqlitePStmt *pstmt)
+{
+       g_return_val_if_fail (pstmt != NULL, NULL);
+       g_return_val_if_fail (GDA_IS_SQLITE_PSTMT (pstmt), NULL);
+       GdaSqlitePStmtPrivate *priv = _gda_sqlite_pstmt_get_instance_private (pstmt);
+
+       return priv->sqlite_stmt;
+}
+gboolean
+_gda_sqlite_pstmt_get_is_used  (GdaSqlitePStmt *pstmt)
+{
+       g_return_val_if_fail (pstmt != NULL, FALSE);
+       g_return_val_if_fail (GDA_IS_SQLITE_PSTMT (pstmt), FALSE);
+       GdaSqlitePStmtPrivate *priv = _gda_sqlite_pstmt_get_instance_private (pstmt);
+
+       return priv->stmt_used;
+}
+void
+_gda_sqlite_pstmt_set_is_used (GdaSqlitePStmt *pstmt,
+                               gboolean used)
+{
+       g_return_if_fail (pstmt != NULL);
+       g_return_if_fail (GDA_IS_SQLITE_PSTMT (pstmt));
+       GdaSqlitePStmtPrivate *priv = _gda_sqlite_pstmt_get_instance_private (pstmt);
+       priv->stmt_used = used;
+}
+
+GHashTable*
+_gda_sqlite_pstmt_get_rowid_hash (GdaSqlitePStmt *pstmt)
+{
+       g_return_val_if_fail (pstmt != NULL, NULL);
+       g_return_val_if_fail (GDA_IS_SQLITE_PSTMT (pstmt), NULL);
+       GdaSqlitePStmtPrivate *priv = _gda_sqlite_pstmt_get_instance_private (pstmt);
+
+       return priv->rowid_hash;
+}
+void
+_gda_sqlite_pstmt_set_rowid_hash (GdaSqlitePStmt *pstmt,
+                                  GHashTable *hash)
+{
+       g_return_if_fail (pstmt != NULL);
+       g_return_if_fail (GDA_IS_SQLITE_PSTMT (pstmt));
+       GdaSqlitePStmtPrivate *priv = _gda_sqlite_pstmt_get_instance_private (pstmt);
+
+       if (priv->rowid_hash != NULL) {
+               g_hash_table_unref (priv->rowid_hash);
+               priv->rowid_hash = NULL;
+       }
+       if (hash != NULL) {
+               priv->rowid_hash = g_hash_table_ref (hash);
+       } else {
+               priv->rowid_hash = NULL;
+       }
+}
+gint
+_gda_sqlite_pstmt_get_nb_rowid_columns (GdaSqlitePStmt *pstmt)
+{
+       g_return_val_if_fail (pstmt != NULL, -1);
+       g_return_val_if_fail (GDA_IS_SQLITE_PSTMT (pstmt), -1);
+       GdaSqlitePStmtPrivate *priv = _gda_sqlite_pstmt_get_instance_private (pstmt);
+
+       return priv->nb_rowid_columns;
+}
+void
+_gda_sqlite_pstmt_set_nb_rowid_columns (GdaSqlitePStmt *pstmt,
+                                        gint nb)
+{
+       g_return_if_fail (pstmt != NULL);
+       g_return_if_fail (GDA_IS_SQLITE_PSTMT (pstmt));
+       GdaSqlitePStmtPrivate *priv = _gda_sqlite_pstmt_get_instance_private (pstmt);
+
+       priv->nb_rowid_columns = nb;
+}
+
diff --git a/libgda/sqlite/gda-sqlite-pstmt.h b/libgda/sqlite/gda-sqlite-pstmt.h
index 18309234d..1a1d98731 100644
--- a/libgda/sqlite/gda-sqlite-pstmt.h
+++ b/libgda/sqlite/gda-sqlite-pstmt.h
@@ -21,6 +21,7 @@
 #ifndef __GDA_SQLITE_PSTMT_H__
 #define __GDA_SQLITE_PSTMT_H__
 
+#include <libgda/sqlite/gda-sqlite-provider.h>
 #include <libgda/providers-support/gda-pstmt.h>
 #ifdef STATIC_SQLITE
 #include "sqlite-src/sqlite3.h"
@@ -35,30 +36,28 @@
 G_BEGIN_DECLS
 
 #define GDA_TYPE_SQLITE_PSTMT            (_gda_sqlite_pstmt_get_type())
-#define GDA_SQLITE_PSTMT(obj)            (G_TYPE_CHECK_INSTANCE_CAST (obj, GDA_TYPE_PSTMT, GdaSqlitePStmt))
-#define GDA_SQLITE_PSTMT_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST (klass, GDA_TYPE_PSTMT, 
GdaSqlitePStmtClass))
-#define GDA_IS_SQLITE_PSTMT(obj)         (G_TYPE_CHECK_INSTANCE_TYPE(obj, GDA_TYPE_PSTMT))
-#define GDA_IS_SQLITE_PSTMT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GDA_TYPE_PSTMT))
 
-typedef struct _GdaSqlitePStmt        GdaSqlitePStmt;
-typedef struct _GdaSqlitePStmtClass   GdaSqlitePStmtClass;
-
-struct _GdaSqlitePStmt {
-       GdaPStmt        object;
-
-       sqlite3_stmt   *sqlite_stmt;
-       gboolean        stmt_used; /* TRUE if a recorset already uses this prepared statement,
-                                   * necessary because only one recordset can use sqlite_stmt at a time */
-       GHashTable      *rowid_hash;
-       gint             nb_rowid_columns;
-};
+G_DECLARE_DERIVABLE_TYPE (GdaSqlitePStmt, _gda_sqlite_pstmt, GDA, SQLITE_PSTMT, GdaPStmt)
 
 struct _GdaSqlitePStmtClass {
        GdaPStmtClass  parent_class;
 };
 
-GType           _gda_sqlite_pstmt_get_type  (void) G_GNUC_CONST;
-GdaSqlitePStmt *_gda_sqlite_pstmt_new       (sqlite3_stmt *sqlite_stmt);
+GdaSqlitePStmt                 *_gda_sqlite_pstmt_new          (GdaSqliteProvider *provider,
+                                                                sqlite3_stmt *sqlite_stmt);
+
+GdaSqliteProvider              *_gda_sqlite_pstmt_get_provider (GdaSqlitePStmt *pstmt);
+sqlite3_stmt                   *_gda_sqlite_pstmt_get_stmt     (GdaSqlitePStmt *pstmt);
+gboolean                       _gda_sqlite_pstmt_get_is_used   (GdaSqlitePStmt *pstmt);
+void                           _gda_sqlite_pstmt_set_is_used   (GdaSqlitePStmt *pstmt,
+                                                                gboolean used);
+
+GHashTable                     *_gda_sqlite_pstmt_get_rowid_hash (GdaSqlitePStmt *pstmt);
+void                            _gda_sqlite_pstmt_set_rowid_hash (GdaSqlitePStmt *pstmt,
+                                                                  GHashTable *hash);
+gint                            _gda_sqlite_pstmt_get_nb_rowid_columns (GdaSqlitePStmt *pstmt);
+void                            _gda_sqlite_pstmt_set_nb_rowid_columns (GdaSqlitePStmt *pstmt,
+                                                                        gint nb);
 
 G_END_DECLS
 
diff --git a/libgda/sqlite/gda-sqlite-recordset.c b/libgda/sqlite/gda-sqlite-recordset.c
index 816425eeb..bc7e703ee 100644
--- a/libgda/sqlite/gda-sqlite-recordset.c
+++ b/libgda/sqlite/gda-sqlite-recordset.c
@@ -115,9 +115,9 @@ gda_sqlite_recordset_dispose (GObject *object)
                GdaSqlitePStmt *ps;
                ps = GDA_SQLITE_PSTMT (gda_data_select_get_prep_stmt (GDA_DATA_SELECT (object)));
                if (ps != NULL) {
-                       ps->stmt_used = FALSE;
+                       _gda_sqlite_pstmt_set_is_used (ps, FALSE);
                        virt_cnc_set_working_obj (gda_data_select_get_connection ((GdaDataSelect*) recset), 
recset);
-                       SQLITE3_CALL (sqlite3_reset) (ps->sqlite_stmt);
+                       SQLITE3_CALL (sqlite3_reset) (_gda_sqlite_pstmt_get_stmt (ps));
                        virt_cnc_set_working_obj (gda_data_select_get_connection ((GdaDataSelect*) recset), 
NULL);
                }
 
@@ -249,12 +249,12 @@ _gda_sqlite_recordset_new (GdaConnection *cnc, GdaSqlitePStmt *ps, GdaSet *exec_
 
         /* make sure @ps reports the correct number of columns */
        if (gda_pstmt_get_ncols (_GDA_PSTMT (ps)) < 0)
-               gda_pstmt_set_cols (_GDA_PSTMT (ps), SQLITE3_CALL (sqlite3_column_count) (ps->sqlite_stmt) -
-                       ps->nb_rowid_columns, gda_pstmt_get_types (_GDA_PSTMT (ps)));
+               gda_pstmt_set_cols (_GDA_PSTMT (ps), SQLITE3_CALL (sqlite3_column_count) 
(_gda_sqlite_pstmt_get_stmt (ps)) -
+                       _gda_sqlite_pstmt_get_nb_rowid_columns (ps), gda_pstmt_get_types (_GDA_PSTMT (ps)));
 
         /* completing ps */
-       g_assert (! ps->stmt_used);
-       ps->stmt_used = TRUE;
+       g_assert (! _gda_sqlite_pstmt_get_is_used (ps));
+       _gda_sqlite_pstmt_set_is_used (ps, TRUE);
        if (!gda_pstmt_get_types (_GDA_PSTMT (ps)) && (gda_pstmt_get_ncols (_GDA_PSTMT (ps)) > 0)) {
                /* create prepared statement's columns */
                GSList *list;
@@ -287,12 +287,12 @@ _gda_sqlite_recordset_new (GdaConnection *cnc, GdaSqlitePStmt *ps, GdaSet *exec_
                     i < gda_pstmt_get_ncols (_GDA_PSTMT (ps));
                     i++, list = list->next) {
                        GdaColumn *column;
-                       gint real_col = i + ps->nb_rowid_columns;
+                       gint real_col = i + _gda_sqlite_pstmt_get_nb_rowid_columns (ps);
                        
                        column = GDA_COLUMN (list->data);
-                       gda_column_set_description (column, SQLITE3_CALL (sqlite3_column_name) 
(ps->sqlite_stmt, real_col));
-                       gda_column_set_name (column, SQLITE3_CALL (sqlite3_column_name) (ps->sqlite_stmt, 
real_col));
-                       gda_column_set_dbms_type (column, SQLITE3_CALL (sqlite3_column_decltype) 
(ps->sqlite_stmt, real_col));
+                       gda_column_set_description (column, SQLITE3_CALL (sqlite3_column_name) 
(_gda_sqlite_pstmt_get_stmt (ps), real_col));
+                       gda_column_set_name (column, SQLITE3_CALL (sqlite3_column_name) 
(_gda_sqlite_pstmt_get_stmt (ps), real_col));
+                       gda_column_set_dbms_type (column, SQLITE3_CALL (sqlite3_column_decltype) 
(_gda_sqlite_pstmt_get_stmt (ps), real_col));
                        if (gda_pstmt_get_types (_GDA_PSTMT (ps)) [i] != GDA_TYPE_NULL)
                                gda_column_set_g_type (column, gda_pstmt_get_types (_GDA_PSTMT (ps)) [i]);
                }
@@ -331,16 +331,16 @@ fuzzy_get_gtype (SqliteConnectionData *cdata, GdaSqlitePStmt *ps, gint colnum)
 {
        const gchar *ctype;
        GType gtype = GDA_TYPE_NULL;
-       gint real_col = colnum + ps->nb_rowid_columns;
+       gint real_col = colnum + _gda_sqlite_pstmt_get_nb_rowid_columns (ps);
 
        if (gda_pstmt_get_types (_GDA_PSTMT (ps)) [colnum] != GDA_TYPE_NULL)
                return gda_pstmt_get_types (_GDA_PSTMT (ps)) [colnum];
        
-       ctype = SQLITE3_CALL (sqlite3_column_origin_name) (ps->sqlite_stmt, real_col);
+       ctype = SQLITE3_CALL (sqlite3_column_origin_name) (_gda_sqlite_pstmt_get_stmt (ps), real_col);
        if (ctype && !strcmp (ctype, "rowid"))
                gtype = G_TYPE_INT64;
        else {
-               ctype = SQLITE3_CALL (sqlite3_column_decltype) (ps->sqlite_stmt, real_col);
+               ctype = SQLITE3_CALL (sqlite3_column_decltype) (_gda_sqlite_pstmt_get_stmt (ps), real_col);
                
                if (ctype) {
                        GType *pg;
@@ -348,7 +348,7 @@ fuzzy_get_gtype (SqliteConnectionData *cdata, GdaSqlitePStmt *ps, gint colnum)
                        gtype = pg ? *pg : GDA_TYPE_NULL;
                }
                if (gtype == GDA_TYPE_NULL) 
-                       gtype = _gda_sqlite_compute_g_type (SQLITE3_CALL (sqlite3_column_type) 
(ps->sqlite_stmt, real_col));
+                       gtype = _gda_sqlite_compute_g_type (SQLITE3_CALL (sqlite3_column_type) 
(_gda_sqlite_pstmt_get_stmt (ps), real_col));
        }
 
        return gtype;
@@ -384,7 +384,7 @@ fetch_next_sqlite_row (GdaSqliteRecordset *model, gboolean do_store, GError **er
        if (model->priv->empty_forced)
                rc = SQLITE_DONE;
        else            
-               rc = SQLITE3_CALL (sqlite3_step) (ps->sqlite_stmt);
+               rc = SQLITE3_CALL (sqlite3_step) (_gda_sqlite_pstmt_get_stmt (ps));
        switch (rc) {
        case  SQLITE_ROW: {
                gint col, real_col;
@@ -393,23 +393,23 @@ fetch_next_sqlite_row (GdaSqliteRecordset *model, gboolean do_store, GError **er
                        GValue *value;
                        GType type = gda_pstmt_get_types (_GDA_PSTMT (ps)) [col];
                        
-                       real_col = col + ps->nb_rowid_columns;
+                       real_col = col + _gda_sqlite_pstmt_get_nb_rowid_columns (ps);
 
                        if (type == GDA_TYPE_NULL) {
                                type = fuzzy_get_gtype (cdata, ps, col);
                                if (type == GDA_TYPE_BLOB) {
                                        /* extra check: make sure we have a rowid for this blob, or fallback 
to binary */
-                                       if (ps->rowid_hash) {
+                                       if (_gda_sqlite_pstmt_get_rowid_hash (ps)) {
                                                gint oidcol = 0;
                                                const char *ctable;
-                                               ctable = SQLITE3_CALL (sqlite3_column_name) (ps->sqlite_stmt, 
real_col);
+                                               ctable = SQLITE3_CALL (sqlite3_column_name) 
(_gda_sqlite_pstmt_get_stmt (ps), real_col);
                                                if (ctable)
-                                                       oidcol = GPOINTER_TO_INT (g_hash_table_lookup 
(ps->rowid_hash,
+                                                       oidcol = GPOINTER_TO_INT (g_hash_table_lookup 
(_gda_sqlite_pstmt_get_rowid_hash (ps),
                                                                                                       
ctable));
                                                if (oidcol == 0) {
-                                                       ctable = SQLITE3_CALL (sqlite3_column_table_name) 
(ps->sqlite_stmt, real_col);
+                                                       ctable = SQLITE3_CALL (sqlite3_column_table_name) 
(_gda_sqlite_pstmt_get_stmt (ps), real_col);
                                                        if (ctable)
-                                                               oidcol = GPOINTER_TO_INT (g_hash_table_lookup 
(ps->rowid_hash, 
+                                                               oidcol = GPOINTER_TO_INT (g_hash_table_lookup 
(_gda_sqlite_pstmt_get_rowid_hash (ps),
                                                                                                              
 ctable));
                                                }
                                                if (oidcol == 0)
@@ -432,13 +432,13 @@ fetch_next_sqlite_row (GdaSqliteRecordset *model, gboolean do_store, GError **er
                        /* fill GValue */
                        value = gda_row_get_value (prow, col);
                        GError *may_error;
-                       may_error = (GError*) SQLITE3_CALL (sqlite3_column_blob) (ps->sqlite_stmt, real_col);
+                       may_error = (GError*) SQLITE3_CALL (sqlite3_column_blob) (_gda_sqlite_pstmt_get_stmt 
(ps), real_col);
                        if (may_error && g_hash_table_lookup (error_blobs_hash, may_error)) {
                                /*g_print ("Row invalidated: [%s]\n", may_error->message);*/
                                gda_row_invalidate_value_e (prow, value, may_error);
                                g_hash_table_remove (error_blobs_hash, may_error);
                        }
-                       else if (SQLITE3_CALL (sqlite3_column_text) (ps->sqlite_stmt, real_col) == NULL) {
+                       else if (SQLITE3_CALL (sqlite3_column_text) (_gda_sqlite_pstmt_get_stmt (ps), 
real_col) == NULL) {
                                /* we have a NULL value */
                                gda_value_set_null (value);
                        }
@@ -449,7 +449,7 @@ fetch_next_sqlite_row (GdaSqliteRecordset *model, gboolean do_store, GError **er
                                        ;
                                else if (type == G_TYPE_INT) {
                                        gint64 i;
-                                       i = SQLITE3_CALL (sqlite3_column_int64) (ps->sqlite_stmt, real_col);
+                                       i = SQLITE3_CALL (sqlite3_column_int64) (_gda_sqlite_pstmt_get_stmt 
(ps), real_col);
                                        if ((i > G_MAXINT) || (i < G_MININT)) {
                                                GError *lerror = NULL;
                                                g_set_error (&lerror, GDA_SERVER_PROVIDER_ERROR,
@@ -462,7 +462,7 @@ fetch_next_sqlite_row (GdaSqliteRecordset *model, gboolean do_store, GError **er
                                }
                                else if (type == G_TYPE_UINT) {
                                        guint64 i;
-                                       i = (gint64) SQLITE3_CALL (sqlite3_column_int64) (ps->sqlite_stmt, 
real_col);
+                                       i = (gint64) SQLITE3_CALL (sqlite3_column_int64) 
(_gda_sqlite_pstmt_get_stmt (ps), real_col);
                                        if (i > G_MAXUINT) {
                                                GError *lerror = NULL;
                                                g_set_error (&lerror, GDA_SERVER_PROVIDER_ERROR,
@@ -474,19 +474,19 @@ fetch_next_sqlite_row (GdaSqliteRecordset *model, gboolean do_store, GError **er
                                                g_value_set_uint (value, (gint) i);
                                }
                                else if (type == G_TYPE_INT64)
-                                       g_value_set_int64 (value, SQLITE3_CALL (sqlite3_column_int64) 
(ps->sqlite_stmt, real_col));
+                                       g_value_set_int64 (value, SQLITE3_CALL (sqlite3_column_int64) 
(_gda_sqlite_pstmt_get_stmt (ps), real_col));
                                else if (type == G_TYPE_UINT64)
-                                       g_value_set_uint64 (value, (guint64) SQLITE3_CALL 
(sqlite3_column_int64) (ps->sqlite_stmt,
+                                       g_value_set_uint64 (value, (guint64) SQLITE3_CALL 
(sqlite3_column_int64) (_gda_sqlite_pstmt_get_stmt (ps),
                                                                                                   real_col));
                                else if (type == G_TYPE_DOUBLE)
-                                       g_value_set_double (value, SQLITE3_CALL (sqlite3_column_double) 
(ps->sqlite_stmt,
+                                       g_value_set_double (value, SQLITE3_CALL (sqlite3_column_double) 
(_gda_sqlite_pstmt_get_stmt (ps),
                                                                                          real_col));
                                else if (type == G_TYPE_STRING)
-                                       g_value_set_string (value, (gchar *) SQLITE3_CALL 
(sqlite3_column_text) (ps->sqlite_stmt,
+                                       g_value_set_string (value, (gchar *) SQLITE3_CALL 
(sqlite3_column_text) (_gda_sqlite_pstmt_get_stmt (ps),
                                                                                                  real_col));
                                else if (type == GDA_TYPE_TEXT) {
                                        GdaText *text = gda_text_new ();
-                                       gda_text_set_string (text, (const gchar *) SQLITE3_CALL 
(sqlite3_column_text) (ps->sqlite_stmt,
+                                       gda_text_set_string (text, (const gchar *) SQLITE3_CALL 
(sqlite3_column_text) (_gda_sqlite_pstmt_get_stmt (ps),
                                                                                                  real_col));
                                        g_value_take_boxed (value, text);
                                }
@@ -494,9 +494,9 @@ fetch_next_sqlite_row (GdaSqliteRecordset *model, gboolean do_store, GError **er
                                        GdaBinary *bin;
                                        
                                        bin = gda_binary_new ();
-                                       length = SQLITE3_CALL (sqlite3_column_bytes) (ps->sqlite_stmt, 
real_col);
+                                       length = SQLITE3_CALL (sqlite3_column_bytes) 
(_gda_sqlite_pstmt_get_stmt (ps), real_col);
                                        if (length > 0) {
-                                               gda_binary_set_data (bin, SQLITE3_CALL (sqlite3_column_blob) 
(ps->sqlite_stmt, /* Flawfinder: ignore */
+                                               gda_binary_set_data (bin, SQLITE3_CALL (sqlite3_column_blob) 
(_gda_sqlite_pstmt_get_stmt (ps), /* Flawfinder: ignore */
                                                                                                       
real_col), length);
                                        }
                                        gda_value_take_binary (value, bin);
@@ -505,29 +505,29 @@ fetch_next_sqlite_row (GdaSqliteRecordset *model, gboolean do_store, GError **er
                                        GdaBlobOp *bop = NULL;
                                        gint oidcol = 0;
 
-                                       if (ps->rowid_hash) {
+                                       if (_gda_sqlite_pstmt_get_rowid_hash (ps)) {
                                                const char *ctable;
-                                               ctable = SQLITE3_CALL (sqlite3_column_name) (ps->sqlite_stmt, 
real_col);
+                                               ctable = SQLITE3_CALL (sqlite3_column_name) 
(_gda_sqlite_pstmt_get_stmt (ps), real_col);
                                                if (ctable)
-                                                       oidcol = GPOINTER_TO_INT (g_hash_table_lookup 
(ps->rowid_hash,
+                                                       oidcol = GPOINTER_TO_INT (g_hash_table_lookup 
(_gda_sqlite_pstmt_get_rowid_hash (ps),
                                                                                                       
ctable));
                                                if (oidcol == 0) {
-                                                       ctable = SQLITE3_CALL (sqlite3_column_table_name) 
(ps->sqlite_stmt, real_col);
+                                                       ctable = SQLITE3_CALL (sqlite3_column_table_name) 
(_gda_sqlite_pstmt_get_stmt (ps), real_col);
                                                        if (ctable)
-                                                               oidcol = GPOINTER_TO_INT (g_hash_table_lookup 
(ps->rowid_hash, 
+                                                               oidcol = GPOINTER_TO_INT (g_hash_table_lookup 
(_gda_sqlite_pstmt_get_rowid_hash (ps),
                                                                                                              
 ctable));
                                                }
                                        }
                                        if (oidcol != 0) {
                                                gint64 rowid;
-                                               rowid = SQLITE3_CALL (sqlite3_column_int64) (ps->sqlite_stmt, 
oidcol - 1); /* remove 1
+                                               rowid = SQLITE3_CALL (sqlite3_column_int64) 
(_gda_sqlite_pstmt_get_stmt (ps), oidcol - 1); /* remove 1
                                                                                                              
 because it was added in the first place */
                                                bop = _gda_sqlite_blob_op_new (cnc,
-                                                                              SQLITE3_CALL 
(sqlite3_column_database_name) (ps->sqlite_stmt, 
+                                                                              SQLITE3_CALL 
(sqlite3_column_database_name) (_gda_sqlite_pstmt_get_stmt (ps),
                                                                                                            
real_col),
-                                                                              SQLITE3_CALL 
(sqlite3_column_table_name) (ps->sqlite_stmt,
+                                                                              SQLITE3_CALL 
(sqlite3_column_table_name) (_gda_sqlite_pstmt_get_stmt (ps),
                                                                                                         
real_col),
-                                                                              SQLITE3_CALL 
(sqlite3_column_origin_name) (ps->sqlite_stmt,
+                                                                              SQLITE3_CALL 
(sqlite3_column_origin_name) (_gda_sqlite_pstmt_get_stmt (ps),
                                                                                                          
real_col),
                                                                              rowid);
                                        }
@@ -547,17 +547,17 @@ fetch_next_sqlite_row (GdaSqliteRecordset *model, gboolean do_store, GError **er
                                        }
                                }
                                else if (type == G_TYPE_BOOLEAN)
-                                       g_value_set_boolean (value, SQLITE3_CALL (sqlite3_column_int) 
(ps->sqlite_stmt, real_col) == 0 ? FALSE : TRUE);
+                                       g_value_set_boolean (value, SQLITE3_CALL (sqlite3_column_int) 
(_gda_sqlite_pstmt_get_stmt (ps), real_col) == 0 ? FALSE : TRUE);
                                else if (type == G_TYPE_DATE) {
                                        GDate date;
                                        if (!gda_parse_iso8601_date (&date, 
-                                                                    (gchar *) SQLITE3_CALL 
(sqlite3_column_text) (ps->sqlite_stmt, 
+                                                                    (gchar *) SQLITE3_CALL 
(sqlite3_column_text) (_gda_sqlite_pstmt_get_stmt (ps),
                                                                                                    
real_col))) {
                                                GError *lerror = NULL;
                                                g_set_error (&lerror, GDA_SERVER_PROVIDER_ERROR,
                                                             GDA_SERVER_PROVIDER_DATA_ERROR,
                                                             _("Invalid date '%s' (date format should be 
YYYY-MM-DD)"), 
-                                                            (gchar *) SQLITE3_CALL (sqlite3_column_text) 
(ps->sqlite_stmt, real_col));
+                                                            (gchar *) SQLITE3_CALL (sqlite3_column_text) 
(_gda_sqlite_pstmt_get_stmt (ps), real_col));
                                                gda_row_invalidate_value_e (prow, value, lerror);
                                        }
                                        else
@@ -566,13 +566,13 @@ fetch_next_sqlite_row (GdaSqliteRecordset *model, gboolean do_store, GError **er
                                else if (type == GDA_TYPE_TIME) {
                                        GdaTime* timegda = gda_time_new ();
                                        if (!gda_parse_iso8601_time (timegda,
-                                                                    (gchar *) SQLITE3_CALL 
(sqlite3_column_text) (ps->sqlite_stmt, 
+                                                                    (gchar *) SQLITE3_CALL 
(sqlite3_column_text) (_gda_sqlite_pstmt_get_stmt (ps),
                                                                                                    
real_col))) {
                                                GError *lerror = NULL;
                                                g_set_error (&lerror, GDA_SERVER_PROVIDER_ERROR,
                                                             GDA_SERVER_PROVIDER_DATA_ERROR,
                                                             _("Invalid time '%s' (time format should be 
HH:MM:SS[.ms])"), 
-                                                            (gchar *) SQLITE3_CALL (sqlite3_column_text) 
(ps->sqlite_stmt, real_col));
+                                                            (gchar *) SQLITE3_CALL (sqlite3_column_text) 
(_gda_sqlite_pstmt_get_stmt (ps), real_col));
                                                gda_row_invalidate_value_e (prow, value, lerror);
                                        }
                                        else {
@@ -584,14 +584,14 @@ fetch_next_sqlite_row (GdaSqliteRecordset *model, gboolean do_store, GError **er
                                }
                                else if (g_type_is_a (type, G_TYPE_DATE_TIME)) {
                                        GDateTime* timestamp = gda_parse_iso8601_timestamp (
-                                                                         (gchar *) SQLITE3_CALL 
(sqlite3_column_text) (ps->sqlite_stmt,
+                                                                         (gchar *) SQLITE3_CALL 
(sqlite3_column_text) (_gda_sqlite_pstmt_get_stmt (ps),
                                                                                real_col));
                                        if (timestamp == NULL) {
                                                GError *lerror = NULL;
                                                g_set_error (&lerror, GDA_SERVER_PROVIDER_ERROR,
                                                             GDA_SERVER_PROVIDER_DATA_ERROR,
                                                             _("Invalid timestamp '%s' (format should be 
YYYY-MM-DDTHH:MM:SS[.ms])"),
-                                                            (gchar *) SQLITE3_CALL (sqlite3_column_text) 
(ps->sqlite_stmt, real_col));
+                                                            (gchar *) SQLITE3_CALL (sqlite3_column_text) 
(_gda_sqlite_pstmt_get_stmt (ps), real_col));
                                                gda_row_invalidate_value_e (prow, value, lerror);
                                        }
                                        else {
@@ -601,7 +601,7 @@ fetch_next_sqlite_row (GdaSqliteRecordset *model, gboolean do_store, GError **er
                                }
                                else if (type == G_TYPE_CHAR) {
                                        gint64 i;
-                                       i = (gint64) SQLITE3_CALL (sqlite3_column_int64) (ps->sqlite_stmt, 
real_col);
+                                       i = (gint64) SQLITE3_CALL (sqlite3_column_int64) 
(_gda_sqlite_pstmt_get_stmt (ps), real_col);
                                        if ((i > G_MAXINT8) || (i < G_MININT8)) {
                                                GError *lerror = NULL;
                                                g_set_error (&lerror, GDA_SERVER_PROVIDER_ERROR,
@@ -614,7 +614,7 @@ fetch_next_sqlite_row (GdaSqliteRecordset *model, gboolean do_store, GError **er
                                }
                                else if (type == G_TYPE_UCHAR) {
                                        gint64 i;
-                                       i = (gint64) SQLITE3_CALL (sqlite3_column_int64) (ps->sqlite_stmt, 
real_col);
+                                       i = (gint64) SQLITE3_CALL (sqlite3_column_int64) 
(_gda_sqlite_pstmt_get_stmt (ps), real_col);
                                        if ((i > G_MAXUINT8) || (i < 0)) {
                                                GError *lerror = NULL;
                                                g_set_error (&lerror, GDA_SERVER_PROVIDER_ERROR,
@@ -627,7 +627,7 @@ fetch_next_sqlite_row (GdaSqliteRecordset *model, gboolean do_store, GError **er
                                }
                                else if (type == GDA_TYPE_SHORT) {
                                        gint64 i;
-                                       i = (gint64) SQLITE3_CALL (sqlite3_column_int64) (ps->sqlite_stmt, 
real_col);
+                                       i = (gint64) SQLITE3_CALL (sqlite3_column_int64) 
(_gda_sqlite_pstmt_get_stmt (ps), real_col);
                                        if ((i > G_MAXSHORT) || (i < G_MINSHORT)) {
                                                GError *lerror = NULL;
                                                g_set_error (&lerror, GDA_SERVER_PROVIDER_ERROR,
@@ -640,7 +640,7 @@ fetch_next_sqlite_row (GdaSqliteRecordset *model, gboolean do_store, GError **er
                                }
                                else if (type == GDA_TYPE_USHORT) {
                                        gint64 i;
-                                       i = (gint64) SQLITE3_CALL (sqlite3_column_int64) (ps->sqlite_stmt, 
real_col);
+                                       i = (gint64) SQLITE3_CALL (sqlite3_column_int64) 
(_gda_sqlite_pstmt_get_stmt (ps), real_col);
                                        if ((i > G_MAXUSHORT) || (i < 0)) {
                                                GError *lerror = NULL;
                                                g_set_error (&lerror, GDA_SERVER_PROVIDER_ERROR,
@@ -674,7 +674,7 @@ fetch_next_sqlite_row (GdaSqliteRecordset *model, gboolean do_store, GError **er
                break;
        case SQLITE_DONE:
                gda_data_select_set_advertized_nrows (GDA_DATA_SELECT (model), model->priv->next_row_num);
-               SQLITE3_CALL (sqlite3_reset) (ps->sqlite_stmt);
+               SQLITE3_CALL (sqlite3_reset) (_gda_sqlite_pstmt_get_stmt (ps));
                break;
        case SQLITE_READONLY:
        case SQLITE_MISUSE:
@@ -685,7 +685,7 @@ fetch_next_sqlite_row (GdaSqliteRecordset *model, gboolean do_store, GError **er
        case SQLITE_ERROR:
        default: {
                GError *lerror = NULL;
-               SQLITE3_CALL (sqlite3_reset) (ps->sqlite_stmt);
+               SQLITE3_CALL (sqlite3_reset) (_gda_sqlite_pstmt_get_stmt (ps));
                if (rc == SQLITE_IOERR_TRUNCATE)
                        g_set_error (&lerror, GDA_DATA_MODEL_ERROR,
                                     GDA_DATA_MODEL_TRUNCATED_ERROR, "%s", _("Truncated data"));
diff --git a/libgda/sqlite/gda-symbols-util.c b/libgda/sqlite/gda-symbols-util.c
index dd271e092..2349a76bb 100644
--- a/libgda/sqlite/gda-symbols-util.c
+++ b/libgda/sqlite/gda-symbols-util.c
@@ -178,6 +178,8 @@ load_symbols (GModule *module)
                goto onerror;
        if (! g_module_symbol (module, "sqlite3_close", (gpointer*) &(s3r->sqlite3_close)))
                goto onerror;
+       if (! g_module_symbol (module, "sqlite3_close_v2", (gpointer*) &(s3r->sqlite3_close_v2)))
+               goto onerror;
        if (! g_module_symbol (module, "sqlite3_column_blob", (gpointer*) &(s3r->sqlite3_column_blob)))
                goto onerror;
        if (! g_module_symbol (module, "sqlite3_column_bytes", (gpointer*) &(s3r->sqlite3_column_bytes)))
diff --git a/libgda/sqlite/gda-symbols-util.h b/libgda/sqlite/gda-symbols-util.h
index f49b3fc03..8fca02daa 100644
--- a/libgda/sqlite/gda-symbols-util.h
+++ b/libgda/sqlite/gda-symbols-util.h
@@ -47,6 +47,7 @@ typedef struct {
        int  (*sqlite3_changes)(sqlite3*);
        int (*sqlite3_clear_bindings)(sqlite3_stmt*);
        int  (*sqlite3_close)(sqlite3*);
+       int  (*sqlite3_close_v2)(sqlite3*);
 
        const void * (*sqlite3_column_blob)(sqlite3_stmt*,int iCol);
        int  (*sqlite3_column_bytes)(sqlite3_stmt*,int iCol);



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