X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fcdata.c;h=2630e733d35d10200e9938adc5082ff6bc200ea2;hb=92e8ddbbc721025619a0b15a963af7efab5acfde;hp=03fefbc6c510f45556c76237472c1139895e7365;hpb=5f0b12845c8dd3cf14e5533eac10e369897f4b2a;p=postrr.git diff --git a/src/cdata.c b/src/cdata.c index 03fefbc..2630e73 100644 --- a/src/cdata.c +++ b/src/cdata.c @@ -160,9 +160,13 @@ cdata_in(PG_FUNCTION_ARGS) )); while ((*endptr != '\0') && isspace((int)*endptr)) + ++endptr; + + if (*endptr != '\0') ereport(ERROR, ( errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for cdata: \"%s\"", orig) + errmsg("invalid input syntax for cdata: \"%s\"", orig), + errdetail("garbage found after number: \"%s\"", endptr) )); if (typmod > 0) @@ -189,8 +193,9 @@ cdata_out(PG_FUNCTION_ARGS) data = PG_GETARG_CDATA_P(0); - snprintf(cd_str, sizeof(cd_str), "%g (U:%i/%i)", - data->value, data->undef_num, data->val_num); + snprintf(cd_str, sizeof(cd_str), "%g (%s U:%i/%i)", + data->value, CF_TO_STR(data->cf), + data->undef_num, data->val_num); result = pstrdup(cd_str); PG_RETURN_CSTRING(result); @@ -362,6 +367,12 @@ cdata_update(PG_FUNCTION_ARGS) data = PG_GETARG_CDATA_P(0); update = PG_GETARG_CDATA_P(1); + if (! data) + PG_RETURN_CDATA_P(update); + + if (! update) + PG_RETURN_CDATA_P(data); + if ((data->cf != update->cf) && (update->val_num > 1)) ereport(ERROR, ( errcode(ERRCODE_INVALID_PARAMETER_VALUE),