From: | Andres Freund <andres(at)anarazel(dot)de> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: safer node casting |
Date: | 2017-01-27 01:34:26 |
Message-ID: | 20170127013426.nsiadresg54lfas5@alap3.anarazel.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 2017-01-26 20:29:06 -0500, Tom Lane wrote:
> Andres Freund <andres(at)anarazel(dot)de> writes:
> > On 2016-12-31 12:08:22 -0500, Peter Eisentraut wrote:
> >> This is inspired by the dynamic_cast operator in C++, but follows the
> >> syntax of the well-known makeNode() macro.
>
> > The analogy to dynamic_cast goes only so far, because we don't actually
> > support inheritance. I.e. in c++ we could successfully cast SeqScanState to a
> > PlanState, ScanState and SeqScanState - but with our model only
> > SeqScanState can be checked.
>
> Yeah, I was thinking about that earlier --- this can only be used to cast
> to a concrete node type, not one of the "abstract" types like Plan * or
> Expr *. Not sure if that's worth worrying about though; I don't think
> I've ever seen actual bugs in PG code from casting the wrong thing in that
> direction. For the most part, passing the wrong thing would end up firing
> a default: case in a switch, or some such, so we already do have some
> defenses for that direction.
Yea, I'm not actually worried about it - I was more generally remarking
on the analogy made by Peter. For a second I was considering bringing up
the analogy in a comment or such, and this was one of a number of
arguments that made me disregard that idea.
Andres
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Paquier | 2017-01-27 01:35:17 | Re: Allow interrupts on waiting standby |
Previous Message | Tom Lane | 2017-01-27 01:29:06 | Re: safer node casting |