pgsql: Fix interaction of Perl and stdbool.h
pgsql: Fix interaction of Perl and stdbool.h
От:
Peter Eisentraut <peter_e@gmx.net>
Дата:
Fix interaction of Perl and stdbool.h Revert the PL/Perl-specific change in 9a95a77d9d5d3003d2d67121f2731b6e5fc37336. We must not prevent Perl from using stdbool.h when it has been built to do so, even if it uses an incompatible size. Otherwise, we would be imposing our bool on Perl, which will lead to crashes because of the size mismatch. Instead, we undef bool after including the Perl headers, as we did previously, but now only if we are not using stdbool.h ourselves. Record that choice in c.h as USE_STDBOOL. This will also make it easier to apply that coding pattern elsewhere if necessary. Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/7ba7986fb4364e889a705c9973fefa138650091c Modified Files -------------- src/include/c.h | 1 + src/pl/plperl/plperl.h | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-)
Re: pgsql: Fix interaction of Perl and stdbool.h
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Peter Eisentraut writes:
> Fix interaction of Perl and stdbool.h
Not sure if this broke it or it was already broken, but my compiler
is now very unhappy.
In file included from /usr/lib64/perl5/CORE/perl.h:2424,
from plperl.h:60,
from SPI.xs:18:
/usr/lib64/perl5/CORE/handy.h:108:1: warning: "bool" redefined
In file included from ../../../src/include/c.h:270,
from ../../../src/include/postgres.h:46,
from SPI.xs:11:
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/include/stdbool.h:33:1: warning: this is the location of the previous definition
In file included from /usr/lib64/perl5/CORE/perl.h:2424,
from plperl.h:60,
from Util.xs:24:
/usr/lib64/perl5/CORE/handy.h:108:1: warning: "bool" redefined
In file included from ../../../src/include/c.h:270,
from ../../../src/include/postgres.h:46,
from Util.xs:14:
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/include/stdbool.h:33:1: warning: this is the location of the previous definition
In file included from /usr/lib64/perl5/CORE/perl.h:2424,
from plperl.h:60,
from plperl.c:51:
/usr/lib64/perl5/CORE/handy.h:108:1: warning: "bool" redefined
In file included from ../../../src/include/c.h:270,
from ../../../src/include/postgres.h:46,
from plperl.c:8:
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/include/stdbool.h:33:1: warning: this is the location of the previous definition
plperl.c: In function '_PG_init':
plperl.c:415: warning: passing argument 4 of 'DefineCustomBoolVariable' from incompatible pointer type
../../../src/include/utils/guc.h:282: note: expected '_Bool *' but argument is of type 'char *'
plperl.c: In function 'select_perl_context':
plperl.c:575: warning: passing argument 4 of 'hash_search' from incompatible pointer type
../../../src/include/utils/hsearch.h:126: note: expected '_Bool *' but argument is of type 'char *'
plperl.c: In function 'plperl_build_tuple_result':
plperl.c:1126: warning: passing argument 3 of 'heap_form_tuple' from incompatible pointer type
../../../src/include/access/htup_details.h:810: note: expected '_Bool *' but argument is of type 'char *'
plperl.c: In function 'plperl_sv_to_literal':
plperl.c:1457: warning: passing argument 3 of 'getTypeOutputInfo' from incompatible pointer type
../../../src/include/utils/lsyscache.h:163: note: expected '_Bool *' but argument is of type 'char *'
plperl.c: In function 'plperl_ref_from_pg_array':
plperl.c:1496: warning: passing argument 4 of 'get_type_io_data' from incompatible pointer type
../../../src/include/utils/lsyscache.h:140: note: expected '_Bool *' but argument is of type 'char *'
plperl.c:1524: warning: passing argument 7 of 'deconstruct_array' from incompatible pointer type
../../../src/include/utils/array.h:388: note: expected '_Bool **' but argument is of type 'char **'
plperl.c: In function 'plperl_modify_tuple':
plperl.c:1807: warning: passing argument 4 of 'heap_modify_tuple' from incompatible pointer type
../../../src/include/access/htup_details.h:812: note: expected '_Bool *' but argument is of type 'char *'
plperl.c:1807: warning: passing argument 5 of 'heap_modify_tuple' from incompatible pointer type
../../../src/include/access/htup_details.h:812: note: expected '_Bool *' but argument is of type 'char *'
plperl.c: In function 'plperl_func_handler':
plperl.c:2497: warning: passing argument 7 of 'plperl_sv_to_datum' from incompatible pointer type
plperl.c:1315: note: expected 'char *' but argument is of type '_Bool *'
plperl.c: In function 'compile_plperl_function':
plperl.c:2813: warning: passing argument 4 of 'SysCacheGetAttr' from incompatible pointer type
../../../src/include/utils/syscache.h:151: note: expected '_Bool *' but argument is of type 'char *'
plperl.c:2929: warning: passing argument 4 of 'SysCacheGetAttr' from incompatible pointer type
../../../src/include/utils/syscache.h:151: note: expected '_Bool *' but argument is of type 'char *'
plperl.c: In function 'plperl_hash_from_tuple':
plperl.c:3047: warning: passing argument 4 of 'heap_getsysattr' from incompatible pointer type
../../../src/include/access/htup_details.h:805: note: expected '_Bool *' but argument is of type 'char *'
plperl.c:3080: warning: passing argument 3 of 'getTypeOutputInfo' from incompatible pointer type
../../../src/include/utils/lsyscache.h:163: note: expected '_Bool *' but argument is of type 'char *'
plperl.c: In function 'plperl_return_next_internal':
plperl.c:3367: warning: passing argument 4 of 'tuplestore_putvalues' from incompatible pointer type
../../../src/include/utils/tuplestore.h:56: note: expected '_Bool *' but argument is of type 'char *'
plperl.c: In function 'plperl_spi_prepare':
plperl.c:3636: warning: passing argument 4 of 'hash_search' from incompatible pointer type
../../../src/include/utils/hsearch.h:126: note: expected '_Bool *' but argument is of type 'char *'
Admittedly, these are all just warnings not errors, but that doesn't make
it acceptable.
gcc 4.4.7, perl 5.10.1, on RHEL6.
regards, tom lane
Re: pgsql: Fix interaction of Perl and stdbool.h
От:
David Steele <david@pgmasters.net>
Дата:
On 3/23/18 11:49 AM, Tom Lane wrote: > Peter Eisentraut writes: >> Fix interaction of Perl and stdbool.h > > Not sure if this broke it or it was already broken, but my compiler > is now very unhappy. > > In file included from /usr/lib64/perl5/CORE/perl.h:2424, > from plperl.h:60, > from SPI.xs:18: > /usr/lib64/perl5/CORE/handy.h:108:1: warning: "bool" redefined One way to fix this is to mark bool as defined in plperl.c: #ifndef HAS_BOOL # define HAS_BOOL 1 #endif Regards, -- -David david@pgmasters.net
Re: pgsql: Fix interaction of Perl and stdbool.h
От:
Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Дата:
On 3/23/18 12:19, David Steele wrote: > On 3/23/18 11:49 AM, Tom Lane wrote: >> Peter Eisentraut writes: >>> Fix interaction of Perl and stdbool.h >> >> Not sure if this broke it or it was already broken, but my compiler >> is now very unhappy. >> >> In file included from /usr/lib64/perl5/CORE/perl.h:2424, >> from plperl.h:60, >> from SPI.xs:18: >> /usr/lib64/perl5/CORE/handy.h:108:1: warning: "bool" redefined > > One way to fix this is to mark bool as defined in plperl.c: > > #ifndef HAS_BOOL > # define HAS_BOOL 1 > #endif Well, that's what we had before, but that crashed on the 4-byte bool platforms. So the fix I pushed does that only if PostgreSQL is using stdbool.h. It works for me on CentOS 6 now. -- Peter Eisentraut http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Re: pgsql: Fix interaction of Perl and stdbool.h
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Peter Eisentraut writes: > Well, that's what we had before, but that crashed on the 4-byte bool > platforms. So the fix I pushed does that only if PostgreSQL is using > stdbool.h. It works for me on CentOS 6 now. Works for me too, thanks! regards, tom lane