On 07.01.2018 00:11, Pavel Stehule wrote:
Operators are necessary for index support now.
Operators allows us to use a more concise syntax in simple cases, when we extract JSON item(s) without error handling:
js @* '$.key' vs
JSON_QUERY(js, '$.key' RETURNING jsonb ERROR ON ERROR) Also @* оperator gives us ability to extract a set of JSON items. JSON_QUERY can only wrap extracted item sequence into JSON array which we have to unwrap with our json[b]_array_elements() function. I also thought about returning setof-types in JSON_VALUE/JSON_QUERY:
JSON_QUERY(jsonb '[1,2,3]', '$[*]' RETURNING SETOF jsonb)
But it is not so easy to implement now, because we should introduce new node like TableFunc (or also we can try to use existing JSON_TABLE infrastructure).
Set-returning expressions are not allowed in every context, so for returning singleton items there should be additional operator.
--