[YSQL] CTE not included in final select statement being skipped #22403
Description
Jira Link: DB-11306
Description
The sample_sql.txt attachment contains a schema, types, functions and sample data for the table. It's quite large since I'm not sure how much I could pare down the example while still exhibiting the same behavior.
This was tested against Yugabyte 2.20.1.3-b3.
The two functions in question are essentially object_close()
and object_close_no_dangling_cte()
. Essentially there are three tables, there's the object
table which is just a table of objects, subobject
table containing transient parts of an object, object_attr
which contains attributes of an object and object_subobject_attr
which similar to suboject
is transient attributes of parts.
What the object_close()
function does is essentially takes all the transient data that are to be included (some can be excluded) and includes the subobject
information into the object
table and merges the subobject attributes to the object attributes.
The CTE that is being skipped in object_close()
is the one with the attrs
alias. The same alias is included in the final select statement with a join in the object_close_no_dangling_cte()
function. That is after executing object_close()
, the object_attr
table does not contain the attributes from the transient object_subobject_attr
table, but it does when executing the object_close_no_dangling_cte()
function. The question is why is this being skipped? Originally I thought all dangling CTEs were being skipped, but another function, object_subobject_close()
contains a dangling CTE that is correctly being executed.
There was another issue I was running into, but can't seem to reproduce anymore, where a transaction that was being rolled back after calling either object_close()
and object_close_no_dangling_cte()
where the changes caused by object_subobject_close()
function was being partially committed with the snapshot isolation level. I can't seem to reproduce what I was seeing here though, but thought I'd mention in.
Issue Type
kind/question
Warning: Please confirm that this issue does not contain any sensitive information
- I confirm this issue does not contain any sensitive information.