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

Fix SEGV on query with Left Outer Join (#7787) #7789

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

colm-mchugh
Copy link
Contributor

@colm-mchugh colm-mchugh commented Dec 16, 2024

Fix the SEGV seen in #7787; 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 Postgres 16's varnullingrels field in Vars (pg commit 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 #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 self-assigned this Dec 16, 2024
Copy link

codecov bot commented Dec 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.69%. Comparing base (7341191) to head (c72b9dd).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7789      +/-   ##
==========================================
- Coverage   89.70%   89.69%   -0.01%     
==========================================
  Files         283      283              
  Lines       60515    60518       +3     
  Branches     7542     7542              
==========================================
- Hits        54284    54282       -2     
- Misses       4074     4080       +6     
+ Partials     2157     2156       -1     

@colm-mchugh colm-mchugh force-pushed the 7787-segfault-loj branch 2 times, most recently from 51f683e to 8b9d71b Compare December 19, 2024 17:43
@colm-mchugh colm-mchugh changed the title Fix #7787 Fix SEGV on query with Left Outer Join (#7787) Dec 19, 2024
Fix the SEGV seen in #7787; 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).
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.

1 participant