summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorTom Lane2019-06-02 16:23:39 +0000
committerTom Lane2019-06-02 16:23:39 +0000
commit032627ee7837f0baa539df7247e003dbaded2c90 (patch)
tree94b4452d11d66927cea679ce97d02cc425261a3f /contrib
parent135063e6f6ee61c7243801e9f4d702921ed53e06 (diff)
Clean up PL/Perl's handling of the _() macro.
Perl likes to redefine the _() macro: #ifdef CAN_PROTOTYPE #define _(args) args #else ... There was lots not to like about the way we dealt with this before: 1. Instead of taking care of the conflict centrally in plperl.h, we expected every one of its ever-growing number of includers to do so. This is duplicative and error-prone in itself, plus it means that plperl.h fails to meet the expectation of being compilable standalone, resulting in macro-redefinition warnings in cpluspluscheck. 2. We left _() with its Perl definition, meaning that if someone tried to use it in any Perl-related extension, it would silently fail to provide run-time translation. I don't see any live bugs of this ilk, but it's clearly a hard-to-notice bug waiting to happen. So fix that by centralizing the cleanup logic, making it match what we're already doing for other macro conflicts with Perl. Since we only expect plperl.h to be included by extensions not core code, we should redefine _() as dgettext() not gettext().
Diffstat (limited to 'contrib')
-rw-r--r--contrib/hstore_plperl/hstore_plperl.c4
-rw-r--r--contrib/jsonb_plperl/jsonb_plperl.c3
2 files changed, 1 insertions, 6 deletions
diff --git a/contrib/hstore_plperl/hstore_plperl.c b/contrib/hstore_plperl/hstore_plperl.c
index 61b5557421c..1316b0500be 100644
--- a/contrib/hstore_plperl/hstore_plperl.c
+++ b/contrib/hstore_plperl/hstore_plperl.c
@@ -1,11 +1,9 @@
#include "postgres.h"
-#undef _
-
#include "fmgr.h"
+#include "hstore/hstore.h"
#include "plperl.h"
#include "plperl_helpers.h"
-#include "hstore/hstore.h"
PG_MODULE_MAGIC;
diff --git a/contrib/jsonb_plperl/jsonb_plperl.c b/contrib/jsonb_plperl/jsonb_plperl.c
index 79c5f57d8fd..b26723a9589 100644
--- a/contrib/jsonb_plperl/jsonb_plperl.c
+++ b/contrib/jsonb_plperl/jsonb_plperl.c
@@ -2,9 +2,6 @@
#include <math.h>
-/* Defined by Perl */
-#undef _
-
#include "fmgr.h"
#include "plperl.h"
#include "plperl_helpers.h"