pgsql: Expand virtual generated columns before sublink pull-up

2025-07-21 Thread Richard Guo
uired during sublink pull-up, we are moving the expansion of virtual generated columns to occur beforehand. To achieve this, if any EXISTS SubLinks can be pulled up, their rangetables are processed just before pulling them up. Author: Richard Guo Reviewed-by: Robert Haas Reviewed-by: Tom Lane Discu

pgsql: Reduce "Var IS [NOT] NULL" quals during constant folding

2025-07-21 Thread Richard Guo
w IS NOT NULL quals after constant folding, and (b) if some outer joins are converted to inner joins, previously irreducible NullTest quals may become reducible. Author: Richard Guo Reviewed-by: Robert Haas Reviewed-by: Tom Lane Discussion: https://postgr.es/m/CAMbWs4-bFJ1At4btk5wqbezdu8PLtQ3zv-aiaY3r

pgsql: Centralize collection of catalog info needed early in the planne

2025-07-21 Thread Richard Guo
ation in the rangetable. This patch centralizes the collection of all required early-stage catalog information into a single loop over the rangetable, allowing each relation to be opened and closed only once. Author: Richard Guo Reviewed-by: Robert Haas Reviewed-by: Tom Lane Discussion:

pgsql: Consider explicit incremental sort for Append and MergeAppend

2025-07-07 Thread Richard Guo
: Richard Guo Reviewed-by: Andrei Lepikhov Reviewed-by: Robert Haas Discussion: https://postgr.es/m/cambws4_v7a2entr+t3poy_yz-fu8zsfyym2swoz4jnmqmsg...@mail.gmail.com Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/55a780e9476a753354a6db887e92125c7886ca6d

pgsql: Enable use of Memoize for ANTI joins

2025-07-02 Thread Richard Guo
this patch, we check whether the inner relation is provably unique for ANTI joins and enable the use of Memoize in such cases. Author: Richard Guo Reviewed-by: wenhui qiu Reviewed-by: Andrei Lepikhov Discussion: https://postgr.es/m/cambws48fdlimnrmjl-g6mdvoqvt0ynyjaqmkv4e2pk-5gkc...@mail.gmail.c

pgsql: Expand virtual generated columns for ALTER COLUMN TYPE

2025-06-25 Thread Richard Guo
Expand virtual generated columns for ALTER COLUMN TYPE For the subcommand ALTER COLUMN TYPE of the ALTER TABLE command, the USING expression may reference virtual generated columns. These columns must be expanded before the expression is fed through expression_planner and the expression-execution

pgsql: Fix Assert failure in XMLTABLE parser

2025-05-15 Thread Richard Guo
o. Additionally, the internal name is renamed to "__pg__is_not_null" to further reduce the risk of collision with user-defined names. Reported-by: Евгений Горбанев Author: Richard Guo Reviewed-by: Alvaro Herrera Discussion: https://postgr.es/m/6bac9886-65bf-4cec-96bd-e304159f2...@ba

pgsql: Fix Assert failure in XMLTABLE parser

2025-05-15 Thread Richard Guo
o. Additionally, the internal name is renamed to "__pg__is_not_null" to further reduce the risk of collision with user-defined names. Reported-by: Евгений Горбанев Author: Richard Guo Reviewed-by: Alvaro Herrera Discussion: https://postgr.es/m/6bac9886-65bf-4cec-96bd-e304159f2...@ba

pgsql: Fix Assert failure in XMLTABLE parser

2025-05-15 Thread Richard Guo
o. Additionally, the internal name is renamed to "__pg__is_not_null" to further reduce the risk of collision with user-defined names. Reported-by: Евгений Горбанев Author: Richard Guo Reviewed-by: Alvaro Herrera Discussion: https://postgr.es/m/6bac9886-65bf-4cec-96bd-e304159f2...@ba

pgsql: Fix Assert failure in XMLTABLE parser

