aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2017-07-31 12:38:35 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2017-07-31 12:38:35 -0400
commit1e58c503ec46ec78ddf19aa5bad7d095f14e042b (patch)
tree4cfe966da89e13dc896dd9024b3c29a94cf91fd3 /src
parent30a5c8bfbd7bec07385c7d40305b06385d700b3f (diff)
downloadpostgresql-1e58c503ec46ec78ddf19aa5bad7d095f14e042b.tar.gz
postgresql-1e58c503ec46ec78ddf19aa5bad7d095f14e042b.zip
PL/Perl portability fix: absorb relevant -D switches from Perl.
Back-patch of commit 3c163a7fc76debbbdad1bdd3c43721cffe72f4db, which see for more info. Also throw in commit b4cc35fbb709bd6fcae8998f041fd731c9acbf42, so Coverity doesn't whine about the back branches. Ashutosh Sharma, some adjustments by me Discussion: https://postgr.es/m/CANFyU97OVQ3+Mzfmt3MhuUm5NwPU=-FtbNH5Eb7nZL9ua8=rcA@mail.gmail.com
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.global.in1
-rw-r--r--src/pl/plperl/GNUmakefile6
-rw-r--r--src/pl/plperl/plperl.c28
-rw-r--r--src/tools/msvc/Mkvcbuild.pm27
4 files changed, 48 insertions, 14 deletions
diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index 8ac7ca7d2bf..cb939b58551 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -298,6 +298,7 @@ else
endif
perl_archlibexp = @perl_archlibexp@
perl_privlibexp = @perl_privlibexp@
+perl_embed_ccflags = @perl_embed_ccflags@
perl_embed_ldflags = @perl_embed_ldflags@
# Miscellaneous
diff --git a/src/pl/plperl/GNUmakefile b/src/pl/plperl/GNUmakefile
index b8e35852544..191f74067a6 100644
--- a/src/pl/plperl/GNUmakefile
+++ b/src/pl/plperl/GNUmakefile
@@ -12,7 +12,11 @@ override CPPFLAGS += -DPLPERL_HAVE_UID_GID
override CPPFLAGS += -Wno-comment
endif
-override CPPFLAGS := -I. -I$(srcdir) $(CPPFLAGS) -I$(perl_archlibexp)/CORE
+# Note: we need to make sure that the CORE directory is included last,
+# probably because it sometimes contains some header files with names
+# that clash with some of ours, or with some that we include, notably on
+# Windows.
+override CPPFLAGS := -I. -I$(srcdir) $(CPPFLAGS) $(perl_embed_ccflags) -I$(perl_archlibexp)/CORE
rpathdir = $(perl_archlibexp)/CORE
diff --git a/src/pl/plperl/plperl.c b/src/pl/plperl/plperl.c
index e58c85c7b47..f4180117a58 100644
--- a/src/pl/plperl/plperl.c
+++ b/src/pl/plperl/plperl.c
@@ -3248,12 +3248,18 @@ plperl_return_next_internal(SV *sv)
/*
* This is the first call to return_next in the current PL/Perl
- * function call, so memoize some lookups
+ * function call, so identify the output tuple descriptor and create a
+ * tuplestore to hold the result rows.
*/
if (prodesc->fn_retistuple)
(void) get_call_result_type(fcinfo, NULL, &tupdesc);
else
+ {
tupdesc = rsi->expectedDesc;
+ /* Protect assumption below that we return exactly one column */
+ if (tupdesc == NULL || tupdesc->natts != 1)
+ elog(ERROR, "expected single-column result descriptor for non-composite SETOF result");
+ }
/*
* Make sure the tuple_store and ret_tdesc are sufficiently
@@ -3301,20 +3307,20 @@ plperl_return_next_internal(SV *sv)
}
else
{
- Datum ret;
- bool isNull;
+ Datum ret[1];
+ bool isNull[1];
- ret = plperl_sv_to_datum(sv,
- prodesc->result_oid,
- -1,
- fcinfo,
- &prodesc->result_in_func,
- prodesc->result_typioparam,
- &isNull);
+ ret[0] = plperl_sv_to_datum(sv,
+ prodesc->result_oid,
+ -1,
+ fcinfo,
+ &prodesc->result_in_func,
+ prodesc->result_typioparam,
+ &isNull[0]);
tuplestore_putvalues(current_call_data->tuple_store,
current_call_data->ret_tdesc,
- &ret, &isNull);
+ ret, isNull);
}
MemoryContextSwitchTo(old_cxt);
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index 6285aab2b65..f3bd30540a2 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -516,7 +516,26 @@ sub mkvcbuild
my $plperl =
$solution->AddProject('plperl', 'dll', 'PLs', 'src/pl/plperl');
$plperl->AddIncludeDir($solution->{options}->{perl} . '/lib/CORE');
- $plperl->AddDefine('PLPERL_HAVE_UID_GID');
+
+ # Add defines from Perl's ccflags; see PGAC_CHECK_PERL_EMBED_CCFLAGS
+ my @perl_embed_ccflags;
+ foreach my $f (split(" ",$Config{ccflags}))
+ {
+ if ($f =~ /^-D[^_]/)
+ {
+ $f =~ s/\-D//;
+ push(@perl_embed_ccflags, $f);
+ }
+ }
+
+ # XXX this probably is redundant now?
+ push(@perl_embed_ccflags, 'PLPERL_HAVE_UID_GID');
+
+ foreach my $f (@perl_embed_ccflags)
+ {
+ $plperl->AddDefine($f);
+ }
+
foreach my $xs ('SPI.xs', 'Util.xs')
{
(my $xsc = $xs) =~ s/\.xs/.c/;
@@ -599,7 +618,11 @@ sub mkvcbuild
'hstore_plperl', 'contrib/hstore_plperl',
'plperl', 'src/pl/plperl',
'hstore', 'contrib/hstore');
- $hstore_plperl->AddDefine('PLPERL_HAVE_UID_GID');
+
+ foreach my $f (@perl_embed_ccflags)
+ {
+ $hstore_plperl->AddDefine($f);
+ }
}
$mf =