[libgda] New database provider for Oracle's Berkeley DB's SQL frontend



commit ee261e95200ee283ec095c45bdd31454f20d8506
Author: Vivien Malerba <malerba gnome-db org>
Date:   Fri Jun 25 21:07:24 2010 +0200

    New database provider for Oracle's Berkeley DB's SQL frontend
    
    Starting with version 11g, Berkeley DB supports SQL
    using the same API as SQLITE3

 configure.ac                                       |   28 ++
 libgda/sqlite/Makefile.am                          |   38 +++-
 libgda/sqlite/README                               |   18 ++
 libgda/sqlite/gda-sqlite-blob-op.c                 |   26 ++-
 libgda/sqlite/gda-sqlite-handler-bin.c             |    4 +
 libgda/sqlite/gda-sqlite-handler-boolean.c         |    4 +
 libgda/sqlite/gda-sqlite-meta.c                    |   51 +++--
 libgda/sqlite/gda-sqlite-provider.c                |  224 +++++++++-------
 libgda/sqlite/gda-sqlite-pstmt.c                   |    9 +-
 libgda/sqlite/gda-sqlite-recordset.c               |   77 +++---
 libgda/sqlite/gda-sqlite.h                         |   23 ++-
 libgda/sqlite/gda-symbols-util.c                   |  281 ++++++++++++++++++++
 libgda/sqlite/gda-symbols-util.h                   |  119 +++++++++
 libgda/sqlite/virtual/gda-vconnection-data-model.c |   10 +-
 libgda/sqlite/virtual/gda-vprovider-data-model.c   |   60 ++--
 providers/Makefile.am                              |    5 +
 providers/bdbsql/Makefile.am                       |   43 +++
 providers/bdbsql/bdbsql_specs_add_column.xml.in    |    1 +
 providers/bdbsql/bdbsql_specs_create_db.xml.in     |    1 +
 providers/bdbsql/bdbsql_specs_create_index.xml.in  |    1 +
 providers/bdbsql/bdbsql_specs_create_table.xml.in  |    1 +
 providers/bdbsql/bdbsql_specs_create_view.xml.in   |    1 +
 providers/bdbsql/bdbsql_specs_drop_db.xml.in       |    1 +
 providers/bdbsql/bdbsql_specs_drop_index.xml.in    |    1 +
 providers/bdbsql/bdbsql_specs_drop_table.xml.in    |    1 +
 providers/bdbsql/bdbsql_specs_drop_view.xml.in     |    1 +
 providers/bdbsql/bdbsql_specs_dsn.xml.in           |    1 +
 providers/bdbsql/bdbsql_specs_rename_table.xml.in  |    1 +
 providers/bdbsql/libgda-bdbsql-4.0.pc.in           |    9 +
 providers/bdbsql/libmain.c                         |  121 +++++++++
 providers/sqlite/Makefile.am                       |    5 +-
 31 files changed, 948 insertions(+), 218 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index f9f446f..da18cae 100644
--- a/configure.ac
+++ b/configure.ac
@@ -568,11 +568,31 @@ then
 	fi
 fi
 
+bdbsqldir=""
 AM_CONDITIONAL(BDB, test x$bdbdir != x)
 if test x$bdbdir != x; then
 	LIBGDA_BDB_INC="#include <libgda/gda-data-model-bdb.h>"
 	LIBGDA_BDB_TYPE="gda_data_model_bdb_get_type"
+
+	if test -f $bdbdir/include/dbsql.h
+	then
+		BDBSQL_CFLAGS="-I${bdbdir}/include"
+		BDBSQL_LIBS="-L${bdbdir}/lib -ldb_sql"
+		BDBSQL_PATH="${bdbdir}/lib"
+		AC_CHECK_LIB(db_sql, sqlite3_table_column_metadata,[bdbsql_api=1], [bdbsql_api=0], $BDBSQL_CFLAGS $BDBSQL_LIBS -pthread -ldl)
+
+		if test $bdbsql_api = 0
+		then
+			BDBSQL_CFLAGS=""
+			BDBSQL_LIBS=""
+			AC_MSG_WARN([Installed BDB Sql was not compiled with the SQLITE_ENABLE_COLUMN_METADATA, BDB Sql provider not compiled])
+		else
+			bdbsqldir="$bdbdir"
+			AC_DEFINE(HAVE_BDBSQL, 1, [Have Berkeley DB SQL])
+		fi
+	fi
 fi
+AM_CONDITIONAL(BDBSQL, test x$bdbsqldir != x)
 AC_SUBST(LIBGDA_BDB_INC)
 AC_SUBST(LIBGDA_BDB_TYPE)
 
@@ -1336,9 +1356,11 @@ else
                 		AC_MSG_RESULT(Note: using system installed version of SQLite, meta data for functions will not be available)
 				have_sqlite=yes
                 		SQLITE_CFLAGS="$SQLITE_CFLAGS -DHAVE_SQLITE"
+				SQLITE_PATH=`pkg-config --variable=libdir sqlite3`
                 		AC_SUBST(SQLITE_CFLAGS)
                 		AC_SUBST(SQLITE_LIBS)
                 		AC_SUBST(SQLITE_VERS)
+                		AC_SUBST(SQLITE_PATH)
         		fi
 		fi
 	fi
@@ -1677,6 +1699,9 @@ dnl ******************************
 AC_SUBST(BDB_LIB)
 AC_SUBST(BDB_LIBS)
 AC_SUBST(BDB_CFLAGS)
+AC_SUBST(BDBSQL_LIBS)
+AC_SUBST(BDBSQL_PATH)
+AC_SUBST(BDBSQL_CFLAGS)
 AC_SUBST(ODBC_LIBS)
 AC_SUBST(ODBC_CFLAGS)
 AC_SUBST(MYSQL_LIBS)
@@ -1771,6 +1796,8 @@ providers/reuseable/postgres/Makefile
 providers/reuseable/mysql/Makefile
 providers/bdb/Makefile
 providers/bdb/libgda-bdb-4.0.pc
+providers/bdbsql/Makefile
+providers/bdbsql/libgda-bdbsql-4.0.pc
 providers/mdb/Makefile
 providers/mdb/libgda-mdb-4.0.pc
 providers/mysql/Makefile
@@ -1864,6 +1891,7 @@ echo "   Building GTK+ UI extension: `if test x$have_ui != xno; then echo yes; e
 echo "   Building Libxslt extension: `if test x$have_xslt != xno; then echo yes; else echo no; fi`"
 echo "   Compiled providers:"
 echo "      Berkeley DB = `if test x$bdbdir != x; then echo yes; else echo no; fi`"
+echo "      Berkeley DB SQL = `if test x$bdbsqldir = x; then echo no; else echo yes; fi`"
 dnl echo "      FireBird = `if test x$firebirddir != x; then echo yes; else echo no; fi`"
 dnl echo "      FreeTDS = `if test x$freetdsdir != x; then echo yes; else echo no; fi`"
 dnl echo "      IBM DB2 = `if test x$ibmdb2dir != x; then echo yes; else echo no; fi`"
diff --git a/libgda/sqlite/Makefile.am b/libgda/sqlite/Makefile.am
index 7288ccc..703ccea 100644
--- a/libgda/sqlite/Makefile.am
+++ b/libgda/sqlite/Makefile.am
@@ -1,6 +1,6 @@
 if HAVE_SQLITE
 SUBDIRS=
-sqlitelibs= $(SQLITE_LIBS)
+sqlitelibs= 
 sqliteinc= $(SQLITE_CFLAGS)
 else
 SUBDIRS= sqlite-src
@@ -11,6 +11,9 @@ endif
 SUBDIRS+= virtual
 
 noinst_LTLIBRARIES = libgda-sqlite.la
+if BDBSQL
+noinst_LTLIBRARIES += libgda-bdbsqlite.la
+endif
 
 AM_CPPFLAGS = \
 	-I$(top_srcdir) \
@@ -56,14 +59,45 @@ libgda_sqlite_la_SOURCES = \
 	gda-sqlite-util.c \
 	gda-sqlite-util.h \
 	gda-sqlite.h \
-	keywords_hash.h
+	keywords_hash.h \
+	gda-symbols-util.h \
+	gda-symbols-util.c
 
+libgda_sqlite_la_CFLAGS = -DSEARCH_LIB_PATH=\""$(SQLITE_PATH)"\"
 libgda_sqlite_la_LDFLAGS = -export-dynamic -module -avoid-version $(NO_UNDEFINED)
 libgda_sqlite_la_LIBADD = \
 	virtual/libgda-virtual-4.0.la \
 	$(sqlitelibs) \
 	$(LIBGDA_LIBS)
 
+libgda_bdbsqlite_la_SOURCES = \
+	$(sqliteheaders) \
+	gda-sqlite-blob-op.c \
+	gda-sqlite-blob-op.h \
+	gda-sqlite-ddl.c \
+	gda-sqlite-ddl.h \
+	gda-sqlite-handler-bin.c \
+	gda-sqlite-handler-bin.h \
+	gda-sqlite-handler-boolean.c \
+	gda-sqlite-handler-boolean.h \
+	gda-sqlite-meta.c \
+	gda-sqlite-meta.h \
+	gda-sqlite-provider.c \
+	gda-sqlite-pstmt.h \
+	gda-sqlite-pstmt.c \
+	gda-sqlite-recordset.c \
+	gda-sqlite-recordset.h \
+	gda-sqlite-util.c \
+	gda-sqlite-util.h \
+	gda-sqlite.h \
+	keywords_hash.h \
+	gda-symbols-util.h \
+	gda-symbols-util.c
+
+libgda_bdbsqlite_la_CFLAGS = $(BDBSQL_CFLAGS) -DWITH_BDBSQLITE -DSEARCH_LIB_PATH=\""$(BDBSQL_PATH)"\"
+libgda_bdbsqlite_la_LDFLAGS = -export-dynamic -module -avoid-version $(NO_UNDEFINED)
+libgda_bdbsqlite_la_LIBADD = 
+
 gdaincludedir=$(includedir)/libgda-$(GDA_ABI_MAJOR_VERSION).$(GDA_ABI_MINOR_VERSION)/libgda/sqlite
 gdainclude_HEADERS=$(sqliteheaders)
 
diff --git a/libgda/sqlite/README b/libgda/sqlite/README
index 6b2ebee..4e7d314 100644
--- a/libgda/sqlite/README
+++ b/libgda/sqlite/README
@@ -1,3 +1,21 @@
+Accessing SQLite's symbols:
+===========================
+Since the addition of Oracle Berkeley DB 5's SQL provider, all the sqlite3_* symbols
+can be loaded twice during the execution of a program linked with Libgda. Therefore
+how the sqlite3_* functions are called is important, and is the reason of the SQLITE3_CALL()
+macro which _MUST_ be used everytime an sqlite3_* function is called.
+
+The shared libraries layout to avoid symbols resolution clashed is outlined in the following
+diagram (when SQLite is used from a shared library, if not, then there is no symbol clash):
+
+libgda-4.0.so --(dlopen)--> libsqlite3.so (which exports all the sqlite3_* symbols)
+	      --(dlopen)--> providers/libgda-sqlite.so (which does not export any sqlite3_* symbol)
+	      --(dlopen)--> providers/libgda-bdbsql.so
+	                        --(dlopen)--> libdb-5.0.so (which exports all the sqlite3_* symbols)
+As the libsqlite3.so and the libdb-5.0.so shared libraries are loaded using the G_MODULE_BIND_LOCAL
+flag, their exported symbols don't clash.
+
+
 Which version of SQLite is used:
 ================================
 
diff --git a/libgda/sqlite/gda-sqlite-blob-op.c b/libgda/sqlite/gda-sqlite-blob-op.c
index 05024b0..751ceeb 100644
--- a/libgda/sqlite/gda-sqlite-blob-op.c
+++ b/libgda/sqlite/gda-sqlite-blob-op.c
@@ -1,5 +1,5 @@
 /* GDA Sqlite provider
- * Copyright (C) 2009 The GNOME Foundation
+ * Copyright (C) 2009 - 2010 The GNOME Foundation
  *
  * AUTHORS:
  *      Vivien Malerba <malerba gnome-db org>
@@ -65,7 +65,11 @@ _gda_sqlite_blob_op_get_type (void)
 		};
 		g_static_mutex_lock (&registering);
 		if (type == 0)
+#ifdef WITH_BDBSQLITE
+			type = g_type_register_static (GDA_TYPE_BLOB_OP, "GdaDBDSqlBlobOp", &info, 0);
+#else
 			type = g_type_register_static (GDA_TYPE_BLOB_OP, "GdaSqliteBlobOp", &info, 0);
+#endif
 		g_static_mutex_unlock (&registering);
 	}
 	return type;
@@ -103,7 +107,7 @@ gda_sqlite_blob_op_finalize (GObject * object)
 
 	/* free specific information */
 	if (bop->priv->sblob) {
-		sqlite3_blob_close (bop->priv->sblob);
+		SQLITE3_CALL (sqlite3_blob_close) (bop->priv->sblob);
 #ifdef GDA_DEBUG_NO
 		g_print ("CLOSED blob %p\n", bop);
 #endif
@@ -156,12 +160,13 @@ _gda_sqlite_blob_op_new (SqliteConnectionData *cdata,
 	if (! check_transaction_started (cdata->gdacnc, &transaction_started))
 		return NULL;
 
-	rc = sqlite3_blob_open (cdata->connection, db ? db : "main", table, column_name, rowid,
+	rc = SQLITE3_CALL (sqlite3_blob_open) (cdata->connection, db ? db : "main",
+					       table, column_name, rowid,
 				1, /* Read & Write */
 				&(sblob));
 	if (rc != SQLITE_OK) {
 #ifdef GDA_DEBUG_NO
-		g_print ("ERROR: %s\n", sqlite3_errmsg (cdata->connection));
+		g_print ("ERROR: %s\n", SQLITE3_CALL (sqlite3_errmsg) (cdata->connection));
 #endif
 		if (transaction_started)
 			gda_connection_rollback_transaction (cdata->gdacnc, NULL, NULL);
@@ -196,7 +201,7 @@ gda_sqlite_blob_op_get_length (GdaBlobOp *op)
 	g_return_val_if_fail (bop->priv, -1);
 	g_return_val_if_fail (bop->priv->sblob, -1);
 
-	len = sqlite3_blob_bytes (bop->priv->sblob);
+	len = SQLITE3_CALL (sqlite3_blob_bytes) (bop->priv->sblob);
 	return len >= 0 ? len : 0;
 }
 
@@ -233,7 +238,7 @@ gda_sqlite_blob_op_read (GdaBlobOp *op, GdaBlob *blob, glong offset, glong size)
 	int rsize;
 	int len;
 
-	len = sqlite3_blob_bytes (bop->priv->sblob);
+	len = SQLITE3_CALL (sqlite3_blob_bytes) (bop->priv->sblob);
 	if (len < 0)
 		return -1;
 	else if (len == 0)
@@ -246,7 +251,7 @@ gda_sqlite_blob_op_read (GdaBlobOp *op, GdaBlob *blob, glong offset, glong size)
 	if (len - offset < rsize)
 		rsize = len - offset;
 
-	rc = sqlite3_blob_read (bop->priv->sblob, bin->data, rsize, offset);
+	rc = SQLITE3_CALL (sqlite3_blob_read) (bop->priv->sblob, bin->data, rsize, offset);
 	if (rc != SQLITE_OK) {
 		g_free (bin->data);
 		bin->data = NULL;
@@ -274,7 +279,7 @@ gda_sqlite_blob_op_write (GdaBlobOp *op, GdaBlob *blob, glong offset)
 	g_return_val_if_fail (bop->priv->sblob, -1);
 	g_return_val_if_fail (blob, -1);
 
-	len = sqlite3_blob_bytes (bop->priv->sblob);
+	len = SQLITE3_CALL (sqlite3_blob_bytes) (bop->priv->sblob);
 	if (len < 0)
 		return -1;
 
@@ -299,7 +304,8 @@ gda_sqlite_blob_op_write (GdaBlobOp *op, GdaBlob *blob, glong offset)
 			else
 				wlen = nread;
 
-			rc = sqlite3_blob_write (bop->priv->sblob, ((GdaBinary *)tmpblob)->data, wlen, offset + nbwritten);
+			rc = SQLITE3_CALL (sqlite3_blob_write) (bop->priv->sblob,
+								((GdaBinary *)tmpblob)->data, wlen, offset + nbwritten);
 			if (rc != SQLITE_OK)
 				tmp_written = -1;
 			else
@@ -327,7 +333,7 @@ gda_sqlite_blob_op_write (GdaBlobOp *op, GdaBlob *blob, glong offset)
 		else
 			wlen = bin->binary_length;
 
-		rc = sqlite3_blob_write (bop->priv->sblob, bin->data, wlen, offset);
+		rc = SQLITE3_CALL (sqlite3_blob_write) (bop->priv->sblob, bin->data, wlen, offset);
 		if (rc != SQLITE_OK)
 			nbwritten = -1;
 		else
diff --git a/libgda/sqlite/gda-sqlite-handler-bin.c b/libgda/sqlite/gda-sqlite-handler-bin.c
index 38719b4..de9eaa0 100644
--- a/libgda/sqlite/gda-sqlite-handler-bin.c
+++ b/libgda/sqlite/gda-sqlite-handler-bin.c
@@ -76,7 +76,11 @@ _gda_sqlite_handler_bin_get_type (void)
 
 		g_static_mutex_lock (&registering);
 		if (type == 0) {
+#ifdef WITH_BDBSQLITE
+			type = g_type_register_static (G_TYPE_OBJECT, "GdaDBDSqlHandlerBin", &info, 0);
+#else
 			type = g_type_register_static (G_TYPE_OBJECT, "GdaSqliteHandlerBin", &info, 0);
+#endif
 			g_type_add_interface_static (type, GDA_TYPE_DATA_HANDLER, &data_entry_info);
 		}
 		g_static_mutex_unlock (&registering);
diff --git a/libgda/sqlite/gda-sqlite-handler-boolean.c b/libgda/sqlite/gda-sqlite-handler-boolean.c
index b42c10d..ecc6141 100644
--- a/libgda/sqlite/gda-sqlite-handler-boolean.c
+++ b/libgda/sqlite/gda-sqlite-handler-boolean.c
@@ -78,7 +78,11 @@ _gda_sqlite_handler_boolean_get_type (void)
 
 		g_static_mutex_lock (&registering);
 		if (type == 0) {
+#ifdef WITH_BDBSQLITE
+			type = g_type_register_static (G_TYPE_OBJECT, "GdaDBDSqlHandlerBoolean", &info, 0);
+#else
 			type = g_type_register_static (G_TYPE_OBJECT, "GdaSqliteHandlerBoolean", &info, 0);
+#endif
 			g_type_add_interface_static (type, GDA_TYPE_DATA_HANDLER, &data_entry_info);
 		}
 		g_static_mutex_unlock (&registering);
diff --git a/libgda/sqlite/gda-sqlite-meta.c b/libgda/sqlite/gda-sqlite-meta.c
index 78cfda8..8fe13fa 100644
--- a/libgda/sqlite/gda-sqlite-meta.c
+++ b/libgda/sqlite/gda-sqlite-meta.c
@@ -1,5 +1,5 @@
 /* Gda Sqlite provider
- * Copyright (C) 2008 The GNOME Foundation
+ * Copyright (C) 2008 - 2010 The GNOME Foundation
  *
  * AUTHORS:
  *         Vivien Malerba <malerba gnome-db org>
@@ -366,7 +366,7 @@ fill_udt_model (SqliteConnectionData *cdata, GHashTable *added_hash,
 
 	cstr = g_value_get_string (p_udt_schema);
 	str = g_strdup_printf ("SELECT name FROM %s.sqlite_master WHERE type='table' AND name not like 'sqlite_%%'", cstr);
-	status = sqlite3_prepare_v2 (cdata->connection, str, -1, &tables_stmt, NULL);
+	status = SQLITE3_CALL (sqlite3_prepare_v2) (cdata->connection, str, -1, &tables_stmt, NULL);
 	g_free (str);
 	if ((status != SQLITE_OK) || !tables_stmt)
 		return FALSE;
@@ -374,24 +374,30 @@ fill_udt_model (SqliteConnectionData *cdata, GHashTable *added_hash,
 	if (!cdata->types)
                 _gda_sqlite_compute_types_hash (cdata);
 
-	for (status = sqlite3_step (tables_stmt); status == SQLITE_ROW; status = sqlite3_step (tables_stmt)) {
+	for (status = SQLITE3_CALL (sqlite3_step) (tables_stmt);
+	     status == SQLITE_ROW;
+	     status = SQLITE3_CALL (sqlite3_step) (tables_stmt)) {
 		gchar *sql;
 		sqlite3_stmt *fields_stmt;
 		gint fields_status;
 
 		if (strcmp (cstr, "main")) 
-			sql = g_strdup_printf ("PRAGMA %s.table_info(%s);", cstr, sqlite3_column_text (tables_stmt, 0));
+			sql = g_strdup_printf ("PRAGMA %s.table_info(%s);", cstr,
+					       SQLITE3_CALL (sqlite3_column_text) (tables_stmt, 0));
 		else
-			sql = g_strdup_printf ("PRAGMA table_info('%s');", sqlite3_column_text (tables_stmt, 0));
-		fields_status = sqlite3_prepare_v2 (cdata->connection, sql, -1, &fields_stmt, NULL);
+			sql = g_strdup_printf ("PRAGMA table_info('%s');",
+					       SQLITE3_CALL (sqlite3_column_text) (tables_stmt, 0));
+		fields_status = SQLITE3_CALL (sqlite3_prepare_v2) (cdata->connection, sql,
+								   -1, &fields_stmt, NULL);
 		g_free (sql);
 		if ((fields_status != SQLITE_OK) || !fields_stmt)
 			break;
 		
-		for (fields_status = sqlite3_step (fields_stmt); fields_status == SQLITE_ROW; 
-		     fields_status = sqlite3_step (fields_stmt)) {
+		for (fields_status = SQLITE3_CALL (sqlite3_step) (fields_stmt);
+		     fields_status == SQLITE_ROW; 
+		     fields_status = SQLITE3_CALL (sqlite3_step) (fields_stmt)) {
 			GType gtype;
-			const gchar *typname = (gchar *) sqlite3_column_text (fields_stmt, 2);
+			const gchar *typname = (gchar *) SQLITE3_CALL (sqlite3_column_text) (fields_stmt, 2);
 			if (!typname || !(*typname)) 
 				continue;
 
@@ -420,9 +426,9 @@ fill_udt_model (SqliteConnectionData *cdata, GHashTable *added_hash,
 				g_hash_table_insert (added_hash, g_strdup (typname), GINT_TO_POINTER (1));
 			}
 		}
-		sqlite3_finalize (fields_stmt);
+		SQLITE3_CALL (sqlite3_finalize) (fields_stmt);
 	}
-	sqlite3_finalize (tables_stmt);
+	SQLITE3_CALL (sqlite3_finalize) (tables_stmt);
 
 	return retval;
 }
@@ -975,9 +981,11 @@ fill_columns_model (GdaConnection *cnc, SqliteConnectionData *cdata,
 			continue; /* ignore that table */
 		
 		this_col_name = g_value_get_string (nthis_col_pname);
-		if (sqlite3_table_column_metadata (cdata->connection, g_value_get_string (p_table_schema), 
-						   this_table_name, this_col_name,
-						   &pzDataType, &pzCollSeq, &pNotNull, &pPrimaryKey, &pAutoinc)
+		if (SQLITE3_CALL (sqlite3_table_column_metadata) (cdata->connection,
+								  g_value_get_string (p_table_schema), 
+								  this_table_name, this_col_name,
+								  &pzDataType, &pzCollSeq,
+								  &pNotNull, &pPrimaryKey, &pAutoinc)
 		    != SQLITE_OK) {
 			/* may fail because we have a view and not a table => use @tmpmodel to fetch info. */
 			cvalue = gda_data_model_get_value_at (tmpmodel, 2, i, error);
@@ -1253,9 +1261,11 @@ fill_constraints_tab_model (GdaConnection *cnc, SqliteConnectionData *cdata, Gda
 			continue; /* ignore that table */
 		
 		this_col_name = g_value_get_string (this_col_pname);
-		if (sqlite3_table_column_metadata (cdata->connection, g_value_get_string (p_table_schema), 
-						   this_table_name, this_col_name,
-						   &pzDataType, &pzCollSeq, &pNotNull, &pPrimaryKey, &pAutoinc)
+		if (SQLITE3_CALL (sqlite3_table_column_metadata) (cdata->connection,
+								  g_value_get_string (p_table_schema), 
+								  this_table_name, this_col_name,
+								  &pzDataType, &pzCollSeq,
+								  &pNotNull, &pPrimaryKey, &pAutoinc)
 		    != SQLITE_OK) {
 			/* may fail because we have a view and not a table => use @tmpmodel to fetch info. */
 			cvalue = gda_data_model_get_value_at (tmpmodel, 5, i, error);
@@ -1768,9 +1778,10 @@ fill_key_columns_model (GdaConnection *cnc, SqliteConnectionData *cdata, GdaData
 				continue; /* ignore that table */
 			
 			this_col_name = g_value_get_string (this_col_pname);
-			if (sqlite3_table_column_metadata (cdata->connection, g_value_get_string (p_table_schema), 
-							   this_table_name, this_col_name,
-							   &pzDataType, &pzCollSeq, &pNotNull, &pPrimaryKey, &pAutoinc)
+			if (SQLITE3_CALL (sqlite3_table_column_metadata) (cdata->connection, g_value_get_string (p_table_schema), 
+									 this_table_name, this_col_name,
+									 &pzDataType, &pzCollSeq,
+									 &pNotNull, &pPrimaryKey, &pAutoinc)
 			    != SQLITE_OK) {
 				/* may fail because we have a view and not a table => use @tmpmodel to fetch info. */
 				cvalue = gda_data_model_get_value_at (tmpmodel, 5, i, error);
diff --git a/libgda/sqlite/gda-sqlite-provider.c b/libgda/sqlite/gda-sqlite-provider.c
index 3e96e09..649bed0 100644
--- a/libgda/sqlite/gda-sqlite-provider.c
+++ b/libgda/sqlite/gda-sqlite-provider.c
@@ -1,5 +1,5 @@
 /* GDA SQLite provider
- * Copyright (C) 1998 - 2009 The GNOME Foundation.
+ * Copyright (C) 1998 - 2010 The GNOME Foundation.
  *
  * AUTHORS:
  *	Rodrigo Moya <rodrigo gnome-db org>
@@ -436,7 +436,7 @@ gda_sqlite_provider_class_init (GdaSqliteProviderClass *klass)
 
 	/* If SQLite was not compiled with the SQLITE_THREADSAFE flag, then it is not
 	 * considered thread safe, and we limit the usage of the provider from the current thread */
-	if (! sqlite3_threadsafe ()) {
+	if (! SQLITE3_CALL (sqlite3_threadsafe) ()) {
 		gda_log_message ("SQLite was not compiled with the SQLITE_THREADSAFE flag, "
 				 "only one thread can access the provider");
 		provider_class->limiting_thread = g_thread_self ();
@@ -451,12 +451,13 @@ gda_sqlite_provider_init (GdaSqliteProvider *sqlite_prv, GdaSqliteProviderClass
 	InternalStatementItem i;
 	GdaSqlParser *parser;
 
-	parser = gda_server_provider_internal_get_parser ((GdaServerProvider*) sqlite_prv);
 	g_static_mutex_lock (&init_mutex);
 
+	parser = gda_server_provider_internal_get_parser ((GdaServerProvider*) sqlite_prv);
+
 	if (!internal_stmt) {
 		/* configure multi threading environment */
-		sqlite3_config (SQLITE_CONFIG_SERIALIZED);
+		SQLITE3_CALL (sqlite3_config) (SQLITE_CONFIG_SERIALIZED);
 
 		internal_stmt = g_new0 (GdaStatement *, sizeof (internal_sql) / sizeof (gchar*));
 		for (i = INTERNAL_PRAGMA_INDEX_LIST; i < sizeof (internal_sql) / sizeof (gchar*); i++) {
@@ -490,8 +491,25 @@ gda_sqlite_provider_get_type (void)
 			(GInstanceInitFunc) gda_sqlite_provider_init
 		};
 		g_static_mutex_lock (&registering);
-		if (type == 0)
+		if (type == 0) {
+#ifdef WITH_BDBSQLITE
+			type = g_type_register_static (GDA_TYPE_SERVER_PROVIDER, "GdaDBDSqlProvider", &info, 0);
+#else
+  #ifdef HAVE_SQLITE
+			GModule *module2;
+			
+			module2 = find_sqlite_library ("libsqlite3");
+			if (module2)
+				load_symbols (module2);
+			if (s3r)
+				type = g_type_register_static (GDA_TYPE_SERVER_PROVIDER, "GdaSqliteProvider", &info, 0);
+			else
+				g_warning (_("Can't find libsqlite3." G_MODULE_SUFFIX " file."));
+  #else
 			type = g_type_register_static (GDA_TYPE_SERVER_PROVIDER, "GdaSqliteProvider", &info, 0);
+  #endif
+#endif
+		}
 		g_static_mutex_unlock (&registering);
 	}
 
@@ -636,10 +654,10 @@ gda_sqlite_provider_open_connection (GdaServerProvider *provider, GdaConnection
 	if (filename)
 		cdata->file = filename;
 
-	errmsg = sqlite3_open (filename, &cdata->connection);
+	errmsg = SQLITE3_CALL (sqlite3_open) (filename, &cdata->connection);
 
 	if (errmsg != SQLITE_OK) {
-		gda_connection_add_event_string (cnc, sqlite3_errmsg (cdata->connection));
+		gda_connection_add_event_string (cnc, SQLITE3_CALL (sqlite3_errmsg) (cdata->connection));
 		gda_sqlite_free_cnc_data (cdata);
 			
 		g_static_rec_mutex_unlock (&cnc_mutex);
@@ -649,10 +667,10 @@ gda_sqlite_provider_open_connection (GdaServerProvider *provider, GdaConnection
 	gda_connection_internal_set_provider_data (cnc, cdata, (GDestroyNotify) gda_sqlite_free_cnc_data);
 
 	/* use extended result codes */
-	sqlite3_extended_result_codes (cdata->connection, 1);
+	SQLITE3_CALL (sqlite3_extended_result_codes) (cdata->connection, 1);
 	
 	/* allow a busy timeout of 500 ms */
-	sqlite3_busy_timeout (cdata->connection, 500);
+	SQLITE3_CALL (sqlite3_busy_timeout) (cdata->connection, 500);
 
 	/* try to prepare all the internal statements */
 	InternalStatementItem i;
@@ -681,18 +699,18 @@ gda_sqlite_provider_open_connection (GdaServerProvider *provider, GdaConnection
 		gint status;
 		gchar *errmsg;
 		
-		status = sqlite3_get_table (cdata->connection, "SELECT name"
-					    " FROM (SELECT * FROM sqlite_master UNION ALL "
-					    "       SELECT * FROM sqlite_temp_master)",
-					    &data,
-					    &nrows,
-					    &ncols,
-					    &errmsg);
+		status = SQLITE3_CALL (sqlite3_get_table) (cdata->connection, "SELECT name"
+							   " FROM (SELECT * FROM sqlite_master UNION ALL "
+							   "       SELECT * FROM sqlite_temp_master)",
+							   &data,
+							   &nrows,
+							   &ncols,
+							   &errmsg);
 		if (status == SQLITE_OK) 
-			sqlite3_free_table (data);
+			SQLITE3_CALL (sqlite3_free_table) (data);
 		else {
 			gda_connection_add_event_string (cnc, errmsg);
-			sqlite3_free (errmsg);
+			SQLITE3_CALL (sqlite3_free) (errmsg);
 			gda_sqlite_free_cnc_data (cdata);
 			gda_connection_internal_set_provider_data (cnc, NULL, (GDestroyNotify) gda_sqlite_free_cnc_data);
 			g_static_rec_mutex_unlock (&cnc_mutex);
@@ -707,13 +725,13 @@ gda_sqlite_provider_open_connection (GdaServerProvider *provider, GdaConnection
 	int res;
 	sqlite3_stmt *pStmt;
 	if (enforce_fk)
-		res = sqlite3_prepare (cdata->connection,
-				       "PRAGMA foreign_keys = ON", -1,
-				       &pStmt, NULL);
+		res = SQLITE3_CALL (sqlite3_prepare) (cdata->connection,
+						      "PRAGMA foreign_keys = ON", -1,
+						      &pStmt, NULL);
 	else
-		res = sqlite3_prepare (cdata->connection,
-				       "PRAGMA foreign_keys = OFF", -1,
-				       &pStmt, NULL);
+		res = SQLITE3_CALL (sqlite3_prepare) (cdata->connection,
+						      "PRAGMA foreign_keys = OFF", -1,
+						      &pStmt, NULL);
 
 	if (res != SQLITE_OK) {
 		if (with_fk) {
@@ -725,9 +743,9 @@ gda_sqlite_provider_open_connection (GdaServerProvider *provider, GdaConnection
 		}
 	}
 	else {
-		res = sqlite3_step (pStmt);
-		sqlite3_reset (pStmt);
-		sqlite3_finalize (pStmt);
+		res = SQLITE3_CALL (sqlite3_step) (pStmt);
+		SQLITE3_CALL (sqlite3_reset) (pStmt);
+		SQLITE3_CALL (sqlite3_finalize) (pStmt);
 		if (res != SQLITE_DONE) {
 			if (with_fk) {
 				gda_sqlite_free_cnc_data (cdata);
@@ -752,9 +770,10 @@ gda_sqlite_provider_open_connection (GdaServerProvider *provider, GdaConnection
 
 		for (i = 0; i < sizeof (scalars) / sizeof (ScalarFunction); i++) {
 			ScalarFunction *func = (ScalarFunction *) &(scalars [i]);
-			gint res = sqlite3_create_function (cdata->connection, 
-							    func->name, func->nargs, SQLITE_UTF8, func->user_data, 
-							    func->xFunc, NULL, NULL);
+			gint res = SQLITE3_CALL (sqlite3_create_function) (cdata->connection, 
+									   func->name, func->nargs,
+									   SQLITE_UTF8, func->user_data, 
+									   func->xFunc, NULL, NULL);
 			if (res != SQLITE_OK) {
 				gda_sqlite_free_cnc_data (cdata);
 				gda_connection_internal_set_provider_data (cnc, NULL, (GDestroyNotify) gda_sqlite_free_cnc_data);
@@ -764,7 +783,7 @@ gda_sqlite_provider_open_connection (GdaServerProvider *provider, GdaConnection
 		}
 	}
 	
-	if (sqlite3_threadsafe ())
+	if (SQLITE3_CALL (sqlite3_threadsafe) ())
 		g_object_set (G_OBJECT (cnc), "thread-owner", NULL, NULL);
 	else
 		g_object_set (G_OBJECT (cnc), "thread-owner", g_thread_self (), NULL);
@@ -1010,11 +1029,11 @@ gda_sqlite_provider_perform_operation (GdaServerProvider *provider, GdaConnectio
 		g_free (tmp);
 
 		cdata = g_new0 (SqliteConnectionData, 1);
-		errmsg = sqlite3_open (filename, &cdata->connection);
+		errmsg = SQLITE3_CALL (sqlite3_open) (filename, &cdata->connection);
 		g_free (filename);
 
 		if (errmsg != SQLITE_OK) {
-			g_set_error (error, 0, 0, "%s", sqlite3_errmsg (cdata->connection)); 
+			g_set_error (error, 0, 0, "%s", SQLITE3_CALL (sqlite3_errmsg) (cdata->connection)); 
 			retval = FALSE;
 		}
 		gda_sqlite_free_cnc_data (cdata);
@@ -1196,7 +1215,7 @@ gda_sqlite_provider_supports (GdaServerProvider *provider,
 	case GDA_CONNECTION_FEATURE_PROCEDURES :
 		return TRUE;
 	case GDA_CONNECTION_FEATURE_MULTI_THREADING:
-		return sqlite3_threadsafe () ? TRUE : FALSE;
+		return SQLITE3_CALL (sqlite3_threadsafe) () ? TRUE : FALSE;
 	default: 
 		return FALSE;
 	}
@@ -1885,10 +1904,10 @@ real_prepare (GdaServerProvider *provider, GdaConnection *cnc, GdaStatement *stm
 		goto out_err;
 
 	/* prepare statement */
-	status = sqlite3_prepare_v2 (cdata->connection, sql, -1, &sqlite_stmt, &left);
+	status = SQLITE3_CALL (sqlite3_prepare_v2) (cdata->connection, sql, -1, &sqlite_stmt, &left);
 	if (status != SQLITE_OK) {
 		g_set_error (error, GDA_SERVER_PROVIDER_ERROR, GDA_SERVER_PROVIDER_PREPARE_STMT_ERROR,
-			      "%s", sqlite3_errmsg (cdata->connection));
+			     "%s", SQLITE3_CALL (sqlite3_errmsg) (cdata->connection));
 		goto out_err;
 	}
 
@@ -2107,7 +2126,7 @@ fill_blob_data (GdaConnection *cnc, GdaSet *params,
 		goto blobs_out;
 	}
 	if (gda_statement_get_statement_type (stmt) == GDA_SQL_STATEMENT_INSERT) {
-		rowid = sqlite3_last_insert_rowid (cdata->connection);
+		rowid = SQLITE3_CALL (sqlite3_last_insert_rowid) (cdata->connection);
 	}
 	else if (gda_statement_get_statement_type (stmt) == GDA_SQL_STATEMENT_UPDATE) {
 		GdaSqlStatement *sel_stmt;
@@ -2272,10 +2291,11 @@ gda_sqlite_provider_statement_execute (GdaServerProvider *provider, GdaConnectio
 			if (!sql)
 				return NULL;
 
-			status = sqlite3_prepare_v2 (cdata->connection, sql, -1, &sqlite_stmt, (const char**) &left);
+			status = SQLITE3_CALL (sqlite3_prepare_v2) (cdata->connection, sql, -1,
+								    &sqlite_stmt, (const char**) &left);
 			if (status != SQLITE_OK) {
 				g_set_error (error, GDA_SERVER_PROVIDER_ERROR, GDA_SERVER_PROVIDER_PREPARE_STMT_ERROR,
-					      "%s", sqlite3_errmsg (cdata->connection));
+					     "%s", SQLITE3_CALL (sqlite3_errmsg) (cdata->connection));
 				g_free (sql);
 				return NULL;
 			}
@@ -2323,12 +2343,12 @@ gda_sqlite_provider_statement_execute (GdaServerProvider *provider, GdaConnectio
 	}
 
 	/* reset prepared stmt */
-	if ((sqlite3_reset (ps->sqlite_stmt) != SQLITE_OK) || 
-	    (sqlite3_clear_bindings (ps->sqlite_stmt) != SQLITE_OK)) {
+	if ((SQLITE3_CALL (sqlite3_reset) (ps->sqlite_stmt) != SQLITE_OK) || 
+	    (SQLITE3_CALL (sqlite3_clear_bindings) (ps->sqlite_stmt) != SQLITE_OK)) {
 		GdaConnectionEvent *event;
 		const char *errmsg;
 
-		errmsg = sqlite3_errmsg (cdata->connection);
+		errmsg = SQLITE3_CALL (sqlite3_errmsg) (cdata->connection);
 		event = gda_connection_event_new (GDA_CONNECTION_EVENT_ERROR);
 		gda_connection_event_set_description (event, errmsg);
 		gda_connection_add_event (cnc, event);
@@ -2380,7 +2400,7 @@ gda_sqlite_provider_statement_execute (GdaServerProvider *provider, GdaConnectio
 			}
 			else {
 				/* bind param to NULL */
-				sqlite3_bind_null (ps->sqlite_stmt, i);
+				SQLITE3_CALL (sqlite3_bind_null) (ps->sqlite_stmt, i);
 				empty_rs = TRUE;
 				continue;
 			}
@@ -2399,7 +2419,7 @@ gda_sqlite_provider_statement_execute (GdaServerProvider *provider, GdaConnectio
 			}
 			else {
 				/* bind param to NULL */
-				sqlite3_bind_null (ps->sqlite_stmt, i);
+				SQLITE3_CALL (sqlite3_bind_null) (ps->sqlite_stmt, i);
 				empty_rs = TRUE;
 				continue;
 			}
@@ -2408,34 +2428,34 @@ gda_sqlite_provider_statement_execute (GdaServerProvider *provider, GdaConnectio
 		
 		const GValue *value = gda_holder_get_value (h);
 		if (!value || gda_value_is_null (value))
-			sqlite3_bind_null (ps->sqlite_stmt, i);
+			SQLITE3_CALL (sqlite3_bind_null) (ps->sqlite_stmt, i);
 		else if (G_VALUE_TYPE (value) == G_TYPE_STRING)
-			sqlite3_bind_text (ps->sqlite_stmt, i, 
-					   g_value_get_string (value), -1, SQLITE_TRANSIENT);
+			SQLITE3_CALL (sqlite3_bind_text) (ps->sqlite_stmt, i, 
+							  g_value_get_string (value), -1, SQLITE_TRANSIENT);
 		else if (G_VALUE_TYPE (value) == G_TYPE_INT)
-			sqlite3_bind_int (ps->sqlite_stmt, i, g_value_get_int (value));
+			SQLITE3_CALL (sqlite3_bind_int) (ps->sqlite_stmt, i, g_value_get_int (value));
 		else if (G_VALUE_TYPE (value) == G_TYPE_LONG)
-			sqlite3_bind_int (ps->sqlite_stmt, i, g_value_get_long (value));
+			SQLITE3_CALL (sqlite3_bind_int) (ps->sqlite_stmt, i, g_value_get_long (value));
 		else if (G_VALUE_TYPE (value) == G_TYPE_DOUBLE)
-			sqlite3_bind_double (ps->sqlite_stmt, i, g_value_get_double (value));
+			SQLITE3_CALL (sqlite3_bind_double) (ps->sqlite_stmt, i, g_value_get_double (value));
 		else if (G_VALUE_TYPE (value) == G_TYPE_FLOAT)
-			sqlite3_bind_double (ps->sqlite_stmt, i, g_value_get_float (value));
+			SQLITE3_CALL (sqlite3_bind_double) (ps->sqlite_stmt, i, g_value_get_float (value));
 		else if (G_VALUE_TYPE (value) == G_TYPE_UINT)
-			sqlite3_bind_int (ps->sqlite_stmt, i, g_value_get_uint (value));
+			SQLITE3_CALL (sqlite3_bind_int) (ps->sqlite_stmt, i, g_value_get_uint (value));
 		else if (G_VALUE_TYPE (value) == G_TYPE_BOOLEAN)
-			sqlite3_bind_int (ps->sqlite_stmt, i, g_value_get_boolean (value) ? 1 : 0);
+			SQLITE3_CALL (sqlite3_bind_int) (ps->sqlite_stmt, i, g_value_get_boolean (value) ? 1 : 0);
 		else if (G_VALUE_TYPE (value) == G_TYPE_INT64)
-			sqlite3_bind_int64 (ps->sqlite_stmt, i, g_value_get_int64 (value));
+			SQLITE3_CALL (sqlite3_bind_int64) (ps->sqlite_stmt, i, g_value_get_int64 (value));
 		else if (G_VALUE_TYPE (value) == G_TYPE_UINT64)
-			sqlite3_bind_int64 (ps->sqlite_stmt, i, g_value_get_uint64 (value));
+			SQLITE3_CALL (sqlite3_bind_int64) (ps->sqlite_stmt, i, g_value_get_uint64 (value));
 		else if (G_VALUE_TYPE (value) == GDA_TYPE_SHORT)
-			sqlite3_bind_int (ps->sqlite_stmt, i, gda_value_get_short (value));
+			SQLITE3_CALL (sqlite3_bind_int) (ps->sqlite_stmt, i, gda_value_get_short (value));
 		else if (G_VALUE_TYPE (value) == GDA_TYPE_USHORT)
-			sqlite3_bind_int (ps->sqlite_stmt, i, gda_value_get_ushort (value));
+			SQLITE3_CALL (sqlite3_bind_int) (ps->sqlite_stmt, i, gda_value_get_ushort (value));
 		else if (G_VALUE_TYPE (value) == G_TYPE_CHAR)
-			sqlite3_bind_int (ps->sqlite_stmt, i, g_value_get_char (value));
+			SQLITE3_CALL (sqlite3_bind_int) (ps->sqlite_stmt, i, g_value_get_char (value));
 		else if (G_VALUE_TYPE (value) == G_TYPE_UCHAR)
-			sqlite3_bind_int (ps->sqlite_stmt, i, g_value_get_uchar (value));
+			SQLITE3_CALL (sqlite3_bind_int) (ps->sqlite_stmt, i, g_value_get_uchar (value));
 		else if (G_VALUE_TYPE (value) == GDA_TYPE_BLOB) {
 			gulong blob_len;
 			GdaBlob *blob = (GdaBlob*) gda_value_get_blob (value);
@@ -2473,7 +2493,7 @@ gda_sqlite_provider_statement_execute (GdaServerProvider *provider, GdaConnectio
 			pb->blob = blob;
 			blobs_list = g_slist_prepend (blobs_list, pb);
 
-			if (sqlite3_bind_zeroblob (ps->sqlite_stmt, i, (int) blob_len) !=
+			if (SQLITE3_CALL (sqlite3_bind_zeroblob) (ps->sqlite_stmt, i, (int) blob_len) !=
 			    SQLITE_OK) {
 				event = gda_connection_event_new (GDA_CONNECTION_EVENT_ERROR);
 				gda_connection_event_set_description (event, 
@@ -2485,8 +2505,8 @@ 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_bind_blob (ps->sqlite_stmt, i, 
-					   bin->data, bin->binary_length, SQLITE_TRANSIENT);
+			SQLITE3_CALL (sqlite3_bind_blob) (ps->sqlite_stmt, i, 
+							  bin->data, bin->binary_length, SQLITE_TRANSIENT);
 		}
 		else if (G_VALUE_TYPE (value) == GDA_TYPE_TIME) {
 			gchar *str;
@@ -2499,7 +2519,7 @@ gda_sqlite_provider_statement_execute (GdaServerProvider *provider, GdaConnectio
 			else
 				str = g_strdup_printf ("%02d:%02d:%02d", 
 						       ts->hour, ts->minute, ts->second);
-			sqlite3_bind_text (ps->sqlite_stmt, i, str, -1, g_free);
+			SQLITE3_CALL (sqlite3_bind_text) (ps->sqlite_stmt, i, str, -1, g_free);
 		}
 		else if (G_VALUE_TYPE (value) == G_TYPE_DATE) {
 			gchar *str;
@@ -2508,7 +2528,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_bind_text (ps->sqlite_stmt, i, str, -1, g_free);
+			SQLITE3_CALL (sqlite3_bind_text) (ps->sqlite_stmt, i, str, -1, g_free);
 		}
 		else if (G_VALUE_TYPE (value) == GDA_TYPE_TIMESTAMP) {
 			gchar *str;
@@ -2521,13 +2541,13 @@ gda_sqlite_provider_statement_execute (GdaServerProvider *provider, GdaConnectio
 			else
 				str = g_strdup_printf ("%4d-%02d-%02d %02d:%02d:%02d", ts->year, ts->month, ts->day, 
 						       ts->hour, ts->minute, ts->second);
-			sqlite3_bind_text (ps->sqlite_stmt, i, str, -1, g_free);
+			SQLITE3_CALL (sqlite3_bind_text) (ps->sqlite_stmt, i, str, -1, g_free);
 		}
 		else if (G_VALUE_TYPE (value) == GDA_TYPE_NUMERIC) {
 			const GdaNumeric *gdan;
 			
 			gdan = gda_value_get_numeric (value);
-			sqlite3_bind_text (ps->sqlite_stmt, i, gdan->number, -1, SQLITE_TRANSIENT);
+			SQLITE3_CALL (sqlite3_bind_text) (ps->sqlite_stmt, i, gdan->number, -1, SQLITE_TRANSIENT);
 		}
 		else {
 			gchar *str;
@@ -2583,17 +2603,17 @@ gda_sqlite_provider_statement_execute (GdaServerProvider *provider, GdaConnectio
                 sqlite3 *handle;
 
                 /* actually execute the command */
-                handle = sqlite3_db_handle (ps->sqlite_stmt);
-                status = sqlite3_step (ps->sqlite_stmt);
-                changes = sqlite3_changes (handle);
+                handle = SQLITE3_CALL (sqlite3_db_handle) (ps->sqlite_stmt);
+                status = SQLITE3_CALL (sqlite3_step) (ps->sqlite_stmt);
+                changes = SQLITE3_CALL (sqlite3_changes) (handle);
                 if (status != SQLITE_DONE) {
-                        if (sqlite3_errcode (handle) != SQLITE_OK) {
-				const char *errmsg = sqlite3_errmsg (handle);
+                        if (SQLITE3_CALL (sqlite3_errcode) (handle) != SQLITE_OK) {
+				const char *errmsg = SQLITE3_CALL (sqlite3_errmsg) (handle);
                                 event = gda_connection_event_new (GDA_CONNECTION_EVENT_ERROR);
                                 gda_connection_event_set_description (event, errmsg);
 				g_set_error (error, GDA_SERVER_PROVIDER_ERROR,
 					     GDA_SERVER_PROVIDER_STATEMENT_EXEC_ERROR, "%s", errmsg);
-                                sqlite3_reset (ps->sqlite_stmt);
+                                SQLITE3_CALL (sqlite3_reset) (ps->sqlite_stmt);
                                 gda_connection_add_event (cnc, event);
 				gda_connection_internal_statement_executed (cnc, stmt, params, event);
 				if (new_ps)
@@ -2616,7 +2636,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_reset (ps->sqlite_stmt);
+				SQLITE3_CALL (sqlite3_reset) (ps->sqlite_stmt);
 				if (new_ps)
 					g_object_unref (ps);
 				return NULL;
@@ -2641,7 +2661,7 @@ gda_sqlite_provider_statement_execute (GdaServerProvider *provider, GdaConnectio
                                                        changes);
                         else if (! g_ascii_strncasecmp (_GDA_PSTMT (ps)->sql, "INSERT", 6)) {
 				sqlite3_int64 last_id;
-				last_id = sqlite3_last_insert_rowid (handle);
+				last_id = SQLITE3_CALL (sqlite3_last_insert_rowid) (handle);
 				str = g_strdup_printf ("INSERT %lld %d", last_id, changes);
 				if (last_inserted_row)
 					*last_inserted_row = make_last_inserted_set (cnc, stmt, last_id);
@@ -2668,7 +2688,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_reset (ps->sqlite_stmt);
+			SQLITE3_CALL (sqlite3_reset) (ps->sqlite_stmt);
 			if (new_ps)
 				g_object_unref (ps);
 			return set;
@@ -2685,15 +2705,15 @@ scalar_gda_file_exists_func (sqlite3_context *context, int argc, sqlite3_value *
 	const gchar *path;
 
 	if (argc != 1) {
-		sqlite3_result_error (context, _("Function requires one argument"), -1);
+		SQLITE3_CALL (sqlite3_result_error) (context, _("Function requires one argument"), -1);
 		return;
 	}
 
-	path = (gchar *) sqlite3_value_text (argv [0]);
+	path = (gchar *) SQLITE3_CALL (sqlite3_value_text) (argv [0]);
 	if (g_file_test (path, G_FILE_TEST_EXISTS))
-		sqlite3_result_int (context, 1);
+		SQLITE3_CALL (sqlite3_result_int) (context, 1);
 	else
-		sqlite3_result_int (context, 0);
+		SQLITE3_CALL (sqlite3_result_int) (context, 0);
 }
 
 
@@ -2706,18 +2726,18 @@ scalar_gda_hex_print_func (sqlite3_context *context, int argc, sqlite3_value **a
 	gchar *str;
 
 	if (argc != 1) {
-		sqlite3_result_error (context, _("Function requires one argument"), -1);
+		SQLITE3_CALL (sqlite3_result_error) (context, _("Function requires one argument"), -1);
 		return;
 	}
 
 	bin = g_new0 (GdaBinary, 1);
-	bin->data = (guchar*) sqlite3_value_blob (argv [0]);
+	bin->data = (guchar*) SQLITE3_CALL (sqlite3_value_blob) (argv [0]);
 	if (!bin->data) {
 		g_free (bin);
-		sqlite3_result_null (context);
+		SQLITE3_CALL (sqlite3_result_null) (context);
 		return;
 	}
-	bin->binary_length = sqlite3_value_bytes (argv [0]);
+	bin->binary_length = SQLITE3_CALL (sqlite3_value_bytes) (argv [0]);
 	gda_value_take_binary ((value = gda_value_new (GDA_TYPE_BINARY)), bin);
 	dh = gda_get_default_handler (GDA_TYPE_BINARY);
 	str = gda_data_handler_get_str_from_value (dh, value);
@@ -2725,7 +2745,7 @@ scalar_gda_hex_print_func (sqlite3_context *context, int argc, sqlite3_value **a
 	bin->data = NULL;
 	bin->binary_length = 0;
 	gda_value_free (value);
-	sqlite3_result_text (context, str, -1, g_free);
+	SQLITE3_CALL (sqlite3_result_text) (context, str, -1, g_free);
 }
 
 static void
@@ -2738,18 +2758,18 @@ scalar_gda_hex_print_func2 (sqlite3_context *context, int argc, sqlite3_value **
 	gint size;
 
 	if (argc != 2) {
-		sqlite3_result_error (context, _("Function requires two arguments"), -1);
+		SQLITE3_CALL (sqlite3_result_error) (context, _("Function requires two arguments"), -1);
 		return;
 	}
 
 	bin = g_new0 (GdaBinary, 1);
-	bin->data = (guchar*) sqlite3_value_blob (argv [0]);
+	bin->data = (guchar*) SQLITE3_CALL (sqlite3_value_blob) (argv [0]);
 	if (!bin->data) {
 		g_free (bin);
-		sqlite3_result_null (context);
+		SQLITE3_CALL (sqlite3_result_null) (context);
 		return;
 	}
-	bin->binary_length = sqlite3_value_bytes (argv [0]);
+	bin->binary_length = SQLITE3_CALL (sqlite3_value_bytes) (argv [0]);
 	gda_value_take_binary ((value = gda_value_new (GDA_TYPE_BINARY)), bin);
 	dh = gda_get_default_handler (GDA_TYPE_BINARY);
 	str = gda_data_handler_get_str_from_value (dh, value);
@@ -2758,9 +2778,9 @@ scalar_gda_hex_print_func2 (sqlite3_context *context, int argc, sqlite3_value **
 	bin->binary_length = 0;
 	gda_value_free (value);
 
-	size = sqlite3_value_int (argv [1]);
+	size = SQLITE3_CALL (sqlite3_value_int) (argv [1]);
 
-	sqlite3_result_text (context, str, -1, g_free);
+	SQLITE3_CALL (sqlite3_result_text) (context, str, -1, g_free);
 }
 
 static void
@@ -2772,17 +2792,17 @@ scalar_gda_hex_func (sqlite3_context *context, int argc, sqlite3_value **argv)
 	gint i;
 
 	if (argc != 1) {
-		sqlite3_result_error (context, _("Function requires one argument"), -1);
+		SQLITE3_CALL (sqlite3_result_error) (context, _("Function requires one argument"), -1);
 		return;
 	}
 
-	data = (guchar*) sqlite3_value_blob (argv [0]);
+	data = (guchar*) SQLITE3_CALL (sqlite3_value_blob) (argv [0]);
 	if (!data) {
-		sqlite3_result_null (context);
+		SQLITE3_CALL (sqlite3_result_null) (context);
 		return;
 	}
 
-	length = sqlite3_value_bytes (argv [0]);
+	length = SQLITE3_CALL (sqlite3_value_bytes) (argv [0]);
 	string = g_string_new ("");
 	for (i = 0; i < length; i++) {
 		if ((i > 0) && (i % 4 == 0))
@@ -2790,7 +2810,7 @@ scalar_gda_hex_func (sqlite3_context *context, int argc, sqlite3_value **argv)
 		g_string_append_printf (string, "%02x", data [i]);
 	}
 
-	sqlite3_result_text (context, string->str, -1, g_free);
+	SQLITE3_CALL (sqlite3_result_text) (context, string->str, -1, g_free);
 	g_string_free (string, FALSE);
 }
 
@@ -2804,18 +2824,18 @@ scalar_gda_hex_func2 (sqlite3_context *context, int argc, sqlite3_value **argv)
 	gint size;
 
 	if (argc != 2) {
-		sqlite3_result_error (context, _("Function requires two arguments"), -1);
+		SQLITE3_CALL (sqlite3_result_error) (context, _("Function requires two arguments"), -1);
 		return;
 	}
 
-	data = (guchar*) sqlite3_value_blob (argv [0]);
+	data = (guchar*) SQLITE3_CALL (sqlite3_value_blob) (argv [0]);
 	if (!data) {
-		sqlite3_result_null (context);
+		SQLITE3_CALL (sqlite3_result_null) (context);
 		return;
 	}
 
-	length = sqlite3_value_bytes (argv [0]);
-	size = sqlite3_value_int (argv [1]);
+	length = SQLITE3_CALL (sqlite3_value_bytes) (argv [0]);
+	size = SQLITE3_CALL (sqlite3_value_int) (argv [1]);
 
 	string = g_string_new ("");
 	for (i = 0; (i < length) && (string->len < (size / 2) * 2 + 2); i++) {
@@ -2826,7 +2846,7 @@ scalar_gda_hex_func2 (sqlite3_context *context, int argc, sqlite3_value **argv)
 
 	if (string->len > size)
 		string->str[size] = 0;
-	sqlite3_result_text (context, string->str, -1, g_free);
+	SQLITE3_CALL (sqlite3_result_text) (context, string->str, -1, g_free);
 	g_string_free (string, FALSE);
 }
 
@@ -2839,7 +2859,7 @@ gda_sqlite_free_cnc_data (SqliteConnectionData *cdata)
 	if (cdata->gdacnc)
 		g_object_remove_weak_pointer (G_OBJECT (cdata->gdacnc), (gpointer*) &(cdata->gdacnc));
 	if (cdata->connection) 
-		sqlite3_close (cdata->connection);
+		SQLITE3_CALL (sqlite3_close) (cdata->connection);
 	g_free (cdata->file);
 	if (cdata->types)
 		g_hash_table_destroy (cdata->types);
diff --git a/libgda/sqlite/gda-sqlite-pstmt.c b/libgda/sqlite/gda-sqlite-pstmt.c
index 50f809c..2341fd5 100644
--- a/libgda/sqlite/gda-sqlite-pstmt.c
+++ b/libgda/sqlite/gda-sqlite-pstmt.c
@@ -1,5 +1,5 @@
 /* GDA library
- * Copyright (C) 2008 - 2009 The GNOME Foundation.
+ * Copyright (C) 2008 - 2010 The GNOME Foundation.
  *
  * AUTHORS:
  *      Vivien Malerba <malerba gnome-db org>
@@ -22,6 +22,7 @@
 
 #include <glib/gi18n-lib.h>
 #include "gda-sqlite-pstmt.h"
+#include "gda-sqlite.h"
 #include <string.h>
 
 static void gda_sqlite_pstmt_class_init (GdaSqlitePStmtClass *klass);
@@ -56,7 +57,11 @@ _gda_sqlite_pstmt_get_type (void)
 
 		g_static_mutex_lock (&registering);
 		if (type == 0)
+#ifdef WITH_BDBSQLITE
+			type = g_type_register_static (GDA_TYPE_PSTMT, "GdaDBDSqlPStmt", &info, 0);
+#else
 			type = g_type_register_static (GDA_TYPE_PSTMT, "GdaSqlitePStmt", &info, 0);
+#endif
 		g_static_mutex_unlock (&registering);
 	}
 	return type;
@@ -91,7 +96,7 @@ gda_sqlite_pstmt_finalize (GObject *object)
 
 	/* free memory */
 	if (pstmt->sqlite_stmt) 
-		sqlite3_finalize (pstmt->sqlite_stmt);
+		SQLITE3_CALL (sqlite3_finalize) (pstmt->sqlite_stmt);
 
 	if (pstmt->rowid_hash)
 		g_hash_table_destroy (pstmt->rowid_hash);
diff --git a/libgda/sqlite/gda-sqlite-recordset.c b/libgda/sqlite/gda-sqlite-recordset.c
index 3e15b69..6ae3fa6 100644
--- a/libgda/sqlite/gda-sqlite-recordset.c
+++ b/libgda/sqlite/gda-sqlite-recordset.c
@@ -1,5 +1,5 @@
 /* GDA SQLite provider
- * Copyright (C) 1998 - 2009 The GNOME Foundation.
+ * Copyright (C) 1998 - 2010 The GNOME Foundation.
  *
  * AUTHORS:
  *	   Rodrigo Moya <rodrigo gnome-db org>
@@ -97,7 +97,7 @@ gda_sqlite_recordset_dispose (GObject *object)
 		GdaSqlitePStmt *ps;
 		ps = GDA_SQLITE_PSTMT (GDA_DATA_SELECT (object)->prep_stmt);
 		ps->stmt_used = FALSE;
-		sqlite3_reset (ps->sqlite_stmt);
+		SQLITE3_CALL (sqlite3_reset) (ps->sqlite_stmt);
 
 		if (recset->priv->tmp_row)
 			g_object_unref (recset->priv->tmp_row);
@@ -132,7 +132,11 @@ _gda_sqlite_recordset_get_type (void)
 		};
 		g_static_mutex_lock (&registering);
 		if (type == 0)
+#ifdef WITH_BDBSQLITE
+			type = g_type_register_static (GDA_TYPE_DATA_SELECT, "GdaDBDSqlRecordset", &info, 0);
+#else
 			type = g_type_register_static (GDA_TYPE_DATA_SELECT, "GdaSqliteRecordset", &info, 0);
+#endif
 		g_static_mutex_unlock (&registering);
 	}
 
@@ -209,7 +213,8 @@ _gda_sqlite_recordset_new (GdaConnection *cnc, GdaSqlitePStmt *ps, GdaSet *exec_
 
         /* make sure @ps reports the correct number of columns */
 	if (_GDA_PSTMT (ps)->ncols < 0)
-		_GDA_PSTMT (ps)->ncols = sqlite3_column_count (ps->sqlite_stmt) - ps->nb_rowid_columns;
+		_GDA_PSTMT (ps)->ncols = SQLITE3_CALL (sqlite3_column_count) (ps->sqlite_stmt) -
+			ps->nb_rowid_columns;
 
         /* completing ps */
 	g_assert (! ps->stmt_used);
@@ -246,9 +251,9 @@ _gda_sqlite_recordset_new (GdaConnection *cnc, GdaSqlitePStmt *ps, GdaSet *exec_
 			gint real_col = i + ps->nb_rowid_columns;
 			
 			column = GDA_COLUMN (list->data);
-			gda_column_set_description (column, sqlite3_column_name (ps->sqlite_stmt, real_col));
-			gda_column_set_name (column, sqlite3_column_name (ps->sqlite_stmt, real_col));
-			gda_column_set_dbms_type (column, sqlite3_column_decltype (ps->sqlite_stmt, real_col));
+			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));
 			if (_GDA_PSTMT (ps)->types [i] != GDA_TYPE_NULL)
 				gda_column_set_g_type (column, _GDA_PSTMT (ps)->types [i]);
 		}
@@ -285,16 +290,16 @@ fuzzy_get_gtype (SqliteConnectionData *cdata, GdaSqlitePStmt *ps, gint colnum)
 	if (_GDA_PSTMT (ps)->types [colnum] != GDA_TYPE_NULL)
 		return _GDA_PSTMT (ps)->types [colnum];
 	
-	ctype = sqlite3_column_origin_name (ps->sqlite_stmt, real_col);
+	ctype = SQLITE3_CALL (sqlite3_column_origin_name) (ps->sqlite_stmt, real_col);
 	if (ctype && !strcmp (ctype, "rowid"))
 		gtype = G_TYPE_INT64;
 	else {
-		ctype = sqlite3_column_decltype (ps->sqlite_stmt, real_col);
+		ctype = SQLITE3_CALL (sqlite3_column_decltype) (ps->sqlite_stmt, real_col);
 		
 		if (ctype)
 			gtype = GPOINTER_TO_INT (g_hash_table_lookup (cdata->types, ctype));
 		if (gtype == GDA_TYPE_NULL) 
-			gtype = _gda_sqlite_compute_g_type (sqlite3_column_type (ps->sqlite_stmt, real_col));
+			gtype = _gda_sqlite_compute_g_type (SQLITE3_CALL (sqlite3_column_type) (ps->sqlite_stmt, real_col));
 	}
 
 	return gtype;
@@ -317,7 +322,7 @@ fetch_next_sqlite_row (GdaSqliteRecordset *model, gboolean do_store, GError **er
 	if (model->priv->empty_forced)
 		rc = SQLITE_DONE;
 	else
-		rc = sqlite3_step (ps->sqlite_stmt);
+		rc = SQLITE3_CALL (sqlite3_step) (ps->sqlite_stmt);
 	switch (rc) {
 	case  SQLITE_ROW: {
 		gint col, real_col;
@@ -336,12 +341,12 @@ fetch_next_sqlite_row (GdaSqliteRecordset *model, gboolean do_store, GError **er
 					if (ps->rowid_hash) {
 						gint oidcol = 0;
 						const char *ctable;
-						ctable = sqlite3_column_name (ps->sqlite_stmt, real_col);
+						ctable = SQLITE3_CALL (sqlite3_column_name) (ps->sqlite_stmt, real_col);
 						if (ctable)
 							oidcol = GPOINTER_TO_INT (g_hash_table_lookup (ps->rowid_hash,
 												       ctable));
 						if (oidcol == 0) {
-							ctable = sqlite3_column_table_name (ps->sqlite_stmt, real_col);
+							ctable = SQLITE3_CALL (sqlite3_column_table_name) (ps->sqlite_stmt, real_col);
 							if (ctable)
 								oidcol = GPOINTER_TO_INT (g_hash_table_lookup (ps->rowid_hash, 
 													       ctable));
@@ -365,7 +370,7 @@ fetch_next_sqlite_row (GdaSqliteRecordset *model, gboolean do_store, GError **er
 			
 			/* fill GValue */
 			value = gda_row_get_value (prow, col);
-			if (sqlite3_column_text (ps->sqlite_stmt, real_col) == NULL) {
+			if (SQLITE3_CALL (sqlite3_column_text) (ps->sqlite_stmt, real_col) == NULL) {
 				/* we have a NULL value */
 				gda_value_set_null (value);
 			}
@@ -377,7 +382,7 @@ fetch_next_sqlite_row (GdaSqliteRecordset *model, gboolean do_store, GError **er
 					;
 				else if (type == G_TYPE_INT) {
 					gint64 i;
-					i = sqlite3_column_int64 (ps->sqlite_stmt, real_col);
+					i = SQLITE3_CALL (sqlite3_column_int64) (ps->sqlite_stmt, real_col);
 					if ((i > G_MAXINT) || (i < G_MININT)) {
 						g_set_error (error, GDA_SERVER_PROVIDER_ERROR,
 							     GDA_SERVER_PROVIDER_DATA_ERROR,
@@ -389,7 +394,7 @@ fetch_next_sqlite_row (GdaSqliteRecordset *model, gboolean do_store, GError **er
 				}
 				else if (type == G_TYPE_UINT) {
 					guint64 i;
-					i = (gint64) sqlite3_column_int64 (ps->sqlite_stmt, real_col);
+					i = (gint64) SQLITE3_CALL (sqlite3_column_int64) (ps->sqlite_stmt, real_col);
 					if (i > G_MAXUINT) {
 						g_set_error (error, GDA_SERVER_PROVIDER_ERROR,
 							     GDA_SERVER_PROVIDER_DATA_ERROR,
@@ -400,24 +405,24 @@ 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_column_int64 (ps->sqlite_stmt, real_col));
+					g_value_set_int64 (value, SQLITE3_CALL (sqlite3_column_int64) (ps->sqlite_stmt, real_col));
 				else if (type == G_TYPE_UINT64)
-					g_value_set_uint64 (value, (guint64) sqlite3_column_int64 (ps->sqlite_stmt,
+					g_value_set_uint64 (value, (guint64) SQLITE3_CALL (sqlite3_column_int64) (ps->sqlite_stmt,
 												   real_col));
 				else if (type == G_TYPE_DOUBLE)
-					g_value_set_double (value, sqlite3_column_double (ps->sqlite_stmt,
+					g_value_set_double (value, SQLITE3_CALL (sqlite3_column_double) (ps->sqlite_stmt,
 											  real_col));
 				else if (type == G_TYPE_STRING)
-					g_value_set_string (value, (gchar *) sqlite3_column_text (ps->sqlite_stmt,
+					g_value_set_string (value, (gchar *) SQLITE3_CALL (sqlite3_column_text) (ps->sqlite_stmt,
 												  real_col));
 				else if (type == GDA_TYPE_BINARY) {
 					GdaBinary *bin;
 					
 					bin = g_new0 (GdaBinary, 1);
-					bin->binary_length = sqlite3_column_bytes (ps->sqlite_stmt, real_col);
+					bin->binary_length = SQLITE3_CALL (sqlite3_column_bytes) (ps->sqlite_stmt, real_col);
 					if (bin->binary_length > 0) {
 						bin->data = g_new (guchar, bin->binary_length);
-						memcpy (bin->data, sqlite3_column_blob (ps->sqlite_stmt,
+						memcpy (bin->data, SQLITE3_CALL (sqlite3_column_blob) (ps->sqlite_stmt,
 											real_col),
 							bin->binary_length);
 					}
@@ -431,12 +436,12 @@ fetch_next_sqlite_row (GdaSqliteRecordset *model, gboolean do_store, GError **er
 
 					if (ps->rowid_hash) {
 						const char *ctable;
-						ctable = sqlite3_column_name (ps->sqlite_stmt, real_col);
+						ctable = SQLITE3_CALL (sqlite3_column_name) (ps->sqlite_stmt, real_col);
 						if (ctable)
 							oidcol = GPOINTER_TO_INT (g_hash_table_lookup (ps->rowid_hash,
 												       ctable));
 						if (oidcol == 0) {
-							ctable = sqlite3_column_table_name (ps->sqlite_stmt, real_col);
+							ctable = SQLITE3_CALL (sqlite3_column_table_name) (ps->sqlite_stmt, real_col);
 							if (ctable)
 								oidcol = GPOINTER_TO_INT (g_hash_table_lookup (ps->rowid_hash, 
 													       ctable));
@@ -444,14 +449,14 @@ fetch_next_sqlite_row (GdaSqliteRecordset *model, gboolean do_store, GError **er
 					}
 					if (oidcol != 0) {
 						gint64 rowid;
-						rowid = sqlite3_column_int64 (ps->sqlite_stmt, oidcol - 1); /* remove 1
+						rowid = SQLITE3_CALL (sqlite3_column_int64) (ps->sqlite_stmt, oidcol - 1); /* remove 1
 													       because it was added in the first place */
 						bop = _gda_sqlite_blob_op_new (cdata,
-									      sqlite3_column_database_name (ps->sqlite_stmt, 
+									       SQLITE3_CALL (sqlite3_column_database_name) (ps->sqlite_stmt, 
 													    real_col),
-									      sqlite3_column_table_name (ps->sqlite_stmt,
+									       SQLITE3_CALL (sqlite3_column_table_name) (ps->sqlite_stmt,
 													 real_col),
-									      sqlite3_column_origin_name (ps->sqlite_stmt,
+									       SQLITE3_CALL (sqlite3_column_origin_name) (ps->sqlite_stmt,
 													  real_col),
 									      rowid);
 					}
@@ -470,16 +475,16 @@ fetch_next_sqlite_row (GdaSqliteRecordset *model, gboolean do_store, GError **er
 					}
 				}
 				else if (type == G_TYPE_BOOLEAN)
-					g_value_set_boolean (value, sqlite3_column_int (ps->sqlite_stmt, real_col) == 0 ? FALSE : TRUE);
+					g_value_set_boolean (value, SQLITE3_CALL (sqlite3_column_int) (ps->sqlite_stmt, real_col) == 0 ? FALSE : TRUE);
 				else if (type == G_TYPE_DATE) {
 					GDate date;
 					if (!gda_parse_iso8601_date (&date, 
-								     (gchar *) sqlite3_column_text (ps->sqlite_stmt, 
+								     (gchar *) SQLITE3_CALL (sqlite3_column_text) (ps->sqlite_stmt, 
 												    real_col))) {
 						g_set_error (error, GDA_SERVER_PROVIDER_ERROR,
 							     GDA_SERVER_PROVIDER_DATA_ERROR,
 							     _("Invalid date '%s' (date format should be YYYY-MM-DD)"), 
-							     (gchar *) sqlite3_column_text (ps->sqlite_stmt, real_col));
+							     (gchar *) SQLITE3_CALL (sqlite3_column_text) (ps->sqlite_stmt, real_col));
 						gda_row_invalidate_value (prow, value);
 					}
 					else
@@ -488,12 +493,12 @@ fetch_next_sqlite_row (GdaSqliteRecordset *model, gboolean do_store, GError **er
 				else if (type == GDA_TYPE_TIME) {
 					GdaTime timegda;
 					if (!gda_parse_iso8601_time (&timegda, 
-								     (gchar *) sqlite3_column_text (ps->sqlite_stmt, 
+								     (gchar *) SQLITE3_CALL (sqlite3_column_text) (ps->sqlite_stmt, 
 												    real_col))) {
 						g_set_error (error, GDA_SERVER_PROVIDER_ERROR,
 							     GDA_SERVER_PROVIDER_DATA_ERROR,
 							     _("Invalid time '%s' (time format should be HH:MM:SS[.ms])"), 
-							     (gchar *) sqlite3_column_text (ps->sqlite_stmt, real_col));
+							     (gchar *) SQLITE3_CALL (sqlite3_column_text) (ps->sqlite_stmt, real_col));
 						gda_row_invalidate_value (prow, value);
 					}
 					else
@@ -502,12 +507,12 @@ fetch_next_sqlite_row (GdaSqliteRecordset *model, gboolean do_store, GError **er
 				else if (type == GDA_TYPE_TIMESTAMP) {
 					GdaTimestamp timestamp;
 					if (!gda_parse_iso8601_timestamp (&timestamp, 
-									  (gchar *) sqlite3_column_text (ps->sqlite_stmt,
+									  (gchar *) SQLITE3_CALL (sqlite3_column_text) (ps->sqlite_stmt,
 													 real_col))) {
 						g_set_error (error, GDA_SERVER_PROVIDER_ERROR,
 							     GDA_SERVER_PROVIDER_DATA_ERROR,
 							     _("Invalid timestamp '%s' (format should be YYYY-MM-DD HH:MM:SS[.ms])"), 
-							     (gchar *) sqlite3_column_text (ps->sqlite_stmt, real_col));
+							     (gchar *) SQLITE3_CALL (sqlite3_column_text) (ps->sqlite_stmt, real_col));
 						gda_row_invalidate_value (prow, value);
 					}
 					else
@@ -531,11 +536,11 @@ fetch_next_sqlite_row (GdaSqliteRecordset *model, gboolean do_store, GError **er
 		break;
 	case SQLITE_ERROR:
 		g_set_error (error, GDA_SERVER_PROVIDER_ERROR,
-			     GDA_SERVER_PROVIDER_INTERNAL_ERROR,  "%s", sqlite3_errmsg (cdata->connection));
+			     GDA_SERVER_PROVIDER_INTERNAL_ERROR,  "%s", SQLITE3_CALL (sqlite3_errmsg) (cdata->connection));
 		break;
 	case SQLITE_DONE:
 		GDA_DATA_SELECT (model)->advertized_nrows = model->priv->next_row_num;
-		sqlite3_reset (ps->sqlite_stmt);
+		SQLITE3_CALL (sqlite3_reset) (ps->sqlite_stmt);
 		break;
 	case SQLITE_MISUSE:
 		g_set_error (error, GDA_SERVER_PROVIDER_ERROR,
diff --git a/libgda/sqlite/gda-sqlite.h b/libgda/sqlite/gda-sqlite.h
index 30aa7c2..16b1a7a 100644
--- a/libgda/sqlite/gda-sqlite.h
+++ b/libgda/sqlite/gda-sqlite.h
@@ -1,5 +1,5 @@
 /* GDA SQLite provider
- * Copyright (C) 1998 - 2009 The GNOME Foundation.
+ * Copyright (C) 1998 - 2010 The GNOME Foundation.
  *
  * AUTHORS:
  *	Rodrigo Moya <rodrigo gnome-db org>
@@ -28,13 +28,22 @@
 #include <glib.h>
 #include <libgda/libgda.h>
 
-#ifdef HAVE_SQLITE
-#include <sqlite3.h>
-  #if (SQLITE_VERSION_NUMBER < 3005000)
-  typedef sqlite_int64 sqlite3_int64;
-  #endif
+#ifdef WITH_BDBSQLITE
+  #include <dbsql.h>
+  #include "gda-symbols-util.h"
+  #define SQLITE3_CALL(x) (s3r->x)
 #else
-#include "sqlite-src/sqlite3.h"
+  #ifdef HAVE_SQLITE
+    #include <sqlite3.h>
+    #include "gda-symbols-util.h"
+    #define SQLITE3_CALL(x) (s3r->x)
+    #if (SQLITE_VERSION_NUMBER < 3005000)
+      typedef sqlite_int64 sqlite3_int64;
+    #endif
+  #else
+    #include "sqlite-src/sqlite3.h"
+    #define SQLITE3_CALL(x) (x)
+  #endif
 #endif
 
 /*
diff --git a/libgda/sqlite/gda-symbols-util.c b/libgda/sqlite/gda-symbols-util.c
new file mode 100644
index 0000000..98e8457
--- /dev/null
+++ b/libgda/sqlite/gda-symbols-util.c
@@ -0,0 +1,281 @@
+/*
+ * Copyright (C) 2010 The GNOME Foundation.
+ *
+ * AUTHORS:
+ *         Vivien Malerba <malerba gnome-db org>
+ *
+ * This Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This Library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this Library; see the file COPYING.LIB.  If not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <glib/gi18n-lib.h>
+#include <libgda.h>
+#include "gda-symbols-util.h"
+
+Sqlite3ApiRoutines *s3r = NULL;
+
+
+
+static GModule *
+find_sqlite_in_dir (const gchar *dir_name, const gchar *name_part)
+{
+	GDir *dir;
+	GError *err = NULL;
+	const gchar *name;
+	GModule *handle = NULL;
+	
+#ifdef GDA_DEBUG_NO
+	g_print ("Looking for '%s' in %s\n", name_part, dir_name);
+#endif
+	dir = g_dir_open (dir_name, 0, &err);
+	if (err) {
+		gda_log_error (err->message);
+		g_error_free (err);
+		return FALSE;
+	}
+	
+	while ((name = g_dir_read_name (dir))) {
+		if (!g_str_has_suffix (name, "." G_MODULE_SUFFIX))
+			continue;
+		if (!g_strrstr (name, name_part))
+			continue;
+		
+		gchar *path;
+		
+		path = g_build_path (G_DIR_SEPARATOR_S, dir_name, name, NULL);
+		handle = g_module_open (path, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);
+		g_free (path);
+		if (!handle) {
+			/*g_warning (_("Error: %s"), g_module_error ());*/
+			continue;
+		}
+
+		gpointer func;
+		if (g_module_symbol (handle, "sqlite3_open", &func)) {
+#ifdef GDA_DEBUG_NO
+			path = g_build_path (G_DIR_SEPARATOR_S, dir_name, name, NULL);
+			g_print ("'%s' found as: '%s'\n", name_part, path);
+			g_free (path);
+#endif
+			break;
+		}
+		else {
+			g_module_close (handle);
+			handle = NULL;
+		}
+
+	}
+	/* free memory */
+	g_dir_close (dir);
+	return handle;
+}
+
+GModule *
+find_sqlite_library (const gchar *name_part)
+{
+	GModule *handle;
+	const gchar *env;
+
+	/* first try by 'normal' shared library finding */
+	handle = g_module_open (name_part, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);
+	if (handle) {
+		gpointer func;
+		if (g_module_symbol (handle, "sqlite3_open", &func)) {
+#ifdef GDA_DEBUG_NO
+			g_print ("'%s' found using default shared library finding\n", name_part);
+#endif
+			return handle;
+		}
+
+		g_module_close (handle);
+		handle = NULL;
+	}
+
+	/* first, use LD_LIBRARY_PATH */
+	env = g_getenv ("LD_LIBRARY_PATH");
+	if (env) {
+		gchar **array;
+		gint i;
+		array = g_strsplit (env, ":", 0);
+		for (i = 0; array[i]; i++) {
+			handle = find_sqlite_in_dir (array [i], name_part);
+			if (handle)
+				break;
+		}
+		g_strfreev (array);
+		if (handle)
+			return handle;
+	}
+
+	/* then use the compile time SEARCH_LIB_PATH */
+	if (SEARCH_LIB_PATH) {
+		gchar **array;
+		gint i;
+		array = g_strsplit (SEARCH_LIB_PATH, ":", 0);
+		for (i = 0; array[i]; i++) {
+			handle = find_sqlite_in_dir (array [i], name_part);
+			if (handle)
+				break;
+		}
+		g_strfreev (array);
+		if (handle)
+			return handle;
+	}
+
+	return NULL;
+}
+
+void
+load_symbols (GModule *module)
+{
+	g_assert (module);
+	s3r = g_new (Sqlite3ApiRoutines, 1);
+
+	if (! g_module_symbol (module, "sqlite3_bind_blob", (gpointer*) &(s3r->sqlite3_bind_blob)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_bind_double", (gpointer*) &(s3r->sqlite3_bind_double)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_bind_int", (gpointer*) &(s3r->sqlite3_bind_int)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_bind_int64", (gpointer*) &(s3r->sqlite3_bind_int64)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_bind_null", (gpointer*) &(s3r->sqlite3_bind_null)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_bind_text", (gpointer*) &(s3r->sqlite3_bind_text)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_bind_zeroblob", (gpointer*) &(s3r->sqlite3_bind_zeroblob)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_blob_bytes", (gpointer*) &(s3r->sqlite3_blob_bytes)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_blob_close", (gpointer*) &(s3r->sqlite3_blob_close)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_blob_open", (gpointer*) &(s3r->sqlite3_blob_open)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_blob_read", (gpointer*) &(s3r->sqlite3_blob_read)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_blob_write", (gpointer*) &(s3r->sqlite3_blob_write)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_busy_timeout", (gpointer*) &(s3r->sqlite3_busy_timeout)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_changes", (gpointer*) &(s3r->sqlite3_changes)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_clear_bindings", (gpointer*) &(s3r->sqlite3_clear_bindings)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_close", (gpointer*) &(s3r->sqlite3_close)))
+		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)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_column_count", (gpointer*) &(s3r->sqlite3_column_count)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_column_database_name", (gpointer*) &(s3r->sqlite3_column_database_name)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_column_decltype", (gpointer*) &(s3r->sqlite3_column_decltype)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_column_double", (gpointer*) &(s3r->sqlite3_column_double)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_column_int", (gpointer*) &(s3r->sqlite3_column_int)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_column_int64", (gpointer*) &(s3r->sqlite3_column_int64)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_column_name", (gpointer*) &(s3r->sqlite3_column_name)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_column_origin_name", (gpointer*) &(s3r->sqlite3_column_origin_name)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_column_table_name", (gpointer*) &(s3r->sqlite3_column_table_name)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_column_text", (gpointer*) &(s3r->sqlite3_column_text)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_column_type", (gpointer*) &(s3r->sqlite3_column_type)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_config", (gpointer*) &(s3r->sqlite3_config)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_create_function", (gpointer*) &(s3r->sqlite3_create_function)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_create_module", (gpointer*) &(s3r->sqlite3_create_module)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_db_handle", (gpointer*) &(s3r->sqlite3_db_handle)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_declare_vtab", (gpointer*) &(s3r->sqlite3_declare_vtab)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_errcode", (gpointer*) &(s3r->sqlite3_errcode)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_errmsg", (gpointer*) &(s3r->sqlite3_errmsg)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_exec", (gpointer*) &(s3r->sqlite3_exec)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_extended_result_codes", (gpointer*) &(s3r->sqlite3_extended_result_codes)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_finalize", (gpointer*) &(s3r->sqlite3_finalize)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_free", (gpointer*) &(s3r->sqlite3_free)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_free_table", (gpointer*) &(s3r->sqlite3_free_table)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_get_table", (gpointer*) &(s3r->sqlite3_get_table)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_last_insert_rowid", (gpointer*) &(s3r->sqlite3_last_insert_rowid)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_malloc", (gpointer*) &(s3r->sqlite3_malloc)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_mprintf", (gpointer*) &(s3r->sqlite3_mprintf)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_open", (gpointer*) &(s3r->sqlite3_open)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_prepare", (gpointer*) &(s3r->sqlite3_prepare)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_prepare_v2", (gpointer*) &(s3r->sqlite3_prepare_v2)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_reset", (gpointer*) &(s3r->sqlite3_reset)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_result_blob", (gpointer*) &(s3r->sqlite3_result_blob)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_result_double", (gpointer*) &(s3r->sqlite3_result_double)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_result_error", (gpointer*) &(s3r->sqlite3_result_error)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_result_int", (gpointer*) &(s3r->sqlite3_result_int)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_result_int64", (gpointer*) &(s3r->sqlite3_result_int64)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_result_null", (gpointer*) &(s3r->sqlite3_result_null)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_result_text", (gpointer*) &(s3r->sqlite3_result_text)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_step", (gpointer*) &(s3r->sqlite3_step)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_table_column_metadata", (gpointer*) &(s3r->sqlite3_table_column_metadata)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_threadsafe", (gpointer*) &(s3r->sqlite3_threadsafe)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_value_blob", (gpointer*) &(s3r->sqlite3_value_blob)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_value_bytes", (gpointer*) &(s3r->sqlite3_value_bytes)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_value_int", (gpointer*) &(s3r->sqlite3_value_int)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_value_text", (gpointer*) &(s3r->sqlite3_value_text)))
+		goto onerror;
+	if (! g_module_symbol (module, "sqlite3_value_type", (gpointer*) &(s3r->sqlite3_value_type)))
+		goto onerror;
+	return;
+
+ onerror:
+	g_free (s3r);
+	s3r = NULL;
+	g_module_close (module);	
+}
+
diff --git a/libgda/sqlite/gda-symbols-util.h b/libgda/sqlite/gda-symbols-util.h
new file mode 100644
index 0000000..6f929e8
--- /dev/null
+++ b/libgda/sqlite/gda-symbols-util.h
@@ -0,0 +1,119 @@
+/*
+ * Copyright (C) 2010 The GNOME Foundation.
+ *
+ * AUTHORS:
+ *         Vivien Malerba <malerba gnome-db org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef __GDA_BDBSQL_UTIL_H__
+#define __GDA_BDBSQL_UTIL_H__
+
+#include <gmodule.h>
+#ifdef WITH_BDBSQLITE
+  #include <dbsql.h>
+#else
+  #include <sqlite3.h>
+#endif
+
+G_BEGIN_DECLS
+
+typedef struct {
+	int  (*sqlite3_bind_blob)(sqlite3_stmt*,int,const void*,int n,void(*)(void*));
+	int  (*sqlite3_bind_double)(sqlite3_stmt*,int,double);
+	int  (*sqlite3_bind_int)(sqlite3_stmt*,int,int);
+	int  (*sqlite3_bind_int64)(sqlite3_stmt*,int,sqlite_int64);
+	int  (*sqlite3_bind_null)(sqlite3_stmt*,int);
+	int  (*sqlite3_bind_text)(sqlite3_stmt*,int,const char*,int n,void(*)(void*));
+	int (*sqlite3_bind_zeroblob)(sqlite3_stmt*,int,int);
+	int (*sqlite3_blob_bytes)(sqlite3_blob*);
+	int (*sqlite3_blob_close)(sqlite3_blob*);
+	int (*sqlite3_blob_open)(sqlite3*,const char*,const char*,const char*,sqlite3_int64,int,sqlite3_blob**);
+	int (*sqlite3_blob_read)(sqlite3_blob*,void*,int,int);
+	int (*sqlite3_blob_write)(sqlite3_blob*,const void*,int,int);
+
+	int  (*sqlite3_busy_timeout)(sqlite3*,int ms);
+	int  (*sqlite3_changes)(sqlite3*);
+	int (*sqlite3_clear_bindings)(sqlite3_stmt*);
+	int  (*sqlite3_close)(sqlite3*);
+
+	const void * (*sqlite3_column_blob)(sqlite3_stmt*,int iCol);
+	int  (*sqlite3_column_bytes)(sqlite3_stmt*,int iCol);
+	int  (*sqlite3_column_count)(sqlite3_stmt*pStmt);
+	const char * (*sqlite3_column_database_name)(sqlite3_stmt*,int);
+	const char * (*sqlite3_column_decltype)(sqlite3_stmt*,int i);
+	double  (*sqlite3_column_double)(sqlite3_stmt*,int iCol);
+	int  (*sqlite3_column_int)(sqlite3_stmt*,int iCol);
+	sqlite_int64  (*sqlite3_column_int64)(sqlite3_stmt*,int iCol);
+	const char * (*sqlite3_column_name)(sqlite3_stmt*,int);
+	const char * (*sqlite3_column_origin_name)(sqlite3_stmt*,int);
+	const char * (*sqlite3_column_table_name)(sqlite3_stmt*,int);
+	const unsigned char * (*sqlite3_column_text)(sqlite3_stmt*,int iCol);
+	int  (*sqlite3_column_type)(sqlite3_stmt*,int iCol);
+
+	int (*sqlite3_config) (int, ...);
+
+	int  (*sqlite3_create_function)(sqlite3*,const char*,int,int,void*,void (*xFunc)(sqlite3_context*,int,sqlite3_value**),void (*xStep)(sqlite3_context*,int,sqlite3_value**),void (*xFinal)(sqlite3_context*));
+	int (*sqlite3_create_module)(sqlite3*,const char*,const sqlite3_module*,void*);
+	sqlite3 * (*sqlite3_db_handle)(sqlite3_stmt*);	
+	int (*sqlite3_declare_vtab)(sqlite3*,const char*);
+
+	int  (*sqlite3_errcode)(sqlite3*db);
+	const char * (*sqlite3_errmsg)(sqlite3*);
+
+	int  (*sqlite3_exec)(sqlite3*,const char*,sqlite3_callback,void*,char**);
+	int (*sqlite3_extended_result_codes)(sqlite3*,int);
+	int  (*sqlite3_finalize)(sqlite3_stmt*pStmt);
+	void  (*sqlite3_free)(void*);
+	void  (*sqlite3_free_table)(char**result);
+	int  (*sqlite3_get_table)(sqlite3*,const char*,char***,int*,int*,char**);
+	sqlite_int64  (*sqlite3_last_insert_rowid)(sqlite3*);
+
+	void *(*sqlite3_malloc)(int);
+	char * (*sqlite3_mprintf)(const char*,...);
+	int  (*sqlite3_open)(const char*,sqlite3**);
+	int  (*sqlite3_prepare)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);
+	int (*sqlite3_prepare_v2)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);
+
+	int  (*sqlite3_reset)(sqlite3_stmt*pStmt);
+	void  (*sqlite3_result_blob)(sqlite3_context*,const void*,int,void(*)(void*));
+	void  (*sqlite3_result_double)(sqlite3_context*,double);
+	void  (*sqlite3_result_error)(sqlite3_context*,const char*,int);
+	void  (*sqlite3_result_int)(sqlite3_context*,int);
+	void  (*sqlite3_result_int64)(sqlite3_context*,sqlite_int64);
+	void  (*sqlite3_result_null)(sqlite3_context*);
+	void  (*sqlite3_result_text)(sqlite3_context*,const char*,int,void(*)(void*));
+
+	int  (*sqlite3_step)(sqlite3_stmt*);
+	int  (*sqlite3_table_column_metadata)(sqlite3*,const char*,const char*,const char*,char const**,char const**,int*,int*,int*);
+	int (*sqlite3_threadsafe)(void);
+
+	const void * (*sqlite3_value_blob)(sqlite3_value*);
+	int  (*sqlite3_value_bytes)(sqlite3_value*);
+	int  (*sqlite3_value_int)(sqlite3_value*);
+	const unsigned char * (*sqlite3_value_text)(sqlite3_value*);
+	int  (*sqlite3_value_type)(sqlite3_value*);
+} Sqlite3ApiRoutines;
+
+extern Sqlite3ApiRoutines *s3r;
+
+GModule *find_sqlite_library (const gchar *name_part);
+void     load_symbols (GModule *module);
+
+G_END_DECLS
+
+#endif
+
diff --git a/libgda/sqlite/virtual/gda-vconnection-data-model.c b/libgda/sqlite/virtual/gda-vconnection-data-model.c
index 6b681b7..da77e6f 100644
--- a/libgda/sqlite/virtual/gda-vconnection-data-model.c
+++ b/libgda/sqlite/virtual/gda-vconnection-data-model.c
@@ -1,6 +1,6 @@
 /* 
  * GDA common library
- * Copyright (C) 2007 The GNOME Foundation.
+ * Copyright (C) 2007 - 2010 The GNOME Foundation.
  *
  * AUTHORS:
  *      Vivien Malerba <malerba gnome-db org>
@@ -250,11 +250,11 @@ gda_vconnection_data_model_add (GdaVconnectionDataModel *cnc, GdaVconnectionData
 	/* actually create the virtual table in @cnc */
 	prov = (GdaVirtualProvider *) gda_connection_get_provider (GDA_CONNECTION (cnc));
 	str = g_strdup_printf ("CREATE VIRTUAL TABLE %s USING %s ('%s')", table_name, G_OBJECT_TYPE_NAME (prov), td->unique_name);
-	rc = sqlite3_exec (scnc->connection, str, NULL, 0, &zErrMsg);
+	rc = SQLITE3_CALL (sqlite3_exec) (scnc->connection, str, NULL, 0, &zErrMsg);
 	g_free (str);
 	if (rc != SQLITE_OK) {
 		g_set_error (error, 0, 0, "%s", zErrMsg);
-		sqlite3_free (zErrMsg);
+		SQLITE3_CALL (sqlite3_free) (zErrMsg);
 		gda_vconnection_data_model_table_data_free (td);
 		cnc->priv->table_data_list = g_slist_remove (cnc->priv->table_data_list, td);
 		retval = FALSE;
@@ -308,12 +308,12 @@ gda_vconnection_data_model_remove (GdaVconnectionDataModel *cnc, const gchar *ta
 	
 	prov = (GdaVirtualProvider *) gda_connection_get_provider (GDA_CONNECTION (cnc));
 	str = g_strdup_printf ("DROP TABLE %s", td->table_name);
-	rc = sqlite3_exec (scnc->connection, str, NULL, 0, &zErrMsg);
+	rc = SQLITE3_CALL (sqlite3_exec) (scnc->connection, str, NULL, 0, &zErrMsg);
 	g_free (str);
 
 	if (rc != SQLITE_OK) {
 		g_set_error (error, 0, 0, "%s", zErrMsg);
-		sqlite3_free (zErrMsg);
+		SQLITE3_CALL (sqlite3_free) (zErrMsg);
 		return FALSE;
 	}
 	else {
diff --git a/libgda/sqlite/virtual/gda-vprovider-data-model.c b/libgda/sqlite/virtual/gda-vprovider-data-model.c
index 6c48241..2c20a4e 100644
--- a/libgda/sqlite/virtual/gda-vprovider-data-model.c
+++ b/libgda/sqlite/virtual/gda-vprovider-data-model.c
@@ -1,6 +1,6 @@
 /* 
  * GDA common library
- * Copyright (C) 2007 - 2008 The GNOME Foundation.
+ * Copyright (C) 2007 - 2010 The GNOME Foundation.
  *
  * AUTHORS:
  *      Vivien Malerba <malerba gnome-db org>
@@ -288,7 +288,7 @@ gda_vprovider_data_model_open_connection (GdaServerProvider *provider, GdaConnec
 	}
 
 	/* Module to declare wirtual tables */
-	if (sqlite3_create_module (scnc->connection, G_OBJECT_TYPE_NAME (provider), &Module, cnc) != SQLITE_OK)
+	if (SQLITE3_CALL (sqlite3_create_module) (scnc->connection, G_OBJECT_TYPE_NAME (provider), &Module, cnc) != SQLITE_OK)
 		return FALSE;
 	/*g_print ("==== Declared module for DB %p\n", scnc->connection);*/
 
@@ -381,7 +381,7 @@ virtualCreate (sqlite3 *db, void *pAux, int argc, const char *const *argv, sqlit
 
 		ncols = gda_data_model_get_n_columns (wrapper);
 		if (ncols <= 0) {
-			*pzErr = sqlite3_mprintf (_("Data model must have at least one column"));
+			*pzErr = SQLITE3_CALL (sqlite3_mprintf) (_("Data model must have at least one column"));
 			g_object_unref (wrapper);
 			return SQLITE_ERROR;
 		}
@@ -395,11 +395,11 @@ virtualCreate (sqlite3 *db, void *pAux, int argc, const char *const *argv, sqlit
 		if (! td->columns) {
 			if (error && error->message) {
 				int len = strlen (error->message) + 1;
-				*pzErr = sqlite3_malloc (sizeof (gchar) * len);
+				*pzErr = SQLITE3_CALL (sqlite3_malloc) (sizeof (gchar) * len);
 				memcpy (*pzErr, error->message, len);
 			}
 			else 
-				*pzErr = sqlite3_mprintf (_("Could not compute virtual table's columns"));
+				*pzErr = SQLITE3_CALL (sqlite3_mprintf) (_("Could not compute virtual table's columns"));
 			return SQLITE_ERROR;
 		}
 		ncols = g_list_length (td->columns);
@@ -424,7 +424,7 @@ virtualCreate (sqlite3 *db, void *pAux, int argc, const char *const *argv, sqlit
 		else
 			column = gda_data_model_describe_column (wrapper, i);
 		if (!column) {
-			*pzErr = sqlite3_mprintf (_("Can't get data model description for column %d"), i);
+			*pzErr = SQLITE3_CALL (sqlite3_mprintf) (_("Can't get data model description for column %d"), i);
 			g_string_free (sql, TRUE);
 			return SQLITE_ERROR;
 		}
@@ -438,7 +438,7 @@ virtualCreate (sqlite3 *db, void *pAux, int argc, const char *const *argv, sqlit
 		gtype = gda_column_get_g_type (column);
 		type = g_type_name (gtype);
 		if (!type) {
-			*pzErr = sqlite3_mprintf (_("Can't get data model's column type or type for column %d"), i);
+			*pzErr = SQLITE3_CALL (sqlite3_mprintf) (_("Can't get data model's column type or type for column %d"), i);
 			g_string_free (sql, TRUE);
 			return SQLITE_ERROR;
 		}
@@ -485,8 +485,8 @@ virtualCreate (sqlite3 *db, void *pAux, int argc, const char *const *argv, sqlit
 	vtable->td = td;
 	*ppVtab = &(vtable->base);
 
-	if (sqlite3_declare_vtab (db, sql->str) != SQLITE_OK) {
-		*pzErr = sqlite3_mprintf (_("Can't declare virtual table (%s)"), sql->str);
+	if (SQLITE3_CALL (sqlite3_declare_vtab) (db, sql->str) != SQLITE_OK) {
+		*pzErr = SQLITE3_CALL (sqlite3_mprintf) (_("Can't declare virtual table (%s)"), sql->str);
 		g_string_free (sql, TRUE);
 		g_free (vtable);
 		*ppVtab = NULL;
@@ -641,13 +641,13 @@ virtualColumn (sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i)
 	
 	if (i == cursor->ncols) {
 		/* private hidden column, which returns the row number */
-		sqlite3_result_int (ctx, gda_data_model_iter_get_row (cursor->iter));
+		SQLITE3_CALL (sqlite3_result_int) (ctx, gda_data_model_iter_get_row (cursor->iter));
 		return SQLITE_OK;
 	}
 
 	param = gda_data_model_iter_get_holder_for_field (cursor->iter, i);
 	if (!param) {
-		sqlite3_result_error (ctx, _("Column not found"), -1);
+		SQLITE3_CALL (sqlite3_result_error) (ctx, _("Column not found"), -1);
 		return SQLITE_EMPTY;
 	}
 	else {
@@ -655,13 +655,13 @@ virtualColumn (sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i)
 		value = gda_holder_get_value (param);
 
 		if (!value || gda_value_is_null (value))
-			sqlite3_result_null (ctx);
+			SQLITE3_CALL (sqlite3_result_null) (ctx);
 		else  if (G_VALUE_TYPE (value) == G_TYPE_INT) 
-			sqlite3_result_int (ctx, g_value_get_int (value));
+			SQLITE3_CALL (sqlite3_result_int) (ctx, g_value_get_int (value));
 		else if (G_VALUE_TYPE (value) == G_TYPE_INT64) 
-			sqlite3_result_int64 (ctx, g_value_get_int64 (value));
+			SQLITE3_CALL (sqlite3_result_int64) (ctx, g_value_get_int64 (value));
 		else if (G_VALUE_TYPE (value) == G_TYPE_DOUBLE) 
-			sqlite3_result_double (ctx, g_value_get_double (value));
+			SQLITE3_CALL (sqlite3_result_double) (ctx, g_value_get_double (value));
 		else if (G_VALUE_TYPE (value) == GDA_TYPE_BLOB) {
 			GdaBlob *blob;
 			GdaBinary *bin;
@@ -670,16 +670,16 @@ virtualColumn (sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i)
 			if (blob->op &&
 			    (bin->binary_length != gda_blob_op_get_length (blob->op)))
 				gda_blob_op_read_all (blob->op, blob);
-			sqlite3_result_blob (ctx, blob->data.data, blob->data.binary_length, SQLITE_TRANSIENT);
+			SQLITE3_CALL (sqlite3_result_blob) (ctx, blob->data.data, blob->data.binary_length, SQLITE_TRANSIENT);
 		}
 		else if (G_VALUE_TYPE (value) == GDA_TYPE_BINARY) {
 			const GdaBinary *bin;
 			bin = gda_value_get_binary (value);
-			sqlite3_result_blob (ctx, bin->data, bin->binary_length, SQLITE_TRANSIENT);
+			SQLITE3_CALL (sqlite3_result_blob) (ctx, bin->data, bin->binary_length, SQLITE_TRANSIENT);
 		}
 		else {
 			gchar *str = gda_value_stringify (value);
-			sqlite3_result_text (ctx, str, -1, SQLITE_TRANSIENT);
+			SQLITE3_CALL (sqlite3_result_text) (ctx, str, -1, SQLITE_TRANSIENT);
 			g_free (str);
 		}
 		return SQLITE_OK;
@@ -750,8 +750,8 @@ virtualUpdate (sqlite3_vtab *tab, int nData, sqlite3_value **apData, sqlite_int6
 
 	if (nData == 1) {
 		/* DELETE */
-		if (sqlite3_value_type (apData[0]) == SQLITE_INTEGER) {
-			gint rowid = sqlite3_value_int (apData [0]);
+		if (SQLITE3_CALL (sqlite3_value_type) (apData[0]) == SQLITE_INTEGER) {
+			gint rowid = SQLITE3_CALL (sqlite3_value_int) (apData [0]);
 			return gda_data_model_remove_row (vtable->wrapper, rowid, NULL) ? SQLITE_OK : SQLITE_READONLY;
 		}
 		else {
@@ -759,12 +759,12 @@ virtualUpdate (sqlite3_vtab *tab, int nData, sqlite3_value **apData, sqlite_int6
 			goto api_misuse;
 		}
 	}
-	else if ((nData > 1) && (sqlite3_value_type (apData[0]) == SQLITE_NULL)) {
+	else if ((nData > 1) && (SQLITE3_CALL (sqlite3_value_type) (apData[0]) == SQLITE_NULL)) {
 		/* INSERT */
 		gint newrow, i;
 		GList *values = NULL;
 		
-		if (sqlite3_value_type (apData[1]) != SQLITE_NULL) {
+		if (SQLITE3_CALL (sqlite3_value_type) (apData[1]) != SQLITE_NULL) {
 			/* argc>1 and argv[0] is not NULL: rowid is imposed by SQLite which is not supported */
 			return SQLITE_READONLY;
 		}
@@ -773,11 +773,11 @@ virtualUpdate (sqlite3_vtab *tab, int nData, sqlite3_value **apData, sqlite_int6
 			GType type;
 			GValue *value;
 			type = gda_column_get_g_type (gda_data_model_describe_column (vtable->wrapper, i - 2));
-			if ((type != GDA_TYPE_NULL) && sqlite3_value_text (apData [i]))
-				value = gda_value_new_from_string ((const gchar*) sqlite3_value_text (apData [i]), type);
+			if ((type != GDA_TYPE_NULL) && SQLITE3_CALL (sqlite3_value_text) (apData [i]))
+				value = gda_value_new_from_string ((const gchar*) SQLITE3_CALL (sqlite3_value_text) (apData [i]), type);
 			else
 				value = gda_value_new_null ();
-			/*g_print ("TXT #%s# => value %p (type=%s) apData[]=%p\n", sqlite3_value_text (apData [i]), value,
+			/*g_print ("TXT #%s# => value %p (type=%s) apData[]=%p\n", SQLITE3_CALL (sqlite3_value_text) (apData [i]), value,
 			  g_type_name (type), apData[i]);*/
 			values = g_list_prepend (values, value);
 		}
@@ -791,24 +791,24 @@ virtualUpdate (sqlite3_vtab *tab, int nData, sqlite3_value **apData, sqlite_int6
 
 		*pRowid = newrow;
 	}
-	else if ((nData > 1) && (sqlite3_value_type (apData[0])==SQLITE_INTEGER)) {
+	else if ((nData > 1) && (SQLITE3_CALL (sqlite3_value_type) (apData[0])==SQLITE_INTEGER)) {
 		/* UPDATE */
 		gint i;
 
-		if (sqlite3_value_int (apData[0]) != sqlite3_value_int (apData[1])) {
+		if (SQLITE3_CALL (sqlite3_value_int) (apData[0]) != SQLITE3_CALL (sqlite3_value_int) (apData[1])) {
 			/* argc>1 and argv[0]==argv[1]: rowid is imposed by SQLite which is not supported */
 			return SQLITE_READONLY;
 		}
 		for (i = 2; i < (nData - 1); i++) {
 			GValue *value;
 			GType type;
-			gint rowid = sqlite3_value_int (apData [0]);
+			gint rowid = SQLITE3_CALL (sqlite3_value_int) (apData [0]);
 			gboolean res;
 			GError *error = NULL;
 
-			/*g_print ("%d => %s\n", i, sqlite3_value_text (apData [i]));*/
+			/*g_print ("%d => %s\n", i, SQLITE3_CALL (sqlite3_value_text) (apData [i]));*/
 			type = gda_column_get_g_type (gda_data_model_describe_column (vtable->wrapper, i - 2));
-			value = gda_value_new_from_string ((const gchar*) sqlite3_value_text (apData [i]), type);
+			value = gda_value_new_from_string ((const gchar*) SQLITE3_CALL (sqlite3_value_text) (apData [i]), type);
 			res = gda_data_model_set_value_at (vtable->wrapper, i - 2, rowid, value, &error);
 			gda_value_free (value);
 			if (!res) {
diff --git a/providers/Makefile.am b/providers/Makefile.am
index 62967c7..b5fce61 100644
--- a/providers/Makefile.am
+++ b/providers/Makefile.am
@@ -2,6 +2,10 @@ if BDB
 GDA_BDB_SERVER=bdb
 endif
 
+if BDBSQL
+GDA_BDBSQL_SERVER=bdbsql
+endif
+
 if IBMDB2
 GDA_IBMDB2_SERVER=ibmdb2
 endif
@@ -63,6 +67,7 @@ SUBDIRS = \
 	sqlite \
 	skel-implementation \
 	$(GDA_BDB_SERVER) \
+	$(GDA_BDBSQL_SERVER) \
 	$(GDA_MDB_SERVER) \
 	$(GDA_POSTGRES_SERVER) \
 	$(GDA_MYSQL_SERVER) \
diff --git a/providers/bdbsql/Makefile.am b/providers/bdbsql/Makefile.am
new file mode 100644
index 0000000..ed07298
--- /dev/null
+++ b/providers/bdbsql/Makefile.am
@@ -0,0 +1,43 @@
+providerdir=$(libdir)/libgda-$(GDA_ABI_MAJOR_VERSION).$(GDA_ABI_MINOR_VERSION)/providers
+provider_LTLIBRARIES = libgda-bdbsql.la
+
+AM_CPPFLAGS = \
+	-I$(top_srcdir) \
+	-I$(top_srcdir)/libgda \
+	-I$(top_srcdir)/libgda/sqlite \
+	-I$(top_builddir) \
+	$(LIBGDA_CFLAGS) \
+	$(BDBSQL_CFLAGS) \
+	$(sqliteinc) 
+
+
+libgda_bdbsql_la_SOURCES = \
+	libmain.c
+
+libgda_bdbsql_la_LDFLAGS = -export-dynamic -module -avoid-version $(NO_UNDEFINED) $(LIBTOOL_PROV_EXPORT_OPTIONS)
+libgda_bdbsql_la_LIBADD = \
+	$(top_builddir)/libgda/sqlite/libgda-bdbsqlite.la
+
+xmldir   = $(datadir)/libgda-4.0
+xml_in_files = \
+	bdbsql_specs_dsn.xml.in \
+	bdbsql_specs_create_db.xml.in \
+	bdbsql_specs_drop_db.xml.in \
+	bdbsql_specs_create_table.xml.in \
+	bdbsql_specs_drop_table.xml.in \
+	bdbsql_specs_create_index.xml.in \
+	bdbsql_specs_drop_index.xml.in \
+	bdbsql_specs_rename_table.xml.in \
+	bdbsql_specs_add_column.xml.in \
+	bdbsql_specs_create_view.xml.in \
+	bdbsql_specs_drop_view.xml.in
+
+ INTLTOOL_XML_RULE@
+
+xml_DATA = $(xml_in_files:.xml.in=.xml)
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = libgda-bdbsql-4.0.pc
+
+EXTRA_DIST = $(xml_in_files) libgda-bdbsql-4.0.pc.in
+DISTCLEANFILES = $(xml_DATA)
diff --git a/providers/bdbsql/bdbsql_specs_add_column.xml.in b/providers/bdbsql/bdbsql_specs_add_column.xml.in
new file mode 120000
index 0000000..a255afa
--- /dev/null
+++ b/providers/bdbsql/bdbsql_specs_add_column.xml.in
@@ -0,0 +1 @@
+../sqlite/sqlite_specs_add_column.xml.in
\ No newline at end of file
diff --git a/providers/bdbsql/bdbsql_specs_create_db.xml.in b/providers/bdbsql/bdbsql_specs_create_db.xml.in
new file mode 120000
index 0000000..c8f1a76
--- /dev/null
+++ b/providers/bdbsql/bdbsql_specs_create_db.xml.in
@@ -0,0 +1 @@
+../sqlite/sqlite_specs_create_db.xml.in
\ No newline at end of file
diff --git a/providers/bdbsql/bdbsql_specs_create_index.xml.in b/providers/bdbsql/bdbsql_specs_create_index.xml.in
new file mode 120000
index 0000000..6c95c53
--- /dev/null
+++ b/providers/bdbsql/bdbsql_specs_create_index.xml.in
@@ -0,0 +1 @@
+../sqlite/sqlite_specs_create_index.xml.in
\ No newline at end of file
diff --git a/providers/bdbsql/bdbsql_specs_create_table.xml.in b/providers/bdbsql/bdbsql_specs_create_table.xml.in
new file mode 120000
index 0000000..3cef9c3
--- /dev/null
+++ b/providers/bdbsql/bdbsql_specs_create_table.xml.in
@@ -0,0 +1 @@
+../sqlite/sqlite_specs_create_table.xml.in
\ No newline at end of file
diff --git a/providers/bdbsql/bdbsql_specs_create_view.xml.in b/providers/bdbsql/bdbsql_specs_create_view.xml.in
new file mode 120000
index 0000000..cdfeefc
--- /dev/null
+++ b/providers/bdbsql/bdbsql_specs_create_view.xml.in
@@ -0,0 +1 @@
+../sqlite/sqlite_specs_create_view.xml.in
\ No newline at end of file
diff --git a/providers/bdbsql/bdbsql_specs_drop_db.xml.in b/providers/bdbsql/bdbsql_specs_drop_db.xml.in
new file mode 120000
index 0000000..3a6f43d
--- /dev/null
+++ b/providers/bdbsql/bdbsql_specs_drop_db.xml.in
@@ -0,0 +1 @@
+../sqlite/sqlite_specs_drop_db.xml.in
\ No newline at end of file
diff --git a/providers/bdbsql/bdbsql_specs_drop_index.xml.in b/providers/bdbsql/bdbsql_specs_drop_index.xml.in
new file mode 120000
index 0000000..2c6daab
--- /dev/null
+++ b/providers/bdbsql/bdbsql_specs_drop_index.xml.in
@@ -0,0 +1 @@
+../sqlite/sqlite_specs_drop_index.xml.in
\ No newline at end of file
diff --git a/providers/bdbsql/bdbsql_specs_drop_table.xml.in b/providers/bdbsql/bdbsql_specs_drop_table.xml.in
new file mode 120000
index 0000000..57b73f4
--- /dev/null
+++ b/providers/bdbsql/bdbsql_specs_drop_table.xml.in
@@ -0,0 +1 @@
+../sqlite/sqlite_specs_drop_table.xml.in
\ No newline at end of file
diff --git a/providers/bdbsql/bdbsql_specs_drop_view.xml.in b/providers/bdbsql/bdbsql_specs_drop_view.xml.in
new file mode 120000
index 0000000..ba154ff
--- /dev/null
+++ b/providers/bdbsql/bdbsql_specs_drop_view.xml.in
@@ -0,0 +1 @@
+../sqlite/sqlite_specs_drop_view.xml.in
\ No newline at end of file
diff --git a/providers/bdbsql/bdbsql_specs_dsn.xml.in b/providers/bdbsql/bdbsql_specs_dsn.xml.in
new file mode 120000
index 0000000..5b59709
--- /dev/null
+++ b/providers/bdbsql/bdbsql_specs_dsn.xml.in
@@ -0,0 +1 @@
+../sqlite/sqlite_specs_dsn.xml.in
\ No newline at end of file
diff --git a/providers/bdbsql/bdbsql_specs_rename_table.xml.in b/providers/bdbsql/bdbsql_specs_rename_table.xml.in
new file mode 120000
index 0000000..63874b7
--- /dev/null
+++ b/providers/bdbsql/bdbsql_specs_rename_table.xml.in
@@ -0,0 +1 @@
+../sqlite/sqlite_specs_rename_table.xml.in
\ No newline at end of file
diff --git a/providers/bdbsql/libgda-bdbsql-4.0.pc.in b/providers/bdbsql/libgda-bdbsql-4.0.pc.in
new file mode 100644
index 0000000..72d2e7c
--- /dev/null
+++ b/providers/bdbsql/libgda-bdbsql-4.0.pc.in
@@ -0,0 +1,9 @@
+prefix= prefix@
+exec_prefix= exec_prefix@
+libdir= libdir@
+includedir= includedir@
+
+Name: libgda-bdbsql- GDA_ABI_MAJOR_VERSION@  GDA_ABI_MINOR_VERSION@
+Description: GDA (GNOME Data Access) BDBSql provider
+Requires: libgda- GDA_ABI_MAJOR_VERSION@  GDA_ABI_MINOR_VERSION@
+Version: @VERSION@
diff --git a/providers/bdbsql/libmain.c b/providers/bdbsql/libmain.c
new file mode 100644
index 0000000..1795ee7
--- /dev/null
+++ b/providers/bdbsql/libmain.c
@@ -0,0 +1,121 @@
+/* GDA Postgres Provider
+ * Copyright (C) 1998 - 2010 The GNOME Foundation
+ *
+ * AUTHORS:
+ *         Vivien Malerba <malerba gnome-db org>
+ *         Rodrigo Moya <rodrigo gnome-db org>
+ *         Gonzalo Paniagua Javier <gonzalo gnome-db org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <glib/gi18n-lib.h>
+#include <gmodule.h>
+#include <libgda/gda-config.h>
+#include "gda-sqlite-provider.h"
+#include <libgda/gda-server-provider-extra.h>
+#include <libgda/binreloc/gda-binreloc.h>
+#include <libgda/sqlite/gda-symbols-util.h>
+
+static gchar      *module_path = NULL;
+const gchar       *plugin_get_name (void);
+const gchar       *plugin_get_description (void);
+gchar             *plugin_get_dsn_spec (void);
+GdaServerProvider *plugin_create_provider (void);
+GModule           *bdbsql_module;
+
+/*
+ * Functions executed when calling g_module_open() and g_module_close()
+ */
+const gchar *
+g_module_check_init (GModule *module)
+{
+	if (! bdbsql_module)
+		bdbsql_module = find_sqlite_library ("libdb_sql-5");
+	if (bdbsql_module)
+		load_symbols (bdbsql_module);
+	if (! s3r)
+		return _("Can't find libdb_sql-5." G_MODULE_SUFFIX " file.");
+
+        /*g_module_make_resident (module);*/
+        return NULL;
+}
+
+void
+g_module_unload (GModule *module)
+{
+	if (bdbsql_module) {
+		if (g_module_close (bdbsql_module))
+			bdbsql_module = NULL;
+	}
+	g_free (s3r);
+	s3r = NULL;
+        g_free (module_path);
+        module_path = NULL;
+}
+
+/*
+ * Normal plugin functions 
+ */
+void
+plugin_init (const gchar *real_path)
+{
+        if (real_path)
+                module_path = g_strdup (real_path);
+}
+
+const gchar *
+plugin_get_name (void)
+{
+	return "BDBSql";
+}
+
+const gchar *
+plugin_get_description (void)
+{
+	return _("Provider for BDB SQL databases");
+}
+
+gchar *
+plugin_get_dsn_spec (void)
+{
+	gchar *ret, *dir;
+
+	dir = gda_gbr_get_file_path (GDA_DATA_DIR, LIBGDA_ABI_NAME, NULL);
+	ret = gda_server_provider_load_file_contents (module_path, dir, "sqlite_specs_dsn.xml");
+	g_free (dir);
+	return ret;
+}
+
+gchar *
+plugin_get_auth_spec (void)
+{
+#define AUTH "<?xml version=\"1.0\"?>" \
+	     "<data-set-spec>" \
+	     "  <parameters/>" \
+	     "</data-set-spec>"
+
+	return g_strdup (AUTH);
+}
+
+GdaServerProvider *
+plugin_create_provider (void)
+{
+	GdaServerProvider *prov;
+
+	prov = (GdaServerProvider*) g_object_new (GDA_TYPE_SQLITE_PROVIDER, NULL);
+        g_object_set_data ((GObject *) prov, "GDA_PROVIDER_DIR", module_path);
+        return prov;
+}
diff --git a/providers/sqlite/Makefile.am b/providers/sqlite/Makefile.am
index e67d78d..ce6fcaf 100644
--- a/providers/sqlite/Makefile.am
+++ b/providers/sqlite/Makefile.am
@@ -15,10 +15,7 @@ libgda_sqlite_la_SOURCES = \
 	libmain.c
 
 libgda_sqlite_la_LDFLAGS = -export-dynamic -module -avoid-version $(NO_UNDEFINED) $(LIBTOOL_PROV_EXPORT_OPTIONS)
-libgda_sqlite_la_LIBADD = \
-	$(top_builddir)/libgda/libgda-4.0.la \
-	$(sqlitelibs) \
-	$(LIBGDA_LIBS)
+libgda_sqlite_la_LIBADD = 
 
 xmldir   = $(datadir)/libgda-4.0
 xml_in_files = \



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