dovecot-2.2: cassandra: Added support for returning "int" type v...
dovecot at dovecot.org
dovecot at dovecot.org
Tue Oct 13 17:43:21 UTC 2015
details: http://hg.dovecot.org/dovecot-2.2/rev/c854e1b3e419
changeset: 19297:c854e1b3e419
user: Timo Sirainen <tss at iki.fi>
date: Tue Oct 13 20:39:50 2015 +0300
description:
cassandra: Added support for returning "int" type values.
It looks like we need to explicitly convert all types to strings.
diffstat:
src/lib-sql/driver-cassandra.c | 23 +++++++++++++++++++++--
1 files changed, 21 insertions(+), 2 deletions(-)
diffs (41 lines):
diff -r dce5ee506cc8 -r c854e1b3e419 src/lib-sql/driver-cassandra.c
--- a/src/lib-sql/driver-cassandra.c Tue Oct 13 13:44:48 2015 +0300
+++ b/src/lib-sql/driver-cassandra.c Tue Oct 13 20:39:50 2015 +0300
@@ -723,16 +723,35 @@
void *output_dup;
size_t output_size;
CassError rc;
+ const char *type;
if (cass_value_is_null(value)) {
*str_r = NULL;
return 0;
}
- rc = cass_value_get_bytes(value, &output, &output_size);
+ switch (cass_data_type_type(cass_value_data_type(value))) {
+ case CASS_VALUE_TYPE_INT: {
+ cass_int32_t num;
+
+ rc = cass_value_get_int32(value, &num);
+ if (rc == CASS_OK) {
+ const char *str = t_strdup_printf("%d", num);
+ output_size = strlen(str);
+ output = (const void *)str;
+ }
+ type = "int32";
+ break;
+ }
+ default:
+ rc = cass_value_get_bytes(value, &output, &output_size);
+ type = "bytes";
+ break;
+ }
if (rc != CASS_OK) {
i_free(result->error);
- result->error = i_strdup_printf("Couldn't get value as string (code=%d)", rc);
+ result->error = i_strdup_printf("Couldn't get value as %s: %s",
+ type, cass_error_desc(rc));
return -1;
}
output_dup = p_malloc(result->row_pool, output_size + 1);
More information about the dovecot-cvs
mailing list