Thread: pgsql: Fix union for pgstat message types

pgsql: Fix union for pgstat message types

From
Magnus Hagander
Date:
Fix union for pgstat message types

The message type for temp files and for checksum failures were missing
from the union. Due to the coding style used there was no compiler error
when this happend. So change the code to actively use the union thereby
producing a compiler error if the same mistake happens again, suggested
by Tom Lane.

Author: Julien Rouhaud
Reported-By: Tomas Vondra
Discussion: https://postgr.es/m/20190430163328.zd4rrlnbvgaqlcdz@development

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/659e53498c3c04e4f400323c02bef98fe8d13ec8

Modified Files
--------------
src/backend/postmaster/pgstat.c | 41 ++++++++++++++++++++++-------------------
src/include/pgstat.h            |  4 +++-
2 files changed, 25 insertions(+), 20 deletions(-)


Re: pgsql: Fix union for pgstat message types

From
Tomas Vondra
Date:
On Wed, May 01, 2019 at 10:34:52AM +0000, Magnus Hagander wrote:
>Fix union for pgstat message types
>
>The message type for temp files and for checksum failures were missing
>from the union. Due to the coding style used there was no compiler error
>when this happend. So change the code to actively use the union thereby
>producing a compiler error if the same mistake happens again, suggested
>by Tom Lane.
>

Should the tempfile bit be backported? That message was added in 9.2.

regards

-- 
Tomas Vondra                  http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services 



Re: pgsql: Fix union for pgstat message types

From
Tom Lane
Date:
Tomas Vondra <tomas.vondra@2ndquadrant.com> writes:
> On Wed, May 01, 2019 at 10:34:52AM +0000, Magnus Hagander wrote:
>> Fix union for pgstat message types

> Should the tempfile bit be backported? That message was added in 9.2.

It's just cosmetic I think.  The main point of having everything in
the union is to make sure the union's size/alignment are sufficient,
but the tempfile message isn't anywhere near creating an issue there.

            regards, tom lane



Re: pgsql: Fix union for pgstat message types

From
Magnus Hagander
Date:
On Sat, May 4, 2019 at 5:54 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Tomas Vondra <tomas.vondra@2ndquadrant.com> writes:
> On Wed, May 01, 2019 at 10:34:52AM +0000, Magnus Hagander wrote:
>> Fix union for pgstat message types

> Should the tempfile bit be backported? That message was added in 9.2.

It's just cosmetic I think.  The main point of having everything in
the union is to make sure the union's size/alignment are sufficient,
but the tempfile message isn't anywhere near creating an issue there.

That was my thought as well. It's really only needed when we add new things, to make sure we don't make those mistakes again. And nobody should be adding new pgstat messages in old branches. 

--

Re: pgsql: Fix union for pgstat message types

From
Tomas Vondra
Date:
On Sat, May 04, 2019 at 07:08:10PM +0200, Magnus Hagander wrote:
>   On Sat, May 4, 2019 at 5:54 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
>     Tomas Vondra <tomas.vondra@2ndquadrant.com> writes:
>     > On Wed, May 01, 2019 at 10:34:52AM +0000, Magnus Hagander wrote:
>     >> Fix union for pgstat message types
>
>     > Should the tempfile bit be backported? That message was added in 9.2.
>
>     It's just cosmetic I think.  The main point of having everything in
>     the union is to make sure the union's size/alignment are sufficient,
>     but the tempfile message isn't anywhere near creating an issue there.
>
>   That was my thought as well. It's really only needed when we add new
>   things, to make sure we don't make those mistakes again. And nobody should
>   be adding new pgstat messages in old branches. 

Fine with me, I don't think the backbranches are broken. OTOH it's a
minor change that would make the code more similar.

regards

-- 
Tomas Vondra                  http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services