From 55c8807978e86f615623eb7922c114b841f14557 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Mon, 1 Dec 2014 11:28:45 -0500 Subject: Fix hstore_to_json_loose's detection of valid JSON number values. We expose a function IsValidJsonNumber that internally calls the lexer for json numbers. That allows us to use the same test everywhere, instead of inventing a broken test for hstore conversions. The new function is also used in datum_to_json, replacing the code that is now moved to the new function. Backpatch to 9.3 where hstore_to_json_loose was introduced. --- src/include/utils/jsonapi.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/include/utils/jsonapi.h') diff --git a/src/include/utils/jsonapi.h b/src/include/utils/jsonapi.h index e25a0d93d89..dcfe71c29dd 100644 --- a/src/include/utils/jsonapi.h +++ b/src/include/utils/jsonapi.h @@ -107,4 +107,11 @@ extern void pg_parse_json(JsonLexContext *lex, JsonSemAction *sem); */ extern JsonLexContext *makeJsonLexContext(text *json, bool need_escapes); +/* + * Utility function to check if a string is a valid JSON number. + * + * str agrument does not need to be nul-terminated. + */ +extern bool IsValidJsonNumber(const char * str, int len); + #endif /* JSONAPI_H */ -- cgit v1.2.3