Re: BUG #17803: Rule "ALSO INSERT ... SELECT ..." fails to substitute default values
Dean Rasheed <dean.a.rasheed@gmail.com>
From: Dean Rasheed <dean.a.rasheed@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: exclusion@gmail.com, pgsql-bugs@lists.postgresql.org
Date: 2023-02-21T17:15:39Z
Lists: pgsql-bugs
Attachments
- fix-default-handling-for-insert-select-rule-v2.patch (text/x-patch) patch v2
On Tue, 21 Feb 2023 at 15:05, Tom Lane <tgl@sss.pgh.pa.us> wrote: > > It seems like this bit: > > + rtr = (RangeTblRef *) linitial(pt->jointree->fromlist); > + selectrte = rt_fetch(rtr->rtindex, pt->rtable); > + selectquery = selectrte->subquery; > > is missing several essential checks. Is the node extracted from > jointree->fromlist actually a RangeTblRef? Seems like it could > be a JoinExpr or FromExpr instead; even if it can't be that today, > an IsA check is cheap future-proofing. Likewise, once you've > got your hands on the RTE, you should check rtekind == RTE_SUBQUERY > rather than assuming it's safe to touch the subquery field. > > (I see that getInsertSelectQuery isn't much better about this, > but we should fix that while we're at it.) > Yeah, that makes sense. Something like this? (I think an elog() is probably more useful than an Assert(), if we don't find what we expect.) Regards, Dean
Commits
-
Fix mishandling of OLD/NEW references in subqueries in rule actions.
- 79f194cc0144 11.20 landed
- 4fd093af7186 12.15 landed
- 39ad791e8510 13.11 landed
- 27ff93d18c2b 14.8 landed
- 8e5b4e0013a8 15.3 landed
- a7d71c41dbd6 16.0 landed
-
Fix multi-row DEFAULT handling for INSERT ... SELECT rules.
- e68b133c30e2 11.20 landed
- 98b83b734982 12.15 landed
- 226da3d47670 13.11 landed
- f0423bea7f0a 14.8 landed
- 940b5474365f 15.3 landed
- 75c737636b8a 16.0 landed
-
Fix DEFAULT-handling in multi-row VALUES lists for updatable views.
- 41531e42d34f 12.0 cited