2025-05-15 Thread Richard Guo
o. Additionally, the internal name is renamed to "__pg__is_not_null" to further reduce the risk of collision with user-defined names. Reported-by: Евгений Горбанев Author: Richard Guo Reviewed-by: Alvaro Herrera Discussion: https://postgr.es/m/6bac9886-65bf-4cec-96bd-e304159f2...@ba

pgsql: Add explicit initialization for all PlannerGlobal fields

2025-05-13 Thread Richard Guo
cy is undesirable from a clarity and maintenance perspective. This patch explicitly initializes the remaining fields to improve consistency and readability. Author: Richard Guo Reviewed-by: David Rowley Discussion: https://postgr.es/m/cambws4-tgqhnoiouqgcuhobqbjjwyx4uxgkxuy3frf4trgb...@mail.gmai

pgsql: Suppress unnecessary explicit sorting for EPQ mergejoin path

2025-05-08 Thread Richard Guo
18902 Reported-by: Nikita Kalinin Author: Richard Guo Reviewed-by: Tender Wang Discussion: https://postgr.es/m/18902-71c1bed2b9f7c...@postgresql.org Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/773db22269d474fab46d25e9e15b1e55252cf92c Modified

pgsql: Track the number of presorted outer pathkeys in MergePath

2025-05-08 Thread Richard Guo
calling pathkeys_count_contained_in. This patch caches the number of presorted outer pathkeys in MergePath, allowing us to save several calls to pathkeys_count_contained_in. It can be considered a complement to the changes in commit 828e94c9d. Reported-by: David Rowley Author: Richard Guo

pgsql: Fix an incorrect check in get_memoize_path

2025-04-15 Thread Richard Guo
se of the current join is present in ppi_clauses. While we're here, remove the XXX comment from the modified code, as it's not justified; in certain cases, it's not possible to move a join clause to the inner side. This is arguably a bugfix, but no backpatch given the lack of field re

pgsql: Remove duplicated comment in get_relation_constraints

2025-04-05 Thread Richard Guo
Remove duplicated comment in get_relation_constraints The check for non-inheritable constraints is performed later, and the same comment is included at that point. While we're here, remove one extraneous blank line. Author: jian he Reviewed-by: Kirill Reshke Reviewed-by: Richar

pgsql: Fix integer-overflow problem in scram_SaltedPassword()

2025-03-26 Thread Richard Guo
tions" instead. Back-patch to v16 where the user-settable GUC scram_iterations has been added. Author: Kevin K Biju Reviewed-by: Richard Guo Reviewed-by: Michael Paquier Discussion: https://postgr.es/m/cam45keemm8hnxdtoxa98qhfz9czgddgy3mxgjmy0c+2wwja...@mail.gmail.com Branch ---

pgsql: Fix integer-overflow problem in scram_SaltedPassword()

2025-03-26 Thread Richard Guo
tions" instead. Back-patch to v16 where the user-settable GUC scram_iterations has been added. Author: Kevin K Biju Reviewed-by: Richard Guo Reviewed-by: Michael Paquier Discussion: https://postgr.es/m/cam45keemm8hnxdtoxa98qhfz9czgddgy3mxgjmy0c+2wwja...@mail.gmail.com Branch ---

pgsql: Fix integer-overflow problem in scram_SaltedPassword()

2025-03-26 Thread Richard Guo
tions" instead. Back-patch to v16 where the user-settable GUC scram_iterations has been added. Author: Kevin K Biju Reviewed-by: Richard Guo Reviewed-by: Michael Paquier Discussion: https://postgr.es/m/cam45keemm8hnxdtoxa98qhfz9czgddgy3mxgjmy0c+2wwja...@mail.gmail.com Branch -- mas

pgsql: Remove code setting wrap_non_vars to true for UNION ALL subqueri

2025-03-13 Thread Richard Guo
sets wrap_non_vars to false before performing pullup_replace_vars on the AppendRelInfo. This patch simply removes the code that sets wrap_non_vars to true for UNION ALL subqueries. Author: Richard Guo Reviewed-by: Dean Rasheed Discussion: https://postgr.es/m/cambws4-vx

pgsql: Fix incorrect handling of subquery pullup

