aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/utils/adt')
-rw-r--r--src/backend/utils/adt/jsonpath.c4
-rw-r--r--src/backend/utils/adt/jsonpath_scan.l24
2 files changed, 14 insertions, 14 deletions
diff --git a/src/backend/utils/adt/jsonpath.c b/src/backend/utils/adt/jsonpath.c
index 9be4e305ffa..91af0300952 100644
--- a/src/backend/utils/adt/jsonpath.c
+++ b/src/backend/utils/adt/jsonpath.c
@@ -500,9 +500,13 @@ printJsonPathItem(StringInfo buf, JsonPathItem *v, bool inKey,
escape_json(buf, jspGetString(v, NULL));
break;
case jpiNumeric:
+ if (jspHasNext(v))
+ appendStringInfoChar(buf, '(');
appendStringInfoString(buf,
DatumGetCString(DirectFunctionCall1(numeric_out,
NumericGetDatum(jspGetNumeric(v)))));
+ if (jspHasNext(v))
+ appendStringInfoChar(buf, ')');
break;
case jpiBool:
if (jspGetBool(v))
diff --git a/src/backend/utils/adt/jsonpath_scan.l b/src/backend/utils/adt/jsonpath_scan.l
index 827a9e44cbb..1f08e7c51f8 100644
--- a/src/backend/utils/adt/jsonpath_scan.l
+++ b/src/backend/utils/adt/jsonpath_scan.l
@@ -82,11 +82,13 @@ other [^\?\%\$\.\[\]\{\}\(\)\|\&\!\=\<\>\@\#\,\*:\-\+\/\\\" \t\n\r\f]
digit [0-9]
integer (0|[1-9]{digit}*)
-decimal {integer}\.{digit}+
-decimalfail {integer}\.
+decimal ({integer}\.{digit}*|\.{digit}+)
real ({integer}|{decimal})[Ee][-+]?{digit}+
-realfail1 ({integer}|{decimal})[Ee]
-realfail2 ({integer}|{decimal})[Ee][-+]
+realfail ({integer}|{decimal})[Ee][-+]
+
+integer_junk {integer}{other}
+decimal_junk {decimal}{other}
+real_junk {real}{other}
hex_dig [0-9A-Fa-f]
unicode \\u({hex_dig}{4}|\{{hex_dig}{1,6}\})
@@ -242,16 +244,10 @@ hex_fail \\x{hex_dig}{0,1}
return INT_P;
}
-{decimalfail} {
- /* throw back the ., and treat as integer */
- yyless(yyleng - 1);
- addstring(true, yytext, yyleng);
- addchar(false, '\0');
- yylval->str = scanstring;
- return INT_P;
- }
-
-({realfail1}|{realfail2}) { yyerror(NULL, "invalid floating point number"); }
+{realfail} { yyerror(NULL, "invalid numeric literal"); }
+{integer_junk} { yyerror(NULL, "trailing junk after numeric literal"); }
+{decimal_junk} { yyerror(NULL, "trailing junk after numeric literal"); }
+{real_junk} { yyerror(NULL, "trailing junk after numeric literal"); }
\" {
addchar(true, '\0');