Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 18b74ac

Browse files
author
Nikita Glukhov
committed
Add JSON_OBJECT() transformation
1 parent 04810d0 commit 18b74ac

File tree

10 files changed

+1152
-16
lines changed

10 files changed

+1152
-16
lines changed

src/backend/nodes/copyfuncs.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2122,6 +2122,37 @@ _copyOnConflictExpr(const OnConflictExpr *from)
21222122
return newnode;
21232123
}
21242124

2125+
/*
2126+
* _copyJsonKeyValue
2127+
*/
2128+
static JsonKeyValue *
2129+
_copyJsonKeyValue(const JsonKeyValue *from)
2130+
{
2131+
JsonKeyValue *newnode = makeNode(JsonKeyValue);
2132+
2133+
COPY_NODE_FIELD(key);
2134+
COPY_NODE_FIELD(value);
2135+
2136+
return newnode;
2137+
}
2138+
2139+
/*
2140+
* _copyJsonObjectCtor
2141+
*/
2142+
static JsonObjectCtor *
2143+
_copyJsonObjectCtor(const JsonObjectCtor *from)
2144+
{
2145+
JsonObjectCtor *newnode = makeNode(JsonObjectCtor);
2146+
2147+
COPY_NODE_FIELD(exprs);
2148+
COPY_NODE_FIELD(output);
2149+
COPY_SCALAR_FIELD(absent_on_null);
2150+
COPY_SCALAR_FIELD(unique);
2151+
COPY_LOCATION_FIELD(location);
2152+
2153+
return newnode;
2154+
}
2155+
21252156
/* ****************************************************************
21262157
* relation.h copy functions
21272158
*
@@ -4989,6 +5020,12 @@ copyObjectImpl(const void *from)
49895020
case T_OnConflictExpr:
49905021
retval = _copyOnConflictExpr(from);
49915022
break;
5023+
case T_JsonKeyValue:
5024+
retval = _copyJsonKeyValue(from);
5025+
break;
5026+
case T_JsonObjectCtor:
5027+
retval = _copyJsonObjectCtor(from);
5028+
break;
49925029

49935030
/*
49945031
* RELATION NODES

src/backend/nodes/nodeFuncs.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3679,6 +3679,30 @@ raw_expression_tree_walker(Node *node,
36793679
break;
36803680
case T_CommonTableExpr:
36813681
return walker(((CommonTableExpr *) node)->ctequery, context);
3682+
case T_JsonValueExpr:
3683+
return walker(((JsonValueExpr *) node)->expr, context);
3684+
case T_JsonOutput:
3685+
return walker(((JsonOutput *) node)->typename, context);
3686+
case T_JsonKeyValue:
3687+
{
3688+
JsonKeyValue *jkv = (JsonKeyValue *) node;
3689+
3690+
if (walker(jkv->key, context))
3691+
return true;
3692+
if (walker(jkv->value, context))
3693+
return true;
3694+
}
3695+
break;
3696+
case T_JsonObjectCtor:
3697+
{
3698+
JsonObjectCtor *joc = (JsonObjectCtor *) node;
3699+
3700+
if (walker(joc->output, context))
3701+
return true;
3702+
if (walker(joc->exprs, context))
3703+
return true;
3704+
}
3705+
break;
36823706
default:
36833707
elog(ERROR, "unrecognized node type: %d",
36843708
(int) nodeTag(node));

0 commit comments

Comments
 (0)