2025-03-13 Thread Richard Guo
y: Dean Rasheed Author: Richard Guo Reviewed-by: Dean Rasheed Discussion: https://postgr.es/m/cambws4-mesahaankskpbn0kkxdhaxc1_ejcvwhxeodqirrg...@mail.gmail.com Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/cc5d98525d43c22b98f360ef0f2c8d7dc57f04dc Modified Files ---

pgsql: Avoid NullTest deduction for clone clauses

2025-03-03 Thread Richard Guo
to no longer trigger the bug that commit fixed, so we also remove that test case. Back-patch to v17 where this bug crept in. Reported-by: Ronald Cruz Diagnosed-by: Tom Lane Author: Richard Guo Reviewed-by: Tom Lane Discussion: https://postgr.es/m/f5320d3d-77af-4ce8-b9c3-4715ff33f...@rentec.com Back

pgsql: Avoid NullTest deduction for clone clauses

2025-03-03 Thread Richard Guo
to no longer trigger the bug that commit fixed, so we also remove that test case. Back-patch to v17 where this bug crept in. Reported-by: Ronald Cruz Diagnosed-by: Tom Lane Author: Richard Guo Reviewed-by: Tom Lane Discussion: https://postgr.es/m/f5320d3d-77af-4ce8-b9c3-4715ff33f...@rentec.com Back

pgsql: Expand virtual generated columns in the planner

2025-02-24 Thread Richard Guo
st Vars in pullup_replace_vars_callback, as it may now deal with Vars referencing the result relation instead of a subquery. The "wrong varnullingrels" error was reported by Alexander Lakhin. The incorrect result issue and the improper outer-join removal issue were reported by Richard Guo. Author:

pgsql: Eliminate code duplication in replace_rte_variables callbacks

2025-02-24 Thread Richard Guo
eliminating code duplication. Author: Dean Rasheed Author: Richard Guo Reviewed-by: Jian He Discussion: https://postgr.es/m/CAEZATCWhr=fm4x5kcpvvs-g2xek+celsntbk_zzmkqfn9vu...@mail.gmail.com Branch -- master Details --- https://git.postgresql.org/pg/commitdiff

pgsql: Fix unsafe access to BufferDescriptors

2025-02-18 Thread Richard Guo
lead to any malfunction. Nonetheless this seems like trouble waiting to happen, so fix it by ensuring that GetBufferDescriptor() is only called when we know the buffer is shared. Author: Tender Wang Reviewed-by: Xuneng Zhou Reviewed-by: Richard Guo Discussion: https://postgr.es/m/CAHewXNku-o46

pgsql: Fix unsafe access to BufferDescriptors

2025-02-18 Thread Richard Guo
lead to any malfunction. Nonetheless this seems like trouble waiting to happen, so fix it by ensuring that GetBufferDescriptor() is only called when we know the buffer is shared. Author: Tender Wang Reviewed-by: Xuneng Zhou Reviewed-by: Richard Guo Discussion: https://postgr.es/m/CAHewXNku-o46

pgsql: Fix unsafe access to BufferDescriptors

2025-02-18 Thread Richard Guo
lead to any malfunction. Nonetheless this seems like trouble waiting to happen, so fix it by ensuring that GetBufferDescriptor() is only called when we know the buffer is shared. Author: Tender Wang Reviewed-by: Xuneng Zhou Reviewed-by: Richard Guo Discussion: https://postgr.es/m/CAHewXNku-o46

pgsql: Fix unsafe access to BufferDescriptors

2025-02-18 Thread Richard Guo
lead to any malfunction. Nonetheless this seems like trouble waiting to happen, so fix it by ensuring that GetBufferDescriptor() is only called when we know the buffer is shared. Author: Tender Wang Reviewed-by: Xuneng Zhou Reviewed-by: Richard Guo Discussion: https://postgr.es/m/CAHewXNku-o46

pgsql: Fix unsafe access to BufferDescriptors

