libgda r3173 - in trunk: . doc/C/tmpl libgda libgda-report libgda-report/DocBook libgda-report/RML libgda-report/engine libgda-xslt libgda/handlers libgda/providers-support libgda/sql-parser libgda/sqlite libgda/sqlite/sqlite-src libgda/sqlite/virtual providers/bdb providers/firebird providers/mdb providers/mysql providers/postgres providers/skel-implementation/capi providers/skel-implementation/models samples/BDB



Author: vivien
Date: Sat Jul  5 14:04:20 2008
New Revision: 3173
URL: http://svn.gnome.org/viewvc/libgda?rev=3173&view=rev

Log:
2008-07-05  Vivien Malerba <malerba gnome-db org>

	* configure.in: better detect Berkeley DB in 64 bits environment
	* libgda/gda-meta-store.c: now caches the parsed SQL when using gda_meta_store_extract()
	for better performances
	* libgda/gda-init.c: doc. improvements
	* libgda/gda-data-model-dir.c:
	* libgda/gda-data-model-bdb.c: minor correction when setting properties
	* libgda/gda-data-model-dir.c:
	* libgda/gda-data-model-dsn-list.c: minor correction related to temporary
	GValue
	* libgda-report/engine/gda-report-engine.c:
	* libgda/gda-easy.c: 64 bits type conversion corrected
	* libgda/gda-xa-transaction.c: gda_xa_transaction_id_to_string() now returns a
	new string
	* other files: improvements to make Libgda behave correclty when multiple
	threads are used each object is used by one thread only.
	* libgda-4.0.pc.in: make Libgda depend on the gobject-2.0 module and
	not only on glib-2.0


Modified:
   trunk/ChangeLog
   trunk/configure.in
   trunk/doc/C/tmpl/gda-xa-transaction.sgml
   trunk/libgda-4.0.pc.in
   trunk/libgda-report/DocBook/gda-report-docbook-document.c
   trunk/libgda-report/RML/gda-report-rml-document.c
   trunk/libgda-report/engine/gda-report-engine.c
   trunk/libgda-report/gda-report-document.c
   trunk/libgda-xslt/sqlexslt.c
   trunk/libgda/dir-blob-op.c
   trunk/libgda/gda-batch.c
   trunk/libgda/gda-blob-op.c
   trunk/libgda/gda-column.c
   trunk/libgda/gda-config.c
   trunk/libgda/gda-connection-event.c
   trunk/libgda/gda-connection.c
   trunk/libgda/gda-data-access-wrapper.c
   trunk/libgda/gda-data-comparator.c
   trunk/libgda/gda-data-handler.c
   trunk/libgda/gda-data-model-array.c
   trunk/libgda/gda-data-model-bdb.c
   trunk/libgda/gda-data-model-dir.c
   trunk/libgda/gda-data-model-dsn-list.c
   trunk/libgda/gda-data-model-import.c
   trunk/libgda/gda-data-model-iter.c
   trunk/libgda/gda-data-model-query.c
   trunk/libgda/gda-data-model-row.c
   trunk/libgda/gda-data-model.c
   trunk/libgda/gda-data-proxy.c
   trunk/libgda/gda-easy.c
   trunk/libgda/gda-holder.c
   trunk/libgda/gda-init.c
   trunk/libgda/gda-meta-store.c
   trunk/libgda/gda-meta-struct.c
   trunk/libgda/gda-row.c
   trunk/libgda/gda-server-operation.c
   trunk/libgda/gda-server-provider.c
   trunk/libgda/gda-set.c
   trunk/libgda/gda-statement.c
   trunk/libgda/gda-threader.c
   trunk/libgda/gda-transaction-status.c
   trunk/libgda/gda-xa-transaction.c
   trunk/libgda/gda-xa-transaction.h
   trunk/libgda/handlers/gda-handler-bin.c
   trunk/libgda/handlers/gda-handler-boolean.c
   trunk/libgda/handlers/gda-handler-numerical.c
   trunk/libgda/handlers/gda-handler-string.c
   trunk/libgda/handlers/gda-handler-time.c
   trunk/libgda/handlers/gda-handler-type.c
   trunk/libgda/providers-support/gda-pmodel.c
   trunk/libgda/providers-support/gda-prow.c
   trunk/libgda/providers-support/gda-pstmt.c
   trunk/libgda/sql-parser/gda-sql-parser.c
   trunk/libgda/sql-parser/gda-statement-struct.c
   trunk/libgda/sqlite/gda-sqlite-handler-bin.c
   trunk/libgda/sqlite/gda-sqlite-meta.c
   trunk/libgda/sqlite/gda-sqlite-provider.c
   trunk/libgda/sqlite/gda-sqlite-pstmt.c
   trunk/libgda/sqlite/gda-sqlite-recordset.c
   trunk/libgda/sqlite/sqlite-src/Makefile.am
   trunk/libgda/sqlite/virtual/gda-vconnection-data-model.c
   trunk/libgda/sqlite/virtual/gda-vconnection-hub.c
   trunk/libgda/sqlite/virtual/gda-virtual-connection.c
   trunk/libgda/sqlite/virtual/gda-virtual-provider.c
   trunk/libgda/sqlite/virtual/gda-vprovider-data-model.c
   trunk/libgda/sqlite/virtual/gda-vprovider-hub.c
   trunk/providers/bdb/gda-bdb-provider.c
   trunk/providers/firebird/gda-firebird-blob-op.c
   trunk/providers/firebird/gda-firebird-provider.c
   trunk/providers/firebird/gda-firebird-recordset.c
   trunk/providers/mdb/gda-mdb-provider.c
   trunk/providers/mysql/gda-mysql-blob-op.c
   trunk/providers/mysql/gda-mysql-meta.c
   trunk/providers/mysql/gda-mysql-parser.c
   trunk/providers/mysql/gda-mysql-provider.c
   trunk/providers/mysql/gda-mysql-pstmt.c
   trunk/providers/mysql/gda-mysql-recordset.c
   trunk/providers/postgres/gda-postgres-blob-op.c
   trunk/providers/postgres/gda-postgres-handler-bin.c
   trunk/providers/postgres/gda-postgres-meta.c
   trunk/providers/postgres/gda-postgres-parser.c
   trunk/providers/postgres/gda-postgres-provider.c
   trunk/providers/postgres/gda-postgres-pstmt.c
   trunk/providers/postgres/gda-postgres-recordset.c
   trunk/providers/skel-implementation/capi/gda-capi-blob-op.c
   trunk/providers/skel-implementation/capi/gda-capi-meta.c
   trunk/providers/skel-implementation/capi/gda-capi-parser.c
   trunk/providers/skel-implementation/capi/gda-capi-provider.c
   trunk/providers/skel-implementation/capi/gda-capi-pstmt.c
   trunk/providers/skel-implementation/capi/gda-capi-recordset.c
   trunk/providers/skel-implementation/models/gda-models-provider.c
   trunk/samples/BDB/custom-bdb-model.c

Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in	(original)
+++ trunk/configure.in	Sat Jul  5 14:04:20 2008
@@ -328,6 +328,15 @@
 				BDB_LIBS="-L${bdbdir}/${lib} -ldb"
 				break
 			fi
+			if test $platform_win32 = no -a -f $d/include/db.h -a -f $d/lib/libdb$linklibext
+			then
+				AC_MSG_RESULT(found Berkeley DB in $d)
+				AC_DEFINE(HAVE_BDB, 1, [Have Berkeley DB])
+				bdbdir=$d
+				BDB_CFLAGS="-I${bdbdir}/include"
+				BDB_LIBS="-L${bdbdir}/lib -ldb"
+				break
+			fi
 			dnl FIXME: check for db1 (non-sleepycat implementation)
 		done
 		if test x$bdbdir = x

Modified: trunk/doc/C/tmpl/gda-xa-transaction.sgml
==============================================================================
--- trunk/doc/C/tmpl/gda-xa-transaction.sgml	(original)
+++ trunk/doc/C/tmpl/gda-xa-transaction.sgml	Sat Jul  5 14:04:20 2008
@@ -121,6 +121,16 @@
 @Returns: 
 
 
+<!-- ##### FUNCTION gda_xa_transaction_rollback ##### -->
+<para>
+
+</para>
+
+ xa_trans: 
+ error: 
+ Returns: 
+
+
 <!-- ##### FUNCTION gda_xa_transaction_commit_recovered ##### -->
 <para>
 

Modified: trunk/libgda-4.0.pc.in
==============================================================================
--- trunk/libgda-4.0.pc.in	(original)
+++ trunk/libgda-4.0.pc.in	Sat Jul  5 14:04:20 2008
@@ -5,7 +5,7 @@
 
 Name: libgda- GDA_ABI_MAJOR_VERSION@  GDA_ABI_MINOR_VERSION@
 Description: GDA (GNOME Data Access) library
-Requires: glib-2.0 gthread-2.0 libxml-2.0
+Requires: gobject-2.0 gthread-2.0 libxml-2.0
 Version: @VERSION@
 Libs: -L${libdir} -lgda- GDA_ABI_MAJOR_VERSION@  GDA_ABI_MINOR_VERSION@
 Cflags: -I${includedir}/libgda- GDA_ABI_MAJOR_VERSION@  GDA_ABI_MINOR_VERSION@ @GDA_DEBUG_FLAGS@

Modified: trunk/libgda-report/DocBook/gda-report-docbook-document.c
==============================================================================
--- trunk/libgda-report/DocBook/gda-report-docbook-document.c	(original)
+++ trunk/libgda-report/DocBook/gda-report-docbook-document.c	Sat Jul  5 14:04:20 2008
@@ -137,20 +137,22 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
-		if (type == 0) {
-			static GTypeInfo info = {
-				sizeof (GdaReportDocbookDocumentClass),
-				(GBaseInitFunc) NULL,
-				(GBaseFinalizeFunc) NULL,
-				(GClassInitFunc) gda_report_docbook_document_class_init,
-				NULL, NULL,
-				sizeof (GdaReportDocbookDocument),
-				0,
-				(GInstanceInitFunc) gda_report_docbook_document_init
-			};
-			
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
+		static GTypeInfo info = {
+			sizeof (GdaReportDocbookDocumentClass),
+			(GBaseInitFunc) NULL,
+			(GBaseFinalizeFunc) NULL,
+			(GClassInitFunc) gda_report_docbook_document_class_init,
+			NULL, NULL,
+			sizeof (GdaReportDocbookDocument),
+			0,
+			(GInstanceInitFunc) gda_report_docbook_document_init
+		};
+		
+		g_static_mutex_lock (&registering);
+		if (type == 0)
 			type = g_type_register_static (GDA_TYPE_REPORT_DOCUMENT, "GdaReportDocbookDocument", &info, 0);
-		}
+		g_static_mutex_unlock (&registering);
 	}
 
 	return type;
@@ -256,6 +258,7 @@
 static gboolean
 gda_report_docbook_document_run_as_html (GdaReportDocument *doc, const gchar *filename, GError **error)
 {
+	static GStaticMutex init_mutex = G_STATIC_MUTEX_INIT;
 	static gchar *xsltproc = NULL;
 	GdaReportDocbookDocument *fdoc;
 	gchar **argv;
@@ -266,6 +269,7 @@
 	fdoc = GDA_REPORT_DOCBOOK_DOCUMENT (doc);
 	g_return_val_if_fail (fdoc->priv, FALSE);
 
+	g_static_mutex_lock (&init_mutex);
 	if (!xsltproc) {
 		xsltproc = g_find_program_in_path ("xsltproc");
 		if (!xsltproc) {
@@ -278,6 +282,7 @@
 		if (!xsltproc) {
 			g_set_error (error, 0, 0,
 				     _("Could not find the '%s' program"), "xsltproc");
+			g_static_mutex_unlock (&init_mutex);
 			return FALSE;
 		}
 	}
@@ -292,9 +297,11 @@
 		if (!fdoc->priv->html_stylesheet) {
 			g_set_error (error, 0, 0,
 				     _("Could not find the DocBook XSL stylesheet for HTML"));
+			g_static_mutex_unlock (&init_mutex);
 			return FALSE;
 		}
 	}
+	g_static_mutex_unlock (&init_mutex);
 
 	argv = g_new (gchar *, 9);
 	argv[0] = g_strdup (xsltproc);

Modified: trunk/libgda-report/RML/gda-report-rml-document.c
==============================================================================
--- trunk/libgda-report/RML/gda-report-rml-document.c	(original)
+++ trunk/libgda-report/RML/gda-report-rml-document.c	Sat Jul  5 14:04:20 2008
@@ -110,20 +110,22 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
-		if (type == 0) {
-			static GTypeInfo info = {
-				sizeof (GdaReportRmlDocumentClass),
-				(GBaseInitFunc) NULL,
-				(GBaseFinalizeFunc) NULL,
-				(GClassInitFunc) gda_report_rml_document_class_init,
-				NULL, NULL,
-				sizeof (GdaReportRmlDocument),
-				0,
-				(GInstanceInitFunc) gda_report_rml_document_init
-			};
-			
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
+		static GTypeInfo info = {
+			sizeof (GdaReportRmlDocumentClass),
+			(GBaseInitFunc) NULL,
+			(GBaseFinalizeFunc) NULL,
+			(GClassInitFunc) gda_report_rml_document_class_init,
+			NULL, NULL,
+			sizeof (GdaReportRmlDocument),
+			0,
+			(GInstanceInitFunc) gda_report_rml_document_init
+		};
+		
+		g_static_mutex_lock (&registering);
+		if (type == 0)
 			type = g_type_register_static (GDA_TYPE_REPORT_DOCUMENT, "GdaReportRmlDocument", &info, 0);
-		}
+		g_static_mutex_unlock (&registering);
 	}
 
 	return type;
@@ -185,11 +187,13 @@
 static gboolean
 gda_report_rml_document_run_as_html (GdaReportDocument *doc, const gchar *filename, GError **error)
 {
+	static GStaticMutex init_mutex = G_STATIC_MUTEX_INIT;
 	static gchar *converter = NULL;
 
 	g_return_val_if_fail (GDA_IS_REPORT_RML_DOCUMENT (doc), FALSE);
 	g_return_val_if_fail (filename && *filename, FALSE);
 
+	g_static_mutex_lock (&init_mutex);
 	if (!converter) {
 		converter = g_find_program_in_path ("trml2html.py");
 		if (!converter) {
@@ -202,9 +206,11 @@
 		if (!converter) {
 			g_set_error (error, 0, 0,
 				     _("Could not find the '%s' program"), "trml2html.py");
+			g_static_mutex_unlock (&init_mutex);
 			return FALSE;
 		}
 	}
+	g_static_mutex_unlock (&init_mutex);
 
 	return gda_report_document_run_converter_path (doc, filename, converter, "trml2html", error);
 }
@@ -212,11 +218,13 @@
 static gboolean
 gda_report_rml_document_run_as_pdf (GdaReportDocument *doc, const gchar *filename, GError **error)
 {
+	static GStaticMutex init_mutex = G_STATIC_MUTEX_INIT;
 	static gchar *converter = NULL;
 
 	g_return_val_if_fail (GDA_IS_REPORT_RML_DOCUMENT (doc), FALSE);
 	g_return_val_if_fail (filename && *filename, FALSE);
 
+	g_static_mutex_lock (&init_mutex);
 	if (!converter) {
 		converter = g_find_program_in_path ("trml2pdf.py");
 		if (!converter) {
@@ -229,9 +237,11 @@
 		if (!converter) {
 			g_set_error (error, 0, 0,
 				     _("Could not find the '%s' program"), "trml2pdf.py");
+			g_static_mutex_unlock (&init_mutex);
 			return FALSE;
 		}
 	}
+	g_static_mutex_unlock (&init_mutex);
 
 	return gda_report_document_run_converter_path (doc, filename, converter, "trml2pdf", error);
 }

Modified: trunk/libgda-report/engine/gda-report-engine.c
==============================================================================
--- trunk/libgda-report/engine/gda-report-engine.c	(original)
+++ trunk/libgda-report/engine/gda-report-engine.c	Sat Jul  5 14:04:20 2008
@@ -138,20 +138,22 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
-		if (type == 0) {
-			static GTypeInfo info = {
-				sizeof (GdaReportEngineClass),
-				(GBaseInitFunc) NULL,
-				(GBaseFinalizeFunc) NULL,
-				(GClassInitFunc) gda_report_engine_class_init,
-				NULL, NULL,
-				sizeof (GdaReportEngine),
-				0,
-				(GInstanceInitFunc) gda_report_engine_init
-			};
-			
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
+		static GTypeInfo info = {
+			sizeof (GdaReportEngineClass),
+			(GBaseInitFunc) NULL,
+			(GBaseFinalizeFunc) NULL,
+			(GClassInitFunc) gda_report_engine_class_init,
+			NULL, NULL,
+			sizeof (GdaReportEngine),
+			0,
+			(GInstanceInitFunc) gda_report_engine_init
+		};
+		
+		g_static_mutex_lock (&registering);
+		if (type == 0)
 			type = g_type_register_static (G_TYPE_OBJECT, "GdaReportEngine", &info, 0);
-		}
+		g_static_mutex_unlock (&registering);
 	}
 
 	return type;
@@ -990,19 +992,24 @@
 	GdaDataModel *model;
 	GValue *retval;
 	gchar *sql;
+	static GStaticMutex init_mutex = G_STATIC_MUTEX_INIT;
 	GdaConnection *vcnc = NULL;
 	GdaSqlParser *parser;
 
 	/* create a virtual connection to execute the expression, if it's the first time */
+	g_static_mutex_lock (&init_mutex);
 	if (!vcnc) {
 		static GdaVirtualProvider *provider = NULL;
 
 		if (!provider)
 			provider = gda_vprovider_data_model_new ();
 		vcnc = gda_virtual_connection_open (provider, error);
-		if (! vcnc) 
+		if (! vcnc) {
+			g_static_mutex_unlock (&init_mutex);
 			return NULL;
+		}
 	}
+	g_static_mutex_unlock (&init_mutex);
 
 	/* parser */
 	parser = g_object_get_data (G_OBJECT (context->cnc), "__gda_parser");
@@ -1055,7 +1062,7 @@
 static guint
 gtype_hash (gconstpointer key)
 {
-        return (guint) key;
+        return GPOINTER_TO_UINT (key);
 }
 
 static gboolean

Modified: trunk/libgda-report/gda-report-document.c
==============================================================================
--- trunk/libgda-report/gda-report-document.c	(original)
+++ trunk/libgda-report/gda-report-document.c	Sat Jul  5 14:04:20 2008
@@ -121,20 +121,22 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
-		if (type == 0) {
-			static GTypeInfo info = {
-				sizeof (GdaReportDocumentClass),
-				(GBaseInitFunc) NULL,
-				(GBaseFinalizeFunc) NULL,
-				(GClassInitFunc) gda_report_document_class_init,
-				NULL, NULL,
-				sizeof (GdaReportDocument),
-				0,
-				(GInstanceInitFunc) gda_report_document_init
-			};
-			
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
+		static GTypeInfo info = {
+			sizeof (GdaReportDocumentClass),
+			(GBaseInitFunc) NULL,
+			(GBaseFinalizeFunc) NULL,
+			(GClassInitFunc) gda_report_document_class_init,
+			NULL, NULL,
+			sizeof (GdaReportDocument),
+			0,
+			(GInstanceInitFunc) gda_report_document_init
+		};
+		
+		g_static_mutex_lock (&registering);
+		if (type == 0)
 			type = g_type_register_static (G_TYPE_OBJECT, "GdaReportDocument", &info, G_TYPE_FLAG_ABSTRACT);
-		}
+		g_static_mutex_unlock (&registering);
 	}
 
 	return type;

