Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit502923b

Browse files
author
Nikita Glukhov
committed
Use nodes JsonFomat and JsonReturning in JsonValueExpr
1 parent49ced4f commit502923b

File tree

4 files changed

+36
-19
lines changed

4 files changed

+36
-19
lines changed

‎contrib/pg_stat_statements/pg_stat_statements.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3086,14 +3086,30 @@ JumbleExpr(pgssJumbleState *jstate, Node *node)
30863086
JumbleExpr(jstate, (Node*)conf->exclRelTlist);
30873087
}
30883088
break;
3089+
caseT_JsonFormat:
3090+
{
3091+
JsonFormat*format= (JsonFormat*)node;
3092+
3093+
APP_JUMB(format->type);
3094+
APP_JUMB(format->encoding);
3095+
}
3096+
break;
3097+
caseT_JsonReturning:
3098+
{
3099+
JsonReturning*returning= (JsonReturning*)node;
3100+
3101+
JumbleExpr(jstate, (Node*)returning->format);
3102+
APP_JUMB(returning->typid);
3103+
APP_JUMB(returning->typmod);
3104+
}
3105+
break;
30893106
caseT_JsonValueExpr:
30903107
{
30913108
JsonValueExpr*expr= (JsonValueExpr*)node;
30923109

30933110
JumbleExpr(jstate, (Node*)expr->raw_expr);
30943111
JumbleExpr(jstate, (Node*)expr->formatted_expr);
3095-
APP_JUMB(expr->format.type);
3096-
APP_JUMB(expr->format.encoding);
3112+
JumbleExpr(jstate, (Node*)expr->format);
30973113
}
30983114
break;
30993115
caseT_List:

‎src/backend/parser/parse_expr.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3584,7 +3584,7 @@ getJsonEncodingConst(JsonFormat *format)
35843584
Nameencname=palloc(sizeof(NameData));
35853585

35863586
if (!format||
3587-
format->type==JS_FORMAT_DEFAULT||
3587+
format->format==JS_FORMAT_DEFAULT||
35883588
format->encoding==JS_ENC_DEFAULT)
35893589
encoding=JS_ENC_UTF8;
35903590
else
@@ -3620,7 +3620,7 @@ makeJsonByteaToTextConversion(Node *expr, JsonFormat *format, int location)
36203620
FuncExpr*fexpr=makeFuncExpr(F_PG_CONVERT_FROM,TEXTOID,
36213621
list_make2(expr,encoding),
36223622
InvalidOid,InvalidOid,
3623-
COERCE_INTERNAL_CAST);
3623+
COERCE_EXPLICIT_CALL);
36243624

36253625
fexpr->location=location;
36263626

@@ -3667,13 +3667,13 @@ transformJsonValueExpr(ParseState *pstate, JsonValueExpr *ve,
36673667

36683668
get_type_category_preferred(exprtype,&typcategory,&typispreferred);
36693669

3670-
if (ve->format.type!=JS_FORMAT_DEFAULT)
3670+
if (ve->format->format!=JS_FORMAT_DEFAULT)
36713671
{
3672-
if (ve->format.encoding!=JS_ENC_DEFAULT&&exprtype!=BYTEAOID)
3672+
if (ve->format->encoding!=JS_ENC_DEFAULT&&exprtype!=BYTEAOID)
36733673
ereport(ERROR,
36743674
(errcode(ERRCODE_DATATYPE_MISMATCH),
36753675
errmsg("JSON ENCODING clause is only allowed for bytea input type"),
3676-
parser_errposition(pstate,ve->format.location)));
3676+
parser_errposition(pstate,ve->format->location)));
36773677