2025-02-18 Thread Richard Guo
lead to any malfunction. Nonetheless this seems like trouble waiting to happen, so fix it by ensuring that GetBufferDescriptor() is only called when we know the buffer is shared. Author: Tender Wang Reviewed-by: Xuneng Zhou Reviewed-by: Richard Guo Discussion: https://postgr.es/m/CAHewXNku-o46

pgsql: Fix unsafe access to BufferDescriptors

2025-02-18 Thread Richard Guo
lead to any malfunction. Nonetheless this seems like trouble waiting to happen, so fix it by ensuring that GetBufferDescriptor() is only called when we know the buffer is shared. Author: Tender Wang Reviewed-by: Xuneng Zhou Reviewed-by: Richard Guo Discussion: https://postgr.es/m/CAHewXNku-o46

pgsql: Fix freeing a child join's SpecialJoinInfo

2025-02-18 Thread Richard Guo
t in. Bug: #18806 Reported-by: 孟令彬 Diagnosed-by: Tender Wang Author: Richard Guo Reviewed-by: Amit Langote Reviewed-by: Ashutosh Bapat Discussion: https://postgr.es/m/18806-d70b0c9fdf63d...@postgresql.org Backpatch-through: 17 Branch -- REL_17_STABLE Details --- https

pgsql: Fix freeing a child join's SpecialJoinInfo

2025-02-18 Thread Richard Guo
t in. Bug: #18806 Reported-by: 孟令彬 Diagnosed-by: Tender Wang Author: Richard Guo Reviewed-by: Amit Langote Reviewed-by: Ashutosh Bapat Discussion: https://postgr.es/m/18806-d70b0c9fdf63d...@postgresql.org Backpatch-through: 17 Branch -- master Details --- https

pgsql: Adjust tuples estimate for appendrels

2025-02-16 Thread Richard Guo
with reality. This is arguably a bug, but nobody has complained about that until now, so no back-patch. Author: Richard Guo Reviewed-by: Tender Wang Reviewed-by: Alena Rybakina Discussion: https://postgr.es/m/CAMbWs4_TG_+kVn6fjG-5GYzzukrNK57=g9euo4gsrug26of...@mail.gmail.com Branc

pgsql: Fix pgindent damage

2025-01-12 Thread Richard Guo
Fix pgindent damage Oversight in commit e0ece2a98. Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/6e826278f1ebd9967c0f8adda29c8960a812e344 Modified Files -- src/backend/executor/execGrouping.c | 2 +- src/include/nodes/execnodes.h | 2 +- 2 files c

pgsql: Remove unused parameter in lookup_var_attr_stats

2025-01-06 Thread Richard Guo
Remove unused parameter in lookup_var_attr_stats The parameter 'rel' in lookup_var_attr_stats was once used to draw an ERROR when ANALYZE failed to acquire sufficient data to build extended statistics. bf2a691e0 changed the logic to raise a WARNING in the caller instead. As a result, this parame

pgsql: Ignore nullingrels when looking up statistics

2025-01-02 Thread Richard Guo
compromise its original purpose. This patch could result in plan changes, but it fixes an actual bug, so back-patch to v16 where the outer-join-aware-Var infrastructure was introduced. Author: Richard Guo Discussion: https://postgr.es/m/cambws4-2z4k+nftize0qbu5n8juuwendatmzi98bazqtwhx...@mail.gm

pgsql: Ignore nullingrels when looking up statistics

2025-01-02 Thread Richard Guo
compromise its original purpose. This patch could result in plan changes, but it fixes an actual bug, so back-patch to v16 where the outer-join-aware-Var infrastructure was introduced. Author: Richard Guo Discussion: https://postgr.es/m/cambws4-2z4k+nftize0qbu5n8juuwendatmzi98bazqtwhx...@mail.gm

pgsql: Ignore nullingrels when looking up statistics

2025-01-02 Thread Richard Guo
compromise its original purpose. This patch could result in plan changes, but it fixes an actual bug, so back-patch to v16 where the outer-join-aware-Var infrastructure was introduced. Author: Richard Guo Discussion: https://postgr.es/m/cambws4-2z4k+nftize0qbu5n8juuwendatmzi98bazqtwhx...@mail.gm

