On Tue, Feb 18, 2025 at 7:09 PM Richard Guo <guofengli...@gmail.com> wrote: > It seems to me that, for a relation in the rangetable that has virtual > generated columns, we can consider it a subquery to some extent. For > instance, suppose we have a query: > > select ... from ... join t on ...; > > and suppose t.b is a virtual generated column. We can consider this > query as: > > select ... from ... join (select a, expr() as b from t) as t on ...; > > In this sense, I'm wondering if we can leverage the > pullup_replace_vars architecture to expand the virtual generated > columns. I believe this would help avoid a lot of duplicate code with > pullup_replace_vars_callback.
I had a try with this idea, and attached is what I came up with. It fixes all the mentioned issues but still requires significant refinement, particularly due to the lack of comments. By leveraging the pullup_replace_vars architecture to expand the virtual generated columns, it saves a lot of duplicate code. Thanks Richard
v2-0001-Expand-virtual-generated-columns-in-planner.patch
Description: Binary data