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

Commitceb864a

Browse files
author
Nikita Glukhov
committed
Add nodes JsonFormat and JsonRetuning
1 parent59f8c5c commitceb864a

File tree

6 files changed

+45
-29
lines changed

6 files changed

+45
-29
lines changed

‎src/backend/nodes/makefuncs.c‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,12 +816,28 @@ makeVacuumRelation(RangeVar *relation, Oid oid, List *va_cols)
816816
returnv;
817817
}
818818

819+
/*
820+
* makeJsonFormat -
821+
* creates a JsonFormat node
822+
*/
823+
JsonFormat*
824+
makeJsonFormat(JsonFormatTypetype,JsonEncodingencoding,intlocation)
825+
{
826+
JsonFormat*jf=makeNode(JsonFormat);
827+
828+
jf->format=type;
829+
jf->encoding=encoding;
830+
jf->location=location;
831+
832+
returnjf;
833+
}
834+
819835
/*
820836
* makeJsonValueExpr -
821837
* creates a JsonValueExpr node
822838
*/
823839
JsonValueExpr*
824-
makeJsonValueExpr(Expr*expr,JsonFormatformat)
840+
makeJsonValueExpr(Expr*expr,JsonFormat*format)
825841
{
826842
JsonValueExpr*jve=makeNode(JsonValueExpr);
827843

‎src/backend/parser/gram.y‎

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
220220
JoinTypejtype;
221221
DropBehaviordbehavior;
222222
OnCommitActiononcommit;
223-
JsonFormatjsformat;
224223
List*list;
225224
Node*node;
226225
Value*value;
@@ -600,15 +599,14 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
600599
%type<list>hash_partbound
601600
%type<defelt>hash_partbound_elem
602601

603-
%type<node>json_value_expr
602+
%type<node>json_format_clause_opt
603+
json_representation
604+
json_value_expr
604605
json_output_clause_opt
605606

606607
%type<ival>json_encoding
607608
json_encoding_clause_opt
608609

609-
%type<jsformat>json_format_clause_opt
610-
json_representation
611-
612610
/*
613611
* Non-keyword token types. These are hard-wired into the "flex" lexer.
614612
* They must be listed first so that their numeric codes do not depend on
@@ -14662,18 +14660,14 @@ json_format_clause_opt:
1466214660
}
1466314661
|/* EMPTY*/
1466414662
{
14665-
$$.type = JS_FORMAT_DEFAULT;
14666-
$$.encoding = JS_ENC_DEFAULT;
14667-
$$.location = -1;
14663+
$$ = (Node *)makeJsonFormat(JS_FORMAT_DEFAULT, JS_ENC_DEFAULT, -1);
1466814664
}
1466914665
;
1467014666

1467114667
json_representation:
1467214668
JSON json_encoding_clause_opt
1467314669
{
14674-
$$.type = JS_FORMAT_JSON;
14675-
$$.encoding = $2;
14676-
$$.location = @1;
14670+
$$ = (Node *)makeJsonFormat(JS_FORMAT_JSON, $2, @1);
1467714671
}
1467814672
/*| implementation_defined_JSON_representation_option (BSON, AVRO etc)*/
1467914673
;

‎src/include/nodes/makefuncs.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ extern GroupingSet *makeGroupingSet(GroupingSetKind kind, List *content, int loc
105105

106106
externVacuumRelation*makeVacuumRelation(RangeVar*relation,Oidoid,List*va_cols);
107107

108-
externJsonValueExpr*makeJsonValueExpr(Expr*expr,JsonFormatformat);
108+
externJsonFormat*makeJsonFormat(JsonFormatTypetype,JsonEncodingencoding,
109+
intlocation);
110+
externJsonValueExpr*makeJsonValueExpr(Expr*expr,JsonFormat*format);
109111
externJsonEncodingmakeJsonEncoding(char*name);
110112

111113
#endif/* MAKEFUNC_H */

‎src/include/nodes/nodes.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,9 @@ typedef enum NodeTag
198198
T_FromExpr,
199199
T_OnConflictExpr,
200200
T_IntoClause,
201+
T_JsonFormat,
202+
T_JsonReturning,
203+
T_JsonValueExpr,
201204

202205
/*
203206
* TAGS FOR EXPRESSION STATE NODES (execnodes.h)
@@ -481,7 +484,6 @@ typedef enum NodeTag
481484
T_PartitionRangeDatum,
482485
T_PartitionCmd,
483486
T_VacuumRelation,
484-
T_JsonValueExpr,
485487
T_JsonOutput,
486488

487489
/*

‎src/include/nodes/parsenodes.h‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,17 +1499,6 @@ typedef struct JsonOutput
14991499
JsonReturningreturning;/* RETURNING FORMAT clause and type Oids */
15001500
}JsonOutput;
15011501

1502-
/*
1503-
* JsonValueExpr -
1504-
*representation of JSON value expression (expr [FORMAT json_format])
1505-
*/
1506-
typedefstructJsonValueExpr
1507-
{
1508-
NodeTagtype;
1509-
Expr*expr;/* raw expression */
1510-
JsonFormatformat;/* FORMAT clause, if specified */
1511-
}JsonValueExpr;
1512-
15131502

15141503
/*****************************************************************************
15151504
*Raw Grammar Output Statements

‎src/include/nodes/primnodes.h‎

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,9 +1218,10 @@ typedef enum JsonFormatType
12181218
*/
12191219
typedefstructJsonFormat
12201220
{
1221-
JsonFormatTypetype;/* format type */
1222-
JsonEncodingencoding;/* JSON encoding */
1223-
intlocation;/* token location, or -1 if unknown */
1221+
NodeTagtype;
1222+
JsonFormatTypeformat;/* format type */
1223+
JsonEncodingencoding;/* JSON encoding */
1224+
intlocation;/* token location, or -1 if unknown */
12241225
}JsonFormat;
12251226

12261227
/*
@@ -1229,11 +1230,23 @@ typedef struct JsonFormat
12291230
*/
12301231
typedefstructJsonReturning
12311232
{
1232-
JsonFormatformat;/* output JSON format */
1233+
NodeTagtype;
1234+
JsonFormat*format;/* output JSON format */
12331235
Oidtypid;/* target type Oid */
12341236
int32typmod;/* target type modifier */
12351237
}JsonReturning;
12361238

1239+
/*
1240+
* JsonValueExpr -
1241+
*representation of JSON value expression (expr [FORMAT json_format])
1242+
*/
1243+
typedefstructJsonValueExpr
1244+
{
1245+
NodeTagtype;
1246+
Expr*expr;/* raw expression */
1247+
JsonFormat*format;/* FORMAT clause, if specified */
1248+
}JsonValueExpr;
1249+
12371250
/* ----------------
12381251
* NullTest
12391252
*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp