summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dunstan2020-04-13 15:55:45 +0000
committerAndrew Dunstan2020-04-13 15:55:45 +0000
commit7be5d8df1f74b78620167d3abf32ee607e728919 (patch)
tree030ea8b9fe1360b7670277c0af44e028de652497
parent8930e43ecd3f683c457865131d7a932401a2188f (diff)
Use perl warnings pragma consistently
We've had a mixture of the warnings pragma, the -w switch on the shebang line, and no warnings at all. This patch removes the -w swicth and add the warnings pragma to all perl sources missing it. It raises the severity of the TestingAndDebugging::RequireUseWarnings perlcritic policy to level 5, so that we catch any future violations. Discussion: https://postgr.es/m/[email protected]
-rwxr-xr-xcontrib/intarray/bench/bench.pl1
-rwxr-xr-xcontrib/intarray/bench/create_test.pl2
-rwxr-xr-xcontrib/seg/seg-validate.pl1
-rwxr-xr-xcontrib/seg/sort-segments.pl1
-rw-r--r--doc/src/sgml/mk_feature_tables.pl3
-rw-r--r--src/backend/catalog/genbki.pl2
-rw-r--r--src/backend/utils/Gen_fmgrtab.pl2
-rwxr-xr-xsrc/backend/utils/mb/Unicode/UCS_to_BIG5.pl2
-rwxr-xr-xsrc/backend/utils/mb/Unicode/UCS_to_EUC_CN.pl2
-rwxr-xr-xsrc/backend/utils/mb/Unicode/UCS_to_EUC_JIS_2004.pl2
-rwxr-xr-xsrc/backend/utils/mb/Unicode/UCS_to_EUC_JP.pl2
-rwxr-xr-xsrc/backend/utils/mb/Unicode/UCS_to_EUC_KR.pl2
-rwxr-xr-xsrc/backend/utils/mb/Unicode/UCS_to_EUC_TW.pl2
-rwxr-xr-xsrc/backend/utils/mb/Unicode/UCS_to_GB18030.pl2
-rwxr-xr-xsrc/backend/utils/mb/Unicode/UCS_to_JOHAB.pl2
-rwxr-xr-xsrc/backend/utils/mb/Unicode/UCS_to_SHIFT_JIS_2004.pl2
-rwxr-xr-xsrc/backend/utils/mb/Unicode/UCS_to_SJIS.pl2
-rwxr-xr-xsrc/backend/utils/mb/Unicode/UCS_to_UHC.pl2
-rwxr-xr-xsrc/backend/utils/mb/Unicode/UCS_to_most.pl2
-rw-r--r--src/backend/utils/mb/Unicode/convutils.pm1
-rw-r--r--src/backend/utils/sort/gen_qsort_tuple.pl3
-rw-r--r--src/bin/psql/create_help.pl3
-rw-r--r--src/interfaces/libpq/test/regress.pl3
-rw-r--r--src/pl/plperl/plc_perlboot.pl1
-rw-r--r--src/pl/plperl/plperl_opmask.pl2
-rwxr-xr-xsrc/test/locale/sort-test.pl1
-rw-r--r--src/test/perl/SimpleTee.pm1
-rw-r--r--src/tools/fix-old-flex-code.pl2
-rw-r--r--src/tools/msvc/build.pl1
-rw-r--r--src/tools/msvc/pgbison.pl2
-rw-r--r--src/tools/msvc/pgflex.pl2
-rw-r--r--src/tools/msvc/vcregress.pl1
-rw-r--r--src/tools/perlcheck/perlcriticrc4
-rwxr-xr-xsrc/tools/pginclude/pgcheckdefines3
-rwxr-xr-xsrc/tools/version_stamp.pl3
35 files changed, 59 insertions, 10 deletions
diff --git a/contrib/intarray/bench/bench.pl b/contrib/intarray/bench/bench.pl
index 92035d6c06a..daf3febc804 100755
--- a/contrib/intarray/bench/bench.pl
+++ b/contrib/intarray/bench/bench.pl
@@ -1,6 +1,7 @@
#!/usr/bin/perl
use strict;
+use warnings;
# make sure we are in a sane environment.
use DBI();
diff --git a/contrib/intarray/bench/create_test.pl b/contrib/intarray/bench/create_test.pl
index d2c678bb53c..3f2a6e4da2a 100755
--- a/contrib/intarray/bench/create_test.pl
+++ b/contrib/intarray/bench/create_test.pl
@@ -3,6 +3,8 @@
# contrib/intarray/bench/create_test.pl
use strict;
+use warnings;
+
print <<EOT;
create table message (
mid int not null,
diff --git a/contrib/seg/seg-validate.pl b/contrib/seg/seg-validate.pl
index b8957ed984a..9fa0887e710 100755
--- a/contrib/seg/seg-validate.pl
+++ b/contrib/seg/seg-validate.pl
@@ -1,6 +1,7 @@
#!/usr/bin/perl
use strict;
+use warnings;
my $integer = '[+-]?[0-9]+';
my $real = '[+-]?[0-9]+\.[0-9]+';
diff --git a/contrib/seg/sort-segments.pl b/contrib/seg/sort-segments.pl
index 04eafd92f21..2e3c9734a94 100755
--- a/contrib/seg/sort-segments.pl
+++ b/contrib/seg/sort-segments.pl
@@ -3,6 +3,7 @@
# this script will sort any table with the segment data type in its last column
use strict;
+use warnings;
my @rows;
diff --git a/doc/src/sgml/mk_feature_tables.pl b/doc/src/sgml/mk_feature_tables.pl
index 476e50e66d0..ee158cb1969 100644
--- a/doc/src/sgml/mk_feature_tables.pl
+++ b/doc/src/sgml/mk_feature_tables.pl
@@ -1,8 +1,9 @@
-# /usr/bin/perl -w
+# /usr/bin/perl
# doc/src/sgml/mk_feature_tables.pl
use strict;
+use warnings;
my $yesno = $ARGV[0];
diff --git a/src/backend/catalog/genbki.pl b/src/backend/catalog/genbki.pl
index ad24f4dcb93..da341245954 100644
--- a/src/backend/catalog/genbki.pl
+++ b/src/backend/catalog/genbki.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
#----------------------------------------------------------------------
#
# genbki.pl
diff --git a/src/backend/utils/Gen_fmgrtab.pl b/src/backend/utils/Gen_fmgrtab.pl
index 7c68dbec22a..b7c7b4c8fae 100644
--- a/src/backend/utils/Gen_fmgrtab.pl
+++ b/src/backend/utils/Gen_fmgrtab.pl
@@ -1,4 +1,4 @@
-#! /usr/bin/perl -w
+#! /usr/bin/perl
#-------------------------------------------------------------------------
#
# Gen_fmgrtab.pl
diff --git a/src/backend/utils/mb/Unicode/UCS_to_BIG5.pl b/src/backend/utils/mb/Unicode/UCS_to_BIG5.pl
index 4c8aaf751ca..84c9c535413 100755
--- a/src/backend/utils/mb/Unicode/UCS_to_BIG5.pl
+++ b/src/backend/utils/mb/Unicode/UCS_to_BIG5.pl
@@ -25,6 +25,8 @@
# # and Unicode name (not used in this script)
use strict;
+use warnings;
+
use convutils;
my $this_script = 'src/backend/utils/mb/Unicode/UCS_to_BIG5.pl';
diff --git a/src/backend/utils/mb/Unicode/UCS_to_EUC_CN.pl b/src/backend/utils/mb/Unicode/UCS_to_EUC_CN.pl
index b493a13838b..1596b64238f 100755
--- a/src/backend/utils/mb/Unicode/UCS_to_EUC_CN.pl
+++ b/src/backend/utils/mb/Unicode/UCS_to_EUC_CN.pl
@@ -14,6 +14,8 @@
# and the "b" field is the hex byte sequence for GB18030
use strict;
+use warnings;
+
use convutils;
my $this_script = 'src/backend/utils/mb/Unicode/UCS_to_EUC_CN.pl';
diff --git a/src/backend/utils/mb/Unicode/UCS_to_EUC_JIS_2004.pl b/src/backend/utils/mb/Unicode/UCS_to_EUC_JIS_2004.pl
index 4faf5972711..092a5b44f55 100755
--- a/src/backend/utils/mb/Unicode/UCS_to_EUC_JIS_2004.pl
+++ b/src/backend/utils/mb/Unicode/UCS_to_EUC_JIS_2004.pl
@@ -8,6 +8,8 @@
# "euc-jis-2004-std.txt" (http://x0213.org)
use strict;
+use warnings;
+
use convutils;
my $this_script = 'src/backend/utils/mb/Unicode/UCS_to_EUC_JIS_2004.pl';
diff --git a/src/backend/utils/mb/Unicode/UCS_to_EUC_JP.pl b/src/backend/utils/mb/Unicode/UCS_to_EUC_JP.pl
index 86743a40741..1d88c0296ee 100755
--- a/src/backend/utils/mb/Unicode/UCS_to_EUC_JP.pl
+++ b/src/backend/utils/mb/Unicode/UCS_to_EUC_JP.pl
@@ -12,6 +12,8 @@
# organization's ftp site.
use strict;
+use warnings;
+
use convutils;
my $this_script = 'src/backend/utils/mb/Unicode/UCS_to_EUC_JP.pl';
diff --git a/src/backend/utils/mb/Unicode/UCS_to_EUC_KR.pl b/src/backend/utils/mb/Unicode/UCS_to_EUC_KR.pl
index a81a7d61cee..b560f9f37ea 100755
--- a/src/backend/utils/mb/Unicode/UCS_to_EUC_KR.pl
+++ b/src/backend/utils/mb/Unicode/UCS_to_EUC_KR.pl
@@ -17,6 +17,8 @@
# # and Unicode name (not used in this script)
use strict;
+use warnings;
+
use convutils;
my $this_script = 'src/backend/utils/mb/Unicode/UCS_to_EUC_KR.pl';
diff --git a/src/backend/utils/mb/Unicode/UCS_to_EUC_TW.pl b/src/backend/utils/mb/Unicode/UCS_to_EUC_TW.pl
index b9ec01dd852..0f52183ff5f 100755
--- a/src/backend/utils/mb/Unicode/UCS_to_EUC_TW.pl
+++ b/src/backend/utils/mb/Unicode/UCS_to_EUC_TW.pl
@@ -18,6 +18,8 @@
# # and Unicode name (not used in this script)
use strict;
+use warnings;
+
use convutils;
my $this_script = 'src/backend/utils/mb/Unicode/UCS_to_EUC_TW.pl';
diff --git a/src/backend/utils/mb/Unicode/UCS_to_GB18030.pl b/src/backend/utils/mb/Unicode/UCS_to_GB18030.pl
index 779e3f7f010..57e63b4004a 100755
--- a/src/backend/utils/mb/Unicode/UCS_to_GB18030.pl
+++ b/src/backend/utils/mb/Unicode/UCS_to_GB18030.pl
@@ -14,6 +14,8 @@
# and the "b" field is the hex byte sequence for GB18030
use strict;
+use warnings;
+
use convutils;
my $this_script = 'src/backend/utils/mb/Unicode/UCS_to_GB18030.pl';
diff --git a/src/backend/utils/mb/Unicode/UCS_to_JOHAB.pl b/src/backend/utils/mb/Unicode/UCS_to_JOHAB.pl
index c1967e00da2..0bcea9e0d4f 100755
--- a/src/backend/utils/mb/Unicode/UCS_to_JOHAB.pl
+++ b/src/backend/utils/mb/Unicode/UCS_to_JOHAB.pl
@@ -16,6 +16,8 @@
# # and Unicode name (not used in this script)
use strict;
+use warnings;
+
use convutils;
my $this_script = 'src/backend/utils/mb/Unicode/UCS_to_JOHAB.pl';
diff --git a/src/backend/utils/mb/Unicode/UCS_to_SHIFT_JIS_2004.pl b/src/backend/utils/mb/Unicode/UCS_to_SHIFT_JIS_2004.pl
index cac9a9c87dc..b516e91306f 100755
--- a/src/backend/utils/mb/Unicode/UCS_to_SHIFT_JIS_2004.pl
+++ b/src/backend/utils/mb/Unicode/UCS_to_SHIFT_JIS_2004.pl
@@ -8,6 +8,8 @@
# "sjis-0213-2004-std.txt" (http://x0213.org)
use strict;
+use warnings;
+
use convutils;
# first generate UTF-8 --> SHIFT_JIS_2004 table
diff --git a/src/backend/utils/mb/Unicode/UCS_to_SJIS.pl b/src/backend/utils/mb/Unicode/UCS_to_SJIS.pl
index c65091159bb..5f4512ec87e 100755
--- a/src/backend/utils/mb/Unicode/UCS_to_SJIS.pl
+++ b/src/backend/utils/mb/Unicode/UCS_to_SJIS.pl
@@ -11,6 +11,8 @@
# ftp site.
use strict;
+use warnings;
+
use convutils;
my $this_script = 'src/backend/utils/mb/Unicode/UCS_to_SJIS.pl';
diff --git a/src/backend/utils/mb/Unicode/UCS_to_UHC.pl b/src/backend/utils/mb/Unicode/UCS_to_UHC.pl
index 78b982a22e6..3282106d7f0 100755
--- a/src/backend/utils/mb/Unicode/UCS_to_UHC.pl
+++ b/src/backend/utils/mb/Unicode/UCS_to_UHC.pl
@@ -14,6 +14,8 @@
# and the "b" field is the hex byte sequence for UHC
use strict;
+use warnings;
+
use convutils;
my $this_script = 'src/backend/utils/mb/Unicode/UCS_to_UHC.pl';
diff --git a/src/backend/utils/mb/Unicode/UCS_to_most.pl b/src/backend/utils/mb/Unicode/UCS_to_most.pl
index 7ff724558d3..8a7b26a5c5f 100755
--- a/src/backend/utils/mb/Unicode/UCS_to_most.pl
+++ b/src/backend/utils/mb/Unicode/UCS_to_most.pl
@@ -16,6 +16,8 @@
# # and Unicode name (not used in this script)
use strict;
+use warnings;
+
use convutils;
my $this_script = 'src/backend/utils/mb/Unicode/UCS_to_most.pl';
diff --git a/src/backend/utils/mb/Unicode/convutils.pm b/src/backend/utils/mb/Unicode/convutils.pm
index 1903b345cbf..2f64a12ea14 100644
--- a/src/backend/utils/mb/Unicode/convutils.pm
+++ b/src/backend/utils/mb/Unicode/convutils.pm
@@ -6,6 +6,7 @@
package convutils;
use strict;
+use warnings;
use Carp;
use Exporter 'import';
diff --git a/src/backend/utils/sort/gen_qsort_tuple.pl b/src/backend/utils/sort/gen_qsort_tuple.pl
index b6b2ffa7d0b..9ed6cfc7eaa 100644
--- a/src/backend/utils/sort/gen_qsort_tuple.pl
+++ b/src/backend/utils/sort/gen_qsort_tuple.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
#
# gen_qsort_tuple.pl
@@ -26,6 +26,7 @@
#
use strict;
+use warnings;
my $SUFFIX;
my $EXTRAARGS;
diff --git a/src/bin/psql/create_help.pl b/src/bin/psql/create_help.pl
index a3b34603efe..ee82e645832 100644
--- a/src/bin/psql/create_help.pl
+++ b/src/bin/psql/create_help.pl
@@ -1,4 +1,4 @@
-#! /usr/bin/perl -w
+#! /usr/bin/perl
#################################################################
# create_help.pl -- converts SGML docs to internal psql help
@@ -20,6 +20,7 @@
#
use strict;
+use warnings;
my $docdir = $ARGV[0] or die "$0: missing required argument: docdir\n";
my $hfile = $ARGV[1] . '.h'
diff --git a/src/interfaces/libpq/test/regress.pl b/src/interfaces/libpq/test/regress.pl
index 3ad638a91b7..54db4f1abfc 100644
--- a/src/interfaces/libpq/test/regress.pl
+++ b/src/interfaces/libpq/test/regress.pl
@@ -1,6 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use strict;
+use warnings;
# use of SRCDIR/SUBDIR is required for supporting VPath builds
my $srcdir = $ENV{'SRCDIR'} or die 'SRCDIR environment variable is not set';
diff --git a/src/pl/plperl/plc_perlboot.pl b/src/pl/plperl/plc_perlboot.pl
index f41aa80e80b..ee1b9bf4634 100644
--- a/src/pl/plperl/plc_perlboot.pl
+++ b/src/pl/plperl/plc_perlboot.pl
@@ -1,6 +1,7 @@
# src/pl/plperl/plc_perlboot.pl
use strict;
+use warnings;
use 5.008001;
use vars qw(%_SHARED $_TD);
diff --git a/src/pl/plperl/plperl_opmask.pl b/src/pl/plperl/plperl_opmask.pl
index e4e64b843f2..3b33112ff94 100644
--- a/src/pl/plperl/plperl_opmask.pl
+++ b/src/pl/plperl/plperl_opmask.pl
@@ -1,4 +1,4 @@
-#!perl -w
+#!perl
use strict;
use warnings;
diff --git a/src/test/locale/sort-test.pl b/src/test/locale/sort-test.pl
index b8fc93aab18..b61968b7e0a 100755
--- a/src/test/locale/sort-test.pl
+++ b/src/test/locale/sort-test.pl
@@ -1,6 +1,7 @@
#! /usr/bin/perl
use strict;
+use warnings;
use locale;
open(my $in_fh, '<', $ARGV[0]) || die;
diff --git a/src/test/perl/SimpleTee.pm b/src/test/perl/SimpleTee.pm
index 9de7b1ac323..74409bde6d7 100644
--- a/src/test/perl/SimpleTee.pm
+++ b/src/test/perl/SimpleTee.pm
@@ -9,6 +9,7 @@
package SimpleTee;
use strict;
+use warnings;
sub TIEHANDLE
{
diff --git a/src/tools/fix-old-flex-code.pl b/src/tools/fix-old-flex-code.pl
index 2954cf5a726..1bbb7cdb841 100644
--- a/src/tools/fix-old-flex-code.pl
+++ b/src/tools/fix-old-flex-code.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
#----------------------------------------------------------------------
#
# fix-old-flex-code.pl
diff --git a/src/tools/msvc/build.pl b/src/tools/msvc/build.pl
index 2e47f24783f..3c886fcd499 100644
--- a/src/tools/msvc/build.pl
+++ b/src/tools/msvc/build.pl
@@ -3,6 +3,7 @@
# src/tools/msvc/build.pl
use strict;
+use warnings;
use File::Basename;
use File::Spec;
diff --git a/src/tools/msvc/pgbison.pl b/src/tools/msvc/pgbison.pl
index 490df833673..774d5be0595 100644
--- a/src/tools/msvc/pgbison.pl
+++ b/src/tools/msvc/pgbison.pl
@@ -3,6 +3,8 @@
# src/tools/msvc/pgbison.pl
use strict;
+use warnings;
+
use File::Basename;
# assume we are in the postgres source root
diff --git a/src/tools/msvc/pgflex.pl b/src/tools/msvc/pgflex.pl
index aceed5ffd6c..26c73dbfade 100644
--- a/src/tools/msvc/pgflex.pl
+++ b/src/tools/msvc/pgflex.pl
@@ -3,6 +3,8 @@
# src/tools/msvc/pgflex.pl
use strict;
+use warnings;
+
use File::Basename;
# silence flex bleatings about file path style
diff --git a/src/tools/msvc/vcregress.pl b/src/tools/msvc/vcregress.pl
index 82dca29a616..c39178a93ca 100644
--- a/src/tools/msvc/vcregress.pl
+++ b/src/tools/msvc/vcregress.pl
@@ -3,6 +3,7 @@
# src/tools/msvc/vcregress.pl
use strict;
+use warnings;
our $config;
diff --git a/src/tools/perlcheck/perlcriticrc b/src/tools/perlcheck/perlcriticrc
index bd848a9a653..314c83c6a59 100644
--- a/src/tools/perlcheck/perlcriticrc
+++ b/src/tools/perlcheck/perlcriticrc
@@ -19,6 +19,10 @@ verbose = %f: %m at line %l, column %c. %e. ([%p] Severity: %s)\n
# allow octal constants with leading zeros
[-ValuesAndExpressions::ProhibitLeadingZeros]
+# insist on use of the warnings pragma
+[TestingAndDebugging::RequireUseWarnings]
+severity = 5
+
# for now raise severity of this to level 5
[Subroutines::RequireFinalReturn]
severity = 5
diff --git a/src/tools/pginclude/pgcheckdefines b/src/tools/pginclude/pgcheckdefines
index 4edf7fc56e8..0a760d6ecad 100755
--- a/src/tools/pginclude/pgcheckdefines
+++ b/src/tools/pginclude/pgcheckdefines
@@ -1,4 +1,4 @@
-#! /usr/bin/perl -w
+#! /usr/bin/perl
#
# This script looks for symbols that are referenced in #ifdef or defined()
@@ -21,6 +21,7 @@
#
use strict;
+use warnings;
use Cwd;
use File::Basename;
diff --git a/src/tools/version_stamp.pl b/src/tools/version_stamp.pl
index cb59ad234ab..fcd3f180487 100755
--- a/src/tools/version_stamp.pl
+++ b/src/tools/version_stamp.pl
@@ -1,4 +1,4 @@
-#! /usr/bin/perl -w
+#! /usr/bin/perl
#################################################################
# version_stamp.pl -- update version stamps throughout the source tree
@@ -21,6 +21,7 @@
#
use strict;
+use warnings;
# Major version is hard-wired into the script. We update it when we branch
# a new development version.