Skip to content

Commit 80424b5

Browse files
author
Nikita Glukhov
committed
Add node functtion for JsonFomat and JsonReturning
1 parent 502923b commit 80424b5

File tree

5 files changed

+143
-10
lines changed

5 files changed

+143
-10
lines changed

src/backend/nodes/copyfuncs.c

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2248,6 +2248,37 @@ _copyOnConflictExpr(const OnConflictExpr *from)
22482248
return newnode;
22492249
}
22502250

2251+
2252+
/*
2253+
* _copyJsonFormat
2254+
*/
2255+
static JsonFormat *
2256+
_copyJsonFormat(const JsonFormat *from)
2257+
{
2258+
JsonFormat *newnode = makeNode(JsonFormat);
2259+
2260+
COPY_SCALAR_FIELD(format);
2261+
COPY_SCALAR_FIELD(encoding);
2262+
COPY_LOCATION_FIELD(location);
2263+
2264+
return newnode;
2265+
}
2266+
2267+
/*
2268+
* _copyJsonReturning
2269+
*/
2270+
static JsonReturning *
2271+
_copyJsonReturning(const JsonReturning *from)
2272+
{
2273+
JsonReturning *newnode = makeNode(JsonReturning);
2274+
2275+
COPY_NODE_FIELD(format);
2276+
COPY_SCALAR_FIELD(typid);
2277+
COPY_SCALAR_FIELD(typmod);
2278+
2279+
return newnode;
2280+
}
2281+
22512282
/*
22522283
* _copyJsonValueExpr
22532284
*/
@@ -2258,7 +2289,7 @@ _copyJsonValueExpr(const JsonValueExpr *from)
22582289

22592290
COPY_NODE_FIELD(raw_expr);
22602291
COPY_NODE_FIELD(formatted_expr);
2261-
COPY_SCALAR_FIELD(format);
2292+
COPY_NODE_FIELD(format);
22622293

22632294
return newnode;
22642295
}
@@ -5160,6 +5191,12 @@ copyObjectImpl(const void *from)
51605191
case T_OnConflictExpr:
51615192
retval = _copyOnConflictExpr(from);
51625193
break;
5194+
case T_JsonFormat:
5195+
retval = _copyJsonFormat(from);
5196+
break;
5197+
case T_JsonReturning:
5198+
retval = _copyJsonReturning(from);
5199+
break;
51635200
case T_JsonValueExpr:
51645201
retval = _copyJsonValueExpr(from);
51655202
break;

src/backend/nodes/equalfuncs.c

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -818,14 +818,32 @@ _equalOnConflictExpr(const OnConflictExpr *a, const OnConflictExpr *b)
818818
return true;
819819
}
820820

821+
static bool
822+
_equalJsonFormat(const JsonFormat *a, const JsonFormat *b)
823+
{
824+
COMPARE_SCALAR_FIELD(format);
825+
COMPARE_SCALAR_FIELD(encoding);
826+
COMPARE_LOCATION_FIELD(location);
827+
828+
return true;
829+
}
830+
831+
static bool
832+
_equalJsonReturning(const JsonReturning *a, const JsonReturning *b)
833+
{
834+
COMPARE_NODE_FIELD(format);
835+
COMPARE_SCALAR_FIELD(typid);
836+
COMPARE_SCALAR_FIELD(typmod);
837+
838+
return true;
839+
}
840+
821841
static bool
822842
_equalJsonValueExpr(const JsonValueExpr *a, const JsonValueExpr *b)
823843
{
824844
COMPARE_NODE_FIELD(raw_expr);
825845
COMPARE_NODE_FIELD(formatted_expr);
826-
COMPARE_SCALAR_FIELD(format.type);
827-
COMPARE_SCALAR_FIELD(format.encoding);
828-
COMPARE_LOCATION_FIELD(format.location);
846+
COMPARE_NODE_FIELD(format);
829847

830848
return true;
831849
}
@@ -3222,6 +3240,12 @@ equal(const void *a, const void *b)
32223240
case T_JoinExpr:
32233241
retval = _equalJoinExpr(a, b);
32243242
break;
3243+
case T_JsonFormat:
3244+
retval = _equalJsonFormat(a, b);
3245+
break;
3246+
case T_JsonReturning:
3247+
retval = _equalJsonReturning(a, b);
3248+
break;
32253249
case T_JsonValueExpr:
32263250
retval = _equalJsonValueExpr(a, b);
32273251
break;

