Re: BUG #18077: PostgreSQL server subprocess crashed by a SELECT statement with WITH clause
Andrei Lepikhov <a.lepikhov@postgrespro.ru>
From: "Lepikhov Andrei" <a.lepikhov@postgrespro.ru>
To: "Michael Paquier" <michael@paquier.xyz>
Cc: "Richard Guo" <guofenglinux@gmail.com>, "Tom Lane" <tgl@sss.pgh.pa.us>,
fuboat@outlook.com, pgsql-bugs@lists.postgresql.org
Date: 2023-09-11T03:15:02Z
Lists: pgsql-bugs
Attachments
- 0001-CustomScan-node-as-a-test-module.patch (application/octet-stream) patch 0001
- quickfix.diff (application/octet-stream) patch
On Thu, Sep 7, 2023, at 4:46 PM, Michael Paquier wrote: > On Thu, Sep 07, 2023 at 03:25:36PM +0700, Lepikhov Andrei wrote: >> I invented a dummy extension "pg_extension" [1], commit 4199a0c, >> which adds CustomScan over the first non-parameterized HashJoin at >> the pathlist. >> The example presented in my letter earlier causes the ERROR on >> CTE. Moreover, if you remove the word 'materialized', you will find >> the same error on Subquery. >> >> [1] https://github.com/danolivo/pg_extension/tree/main > > Digressing a bit here about this point.. In the long-term I think > that it would be a good idea to have a template module in > src/test/modules/ that shows how to use a CustomScan so as it is able > to demonstrate how this stuff works, and to check if it is works as > intended. With regression tests, of course. I agree. I often use it in different situations: for scan, join purposes, as a stat gathering tool and others. Having some templates in the code base would be comfortable. Also, We should remember to add some examples of extensible node usage ... In the attachment - rewritten code of the CustomScan node, as mentioned earlier, as a test module with one regression test. It shows both CTE and Subquery problems (they have different sources of error). Also, I have attached a patch that fixes the problem's symptoms - not the origins of the problem, just for demonstration. -- Regards, Andrei Lepikhov
Commits
-
Track nesting depth correctly when drilling down into RECORD Vars.
- e0e492e5a928 17.0 landed
- d29812c0c6cd 12.17 landed
- c5b7f791dab9 13.13 landed
- ae13f8166dc3 14.10 landed
- a374f6c61681 11.22 landed
- 53630f12d39b 16.1 landed
- 2679a107a152 15.5 landed
-
Fix get_expr_result_type() to find field names for RECORD Consts.
- 8a15b4178c40 12.17 landed
- 59bc0dfe44a6 13.13 landed
- 479b99125dcc 11.22 landed
-
Allow extracting fields from a ROW() expression in more cases.
- ece1154f4c89 11.22 landed
- 2f02d4a2b9cb 12.17 landed