Modified: trunk/libgda-xslt/sqlexslt.c
==============================================================================
--- trunk/libgda-xslt/sqlexslt.c	(original)
+++ trunk/libgda-xslt/sqlexslt.c	Sat Jul  5 14:04:20 2008
@@ -41,7 +41,10 @@
 void
 gda_xslt_register (void)
 {
+	static GStaticMutex init_mutex = G_STATIC_MUTEX_INIT;
 	static int init = 0;
+
+	g_static_mutex_lock (&init_mutex);
 	if (!init) {
 		int init_res;
 		init = 1;
@@ -54,6 +57,7 @@
 				 init_res);
 		}
 	}
+	g_static_mutex_unlock (&init_mutex);
 }
 
 /**

Modified: trunk/libgda/dir-blob-op.c
==============================================================================
--- trunk/libgda/dir-blob-op.c	(original)
+++ trunk/libgda/dir-blob-op.c	Sat Jul  5 14:04:20 2008
@@ -53,6 +53,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaDirBlobOpClass),
 			(GBaseInitFunc) NULL,
@@ -64,7 +65,10 @@
 			0,
 			(GInstanceInitFunc) gda_dir_blob_op_init
 		};
-		type = g_type_register_static (GDA_TYPE_BLOB_OP, "GdaDirBlobOp", &info, 0);
+		g_static_mutex_lock (&registering);
+		if (type == 0)
+			type = g_type_register_static (GDA_TYPE_BLOB_OP, "GdaDirBlobOp", &info, 0);
+		g_static_mutex_unlock (&registering);
 	}
 	return type;
 }

Modified: trunk/libgda/gda-batch.c
==============================================================================
--- trunk/libgda/gda-batch.c	(original)
+++ trunk/libgda/gda-batch.c	Sat Jul  5 14:04:20 2008
@@ -77,6 +77,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaBatchClass),
 			(GBaseInitFunc) NULL,
@@ -89,7 +90,10 @@
 			(GInstanceInitFunc) gda_batch_init
 		};
 		
-		type = g_type_register_static (G_TYPE_OBJECT, "GdaBatch", &info, 0);
+		g_static_mutex_lock (&registering);
+		if (type == 0)
+			type = g_type_register_static (G_TYPE_OBJECT, "GdaBatch", &info, 0);
+		g_static_mutex_unlock (&registering);
 	}
 	return type;
 }

Modified: trunk/libgda/gda-blob-op.c
==============================================================================
--- trunk/libgda/gda-blob-op.c	(original)
+++ trunk/libgda/gda-blob-op.c	Sat Jul  5 14:04:20 2008
@@ -40,7 +40,8 @@
 {
         static GType type = 0;
 
-        if (G_UNLIKELY (type == 0)) {
+	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
                 static const GTypeInfo info = {
                         sizeof (GdaBlobOpClass),
                         (GBaseInitFunc) NULL,
@@ -53,7 +54,10 @@
                         (GInstanceInitFunc) gda_blob_op_init
                 };
 
-                type = g_type_register_static (PARENT_TYPE, "GdaBlobOp", &info, G_TYPE_FLAG_ABSTRACT);
+		g_static_mutex_lock (&registering);
+		if (type == 0)
+			type = g_type_register_static (PARENT_TYPE, "GdaBlobOp", &info, G_TYPE_FLAG_ABSTRACT);
+		g_static_mutex_unlock (&registering);
         }
         return type;
 }

Modified: trunk/libgda/gda-column.c
==============================================================================
--- trunk/libgda/gda-column.c	(original)
+++ trunk/libgda/gda-column.c	Sat Jul  5 14:04:20 2008
@@ -181,6 +181,7 @@
 	static GType type = 0;
 	
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaColumnClass),
 			(GBaseInitFunc) NULL,
@@ -192,7 +193,10 @@
 			0,
 			(GInstanceInitFunc) gda_column_init
 		};
-		type = g_type_register_static (PARENT_TYPE, "GdaColumn", &info, 0);
+		g_static_mutex_lock (&registering);
+		if (type == 0)
+			type = g_type_register_static (PARENT_TYPE, "GdaColumn", &info, 0);
+		g_static_mutex_unlock (&registering);
 	}
 	
 	return type;

Modified: trunk/libgda/gda-config.c
==============================================================================
--- trunk/libgda/gda-config.c	(original)
+++ trunk/libgda/gda-config.c	Sat Jul  5 14:04:20 2008
@@ -622,7 +622,10 @@
 			0,
 			(GInstanceInitFunc) gda_config_init
 		};
-		type = g_type_register_static (G_TYPE_OBJECT, "GdaConfig", &info, 0);
+		GDA_CONFIG_LOCK ();
+		if (type == 0)
+			type = g_type_register_static (G_TYPE_OBJECT, "GdaConfig", &info, 0);
+		GDA_CONFIG_UNLOCK ();
 	}
 
 	return type;

Modified: trunk/libgda/gda-connection-event.c
==============================================================================
--- trunk/libgda/gda-connection-event.c	(original)
+++ trunk/libgda/gda-connection-event.c	Sat Jul  5 14:04:20 2008
@@ -58,6 +58,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaConnectionEventClass),
 			(GBaseInitFunc) NULL,
@@ -69,7 +70,10 @@
 			0,
 			(GInstanceInitFunc) gda_connection_event_init
 		};
-		type = g_type_register_static (G_TYPE_OBJECT, "GdaConnectionEvent", &info, 0);
+		g_static_mutex_lock (&registering);
+		if (type == 0)
+			type = g_type_register_static (G_TYPE_OBJECT, "GdaConnectionEvent", &info, 0);
+		g_static_mutex_unlock (&registering);
 	}
 
 	return type;

Modified: trunk/libgda/gda-connection.c
==============================================================================
--- trunk/libgda/gda-connection.c	(original)
+++ trunk/libgda/gda-connection.c	Sat Jul  5 14:04:20 2008
@@ -287,6 +287,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static GTypeInfo info = {
 			sizeof (GdaConnectionClass),
 			(GBaseInitFunc) NULL,
@@ -297,7 +298,10 @@
 			0,
 			(GInstanceInitFunc) gda_connection_init
 		};
-		type = g_type_register_static (G_TYPE_OBJECT, "GdaConnection", &info, 0);
+		g_static_mutex_lock (&registering);
+		if (type == 0)
+			type = g_type_register_static (G_TYPE_OBJECT, "GdaConnection", &info, 0);
+		g_static_mutex_unlock (&registering);
 	}
 
 	return type;
@@ -2898,6 +2902,7 @@
 
 		lcontext.size = 0;
 		for (i = 0; i < nb; i++) {
+			/*g_print ("TH %p %s(cnc=>%p store=>%p)\n", g_thread_self(), rmeta [i].func_name, cnc, store);*/
 			if (! rmeta [i].func) 
 				WARN_METHOD_NOT_IMPLEMENTED (provider, rmeta [i].func_name);
 			else {
@@ -3084,6 +3089,7 @@
 {
 	GdaMetaStore *store;
 	GdaDataModel *model = NULL;
+	static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
 	static GHashTable *stmt_hash = NULL;
 	GdaStatement *stmt;
 	GdaSet *set = NULL;
@@ -3099,8 +3105,12 @@
 	MetaKey key;
 	gint i;
 	gchar *fname;
+
+	g_static_mutex_lock (&mutex);
 	if (!stmt_hash)
 		stmt_hash = prepare_meta_statements_hash ();
+	g_static_mutex_unlock (&mutex);
+
 	key.meta_type = meta_type;
 	key.nb_filters = nb_filters;
 	key.filters = NULL;

Modified: trunk/libgda/gda-data-access-wrapper.c
==============================================================================
--- trunk/libgda/gda-data-access-wrapper.c	(original)
+++ trunk/libgda/gda-data-access-wrapper.c	Sat Jul  5 14:04:20 2008
@@ -94,6 +94,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaDataAccessWrapperClass),
 			(GBaseInitFunc) NULL,
@@ -112,8 +113,12 @@
 			NULL
 		};
 
-		type = g_type_register_static (G_TYPE_OBJECT, "GdaDataAccessWrapper", &info, 0);
-		g_type_add_interface_static (type, GDA_TYPE_DATA_MODEL, &data_model_info);
+		g_static_mutex_lock (&registering);
+		if (type == 0) {
+			type = g_type_register_static (G_TYPE_OBJECT, "GdaDataAccessWrapper", &info, 0);
+			g_type_add_interface_static (type, GDA_TYPE_DATA_MODEL, &data_model_info);
+		}
+		g_static_mutex_unlock (&registering);
 	}
 	return type;
 }

Modified: trunk/libgda/gda-data-comparator.c
==============================================================================
--- trunk/libgda/gda-data-comparator.c	(original)
+++ trunk/libgda/gda-data-comparator.c	Sat Jul  5 14:04:20 2008
@@ -88,6 +88,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaDataComparatorClass),
 			(GBaseInitFunc) NULL,
@@ -100,7 +101,10 @@
 			(GInstanceInitFunc) gda_data_comparator_init
 		};
 
-		type = g_type_register_static (G_TYPE_OBJECT, "GdaDataComparator", &info, 0);		
+		g_static_mutex_lock (&registering);
+		if (type == 0)
+			type = g_type_register_static (G_TYPE_OBJECT, "GdaDataComparator", &info, 0);
+		g_static_mutex_unlock (&registering);
 	}
 	return type;
 }

Modified: trunk/libgda/gda-data-handler.c
==============================================================================
--- trunk/libgda/gda-data-handler.c	(original)
+++ trunk/libgda/gda-data-handler.c	Sat Jul  5 14:04:20 2008
@@ -20,6 +20,7 @@
 
 #include "gda-data-handler.h"
 
+static GStaticRecMutex init_mutex = G_STATIC_REC_MUTEX_INIT;
 static void gda_data_handler_iface_init (gpointer g_class);
 
 GType
@@ -40,8 +41,12 @@
 			(GInstanceInitFunc) NULL
 		};
 		
-		type = g_type_register_static (G_TYPE_INTERFACE, "GdaDataHandler", &info, 0);
-                g_type_interface_add_prerequisite (type, G_TYPE_OBJECT);
+		g_static_rec_mutex_lock (&init_mutex);
+		if (type == 0) {
+			type = g_type_register_static (G_TYPE_INTERFACE, "GdaDataHandler", &info, 0);
+			g_type_interface_add_prerequisite (type, G_TYPE_OBJECT);
+		}
+		g_static_rec_mutex_unlock (&init_mutex);
 	}
 	return type;
 }
@@ -52,9 +57,11 @@
 {
 	static gboolean initialized = FALSE;
 
+	g_static_rec_mutex_lock (&init_mutex);
 	if (! initialized) {
 		initialized = TRUE;
 	}
+	g_static_rec_mutex_unlock (&init_mutex);
 }
 
 /**

Modified: trunk/libgda/gda-data-model-array.c
==============================================================================
--- trunk/libgda/gda-data-model-array.c	(original)
+++ trunk/libgda/gda-data-model-array.c	Sat Jul  5 14:04:20 2008
@@ -339,6 +339,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaDataModelArrayClass),
 			(GBaseInitFunc) NULL,
@@ -350,7 +351,10 @@
 			0,
 			(GInstanceInitFunc) gda_data_model_array_init
 		};
-		type = g_type_register_static (PARENT_TYPE, "GdaDataModelArray", &info, 0);
+		g_static_mutex_lock (&registering);
+		if (type == 0)
+			type = g_type_register_static (PARENT_TYPE, "GdaDataModelArray", &info, 0);
+		g_static_mutex_unlock (&registering);
 	}
 	return type;
 }

Modified: trunk/libgda/gda-data-model-bdb.c
==============================================================================
--- trunk/libgda/gda-data-model-bdb.c	(original)
+++ trunk/libgda/gda-data-model-bdb.c	Sat Jul  5 14:04:20 2008
@@ -33,23 +33,24 @@
 #define BDB_VERSION  (10000*DB_VERSION_MAJOR+100*DB_VERSION_MINOR+DB_VERSION_PATCH)
 
 struct _GdaDataModelBdbPrivate {
-	gchar  *filename;
-	gchar  *db_name;
+	gchar    *filename;
+	gchar    *db_name;
+	gboolean  db_name_set;
 
-	DB     *dbp;
-	DBC    *dbpc; /* cursor */
-	int     cursor_pos; /* <0 if @dbpc is invalid */
+	DB       *dbp;
+	DBC      *dbpc; /* cursor */
+	int       cursor_pos; /* <0 if @dbpc is invalid */
 
-	GSList *errors; /* list of errors as GError structures*/
+	GSList   *errors; /* list of errors as GError structures*/
 
-	GSList *columns;
-	gint    n_columns; /* length of @columns */
-	gint    n_rows;
+	GSList   *columns;
+	gint      n_columns; /* length of @columns */
+	gint      n_rows;
 
-	gint    n_key_columns; /* > 0 if custom number of columns */
-	gint    n_data_columns;/* > 0 if custom number of columns */
+	gint      n_key_columns; /* > 0 if custom number of columns */
+	gint      n_data_columns;/* > 0 if custom number of columns */
 
-	GSList *cursor_values; /* list of GValues for the current row */
+	GSList   *cursor_values; /* list of GValues for the current row */
 };
 
 /* properties */
@@ -139,6 +140,7 @@
 	model->priv->n_rows = 0;
 	model->priv->cursor_values = NULL;
 	model->priv->cursor_pos = -1;
+	model->priv->db_name_set = FALSE;
 }
 
 static void
@@ -224,6 +226,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaDataModelBdbClass),
 			(GBaseInitFunc) NULL,
@@ -241,8 +244,12 @@
                         NULL
                 };
 
-		type = g_type_register_static (G_TYPE_OBJECT, "GdaDataModelBdb", &info, 0);
-		g_type_add_interface_static (type, GDA_TYPE_DATA_MODEL, &data_model_info);
+		g_static_mutex_lock (&registering);
+		if (type == 0) {
+			type = g_type_register_static (G_TYPE_OBJECT, "GdaDataModelBdb", &info, 0);
+			g_type_add_interface_static (type, GDA_TYPE_DATA_MODEL, &data_model_info);
+		}
+		g_static_mutex_unlock (&registering);
 	}
 	return type;
 }
@@ -281,7 +288,6 @@
 {
         GdaDataModelBdb *model;
         const gchar *string;
-	static gboolean db_name_set = FALSE, db_file_set = FALSE;
 
         model = GDA_DATA_MODEL_BDB (object);
         if (model->priv) {
@@ -292,10 +298,8 @@
 				model->priv->filename = NULL;
 			}
 			string = g_value_get_string (value);
-			if (string) {
+			if (string) 
 				model->priv->filename = g_strdup (string);
-				db_file_set = TRUE;
-			}
 			break;
                 case PROP_DB_NAME:
 			if (model->priv->db_name) {
@@ -305,12 +309,12 @@
 			string = g_value_get_string (value);
 			if (string) 
 				model->priv->db_name = g_strdup (string);
-			db_name_set = TRUE;
+			model->priv->db_name_set = TRUE;
 			break;
 		}
 	}
 
