Met strange behavior using query with json_table in cte at oracle - connection reset from server, without details.
Illustrating artificial query is:
with data as ( select 5 as some_value from dual),ps as ( select dt.some_value, json_cnt from data dt cross join json_table( to_clob('{"positions":[{"name":"aaa","cnt":5}]}'),'$' columns ( nested path '$.positions[*]' columns ( json_cnt varchar2 path '$.cnt' ) ) ))-- select * -- its ok -- select count(json_cnt) -- also okselect count(*) -- fails with connection resetfrom ps
It behaves such way:
count(*)
- leads to "No more data read from socket" and 17410 error*
- leads to correct fields representationcount(json_cnt)
- leads to correct count (1)
In real scenario query is more complicated and uses data from real tables, but for illustration purpose cut it to be reproducible(at least in my environment) in simplified format.
More I can say, that adding some kind of additional use of intermediate cte, "corrects" expected behavior. following query works without a problem :
with data as ( select 5 as some_value from dual),ps as ( select dt.some_value, json_cnt from data dt cross join json_table( to_clob('{"positions":[{"name":"aaa","cnt":5}]}'),'$' columns ( nested path '$.positions[*]' columns ( json_cnt varchar2 path '$.cnt' ) ) )),int_cte as ( select 5 as json_cnt from dual)select count(*)from psleft join int_cte on ps.json_cnt = int_cte.json_cnt;
I can guess, that there is some strange combo of cross join leading to this, but don't understand the reason. And it took a time to figure out the source of a problem in real query.
Can somebody give a hint what is wrong with first query and what leads to error without explicit check but connection reset.
Version: 12.2.0.1.0