[libgda/LIBGDA_4.2] Skel provider implementation: added statement rewriting for NULL parameters
- From: Vivien Malerba <vivien src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda/LIBGDA_4.2] Skel provider implementation: added statement rewriting for NULL parameters
- Date: Wed, 31 Aug 2011 20:00:57 +0000 (UTC)
commit 8abe8631e8a98f1d346e9e68d31d32eab04c1eac
Author: Vivien Malerba <malerba gnome-db org>
Date: Fri Aug 19 17:11:13 2011 +0200
Skel provider implementation: added statement rewriting for NULL parameters
.../skel-implementation/capi/gda-capi-provider.c | 62 +++++++++++++++-----
1 files changed, 46 insertions(+), 16 deletions(-)
---
diff --git a/providers/skel-implementation/capi/gda-capi-provider.c b/providers/skel-implementation/capi/gda-capi-provider.c
index 53684e1..2ddba69 100644
--- a/providers/skel-implementation/capi/gda-capi-provider.c
+++ b/providers/skel-implementation/capi/gda-capi-provider.c
@@ -1099,7 +1099,13 @@ gda_capi_provider_statement_execute (GdaServerProvider *provider, GdaConnection
}
}
if (!h) {
- if (! allow_noparam) {
+ if (allow_noparam) {
+ /* bind param to NULL */
+ TO_IMPLEMENT;
+ empty_rs = TRUE;
+ continue;
+ }
+ else {
gchar *str;
str = g_strdup_printf (_("Missing parameter '%s' to execute query"), pname);
event = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_ERROR);
@@ -1108,17 +1114,17 @@ gda_capi_provider_statement_execute (GdaServerProvider *provider, GdaConnection
GDA_SERVER_PROVIDER_MISSING_PARAM_ERROR, "%s", str);
g_free (str);
break;
- }
- else {
- /* bind param to NULL */
- TO_IMPLEMENT;
- empty_rs = TRUE;
- continue;
}
}
if (!gda_holder_is_valid (h)) {
- if (! allow_noparam) {
+ if (allow_noparam) {
+ /* bind param to NULL */
+ TO_IMPLEMENT;
+ empty_rs = TRUE;
+ continue;
+ }
+ else {
gchar *str;
str = g_strdup_printf (_("Parameter '%s' is invalid"), pname);
event = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_ERROR);
@@ -1127,12 +1133,6 @@ gda_capi_provider_statement_execute (GdaServerProvider *provider, GdaConnection
GDA_SERVER_PROVIDER_MISSING_PARAM_ERROR, "%s", str);
g_free (str);
break;
- }
- else {
- /* bind param to NULL */
- TO_IMPLEMENT;
- empty_rs = TRUE;
- continue;
}
}
else if (gda_holder_value_is_default (h) && !gda_holder_get_value (h)) {
@@ -1170,8 +1170,38 @@ gda_capi_provider_statement_execute (GdaServerProvider *provider, GdaConnection
/* actual binding using the C API, for parameter at position @i */
- /* const GValue *value = gda_holder_get_value (h); */
- TO_IMPLEMENT;
+ const GValue *value = gda_holder_get_value (h);
+ if (!value || gda_value_is_null (value)) {
+ GdaStatement *rstmt;
+ if (! gda_rewrite_statement_for_null_parameters (stmt, params, &rstmt, error)) {
+ TO_IMPLEMENT; /* bind to NULL */
+ }
+ else if (!rstmt)
+ return NULL;
+ else {
+ GObject *obj;
+ obj = gda_capi_provider_statement_execute (provider, cnc,
+ rstmt, params,
+ model_usage,
+ col_types,
+ last_inserted_row,
+ task_id, async_cb,
+ cb_data, error);
+ g_object_unref (rstmt);
+ if (GDA_IS_DATA_SELECT (obj)) {
+ GdaPStmt *pstmt;
+ g_object_get (obj, "prepared-stmt", &pstmt, NULL);
+ if (pstmt) {
+ gda_pstmt_set_gda_statement (pstmt, stmt);
+ g_object_unref (pstmt);
+ }
+ }
+ return obj;
+ }
+ }
+ else {
+ TO_IMPLEMENT;
+ }
}
if (event) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]