[gom] command: Also debug-print the values of the query
- From: Mathieu Bridon <mbridon src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gom] command: Also debug-print the values of the query
- Date: Sun, 25 Jan 2015 09:07:04 +0000 (UTC)
commit ca037253a0239dbbaa84152d7b9e09efb230a4c4
Author: Mathieu Bridon <bochecha daitauha fr>
Date: Mon Dec 29 11:37:37 2014 +0100
command: Also debug-print the values of the query
This is quite useful when debugging what is going on with a query.
https://bugzilla.gnome.org/show_bug.cgi?id=742180
gom/gom-command.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 46 insertions(+), 1 deletions(-)
---
diff --git a/gom/gom-command.c b/gom/gom-command.c
index 511b9a4..8584707 100644
--- a/gom/gom-command.c
+++ b/gom/gom-command.c
@@ -332,7 +332,52 @@ gom_command_execute (GomCommand *command,
gom_command_bind_params(command);
#if 0
- g_debug("%s", sqlite3_sql(priv->stmt));
+ g_print("%s", sqlite3_sql(priv->stmt));
+
+ if (priv->params != NULL) {
+ GHashTableIter iter;
+ gpointer key;
+ gpointer value;
+ gboolean first = TRUE;
+
+ g_print(" (");
+
+ g_hash_table_iter_init(&iter, priv->params);
+ while (g_hash_table_iter_next(&iter, &key, &value)) {
+ GValue *v = (GValue *)value;
+
+ if (!first)
+ g_print(", ");
+
+ if (G_VALUE_HOLDS_BOOLEAN(v)) {
+ gboolean b = g_value_get_boolean(v);
+ g_print("%s", b ? "TRUE" : "FALSE");
+ } else if (G_VALUE_HOLDS_INT(v)) {
+ gint i = g_value_get_int(v);
+ g_print("%d", i);
+ } else if (G_VALUE_HOLDS_INT64(v)) {
+ gint64 i = g_value_get_int64(v);
+ g_print("%" G_GINT64_FORMAT, i);
+ } else if (G_VALUE_HOLDS_STRING(v)) {
+ const gchar *s = g_value_get_string(v);
+ g_print("'%s'", s);
+ } else if (G_VALUE_HOLDS_UCHAR(v)) {
+ guchar i = g_value_get_uchar(v);
+ g_print("%c", i);
+ } else if (G_VALUE_HOLDS_UINT(v)) {
+ guint i = g_value_get_uint(v);
+ g_print("%u", i);
+ } else {
+ g_print("'unknown'");
+ }
+
+ first = FALSE;
+ }
+
+ g_print(")");
+ }
+
+ g_print("\n");
#endif
if (!cursor) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]