pgsql: Avoid unnecessary wrapping for more complex expressions

2024-12-17 Thread Richard Guo
e Vars and PHVs introduced in commit f64ec81a8. No backpatch as this could result in plan changes. Author: Richard Guo Discussion: https://postgr.es/m/CAMbWs4_ENtfRdLaM_bXAxiKRYO7DmwDBDG4_2=vtdi0mjp-...@mail.gmail.com Branch -- master Details --- https://git.postgresql.or

pgsql: Improve the test case from 5668a857d

2024-12-11 Thread Richard Guo
patch simplifies the test case with a more straightforward query. Per discussion with Melanie Plageman. Author: Richard Guo Discussion: https://postgr.es/m/caakru_a-cip2xcxp13fmxq+t9bhlavaphtyjr94awl2mbxh...@mail.gmail.com Branch -- master Details --- https://git.postgresql.org/pg

pgsql: Avoid unnecessary wrapping for Vars and PHVs

2024-12-09 Thread Richard Guo
an changes. Author: Richard Guo Reviewed-by: James Coleman, Dmitry Dolgov, Andrei Lepikhov Discussion: https://postgr.es/m/CAMbWs48uk6C7Z9m_FNT8_21CMCk68hrgAsz=z6zpp1pnzmk...@mail.gmail.com Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/f64ec81a810ebd4649beb6c153844f

pgsql: Fix right-semi-joins in HashJoin rescans

2024-12-09 Thread Richard Guo
in rescans. This oversight has been shown to produce incorrect results. This patch fixes it. Author: Richard Guo Discussion: https://postgr.es/m/CAMbWs4-nQF9io2WL2SkD0eXvfPdyBc9Q=hrwfqhcgv2usa0...@mail.gmail.com Branch -- master Details --- https://git.postgresql.org/pg/

Re: pgsql: Avoid mislabeling of lateral references when pulling up a subque

2024-11-29 Thread Richard Guo
On Sat, Nov 30, 2024 at 6:31 AM Tom Lane wrote: > I wrote: > > The ideas I'd been toying with last night involved a pre-scan over > > the join tree to calculate the potential nullingrels of each leaf RTE > > (same idea as RelOptInfo.nulling_relids, but of course we don't have > > any RelOptInfos y

Re: pgsql: Avoid mislabeling of lateral references when pulling up a subque