-	if (db_name_set && db_file_set) {
+	if (model->priv->db_name_set && model->priv->filename) {
 		/* open the DB file */
 		int ret;
 		DBC *dbpc;

Modified: trunk/libgda/gda-data-model-dir.c
==============================================================================
--- trunk/libgda/gda-data-model-dir.c	(original)
+++ trunk/libgda/gda-data-model-dir.c	Sat Jul  5 14:04:20 2008
@@ -54,12 +54,14 @@
 #include "dir-blob-op.h"
 
 struct _GdaDataModelDirPrivate {
-	gchar  *basedir;
-	GSList *errors; /* list of errors as GError structures */
-	GSList *columns; /* list of GdaColumn objects */
+	gchar     *basedir;
+	GSList    *errors; /* list of errors as GError structures */
+	GSList    *columns; /* list of GdaColumn objects */
 
 	GPtrArray *rows; /* array of FileRow pointers */
 	gint       upd_row; /* internal usage when updating contents */
+
+	GValue    *tmp_value; /* GValue returned by gda_data_model_get_value_at() */
 };
 
 /* Row implementation details */
@@ -180,6 +182,7 @@
 	model->priv->basedir = NULL;
 	model->priv->columns = NULL;
 	model->priv->rows = g_ptr_array_new (); /* array of FileRow pointers */
+	model->priv->tmp_value = NULL;
 }
 
 static void
@@ -215,6 +218,11 @@
 	g_return_if_fail (GDA_IS_DATA_MODEL_DIR (model));
 
 	if (model->priv) {
+		if (model->priv->tmp_value) {
+			gda_value_free (model->priv->tmp_value);
+			model->priv->tmp_value = NULL;
+		}
+
 		if (model->priv->basedir) {
 			g_free (model->priv->basedir);
 			model->priv->basedir = NULL;
@@ -259,6 +267,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaDataModelDirClass),
 			(GBaseInitFunc) NULL,
@@ -276,8 +285,12 @@
                         NULL
                 };
 
-		type = g_type_register_static (G_TYPE_OBJECT, "GdaDataModelDir", &info, 0);
-		g_type_add_interface_static (type, GDA_TYPE_DATA_MODEL, &data_model_info);
+		g_static_mutex_lock (&registering);
+		if (type == 0) {
+			type = g_type_register_static (G_TYPE_OBJECT, "GdaDataModelDir", &info, 0);
+			g_type_add_interface_static (type, GDA_TYPE_DATA_MODEL, &data_model_info);
+		}
+		g_static_mutex_unlock (&registering);
 	}
 	return type;
 }
@@ -290,7 +303,6 @@
 {
         GdaDataModelDir *model;
         const gchar *string;
-	static gboolean basedir_set = FALSE;
 
         model = GDA_DATA_MODEL_DIR (object);
         if (model->priv) {
@@ -301,14 +313,12 @@
 				model->priv->basedir = NULL;
 			}
 			string = g_value_get_string (value);
-			if (string) {
+			if (string) 
 				model->priv->basedir = g_strdup (string);
-				basedir_set = TRUE;
-			}
 			break;
 		}
 
-		if (basedir_set) {
+		if (model->priv->basedir) {
 			/* create columns */
 			model->priv->columns = NULL;
 			GdaColumn *column;
@@ -771,7 +781,6 @@
 	GdaDataModelDir *imodel;
 	GValue *value = NULL;
 	FileRow *frow;
-	static GValue *tmp_value = NULL;
 
 	g_return_val_if_fail (GDA_IS_DATA_MODEL_DIR (model), NULL);
 	imodel = GDA_DATA_MODEL_DIR (model);
@@ -797,10 +806,10 @@
 		case COL_DIRNAME: {
 			gchar *tmp;
 			tmp = compute_dirname (imodel, frow);
-			if (!tmp_value)
-				tmp_value = gda_value_new (G_TYPE_STRING);
-			g_value_take_string (tmp_value, tmp);
-			value = tmp_value;
+			if (!imodel->priv->tmp_value)
+				imodel->priv->tmp_value = gda_value_new (G_TYPE_STRING);
+			g_value_take_string (imodel->priv->tmp_value, tmp);
+			value = imodel->priv->tmp_value;
 			break;
 		}
 		case COL_FILENAME:

Modified: trunk/libgda/gda-data-model-dsn-list.c
==============================================================================
--- trunk/libgda/gda-data-model-dsn-list.c	(original)
+++ trunk/libgda/gda-data-model-dsn-list.c	Sat Jul  5 14:04:20 2008
@@ -30,9 +30,10 @@
 #include <libgda/gda-config.h>
 
 struct _GdaDataModelDsnListPrivate {
-	gint nb_dsn;
+	gint    nb_dsn;
 	GSList *columns;
-	gint row_to_remove;
+	gint    row_to_remove;
+	GValue *tmp_value;
 };
 
 static void gda_data_model_dsn_list_class_init (GdaDataModelDsnListClass *klass);
@@ -148,6 +149,8 @@
 			  G_CALLBACK (dsn_removed_cb), model);
 	g_signal_connect (G_OBJECT (config), "dsn_changed",
 			  G_CALLBACK (dsn_changed_cb), model);
+
+	model->priv->tmp_value = NULL;
 }
 
 static void
@@ -177,6 +180,12 @@
 						      G_CALLBACK (dsn_to_be_removed_cb), model);
 		g_signal_handlers_disconnect_by_func (G_OBJECT (config),
 						      G_CALLBACK (dsn_changed_cb), model);
+
+		if (model->priv->tmp_value) {
+			gda_value_free (model->priv->tmp_value);
+			model->priv->tmp_value = NULL;
+		}
+
 		g_free (model->priv);
 		model->priv = NULL;
 	}
@@ -222,6 +231,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaDataModelDsnListClass),
 			(GBaseInitFunc) NULL,
@@ -239,8 +249,12 @@
                         NULL
                 };
 
-		type = g_type_register_static (G_TYPE_OBJECT, "GdaDataModelDsnList", &info, 0);
-		g_type_add_interface_static (type, GDA_TYPE_DATA_MODEL, &data_model_info);
+		g_static_mutex_lock (&registering);
+		if (type == 0) {
+			type = g_type_register_static (G_TYPE_OBJECT, "GdaDataModelDsnList", &info, 0);
+			g_type_add_interface_static (type, GDA_TYPE_DATA_MODEL, &data_model_info);
+		}
+		g_static_mutex_unlock (&registering);
 	}
 
 	return type;
@@ -283,11 +297,11 @@
 static const GValue *
 gda_data_model_dsn_list_get_value_at (GdaDataModel *model, gint col, gint row)
 {
-	static GValue *val = NULL;
+	GdaDataModelDsnList *dmodel = GDA_DATA_MODEL_DSN_LIST (model);
 
-	if (val) {
-		gda_value_free (val);
-		val = NULL;
+	if (dmodel->priv->tmp_value) {
+		gda_value_free (dmodel->priv->tmp_value);
+		dmodel->priv->tmp_value = NULL;
 	}
 		
 	if ((col < gda_data_model_dsn_list_get_n_columns (model)) && 
@@ -295,42 +309,42 @@
 		GdaDataSourceInfo *info = gda_config_get_dsn_at_index (row);
 		g_assert (info);
 		if (col != 5)
-			val = gda_value_new (G_TYPE_STRING);
+			dmodel->priv->tmp_value = gda_value_new (G_TYPE_STRING);
 		else
-			val = gda_value_new (G_TYPE_BOOLEAN);
+			dmodel->priv->tmp_value = gda_value_new (G_TYPE_BOOLEAN);
 		switch (col) {
 		case 0:
-			g_value_set_string (val, info->name);
+			g_value_set_string (dmodel->priv->tmp_value, info->name);
 			break;
 		case 1:
-			g_value_set_string (val, info->provider);
+			g_value_set_string (dmodel->priv->tmp_value, info->provider);
 			break;
 		case 2:
-			g_value_set_string (val, info->description);
+			g_value_set_string (dmodel->priv->tmp_value, info->description);
 			break;
 		case 3:
-			g_value_set_string (val, info->cnc_string);
+			g_value_set_string (dmodel->priv->tmp_value, info->cnc_string);
 			break;
 		case 4: 
 			if (info->auth_string) {
 				GdaQuarkList* ql;
 				ql = gda_quark_list_new_from_string (info->auth_string);
 				
-				g_value_set_string (val, gda_quark_list_find (ql, "USERNAME"));
+				g_value_set_string (dmodel->priv->tmp_value, gda_quark_list_find (ql, "USERNAME"));
 				gda_quark_list_free (ql);
 			}
 			else
-				g_value_set_string (val, "");
+				g_value_set_string (dmodel->priv->tmp_value, "");
 			break;
 		case 5:
-			g_value_set_boolean (val, info->is_system);
+			g_value_set_boolean (dmodel->priv->tmp_value, info->is_system);
 			break;
 		default:
 			g_assert_not_reached ();
 		}
 	}
 	
-	return val;
+	return dmodel->priv->tmp_value;
 }
 
 static GdaValueAttribute

Modified: trunk/libgda/gda-data-model-import.c
==============================================================================
--- trunk/libgda/gda-data-model-import.c	(original)
+++ trunk/libgda/gda-data-model-import.c	Sat Jul  5 14:04:20 2008
@@ -181,6 +181,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaDataModelImportClass),
 			(GBaseInitFunc) NULL,
@@ -199,8 +200,12 @@
 			NULL
 		};
 
-		type = g_type_register_static (G_TYPE_OBJECT, "GdaDataModelImport", &info, 0);
-		g_type_add_interface_static (type, GDA_TYPE_DATA_MODEL, &data_model_info);
+		g_static_mutex_lock (&registering);
+		if (type == 0) {
+			type = g_type_register_static (G_TYPE_OBJECT, "GdaDataModelImport", &info, 0);
+			g_type_add_interface_static (type, GDA_TYPE_DATA_MODEL, &data_model_info);
+		}
+		g_static_mutex_unlock (&registering);
 	}
 	return type;
 }

Modified: trunk/libgda/gda-data-model-iter.c
==============================================================================
--- trunk/libgda/gda-data-model-iter.c	(original)
+++ trunk/libgda/gda-data-model-iter.c	Sat Jul  5 14:04:20 2008
@@ -101,6 +101,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaDataModelIterClass),
 			(GBaseInitFunc) NULL,
@@ -114,7 +115,10 @@
 		};
 
 		
-		type = g_type_register_static (GDA_TYPE_SET, "GdaDataModelIter", &info, 0);
+		g_static_mutex_lock (&registering);
+		if (type == 0)
+			type = g_type_register_static (GDA_TYPE_SET, "GdaDataModelIter", &info, 0);
+		g_static_mutex_unlock (&registering);
 	}
 	return type;
 }

Modified: trunk/libgda/gda-data-model-query.c
==============================================================================
--- trunk/libgda/gda-data-model-query.c	(original)
+++ trunk/libgda/gda-data-model-query.c	Sat Jul  5 14:04:20 2008
@@ -145,6 +145,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaDataModelQueryClass),
 			(GBaseInitFunc) NULL,
@@ -163,8 +164,12 @@
 			NULL
 		};
 
-		type = g_type_register_static (G_TYPE_OBJECT, "GdaDataModelQuery", &info, 0);
-		g_type_add_interface_static (type, GDA_TYPE_DATA_MODEL, &data_model_info);
+		g_static_mutex_lock (&registering);
+		if (type == 0) {
+			type = g_type_register_static (G_TYPE_OBJECT, "GdaDataModelQuery", &info, 0);
+			g_type_add_interface_static (type, GDA_TYPE_DATA_MODEL, &data_model_info);
+		}
+		g_static_mutex_unlock (&registering);
 	}
 	return type;
 }

Modified: trunk/libgda/gda-data-model-row.c
==============================================================================
--- trunk/libgda/gda-data-model-row.c	(original)
+++ trunk/libgda/gda-data-model-row.c	Sat Jul  5 14:04:20 2008
@@ -176,6 +176,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static GTypeInfo info = {
 			sizeof (GdaDataModelRowClass),
 			(GBaseInitFunc) NULL,
@@ -193,8 +194,12 @@
 			NULL
 		};
 		
-		type = g_type_register_static (G_TYPE_OBJECT, "GdaDataModelRow", &info, G_TYPE_FLAG_ABSTRACT);
-		g_type_add_interface_static (type, GDA_TYPE_DATA_MODEL, &data_model_info);
+		g_static_mutex_lock (&registering);
+		if (type == 0) {
+			type = g_type_register_static (G_TYPE_OBJECT, "GdaDataModelRow", &info, G_TYPE_FLAG_ABSTRACT);
+			g_type_add_interface_static (type, GDA_TYPE_DATA_MODEL, &data_model_info);
+		}
+		g_static_mutex_unlock (&registering);
 	}
 
 	return type;

Modified: trunk/libgda/gda-data-model.c
==============================================================================
--- trunk/libgda/gda-data-model.c	(original)
+++ trunk/libgda/gda-data-model.c	Sat Jul  5 14:04:20 2008
@@ -40,6 +40,7 @@
 #endif
 #include "csv.h"
 
+static GStaticRecMutex init_mutex = G_STATIC_REC_MUTEX_INIT;
 static void gda_data_model_class_init (gpointer g_class);
 
 /* signals */
@@ -72,8 +73,12 @@
 			(GInstanceInitFunc) NULL
 		};
 		
-		type = g_type_register_static (G_TYPE_INTERFACE, "GdaDataModel", &info, 0);
-		g_type_interface_add_prerequisite (type, G_TYPE_OBJECT);
+		g_static_rec_mutex_lock (&init_mutex);
+		if (type == 0) {
+			type = g_type_register_static (G_TYPE_INTERFACE, "GdaDataModel", &info, 0);
+			g_type_interface_add_prerequisite (type, G_TYPE_OBJECT);
+		}
+		g_static_rec_mutex_unlock (&init_mutex);
 	}
 	return type;
 }
@@ -83,6 +88,7 @@
 {
 	static gboolean initialized = FALSE;
 
+	g_static_rec_mutex_lock (&init_mutex);
 	if (! initialized) {
 		gda_data_model_signals[CHANGED] =
 			g_signal_new ("changed",
@@ -127,6 +133,7 @@
 
 		initialized = TRUE;
 	}
+	g_static_rec_mutex_unlock (&init_mutex);
 }
 
 static gboolean

Modified: trunk/libgda/gda-data-proxy.c
==============================================================================
--- trunk/libgda/gda-data-proxy.c	(original)
+++ trunk/libgda/gda-data-proxy.c	Sat Jul  5 14:04:20 2008
@@ -86,7 +86,10 @@
 /* get a pointer to the parents to be able to call their destructor */
 static GObjectClass  *parent_class = NULL;
 
+static GStaticMutex parser_mutex = G_STATIC_MUTEX_INIT;
 static GdaSqlParser *internal_parser;
+static GStaticMutex provider_mutex = G_STATIC_MUTEX_INIT;
+static GdaVirtualProvider *virtual_provider = NULL;
 
 /* signals */
 enum
@@ -480,6 +483,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaDataProxyClass),
 			(GBaseInitFunc) NULL,
@@ -498,9 +502,12 @@
 			NULL
 		};
 		
-		type = g_type_register_static (G_TYPE_OBJECT, "GdaDataProxy", &info, 0);
-		g_type_add_interface_static (type, GDA_TYPE_DATA_MODEL, &data_model_info);
-		
+		g_static_mutex_lock (&registering);
+		if (type == 0) {
+			type = g_type_register_static (G_TYPE_OBJECT, "GdaDataProxy", &info, 0);
+			g_type_add_interface_static (type, GDA_TYPE_DATA_MODEL, &data_model_info);
+		}
+		g_static_mutex_unlock (&registering);
 	}
 	return type;
 }
@@ -604,7 +611,9 @@
 					 g_param_spec_int ("sample_size", NULL, NULL, 0, G_MAXINT - 1, 300,
 							   (G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT)));
 
+	g_static_mutex_lock (&parser_mutex);
 	internal_parser = gda_sql_parser_new ();
+	g_static_mutex_unlock (&parser_mutex);
 }
 
 static void
@@ -2789,7 +2798,6 @@
 static gboolean
 apply_filter_statement (GdaDataProxy *proxy, GError **error)
 {
-	static GdaVirtualProvider *provider = NULL;
 	GdaConnection *vcnc;
 	GdaDataModel *filtered_rows = NULL;
 	GdaStatement *stmt = NULL;
@@ -2804,16 +2812,18 @@
 
 	if (!stmt)
 		goto clean_previous_filter;
-
-	if (!provider) 
-		provider = gda_vprovider_data_model_new ();
+	
+	g_static_mutex_lock (&provider_mutex);
+	if (!virtual_provider) 
+		virtual_provider = gda_vprovider_data_model_new ();
+	g_static_mutex_unlock (&provider_mutex);
 
 	/* Force direct data access where proxy_row <=> absolute_row */
 	proxy->priv->force_direct_mapping = TRUE;
 
 	vcnc = proxy->priv->filter_vcnc;
 	if (!vcnc) {
-		vcnc = gda_virtual_connection_open (provider, NULL);
+		vcnc = gda_virtual_connection_open (virtual_provider, NULL);
 		if (! vcnc) {
 			g_set_error (error, GDA_DATA_PROXY_ERROR, GDA_DATA_PROXY_FILTER_ERROR,
 				     _("Could not create virtual connection"));
@@ -2974,7 +2984,9 @@
 		sql = g_strdup_printf (FILTER_SELECT_WHERE "%s", filter_expr);
 	g_free (tmp);
 
+	g_static_mutex_lock (&parser_mutex);
 	stmt = gda_sql_parser_parse_string (internal_parser, sql, &ptr, NULL);
+	g_static_mutex_unlock (&parser_mutex);
 	g_free (sql);
 	if (ptr || !stmt || (gda_statement_get_statement_type (stmt) != GDA_SQL_STATEMENT_SELECT)) {
 		/* also catches problems with multiple statements in @filter_expr, such as SQL code injection */

Modified: trunk/libgda/gda-easy.c
==============================================================================
--- trunk/libgda/gda-easy.c	(original)
+++ trunk/libgda/gda-easy.c	Sat Jul  5 14:04:20 2008
@@ -23,6 +23,7 @@
 #include <sql-parser/gda-sql-parser.h>
 #include <libgda/gda-config.h>
 
+static GStaticMutex parser_mutex = G_STATIC_MUTEX_INIT;
 static GdaSqlParser *internal_parser = NULL;
 
 /* module error */
@@ -188,8 +189,10 @@
 			      || g_str_has_prefix (sql, "SELECT"),
 			      NULL);
     
+	g_static_mutex_lock (&parser_mutex);
 	if (!internal_parser)
 		internal_parser = gda_sql_parser_new ();
+	g_static_mutex_unlock (&parser_mutex);
 
 	stmt = gda_sql_parser_parse_string (internal_parser, sql, NULL, error);
 	if (!stmt) 
@@ -220,8 +223,10 @@
 			      || GDA_IS_CONNECTION (cnc) 
 			      || !gda_connection_is_opened (cnc), -1);
     
+	g_static_mutex_lock (&parser_mutex);
 	if (!internal_parser)
 		internal_parser = gda_sql_parser_new ();
+	g_static_mutex_unlock (&parser_mutex);
 
 	stmt = gda_sql_parser_parse_string (internal_parser, sql, NULL, error);
 	if (!stmt) 
@@ -423,7 +428,7 @@
 static guint
 gtype_hash (gconstpointer key)
 {
-        return (guint) key;
+        return GPOINTER_TO_UINT (key);
 }
 
 static gboolean 
@@ -445,9 +450,11 @@
 GdaDataHandler *
 gda_get_default_handler (GType for_type)
 {
+	static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
 	static GHashTable *hash = NULL;
 	GdaDataHandler *dh;
 
+	g_static_mutex_lock (&mutex);
 	if (!hash) {
 		hash = g_hash_table_new_full (gtype_hash, gtype_equal,
 					      NULL, (GDestroyNotify) g_object_unref);
@@ -472,6 +479,7 @@
                 g_hash_table_insert (hash, (gpointer) G_TYPE_ULONG, gda_handler_type_new ());
                 g_hash_table_insert (hash, (gpointer) G_TYPE_UINT, gda_handler_numerical_new ());
 	}
+	g_static_mutex_unlock (&mutex);
 	
 	dh = g_hash_table_lookup (hash, (gpointer) for_type);
 	return dh;

Modified: trunk/libgda/gda-holder.c
==============================================================================
--- trunk/libgda/gda-holder.c	(original)
+++ trunk/libgda/gda-holder.c	Sat Jul  5 14:04:20 2008
@@ -118,6 +118,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaHolderClass),
 			(GBaseInitFunc) NULL,
@@ -130,7 +131,10 @@
 			(GInstanceInitFunc) gda_holder_init
 		};
 		
-		type = g_type_register_static (G_TYPE_OBJECT, "GdaHolder", &info, 0);
+		g_static_mutex_lock (&registering);
+		if (type == 0)
+			type = g_type_register_static (G_TYPE_OBJECT, "GdaHolder", &info, 0);
+		g_static_mutex_unlock (&registering);
 	}
 
 	return type;
@@ -323,6 +327,8 @@
 gda_holder_new_inline (GType type, const gchar *id, ...)
 {
 	GdaHolder *holder;
+
+	static GStaticMutex serial_mutex = G_STATIC_MUTEX_INIT;
 	static guint serial = 0;
 
 	holder = gda_holder_new (type);
@@ -332,8 +338,11 @@
 
 		if (id)
 			holder->priv->id = g_strdup (id);
-		else
+		else {
+			g_static_mutex_lock (&serial_mutex);
 			holder->priv->id = g_strdup_printf ("%d", serial++);
+			g_static_mutex_unlock (&serial_mutex);
+		}
 
 		va_start (ap, id);
 		value = gda_value_new (type);

Modified: trunk/libgda/gda-init.c
==============================================================================
--- trunk/libgda/gda-init.c	(original)
+++ trunk/libgda/gda-init.c	Sat Jul  5 14:04:20 2008
@@ -34,16 +34,22 @@
 /**
  * gda_init
  * 
- * Initializes the GDA library. Must be called prior to any Libgda usage.
+ * Initializes the GDA library, must be called prior to any Libgda usage. Note that unless the
+ * LIBGDA_NO_THREADS environment variable is set (to any value), the GLib thread system will
+ * be initialized as well if not yet initialized.
  */
 void
 gda_init (void)
 {
+	static GStaticMutex init_mutex = G_STATIC_MUTEX_INIT;
 	static gboolean initialized = FALSE;
+
 	GType type;
 	gchar *file;
 
+	g_static_mutex_lock (&init_mutex);
 	if (initialized) {
+		g_static_mutex_unlock (&init_mutex);
 		gda_log_error (_("Ignoring attempt to re-initialize GDA library."));
 		return;
 	}
@@ -160,4 +166,5 @@
 	g_free (file);
 
 	initialized = TRUE;
+	g_static_mutex_unlock (&init_mutex);
 }

Modified: trunk/libgda/gda-meta-store.c
==============================================================================
--- trunk/libgda/gda-meta-store.c	(original)
+++ trunk/libgda/gda-meta-store.c	Sat Jul  5 14:04:20 2008
@@ -62,6 +62,8 @@
 static gboolean initialize_cnc_struct (GdaMetaStore *store, GError **error);
 static void gda_meta_store_change_free (GdaMetaStoreChange *change);
 
+static GStaticRecMutex init_mutex = G_STATIC_REC_MUTEX_INIT;
+
 /* simple predefined statements */
 enum {
 	STMT_GET_VERSION,
@@ -205,6 +207,10 @@
 	GHashTable    *p_db_objects_hash; /* key = table name, value = a DbObject structure */
 
 	gboolean       override_mode;
+
+	gint           max_extract_stmt; /* 0 => don't keep GdaStatement */
+	gint           current_extract_stmt;
+	GHashTable    *extract_stmt_hash; /* key = a SQL string, value = a #GdaStatement */
 };
 
 static void db_object_free    (DbObject *dbobj);
@@ -212,7 +218,7 @@
 
 
 /* get a pointer to the parents to be able to call their destructor */
-static GObjectClass  *parent_class = NULL;
+static GObjectClass *parent_class = NULL;
 
 /* signals */
 enum {
@@ -241,7 +247,6 @@
 	return quark;
 }
 
-
 GType
 gda_meta_store_get_type (void) {
 	static GType type = 0;
@@ -259,7 +264,10 @@
 			(GInstanceInitFunc) gda_meta_store_init
 		};
 		
-		type = g_type_register_static (G_TYPE_OBJECT, "GdaMetaStore", &info, 0);
+		g_static_rec_mutex_lock (&init_mutex);
+		if (type == 0)
+			type = g_type_register_static (G_TYPE_OBJECT, "GdaMetaStore", &info, 0);
+		g_static_rec_mutex_unlock (&init_mutex);
 	}
 	return type;
 }
@@ -322,7 +330,8 @@
 gda_meta_store_class_init (GdaMetaStoreClass *klass) 
 {
 	GObjectClass *object_class = G_OBJECT_CLASS (klass);
-	
+
+	g_static_rec_mutex_lock (&init_mutex);
 	parent_class = g_type_class_peek_parent (klass);
 	
 	/**
@@ -445,6 +454,8 @@
 	}
 	g_string_free (string, TRUE);
 #endif
+
+	g_static_rec_mutex_unlock (&init_mutex);
 }
 
 
@@ -463,6 +474,10 @@
 	store->priv->p_db_objects_hash = g_hash_table_new (g_str_hash, g_str_equal);
 
 	store->priv->override_mode = FALSE;
+
+	store->priv->max_extract_stmt = 10;
+	store->priv->current_extract_stmt = 0;
+	store->priv->extract_stmt_hash = NULL;
 }
 
 static GObject *
@@ -476,6 +491,7 @@
 	GdaMetaStore *store;
 	gboolean been_specified = FALSE;
 	
+	g_static_rec_mutex_lock (&init_mutex);
 	object = G_OBJECT_CLASS (parent_class)->constructor (type,
 		n_construct_properties,
 		construct_properties);
@@ -494,7 +510,7 @@
 	
 	if (!store->priv->cnc && !been_specified)
 		/* in memory DB */
-		g_object_set (object, "cnc-string", "SQLite://DB_DIR=.;DB_NAME=:memory:", NULL);
+		g_object_set (object, "cnc-string", "SQLite://DB_DIR=.;DB_NAME=__gda_tmp", NULL);
 	
 	if (store->priv->cnc) {
 		store->priv->schema_ok = initialize_cnc_struct (store, &error);
@@ -524,7 +540,8 @@
 		else 
 			create_db_objects (klass, store);
 	}
-	
+	g_static_rec_mutex_unlock (&init_mutex);
+
 	return object;
 }
 
@@ -571,11 +588,13 @@
 {
 	GObject *obj;
 	GdaMetaStore *store;
-	
+
+	g_static_rec_mutex_lock (&init_mutex);
 	if (string)
 		obj = g_object_new (GDA_TYPE_META_STORE, "cnc-string", string, NULL);
 	else
-		obj = g_object_new (GDA_TYPE_META_STORE, "cnc-string", "SQLite://DB_NAME=:memory:", NULL);
+		obj = g_object_new (GDA_TYPE_META_STORE, "cnc-string", "SQLite://DB_NAME=__gda_tmp", NULL);
+	g_static_rec_mutex_unlock (&init_mutex);
 	store = GDA_META_STORE (obj);
 	if (!store->priv->cnc) {
 		g_object_unref (store);
@@ -596,6 +615,11 @@
 	if (store->priv) {
 		GSList *list;
 
+		if (store->priv->extract_stmt_hash) {
+			g_hash_table_destroy (store->priv->extract_stmt_hash);
+			store->priv->extract_stmt_hash = NULL;
+		}
+
 		if (store->priv->override_mode) 
 			_gda_meta_store_cancel_data_reset (store, NULL);
 
@@ -1917,25 +1941,40 @@
 GdaDataModel *
 gda_meta_store_extract (GdaMetaStore *store, const gchar *select_sql, GError **error, ...)
 {
-	GdaMetaStoreClass *klass;
-	GdaStatement *stmt;
-	const gchar *remain;
+	GdaStatement *stmt = NULL;
 	GdaDataModel *model;
 	GdaSet *params = NULL;
 
 	g_return_val_if_fail (GDA_IS_META_STORE (store), NULL);
 	g_return_val_if_fail (store->priv, NULL);
 
+	if ((store->priv->max_extract_stmt > 0) && !store->priv->extract_stmt_hash)
+		store->priv->extract_stmt_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
+
 	/* statement creation */
-	klass = (GdaMetaStoreClass *) G_OBJECT_GET_CLASS (store);
-	stmt = gda_sql_parser_parse_string (klass->cpriv->parser, select_sql, &remain, error);
-	if (!stmt)
-		return NULL;
-	if (remain) {
-		g_set_error (error, GDA_META_STORE_ERROR, GDA_META_STORE_EXTRACT_SQL_ERROR,
-			     _("More than one SQL statement"));
-		g_object_unref (stmt);
-		return NULL;
+	if (store->priv->extract_stmt_hash)
+		stmt = g_hash_table_lookup (store->priv->extract_stmt_hash, select_sql);
+	if (stmt) 
+		g_object_ref (stmt);
+	else {
+		GdaMetaStoreClass *klass;
+		const gchar *remain;
+
+		klass = (GdaMetaStoreClass *) G_OBJECT_GET_CLASS (store);
+		stmt = gda_sql_parser_parse_string (klass->cpriv->parser, select_sql, &remain, error);
+		if (!stmt)
+			return NULL;
+		if (remain) {
+			g_set_error (error, GDA_META_STORE_ERROR, GDA_META_STORE_EXTRACT_SQL_ERROR,
+				     _("More than one SQL statement"));
+			g_object_unref (stmt);
+			return NULL;
+		}
+
+		if (store->priv->current_extract_stmt < store->priv->max_extract_stmt) {
+			g_hash_table_insert (store->priv->extract_stmt_hash, g_strdup (select_sql), g_object_ref (stmt));
+			store->priv->current_extract_stmt++;
+		}
 	}
 	
 	/* parameters */
@@ -2872,7 +2911,7 @@
  * @error: a place to store errors, or %NULL
  *
  * The #GdaMetaStore object maintains a list of (name,value) attributes (attributes names starting with a '_'
- * character are for intarnal use only and cannot be altered). This method and the gda_meta_store_set_attribute_value()
+ * character are for internal use only and cannot be altered). This method and the gda_meta_store_set_attribute_value()
  * method allows the user to add, set or remove attributes specific to their usage.
  * 
  * This method allows to get the value of a attribute stored in @store. The returned attribute value is 
@@ -2938,6 +2977,7 @@
 				    const gchar *att_value, GError **error)
 {
 	GdaMetaStoreClass *klass;
+	static GStaticMutex set_mutex = G_STATIC_MUTEX_INIT;
 	static GdaSet *set = NULL;
 	gboolean started_transaction = FALSE;
 
@@ -2951,10 +2991,14 @@
 	}
 
 	klass = (GdaMetaStoreClass *) G_OBJECT_GET_CLASS (store);
+	g_static_mutex_lock (&set_mutex);
 	if (!set) {
-		if (!gda_statement_get_parameters (klass->cpriv->prep_stmts [STMT_SET_ATT_VALUE], &set, error))
+		if (!gda_statement_get_parameters (klass->cpriv->prep_stmts [STMT_SET_ATT_VALUE], &set, error)) {
+			g_static_mutex_unlock (&set_mutex);
 			return FALSE;
+		}
 	}
+	g_static_mutex_unlock (&set_mutex);
 
 	if (!gda_set_set_holder_value (set, "name", att_name)) {
 		g_set_error (error, GDA_META_STORE_ERROR, GDA_META_STORE_ATTRIBUTE_ERROR,

Modified: trunk/libgda/gda-meta-struct.c
==============================================================================
--- trunk/libgda/gda-meta-struct.c	(original)
+++ trunk/libgda/gda-meta-struct.c	Sat Jul  5 14:04:20 2008
@@ -87,6 +87,7 @@
 	static GType type = 0;
 	
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaMetaStructClass),
 			(GBaseInitFunc) NULL,
@@ -99,7 +100,10 @@
 			(GInstanceInitFunc) gda_meta_struct_init
 		};
 		
-		type = g_type_register_static (G_TYPE_OBJECT, "GdaMetaStruct", &info, 0);
+		g_static_mutex_lock (&registering);
+		if (type == 0)
+			type = g_type_register_static (G_TYPE_OBJECT, "GdaMetaStruct", &info, 0);
+		g_static_mutex_unlock (&registering);
 	}
 	return type;
 }

Modified: trunk/libgda/gda-row.c
==============================================================================
--- trunk/libgda/gda-row.c	(original)
+++ trunk/libgda/gda-row.c	Sat Jul  5 14:04:20 2008
@@ -256,6 +256,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaRowClass),
 			(GBaseInitFunc) NULL,
@@ -267,7 +268,10 @@
 			0,
 			(GInstanceInitFunc) gda_row_init
 		};
-		type = g_type_register_static (PARENT_TYPE, "GdaRow", &info, 0);
+		g_static_mutex_lock (&registering);
+		if (type == 0)
+			type = g_type_register_static (PARENT_TYPE, "GdaRow", &info, 0);
+		g_static_mutex_unlock (&registering);
 	}
 
 	return type;

Modified: trunk/libgda/gda-server-operation.c
==============================================================================
--- trunk/libgda/gda-server-operation.c	(original)
+++ trunk/libgda/gda-server-operation.c	Sat Jul  5 14:04:20 2008
@@ -38,7 +38,6 @@
 #endif
 #include <glib/gi18n-lib.h>
 
-#define PARENT_TYPE G_TYPE_OBJECT
 #define CLASS(operation) (GDA_SERVER_OPERATION_CLASS (G_OBJECT_GET_CLASS (operation)))
 
 static void gda_server_operation_class_init (GdaServerOperationClass *klass);
@@ -243,6 +242,8 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
+
 		static const GTypeInfo info = {
 			sizeof (GdaServerOperationClass),
 			(GBaseInitFunc) NULL,
@@ -255,7 +256,10 @@
 			(GInstanceInitFunc) gda_server_operation_init
 		};
 
-		type = g_type_register_static (PARENT_TYPE, "GdaServerOperation", &info, 0);
+		g_static_mutex_lock (&registering);
+		if (!type)
+			type = g_type_register_static (G_TYPE_OBJECT, "GdaServerOperation", &info, 0);
+		g_static_mutex_unlock (&registering);
 	}
 	return type;
 }

Modified: trunk/libgda/gda-server-provider.c
==============================================================================
--- trunk/libgda/gda-server-provider.c	(original)
+++ trunk/libgda/gda-server-provider.c	Sat Jul  5 14:04:20 2008
@@ -192,6 +192,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaServerProviderClass),
 			(GBaseInitFunc) NULL,
@@ -203,7 +204,10 @@
 			0,
 			(GInstanceInitFunc) gda_server_provider_init
 		};
-		type = g_type_register_static (PARENT_TYPE, "GdaServerProvider", &info, G_TYPE_FLAG_ABSTRACT);
+		g_static_mutex_lock (&registering);
+		if (type == 0)
+			type = g_type_register_static (PARENT_TYPE, "GdaServerProvider", &info, G_TYPE_FLAG_ABSTRACT);
+		g_static_mutex_unlock (&registering);
 	}
 
 	return type;
@@ -417,8 +421,10 @@
 				      GdaServerOperationType type, 
 				      GdaSet *options, GError **error)
 {
+	static GStaticMutex init_mutex = G_STATIC_MUTEX_INIT;
 	static OpReq **op_req_table = NULL;
 
+	g_static_mutex_lock (&init_mutex);
 	if (! op_req_table) {
 		op_req_table = g_new0 (OpReq *, GDA_SERVER_OPERATION_LAST);
 
@@ -438,6 +444,7 @@
 		op_req_table [GDA_SERVER_OPERATION_CREATE_VIEW] = op_req_CREATE_VIEW;
 		op_req_table [GDA_SERVER_OPERATION_DROP_VIEW] = op_req_DROP_VIEW;
 	}
+	g_static_mutex_unlock (&init_mutex);
 
 	g_return_val_if_fail (GDA_IS_SERVER_PROVIDER (provider), NULL);
 

Modified: trunk/libgda/gda-set.c
==============================================================================
--- trunk/libgda/gda-set.c	(original)
+++ trunk/libgda/gda-set.c	Sat Jul  5 14:04:20 2008
@@ -171,6 +171,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaSetClass),
 			(GBaseInitFunc) NULL,
@@ -183,7 +184,10 @@
 			(GInstanceInitFunc) gda_set_init
 		};
 		
-		type = g_type_register_static (G_TYPE_OBJECT, "GdaSet", &info, 0);
+		g_static_mutex_lock (&registering);
+		if (type == 0)
+			type = g_type_register_static (G_TYPE_OBJECT, "GdaSet", &info, 0);
+		g_static_mutex_unlock (&registering);
 	}
 
 	return type;

Modified: trunk/libgda/gda-statement.c
==============================================================================
--- trunk/libgda/gda-statement.c	(original)
+++ trunk/libgda/gda-statement.c	Sat Jul  5 14:04:20 2008
@@ -97,6 +97,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaStatementClass),
 			(GBaseInitFunc) NULL,
@@ -109,7 +110,10 @@
 			(GInstanceInitFunc) gda_statement_init
 		};
 		
-		type = g_type_register_static (G_TYPE_OBJECT, "GdaStatement", &info, 0);
+		g_static_mutex_lock (&registering);
+		if (type == 0)
+			type = g_type_register_static (G_TYPE_OBJECT, "GdaStatement", &info, 0);
+		g_static_mutex_unlock (&registering);
 	}
 	return type;
 }

Modified: trunk/libgda/gda-threader.c
==============================================================================
--- trunk/libgda/gda-threader.c	(original)
+++ trunk/libgda/gda-threader.c	Sat Jul  5 14:04:20 2008
@@ -71,6 +71,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaThreaderClass),
 			(GBaseInitFunc) NULL,
@@ -83,7 +84,10 @@
 			(GInstanceInitFunc) gda_threader_init
 		};
 		
-		type = g_type_register_static (G_TYPE_OBJECT, "GdaThreader", &info, 0);
+		g_static_mutex_lock (&registering);
+		if (type == 0)
+			type = g_type_register_static (G_TYPE_OBJECT, "GdaThreader", &info, 0);
+		g_static_mutex_unlock (&registering);
 	}
 
 	return type;

Modified: trunk/libgda/gda-transaction-status.c
==============================================================================
--- trunk/libgda/gda-transaction-status.c	(original)
+++ trunk/libgda/gda-transaction-status.c	Sat Jul  5 14:04:20 2008
@@ -109,19 +109,21 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
-		if (type == 0) {
-			static GTypeInfo info = {
-				sizeof (GdaTransactionStatusClass),
-				(GBaseInitFunc) NULL,
-				(GBaseFinalizeFunc) NULL,
-				(GClassInitFunc) gda_transaction_status_class_init,
-				NULL, NULL,
-				sizeof (GdaTransactionStatus),
-				0,
-				(GInstanceInitFunc) gda_transaction_status_init
-			};
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
+		static GTypeInfo info = {
+			sizeof (GdaTransactionStatusClass),
+			(GBaseInitFunc) NULL,
+			(GBaseFinalizeFunc) NULL,
+			(GClassInitFunc) gda_transaction_status_class_init,
+			NULL, NULL,
+			sizeof (GdaTransactionStatus),
+			0,
+			(GInstanceInitFunc) gda_transaction_status_init
+		};
+		g_static_mutex_lock (&registering);
+		if (type == 0)
 			type = g_type_register_static (PARENT_TYPE, "GdaTransactionStatus", &info, 0);
-		}
+		g_static_mutex_unlock (&registering);
 	}
 
 	return type;

Modified: trunk/libgda/gda-xa-transaction.c
==============================================================================
--- trunk/libgda/gda-xa-transaction.c	(original)
+++ trunk/libgda/gda-xa-transaction.c	Sat Jul  5 14:04:20 2008
@@ -216,19 +216,21 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
-		if (type == 0) {
-			static GTypeInfo info = {
-				sizeof (GdaXaTransactionClass),
-				(GBaseInitFunc) NULL,
-				(GBaseFinalizeFunc) NULL,
-				(GClassInitFunc) gda_xa_transaction_class_init,
-				NULL, NULL,
-				sizeof (GdaXaTransaction),
-				0,
-				(GInstanceInitFunc) gda_xa_transaction_init
-			};
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
+		static GTypeInfo info = {
+			sizeof (GdaXaTransactionClass),
+			(GBaseInitFunc) NULL,
+			(GBaseFinalizeFunc) NULL,
+			(GClassInitFunc) gda_xa_transaction_class_init,
+			NULL, NULL,
+			sizeof (GdaXaTransaction),
+			0,
+			(GInstanceInitFunc) gda_xa_transaction_init
+		};
+		g_static_mutex_lock (&registering);
+		if (type == 0)
 			type = g_type_register_static (G_TYPE_OBJECT, "GdaXaTransaction", &info, 0);
-		}
+		g_static_mutex_unlock (&registering);
 	}
 
 	return type;
@@ -702,19 +704,17 @@
  * &lt;gtrid&gt; and &lt;bqual&gt; strings contain alphanumeric characters, and non alphanumeric characters
  * are converted to "%ab" where ab is the hexadecimal representation of the character.
  *
- * Returns: a read-only string representation of @xid
+ * Returns: a new string representation of @xid
  */
-const gchar *
+gchar *
 gda_xa_transaction_id_to_string (const GdaXaTransactionId *xid)
 {
 #define XID_SIZE (128 * 3 +15)
-	static gchar str[XID_SIZE];
+	gchar *str = g_new0 (gchar, XID_SIZE);
 	int index = 0, i;
 	
 	g_return_val_if_fail (xid, NULL);
 
-	memset (str, 0, XID_SIZE);
-	
 	/* global transaction ID */
 	for (i = 0; i < xid->gtrid_length; i++) {
 		if (g_ascii_isalnum (xid->data[i])) {

Modified: trunk/libgda/gda-xa-transaction.h
==============================================================================
--- trunk/libgda/gda-xa-transaction.h	(original)
+++ trunk/libgda/gda-xa-transaction.h	Sat Jul  5 14:04:20 2008
@@ -74,13 +74,14 @@
 void                      gda_xa_transaction_unregister_connection (GdaXaTransaction *xa_trans, GdaConnection *cnc);
 
 gboolean                  gda_xa_transaction_begin  (GdaXaTransaction *xa_trans, GError **error);
-gboolean                  gda_xa_transaction_commit (GdaXaTransaction *xa_trans, GSList **cnc_to_recover, GError **error);gboolean                  gda_xa_transaction_rollback (GdaXaTransaction *xa_trans, GError **error);
+gboolean                  gda_xa_transaction_commit (GdaXaTransaction *xa_trans, GSList **cnc_to_recover, GError **error);
+gboolean                  gda_xa_transaction_rollback (GdaXaTransaction *xa_trans, GError **error);
 
 gboolean                  gda_xa_transaction_commit_recovered (GdaXaTransaction *xa_trans, GSList **cnc_to_recover, 
 							       GError **error);
 
 /* utility functions */
-const gchar              *gda_xa_transaction_id_to_string (const GdaXaTransactionId *xid);
+gchar                    *gda_xa_transaction_id_to_string (const GdaXaTransactionId *xid);
 GdaXaTransactionId       *gda_xa_transaction_string_to_id (const gchar *str);
 
 G_END_DECLS

Modified: trunk/libgda/handlers/gda-handler-bin.c
==============================================================================
--- trunk/libgda/handlers/gda-handler-bin.c	(original)
+++ trunk/libgda/handlers/gda-handler-bin.c	Sat Jul  5 14:04:20 2008
@@ -59,6 +59,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaHandlerBinClass),
 			(GBaseInitFunc) NULL,
@@ -77,8 +78,12 @@
 			NULL
 		};
 
-		type = g_type_register_static (G_TYPE_OBJECT, "GdaHandlerBin", &info, 0);
-		g_type_add_interface_static (type, GDA_TYPE_DATA_HANDLER, &data_entry_info);
+		g_static_mutex_lock (&registering);
+		if (type == 0) {
+			type = g_type_register_static (G_TYPE_OBJECT, "GdaHandlerBin", &info, 0);
+			g_type_add_interface_static (type, GDA_TYPE_DATA_HANDLER, &data_entry_info);
+		}
+		g_static_mutex_unlock (&registering);
 	}
 	return type;
 }

Modified: trunk/libgda/handlers/gda-handler-boolean.c
==============================================================================
--- trunk/libgda/handlers/gda-handler-boolean.c	(original)
+++ trunk/libgda/handlers/gda-handler-boolean.c	Sat Jul  5 14:04:20 2008
@@ -59,6 +59,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaHandlerBooleanClass),
 			(GBaseInitFunc) NULL,
@@ -77,8 +78,12 @@
 			NULL
 		};
 
-		type = g_type_register_static (G_TYPE_OBJECT, "GdaHandlerBoolean", &info, 0);
-		g_type_add_interface_static (type, GDA_TYPE_DATA_HANDLER, &data_entry_info);
+		g_static_mutex_lock (&registering);
+		if (type == 0) {
+			type = g_type_register_static (G_TYPE_OBJECT, "GdaHandlerBoolean", &info, 0);
+			g_type_add_interface_static (type, GDA_TYPE_DATA_HANDLER, &data_entry_info);
+		}
+		g_static_mutex_unlock (&registering);
 	}
 	return type;
 }

Modified: trunk/libgda/handlers/gda-handler-numerical.c
==============================================================================
--- trunk/libgda/handlers/gda-handler-numerical.c	(original)
+++ trunk/libgda/handlers/gda-handler-numerical.c	Sat Jul  5 14:04:20 2008
@@ -58,6 +58,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaHandlerNumericalClass),
 			(GBaseInitFunc) NULL,
@@ -76,8 +77,12 @@
 			NULL
 		};
 
-		type = g_type_register_static (G_TYPE_OBJECT, "GdaHandlerNumerical", &info, 0);
-		g_type_add_interface_static (type, GDA_TYPE_DATA_HANDLER, &data_entry_info);
+		g_static_mutex_lock (&registering);
+		if (type == 0) {
+			type = g_type_register_static (G_TYPE_OBJECT, "GdaHandlerNumerical", &info, 0);
+			g_type_add_interface_static (type, GDA_TYPE_DATA_HANDLER, &data_entry_info);
+		}
+		g_static_mutex_unlock (&registering);
 	}
 	return type;
 }

Modified: trunk/libgda/handlers/gda-handler-string.c
==============================================================================
--- trunk/libgda/handlers/gda-handler-string.c	(original)
+++ trunk/libgda/handlers/gda-handler-string.c	Sat Jul  5 14:04:20 2008
@@ -63,6 +63,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaHandlerStringClass),
 			(GBaseInitFunc) NULL,
@@ -81,8 +82,12 @@
 			NULL
 		};
 
-		type = g_type_register_static (G_TYPE_OBJECT, "GdaHandlerString", &info, 0);
-		g_type_add_interface_static (type, GDA_TYPE_DATA_HANDLER, &data_entry_info);
+		g_static_mutex_lock (&registering);
+		if (type == 0) {
+			type = g_type_register_static (G_TYPE_OBJECT, "GdaHandlerString", &info, 0);
+			g_type_add_interface_static (type, GDA_TYPE_DATA_HANDLER, &data_entry_info);
+		}
+		g_static_mutex_unlock (&registering);
 	}
 	return type;
 }

Modified: trunk/libgda/handlers/gda-handler-time.c
==============================================================================
--- trunk/libgda/handlers/gda-handler-time.c	(original)
+++ trunk/libgda/handlers/gda-handler-time.c	Sat Jul  5 14:04:20 2008
@@ -85,6 +85,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaHandlerTimeClass),
 			(GBaseInitFunc) NULL,
@@ -103,8 +104,12 @@
 			NULL
 		};
 
-		type = g_type_register_static (G_TYPE_OBJECT, "GdaHandlerTime", &info, 0);
-		g_type_add_interface_static (type, GDA_TYPE_DATA_HANDLER, &data_entry_info);
+		g_static_mutex_lock (&registering);
+		if (type == 0) {
+			type = g_type_register_static (G_TYPE_OBJECT, "GdaHandlerTime", &info, 0);
+			g_type_add_interface_static (type, GDA_TYPE_DATA_HANDLER, &data_entry_info);
+		}
+		g_static_mutex_unlock (&registering);
 	}
 	return type;
 }

Modified: trunk/libgda/handlers/gda-handler-type.c
==============================================================================
--- trunk/libgda/handlers/gda-handler-type.c	(original)
+++ trunk/libgda/handlers/gda-handler-type.c	Sat Jul  5 14:04:20 2008
@@ -57,6 +57,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaHandlerTypeClass),
 			(GBaseInitFunc) NULL,
@@ -75,8 +76,12 @@
 			NULL
 		};
 
-		type = g_type_register_static (G_TYPE_OBJECT, "GdaHandlerType", &info, 0);
-		g_type_add_interface_static (type, GDA_TYPE_DATA_HANDLER, &data_entry_info);
+		g_static_mutex_lock (&registering);
+		if (type == 0) {
+			type = g_type_register_static (G_TYPE_OBJECT, "GdaHandlerType", &info, 0);
+			g_type_add_interface_static (type, GDA_TYPE_DATA_HANDLER, &data_entry_info);
+		}
+		g_static_mutex_unlock (&registering);
 	}
 	return type;
 }

Modified: trunk/libgda/providers-support/gda-pmodel.c
==============================================================================
--- trunk/libgda/providers-support/gda-pmodel.c	(original)
+++ trunk/libgda/providers-support/gda-pmodel.c	Sat Jul  5 14:04:20 2008
@@ -115,6 +115,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaPModelClass),
 			(GBaseInitFunc) NULL,
@@ -133,8 +134,12 @@
 			NULL
 		};
 
-		type = g_type_register_static (G_TYPE_OBJECT, "GdaPModel", &info, 0);
-		g_type_add_interface_static (type, GDA_TYPE_DATA_MODEL, &data_model_info);
+		g_static_mutex_lock (&registering);
+		if (type == 0) {
+			type = g_type_register_static (G_TYPE_OBJECT, "GdaPModel", &info, 0);
+			g_type_add_interface_static (type, GDA_TYPE_DATA_MODEL, &data_model_info);
+		}
+		g_static_mutex_unlock (&registering);
 	}
 	return type;
 }

Modified: trunk/libgda/providers-support/gda-prow.c
==============================================================================
--- trunk/libgda/providers-support/gda-prow.c	(original)
+++ trunk/libgda/providers-support/gda-prow.c	Sat Jul  5 14:04:20 2008
@@ -171,6 +171,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaPRowClass),
 			(GBaseInitFunc) NULL,
@@ -182,7 +183,10 @@
 			0,
 			(GInstanceInitFunc) gda_prow_init
 		};
-		type = g_type_register_static (PARENT_TYPE, "GdaPRow", &info, 0);
+		g_static_mutex_lock (&registering);
+		if (type == 0)
+			type = g_type_register_static (PARENT_TYPE, "GdaPRow", &info, 0);
+		g_static_mutex_unlock (&registering);
 	}
 
 	return type;

Modified: trunk/libgda/providers-support/gda-pstmt.c
==============================================================================
--- trunk/libgda/providers-support/gda-pstmt.c	(original)
+++ trunk/libgda/providers-support/gda-pstmt.c	Sat Jul  5 14:04:20 2008
@@ -43,6 +43,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaPStmtClass),
 			(GBaseInitFunc) NULL,
@@ -55,7 +56,10 @@
 			(GInstanceInitFunc) gda_pstmt_init
 		};
 
-		type = g_type_register_static (G_TYPE_OBJECT, "GdaPStmt", &info, 0);
+		g_static_mutex_lock (&registering);
+		if (type == 0)
+			type = g_type_register_static (G_TYPE_OBJECT, "GdaPStmt", &info, 0);
+		g_static_mutex_unlock (&registering);
 	}
 	return type;
 }

Modified: trunk/libgda/sql-parser/gda-sql-parser.c
==============================================================================
--- trunk/libgda/sql-parser/gda-sql-parser.c	(original)
+++ trunk/libgda/sql-parser/gda-sql-parser.c	Sat Jul  5 14:04:20 2008
@@ -47,6 +47,8 @@
 					GParamSpec *pspec);
 /* get a pointer to the parents to be able to call their destructor */
 static GObjectClass  *parent_class = NULL;
+static GStaticRecMutex usage_mutex = G_STATIC_REC_MUTEX_INIT;
+
 
 static void gda_sql_parser_reset (GdaSqlParser *parser);
 static GValue *tokenizer_get_next_token (GdaSqlParser *parser); 
@@ -106,6 +108,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaSqlParserClass),
 			(GBaseInitFunc) NULL,
@@ -118,7 +121,10 @@
 			(GInstanceInitFunc) gda_sql_parser_init
 		};
 		
-		type = g_type_register_static (G_TYPE_OBJECT, "GdaSqlParser", &info, 0);
+		g_static_mutex_lock (&registering);
+		if (type == 0)
+			type = g_type_register_static (G_TYPE_OBJECT, "GdaSqlParser", &info, 0);
+		g_static_mutex_unlock (&registering);
 	}
 	return type;
 }
@@ -414,6 +420,8 @@
 	if (!sql)
 		return NULL;
 
+	g_static_rec_mutex_lock (&usage_mutex);
+
 	if (remain)
 		*remain = NULL;
 	
@@ -597,6 +605,8 @@
 
 	parser->priv->mode = parse_mode;
 
+	g_static_rec_mutex_unlock (&usage_mutex);
+
 	return stmt;
 }
 
@@ -639,6 +649,8 @@
 	if (!sql)
 		return batch;
 
+	g_static_rec_mutex_lock (&usage_mutex);
+
 	int_sql = sql;
 	while (int_sql && allok) {
 		GError *lerror = NULL;
@@ -680,6 +692,8 @@
 		g_object_unref (batch);
 		batch = NULL;
 	}
+
+	g_static_rec_mutex_unlock (&usage_mutex);
 	
 	return batch;
 }
@@ -843,10 +857,12 @@
 static gint
 keywordCode (GdaSqlParser *parser, gchar *str, gint len)
 {
+	static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
 	static GHashTable *keywords = NULL;
 	gint type;
 	gchar oldc;
 
+	g_static_mutex_lock (&mutex);
 	if (!keywords) {
 		/* if keyword begins with a number, it is the GdaSqlParserFlavour to which it only applies:
 		* for example "4start" would refer to the START keyword for PostgreSQL only */
@@ -930,7 +946,8 @@
 		g_hash_table_insert (keywords, "work", GINT_TO_POINTER (L_TRANSACTION));
 		g_hash_table_insert (keywords, "write", GINT_TO_POINTER (L_WRITE));
 	}
-	
+	g_static_mutex_unlock (&mutex);
+
 	oldc = str[len];
 	str[len] = 0;
 	type = GPOINTER_TO_INT (g_hash_table_lookup (keywords, str));

Modified: trunk/libgda/sql-parser/gda-statement-struct.c
==============================================================================
--- trunk/libgda/sql-parser/gda-statement-struct.c	(original)
+++ trunk/libgda/sql-parser/gda-statement-struct.c	Sat Jul  5 14:04:20 2008
@@ -51,7 +51,10 @@
 GdaSqlStatementContentsInfo *
 gda_sql_statement_get_contents_infos  (GdaSqlStatementType type) 
 {
+	static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
 	static GdaSqlStatementContentsInfo **contents = NULL;
+
+	g_static_mutex_lock (&mutex);
 	if (!contents) {
 		contents = g_new0 (GdaSqlStatementContentsInfo *, GDA_SQL_STATEMENT_NONE);
 
@@ -68,6 +71,8 @@
 		contents [GDA_SQL_STATEMENT_ROLLBACK_SAVEPOINT] = gda_sql_statement_rollback_savepoint_get_infos ();
 		contents [GDA_SQL_STATEMENT_DELETE_SAVEPOINT] = gda_sql_statement_delete_savepoint_get_infos ();
 	}
+	g_static_mutex_unlock (&mutex);
+
 	return contents[type];
 }
 

Modified: trunk/libgda/sqlite/gda-sqlite-handler-bin.c
==============================================================================
--- trunk/libgda/sqlite/gda-sqlite-handler-bin.c	(original)
+++ trunk/libgda/sqlite/gda-sqlite-handler-bin.c	Sat Jul  5 14:04:20 2008
@@ -57,6 +57,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaSqliteHandlerBinClass),
 			(GBaseInitFunc) NULL,
@@ -75,8 +76,12 @@
 			NULL
 		};
 
-		type = g_type_register_static (G_TYPE_OBJECT, "GdaSqliteHandlerBin", &info, 0);
-		g_type_add_interface_static (type, GDA_TYPE_DATA_HANDLER, &data_entry_info);
+		g_static_mutex_lock (&registering);
+		if (type == 0) {
+			type = g_type_register_static (G_TYPE_OBJECT, "GdaSqliteHandlerBin", &info, 0);
+			g_type_add_interface_static (type, GDA_TYPE_DATA_HANDLER, &data_entry_info);
+		}
+		g_static_mutex_unlock (&registering);
 	}
 	return type;
 }

Modified: trunk/libgda/sqlite/gda-sqlite-meta.c
==============================================================================
--- trunk/libgda/sqlite/gda-sqlite-meta.c	(original)
+++ trunk/libgda/sqlite/gda-sqlite-meta.c	Sat Jul  5 14:04:20 2008
@@ -96,8 +96,11 @@
 void
 _gda_sqlite_provider_meta_init (GdaServerProvider *provider)
 {
+	static GStaticMutex init_mutex = G_STATIC_MUTEX_INIT;
 	InternalStatementItem i;
 
+	g_static_mutex_lock (&init_mutex);
+
         internal_parser = gda_server_provider_internal_get_parser (provider);
 	internal_params = gda_set_new (NULL);
 
@@ -124,6 +127,8 @@
 
 	pragma_set = gda_set_new_inline (2, "tblname", G_TYPE_STRING, "",
 					 "idxname", G_TYPE_STRING, "");
+
+	g_static_mutex_unlock (&init_mutex);
 }
 
 gboolean
@@ -196,10 +201,11 @@
 			break;
 		}
 	}
-	gda_value_free (vint);
-	if (retval)
+	if (retval) 
 		retval = gda_meta_store_modify (store, context->table_name, mod_model, NULL, error, NULL);
 	g_object_unref (mod_model);
+	gda_value_free (vint);
+
 	return retval;
 }
 

Modified: trunk/libgda/sqlite/gda-sqlite-provider.c
==============================================================================
--- trunk/libgda/sqlite/gda-sqlite-provider.c	(original)
+++ trunk/libgda/sqlite/gda-sqlite-provider.c	Sat Jul  5 14:04:20 2008
@@ -50,6 +50,7 @@
 #define _GDA_PSTMT(x) ((GdaPStmt*)(x))
 
 #define FILE_EXTENSION ".db"
+static GStaticRecMutex cnc_mutex = G_STATIC_REC_MUTEX_INIT;
 #ifdef HAVE_SQLITE
 static SqliteConnectionData *opening_cdata = NULL;
 static GHashTable *db_connections_hash = NULL;
@@ -147,7 +148,8 @@
 /*
  * Prepared internal statements
  */
-static GdaStatement **internal_stmt;
+static GStaticMutex init_mutex = G_STATIC_MUTEX_INIT;
+static GdaStatement **internal_stmt = NULL;
 
 typedef enum {
 	INTERNAL_PRAGMA_INDEX_LIST,
@@ -281,15 +283,19 @@
 	GdaSqlParser *parser;
 
 	parser = gda_server_provider_internal_get_parser ((GdaServerProvider*) sqlite_prv);
-	internal_stmt = g_new0 (GdaStatement *, sizeof (internal_sql) / sizeof (gchar*));
-	for (i = INTERNAL_PRAGMA_INDEX_LIST; i < sizeof (internal_sql) / sizeof (gchar*); i++) {
-		internal_stmt[i] = gda_sql_parser_parse_string (parser, internal_sql[i], NULL, NULL);
-		if (!internal_stmt[i]) 
-			g_error ("Could not parse internal statement: %s\n", internal_sql[i]);
+	g_static_mutex_lock (&init_mutex);
+	if (!internal_stmt) {
+		internal_stmt = g_new0 (GdaStatement *, sizeof (internal_sql) / sizeof (gchar*));
+		for (i = INTERNAL_PRAGMA_INDEX_LIST; i < sizeof (internal_sql) / sizeof (gchar*); i++) {
+			internal_stmt[i] = gda_sql_parser_parse_string (parser, internal_sql[i], NULL, NULL);
+			if (!internal_stmt[i]) 
+				g_error ("Could not parse internal statement: %s\n", internal_sql[i]);
+		}
 	}
 
 	/* meta data init */
 	_gda_sqlite_provider_meta_init ((GdaServerProvider*) sqlite_prv);
+	g_static_mutex_unlock (&init_mutex);
 }
 
 GType
@@ -298,6 +304,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static GTypeInfo info = {
 			sizeof (GdaSqliteProviderClass),
 			(GBaseInitFunc) NULL,
@@ -308,8 +315,10 @@
 			0,
 			(GInstanceInitFunc) gda_sqlite_provider_init
 		};
-		type = g_type_register_static (GDA_TYPE_SERVER_PROVIDER, "GdaSqliteProvider",
-					       &info, 0);
+		g_static_mutex_lock (&registering);
+		if (type == 0)
+			type = g_type_register_static (GDA_TYPE_SERVER_PROVIDER, "GdaSqliteProvider", &info, 0);
+		g_static_mutex_unlock (&registering);
 	}
 
 	return type;
@@ -528,6 +537,8 @@
                 return FALSE;
 	}
 
+	g_static_rec_mutex_lock (&cnc_mutex);
+
 	/* get all parameters received */
 	dirname = gda_quark_list_find (params, "DB_DIR");
 	if (!dirname)
@@ -544,6 +555,7 @@
 			if (!str) {
 				gda_connection_add_event_string (cnc,
 								 _("The connection string must contain DB_DIR and DB_NAME values"));
+				g_static_rec_mutex_unlock (&cnc_mutex);
 				return FALSE;
 			}
 			else {
@@ -573,6 +585,7 @@
 									   "DB_DIR (the path to the database file) and DB_NAME "
 									   "(the database file without the '%s' at the end)."), FILE_EXTENSION);
 					g_free (dup);
+					g_static_rec_mutex_unlock (&cnc_mutex);
 					return FALSE;
 				}
 				else
@@ -585,12 +598,16 @@
 		if (! g_ascii_strcasecmp (dbname,":memory:"))
 			/* we have an in memory database */
 			filename = g_strdup (":memory:");
+		else if (! g_ascii_strcasecmp (dbname,"__gda_tmp"))
+			/* we have an in memory database */
+			filename = NULL/*g_strdup ("")*/;
 		else {
 			if (!g_file_test (dirname, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
 				gda_connection_add_event_string (cnc,
 								 _("The DB_DIR part of the connection string must point "
 								   "to a valid directory"));
 				g_free (dup);
+				g_static_rec_mutex_unlock (&cnc_mutex);
 				return FALSE;
 			}
 			
@@ -625,6 +642,7 @@
 #ifdef HAVE_SQLITE
 		opening_cdata = NULL;
 #endif
+		g_static_rec_mutex_unlock (&cnc_mutex);
 		return FALSE;
 	}
 
@@ -675,6 +693,7 @@
 #ifdef HAVE_SQLITE
 			opening_cdata = NULL;
 #endif
+			g_static_rec_mutex_unlock (&cnc_mutex);
 			return FALSE;
 		}
 	}
@@ -693,6 +712,7 @@
 #ifdef HAVE_SQLITE
 				opening_cdata = NULL;
 #endif
+				g_static_rec_mutex_unlock (&cnc_mutex);
 				return FALSE;
 			}
 		}
@@ -705,6 +725,7 @@
 	g_hash_table_insert (db_connections_hash, cdata->connection, cdata);
 #endif
 
+	g_static_rec_mutex_unlock (&cnc_mutex);
 	return TRUE;
 }
 
@@ -727,13 +748,16 @@
 static const gchar *
 gda_sqlite_provider_get_server_version (GdaServerProvider *provider, GdaConnection *cnc)
 {
+	static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
 	static gchar *version_string = NULL;
 
 	g_return_val_if_fail (GDA_IS_CONNECTION (cnc), FALSE);
 	g_return_val_if_fail (gda_connection_get_provider_obj (cnc) == provider, NULL);
 
+	g_static_mutex_lock (&mutex);
 	if (!version_string)
 		version_string = g_strdup_printf ("SQLite version %s", SQLITE_VERSION);
+	g_static_mutex_unlock (&mutex);
 
 	return (const gchar *) version_string;
 }
@@ -977,7 +1001,6 @@
 				       GError **error)
 {
 	gboolean status = TRUE;
-	static GdaSet *params_set = NULL;
 
 	g_return_val_if_fail (GDA_IS_CONNECTION (cnc), FALSE);
 	g_return_val_if_fail (gda_connection_get_provider_obj (cnc) == provider, FALSE);
@@ -988,13 +1011,17 @@
 	}
 
 	if (name) {
+		static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
+		static GdaSet *params_set = NULL;
+		g_static_mutex_lock (&mutex);
 		if (!params_set)
 			params_set = gda_set_new_inline (1, "name", G_TYPE_STRING, name);
 		else 
 			gda_set_set_holder_value (params_set, "name", name);
 		if (gda_connection_statement_execute_non_select (cnc, internal_stmt[INTERNAL_BEGIN_NAMED], 
 								 params_set, NULL, NULL) == -1) 
-		status = FALSE;
+			status = FALSE;
+		g_static_mutex_unlock (&mutex);
 	}
 	else {
 		if (gda_connection_statement_execute_non_select (cnc, internal_stmt[INTERNAL_BEGIN], 
@@ -1013,19 +1040,22 @@
 					const gchar *name, GError **error)
 {
 	gboolean status = TRUE;
-	static GdaSet *params_set = NULL;
 
 	g_return_val_if_fail (GDA_IS_CONNECTION (cnc), FALSE);
 	g_return_val_if_fail (gda_connection_get_provider_obj (cnc) == provider, FALSE);
 
 	if (name) {
+		static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
+		static GdaSet *params_set = NULL;
+		g_static_mutex_lock (&mutex);
 		if (!params_set)
 			params_set = gda_set_new_inline (1, "name", G_TYPE_STRING, name);
 		else 
 			gda_set_set_holder_value (params_set, "name", name);
 		if (gda_connection_statement_execute_non_select (cnc, internal_stmt[INTERNAL_COMMIT_NAMED], 
 								 params_set, NULL, NULL) == -1) 
-		status = FALSE;
+			status = FALSE;
+		g_static_mutex_unlock (&mutex);
 	}
 	else {
 		if (gda_connection_statement_execute_non_select (cnc, internal_stmt[INTERNAL_COMMIT], 
@@ -1045,19 +1075,22 @@
 					  const gchar *name, GError **error)
 {
 	gboolean status = TRUE;
-	static GdaSet *params_set = NULL;
 
 	g_return_val_if_fail (GDA_IS_CONNECTION (cnc), FALSE);
 	g_return_val_if_fail (gda_connection_get_provider_obj (cnc) == provider, FALSE);
 
 	if (name) {
+		static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
+		static GdaSet *params_set = NULL;
+		g_static_mutex_lock (&mutex);
 		if (!params_set)
 			params_set = gda_set_new_inline (1, "name", G_TYPE_STRING, name);
 		else 
 			gda_set_set_holder_value (params_set, "name", name);
 		if (gda_connection_statement_execute_non_select (cnc, internal_stmt[INTERNAL_ROLLBACK_NAMED], 
 								 params_set, NULL, NULL) == -1) 
-		status = FALSE;
+			status = FALSE;
+		g_static_mutex_unlock (&mutex);
 	}
 	else {
 		if (gda_connection_statement_execute_non_select (cnc, internal_stmt[INTERNAL_ROLLBACK], 
@@ -2150,8 +2183,10 @@
 
 #ifdef HAVE_SQLITE
 	/* remove the (cdata->connection, cdata) to db_connections_hash */
+	g_static_rec_mutex_lock (&cnc_mutex);
 	if (db_connections_hash && cdata->connection)
 		g_hash_table_remove (db_connections_hash, cdata->connection);
+	g_static_rec_mutex_unlock (&cnc_mutex);
 #endif
 
 	if (cdata->connection) 

Modified: trunk/libgda/sqlite/gda-sqlite-pstmt.c
==============================================================================
--- trunk/libgda/sqlite/gda-sqlite-pstmt.c	(original)
+++ trunk/libgda/sqlite/gda-sqlite-pstmt.c	Sat Jul  5 14:04:20 2008
@@ -41,6 +41,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaSqlitePStmtClass),
 			(GBaseInitFunc) NULL,
@@ -53,7 +54,10 @@
 			(GInstanceInitFunc) gda_sqlite_pstmt_init
 		};
 
-		type = g_type_register_static (GDA_TYPE_PSTMT, "GdaSqlitePStmt", &info, 0);
+		g_static_mutex_lock (&registering);
+		if (type == 0)
+			type = g_type_register_static (GDA_TYPE_PSTMT, "GdaSqlitePStmt", &info, 0);
+		g_static_mutex_unlock (&registering);
 	}
 	return type;
 }

Modified: trunk/libgda/sqlite/gda-sqlite-recordset.c
==============================================================================
--- trunk/libgda/sqlite/gda-sqlite-recordset.c	(original)
+++ trunk/libgda/sqlite/gda-sqlite-recordset.c	Sat Jul  5 14:04:20 2008
@@ -110,6 +110,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaSqliteRecordsetClass),
 			(GBaseInitFunc) NULL,
@@ -121,7 +122,10 @@
 			0,
 			(GInstanceInitFunc) gda_sqlite_recordset_init
 		};
-		type = g_type_register_static (GDA_TYPE_PMODEL, "GdaSqliteRecordset", &info, 0);
+		g_static_mutex_lock (&registering);
+		if (type == 0)
+			type = g_type_register_static (GDA_TYPE_PMODEL, "GdaSqliteRecordset", &info, 0);
+		g_static_mutex_unlock (&registering);
 	}
 
 	return type;

Modified: trunk/libgda/sqlite/sqlite-src/Makefile.am
==============================================================================
--- trunk/libgda/sqlite/sqlite-src/Makefile.am	(original)
+++ trunk/libgda/sqlite/sqlite-src/Makefile.am	Sat Jul  5 14:04:20 2008
@@ -1,6 +1,6 @@
 noinst_LTLIBRARIES = \
 	libsqlite.la
-AM_CPPFLAGS = -DSQLITE_ENABLE_COLUMN_METADATA
+AM_CPPFLAGS = -DSQLITE_ENABLE_COLUMN_METADATA -DTHREADSAFE=1
 
 # Download the Windows prepared SQLite (series 3.x) sources in a ZIP, and
 # extract the zip in this directory (thanks to http://aaronbock.net/articles/sqlite!)

Modified: trunk/libgda/sqlite/virtual/gda-vconnection-data-model.c
==============================================================================
--- trunk/libgda/sqlite/virtual/gda-vconnection-data-model.c	(original)
+++ trunk/libgda/sqlite/virtual/gda-vconnection-data-model.c	Sat Jul  5 14:04:20 2008
@@ -104,6 +104,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		if (type == 0) {
 			static GTypeInfo info = {
 				sizeof (GdaVconnectionDataModelClass),
@@ -116,7 +117,10 @@
 				(GInstanceInitFunc) gda_vconnection_data_model_init
 			};
 			
+		g_static_mutex_lock (&registering);
+		if (type == 0)
 			type = g_type_register_static (GDA_TYPE_VIRTUAL_CONNECTION, "GdaVconnectionDataModel", &info, 0);
+		g_static_mutex_unlock (&registering);
 		}
 	}
 

Modified: trunk/libgda/sqlite/virtual/gda-vconnection-hub.c
==============================================================================
--- trunk/libgda/sqlite/virtual/gda-vconnection-hub.c	(original)
+++ trunk/libgda/sqlite/virtual/gda-vconnection-hub.c	Sat Jul  5 14:04:20 2008
@@ -120,6 +120,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		if (type == 0) {
 			static GTypeInfo info = {
 				sizeof (GdaVconnectionHubClass),
@@ -132,7 +133,10 @@
 				(GInstanceInitFunc) gda_vconnection_hub_init
 			};
 			
+		g_static_mutex_lock (&registering);
+		if (type == 0)
 			type = g_type_register_static (GDA_TYPE_VCONNECTION_DATA_MODEL, "GdaVconnectionHub", &info, 0);
+		g_static_mutex_unlock (&registering);
 		}
 	}
 

