Hello hackers,
Please look at a bunch of unused variables and a couple of other defects
I found in the perl code, maybe you'll find them worth fixing:
contrib/amcheck/t/001_verify_heapam.pl
$result # unused since introduction in 866e24d47
unused sub:
get_toast_for # not used since 860593ec3
contrib/amcheck/t/002_cic.pl
$result # orphaned since 7f580aa5d
src/backend/utils/activity/generate-wait_event_types.pl
$note, $note_name # unused since introduction in fa8892847
src/bin/pg_dump/t/003_pg_dump_with_server.pl
$cmd, $stdout, $stderr, $result # unused since introduction in 2f9eb3132
src/bin/pg_dump/t/005_pg_dump_filterfile.pl
$cmd, $stdout, $stderr, $result # unused since introduciton in a5cf808be
src/test/modules/ldap_password_func/t/001_mutated_bindpasswd.pl
$slapd, $ldap_schema_dir # unused since introduction in 419a8dd81
src/test/modules/ssl_passphrase_callback/t/001_testfunc.pl
$clearpass # orphaned since b846091fd
src/test/perl/PostgreSQL/Test/AdjustUpgrade.pm
$ostmt # unused since introduction in 47bb9db75
src/test/recovery/t/021_row_visibility.pl
$ret # unused since introduction in 7b28913bc
src/test/recovery/t/032_relfilenode_reuse.pl
$ret # unused since introduction in e2f65f425
src/test/recovery/t/035_standby_logical_decoding.pl
$stdin, $ret, $slot # unused since introduction in fcd77d532
$subscriber_stdin, $subscriber_stdout, $subscriber_stderr # unused since
introduction in 376dc8205
src/test/subscription/t/024_add_drop_pub.pl
invalid reference in a comment:
tab_drop_refresh -> tab_2 # introduced with 1046a69b3
(invalid since v6-0001-...patch in the commit's thread)
src/tools/msvc_gendef.pl
@def # unused since introduction in 933b46644?
I've attached a patch with all of these changes (tested with meson build
on Windows and check-world on Linux).
Best regards,
Alexander
diff --git a/contrib/amcheck/t/001_verify_heapam.pl b/contrib/amcheck/t/001_verify_heapam.pl
index 9de3148277..481e4dbe4f 100644
--- a/contrib/amcheck/t/001_verify_heapam.pl
+++ b/contrib/amcheck/t/001_verify_heapam.pl
@@ -9,7 +9,7 @@ use PostgreSQL::Test::Utils;
use Test::More;
-my ($node, $result);
+my $node;
#
# Test set-up
@@ -87,19 +87,6 @@ sub relation_filepath
return "$pgdata/$rel";
}
-# Returns the fully qualified name of the toast table for the named relation
-sub get_toast_for
-{
- my ($relname) = @_;
-
- return $node->safe_psql(
- 'postgres', qq(
- SELECT 'pg_toast.' || t.relname
- FROM pg_catalog.pg_class c, pg_catalog.pg_class t
- WHERE c.relname = '$relname'
- AND c.reltoastrelid = t.oid));
-}
-
# (Re)create and populate a test table of the given name.
sub fresh_test_table
{
diff --git a/contrib/amcheck/t/002_cic.pl b/contrib/amcheck/t/002_cic.pl
index 53a3db9745..0207407ca0 100644
--- a/contrib/amcheck/t/002_cic.pl
+++ b/contrib/amcheck/t/002_cic.pl
@@ -10,7 +10,7 @@ use PostgreSQL::Test::Utils;
use Test::More;
-my ($node, $result);
+my $node;
#
# Test set-up
diff --git a/src/backend/utils/activity/generate-wait_event_types.pl b/src/backend/utils/activity/generate-wait_event_types.pl
index 42f36f405b..b2d61bd8ba 100644
--- a/src/backend/utils/activity/generate-wait_event_types.pl
+++ b/src/backend/utils/activity/generate-wait_event_types.pl
@@ -42,8 +42,6 @@ my @abi_compatibility_lines;
my @lines;
my $abi_compatibility = 0;
my $section_name;
-my $note;
-my $note_name;
# Remove comments and empty lines and add waitclassname based on the section
while (<$wait_event_names>)
diff --git a/src/bin/pg_dump/t/003_pg_dump_with_server.pl b/src/bin/pg_dump/t/003_pg_dump_with_server.pl
index b5a1445550..3f549f44e7 100644
--- a/src/bin/pg_dump/t/003_pg_dump_with_server.pl
+++ b/src/bin/pg_dump/t/003_pg_dump_with_server.pl
@@ -26,7 +26,6 @@ $node->safe_psql('postgres', "CREATE SERVER s1 FOREIGN DATA WRAPPER dummy");
$node->safe_psql('postgres', "CREATE SERVER s2 FOREIGN DATA WRAPPER dummy");
$node->safe_psql('postgres', "CREATE FOREIGN TABLE t0 (a int) SERVER s0");
$node->safe_psql('postgres', "CREATE FOREIGN TABLE t1 (a int) SERVER s1");
-my ($cmd, $stdout, $stderr, $result);
command_fails_like(
[ "pg_dump", '-p', $port, '--include-foreign-data=s0', 'postgres' ],
diff --git a/src/bin/pg_dump/t/005_pg_dump_filterfile.pl b/src/bin/pg_dump/t/005_pg_dump_filterfile.pl
index a80e13a0d3..6025bb296c 100644
--- a/src/bin/pg_dump/t/005_pg_dump_filterfile.pl
+++ b/src/bin/pg_dump/t/005_pg_dump_filterfile.pl
@@ -81,7 +81,6 @@ $node->safe_psql('sourcedb',
#
# Test interaction of correctly specified filter file
#
-my ($cmd, $stdout, $stderr, $result);
# Empty filterfile
open $inputfile, '>', "$tempdir/inputfile.txt"
diff --git a/src/test/modules/ldap_password_func/t/001_mutated_bindpasswd.pl b/src/test/modules/ldap_password_func/t/001_mutated_bindpasswd.pl
index b990e7d101..82b1cb88e9 100644
--- a/src/test/modules/ldap_password_func/t/001_mutated_bindpasswd.pl
+++ b/src/test/modules/ldap_password_func/t/001_mutated_bindpasswd.pl
@@ -12,10 +12,6 @@ use Test::More;
use lib "$FindBin::RealBin/../../../ldap";
use LdapServer;
-my ($slapd, $ldap_bin_dir, $ldap_schema_dir);
-
-$ldap_bin_dir = undef; # usually in PATH
-
if ($ENV{with_ldap} ne 'yes')
{
plan skip_all => 'LDAP not supported by this build';
diff --git a/src/test/modules/ssl_passphrase_callback/t/001_testfunc.pl b/src/test/modules/ssl_passphrase_callback/t/001_testfunc.pl
index 7a63539f39..f71d0ff3e0 100644
--- a/src/test/modules/ssl_passphrase_callback/t/001_testfunc.pl
+++ b/src/test/modules/ssl_passphrase_callback/t/001_testfunc.pl
@@ -15,7 +15,6 @@ unless (($ENV{with_ssl} || "") eq 'openssl')
plan skip_all => 'OpenSSL not supported by this build';
}
-my $clearpass = "FooBaR1";
my $rot13pass = "SbbOnE1";
# see the Makefile for how the certificate and key have been generated
diff --git a/src/test/perl/PostgreSQL/Test/AdjustUpgrade.pm b/src/test/perl/PostgreSQL/Test/AdjustUpgrade.pm
index 3cec72d9d4..239c17aced 100644
--- a/src/test/perl/PostgreSQL/Test/AdjustUpgrade.pm
+++ b/src/test/perl/PostgreSQL/Test/AdjustUpgrade.pm
@@ -534,7 +534,6 @@ sub _mash_view_qualifiers
{
my @thischunks = split /;/, $chunk, 2;
my $stmt = shift(@thischunks);
- my $ostmt = $stmt;
# now $stmt is just the body of the CREATE [MATERIALIZED] VIEW
$stmt =~ s/$qualifier\.//g;
diff --git a/src/test/recovery/t/021_row_visibility.pl b/src/test/recovery/t/021_row_visibility.pl
index 255caffb19..d046137601 100644
--- a/src/test/recovery/t/021_row_visibility.pl
+++ b/src/test/recovery/t/021_row_visibility.pl
@@ -168,7 +168,6 @@ $node_standby->stop;
sub send_query_and_wait
{
my ($psql, $query, $untl) = @_;
- my $ret;
# send query
$$psql{stdin} .= $query;
diff --git a/src/test/recovery/t/032_relfilenode_reuse.pl b/src/test/recovery/t/032_relfilenode_reuse.pl
index 96a8104b80..d473cd167c 100644
--- a/src/test/recovery/t/032_relfilenode_reuse.pl
+++ b/src/test/recovery/t/032_relfilenode_reuse.pl
@@ -205,7 +205,6 @@ sub cause_eviction
sub send_query_and_wait
{
my ($psql, $query, $untl) = @_;
- my $ret;
# For each query we run, we'll restart the timeout. Otherwise the timeout
# would apply to the whole test script, and would need to be set very high
diff --git a/src/test/recovery/t/035_standby_logical_decoding.pl b/src/test/recovery/t/035_standby_logical_decoding.pl
index 4628f9fb80..4185b803b2 100644
--- a/src/test/recovery/t/035_standby_logical_decoding.pl
+++ b/src/test/recovery/t/035_standby_logical_decoding.pl
@@ -10,10 +10,7 @@ use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More;
-my ($stdin, $stdout, $stderr,
- $cascading_stdout, $cascading_stderr, $subscriber_stdin,
- $subscriber_stdout, $subscriber_stderr, $ret,
- $handle, $slot);
+my ($stdout, $stderr, $cascading_stdout, $cascading_stderr, $handle);
my $node_primary = PostgreSQL::Test::Cluster->new('primary');
my $node_standby = PostgreSQL::Test::Cluster->new('standby');
diff --git a/src/test/subscription/t/024_add_drop_pub.pl b/src/test/subscription/t/024_add_drop_pub.pl
index 55c3b2b4ae..c0d7ffcb6b 100644
--- a/src/test/subscription/t/024_add_drop_pub.pl
+++ b/src/test/subscription/t/024_add_drop_pub.pl
@@ -63,7 +63,7 @@ $node_subscriber->safe_psql('postgres',
# Wait for initial table sync to finish
$node_subscriber->wait_for_subscription_sync($node_publisher, 'tap_sub');
-# Check the initial data of tab_drop_refresh was copied to subscriber
+# Check the initial data of tab_2 was copied to subscriber
$result = $node_subscriber->safe_psql('postgres',
"SELECT count(*), min(a), max(a) FROM tab_2");
is($result, qq(10|1|10), 'check initial data is copied to subscriber');
diff --git a/src/tools/msvc_gendef.pl b/src/tools/msvc_gendef.pl
index 404076dbbc..97346cc892 100644
--- a/src/tools/msvc_gendef.pl
+++ b/src/tools/msvc_gendef.pl
@@ -6,8 +6,6 @@ use warnings FATAL => 'all';
use List::Util qw(min);
use Getopt::Long;
-my @def;
-
#
# Script that generates a .DEF file for all objects in a directory
#