Hi, The attached patch makes SQL/JSON PASSING clauses reject duplicate variable names instead of silently using the first matching value.
For example, this previously returned only "comedy":
SELECT jt.kind
FROM JSON_TABLE(
'{ "favorites":[{ "kind" : "comedy" },{ "kind" : "drama" }] }',
'$.favorites[*]?(@.kind == $k1)'
PASSING 'comedy' AS k1, 'drama' AS k1
COLUMNS (kind text PATH '$.kind')
) AS jt;
With the patch it raises:
ERROR: PASSING argument name "k1" is not unique
The same check applies to JSON_EXISTS, JSON_QUERY, JSON_VALUE, and
JSON_TABLE because they all use transformJsonPassingArgs(). The patch
also adds regression tests for JSON_QUERY and JSON_TABLE.
The patch was tested with the full regression suite on current master.
Thanks,
DeWei Dai
HighGo Software Co., Ltd.
https://www.highgo.com/
[email protected]
0001-Reject-duplicate-PASSING-argument-names.patch
Description: Binary data