Modified: trunk/libgda/sqlite/virtual/gda-virtual-connection.c
==============================================================================
--- trunk/libgda/sqlite/virtual/gda-virtual-connection.c	(original)
+++ trunk/libgda/sqlite/virtual/gda-virtual-connection.c	Sat Jul  5 14:04:20 2008
@@ -97,6 +97,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		if (type == 0) {
 			static GTypeInfo info = {
 				sizeof (GdaVirtualConnectionClass),
@@ -109,7 +110,10 @@
 				(GInstanceInitFunc) gda_virtual_connection_init
 			};
 			
+		g_static_mutex_lock (&registering);
+		if (type == 0)
 			type = g_type_register_static (PARENT_TYPE, "GdaVirtualConnection", &info, G_TYPE_FLAG_ABSTRACT);
+		g_static_mutex_unlock (&registering);
 		}
 	}
 

Modified: trunk/libgda/sqlite/virtual/gda-virtual-provider.c
==============================================================================
--- trunk/libgda/sqlite/virtual/gda-virtual-provider.c	(original)
+++ trunk/libgda/sqlite/virtual/gda-virtual-provider.c	Sat Jul  5 14:04:20 2008
@@ -110,6 +110,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		if (type == 0) {
 			static GTypeInfo info = {
 				sizeof (GdaVirtualProviderClass),
@@ -122,7 +123,10 @@
 				(GInstanceInitFunc) gda_virtual_provider_init
 			};
 			
+		g_static_mutex_lock (&registering);
+		if (type == 0)
 			type = g_type_register_static (PARENT_TYPE, "GdaVirtualProvider", &info, G_TYPE_FLAG_ABSTRACT);
+		g_static_mutex_unlock (&registering);
 		}
 	}
 

Modified: trunk/libgda/sqlite/virtual/gda-vprovider-data-model.c
==============================================================================
--- trunk/libgda/sqlite/virtual/gda-vprovider-data-model.c	(original)
+++ trunk/libgda/sqlite/virtual/gda-vprovider-data-model.c	Sat Jul  5 14:04:20 2008
@@ -123,6 +123,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		if (type == 0) {
 			static GTypeInfo info = {
 				sizeof (GdaVproviderDataModelClass),
@@ -135,7 +136,10 @@
 				(GInstanceInitFunc) gda_vprovider_data_model_init
 			};
 			
+		g_static_mutex_lock (&registering);
+		if (type == 0)
 			type = g_type_register_static (GDA_TYPE_VIRTUAL_PROVIDER, "GdaVproviderDataModel", &info, 0);
+		g_static_mutex_unlock (&registering);
 		}
 	}
 

Modified: trunk/libgda/sqlite/virtual/gda-vprovider-hub.c
==============================================================================
--- trunk/libgda/sqlite/virtual/gda-vprovider-hub.c	(original)
+++ trunk/libgda/sqlite/virtual/gda-vprovider-hub.c	Sat Jul  5 14:04:20 2008
@@ -105,6 +105,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		if (type == 0) {
 			static GTypeInfo info = {
 				sizeof (GdaVproviderHubClass),
@@ -117,7 +118,10 @@
 				(GInstanceInitFunc) gda_vprovider_hub_init
 			};
 			
+		g_static_mutex_lock (&registering);
+		if (type == 0)
 			type = g_type_register_static (GDA_TYPE_VPROVIDER_DATA_MODEL, "GdaVproviderHub", &info, 0);
+		g_static_mutex_unlock (&registering);
 		}
 	}
 

Modified: trunk/providers/bdb/gda-bdb-provider.c
==============================================================================
--- trunk/providers/bdb/gda-bdb-provider.c	(original)
+++ trunk/providers/bdb/gda-bdb-provider.c	Sat Jul  5 14:04:20 2008
@@ -95,6 +95,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static GTypeInfo info = {
 			sizeof (GdaBdbProviderClass),
 			(GBaseInitFunc) NULL,
@@ -105,7 +106,10 @@
 			0,
 			(GInstanceInitFunc) gda_bdb_provider_init
 		};
-		type = g_type_register_static (GDA_TYPE_VPROVIDER_DATA_MODEL, "GdaBdbProvider", &info, 0);
+		g_static_mutex_lock (&registering);
+		if (type == 0)
+			type = g_type_register_static (GDA_TYPE_VPROVIDER_DATA_MODEL, "GdaBdbProvider", &info, 0);
+		g_static_mutex_unlock (&registering);
 	}
 
 	return type;

Modified: trunk/providers/firebird/gda-firebird-blob-op.c
==============================================================================
--- trunk/providers/firebird/gda-firebird-blob-op.c	(original)
+++ trunk/providers/firebird/gda-firebird-blob-op.c	Sat Jul  5 14:04:20 2008
@@ -51,6 +51,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaFirebirdBlobOpClass),
 			(GBaseInitFunc) NULL,
@@ -62,7 +63,10 @@
 			0,
 			(GInstanceInitFunc) gda_firebird_blob_op_init
 		};
-		type = g_type_register_static (GDA_TYPE_BLOB_OP, "GdaFirebirdBlobOp", &info, 0);
+		g_static_mutex_lock (&registering);
+		if (type == 0)
+			type = g_type_register_static (GDA_TYPE_BLOB_OP, "GdaFirebirdBlobOp", &info, 0);
+		g_static_mutex_unlock (&registering);
 	}
 	return type;
 }

Modified: trunk/providers/firebird/gda-firebird-provider.c
==============================================================================
--- trunk/providers/firebird/gda-firebird-provider.c	(original)
+++ trunk/providers/firebird/gda-firebird-provider.c	Sat Jul  5 14:04:20 2008
@@ -274,6 +274,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static GTypeInfo info = {
 			sizeof (GdaFirebirdProviderClass),
 			(GBaseInitFunc) NULL,

Modified: trunk/providers/firebird/gda-firebird-recordset.c
==============================================================================
--- trunk/providers/firebird/gda-firebird-recordset.c	(original)
+++ trunk/providers/firebird/gda-firebird-recordset.c	Sat Jul  5 14:04:20 2008
@@ -112,6 +112,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaFirebirdRecordsetClass),
 			(GBaseInitFunc) NULL,
@@ -123,7 +124,10 @@
 			0,
 			(GInstanceInitFunc) gda_firebird_recordset_init
 		};
-		type = g_type_register_static (GDA_TYPE_PMODEL, "GdaFirebirdRecordset", &info, 0);
+		g_static_mutex_lock (&registering);
+		if (type == 0)
+			type = g_type_register_static (GDA_TYPE_PMODEL, "GdaFirebirdRecordset", &info, 0);
+		g_static_mutex_unlock (&registering);
 	}
 
 	return type;

Modified: trunk/providers/mdb/gda-mdb-provider.c
==============================================================================
--- trunk/providers/mdb/gda-mdb-provider.c	(original)
+++ trunk/providers/mdb/gda-mdb-provider.c	Sat Jul  5 14:04:20 2008
@@ -57,6 +57,7 @@
 
 
 static GObjectClass *parent_class = NULL;
+static GStaticMutex mdb_init_mutex = G_STATIC_MUTEX_INIT;
 static gint loaded_providers = 0;
 char *g_input_ptr;
 
@@ -101,9 +102,11 @@
 	parent_class->finalize (object);
 
 	/* call MDB exit function if there are no more providers */
+	g_static_mutex_lock (&mdb_init_mutex);
 	loaded_providers--;
 	if (loaded_providers == 0)
 		mdb_exit ();
+	g_static_mutex_unlock (&mdb_init_mutex);
 }
 
 GType
@@ -112,6 +115,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static GTypeInfo info = {
 			sizeof (GdaMdbProviderClass),
 			(GBaseInitFunc) NULL,
@@ -122,7 +126,10 @@
 			0,
 			(GInstanceInitFunc) gda_mdb_provider_init
 		};
-		type = g_type_register_static (GDA_TYPE_VPROVIDER_DATA_MODEL, "GdaMdbProvider", &info, 0);
+		g_static_mutex_lock (&registering);
+		if (type == 0)
+			type = g_type_register_static (GDA_TYPE_VPROVIDER_DATA_MODEL, "GdaMdbProvider", &info, 0);
+		g_static_mutex_unlock (&registering);
 	}
 
 	return type;
@@ -131,13 +138,13 @@
 GdaServerProvider *
 gda_mdb_provider_new (void)
 {
-	static gboolean mdb_initialized = FALSE;
 	GdaMdbProvider *provider;
 
-	if (!mdb_initialized)
+	g_static_mutex_lock (&mdb_init_mutex);
+	if (loaded_providers == 0) 
 		mdb_init ();
-
 	loaded_providers++;
+	g_static_mutex_unlock (&mdb_init_mutex);
 
 	provider = g_object_new (gda_mdb_provider_get_type (), NULL);
 	return GDA_SERVER_PROVIDER (provider);

Modified: trunk/providers/mysql/gda-mysql-blob-op.c
==============================================================================
--- trunk/providers/mysql/gda-mysql-blob-op.c	(original)
+++ trunk/providers/mysql/gda-mysql-blob-op.c	Sat Jul  5 14:04:20 2008
@@ -51,6 +51,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaMysqlBlobOpClass),
 			(GBaseInitFunc) NULL,
@@ -62,7 +63,10 @@
 			0,
 			(GInstanceInitFunc) gda_mysql_blob_op_init
 		};
-		type = g_type_register_static (GDA_TYPE_BLOB_OP, "GdaMysqlBlobOp", &info, 0);
+		g_static_mutex_lock (&registering);
+		if (type == 0)
+			type = g_type_register_static (GDA_TYPE_BLOB_OP, "GdaMysqlBlobOp", &info, 0);
+		g_static_mutex_unlock (&registering);
 	}
 	return type;
 }

Modified: trunk/providers/mysql/gda-mysql-meta.c
==============================================================================
--- trunk/providers/mysql/gda-mysql-meta.c	(original)
+++ trunk/providers/mysql/gda-mysql-meta.c	Sat Jul  5 14:04:20 2008
@@ -164,15 +164,12 @@
 };
 
 /*
- * predefined statements' GdaStatement
+ * global static values, and
+ * predefined statements' GdaStatement, all initialized in _gda_postgres_provider_meta_init()
  */
 static GdaStatement **internal_stmt;
 static GdaSet        *i_set;
-
-/* 
- * global static values
- */
-static GdaSqlParser *internal_parser = NULL;
+static GdaSqlParser  *internal_parser = NULL;
 /* TO_ADD: other static values */
 
 
@@ -182,10 +179,12 @@
 void
 _gda_mysql_provider_meta_init (GdaServerProvider  *provider)
 {
+	static GStaticMutex init_mutex = G_STATIC_MUTEX_INIT;
 	InternalStatementItem i;
 
-        internal_parser = gda_server_provider_internal_get_parser (provider);
+	g_static_mutex_lock (&init_mutex);
 
+        internal_parser = gda_server_provider_internal_get_parser (provider);
         internal_stmt = g_new0 (GdaStatement *, sizeof (internal_sql) / sizeof (gchar*));
         for (i = I_STMT_CATALOG; i < sizeof (internal_sql) / sizeof (gchar*); i++) {
                 internal_stmt[i] = gda_sql_parser_parse_string (internal_parser, internal_sql[i], NULL, NULL);
@@ -197,6 +196,8 @@
 	i_set = gda_set_new_inline (3, "cat", G_TYPE_STRING, "", 
 				    "name", G_TYPE_STRING, "",
 				    "schema", G_TYPE_STRING, "");
+
+	g_static_mutex_unlock (&init_mutex);
 }
 
 gboolean

Modified: trunk/providers/mysql/gda-mysql-parser.c
==============================================================================
--- trunk/providers/mysql/gda-mysql-parser.c	(original)
+++ trunk/providers/mysql/gda-mysql-parser.c	Sat Jul  5 14:04:20 2008
@@ -37,6 +37,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaMysqlParserClass),
 			(GBaseInitFunc) NULL,
@@ -49,7 +50,10 @@
 			(GInstanceInitFunc) gda_mysql_parser_init
 		};
 		
-		type = g_type_register_static (GDA_TYPE_SQL_PARSER, "GdaMysqlParser", &info, 0);
+		g_static_mutex_lock (&registering);
+		if (type == 0)
+			type = g_type_register_static (GDA_TYPE_SQL_PARSER, "GdaMysqlParser", &info, 0);
+		g_static_mutex_unlock (&registering);
 	}
 	return type;
 }

Modified: trunk/providers/mysql/gda-mysql-provider.c
==============================================================================
--- trunk/providers/mysql/gda-mysql-provider.c	(original)
+++ trunk/providers/mysql/gda-mysql-provider.c	Sat Jul  5 14:04:20 2008
@@ -335,6 +335,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static GTypeInfo info = {
 			sizeof (GdaMysqlProviderClass),
 			(GBaseInitFunc) NULL,
@@ -345,8 +346,10 @@
 			0,
 			(GInstanceInitFunc) gda_mysql_provider_init
 		};
-		type = g_type_register_static (GDA_TYPE_SERVER_PROVIDER, "GdaMysqlProvider",
-					       &info, 0);
+		g_static_mutex_lock (&registering);
+		if (type == 0)
+			type = g_type_register_static (GDA_TYPE_SERVER_PROVIDER, "GdaMysqlProvider", &info, 0);
+		g_static_mutex_unlock (&registering);
 	}
 
 	return type;

Modified: trunk/providers/mysql/gda-mysql-pstmt.c
==============================================================================
--- trunk/providers/mysql/gda-mysql-pstmt.c	(original)
+++ trunk/providers/mysql/gda-mysql-pstmt.c	Sat Jul  5 14:04:20 2008
@@ -45,6 +45,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaMysqlPStmtClass),
 			(GBaseInitFunc) NULL,
@@ -57,7 +58,10 @@
 			(GInstanceInitFunc) gda_mysql_pstmt_init
 		};
 
-		type = g_type_register_static (GDA_TYPE_PSTMT, "GdaMysqlPStmt", &info, 0);
+		g_static_mutex_lock (&registering);
+		if (type == 0)
+			type = g_type_register_static (GDA_TYPE_PSTMT, "GdaMysqlPStmt", &info, 0);
+		g_static_mutex_unlock (&registering);
 	}
 	return type;
 }

Modified: trunk/providers/mysql/gda-mysql-recordset.c
==============================================================================
--- trunk/providers/mysql/gda-mysql-recordset.c	(original)
+++ trunk/providers/mysql/gda-mysql-recordset.c	Sat Jul  5 14:04:20 2008
@@ -231,6 +231,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaMysqlRecordsetClass),
 			(GBaseInitFunc) NULL,
@@ -242,7 +243,10 @@
 			0,
 			(GInstanceInitFunc) gda_mysql_recordset_init
 		};
-		type = g_type_register_static (GDA_TYPE_PMODEL, "GdaMysqlRecordset", &info, 0);
+		g_static_mutex_lock (&registering);
+		if (type == 0)
+			type = g_type_register_static (GDA_TYPE_PMODEL, "GdaMysqlRecordset", &info, 0);
+		g_static_mutex_unlock (&registering);
 	}
 
 	return type;

Modified: trunk/providers/postgres/gda-postgres-blob-op.c
==============================================================================
--- trunk/providers/postgres/gda-postgres-blob-op.c	(original)
+++ trunk/providers/postgres/gda-postgres-blob-op.c	Sat Jul  5 14:04:20 2008
@@ -52,6 +52,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaPostgresBlobOpClass),
 			(GBaseInitFunc) NULL,
@@ -63,7 +64,10 @@
 			0,
 			(GInstanceInitFunc) gda_postgres_blob_op_init
 		};
-		type = g_type_register_static (GDA_TYPE_BLOB_OP, "GdaPostgresBlobOp", &info, 0);
+		g_static_mutex_lock (&registering);
+		if (type == 0)
+			type = g_type_register_static (GDA_TYPE_BLOB_OP, "GdaPostgresBlobOp", &info, 0);
+		g_static_mutex_unlock (&registering);
 	}
 	return type;
 }

Modified: trunk/providers/postgres/gda-postgres-handler-bin.c
==============================================================================
--- trunk/providers/postgres/gda-postgres-handler-bin.c	(original)
+++ trunk/providers/postgres/gda-postgres-handler-bin.c	Sat Jul  5 14:04:20 2008
@@ -61,6 +61,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaPostgresHandlerBinClass),
 			(GBaseInitFunc) NULL,
@@ -79,8 +80,12 @@
 			NULL
 		};
 
-		type = g_type_register_static (G_TYPE_OBJECT, "GdaPostgresHandlerBin", &info, 0);
-		g_type_add_interface_static (type, GDA_TYPE_DATA_HANDLER, &data_entry_info);
+		g_static_mutex_lock (&registering);
+		if (type == 0) {
+			type = g_type_register_static (G_TYPE_OBJECT, "GdaPostgresHandlerBin", &info, 0);
+			g_type_add_interface_static (type, GDA_TYPE_DATA_HANDLER, &data_entry_info);
+		}
+		g_static_mutex_unlock (&registering);
 	}
 	return type;
 }

