8000 Add CTE support by yugo-n · Pull Request #47 · sraoss/pg_ivm · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add CTE support #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 30, 2023
Merged

Add CTE support #47

merged 3 commits into from
Jan 30, 2023

Conversation

yugo-n
Copy link
Collaborator
@yugo-n yugo-n commented Jan 16, 2023

Simple CTEs which does not contain aggregates or DISTINCT are now supported similarly to simple sub-queries.

Before a view is maintained, all CTEs are converted to corresponding subqueries to enable to treat CTEs as same as subqueries. For this end, codes of the static fnction inline_cte in the core (optimizer/plan/subselect.c) was imported.

@yugo-n yugo-n requested a review from thoshiai January 16, 2023 07:43
Simple CTEs which does not contain aggregates or DISTINCT are now
supported similarly to simple sub-queries.

Before a view is maintained, all CTEs are converted to corresponding
subqueries to enable to treat CTEs as same as subqueries. For this
end, codes of the static fnction inline_cte in the core
(optimizer/plan/subselect.c) was imported.
When a table in a unreferenced CTE is TRUNCATEd, the contents
of the IMMV is not affected so it must not be truncated. For
confirming it at the maintenance time, we have to check if the
modified table used in a CTE is actually referenced. Although
it would possible, we just disallow to create such IMMVs for now
since such unreferenced CTE is useless unless it doesn't contain
modifying commands, that is already prohibited.

Some error messages are fixed to use "WITH query" instead of "CTE"
as same as in the PostgreSQL core code.

Also, add tests for nested CTE and multiply-referenced CTE, and
a test for nested-subquery in passing.
@thoshiai thoshiai self-requested a review January 29, 2023 23:35
Copy link
Collaborator
@thoshiai 8000 thoshiai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for fixing source code! It looks so good.

@yugo-n
Copy link
Collaborator Author
yugo-n commented Jan 30, 2023

Thank you fore your review!

@yugo-n yugo-n merged commit b928e32 into main Jan 30, 2023
@yugo-n yugo-n deleted the cte branch January 30, 2023 02:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0