src/backend/nodes/nodeFuncs.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2604,6 +2604,7 @@ expression_tree_mutator(Node *node,
26042604
case T_NextValueExpr:
26052605
case T_RangeTblRef:
26062606
case T_SortGroupClause:
2607+
case T_JsonFormat:
26072608
return (Node *) copyObject(node);
26082609
case T_WithCheckOption:
26092610
{
@@ -3198,6 +3199,16 @@ expression_tree_mutator(Node *node,
31983199
return (Node *) newnode;
31993200
}
32003201
break;
3202+
case T_JsonReturning:
3203+
{
3204+
JsonReturning *jr = (JsonReturning *) node;
3205+
JsonReturning *newnode;
3206+
3207+
FLATCOPY(newnode, jr, JsonReturning);
3208+
MUTATE(newnode->format, jr->format, JsonFormat *);
3209+
3210+
return (Node *) newnode;
3211+
}
32013212
case T_JsonValueExpr:
32023213
{
32033214
JsonValueExpr *jve = (JsonValueExpr *) node;
@@ -3206,6 +3217,7 @@ expression_tree_mutator(Node *node,
32063217
FLATCOPY(newnode, jve, JsonValueExpr);
32073218
MUTATE(newnode->raw_expr, jve->raw_expr, Expr *);
32083219
MUTATE(newnode->formatted_expr, jve->formatted_expr, Expr *);
3220+
MUTATE(newnode->format, jve->format, JsonFormat *);
32093221

32103222
return (Node *) newnode;
32113223
}
@@ -3904,6 +3916,8 @@ raw_expression_tree_walker(Node *node,
39043916
break;
39053917
case T_CommonTableExpr:
39063918
return walker(((CommonTableExpr *) node)->ctequery, context);
3919+
case T_JsonReturning:
3920+
return walker(((JsonReturning *) node)->format, context);
39073921
case T_JsonValueExpr:
39083922
{
39093923
JsonValueExpr *jve = (JsonValueExpr *) node;
@@ -3912,6 +3926,8 @@ raw_expression_tree_walker(Node *node,
39123926
return true;
39133927
if (walker(jve->formatted_expr, context))
39143928
return true;
3929+
if (walker(jve->format, context))
3930+
return true;
39153931
}
39163932
break;
39173933
default:

src/backend/nodes/outfuncs.c

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1709,16 +1709,34 @@ _outOnConflictExpr(StringInfo str, const OnConflictExpr *node)
17091709
WRITE_NODE_FIELD(exclRelTlist);
17101710
}
17111711

1712+
static void
1713+
_outJsonFormat(StringInfo str, const JsonFormat *node)
1714+
{
1715+
WRITE_NODE_TYPE("JSONFORMAT");
1716+
1717+
WRITE_ENUM_FIELD(format, JsonFormatType);
1718+
WRITE_ENUM_FIELD(encoding, JsonEncoding);
1719+
WRITE_LOCATION_FIELD(location);
1720+
}
1721+
1722+
static void
1723+
_outJsonReturning(StringInfo str, const JsonReturning *node)
1724+
{
1725+
WRITE_NODE_TYPE("JSONRETURNING");
1726+
1727+
WRITE_NODE_FIELD(format);
1728+
WRITE_OID_FIELD(typid);
1729+
WRITE_INT_FIELD(typmod);
1730+
}
1731+
17121732
static void
17131733
_outJsonValueExpr(StringInfo str, const JsonValueExpr *node)
17141734
{
17151735
WRITE_NODE_TYPE("JSONVALUEEXPR");
17161736

17171737
WRITE_NODE_FIELD(raw_expr);
17181738
WRITE_NODE_FIELD(formatted_expr);
1719-
WRITE_ENUM_FIELD(format.type, JsonFormatType);
1720-
WRITE_ENUM_FIELD(format.encoding, JsonEncoding);
1721-
WRITE_LOCATION_FIELD(format.location);
1739+
WRITE_NODE_FIELD(format);
17221740
}
17231741

17241742
/*****************************************************************************
@@ -4349,6 +4367,12 @@ outNode(StringInfo str, const void *obj)
43494367
case T_PartitionRangeDatum:
43504368
_outPartitionRangeDatum(str, obj);
43514369
break;
4370+
case T_JsonFormat:
4371+
_outJsonFormat(str, obj);
4372+
break;
4373+
case T_JsonReturning:
4374+
_outJsonReturning(str, obj);
4375+
break;
43524376
case T_JsonValueExpr:
43534377
_outJsonValueExpr(str, obj);
43544378
break;

src/backend/nodes/readfuncs.c

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,6 +1343,36 @@ _readOnConflictExpr(void)
13431343
READ_DONE();
13441344
}
13451345

1346+
/*
1347+
* _readJsonFormat
1348+
*/
1349+
static JsonFormat *
1350+
_readJsonFormat(void)
1351+
{
1352+
READ_LOCALS(JsonFormat);
1353+
1354+
READ_ENUM_FIELD(format, JsonFormatType);
1355+
READ_ENUM_FIELD(encoding, JsonEncoding);
1356+
READ_LOCATION_FIELD(location);
1357+
1358+
READ_DONE();
1359+
}
1360+
1361+
/*
1362+
* _readJsonReturning
1363+
*/
1364+
static JsonReturning *
1365+
_readJsonReturning(void)
1366+
{
1367+
READ_LOCALS(JsonReturning);
1368+
1369+
READ_NODE_FIELD(format);
1370+
READ_OID_FIELD(typid);
1371+
READ_INT_FIELD(typmod);
1372+
1373+
READ_DONE();
1374+
}
1375+
13461376
/*
13471377
* _readJsonValueExpr
13481378
*/
@@ -1353,9 +1383,7 @@ _readJsonValueExpr(void)
13531383

13541384
READ_NODE_FIELD(raw_expr);
13551385
READ_NODE_FIELD(formatted_expr);
1356-
READ_ENUM_FIELD(format.type, JsonFormatType);
1357-
READ_ENUM_FIELD(format.encoding, JsonEncoding);
1358-
READ_LOCATION_FIELD(format.location);
1386+
READ_NODE_FIELD(format);
13591387

13601388
READ_DONE();
13611389
}
@@ -2897,6 +2925,10 @@ parseNodeString(void)
28972925
return_value = _readPartitionBoundSpec();
28982926
else if (MATCH("PARTITIONRANGEDATUM", 19))
28992927
return_value = _readPartitionRangeDatum();
2928+
else if (MATCH("JSONFORMAT", 10))
2929+
return_value = _readJsonFormat();
2930+
else if (MATCH("JSONRETURNING", 13))
2931+
return_value = _readJsonReturning();
29002932
else if (MATCH("JSONVALUEEXPR", 13))
29012933
return_value = _readJsonValueExpr();
29022934
else

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy