@@ -91,7 +91,6 @@ flattenJsonPathParseItem(StringInfo buf, JsonPathParseItem *item,
91
91
{
92
92
int32 left , right ;
93
93
94
- forbiddenRoot = true;
95
94
left = buf -> len ;
96
95
97
96
/*
@@ -102,9 +101,9 @@ flattenJsonPathParseItem(StringInfo buf, JsonPathParseItem *item,
102
101
right = buf -> len ;
103
102
appendBinaryStringInfo (buf , (char * )& right /* fake value */ , sizeof (right ));
104
103
105
- chld = flattenJsonPathParseItem (buf , item -> value .args .left , true );
104
+ chld = flattenJsonPathParseItem (buf , item -> value .args .left , forbiddenRoot );
106
105
* (int32 * )(buf -> data + left ) = chld ;
107
- chld = flattenJsonPathParseItem (buf , item -> value .args .right , true );
106
+ chld = flattenJsonPathParseItem (buf , item -> value .args .right , forbiddenRoot );
108
107
* (int32 * )(buf -> data + right ) = chld ;
109
108
}
110
109
break ;
@@ -120,8 +119,9 @@ flattenJsonPathParseItem(StringInfo buf, JsonPathParseItem *item,
120
119
arg = buf -> len ;
121
120
appendBinaryStringInfo (buf , (char * )& arg /* fake value */ , sizeof (arg ));
122
121
123
- forbiddenRoot = true;
124
- chld = flattenJsonPathParseItem (buf , item -> value .arg , true);
122
+ chld = flattenJsonPathParseItem (buf , item -> value .arg ,
123
+ item -> type == jpiFilter ||
124
+ forbiddenRoot );
125
125
* (int32 * )(buf -> data + arg ) = chld ;
126
126
}
127
127
break ;
@@ -136,9 +136,15 @@ flattenJsonPathParseItem(StringInfo buf, JsonPathParseItem *item,
136
136
ereport (ERROR ,
137
137
(errcode (ERRCODE_SYNTAX_ERROR ),
138
138
errmsg ("root is not allowed in expression" )));
139
+ break ;
139
140
case jpiAnyArray :
140
141
case jpiAnyKey :
142
+ break ;
141
143
case jpiCurrent :
144
+ if (!forbiddenRoot )
145
+ ereport (ERROR ,
146
+ (errcode (ERRCODE_SYNTAX_ERROR ),
147
+ errmsg ("@ is not allowed in root expressions" )));
142
148
break ;
143
149
case jpiIndexArray :
144
150
appendBinaryStringInfo (buf ,
0 commit comments