Modified: trunk/providers/postgres/gda-postgres-meta.c
==============================================================================
--- trunk/providers/postgres/gda-postgres-meta.c	(original)
+++ trunk/providers/postgres/gda-postgres-meta.c	Sat Jul  5 14:04:20 2008
@@ -192,27 +192,25 @@
 };
 
 /*
- * predefined statements' GdaStatement
+ * global static values, and
+ * predefined statements' GdaStatement, all initialized in _gda_postgres_provider_meta_init()
  */
 static GdaStatement **internal_stmt;
-
-/* 
- * global static values
- */
 static GdaSqlParser *internal_parser = NULL;
 static GdaSet       *i_set;
 
-
 /*
  * Meta initialization
  */
 void
 _gda_postgres_provider_meta_init (GdaServerProvider *provider)
 {
+	static GStaticMutex init_mutex = G_STATIC_MUTEX_INIT;
 	InternalStatementItem i;
 
-        internal_parser = gda_server_provider_internal_get_parser (provider);
+	g_static_mutex_lock (&init_mutex);
 
+        internal_parser = gda_server_provider_internal_get_parser (provider);
         internal_stmt = g_new0 (GdaStatement *, sizeof (internal_sql) / sizeof (gchar*));
         for (i = I_STMT_CATALOG; i < sizeof (internal_sql) / sizeof (gchar*); i++) {
                 internal_stmt[i] = gda_sql_parser_parse_string (internal_parser, internal_sql[i], NULL, NULL);
@@ -220,11 +218,12 @@
                         g_error ("Could not parse internal statement: %s\n", internal_sql[i]);
         }
 
-	/* initialize static values here */
 	i_set = gda_set_new_inline (4, "cat", G_TYPE_STRING, "", 
 				    "name", G_TYPE_STRING, "",
 				    "schema", G_TYPE_STRING, "",
 				    "name2", G_TYPE_STRING, "");
+
+	g_static_mutex_unlock (&init_mutex);
 }
 
 gboolean

Modified: trunk/providers/postgres/gda-postgres-parser.c
==============================================================================
--- trunk/providers/postgres/gda-postgres-parser.c	(original)
+++ trunk/providers/postgres/gda-postgres-parser.c	Sat Jul  5 14:04:20 2008
@@ -37,6 +37,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaPostgresParserClass),
 			(GBaseInitFunc) NULL,
@@ -49,7 +50,10 @@
 			(GInstanceInitFunc) gda_postgres_parser_init
 		};
 		
-		type = g_type_register_static (GDA_TYPE_SQL_PARSER, "GdaPostgresParser", &info, 0);
+		g_static_mutex_lock (&registering);
+		if (type == 0)
+			type = g_type_register_static (GDA_TYPE_SQL_PARSER, "GdaPostgresParser", &info, 0);
+		g_static_mutex_unlock (&registering);
 	}
 	return type;
 }

Modified: trunk/providers/postgres/gda-postgres-provider.c
==============================================================================
--- trunk/providers/postgres/gda-postgres-provider.c	(original)
+++ trunk/providers/postgres/gda-postgres-provider.c	Sat Jul  5 14:04:20 2008
@@ -286,6 +286,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static GTypeInfo info = {
 			sizeof (GdaPostgresProviderClass),
 			(GBaseInitFunc) NULL,
@@ -296,8 +297,10 @@
 			0,
 			(GInstanceInitFunc) gda_postgres_provider_init
 		};
-		type = g_type_register_static (GDA_TYPE_SERVER_PROVIDER, "GdaPostgresProvider",
-					       &info, 0);
+		g_static_mutex_lock (&registering);
+		if (type == 0)
+			type = g_type_register_static (GDA_TYPE_SERVER_PROVIDER, "GdaPostgresProvider", &info, 0);
+		g_static_mutex_unlock (&registering);
 	}
 
 	return type;
@@ -2185,6 +2188,7 @@
 {
 	GdaSet *params;
 	gint affected;
+	gchar *str;
 
 	g_return_val_if_fail (GDA_IS_CONNECTION (cnc), FALSE);
 	g_return_val_if_fail (gda_connection_get_provider_obj (cnc) == provider, FALSE);
@@ -2192,12 +2196,15 @@
 
 	if (!gda_statement_get_parameters (internal_stmt [I_STMT_XA_PREPARE], &params, error))
 		return FALSE;
-	if (!gda_set_set_holder_value (params, "xid", gda_xa_transaction_id_to_string (xid))) {
+	str = gda_xa_transaction_id_to_string (xid);
+	if (!gda_set_set_holder_value (params, "xid", str)) {
+		g_free (str);
 		g_object_unref (params);
 		g_set_error (error, GDA_SERVER_PROVIDER_ERROR, GDA_SERVER_PROVIDER_INTERNAL_ERROR,
 			     _("Could not set the XA transaction ID parameter"));
 		return FALSE;
 	}
+	g_free (str);
 	affected = gda_connection_statement_execute_non_select (cnc, internal_stmt [I_STMT_XA_PREPARE], params, 
 								NULL, error);
 	g_object_unref (params);
@@ -2217,6 +2224,7 @@
 {
 	GdaSet *params;
 	gint affected;
+	gchar *str;
 
 	g_return_val_if_fail (GDA_IS_CONNECTION (cnc), FALSE);
 	g_return_val_if_fail (gda_connection_get_provider_obj (cnc) == provider, FALSE);
@@ -2224,12 +2232,15 @@
 
 	if (!gda_statement_get_parameters (internal_stmt [I_STMT_XA_PREPARE], &params, error))
 		return FALSE;
-	if (!gda_set_set_holder_value (params, "xid", gda_xa_transaction_id_to_string (xid))) {
+	str = gda_xa_transaction_id_to_string (xid);
+	if (!gda_set_set_holder_value (params, "xid", str)) {
+		g_free (str);
 		g_object_unref (params);
 		g_set_error (error, GDA_SERVER_PROVIDER_ERROR, GDA_SERVER_PROVIDER_INTERNAL_ERROR,
 			     _("Could not set the XA transaction ID parameter"));
 		return FALSE;
 	}
+	g_free (str);
 	affected = gda_connection_statement_execute_non_select (cnc, internal_stmt [I_STMT_XA_COMMIT], params, 
 								NULL, error);
 	g_object_unref (params);
@@ -2248,6 +2259,7 @@
 {
 	GdaSet *params;
 	gint affected;
+	gchar *str;
 
 	g_return_val_if_fail (GDA_IS_CONNECTION (cnc), FALSE);
 	g_return_val_if_fail (gda_connection_get_provider_obj (cnc) == provider, FALSE);
@@ -2255,12 +2267,15 @@
 
 	if (!gda_statement_get_parameters (internal_stmt [I_STMT_XA_PREPARE], &params, error))
 		return FALSE;
-	if (!gda_set_set_holder_value (params, "xid", gda_xa_transaction_id_to_string (xid))) {
+	str = gda_xa_transaction_id_to_string (xid);
+	if (!gda_set_set_holder_value (params, "xid", str)) {
+		g_free (str);
 		g_object_unref (params);
 		g_set_error (error, GDA_SERVER_PROVIDER_ERROR, GDA_SERVER_PROVIDER_INTERNAL_ERROR,
 			     _("Could not set the XA transaction ID parameter"));
 		return FALSE;
 	}
+	g_free (str);
 	affected = gda_connection_statement_execute_non_select (cnc, internal_stmt [I_STMT_XA_ROLLBACK], params, 
 								NULL, error);
 	g_object_unref (params);

Modified: trunk/providers/postgres/gda-postgres-pstmt.c
==============================================================================
--- trunk/providers/postgres/gda-postgres-pstmt.c	(original)
+++ trunk/providers/postgres/gda-postgres-pstmt.c	Sat Jul  5 14:04:20 2008
@@ -42,6 +42,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaPostgresPStmtClass),
 			(GBaseInitFunc) NULL,
@@ -54,7 +55,10 @@
 			(GInstanceInitFunc) gda_postgres_pstmt_init
 		};
 
-		type = g_type_register_static (GDA_TYPE_PSTMT, "GdaPostgresPStmt", &info, 0);
+		g_static_mutex_lock (&registering);
+		if (type == 0)
+			type = g_type_register_static (GDA_TYPE_PSTMT, "GdaPostgresPStmt", &info, 0);
+		g_static_mutex_unlock (&registering);
 	}
 	return type;
 }

Modified: trunk/providers/postgres/gda-postgres-recordset.c
==============================================================================
--- trunk/providers/postgres/gda-postgres-recordset.c	(original)
+++ trunk/providers/postgres/gda-postgres-recordset.c	Sat Jul  5 14:04:20 2008
@@ -226,6 +226,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaPostgresRecordsetClass),
 			(GBaseInitFunc) NULL,
@@ -237,7 +238,10 @@
 			0,
 			(GInstanceInitFunc) gda_postgres_recordset_init
 		};
-		type = g_type_register_static (GDA_TYPE_PMODEL, "GdaPostgresRecordset", &info, 0);
+		g_static_mutex_lock (&registering);
+		if (type == 0)
+			type = g_type_register_static (GDA_TYPE_PMODEL, "GdaPostgresRecordset", &info, 0);
+		g_static_mutex_unlock (&registering);
 	}
 
 	return type;

Modified: trunk/providers/skel-implementation/capi/gda-capi-blob-op.c
==============================================================================
--- trunk/providers/skel-implementation/capi/gda-capi-blob-op.c	(original)
+++ trunk/providers/skel-implementation/capi/gda-capi-blob-op.c	Sat Jul  5 14:04:20 2008
@@ -51,6 +51,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaCapiBlobOpClass),
 			(GBaseInitFunc) NULL,
@@ -62,7 +63,10 @@
 			0,
 			(GInstanceInitFunc) gda_capi_blob_op_init
 		};
-		type = g_type_register_static (GDA_TYPE_BLOB_OP, "GdaCapiBlobOp", &info, 0);
+		g_static_mutex_lock (&registering);
+		if (type == 0)
+			type = g_type_register_static (GDA_TYPE_BLOB_OP, "GdaCapiBlobOp", &info, 0);
+		g_static_mutex_unlock (&registering);
 	}
 	return type;
 }

Modified: trunk/providers/skel-implementation/capi/gda-capi-meta.c
==============================================================================
--- trunk/providers/skel-implementation/capi/gda-capi-meta.c	(original)
+++ trunk/providers/skel-implementation/capi/gda-capi-meta.c	Sat Jul  5 14:04:20 2008
@@ -51,15 +51,12 @@
 };
 
 /*
- * predefined statements' GdaStatement
+ * global static values, and
+ * predefined statements' GdaStatement, all initialized in _gda_capi_provider_meta_init()
  */
 static GdaStatement **internal_stmt;
 static GdaSet        *i_set;
-
-/* 
- * global static values
- */
-static GdaSqlParser *internal_parser = NULL;
+static GdaSqlParser  *internal_parser = NULL;
 /* TO_ADD: other static values */
 
 
@@ -69,10 +66,12 @@
 void
 _gda_capi_provider_meta_init (GdaServerProvider *provider)
 {
+	static GStaticMutex init_mutex = G_STATIC_MUTEX_INIT;
 	InternalStatementItem i;
 
-        internal_parser = gda_server_provider_internal_get_parser (provider);
+	g_static_mutex_lock (&init_mutex);
 
+        internal_parser = gda_server_provider_internal_get_parser (provider);
         internal_stmt = g_new0 (GdaStatement *, sizeof (internal_sql) / sizeof (gchar*));
         for (i = I_STMT_1; i < sizeof (internal_sql) / sizeof (gchar*); i++) {
                 internal_stmt[i] = gda_sql_parser_parse_string (internal_parser, internal_sql[i], NULL, NULL);
@@ -85,6 +84,8 @@
 				    "name", G_TYPE_STRING, "",
 				    "schema", G_TYPE_STRING, "",
 				    "name2", G_TYPE_STRING, "");
+
+	g_static_mutex_unlock (&init_mutex);
 }
 
 gboolean

Modified: trunk/providers/skel-implementation/capi/gda-capi-parser.c
==============================================================================
--- trunk/providers/skel-implementation/capi/gda-capi-parser.c	(original)
+++ trunk/providers/skel-implementation/capi/gda-capi-parser.c	Sat Jul  5 14:04:20 2008
@@ -37,6 +37,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaCapiParserClass),
 			(GBaseInitFunc) NULL,
@@ -49,7 +50,10 @@
 			(GInstanceInitFunc) gda_capi_parser_init
 		};
 		
-		type = g_type_register_static (GDA_TYPE_SQL_PARSER, "GdaCapiParser", &info, 0);
+		g_static_mutex_lock (&registering);
+		if (type == 0)
+			type = g_type_register_static (GDA_TYPE_SQL_PARSER, "GdaCapiParser", &info, 0);
+		g_static_mutex_unlock (&registering);
 	}
 	return type;
 }

Modified: trunk/providers/skel-implementation/capi/gda-capi-provider.c
==============================================================================
--- trunk/providers/skel-implementation/capi/gda-capi-provider.c	(original)
+++ trunk/providers/skel-implementation/capi/gda-capi-provider.c	Sat Jul  5 14:04:20 2008
@@ -273,6 +273,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static GTypeInfo info = {
 			sizeof (GdaCapiProviderClass),
 			(GBaseInitFunc) NULL,
@@ -283,8 +284,10 @@
 			0,
 			(GInstanceInitFunc) gda_capi_provider_init
 		};
-		type = g_type_register_static (GDA_TYPE_SERVER_PROVIDER, "GdaCapiProvider",
-					       &info, 0);
+		g_static_mutex_lock (&registering);
+		if (type == 0)
+			type = g_type_register_static (GDA_TYPE_SERVER_PROVIDER, "GdaCapiProvider", &info, 0);
+		g_static_mutex_unlock (&registering);
 	}
 
 	return type;

Modified: trunk/providers/skel-implementation/capi/gda-capi-pstmt.c
==============================================================================
--- trunk/providers/skel-implementation/capi/gda-capi-pstmt.c	(original)
+++ trunk/providers/skel-implementation/capi/gda-capi-pstmt.c	Sat Jul  5 14:04:20 2008
@@ -41,6 +41,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaCapiPStmtClass),
 			(GBaseInitFunc) NULL,
@@ -53,7 +54,10 @@
 			(GInstanceInitFunc) gda_capi_pstmt_init
 		};
 
-		type = g_type_register_static (GDA_TYPE_PSTMT, "GdaCapiPStmt", &info, 0);
+		g_static_mutex_lock (&registering);
+		if (type == 0)
+			type = g_type_register_static (GDA_TYPE_PSTMT, "GdaCapiPStmt", &info, 0);
+		g_static_mutex_unlock (&registering);
 	}
 	return type;
 }

Modified: trunk/providers/skel-implementation/capi/gda-capi-recordset.c
==============================================================================
--- trunk/providers/skel-implementation/capi/gda-capi-recordset.c	(original)
+++ trunk/providers/skel-implementation/capi/gda-capi-recordset.c	Sat Jul  5 14:04:20 2008
@@ -112,6 +112,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static const GTypeInfo info = {
 			sizeof (GdaCapiRecordsetClass),
 			(GBaseInitFunc) NULL,
@@ -123,7 +124,10 @@
 			0,
 			(GInstanceInitFunc) gda_capi_recordset_init
 		};
-		type = g_type_register_static (GDA_TYPE_PMODEL, "GdaCapiRecordset", &info, 0);
+		g_static_mutex_lock (&registering);
+		if (type == 0)
+			type = g_type_register_static (GDA_TYPE_PMODEL, "GdaCapiRecordset", &info, 0);
+		g_static_mutex_unlock (&registering);
 	}
 
 	return type;

Modified: trunk/providers/skel-implementation/models/gda-models-provider.c
==============================================================================
--- trunk/providers/skel-implementation/models/gda-models-provider.c	(original)
+++ trunk/providers/skel-implementation/models/gda-models-provider.c	Sat Jul  5 14:04:20 2008
@@ -92,6 +92,7 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
 		static GTypeInfo info = {
 			sizeof (GdaModelsProviderClass),
 			(GBaseInitFunc) NULL,
@@ -102,7 +103,10 @@
 			0,
 			(GInstanceInitFunc) gda_models_provider_init
 		};
-		type = g_type_register_static (GDA_TYPE_VPROVIDER_DATA_MODEL, "GdaModelsProvider", &info, 0);
+		g_static_mutex_lock (&registering);
+		if (type == 0)
+			type = g_type_register_static (GDA_TYPE_VPROVIDER_DATA_MODEL, "GdaModelsProvider", &info, 0);
+		g_static_mutex_unlock (&registering);
 	}
 
 	return type;

Modified: trunk/samples/BDB/custom-bdb-model.c
==============================================================================
--- trunk/samples/BDB/custom-bdb-model.c	(original)
+++ trunk/samples/BDB/custom-bdb-model.c	Sat Jul  5 14:04:20 2008
@@ -72,20 +72,22 @@
 	static GType type = 0;
 
 	if (G_UNLIKELY (type == 0)) {
-		if (type == 0) {
-			static GTypeInfo info = {
-				sizeof (CustomDataModelClass),
-				(GBaseInitFunc) NULL,
-				(GBaseFinalizeFunc) NULL,
-				(GClassInitFunc) custom_data_model_class_init,
-				NULL, NULL,
-				sizeof (CustomDataModel),
-				0,
-				(GInstanceInitFunc) custom_data_model_init
-			};
-			
+		static GStaticMutex registering = G_STATIC_MUTEX_INIT;
+		static GTypeInfo info = {
+			sizeof (CustomDataModelClass),
+			(GBaseInitFunc) NULL,
+			(GBaseFinalizeFunc) NULL,
+			(GClassInitFunc) custom_data_model_class_init,
+			NULL, NULL,
+			sizeof (CustomDataModel),
+			0,
+			(GInstanceInitFunc) custom_data_model_init
+		};
+		
+		g_static_mutex_lock (&registering);
+		if (type == 0)
 			type = g_type_register_static (PARENT_TYPE, "CustomDataModel", &info, 0);
-		}
+		g_static_mutex_unlock (&registering);
 	}
 
 	return type;



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