[libgda] Implementing missing features in GdaConnection for the new way to handle events
- From: Vivien Malerba <vivien src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] Implementing missing features in GdaConnection for the new way to handle events
- Date: Mon, 12 Jul 2010 20:20:45 +0000 (UTC)
commit 39f73be8a42334ab64f410903d8d65b95ab3459a
Author: Vivien Malerba <malerba gnome-db org>
Date: Mon Jul 12 19:02:05 2010 +0200
Implementing missing features in GdaConnection for the new way to handle events
* added a new "events-history-size" property to allow one to grow or
reduce the number of GdaConnectionEvent objects kept
* GdaConnection now behaves like before from the outside
* database providers now use the new gda_connection_point_available_event() method
* deprecated gda_connection_event_new()
doc/C/tmpl/gda-connection.sgml | 5 +
libgda/gda-connection-event.c | 5 +
libgda/gda-connection.c | 118 ++++++++++++++++++--
libgda/libgda.symbols | 1 +
providers/jdbc/gda-jdbc-provider.c | 18 ++--
providers/mysql/gda-mysql-provider.c | 20 ++--
providers/mysql/gda-mysql-util.c | 4 +-
providers/oracle/gda-oracle-provider.c | 14 +-
providers/oracle/gda-oracle-util.c | 12 +-
providers/oracle/gda-oracle-util.h | 2 +-
providers/postgres/gda-postgres-provider.c | 30 +++--
providers/postgres/gda-postgres-util.c | 6 +-
.../skel-implementation/capi/gda-capi-provider.c | 10 +-
providers/web/gda-web-provider.c | 12 +-
14 files changed, 183 insertions(+), 74 deletions(-)
---
diff --git a/doc/C/tmpl/gda-connection.sgml b/doc/C/tmpl/gda-connection.sgml
index 24ef318..c69338d 100644
--- a/doc/C/tmpl/gda-connection.sgml
+++ b/doc/C/tmpl/gda-connection.sgml
@@ -133,6 +133,11 @@ A connection to a database
</para>
+<!-- ##### ARG GdaConnection:events-history-size ##### -->
+<para>
+
+</para>
+
<!-- ##### ARG GdaConnection:is-wrapper ##### -->
<para>
diff --git a/libgda/gda-connection-event.c b/libgda/gda-connection-event.c
index 90358ac..fb5f83e 100644
--- a/libgda/gda-connection-event.c
+++ b/libgda/gda-connection-event.c
@@ -117,6 +117,8 @@ gda_connection_event_init (GdaConnectionEvent *event, GdaConnectionEventClass *k
* events from the different providers to the clients.
*
* Returns: the event object.
+ *
+ * Deprecated: 4.2: use gda_connection_point_available_event() instead
*/
GdaConnectionEvent *
gda_connection_event_new (GdaConnectionEventType type)
@@ -124,6 +126,7 @@ gda_connection_event_new (GdaConnectionEventType type)
GdaConnectionEvent *event;
event = GDA_CONNECTION_EVENT (g_object_new (GDA_TYPE_CONNECTION_EVENT, "type", (int)type, NULL));
+ g_print ("Createdevent %p\n", event);
return event;
}
@@ -147,6 +150,8 @@ gda_connection_event_finalize (GObject *object)
/* chain to parent class */
parent_class->finalize (object);
+
+ g_print ("Finalizedevent %p\n", event);
}
static void gda_connection_event_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
diff --git a/libgda/gda-connection.c b/libgda/gda-connection.c
index 6ecf9c8..6eed925 100644
--- a/libgda/gda-connection.c
+++ b/libgda/gda-connection.c
@@ -54,6 +54,9 @@
#include <unistd.h>
#define PROV_CLASS(provider) (GDA_SERVER_PROVIDER_CLASS (G_OBJECT_GET_CLASS (provider)))
+
+/* number of GdaConnectionEvent kept by each connection. Should be enough to avoid losing any
+ * event, considering that the events are reseted after each statement execution */
#define EVENTS_ARRAY_SIZE 5
struct _GdaConnectionPrivate {
@@ -68,6 +71,7 @@ struct _GdaConnectionPrivate {
GdaMetaStore *meta_store;
+ gboolean auto_clear_events; /* TRUE if events_list is cleared before any statement execution */
GdaConnectionEvent **events_array; /* circular array */
gint events_array_size;
gboolean events_array_full;
@@ -138,6 +142,7 @@ static gboolean gda_connection_trylock (GdaLockable *lockable);
static void gda_connection_unlock (GdaLockable *lockable);
static void update_meta_store_after_statement_exec (GdaConnection *cnc, GdaStatement *stmt, GdaSet *params);
+static void change_events_array_max_size (GdaConnection *cnc, gint size);
enum {
ERROR,
@@ -163,7 +168,8 @@ enum
PROP_META_STORE,
PROP_THREAD_OWNER,
PROP_IS_THREAD_WRAPPER,
- PROP_MONITOR_WRAPPED_IN_MAINLOOP
+ PROP_MONITOR_WRAPPED_IN_MAINLOOP,
+ PROP_EVENTS_HISTORY_SIZE
};
static GObjectClass *parent_class = NULL;
@@ -352,6 +358,20 @@ gda_connection_class_init (GdaConnectionClass *klass)
_("Make the connection set up a monitoring function in the mainloop to monitor the wrapped connection"),
FALSE,
(G_PARAM_READABLE | G_PARAM_WRITABLE)));
+
+ /**
+ * GdaConnection:events-history-size:
+ *
+ * Defines the number of #GdaConnectionEvent objects kept in memory which can
+ * be fetched using gda_connection_get_events().
+ *
+ * Since: 4.2
+ */
+ g_object_class_install_property (object_class, PROP_EVENTS_HISTORY_SIZE,
+ g_param_spec_int ("events-history-size", NULL,
+ _(""), EVENTS_ARRAY_SIZE, G_MAXINT,
+ EVENTS_ARRAY_SIZE,
+ (G_PARAM_READABLE | G_PARAM_WRITABLE)));
object_class->dispose = gda_connection_dispose;
object_class->finalize = gda_connection_finalize;
@@ -403,6 +423,7 @@ gda_connection_init (GdaConnection *cnc, GdaConnectionClass *klass)
cnc->priv->cnc_string = NULL;
cnc->priv->auth_string = NULL;
cnc->priv->is_open = FALSE;
+ cnc->priv->auto_clear_events = TRUE;
cnc->priv->events_array_size = EVENTS_ARRAY_SIZE;
cnc->priv->events_array = g_new0 (GdaConnectionEvent*, EVENTS_ARRAY_SIZE);
cnc->priv->events_array_full = FALSE;
@@ -447,6 +468,7 @@ gda_connection_dispose (GObject *object)
}
if (cnc->priv->events_list) {
+ g_list_foreach (cnc->priv->events_list, (GFunc) g_object_unref, NULL);
g_list_free (cnc->priv->events_list);
cnc->priv->events_list = NULL;
}
@@ -754,6 +776,11 @@ gda_connection_set_property (GObject *object,
}
}
break;
+ case PROP_EVENTS_HISTORY_SIZE:
+ gda_connection_lock ((GdaLockable*) cnc);
+ change_events_array_max_size (cnc, g_value_get_int (value));
+ gda_connection_unlock ((GdaLockable*) cnc);
+ break;
}
}
}
@@ -794,6 +821,9 @@ gda_connection_get_property (GObject *object,
g_value_set_boolean (value, cnc->priv->is_thread_wrapper && (cnc->priv->monitor_id > 0) ?
TRUE : FALSE);
break;
+ case PROP_EVENTS_HISTORY_SIZE:
+ g_value_set_int (value, cnc->priv->events_array_size);
+ break;
}
}
}
@@ -1699,25 +1729,31 @@ gda_connection_get_authentication (GdaConnection *cnc)
* @type: a #GdaConnectionEventType
*
* Use this method to get a pointer to the next available connection event which can then be customized
- * and taken into account using gda_connection_add_event().
+ * and taken into account using gda_connection_add_event(). This method is a drop-in replacament
+ * for gda_connection_event_new() which improves performances by reusing as much as possible
+ * #GdaConnectionEvent objects. Newly written database providers should use this method.
*
- * Returns: (transfer none): a pointer to the next available connection event, or %NULL if event should
+ * Returns: (transfer full): a pointer to the next available connection event, or %NULL if event should
* be ignored
+ *
+ * Since: 4.2
*/
GdaConnectionEvent *
gda_connection_point_available_event (GdaConnection *cnc, GdaConnectionEventType type)
{
g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
+ /* ownership is transfered to the caller ! */
+
GdaConnectionEvent *eev;
eev = cnc->priv->events_array [cnc->priv->events_array_next];
- if (!eev) {
+ if (!eev)
eev = gda_connection_event_new (type);
- cnc->priv->events_array [cnc->priv->events_array_next] = eev;
- }
- else
+ else {
gda_connection_event_set_event_type (eev, type);
-
+ cnc->priv->events_array [cnc->priv->events_array_next] = NULL;
+ }
+
return eev;
}
@@ -1765,11 +1801,12 @@ gda_connection_add_event (GdaConnection *cnc, GdaConnectionEvent *event)
/* clear external list of events */
if (cnc->priv->events_list) {
+ g_list_foreach (cnc->priv->events_list, (GFunc) g_object_unref, NULL);
g_list_free (cnc->priv->events_list);
cnc->priv->events_list = NULL;
}
- /* add event */
+ /* add event, ownership is transfered to @cnc */
GdaConnectionEvent *eev;
eev = cnc->priv->events_array [cnc->priv->events_array_next];
if (eev != event) {
@@ -1857,6 +1894,15 @@ gda_connection_add_event_string (GdaConnection *cnc, const gchar *str, ...)
return error;
}
+static void
+_clear_connection_events (GdaConnection *locked_cnc)
+{
+ if (locked_cnc->priv->auto_clear_events) {
+ locked_cnc->priv->events_array_full = FALSE;
+ locked_cnc->priv->events_array_next = 0;
+ }
+}
+
/**
* gda_connection_clear_events_list:
* @cnc: a #GdaConnection object.
@@ -1869,8 +1915,7 @@ gda_connection_clear_events_list (GdaConnection *cnc)
{
g_return_if_fail (GDA_IS_CONNECTION (cnc));
gda_connection_lock ((GdaLockable*) cnc);
- cnc->priv->events_array_full = FALSE;
- cnc->priv->events_array_next = 0;
+ _clear_connection_events (cnc);
gda_connection_unlock ((GdaLockable*) cnc);
}
@@ -1918,7 +1963,9 @@ gda_connection_perform_operation (GdaConnection *cnc, GdaServerOperation *op, GE
g_return_val_if_fail (cnc->priv->provider_obj, FALSE);
g_return_val_if_fail (GDA_IS_SERVER_OPERATION (op), FALSE);
+ cnc->priv->auto_clear_events = FALSE;
retval = gda_server_provider_perform_operation (cnc->priv->provider_obj, cnc, op, error);
+ cnc->priv->auto_clear_events = TRUE;
return retval;
}
@@ -1942,6 +1989,37 @@ gda_connection_create_parser (GdaConnection *cnc)
return gda_server_provider_create_parser (cnc->priv->provider_obj, cnc);
}
+/*
+ * Also resets the events list (as perceived when calling gda_connection_get_events()
+ */
+static void
+change_events_array_max_size (GdaConnection *cnc, gint size)
+{
+ size ++; /* add 1 to compensate the "lost" slot when rotating the events array */
+ if (size == cnc->priv->events_array_size)
+ return;
+
+ if (size > cnc->priv->events_array_size) {
+ gint i;
+ cnc->priv->events_array = g_renew (GdaConnectionEvent*, cnc->priv->events_array,
+ size);
+ for (i = cnc->priv->events_array_size; i < size; i++)
+ cnc->priv->events_array [i] = NULL;
+ }
+ else if (size >= EVENTS_ARRAY_SIZE) {
+ gint i;
+ for (i = size; i < cnc->priv->events_array_size; i++) {
+ if (cnc->priv->events_array [i])
+ g_object_unref (cnc->priv->events_array [i]);
+ }
+ cnc->priv->events_array = g_renew (GdaConnectionEvent*, cnc->priv->events_array,
+ size);
+ }
+ cnc->priv->events_array_size = size;
+ cnc->priv->events_array_full = FALSE;
+ cnc->priv->events_array_next = 0;
+}
+
/**
* gda_connection_batch_execute:
* @cnc: a #GdaConnection object
@@ -1969,7 +2047,14 @@ gda_connection_batch_execute (GdaConnection *cnc, GdaBatch *batch, GdaSet *param
g_return_val_if_fail (GDA_IS_BATCH (batch), NULL);
gda_connection_lock ((GdaLockable*) cnc);
- for (stmt_list = (GSList*) gda_batch_get_statements (batch); stmt_list; stmt_list = stmt_list->next) {
+ cnc->priv->auto_clear_events = FALSE;
+
+ /* increase the size of cnc->priv->events_array to be able to store all the
+ * connection events */
+ stmt_list = (GSList*) gda_batch_get_statements (batch);
+ change_events_array_max_size (cnc, g_slist_length (stmt_list) * 2);
+
+ for (; stmt_list; stmt_list = stmt_list->next) {
GObject *obj;
obj = gda_connection_statement_execute (cnc, GDA_STATEMENT (stmt_list->data), params,
model_usage, NULL, error);
@@ -1977,6 +2062,7 @@ gda_connection_batch_execute (GdaConnection *cnc, GdaBatch *batch, GdaSet *param
break;
retlist = g_slist_prepend (retlist, obj);
}
+ cnc->priv->auto_clear_events = TRUE;
gda_connection_unlock ((GdaLockable*) cnc);
return g_slist_reverse (retlist);
@@ -2488,6 +2574,9 @@ gda_connection_statement_execute_v (GdaConnection *cnc, GdaStatement *stmt, GdaS
g_object_ref ((GObject*) cnc);
gda_connection_lock ((GdaLockable*) cnc);
+
+ _clear_connection_events (cnc);
+
if (last_inserted_row)
*last_inserted_row = NULL;
@@ -2760,6 +2849,8 @@ gda_connection_statement_execute_select_fullv (GdaConnection *cnc, GdaStatement
g_object_ref ((GObject*) cnc);
gda_connection_lock ((GdaLockable*) cnc);
+ _clear_connection_events (cnc);
+
if (!cnc->priv->is_open) {
g_set_error (error, GDA_CONNECTION_ERROR, GDA_CONNECTION_CLOSED_ERROR,
_("Connection is closed"));
@@ -4676,6 +4767,9 @@ gda_connection_get_events (GdaConnection *cnc)
if (cnc->priv->events_list)
return cnc->priv->events_list;
+
+ /* a new list of the GdaConnectionEvent objects is created, the
+ * ownership of each GdaConnectionEvent object is transfered to the list */
GList *list = NULL;
if (cnc->priv->events_array_full) {
gint i;
diff --git a/libgda/libgda.symbols b/libgda/libgda.symbols
index 15db331..a3393b1 100644
--- a/libgda/libgda.symbols
+++ b/libgda/libgda.symbols
@@ -153,6 +153,7 @@
gda_connection_open_sqlite
gda_connection_options_get_type
gda_connection_perform_operation
+ gda_connection_point_available_event
gda_connection_quote_sql_identifier
gda_connection_repetitive_statement_execute
gda_connection_rollback_savepoint
diff --git a/providers/jdbc/gda-jdbc-provider.c b/providers/jdbc/gda-jdbc-provider.c
index 95fff4f..d00c193 100644
--- a/providers/jdbc/gda-jdbc-provider.c
+++ b/providers/jdbc/gda-jdbc-provider.c
@@ -1,5 +1,5 @@
/* GDA Jdbc provider
- * Copyright (C) 2008 - 2009 The GNOME Foundation.
+ * Copyright (C) 2008 - 2010 The GNOME Foundation.
*
* AUTHORS:
* Vivien Malerba <malerba gnome-db org>
@@ -1292,7 +1292,7 @@ gda_jdbc_provider_statement_execute (GdaServerProvider *provider, GdaConnection
/* find requested parameter */
if (!params) {
- event = gda_connection_event_new (GDA_CONNECTION_EVENT_ERROR);
+ event = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_ERROR);
gda_connection_event_set_description (event, _("Missing parameter(s) to execute query"));
g_set_error (error, GDA_SERVER_PROVIDER_ERROR,
GDA_SERVER_PROVIDER_MISSING_PARAM_ERROR,
@@ -1312,7 +1312,7 @@ gda_jdbc_provider_statement_execute (GdaServerProvider *provider, GdaConnection
if (! allow_noparam) {
gchar *str;
str = g_strdup_printf (_("Missing parameter '%s' to execute query"), pname);
- event = gda_connection_event_new (GDA_CONNECTION_EVENT_ERROR);
+ event = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_ERROR);
gda_connection_event_set_description (event, str);
g_set_error (error, GDA_SERVER_PROVIDER_ERROR,
GDA_SERVER_PROVIDER_MISSING_PARAM_ERROR, "%s", str);
@@ -1324,7 +1324,7 @@ gda_jdbc_provider_statement_execute (GdaServerProvider *provider, GdaConnection
jexec_res = jni_wrapper_method_call (jenv, GdaJPStmt__setParameterValue,
ps->pstmt_obj, NULL, NULL, &lerror, i, 0);
if (!jexec_res) {
- event = gda_connection_event_new (GDA_CONNECTION_EVENT_ERROR);
+ event = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_ERROR);
if (lerror)
gda_connection_event_set_description (event,
lerror->message ? lerror->message : _("No detail"));
@@ -1341,7 +1341,7 @@ gda_jdbc_provider_statement_execute (GdaServerProvider *provider, GdaConnection
if (! allow_noparam) {
gchar *str;
str = g_strdup_printf (_("Parameter '%s' is invalid"), pname);
- event = gda_connection_event_new (GDA_CONNECTION_EVENT_ERROR);
+ event = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_ERROR);
gda_connection_event_set_description (event, str);
g_set_error (error, GDA_SERVER_PROVIDER_ERROR,
GDA_SERVER_PROVIDER_MISSING_PARAM_ERROR, "%s", str);
@@ -1353,7 +1353,7 @@ gda_jdbc_provider_statement_execute (GdaServerProvider *provider, GdaConnection
jexec_res = jni_wrapper_method_call (jenv, GdaJPStmt__setParameterValue,
ps->pstmt_obj, NULL, NULL, &lerror, i, 0);
if (!jexec_res) {
- event = gda_connection_event_new (GDA_CONNECTION_EVENT_ERROR);
+ event = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_ERROR);
if (lerror)
gda_connection_event_set_description (event,
lerror->message ? lerror->message : _("No detail"));
@@ -1372,7 +1372,7 @@ gda_jdbc_provider_statement_execute (GdaServerProvider *provider, GdaConnection
ps->pstmt_obj, NULL, NULL, &lerror, i,
(G_VALUE_TYPE (value) == GDA_TYPE_NULL) ? (glong) 0 : (glong) value);
if (!jexec_res) {
- event = gda_connection_event_new (GDA_CONNECTION_EVENT_ERROR);
+ event = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_ERROR);
if (lerror)
gda_connection_event_set_description (event,
lerror->message ? lerror->message : _("No detail"));
@@ -1391,7 +1391,7 @@ gda_jdbc_provider_statement_execute (GdaServerProvider *provider, GdaConnection
}
/* add a connection event for the execution */
- event = gda_connection_event_new (GDA_CONNECTION_EVENT_COMMAND);
+ event = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_COMMAND);
gda_connection_event_set_description (event, _GDA_PSTMT (ps)->sql);
gda_connection_add_event (cnc, event);
@@ -1487,7 +1487,7 @@ gda_jdbc_provider_statement_execute (GdaServerProvider *provider, GdaConnection
gchar *str;
GdaConnectionEvent *event;
- event = gda_connection_event_new (GDA_CONNECTION_EVENT_NOTICE);
+ event = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_NOTICE);
str = g_strdup (PQcmdStatus (pg_res));
gda_connection_event_set_description (event, str);
g_free (str);
diff --git a/providers/mysql/gda-mysql-provider.c b/providers/mysql/gda-mysql-provider.c
index 8975d62..099aa4d 100644
--- a/providers/mysql/gda-mysql-provider.c
+++ b/providers/mysql/gda-mysql-provider.c
@@ -1,5 +1,5 @@
/* GDA Mysql provider
- * Copyright (C) 2008 - 2009 The GNOME Foundation.
+ * Copyright (C) 2008 - 2010 The GNOME Foundation.
*
* AUTHORS:
* Carlos Savoretti <csavoretti gmail com>
@@ -539,7 +539,7 @@ gda_mysql_real_query_wrap (GdaConnection *cnc, MYSQL *mysql, const char *stmt_st
{
GdaConnectionEvent *event;
- event = gda_connection_event_new (GDA_CONNECTION_EVENT_COMMAND);
+ event = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_COMMAND);
gda_connection_event_set_description (event, stmt_str);
gda_connection_add_event (cnc, event);
@@ -615,7 +615,7 @@ gda_mysql_provider_open_connection (GdaServerProvider *provider,
(compress && ((*compress == 't') || (*compress == 'T'))) ? TRUE : FALSE,
&error);
if (!mysql) {
- GdaConnectionEvent *event_error = gda_connection_event_new (GDA_CONNECTION_EVENT_ERROR);
+ GdaConnectionEvent *event_error = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_ERROR);
gda_connection_event_set_sqlstate (event_error, _("Unknown"));
gda_connection_event_set_description (event_error,
error && error->message ? error->message :
@@ -2052,7 +2052,7 @@ gda_mysql_provider_statement_execute (GdaServerProvider *provider,
/* find requested parameter */
if (!params) {
- event = gda_connection_event_new (GDA_CONNECTION_EVENT_ERROR);
+ event = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_ERROR);
gda_connection_event_set_description (event, _("Missing parameter(s) to execute query"));
g_set_error (error, GDA_SERVER_PROVIDER_ERROR,
GDA_SERVER_PROVIDER_MISSING_PARAM_ERROR,
@@ -2072,7 +2072,7 @@ gda_mysql_provider_statement_execute (GdaServerProvider *provider,
if (!allow_noparam) {
gchar *str;
str = g_strdup_printf (_("Missing parameter '%s' to execute query"), pname);
- event = gda_connection_event_new (GDA_CONNECTION_EVENT_ERROR);
+ event = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_ERROR);
gda_connection_event_set_description (event, str);
g_set_error (error, GDA_SERVER_PROVIDER_ERROR,
GDA_SERVER_PROVIDER_MISSING_PARAM_ERROR, "%s", str);
@@ -2092,7 +2092,7 @@ gda_mysql_provider_statement_execute (GdaServerProvider *provider,
if (!allow_noparam) {
gchar *str;
str = g_strdup_printf (_("Parameter '%s' is invalid"), pname);
- event = gda_connection_event_new (GDA_CONNECTION_EVENT_ERROR);
+ event = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_ERROR);
gda_connection_event_set_description (event, str);
g_set_error (error, GDA_SERVER_PROVIDER_ERROR,
GDA_SERVER_PROVIDER_MISSING_PARAM_ERROR, "%s", str);
@@ -2225,7 +2225,7 @@ gda_mysql_provider_statement_execute (GdaServerProvider *provider,
str = _("BLOB is too big");
if (str) {
- event = gda_connection_event_new (GDA_CONNECTION_EVENT_ERROR);
+ event = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_ERROR);
gda_connection_event_set_description (event, str);
g_set_error (error, GDA_SERVER_PROVIDER_ERROR,
GDA_SERVER_PROVIDER_DATA_ERROR, "%s", str);
@@ -2261,7 +2261,7 @@ gda_mysql_provider_statement_execute (GdaServerProvider *provider,
G_VALUE_TYPE (value));
if (data_handler == NULL) {
/* there is an error here */
- event = gda_connection_event_new (GDA_CONNECTION_EVENT_ERROR);
+ event = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_ERROR);
gda_connection_event_set_description (event, str);
g_set_error (error, GDA_SERVER_PROVIDER_ERROR,
GDA_SERVER_PROVIDER_DATA_ERROR, "%s", str);
@@ -2310,7 +2310,7 @@ gda_mysql_provider_statement_execute (GdaServerProvider *provider,
}
/* add a connection event for the execution */
- event = gda_connection_event_new (GDA_CONNECTION_EVENT_COMMAND);
+ event = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_COMMAND);
gda_connection_event_set_description (event, _GDA_PSTMT (ps)->sql);
gda_connection_add_event (cnc, event);
@@ -2385,7 +2385,7 @@ gda_mysql_provider_statement_execute (GdaServerProvider *provider,
if (affected_rows >= 0) {
GdaConnectionEvent *event;
gchar *str;
- event = gda_connection_event_new (GDA_CONNECTION_EVENT_NOTICE);
+ event = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_NOTICE);
str = g_strdup_printf ("%llu", affected_rows);
gda_connection_event_set_description (event, str);
g_free (str);
diff --git a/providers/mysql/gda-mysql-util.c b/providers/mysql/gda-mysql-util.c
index 98ad113..3346443 100644
--- a/providers/mysql/gda-mysql-util.c
+++ b/providers/mysql/gda-mysql-util.c
@@ -1,5 +1,5 @@
/* GDA mysql provider
- * Copyright (C) 1998 - 2008 The GNOME Foundation.
+ * Copyright (C) 1998 - 2010 The GNOME Foundation.
*
* AUTHORS:
* Vivien Malerba <malerba gnome-db org>
@@ -37,7 +37,7 @@ _gda_mysql_make_error (GdaConnection *cnc,
GError **error)
{
GdaConnectionEvent *event_error =
- gda_connection_event_new (GDA_CONNECTION_EVENT_ERROR);
+ gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_ERROR);
if (mysql) {
gda_connection_event_set_sqlstate
(event_error, mysql_sqlstate (mysql));
diff --git a/providers/oracle/gda-oracle-provider.c b/providers/oracle/gda-oracle-provider.c
index 8bf66b4..ec607b8 100644
--- a/providers/oracle/gda-oracle-provider.c
+++ b/providers/oracle/gda-oracle-provider.c
@@ -1,5 +1,5 @@
/* GDA Oracle provider
- * Copyright (C) 2009 The GNOME Foundation.
+ * Copyright (C) 2009 - 2010 The GNOME Foundation.
*
* AUTHORS:
* Rodrigo Moya <rodrigo gnome-db org>
@@ -740,7 +740,7 @@ gda_oracle_provider_close_connection (GdaServerProvider *provider, GdaConnection
cdata->hsession,
OCI_DEFAULT))) {
gda_connection_add_event (cnc,
- _gda_oracle_make_error (cdata->herr, OCI_HTYPE_ERROR, __FILE__, __LINE__));
+ _gda_oracle_make_error (cnc, cdata->herr, OCI_HTYPE_ERROR, __FILE__, __LINE__));
return FALSE;
}
@@ -1777,7 +1777,7 @@ gda_oracle_provider_statement_execute (GdaServerProvider *provider, GdaConnectio
/* find requested parameter */
if (!params) {
- event = gda_connection_event_new (GDA_CONNECTION_EVENT_ERROR);
+ event = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_ERROR);
gda_connection_event_set_description (event, _("Missing parameter(s) to execute query"));
g_set_error (error, GDA_SERVER_PROVIDER_ERROR,
GDA_SERVER_PROVIDER_MISSING_PARAM_ERROR,
@@ -1800,7 +1800,7 @@ gda_oracle_provider_statement_execute (GdaServerProvider *provider, GdaConnectio
if (! allow_noparam) {
gchar *str;
str = g_strdup_printf (_("Missing parameter '%s' to execute query"), pname);
- event = gda_connection_event_new (GDA_CONNECTION_EVENT_ERROR);
+ event = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_ERROR);
gda_connection_event_set_description (event, str);
g_set_error (error, GDA_SERVER_PROVIDER_ERROR,
GDA_SERVER_PROVIDER_MISSING_PARAM_ERROR, "%s", str);
@@ -1820,7 +1820,7 @@ gda_oracle_provider_statement_execute (GdaServerProvider *provider, GdaConnectio
if (! allow_noparam) {
gchar *str;
str = g_strdup_printf (_("Parameter '%s' is invalid"), pname);
- event = gda_connection_event_new (GDA_CONNECTION_EVENT_ERROR);
+ event = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_ERROR);
gda_connection_event_set_description (event, str);
g_set_error (error, GDA_SERVER_PROVIDER_ERROR,
GDA_SERVER_PROVIDER_MISSING_PARAM_ERROR, "%s", str);
@@ -1869,7 +1869,7 @@ gda_oracle_provider_statement_execute (GdaServerProvider *provider, GdaConnectio
}
/* add a connection event for the execution */
- event = gda_connection_event_new (GDA_CONNECTION_EVENT_COMMAND);
+ event = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_COMMAND);
gda_connection_event_set_description (event, _GDA_PSTMT (ps)->sql);
gda_connection_add_event (cnc, event);
event = NULL;
@@ -2043,7 +2043,7 @@ gda_oracle_provider_statement_execute (GdaServerProvider *provider, GdaConnectio
break;
}
if (str) {
- event = gda_connection_event_new (GDA_CONNECTION_EVENT_NOTICE);
+ event = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_NOTICE);
gda_connection_event_set_description (event, str);
g_free (str);
gda_connection_add_event (cnc, event);
diff --git a/providers/oracle/gda-oracle-util.c b/providers/oracle/gda-oracle-util.c
index ba743ba..be066b9 100644
--- a/providers/oracle/gda-oracle-util.c
+++ b/providers/oracle/gda-oracle-util.c
@@ -1,5 +1,5 @@
/* GDA Oracle provider
- * Copyright (C) 2002 - 2009 The GNOME Foundation.
+ * Copyright (C) 2002 - 2010 The GNOME Foundation.
*
* AUTHORS:
* Tim Coleman <tim timcoleman com>
@@ -49,7 +49,7 @@
* The error number is set to the Oracle error code.
*/
GdaConnectionEvent *
-_gda_oracle_make_error (dvoid *hndlp, ub4 type, const gchar *file, gint line)
+_gda_oracle_make_error (GdaConnection *cnc, dvoid *hndlp, ub4 type, const gchar *file, gint line)
{
GdaConnectionEvent *error = NULL;
gchar errbuf[512];
@@ -66,7 +66,7 @@ _gda_oracle_make_error (dvoid *hndlp, ub4 type, const gchar *file, gint line)
(ub4) type);
if (errcode != 1405) {
- error = gda_connection_event_new (GDA_CONNECTION_EVENT_ERROR);
+ error = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_ERROR);
gda_connection_event_set_description (error, errbuf);
/*g_warning ("Oracle error:%s", errbuf);*/
if (errcode == 600)
@@ -74,7 +74,7 @@ _gda_oracle_make_error (dvoid *hndlp, ub4 type, const gchar *file, gint line)
}
}
else {
- error = gda_connection_event_new (GDA_CONNECTION_EVENT_ERROR);
+ error = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_ERROR);
gda_connection_event_set_description (error, _("NO DESCRIPTION"));
}
@@ -119,11 +119,11 @@ _gda_oracle_handle_error (gint result, GdaConnection *cnc,
case OCI_ERROR:
switch(type) {
case OCI_HTYPE_ERROR:
- error = _gda_oracle_make_error (cdata->herr, type, file, line);
+ error = _gda_oracle_make_error (cnc, cdata->herr, type, file, line);
gda_connection_add_event (cnc, error);
break;
case OCI_HTYPE_ENV:
- error = _gda_oracle_make_error (cdata->henv, type, file, line);
+ error = _gda_oracle_make_error (cnc, cdata->henv, type, file, line);
if (error)
gda_connection_add_event (cnc, error);
break;
diff --git a/providers/oracle/gda-oracle-util.h b/providers/oracle/gda-oracle-util.h
index 8764b0c..b987299 100644
--- a/providers/oracle/gda-oracle-util.h
+++ b/providers/oracle/gda-oracle-util.h
@@ -92,7 +92,7 @@ typedef struct {
GdaStaticType s_type;
} GdaOracleValue;
-GdaConnectionEvent *_gda_oracle_make_error (dvoid *hndlp, ub4 type, const gchar *file, gint line);
+GdaConnectionEvent *_gda_oracle_make_error (GdaConnection *cnc, dvoid *hndlp, ub4 type, const gchar *file, gint line);
GdaConnectionEvent *_gda_oracle_handle_error (gint result, GdaConnection *cnc,
OracleConnectionData *cdata,
ub4 type, const gchar *msg,
diff --git a/providers/postgres/gda-postgres-provider.c b/providers/postgres/gda-postgres-provider.c
index 57b484d..abadb87 100644
--- a/providers/postgres/gda-postgres-provider.c
+++ b/providers/postgres/gda-postgres-provider.c
@@ -1,5 +1,5 @@
/* GDA postgres provider
- * Copyright (C) 1998 - 2009 The GNOME Foundation.
+ * Copyright (C) 1998 - 2010 The GNOME Foundation.
*
* AUTHORS:
* Vivien Malerba <malerba gnome-db org>
@@ -381,20 +381,24 @@ get_pg_version_float (const gchar *str)
}
static void
-pq_notice_processor (PostgresConnectionData *cdata, const char *message)
+pq_notice_processor (GdaConnection *cnc, const char *message)
{
GdaConnectionEvent *error;
+ PostgresConnectionData *cdata;
if (!message)
return;
- error = gda_connection_event_new (GDA_CONNECTION_EVENT_NOTICE);
+ cdata = (PostgresConnectionData*) gda_connection_internal_get_provider_data (cnc);
+ if (!cdata)
+ return;
+ error = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_NOTICE);
gda_connection_event_set_description (error, message);
gda_connection_event_set_code (error, -1);
- gda_connection_event_set_source (error, gda_connection_get_provider_name (cdata->cnc));
+ gda_connection_event_set_source (error, gda_connection_get_provider_name (cnc));
gda_connection_event_set_sqlstate (error, "-1");
- gda_connection_add_event (cdata->cnc, error);
+ gda_connection_add_event (cnc, error);
}
/*
@@ -547,7 +551,7 @@ gda_postgres_provider_open_connection (GdaServerProvider *provider, GdaConnectio
gda_connection_internal_set_provider_data (cnc, cdata, (GDestroyNotify) gda_postgres_free_cnc_data);
/* handle LibPQ's notices */
- PQsetNoticeProcessor (pconn, (PQnoticeProcessor) pq_notice_processor, cdata);
+ PQsetNoticeProcessor (pconn, (PQnoticeProcessor) pq_notice_processor, cnc);
/* handle the reuseable part */
GdaProviderReuseableOperations *ops;
@@ -1866,7 +1870,7 @@ gda_postgres_provider_statement_execute (GdaServerProvider *provider, GdaConnect
cursor_sql = g_strdup_printf ("DECLARE %s SCROLL CURSOR WITH HOLD FOR %s", cursor_name, sql);
g_free (sql);
pg_res = _gda_postgres_PQexec_wrap (cnc, cdata->pconn, cursor_sql);
- event = gda_connection_event_new (GDA_CONNECTION_EVENT_COMMAND);
+ event = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_COMMAND);
gda_connection_event_set_description (event, cursor_sql);
gda_connection_add_event (cnc, event);
g_free (cursor_sql);
@@ -1932,7 +1936,7 @@ gda_postgres_provider_statement_execute (GdaServerProvider *provider, GdaConnect
/* find requested parameter */
if (!params) {
- event = gda_connection_event_new (GDA_CONNECTION_EVENT_ERROR);
+ event = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_ERROR);
gda_connection_event_set_description (event, _("Missing parameter(s) to execute query"));
g_set_error (error, GDA_SERVER_PROVIDER_ERROR,
GDA_SERVER_PROVIDER_MISSING_PARAM_ERROR,
@@ -1952,7 +1956,7 @@ gda_postgres_provider_statement_execute (GdaServerProvider *provider, GdaConnect
if (! allow_noparam) {
gchar *str;
str = g_strdup_printf (_("Missing parameter '%s' to execute query"), pname);
- event = gda_connection_event_new (GDA_CONNECTION_EVENT_ERROR);
+ event = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_ERROR);
gda_connection_event_set_description (event, str);
g_set_error (error, GDA_SERVER_PROVIDER_ERROR,
GDA_SERVER_PROVIDER_MISSING_PARAM_ERROR, "%s", str);
@@ -1970,7 +1974,7 @@ gda_postgres_provider_statement_execute (GdaServerProvider *provider, GdaConnect
if (! allow_noparam) {
gchar *str;
str = g_strdup_printf (_("Parameter '%s' is invalid"), pname);
- event = gda_connection_event_new (GDA_CONNECTION_EVENT_ERROR);
+ event = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_ERROR);
gda_connection_event_set_description (event, str);
g_set_error (error, GDA_SERVER_PROVIDER_ERROR,
GDA_SERVER_PROVIDER_MISSING_PARAM_ERROR, "%s", str);
@@ -1996,7 +2000,7 @@ gda_postgres_provider_statement_execute (GdaServerProvider *provider, GdaConnect
/* Postgres requires that a transaction be started for LOB operations */
if (!check_transaction_started (cnc, &transaction_started)) {
- event = gda_connection_event_new (GDA_CONNECTION_EVENT_ERROR);
+ event = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_ERROR);
gda_connection_event_set_description (event, _("Cannot start transaction"));
g_set_error (error, GDA_SERVER_PROVIDER_ERROR, GDA_SERVER_PROVIDER_MISSING_PARAM_ERROR,
"%s", _("Cannot start transaction"));
@@ -2054,7 +2058,7 @@ gda_postgres_provider_statement_execute (GdaServerProvider *provider, GdaConnect
}
/* add a connection event for the execution */
- event = gda_connection_event_new (GDA_CONNECTION_EVENT_COMMAND);
+ event = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_COMMAND);
gda_connection_event_set_description (event, _GDA_PSTMT (ps)->sql);
gda_connection_add_event (cnc, event);
@@ -2102,7 +2106,7 @@ gda_postgres_provider_statement_execute (GdaServerProvider *provider, GdaConnect
gchar *str;
GdaConnectionEvent *event;
- event = gda_connection_event_new (GDA_CONNECTION_EVENT_NOTICE);
+ event = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_NOTICE);
str = g_strdup (PQcmdStatus (pg_res));
gda_connection_event_set_description (event, str);
g_free (str);
diff --git a/providers/postgres/gda-postgres-util.c b/providers/postgres/gda-postgres-util.c
index b558a2e..1fc61e4 100644
--- a/providers/postgres/gda-postgres-util.c
+++ b/providers/postgres/gda-postgres-util.c
@@ -1,5 +1,5 @@
/* GDA postgres provider
- * Copyright (C) 1998 - 2008 The GNOME Foundation.
+ * Copyright (C) 1998 - 2010 The GNOME Foundation.
*
* AUTHORS:
* Vivien Malerba <malerba gnome-db org>
@@ -55,7 +55,7 @@ _gda_postgres_make_error (GdaConnection *cnc, PGconn *pconn, PGresult *pg_res, G
GdaConnectionEventCode gda_code = GDA_CONNECTION_EVENT_CODE_UNKNOWN;
GdaTransactionStatus *trans;
- error_ev = gda_connection_event_new (GDA_CONNECTION_EVENT_ERROR);
+ error_ev = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_ERROR);
if (pconn != NULL) {
gchar *message;
@@ -116,7 +116,7 @@ _gda_postgres_PQexec_wrap (GdaConnection *cnc, PGconn *pconn, const char *query)
GdaConnectionEvent *event;
if (cnc) {
- event = gda_connection_event_new (GDA_CONNECTION_EVENT_COMMAND);
+ event = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_COMMAND);
gda_connection_event_set_description (event, query);
gda_connection_add_event (cnc, event);
}
diff --git a/providers/skel-implementation/capi/gda-capi-provider.c b/providers/skel-implementation/capi/gda-capi-provider.c
index cca19ed..306b507 100644
--- a/providers/skel-implementation/capi/gda-capi-provider.c
+++ b/providers/skel-implementation/capi/gda-capi-provider.c
@@ -1,5 +1,5 @@
/* GDA Capi provider
- * Copyright (C) 2008 - 2009 The GNOME Foundation.
+ * Copyright (C) 2008 - 2010 The GNOME Foundation.
*
* AUTHORS:
* TO_ADD: your name and email
@@ -1072,7 +1072,7 @@ gda_capi_provider_statement_execute (GdaServerProvider *provider, GdaConnection
/* find requested parameter */
if (!params) {
- event = gda_connection_event_new (GDA_CONNECTION_EVENT_ERROR);
+ event = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_ERROR);
gda_connection_event_set_description (event, _("Missing parameter(s) to execute query"));
g_set_error (error, GDA_SERVER_PROVIDER_ERROR,
GDA_SERVER_PROVIDER_MISSING_PARAM_ERROR,
@@ -1092,7 +1092,7 @@ gda_capi_provider_statement_execute (GdaServerProvider *provider, GdaConnection
if (! allow_noparam) {
gchar *str;
str = g_strdup_printf (_("Missing parameter '%s' to execute query"), pname);
- event = gda_connection_event_new (GDA_CONNECTION_EVENT_ERROR);
+ event = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_ERROR);
gda_connection_event_set_description (event, str);
g_set_error (error, GDA_SERVER_PROVIDER_ERROR,
GDA_SERVER_PROVIDER_MISSING_PARAM_ERROR, "%s", str);
@@ -1111,7 +1111,7 @@ gda_capi_provider_statement_execute (GdaServerProvider *provider, GdaConnection
if (! allow_noparam) {
gchar *str;
str = g_strdup_printf (_("Parameter '%s' is invalid"), pname);
- event = gda_connection_event_new (GDA_CONNECTION_EVENT_ERROR);
+ event = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_ERROR);
gda_connection_event_set_description (event, str);
g_set_error (error, GDA_SERVER_PROVIDER_ERROR,
GDA_SERVER_PROVIDER_MISSING_PARAM_ERROR, "%s", str);
@@ -1138,7 +1138,7 @@ gda_capi_provider_statement_execute (GdaServerProvider *provider, GdaConnection
}
/* add a connection event for the execution */
- event = gda_connection_event_new (GDA_CONNECTION_EVENT_COMMAND);
+ event = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_COMMAND);
gda_connection_event_set_description (event, _GDA_PSTMT (ps)->sql);
gda_connection_add_event (cnc, event);
diff --git a/providers/web/gda-web-provider.c b/providers/web/gda-web-provider.c
index cc3c8d4..161db77 100644
--- a/providers/web/gda-web-provider.c
+++ b/providers/web/gda-web-provider.c
@@ -1,5 +1,5 @@
/* GDA provider
- * Copyright (C) 2009 The GNOME Foundation.
+ * Copyright (C) 2009 - 2010 The GNOME Foundation.
*
* AUTHORS:
* Vivien Malerba <malerba gnome-db org>
@@ -1463,7 +1463,7 @@ gda_web_provider_statement_execute (GdaServerProvider *provider, GdaConnection *
/* find requested parameter */
if (!params) {
- event = gda_connection_event_new (GDA_CONNECTION_EVENT_ERROR);
+ event = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_ERROR);
gda_connection_event_set_description (event, _("Missing parameter(s) to execute query"));
g_set_error (error, GDA_SERVER_PROVIDER_ERROR,
GDA_SERVER_PROVIDER_MISSING_PARAM_ERROR,
@@ -1483,7 +1483,7 @@ gda_web_provider_statement_execute (GdaServerProvider *provider, GdaConnection *
if (! allow_noparam) {
gchar *str;
str = g_strdup_printf (_("Missing parameter '%s' to execute query"), pname);
- event = gda_connection_event_new (GDA_CONNECTION_EVENT_ERROR);
+ event = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_ERROR);
gda_connection_event_set_description (event, str);
g_set_error (error, GDA_SERVER_PROVIDER_ERROR,
GDA_SERVER_PROVIDER_MISSING_PARAM_ERROR, "%s", str);
@@ -1503,7 +1503,7 @@ gda_web_provider_statement_execute (GdaServerProvider *provider, GdaConnection *
if (! allow_noparam) {
gchar *str;
str = g_strdup_printf (_("Parameter '%s' is invalid"), pname);
- event = gda_connection_event_new (GDA_CONNECTION_EVENT_ERROR);
+ event = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_ERROR);
gda_connection_event_set_description (event, str);
g_set_error (error, GDA_SERVER_PROVIDER_ERROR,
GDA_SERVER_PROVIDER_MISSING_PARAM_ERROR, "%s", str);
@@ -1536,7 +1536,7 @@ gda_web_provider_statement_execute (GdaServerProvider *provider, GdaConnection *
}
/* add a connection event for the execution */
- event = gda_connection_event_new (GDA_CONNECTION_EVENT_COMMAND);
+ event = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_COMMAND);
gda_connection_event_set_description (event, _GDA_PSTMT (ps)->sql);
gda_connection_add_event (cnc, event);
@@ -1593,7 +1593,7 @@ gda_web_provider_statement_execute (GdaServerProvider *provider, GdaConnection *
}
/* required: help @cnc keep some stats */
- event = gda_connection_event_new (GDA_CONNECTION_EVENT_NOTICE);
+ event = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_NOTICE);
gda_connection_event_set_description (event, "Command OK");
gda_connection_add_event (cnc, event);
gda_connection_internal_statement_executed (cnc, stmt, params, event);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]