Permalink
Browse files

Fixed text field length bug and added REAL_RESULT support

  • Loading branch information...
1 parent c50b067 commit 313f8dae91147ef3800fa7b67819bb419d437121 @toddtreece committed Jan 18, 2012
Showing with 14 additions and 2 deletions.
  1. +14 −2 io.c
View
16 io.c
@@ -55,14 +55,14 @@ long long mongodb_save(UDF_INIT *initid, UDF_ARGS *args, char *result, unsigned
if (args->args[i]) {
if (args->arg_type[i] == STRING_RESULT || args->arg_type[i] == DECIMAL_RESULT) {
-
+
if(args->lengths[i] < strlen(args->args[i])) {
args->args[i][args->lengths[i]] = '\0';
}
- if(strcmp(args->args[i], "NULL") == 0 || args->lengths[i] == 0) {
+ if(strcmp(args->args[i], "NULL") == 0 || args->lengths[i] == 0 || strlen(args->args[i]) == 0 || args->args[i] == NULL) {
bson_append_null(b, args->attributes[i]);
@@ -90,6 +90,18 @@ long long mongodb_save(UDF_INIT *initid, UDF_ARGS *args, char *result, unsigned
}
+ } else if (args->arg_type[i] == REAL_RESULT) {
+
+ if(args->args[i] == NULL) {
+
+ bson_append_null(b, args->attributes[i]);
+
+ } else {
+
+ bson_append_double(b, args->attributes[i],*((double*) args->args[i]));
+
+ }
+
}
}

0 comments on commit 313f8da

Please sign in to comment.