commit 6fb2c997dd7bcbdc6f36dced60ccc82fb01a6d2f
Author: Christoph Berg <christoph.berg@credativ.de>
Date:   Thu Sep 9 16:52:22 2021 +0200

    Debian deprecates `which`, use POSIX standard `command -v` instead
    
    debianutils (5.3-1) unstable; urgency=medium
    
      * The 'which' utility will be removed in the future.  Shell scripts
        often use it to check whether a command is available.  A more
        standard way to do this is with 'command -v'; for example:
          if command -v update-icon-caches >/dev/null; then
            update-icon-caches /usr/share/icons/...
          fi
        '2>/dev/null' is unnecessary when using 'command': POSIX says "no
        output shall be written" if the command isn't found.  It's also
        unnecessary for the debianutils version of 'which', and hides the
        deprecation warning.
    
     -- Clint Adams <clint@debian.org>  Fri, 20 Aug 2021 07:22:18 -0400

diff --git a/check_postgres.pl b/check_postgres.pl
index ba28f27..be5ccdb 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -2090,7 +2090,7 @@ if (exists $opt{PSQL}) {
 }
 else {
     my $psql = (defined $PGBINDIR) ? "$PGBINDIR/psql" : 'psql';
-    chomp($PSQL = qx{which "$psql"});
+    chomp($PSQL = qx{command -v "$psql"});
     $PSQL or ndie msg('opt-psql-nofind');
 }
 -x $PSQL or ndie msg('opt-psql-noexec', $PSQL);