36783678
if (exprtype==JSONOID||exprtype==JSONBOID)
36793679
{
@@ -3683,7 +3683,7 @@ transformJsonValueExpr(ParseState *pstate, JsonValueExpr *ve,
36833683
parser_errposition(pstate,ve->format->location)));
36843684
}
36853685
else
3686-
format=ve->format.type;
3686+
format=ve->format->format;
36873687
}
36883688
elseif (exprtype==JSONOID||exprtype==JSONBOID)
36893689
format=JS_FORMAT_DEFAULT;/* do not format json[b] types */
@@ -3701,16 +3701,16 @@ transformJsonValueExpr(ParseState *pstate, JsonValueExpr *ve,
37013701
if (exprtype!=BYTEAOID&&typcategory!=TYPCATEGORY_STRING)
37023702
ereport(ERROR,
37033703
(errcode(ERRCODE_DATATYPE_MISMATCH),
3704-
errmsg(ve->format.type==JS_FORMAT_DEFAULT ?
3704+
errmsg(ve->format->format==JS_FORMAT_DEFAULT ?
37053705
"cannot use non-string types with implicit FORMAT JSON clause" :
37063706
"cannot use non-string types with explicit FORMAT JSON clause"),
3707-
parser_errposition(pstate,ve->format.location >=0 ?
3708-
ve->format.location :location)));
3707+
parser_errposition(pstate,ve->format->location >=0 ?
3708+
ve->format->location :location)));
37093709

37103710
/* Convert encoded JSON text from bytea. */
37113711
if (format==JS_FORMAT_JSON&&exprtype==BYTEAOID)
37123712
{
3713-
expr=makeJsonByteaToTextConversion(expr,&ve->format,location);
3713+
expr=makeJsonByteaToTextConversion(expr,ve->format,location);
37143714
exprtype=TEXTOID;
37153715
}
37163716

‎src/backend/utils/adt/ruleutils.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7899,16 +7899,16 @@ get_rule_expr_paren(Node *node, deparse_context *context,
78997899
}
79007900

79017901
/*
7902-
* get_json_format- Parse back a JsonFormatstructure
7902+
* get_json_format- Parse back a JsonFormatnode
79037903
*/
79047904
staticvoid
79057905
get_json_format(JsonFormat*format,deparse_context*context)
79067906
{
7907-
if (format->type==JS_FORMAT_DEFAULT)
7907+
if (format->format==JS_FORMAT_DEFAULT)
79087908
return;
79097909

79107910
appendStringInfoString(context->buf,
7911-
format->type==JS_FORMAT_JSONB ?
7911+
format->format==JS_FORMAT_JSONB ?
79127912
" FORMAT JSONB" :" FORMAT JSON");
79137913

79147914
if (format->encoding!=JS_ENC_DEFAULT)
@@ -7936,9 +7936,9 @@ get_json_returning(JsonReturning *returning, deparse_context *context,
79367936
returning->typmod));
79377937

79387938
if (!json_format_by_default||
7939-
returning->format.type!=
7939+
returning->format->format!=
79407940
(returning->typid==JSONBOID ?JS_FORMAT_JSONB :JS_FORMAT_JSON))
7941-
get_json_format(&returning->format,context);
7941+
get_json_format(returning->format,context);
79427942
}
79437943

79447944
/* ----------
@@ -9118,7 +9118,7 @@ get_rule_expr(Node *node, deparse_context *context,
91189118
JsonValueExpr*jve= (JsonValueExpr*)node;
91199119

91209120
get_rule_expr((Node*)jve->raw_expr,context, false);
9121-
get_json_format(&jve->format,context);
9121+
get_json_format(jve->format,context);
91229122
}
91239123
break;
91249124

‎src/include/nodes/primnodes.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,8 @@ typedef struct JsonReturning
12431243
typedefstructJsonValueExpr
12441244
{
12451245
NodeTagtype;
1246-
Expr*expr;/* raw expression */
1246+
Expr*raw_expr;/* raw expression */
1247+
Expr*formatted_expr;/* formatted expression or NULL */
12471248
JsonFormat*format;/* FORMAT clause, if specified */
12481249
}JsonValueExpr;
12491250

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp