Hi Zhenglong,
I found one remaining correctness issue involving result-domain coercion:
ExecInitJsonExpr() returns NULL as soon as the context item or the
path specification evaluates to NULL
Result coercion still runs after that shortcut. A RETURNING domain with
NOT NULL can reject NULL and invoke EMPTY ARRAY ON ERROR, producing [].
With v2, the attached reproducer returns [] for a NULL argument to an
inlined STRICT wrapper; preventing inlining returns SQL NULL. Outer-join pull-up has the same problem.
In local testing, a conservative domain guard fixes these cases, but also
disables some safe inlining. An unconstrained-domain JSON_QUERY wrapper went
from about 35 ms to 196 ms over 100,000 rows (5.6x), while direct-_expression_
timings remained comparable.
Should we preserve unconstrained-domain inlining, with cached plans rebuilt
if constraints are added to the domain or its parents?
Thanks,
Ethan
Attached: domain-reproducer.sql |
domain-reproducer.sql
Description: Binary data