Re: partitioned tables and contrib/sepgsql

From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Joe Conway <mail(at)joeconway(dot)com>, Mike Palmiotto <mike(dot)palmiotto(at)crunchydata(dot)com>, Stephen Frost <sfrost(at)snowman(dot)net>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: partitioned tables and contrib/sepgsql
Date: 2017-04-05 15:56:31
Message-ID: 2a3b192d-3e52-5611-0fa3-a1e62c7be7c1@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 4/5/17 01:20, Tom Lane wrote:
>> The complaint about bool is also just a warning.
>
> Really?
>
> $ cat test.c
> typedef char bool;
> typedef char bool;
> $ gcc -c test.c
> test.c:2: error: redefinition of typedef 'bool'
> test.c:1: note: previous declaration of 'bool' was here
>
> This is with gcc 4.4.7.

But the above is not how the current code looks.

stdbool.h does

#define bool _Bool

c.h does

#ifndef bool
typedef char bool;
#endif

So if you get stdbool.h first, then c.h does nothing. If you get c.h
first, then the macro from stdbool.h will mask the c.h typedef.

Where this gets really fun is when you include other header files
between, say, postgres.h and selinux/label.h, because then the function
definitions from those header files will be incompatible before and
after the stdbool.h inclusion. Which indeed currently leads to the
following compilation error:

label.c: In function ‘sepgsql_init_client_label’:
label.c:437:18: error: assignment from incompatible pointer type
[-Werror=incompatible-pointer-types]
needs_fmgr_hook = sepgsql_needs_fmgr_hook;
^

So I can't reproduce the original complaint, but this is potentially worse.

(The above is on Fedora 25. You need a fairly new selinux.)

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2017-04-05 16:04:00 Re: partitioned tables and contrib/sepgsql
Previous Message Robert Haas 2017-04-05 15:53:58 Re: scram and \password