[libgda] Added the GDA_CONNECTION_FEATURE_ASYNC_EXEC option to test if a connection supports async. execution
- From: Vivien Malerba <vivien src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] Added the GDA_CONNECTION_FEATURE_ASYNC_EXEC option to test if a connection supports async. execution
- Date: Mon, 11 Mar 2013 21:10:23 +0000 (UTC)
commit ec24a4358a8c31ba94b9dcaf1b34a2f73ac423a1
Author: Vivien Malerba <malerba gnome-db org>
Date: Mon Mar 11 21:59:37 2013 +0100
Added the GDA_CONNECTION_FEATURE_ASYNC_EXEC option to test if a connection supports async. execution
libgda/gda-connection.c | 13 ++++++++++++-
libgda/gda-connection.h | 9 ++++++---
libgda/gda-server-provider.c | 3 +++
3 files changed, 21 insertions(+), 4 deletions(-)
---
diff --git a/libgda/gda-connection.c b/libgda/gda-connection.c
index b4960ad..7b5ce8b 100644
--- a/libgda/gda-connection.c
+++ b/libgda/gda-connection.c
@@ -3092,7 +3092,7 @@ get_task_index (GdaConnection *cnc, guint task_id, gboolean *out_completed, gboo
}
/*
- * This callback is called from the GdaServerProvider object
+ * This callback is called from the GdaServerProvider object, from the handle_async() method
*/
static void
async_stmt_exec_cb (G_GNUC_UNUSED GdaServerProvider *provider, GdaConnection *cnc, guint task_id,
@@ -3257,6 +3257,14 @@ gda_connection_async_statement_execute (GdaConnection *cnc, GdaStatement *stmt,
return 0;
}
+ if (!PROV_CLASS (cnc->priv->provider_obj)->handle_async) {
+ g_set_error (error, GDA_CONNECTION_ERROR, GDA_CONNECTION_UNSUPPORTED_ASYNC_EXEC_ERROR,
+ _("Asynchronous execution is not supported"));
+ gda_connection_unlock (GDA_LOCKABLE (cnc));
+ g_object_unref ((GObject*) cnc);
+ return 0;
+ }
+
id = cnc->priv->next_task_id ++;
task = cnc_task_new (id, stmt, model_usage, col_types, params, need_last_insert_row);
g_array_append_val (cnc->priv->waiting_tasks, task);
@@ -3337,6 +3345,7 @@ gda_connection_async_fetch_result (GdaConnection *cnc, guint task_id, GdaSet **l
gboolean is_completed;
GObject *obj = NULL;
g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
+ g_return_val_if_fail (cnc->priv->provider_obj, NULL);
if (! gda_connection_trylock ((GdaLockable*) cnc)) {
g_set_error (error, GDA_CONNECTION_ERROR, GDA_CONNECTION_CANT_LOCK_ERROR,
@@ -4337,6 +4346,8 @@ gda_connection_supports_feature (GdaConnection *cnc, GdaConnectionFeature featur
g_return_val_if_fail (GDA_IS_CONNECTION (cnc), FALSE);
g_return_val_if_fail (cnc->priv->provider_obj, FALSE);
+ if (feature == GDA_CONNECTION_FEATURE_ASYNC_EXEC)
+ return PROV_CLASS (cnc->priv->provider_obj)->handle_async ? TRUE : FALSE;
return gda_server_provider_supports_feature (cnc->priv->provider_obj, cnc, feature);
}
diff --git a/libgda/gda-connection.h b/libgda/gda-connection.h
index 67f48d1..3140121 100644
--- a/libgda/gda-connection.h
+++ b/libgda/gda-connection.h
@@ -63,7 +63,8 @@ typedef enum {
GDA_CONNECTION_TASK_NOT_FOUND_ERROR,
GDA_CONNECTION_UNSUPPORTED_THREADS_ERROR,
GDA_CONNECTION_CLOSED_ERROR,
- GDA_CONNECTION_META_DATA_CONTEXT_ERROR
+ GDA_CONNECTION_META_DATA_CONTEXT_ERROR,
+ GDA_CONNECTION_UNSUPPORTED_ASYNC_EXEC_ERROR
} GdaConnectionError;
#define GDA_CONNECTION_NONEXIST_DSN_ERROR GDA_CONNECTION_DSN_NOT_FOUND_ERROR
@@ -218,6 +219,7 @@ typedef enum {
* @GDA_CONNECTION_FEATURE_VIEWS: test for views support
* @GDA_CONNECTION_FEATURE_XA_TRANSACTIONS: test for distributed transactions support
* @GDA_CONNECTION_FEATURE_MULTI_THREADING: test for native multi-threading support
+ * @GDA_CONNECTION_FEATURE_ASYNC_EXEC: test if connection supports asynchronous execution
* @GDA_CONNECTION_FEATURE_LAST: not used
*
* Used in gda_connection_supports_feature() and gda_server_provider_supports_feature() to test if a
connection
@@ -242,6 +244,7 @@ typedef enum {
GDA_CONNECTION_FEATURE_XA_TRANSACTIONS,
GDA_CONNECTION_FEATURE_MULTI_THREADING,
+ GDA_CONNECTION_FEATURE_ASYNC_EXEC,
GDA_CONNECTION_FEATURE_LAST
} GdaConnectionFeature;
@@ -337,7 +340,7 @@ gchar *gda_connection_quote_sql_identifier (GdaConnection *cnc, co
gchar *gda_connection_statement_to_sql (GdaConnection *cnc,
GdaStatement *stmt, GdaSet *params,
GdaStatementSqlFlag flags,
GSList **params_used, GError **error);
-/* synchronous exec */
+/* synchronous execution */
gboolean gda_connection_statement_prepare (GdaConnection *cnc,
GdaStatement *stmt, GError **error);
GObject *gda_connection_statement_execute (GdaConnection *cnc, GdaStatement *stmt, GdaSet
*params,
@@ -354,7 +357,7 @@ GdaDataModel *gda_connection_statement_execute_select_full (GdaConnection
gint gda_connection_statement_execute_non_select (GdaConnection *cnc, GdaStatement *stmt,
GdaSet *params, GdaSet **last_insert_row,
GError **error);
-/* Async. execution */
+/* asynchronous execution */
guint gda_connection_async_statement_execute (GdaConnection *cnc, GdaStatement *stmt, GdaSet
*params,
GdaStatementModelUsage model_usage, GType
*col_types,
gboolean need_last_insert_row,
diff --git a/libgda/gda-server-provider.c b/libgda/gda-server-provider.c
index 64b21cf..126e10d 100644
--- a/libgda/gda-server-provider.c
+++ b/libgda/gda-server-provider.c
@@ -656,6 +656,9 @@ gda_server_provider_supports_feature (GdaServerProvider *provider, GdaConnection
g_return_val_if_fail (GDA_IS_SERVER_PROVIDER (provider), FALSE);
g_return_val_if_fail (!cnc || GDA_IS_CONNECTION (cnc), FALSE);
+ if (feature == GDA_CONNECTION_FEATURE_ASYNC_EXEC)
+ return CLASS(provider)->handle_async ? TRUE : FALSE;;
+
if (cnc)
gda_lockable_lock ((GdaLockable*) cnc);
if (CLASS (provider)->supports_feature)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]