From: | Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk> |
---|---|
To: | Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andreas Seltenreich <seltenreich(at)gmx(dot)de>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Simon Riggs <simon(at)2ndquadrant(dot)com> |
Subject: | Re: [sqlsmith] Planner crash on foreign table join |
Date: | 2017-04-10 05:14:42 |
Message-ID: | 87d1ckx3gd.fsf@news-spur.riddles.org.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
>>>>> "Thomas" == Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com> writes:
>> SomeType *x = (SomeType *) lfirst(l);
>>
>> (in my code I tend to omit the (SomeType *), which I dislike because
>> it adds no real protection)
Thomas> Just BTW, without that cast it's not compilable as C++, so I'm
Thomas> guessing that Peter E will finish up putting it back in
Thomas> wherever you leave it out...
There's north of 150 other examples (just grep for '= lfirst' in the
source). Some were even committed by Peter E :-)
In the discussion with Andres the same point came up for palloc, for
which I suggested we add something along the lines of:
#define palloc_object(_type_) (_type_ *) palloc(sizeof(_type_))
#define palloc_array(_type_, n) (_type_ *) palloc((n) * sizeof(_type_))
palloc() without a cast is even more common than lfirst() without one,
and something like half of those (and 80%+ of the pallocs that do have a
cast) are palloc(sizeof(...)) or palloc(something * sizeof(...)).
--
Andrew (irc:RhodiumToad)
From | Date | Subject | |
---|---|---|---|
Next Message | Masahiko Sawada | 2017-04-10 05:16:02 | max_sync_workers_per_subscription is missing in postgresql.conf |
Previous Message | David E. Wheeler | 2017-04-10 05:07:13 | Re: Malformed Array Literal in PL/pgSQL Exception Block |