Skip to content
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

[Bug Fix] SEGV on query with Left Outer Join (#7787) (#7901) #7904

Merged
merged 1 commit into from
Feb 18, 2025

Conversation

colm-mchugh
Copy link
Contributor

DESCRIPTION: Fixes a crash in left outer joins that can happen when there is an an aggregate on a column from the inner side of the join.

Fix the SEGV seen in #7787 and #7899; it occurs because a column in the targetlist of a worker subquery can contain a non-empty varnullingrels field if the column is from the inner side of a left outer join. The issue can also occur with the columns in the HAVING clause, and this is also tested in the fix. The issue was triggered by the introduction of the varnullingrels to Vars in Postgres 16 (2489d76c)

There is a related issue, #7705, where a non-empty varnullingrels was incorrectly copied into the query tree for the combine query. Here, a non-empty varnullingrels field of a var is incorrectly copied into the query tree for a worker subquery.

The regress file from #7705 is used (and renamed) to also test this (#7787). An alternative test output file is required for Postgres 15 because of an optimization to DISTINCT in Postgres 16 (1349d2790bf).

DESCRIPTION: Fixes a crash in left outer joins that can happen when
there is an an aggregate on a column from the inner side of the join.

Fix the SEGV seen in #7787 and #7899; it occurs because a column in the
targetlist of a worker subquery can contain a non-empty varnullingrels
field if the column is from the inner side of a left outer join. The
issue can also occur with the columns in the HAVING clause, and this is
also tested in the fix. The issue was triggered by the introduction of
the varnullingrels to Vars in Postgres 16 (2489d76c)

There is a related issue, #7705, where a non-empty varnullingrels was
incorrectly copied into the query tree for the combine query. Here, a
non-empty varnullingrels field of a var is incorrectly copied into the
query tree for a worker subquery.

The regress file from #7705 is used (and renamed) to also test this
(#7787). An alternative test output file is required for Postgres 15
because of an optimization to DISTINCT in Postgres 16 (1349d2790bf).
@colm-mchugh colm-mchugh requested a review from naisila February 18, 2025 14:51
@colm-mchugh colm-mchugh self-assigned this Feb 18, 2025
@colm-mchugh
Copy link
Contributor Author

Backport #7901 to 12.1.

Copy link

codecov bot commented Feb 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.65%. Comparing base (cb31a64) to head (76c8f3e).
Report is 9 commits behind head on release-12.1.

Additional details and impacted files
@@               Coverage Diff                @@
##           release-12.1    #7904      +/-   ##
================================================
+ Coverage         89.57%   89.65%   +0.07%     
================================================
  Files               276      276              
  Lines             59660    59664       +4     
  Branches           7448     7448              
================================================
+ Hits              53442    53489      +47     
+ Misses             4081     4038      -43     
  Partials           2137     2137              

@colm-mchugh colm-mchugh merged commit 1a8e2c8 into release-12.1 Feb 18, 2025
121 checks passed
@colm-mchugh colm-mchugh deleted the colm/issue_7787.bp-12.1 branch February 18, 2025 20:56
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