@@ -751,11 +751,12 @@ json_lex_string(JsonLexContext *lex)
751
751
report_json_context (lex )));
752
752
753
753
/*
754
- * For UTF8, replace the escape sequence by the actual utf8
755
- * character in lex->strval. Do this also for other encodings
756
- * if the escape designates an ASCII character, otherwise
757
- * raise an error. We don't ever unescape a \u0000, since that
758
- * would result in an impermissible nul byte.
754
+ * For UTF8, replace the escape sequence by the actual
755
+ * utf8 character in lex->strval. Do this also for other
756
+ * encodings if the escape designates an ASCII character,
757
+ * otherwise raise an error. We don't ever unescape a
758
+ * \u0000, since that would result in an impermissible nul
759
+ * byte.
759
760
*/
760
761
761
762
if (ch == 0 )
@@ -771,8 +772,9 @@ json_lex_string(JsonLexContext *lex)
771
772
else if (ch <= 0x007f )
772
773
{
773
774
/*
774
- * This is the only way to designate things like a form feed
775
- * character in JSON, so it's useful in all encodings.
775
+ * This is the only way to designate things like a
776
+ * form feed character in JSON, so it's useful in all
777
+ * encodings.
776
778
*/
777
779
appendStringInfoChar (lex -> strval , (char ) ch );
778
780
}
@@ -866,7 +868,7 @@ json_lex_string(JsonLexContext *lex)
866
868
ereport (ERROR ,
867
869
(errcode (ERRCODE_INVALID_TEXT_REPRESENTATION ),
868
870
errmsg ("invalid input syntax for type json" ),
869
- errdetail ("Unicode low surrogate must follow a high surrogate." ),
871
+ errdetail ("Unicode low surrogate must follow a high surrogate." ),
870
872
report_json_context (lex )));
871
873
872
874
/* Hooray, we found the end of the string! */
@@ -1221,7 +1223,7 @@ datum_to_json(Datum val, bool is_null, StringInfo result,
1221
1223
{
1222
1224
char * outputstr ;
1223
1225
text * jsontext ;
1224
- bool numeric_error ;
1226
+ bool numeric_error ;
1225
1227
JsonLexContext dummy_lex ;
1226
1228
1227
1229
if (is_null )
@@ -1246,13 +1248,14 @@ datum_to_json(Datum val, bool is_null, StringInfo result,
1246
1248
break ;
1247
1249
case TYPCATEGORY_NUMERIC :
1248
1250
outputstr = OidOutputFunctionCall (typoutputfunc , val );
1251
+
1249
1252
/*
1250
1253
* Don't call escape_json here if it's a valid JSON number.
1251
1254
*/
1252
1255
dummy_lex .input = * outputstr == '-' ? outputstr + 1 : outputstr ;
1253
1256
dummy_lex .input_length = strlen (dummy_lex .input );
1254
1257
json_lex_number (& dummy_lex , dummy_lex .input , & numeric_error );
1255
- if (! numeric_error )
1258
+ if (!numeric_error )
1256
1259
appendStringInfoString (result , outputstr );
1257
1260
else
1258
1261
escape_json (result , outputstr );
@@ -1808,34 +1811,34 @@ json_typeof(PG_FUNCTION_ARGS)
1808
1811
1809
1812
JsonLexContext * lex = makeJsonLexContext (json , false);
1810
1813
JsonTokenType tok ;
1811
- char * type ;
1814
+ char * type ;
1812
1815
1813
1816
/* Lex exactly one token from the input and check its type. */
1814
1817
json_lex (lex );
1815
1818
tok = lex_peek (lex );
1816
1819
switch (tok )
1817
1820
{
1818
- case JSON_TOKEN_OBJECT_START :
1819
- type = "object" ;
1820
- break ;
1821
- case JSON_TOKEN_ARRAY_START :
1822
- type = "array" ;
1823
- break ;
1824
- case JSON_TOKEN_STRING :
1825
- type = "string" ;
1826
- break ;
1827
- case JSON_TOKEN_NUMBER :
1828
- type = "number" ;
1829
- break ;
1830
- case JSON_TOKEN_TRUE :
1831
- case JSON_TOKEN_FALSE :
1832
- type = "boolean" ;
1833
- break ;
1834
- case JSON_TOKEN_NULL :
1835
- type = "null" ;
1836
- break ;
1837
- default :
1838
- elog (ERROR , "unexpected json token: %d" , tok );
1821
+ case JSON_TOKEN_OBJECT_START :
1822
+ type = "object" ;
1823
+ break ;
1824
+ case JSON_TOKEN_ARRAY_START :
1825
+ type = "array" ;
1826
+ break ;
1827
+ case JSON_TOKEN_STRING :
1828
+ type = "string" ;
1829
+ break ;
1830
+ case JSON_TOKEN_NUMBER :
1831
+ type = "number" ;
1832
+ break ;
1833
+ case JSON_TOKEN_TRUE :
1834
+ case JSON_TOKEN_FALSE :
1835
+ type = "boolean" ;
1836
+ break ;
1837
+ case JSON_TOKEN_NULL :
1838
+ type = "null" ;
1839
+ break ;
1840
+ default :
1841
+ elog (ERROR , "unexpected json token: %d" , tok );
1839
1842
}
1840
1843
1841
1844
PG_RETURN_TEXT_P (cstring_to_text (type ));
0 commit comments