From 8d415fdfdeee63d9bd3b0858230d10df95d605dd Mon Sep 17 00:00:00 2001 From: John Ralls Date: Fri, 19 Aug 2016 15:32:33 -0700 Subject: [PATCH] Bug 770113 - compiling issue with libdbi. On OpenSuSe. They've taken to using libdbi's git repo instead of the last tarball (0.9.0 in March 2013) and there's a significant change in the data format. --- src/backend/dbi/gnc-backend-dbi.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/dbi/gnc-backend-dbi.c b/src/backend/dbi/gnc-backend-dbi.c index 331f5b89ac..a716ad2e28 100644 --- a/src/backend/dbi/gnc-backend-dbi.c +++ b/src/backend/dbi/gnc-backend-dbi.c @@ -70,9 +70,11 @@ #if LIBDBI_VERSION >= 900 #define HAVE_LIBDBI_R 1 +#define HAVE_LIBDBI_TO_LONGLONG 1 static dbi_inst dbi_instance = NULL; #else #define HAVE_LIBDBI_R 0 +#define HAVE_LIBDBI_TO_LONGLONG 0 #endif /* For direct access to dbi data structs, sadly needed for datetime */ @@ -2208,15 +2210,21 @@ row_get_value_at_col_name( GncSqlRow* row, const gchar* col_name ) } else { +#if HAVE_LIBDBI_TO_LONGLONG + /* A less evil hack than the one required by libdbi-0.8, but still + * necessary to work around the same bug. + */ + time64 time = dbi_result_get_as_longlong(dbi_row->result, + col_name); +#else /* A seriously evil hack to work around libdbi bug #15 - * https://sourceforge.net/p/libdbi/bugs/15/. When libdbi - * v0.9 is widely available this can be replaced with - * dbi_result_get_as_longlong. + * https://sourceforge.net/p/libdbi/bugs/15/. */ dbi_result_t *result = (dbi_result_t*)(dbi_row->result); guint64 row = dbi_result_get_currow (result); guint idx = dbi_result_get_field_idx (result, col_name) - 1; time64 time = result->rows[row]->field_values[idx].d_datetime; +#endif (void)g_value_init( value, G_TYPE_INT64 ); g_value_set_int64 (value, time); }