index c6fb5719821966c7b756ffd4256aaa5757c8d906..89e77adbc751fe5dc7f8980b86b8bb8ae04f5239 100644 (file)
@@ -857,27 +857,6 @@ makeJsonValueExpr(Expr *raw_expr, Expr *formatted_expr,
return jve;
}
-/*
- * makeJsonEncoding -
- * converts JSON encoding name to enum JsonEncoding
- */
-JsonEncoding
-makeJsonEncoding(char *name)
-{
- if (!pg_strcasecmp(name, "utf8"))
- return JS_ENC_UTF8;
- if (!pg_strcasecmp(name, "utf16"))
- return JS_ENC_UTF16;
- if (!pg_strcasecmp(name, "utf32"))
- return JS_ENC_UTF32;
-
- ereport(ERROR,
- errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("unrecognized JSON encoding: %s", name));
-
- return JS_ENC_DEFAULT;
-}
-
/*
* makeJsonKeyValue -
* creates a JsonKeyValue node
index d631ac89a9175e62e8bbe8025429b8a884bf7ac3..f16bbd3cddeaa24154950a49894e8e197e33d85e 100644 (file)
@@ -645,7 +645,8 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
%type <list> hash_partbound
%type <defelt> hash_partbound_elem
-%type <node> json_format_clause_opt
+%type <node> json_format_clause
+ json_format_clause_opt
json_value_expr
json_returning_clause_opt
json_name_and_value
@@ -653,8 +654,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
%type <list> json_name_and_value_list
json_value_expr_list
json_array_aggregate_order_by_clause_opt
-%type <ival> json_encoding_clause_opt
- json_predicate_type_constraint
+%type <ival> json_predicate_type_constraint
%type <boolean> json_key_uniqueness_constraint_opt
json_object_constructor_null_clause_opt
json_array_constructor_null_clause_opt
/*
* Required by SQL/JSON, but there are conflicts
| a_expr
- FORMAT_LA JSON json_encoding_clause_opt
+ json_format_clause
IS json_predicate_type_constraint
json_key_uniqueness_constraint_opt %prec IS
{
- 3ドル.location = @2;
- $$ = makeJsonIsPredicate(1,ドル 3,ドル 5,ドル 6,ドル @1);
+ $$ = makeJsonIsPredicate(1,ドル 2,ドル 4,ドル 5,ドル @1);
}
*/
| a_expr IS NOT
/*
* Required by SQL/JSON, but there are conflicts
| a_expr
- FORMAT_LA JSON json_encoding_clause_opt
+ json_format_clause
IS NOT
json_predicate_type_constraint
json_key_uniqueness_constraint_opt %prec IS
{
- 3ドル.location = @2;
- $$ = makeNotExpr(makeJsonIsPredicate(1,ドル 3,ドル 6,ドル 7,ドル @1), @1);
+ $$ = makeNotExpr(makeJsonIsPredicate(1,ドル 2,ドル 5,ドル 6,ドル @1), @1);
}
*/
| DEFAULT
}
;
+json_format_clause:
+ FORMAT_LA JSON ENCODING name
+ {
+ int encoding;
+
+ if (!pg_strcasecmp(4,ドル "utf8"))
+ encoding = JS_ENC_UTF8;
+ else if (!pg_strcasecmp(4,ドル "utf16"))
+ encoding = JS_ENC_UTF16;
+ else if (!pg_strcasecmp(4,ドル "utf32"))
+ encoding = JS_ENC_UTF32;
+ else
+ ereport(ERROR,
+ errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("unrecognized JSON encoding: %s", 4ドル));
+
+ $$ = (Node *) makeJsonFormat(JS_FORMAT_JSON, encoding, @1);
+ }
+ | FORMAT_LA JSON
+ {
+ $$ = (Node *) makeJsonFormat(JS_FORMAT_JSON, JS_ENC_DEFAULT, @1);
+ }
+ ;
+
json_format_clause_opt:
- FORMAT_LA JSON json_encoding_clause_opt
+ json_format_clause
{
- $$ = (Node *) makeJsonFormat(JS_FORMAT_JSON, 3,ドル @1);
+ $$ = 1ドル;
}
| /* EMPTY */
{
}
;
-json_encoding_clause_opt:
- ENCODING name { $$ = makeJsonEncoding(2ドル); }
- | /* EMPTY */ { $$ = JS_ENC_DEFAULT; }
- ;
-
json_returning_clause_opt:
RETURNING Typename json_format_clause_opt
{