2024-11-29 Thread Richard Guo
On Fri, Nov 29, 2024 at 10:44 AM Tom Lane wrote: > Richard Guo writes: > > On Fri, Nov 29, 2024 at 7:33 AM Tom Lane wrote: > >> It seems to be sufficient to just not mark lateral > >> references at all in this case. (I have a nagging feeling that more > >&g

Re: pgsql: Avoid mislabeling of lateral references when pulling up a subque

2024-11-28 Thread Richard Guo
On Fri, Nov 29, 2024 at 7:33 AM Tom Lane wrote: > It seems to be sufficient to just not mark lateral > references at all in this case. (I have a nagging feeling that more > complexity may be needed in cases where there are several levels of > outer join, but some attempts to break it with that di

pgsql: Fix test case from a8ccf4e93

2024-11-25 Thread Richard Guo
Fix test case from a8ccf4e93 Commit a8ccf4e93 uses the same table name "distinct_tbl" in both select_distinct.sql and select_distinct_on.sql, which could cause conflicts when these two test scripts are run in parallel. Fix by renaming the table in select_distinct_on.sql to "distinct_on_tbl". Per

pgsql: Remove dead code in get_param_path_clause_serials()

2024-11-25 Thread Richard Guo
to change anytime soon (as explained in the comments for generate_orderedappend_paths), we don't need to consider MergeAppendPath in this function. This change won't make any measurable difference in performance; it's just for clarity's sake. Author: Richard Guo Reviewed-

pgsql: Reordering DISTINCT keys to match input path's pathkeys

2024-11-25 Thread Richard Guo
isabled if needed. Author: Richard Guo Reviewed-by: Andrei Lepikhov Discussion: https://postgr.es/m/CAMbWs48dR26cCcX0f=8bja2JKQPcU64136kHk=xekht9xsc...@mail.gmail.com Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/a8ccf4e93a7eeaae66007bbf78cf9183ceb1b371 Modi

pgsql: Fix inconsistent RestrictInfo serial numbers

2024-11-07 Thread Richard Guo
_rinfo_serial counter after generating the additional constant-FALSE RestrictInfo. Back-patch to v17 where the issue crept in. In v17, I failed to make a test case that would expose this bug, so no test case for v17. Author: Richard Guo Discussion: https://postgr.es/m/cambws4-b6kafn+lmpuh-tyfwfy

pgsql: Fix inconsistent RestrictInfo serial numbers

2024-11-07 Thread Richard Guo
_rinfo_serial counter after generating the additional constant-FALSE RestrictInfo. Back-patch to v17 where the issue crept in. In v17, I failed to make a test case that would expose this bug, so no test case for v17. Author: Richard Guo Discussion: https://postgr.es/m/cambws4-b6kafn+lmpuh-tyfwfy

pgsql: Remove the RTE_GROUP RTE if we drop the groupClause

2024-10-24 Thread Richard Guo
we'd better remove the RTE_GROUP RTE and clear the hasGroupRTE flag, as they depend on the groupClause. Failing to do so could result in a bogus RTE_GROUP entry in the parent query, leading to an assertion failure on the hasGroupRTE flag. Reported-by: David Rowley Author: Richard Guo Discussi

pgsql: Allow pushdown of HAVING clauses with grouping sets

2024-10-09 Thread Richard Guo
se clauses that reference any nullable-by-grouping-sets columns: we just need to check if the RT index of the RTE_GROUP RTE is present in the clause. For other HAVING clauses, they can be safely pushed down. Author: Richard Guo Discussion: https://postgr.es/m/CAMbWs4-NpzPgtKU=hgnvyn+J-GanxQCjrUi7p

pgsql: Consider explicit incremental sort for mergejoins

2024-10-09 Thread Richard Guo
in this case (see final_cost_mergejoin). There is one ensuing plan change in the regression tests, and we have to modify that test case to ensure that it continues to test what it is intended to. No backpatch as this could result in plan changes. Author: Richard Guo Reviewed-by: David Rowley

pgsql: Introduce an RTE for the grouping step

2024-09-09 Thread Richard Guo
to Tom Lane for the idea to invent a new kind of RTE. Per reports from Geoff Winkless, Tobias Wendorff, Richard Guo from various threads. Author: Richard Guo Reviewed-by: Ashutosh Bapat, Sutou Kouhei Discussion: https://postgr.es/m/cambws4_dp7e7otwaizebx8+p1rxw4thkzxh1qg81rhu9z47...@mail.gmail.com

pgsql: Mark expressions nullable by grouping sets

2024-09-09 Thread Richard Guo
arser. Thanks to Tom Lane for the idea to invent a new kind of RTE. Per reports from Geoff Winkless, Tobias Wendorff, Richard Guo from various threads. Author: Richard Guo Reviewed-by: Ashutosh Bapat, Sutou Kouhei Discussion: https://postgr.es/m/cambws4_dp7e7otwaizebx8+p1rxw4thkzxh1qg81rh

pgsql: Fix order of parameters in a cost_sort call

2024-09-08 Thread Richard Guo
Fix order of parameters in a cost_sort call In label_sort_with_costsize, the cost_sort function is called with the parameters 'input_disabled_nodes' and 'input_cost' in the wrong order. This does not cause any plan diffs in the regression tests, because label_sort_with_costsize is only used to lab

pgsql: Avoid unnecessary post-sort projection

2024-09-03 Thread Richard Guo
sonable and are exactly what we are fixing here. So no additional test cases are added. No backpatch as this could result in plan changes. Author: Richard Guo Reviewed-by: Peter Eisentraut, David Rowley, Tom Lane Discussion: https://postgr.es/m/cambws48tossvmnz88663_2yg3hfeofss-j2ptnendh6j_rl...

pgsql: Check the validity of commutators for merge/hash clauses

2024-09-03 Thread Richard Guo
he test case. This is why the test case is included in equivclass.sql rather than in join.sql. Although this is arguably a bug fix, it cannot be reproduced without installing an incomplete opclass, which is unlikely to happen in practice, so no back-patch. Reported-by: Alexander Pyhalov Author: Ric

pgsql: Small code simplification

2024-08-21 Thread Richard Guo
Small code simplification Apply the same code simplification to ATExecAddColumn as was done in 7ff9afbbd: apply GETSTRUCT() once instead of doing it repeatedly in the same function. Author: Tender Wang Discussion: https://postgr.es/m/cahewxnko9+u437jvkt14s0mcu6qpf6g-p2mzk5j9mai4chd...@mail.gmail

Re: pgsql: Slightly refactor varstr_sortsupport() to improve readability.

2024-08-20 Thread Richard Guo
On Wed, Aug 21, 2024 at 6:33 AM Jeff Davis wrote: > Slightly refactor varstr_sortsupport() to improve readability. > > Author: Andreas Karlsson > Discussion: https://postgr.es/m/69c2a864-846f-4309-bd5a-aaa1c34f9...@proxel.se > > Branch > -- > master > > Details > --- > https://git.postgres

pgsql: Fix partitionwise join with partially-redundant join clauses

2024-07-29 Thread Richard Guo
l() to check if partition keys are known equal by ECs. Author: Richard Guo, Tom Lane Reviewed-by: Tom Lane, Ashutosh Bapat, Robert Haas Discussion: https://postgr.es/m/can_9jtzo_2f5dklqxvtdx5v6dwqb0xk+ihstpket3a1lt6x...@mail.gmail.com Branch -- master Details --- https://git.postgresql.or

pgsql: Refactor the checks for parameterized partial paths

2024-07-29 Thread Richard Guo
correctly. This patch fixes that. In addtion, this patch simplifies the checks peformed in try_partial_hashjoin_path and try_partial_mergejoin_path with the help of macro PATH_REQ_OUTER, and also adds asserts that the outer path is not parameterized in try_partial_xxx_path functions. Author: Richard Guo

pgsql: Short-circuit sort_inner_and_outer if there are no mergejoin cla

2024-07-29 Thread Richard Guo
to be empty, which accounts for approximately one-fourth. I think this suggests that implementing this shortcut is worthwhile. Author: Richard Guo Reviewed-by: Ashutosh Bapat Discussion: https://postgr.es/m/cambws48rkizgfed5a0jtztry5zdvvvnihh0akeuoz21f+0d...@mail.gmail.com Branch -- m

pgsql: Simplify create_merge_append_path for clarity

2024-07-28 Thread Richard Guo
of calling get_appendrel_parampathinfo. We can also simplify the Assert for child paths a little bit. This change won't make any measurable difference in performance; it's just for clarity's sake. Author: Richard Guo Reviewed-by: Alena Rybakina, Paul A Jungwirth Discuss

pgsql: Reduce memory used by partitionwise joins

2024-07-28 Thread Richard Guo
represents the relids of child-join relations at the end of each iteration. Additionally, it modifies build_child_join_rel() to reuse the AppendRelInfo structures generated within each iteration. Author: Ashutosh Bapat Reviewed-by: David Christensen, Richard Guo Discussion: https://postgr.es/m

pgsql: Remove redundant code in create_gather_merge_path

2024-07-22 Thread Richard Guo
mputes the cost for a Sort node, is redundant. This patch removes the redundant code and emits an error if the subpath is not sufficiently ordered. Meanwhile, this patch changes the check for the subpath's pathkeys in create_gather_merge_plan to an Assert. Author: Richard Guo Discussion: http

pgsql: Fix rowcount estimate for gather (merge) paths

2024-07-22 Thread Richard Guo
could result in plan changes. Author: Anthonin Bonnefoy Reviewed-by: Rafia Sabih, Richard Guo Discussion: https://postgr.es/m/CAO6_Xqr9+51NxgO=XospEkUeAg-p=ejawmtpdczwjrggkj5...@mail.gmail.com Branch -- master Details --- https://git.postgresql.org/pg/commi

pgsql: Fix unstable test in select_parallel.sql

2024-07-21 Thread Richard Guo
esult, here we enforce the join order using a lateral join. While here, modify the test case to verify that parallel nestloop join is not generated if the inner path is not parallel-safe, which is what we wanted to test in 22d946b0f. Reported-by: Alexander Lakhin as per buildfarm Author: Richar

pgsql: Check lateral references within PHVs for memoize cache keys

2024-07-14 Thread Richard Guo
the cache keys. In passing, this patch also includes a comment clarifying that Memoize nodes are currently not added on top of join relation paths. This explains why this patch only considers PlaceHolderVars that are due to be evaluated at baserels. Author: Richard Guo Reviewed-by: Tom Lane

pgsql: Consider materializing the cheapest inner path in parallel nestl

2024-07-11 Thread Richard Guo
when building partial nestloop paths. This approach potentially reduces the need to rescan the inner side of a partial nestloop path for each outer tuple. Author: Tender Wang Reviewed-by: Richard Guo, Robert Haas, David Rowley, Alena Rybakina Reviewed-by: Tomasz Rybak, Paul Jungwirth, Yuki Fujii

pgsql: Remove an extra period in code comment

2024-07-07 Thread Richard Guo
Remove an extra period in code comment Author: Junwang Zhao Discussion: https://postgr.es/m/CAEG8a3L9GgfKc+XT+NMHPY7atAOVYqjUqKEFQKhcPHFYRW=p...@mail.gmail.com Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/d7db04dfdae361479e77054670ee9d806c6a6420 Modified Files

pgsql: Fix right-anti-joins when the inner relation is proven unique

2024-07-07 Thread Richard Guo
-right-anti-join does not suffer from this wrong results issue, we apply the same change to it as well, to help save cycles for the same reason. Per bug #18522 from Antti Lampinen, and bug #18526 from Feliphe Pozzer. Back-patch to v16 where right-anti-join was introduced. Author: Richard Guo

pgsql: Fix right-anti-joins when the inner relation is proven unique

2024-07-07 Thread Richard Guo
-right-anti-join does not suffer from this wrong results issue, we apply the same change to it as well, to help save cycles for the same reason. Per bug #18522 from Antti Lampinen, and bug #18526 from Feliphe Pozzer. Back-patch to v16 where right-anti-join was introduced. Author: Richard Guo

pgsql: Fix right-anti-joins when the inner relation is proven unique

2024-07-07 Thread Richard Guo
-right-anti-join does not suffer from this wrong results issue, we apply the same change to it as well, to help save cycles for the same reason. Per bug #18522 from Antti Lampinen, and bug #18526 from Feliphe Pozzer. Back-patch to v16 where right-anti-join was introduced. Author: Richard Guo

pgsql: Support "Right Semi Join" plan shapes

2024-07-04 Thread Richard Guo
is patch. Note that this patch also modifies a test query in join.sql to ensure it continues testing as intended. With this patch the original query would result in a right-semi-join rather than semi-join, compromising its original purpose of testing the fix for neqjoinsel's behavior for semi-jo

pgsql: Fix comment about cross-checking the varnullingrels

2024-06-09 Thread Richard Guo
Fix comment about cross-checking the varnullingrels The nullingrels match checks are not limited to debugging builds. Oversight in commit 867be9c07. Author: Richard Guo Reviewed-by: Alvaro Herrera, Tom Lane, Robert Haas Discussion: https://postgr.es/m/CAMbWs4_SDsdYD7DdQw7RXc3jv3axbg

Re: pgsql: Remove over-optimistic Assert.

2023-02-02 Thread Richard Guo
On Thu, Feb 2, 2023 at 8:40 AM Tom Lane wrote: > Remove over-optimistic Assert. > > In commit 2489d76c4, I'd thought it'd be safe to assert that a > PlaceHolderVar appearing in a scan-level expression has empty > nullingrels. However this is not so, as when we determine that a > join relation is