[libgda] Better handle situations where GdaConnection is closed
- From: Vivien Malerba <vivien src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] Better handle situations where GdaConnection is closed
- Date: Fri, 11 Nov 2011 13:12:26 +0000 (UTC)
commit 0a1baca4476309b26903d9d856704d42929bb644
Author: Vivien Malerba <malerba gnome-db org>
Date: Fri Nov 11 13:55:58 2011 +0100
Better handle situations where GdaConnection is closed
libgda/gda-connection.c | 8 ++------
libgda/sqlite/gda-sqlite-util.c | 6 +-----
libgda/thread-wrapper/gda-thread-provider.c | 2 +-
providers/mysql/gda-mysql-provider.c | 7 +++----
providers/oracle/gda-oracle-provider.c | 7 ++-----
providers/postgres/gda-postgres-handler-bin.c | 3 ---
providers/postgres/gda-postgres-provider.c | 5 +----
providers/reuseable/mysql/gda-mysql-meta.c | 2 +-
providers/reuseable/postgres/gda-postgres-meta.c | 2 +-
.../skel-implementation/capi/gda-capi-provider.c | 2 +-
providers/web/gda-web-provider.c | 2 +-
11 files changed, 14 insertions(+), 32 deletions(-)
---
diff --git a/libgda/gda-connection.c b/libgda/gda-connection.c
index 5ec9894..b2842c1 100644
--- a/libgda/gda-connection.c
+++ b/libgda/gda-connection.c
@@ -6284,7 +6284,7 @@ gda_connection_internal_set_provider_data (GdaConnection *cnc, gpointer data, GD
* Get the opaque pointer previously set using gda_connection_internal_set_provider_data().
* If it's not set, then add a connection event and returns %NULL
*
- * Returns: the pointer to the opaque structure set using gda_connection_internal_set_provider_data()
+ * Returns: (allow-none): the pointer to the opaque structure set using gda_connection_internal_set_provider_data(), or %NULL
*/
gpointer
gda_connection_internal_get_provider_data (GdaConnection *cnc)
@@ -6293,8 +6293,6 @@ gda_connection_internal_get_provider_data (GdaConnection *cnc)
g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
retval = cnc->priv->provider_data;
- if (! retval)
- gda_connection_add_event_string (cnc, _("Internal error: invalid provider handle"));
return retval;
}
@@ -6319,9 +6317,7 @@ gda_connection_get_meta_store (GdaConnection *cnc)
ThreadConnectionData *cdata = NULL;
if (cnc->priv->is_thread_wrapper) {
cdata = (ThreadConnectionData*) gda_connection_internal_get_provider_data (cnc);
- g_assert (cdata);
-
- if (cdata->sub_connection->priv->meta_store) {
+ if (cdata && cdata->sub_connection->priv->meta_store) {
cnc->priv->meta_store = g_object_ref (cdata->sub_connection->priv->meta_store);
store = cnc->priv->meta_store;
}
diff --git a/libgda/sqlite/gda-sqlite-util.c b/libgda/sqlite/gda-sqlite-util.c
index 658619c..92f4db7 100644
--- a/libgda/sqlite/gda-sqlite-util.c
+++ b/libgda/sqlite/gda-sqlite-util.c
@@ -307,12 +307,8 @@ _gda_sqlite_identifier_quote (G_GNUC_UNUSED GdaServerProvider *provider, GdaConn
GdaSqlReservedKeywordsFunc kwfunc;
SqliteConnectionData *cdata = NULL;
- if (cnc) {
+ if (cnc)
cdata = (SqliteConnectionData*) gda_connection_internal_get_provider_data (cnc);
- if (!cdata)
- return NULL;
- }
-
kwfunc = _gda_sqlite_get_reserved_keyword_func ();
if (for_meta_store) {
diff --git a/libgda/thread-wrapper/gda-thread-provider.c b/libgda/thread-wrapper/gda-thread-provider.c
index 45dd92c..73cd443 100644
--- a/libgda/thread-wrapper/gda-thread-provider.c
+++ b/libgda/thread-wrapper/gda-thread-provider.c
@@ -1379,7 +1379,7 @@ gda_thread_provider_get_default_dbms_type (GdaServerProvider *provider, GdaConne
cdata = (ThreadConnectionData*) gda_connection_internal_get_provider_data (cnc);
if (!cdata)
- return FALSE;
+ return NULL;
wdata.prov = cdata->cnc_provider;
wdata.cnc = cdata->sub_connection;
diff --git a/providers/mysql/gda-mysql-provider.c b/providers/mysql/gda-mysql-provider.c
index aff5a23..18ac6b9 100644
--- a/providers/mysql/gda-mysql-provider.c
+++ b/providers/mysql/gda-mysql-provider.c
@@ -3028,11 +3028,10 @@ gda_mysql_identifier_quote (GdaServerProvider *provider, GdaConnection *cnc,
if (cnc) {
cdata = (MysqlConnectionData*) gda_connection_internal_get_provider_data (cnc);
- if (!cdata)
- return NULL;
- case_sensitive = cdata->reuseable->identifiers_case_sensitive;
+ if (cdata)
+ case_sensitive = cdata->reuseable->identifiers_case_sensitive;
}
- else if (((GdaMysqlProvider*) provider)->test_mode)
+ if (!cdata && ((GdaMysqlProvider*) provider)->test_mode)
case_sensitive = ((GdaMysqlProvider*) provider)->test_identifiers_case_sensitive;
kwfunc = _gda_mysql_reuseable_get_reserved_keywords_func
diff --git a/providers/oracle/gda-oracle-provider.c b/providers/oracle/gda-oracle-provider.c
index 4a013b5..734b4f4 100644
--- a/providers/oracle/gda-oracle-provider.c
+++ b/providers/oracle/gda-oracle-provider.c
@@ -782,7 +782,7 @@ gda_oracle_provider_get_server_version (GdaServerProvider *provider, GdaConnecti
cdata = (OracleConnectionData*) gda_connection_internal_get_provider_data (cnc);
if (!cdata)
- return FALSE;
+ return NULL;
return cdata->version;
}
@@ -2524,11 +2524,8 @@ gda_oracle_identifier_quote (GdaServerProvider *provider, GdaConnection *cnc,
GdaSqlReservedKeywordsFunc kwfunc;
OracleConnectionData *cdata = NULL;
- if (cnc) {
+ if (cnc)
cdata = (OracleConnectionData*) gda_connection_internal_get_provider_data (cnc);
- if (!cdata)
- return NULL;
- }
kwfunc = _gda_oracle_get_reserved_keyword_func (cdata);
diff --git a/providers/postgres/gda-postgres-handler-bin.c b/providers/postgres/gda-postgres-handler-bin.c
index d421dbe..df6e52d 100644
--- a/providers/postgres/gda-postgres-handler-bin.c
+++ b/providers/postgres/gda-postgres-handler-bin.c
@@ -193,10 +193,7 @@ gda_postgres_handler_bin_get_sql_from_value (GdaDataHandler *iface, const GValue
if (hdl->priv->cnc) {
g_return_val_if_fail (GDA_IS_CONNECTION (hdl->priv->cnc), NULL);
-
cdata = (PostgresConnectionData*) gda_connection_internal_get_provider_data (hdl->priv->cnc);
- if (!cdata)
- return FALSE;
}
if (value) {
diff --git a/providers/postgres/gda-postgres-provider.c b/providers/postgres/gda-postgres-provider.c
index 5c8585f..e407647 100644
--- a/providers/postgres/gda-postgres-provider.c
+++ b/providers/postgres/gda-postgres-provider.c
@@ -2538,11 +2538,8 @@ gda_postgresql_identifier_quote (G_GNUC_UNUSED GdaServerProvider *provider, GdaC
GdaSqlReservedKeywordsFunc kwfunc;
PostgresConnectionData *cdata = NULL;
- if (cnc) {
+ if (cnc)
cdata = (PostgresConnectionData*) gda_connection_internal_get_provider_data (cnc);
- if (!cdata)
- return NULL;
- }
kwfunc = _gda_postgres_reuseable_get_reserved_keywords_func
(cdata ? (GdaProviderReuseable*) cdata->reuseable : NULL);
diff --git a/providers/reuseable/mysql/gda-mysql-meta.c b/providers/reuseable/mysql/gda-mysql-meta.c
index a4a768d..c40c3f0 100644
--- a/providers/reuseable/mysql/gda-mysql-meta.c
+++ b/providers/reuseable/mysql/gda-mysql-meta.c
@@ -280,7 +280,7 @@ _gda_mysql_provider_meta_init (GdaServerProvider *provider)
#endif
}
-#define GDA_MYSQL_GET_REUSEABLE_DATA(cdata) (* ((GdaMysqlReuseable**) (cdata)))
+#define GDA_MYSQL_GET_REUSEABLE_DATA(cdata) ((cdata) ? * ((GdaMysqlReuseable**) (cdata)) : NULL)
gboolean
_gda_mysql_meta__info (G_GNUC_UNUSED GdaServerProvider *prov,
diff --git a/providers/reuseable/postgres/gda-postgres-meta.c b/providers/reuseable/postgres/gda-postgres-meta.c
index 1a46a36..2d83e1c 100644
--- a/providers/reuseable/postgres/gda-postgres-meta.c
+++ b/providers/reuseable/postgres/gda-postgres-meta.c
@@ -311,7 +311,7 @@ _gda_postgres_provider_meta_init (GdaServerProvider *provider)
#endif
}
-#define GDA_POSTGRES_GET_REUSEABLE_DATA(cdata) (* ((GdaPostgresReuseable**) (cdata)))
+#define GDA_POSTGRES_GET_REUSEABLE_DATA(cdata) ((cdata) ? * ((GdaPostgresReuseable**) (cdata)) : NULL)
gboolean
_gda_postgres_meta__info (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnection *cnc,
diff --git a/providers/skel-implementation/capi/gda-capi-provider.c b/providers/skel-implementation/capi/gda-capi-provider.c
index bf1a451..d1d8323 100644
--- a/providers/skel-implementation/capi/gda-capi-provider.c
+++ b/providers/skel-implementation/capi/gda-capi-provider.c
@@ -424,7 +424,7 @@ gda_capi_provider_get_server_version (GdaServerProvider *provider, GdaConnection
cdata = (CapiConnectionData*) gda_connection_internal_get_provider_data (cnc);
if (!cdata)
- return FALSE;
+ return NULL;
TO_IMPLEMENT;
return NULL;
}
diff --git a/providers/web/gda-web-provider.c b/providers/web/gda-web-provider.c
index 584b5de..4571991 100644
--- a/providers/web/gda-web-provider.c
+++ b/providers/web/gda-web-provider.c
@@ -561,7 +561,7 @@ gda_web_provider_get_server_version (GdaServerProvider *provider, GdaConnection
cdata = (WebConnectionData*) gda_connection_internal_get_provider_data (cnc);
if (!cdata)
- return FALSE;
+ return NULL;
return cdata->server_version;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]