Re: [COMMITTERS] pgsql: Introduce dynamic shared memory areas. - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [COMMITTERS] pgsql: Introduce dynamic shared memory areas.
Date
Msg-id 32388.1480951024@sss.pgh.pa.us
Whole thread Raw
In response to Re: [COMMITTERS] pgsql: Introduce dynamic shared memory areas.  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
Robert Haas <robertmhaas@gmail.com> writes:
> Hmm, I'm not sure I understand that warning.  I think the complaint is
> about this line of code:

>         Size        threshold = 1 << (bin - 1);

> "bin" is declared as "Size", and threshold is also declared as "Size",
> so what's the problem?

The shift operator does not coerce its operands to be the same size.
It just shifts the left operand in its native width, which here is
"int", which ain't enough.

> (Size) 1 << (bin - 1) would be safer?

Yes.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: [COMMITTERS] pgsql: Introduce dynamic shared memory areas.
Next
From: Pavel Stehule
Date:
Subject: missing optimization - column <> column