| From: | Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> |
|---|---|
| To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
| Cc: | exclusion(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org |
| Subject: | Re: BUG #17803: Rule "ALSO INSERT ... SELECT ..." fails to substitute default values |
| Date: | 2023-02-21 17:15:39 |
| Message-ID: | CAEZATCWoXX9-+ZaaLiOMRsZgwmStayBGmCdA0BdwVzo5GCU51Q@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
On Tue, 21 Feb 2023 at 15:05, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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
| Attachment | Content-Type | Size |
|---|---|---|
| fix-default-handling-for-insert-select-rule-v2.patch | text/x-patch | 5.8 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2023-02-21 17:27:54 | Re: BUG #17800: ON CONFLICT DO UPDATE fails to detect incompatible fields that leads to a server crash |
| Previous Message | Stephen Frost | 2023-02-21 16:35:54 | Re: Query run in 27s with 15.2 vs 37ms with 14.6 |