public inbox for [email protected]  
help / color / mirror / Atom feed
[PATCH 07/10] add wal_compression_method: zstd
8+ messages / 4 participants
[nested] [flat]

* [PATCH 07/10] add wal_compression_method: zstd
@ 2021-03-12 20:43 Justin Pryzby <[email protected]>
  0 siblings, 0 replies; 8+ messages in thread

From: Justin Pryzby @ 2021-03-12 20:43 UTC (permalink / raw)

---
 configure                                     | 163 ++++++++++++++++++
 configure.ac                                  |  26 +++
 doc/src/sgml/config.sgml                      |   2 +-
 src/backend/access/transam/xlog.c             |   3 +
 src/backend/access/transam/xloginsert.c       |  19 ++
 src/backend/access/transam/xlogreader.c       |  16 ++
 src/backend/utils/misc/postgresql.conf.sample |   2 +-
 src/include/access/xlog_internal.h            |   1 +
 src/include/pg_config.h.in                    |   3 +
 src/tools/msvc/Solution.pm                    |   1 +
 10 files changed, 234 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 3afa1e87e3..20c6e08c02 100755
--- a/configure
+++ b/configure
@@ -699,6 +699,9 @@ with_gnu_ld
 LD
 LDFLAGS_SL
 LDFLAGS_EX
+ZSTD_LIBS
+ZSTD_CFLAGS
+with_zstd
 LZ4_LIBS
 LZ4_CFLAGS
 with_lz4
@@ -868,6 +871,7 @@ with_libxslt
 with_system_tzdata
 with_zlib
 with_lz4
+with_zstd
 with_gnu_ld
 with_ssl
 with_openssl
@@ -897,6 +901,8 @@ XML2_CFLAGS
 XML2_LIBS
 LZ4_CFLAGS
 LZ4_LIBS
+ZSTD_CFLAGS
+ZSTD_LIBS
 LDFLAGS_EX
 LDFLAGS_SL
 PERL
@@ -1576,6 +1582,7 @@ Optional Packages:
                           use system time zone data in DIR
   --without-zlib          do not use Zlib
   --without-lz4           build without LZ4 support
+  --with-zstd             build with Zstd compression library
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
   --with-ssl=LIB          use LIB for SSL/TLS support (openssl)
   --with-openssl          obsolete spelling of --with-ssl=openssl
@@ -1605,6 +1612,8 @@ Some influential environment variables:
   XML2_LIBS   linker flags for XML2, overriding pkg-config
   LZ4_CFLAGS  C compiler flags for LZ4, overriding pkg-config
   LZ4_LIBS    linker flags for LZ4, overriding pkg-config
+  ZSTD_CFLAGS C compiler flags for ZSTD, overriding pkg-config
+  ZSTD_LIBS   linker flags for ZSTD, overriding pkg-config
   LDFLAGS_EX  extra linker flags for linking executables only
   LDFLAGS_SL  extra linker flags for linking shared libraries only
   PERL        Perl program
@@ -8705,6 +8714,137 @@ fi
   CFLAGS="$LZ4_CFLAGS $CFLAGS"
 fi
 
+#
+# ZSTD
+#
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build with zstd support" >&5
+$as_echo_n "checking whether to build with zstd support... " >&6; }
+
+
+
+# Check whether --with-zstd was given.
+if test "${with_zstd+set}" = set; then :
+  withval=$with_zstd;
+  case $withval in
+    yes)
+
+$as_echo "#define USE_ZSTD 1" >>confdefs.h
+
+      ;;
+    no)
+      :
+      ;;
+    *)
+      as_fn_error $? "no argument expected for --with-zstd option" "$LINENO" 5
+      ;;
+  esac
+
+else
+  with_zstd=no
+
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_zstd" >&5
+$as_echo "$with_zstd" >&6; }
+
+
+if test "$with_zstd" = yes; then
+
+pkg_failed=no
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libzstd" >&5
+$as_echo_n "checking for libzstd... " >&6; }
+
+if test -n "$ZSTD_CFLAGS"; then
+    pkg_cv_ZSTD_CFLAGS="$ZSTD_CFLAGS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libzstd\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "libzstd") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_ZSTD_CFLAGS=`$PKG_CONFIG --cflags "libzstd" 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes
+else
+  pkg_failed=yes
+fi
+ else
+    pkg_failed=untried
+fi
+if test -n "$ZSTD_LIBS"; then
+    pkg_cv_ZSTD_LIBS="$ZSTD_LIBS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libzstd\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "libzstd") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_ZSTD_LIBS=`$PKG_CONFIG --libs "libzstd" 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes
+else
+  pkg_failed=yes
+fi
+ else
+    pkg_failed=untried
+fi
+
+
+
+if test $pkg_failed = yes; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+        _pkg_short_errors_supported=yes
+else
+        _pkg_short_errors_supported=no
+fi
+        if test $_pkg_short_errors_supported = yes; then
+	        ZSTD_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libzstd" 2>&1`
+        else
+	        ZSTD_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libzstd" 2>&1`
+        fi
+	# Put the nasty error message in config.log where it belongs
+	echo "$ZSTD_PKG_ERRORS" >&5
+
+	as_fn_error $? "Package requirements (libzstd) were not met:
+
+$ZSTD_PKG_ERRORS
+
+Consider adjusting the PKG_CONFIG_PATH environment variable if you
+installed software in a non-standard prefix.
+
+Alternatively, you may set the environment variables ZSTD_CFLAGS
+and ZSTD_LIBS to avoid the need to call pkg-config.
+See the pkg-config man page for more details." "$LINENO" 5
+elif test $pkg_failed = untried; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+	{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "The pkg-config script could not be found or is too old.  Make sure it
+is in your PATH or set the PKG_CONFIG environment variable to the full
+path to pkg-config.
+
+Alternatively, you may set the environment variables ZSTD_CFLAGS
+and ZSTD_LIBS to avoid the need to call pkg-config.
+See the pkg-config man page for more details.
+
+To get pkg-config, see <http://pkg-config.freedesktop.org/;.
+See \`config.log' for more details" "$LINENO" 5; }
+else
+	ZSTD_CFLAGS=$pkg_cv_ZSTD_CFLAGS
+	ZSTD_LIBS=$pkg_cv_ZSTD_LIBS
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+fi
+  LIBS="$ZSTD_LIBS $LIBS"
+  CFLAGS="$ZSTD_CFLAGS $CFLAGS"
+fi
+
 #
 # Assignments
 #
@@ -13556,6 +13696,29 @@ done
   CPPFLAGS=$ac_save_CPPFLAGS
 fi
 
+if test "$with_zstd" = yes; then
+  ac_save_CPPFLAGS=$CPPFLAGS
+  CPPFLAGS="$ZSTD_CFLAGS $CPPFLAGS"
+
+  # Verify we have zstd's header files
+  for ac_header in zstd.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "zstd.h" "ac_cv_header_zstd_h" "$ac_includes_default"
+if test "x$ac_cv_header_zstd_h" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_ZSTD_H 1
+_ACEOF
+
+else
+  as_fn_error $? "zstd.h header file is required for zstd" "$LINENO" 5
+fi
+
+done
+
+
+  CPPFLAGS=$ac_save_CPPFLAGS
+fi
+
 if test "$with_gssapi" = yes ; then
   for ac_header in gssapi/gssapi.h
 do :
diff --git a/configure.ac b/configure.ac
index d62ea5f742..c4956745ce 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1001,6 +1001,21 @@ if test "$with_lz4" = yes; then
   CFLAGS="$LZ4_CFLAGS $CFLAGS"
 fi
 
+#
+# ZSTD
+#
+AC_MSG_CHECKING([whether to build with zstd support])
+PGAC_ARG_BOOL(with, zstd, no, [build with Zstd compression library],
+              [AC_DEFINE([USE_ZSTD], 1, [Define to 1 to build with zstd support. (--with-zstd)])])
+AC_MSG_RESULT([$with_zstd])
+AC_SUBST(with_zstd)
+
+if test "$with_zstd" = yes; then
+  PKG_CHECK_MODULES(ZSTD, libzstd)
+  LIBS="$ZSTD_LIBS $LIBS"
+  CFLAGS="$ZSTD_CFLAGS $CFLAGS"
+fi
+
 #
 # Assignments
 #
@@ -1433,6 +1448,17 @@ if test "$with_lz4" = yes; then
   CPPFLAGS=$ac_save_CPPFLAGS
 fi
 
+if test "$with_zstd" = yes; then
+  ac_save_CPPFLAGS=$CPPFLAGS
+  CPPFLAGS="$ZSTD_CFLAGS $CPPFLAGS"
+
+  # Verify we have zstd's header files
+  AC_CHECK_HEADERS(zstd.h, [],
+       [AC_MSG_ERROR([zstd.h header file is required for zstd])])
+
+  CPPFLAGS=$ac_save_CPPFLAGS
+fi
+
 if test "$with_gssapi" = yes ; then
   AC_CHECK_HEADERS(gssapi/gssapi.h, [],
 	[AC_CHECK_HEADERS(gssapi.h, [], [AC_MSG_ERROR([gssapi.h header file is required for GSSAPI])])])
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index 257775c83b..94dd6ef3e9 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -3083,7 +3083,7 @@ include_dir 'conf.d'
         This parameter selects the compression method used to compress WAL when
         <varname>wal_compression</varname> is enabled.
         The supported methods are pglz, zlib, and (if configured when
-        <productname>PostgreSQL</productname> was built) lz4.
+        <productname>PostgreSQL</productname> was built) lz4 and zstd.
         The default value is <literal>pglz</literal>.
         Only superusers can change this setting.
        </para>
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 609d954a3a..9bac79b579 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -189,6 +189,9 @@ const struct config_enum_entry wal_compression_options[] = {
 #endif
 #ifdef  USE_LZ4
 	{"lz4", WAL_COMPRESSION_LZ4, false},
+#endif
+#ifdef  USE_ZSTD
+	{"zstd", WAL_COMPRESSION_ZSTD, false},
 #endif
 	{NULL, 0, false}
 };
diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c
index 9fe5c30236..5d1ae37dae 100644
--- a/src/backend/access/transam/xloginsert.c
+++ b/src/backend/access/transam/xloginsert.c
@@ -41,6 +41,10 @@
 #include "lz4.h"
 #endif
 
+#ifdef USE_ZSTD
+#include "zstd.h"
+#endif
+
 /* Buffer size required to store a compressed version of backup block image */
 #define PGLZ_MAX_BLCKSZ PGLZ_MAX_OUTPUT(BLCKSZ)
 
@@ -896,6 +900,21 @@ XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length,
 		break;
 #endif
 
+#ifdef USE_ZSTD
+	case WAL_COMPRESSION_ZSTD:
+		len = ZSTD_compress(dest, PGLZ_MAX_BLCKSZ, source, orig_len, 1);
+		if (ZSTD_isError(len))
+		{
+			ereport(ERROR,
+					(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+					 errmsg("failed compressing zstd: %s",
+						 ZSTD_getErrorName(len))));
+			len = -1;
+		}
+
+		break;
+#endif
+
 	default:
 		/*
 		 * It should be impossible to get here for unsupported algorithms,
diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c
index fa1e38a810..caa1031d63 100644
--- a/src/backend/access/transam/xlogreader.c
+++ b/src/backend/access/transam/xlogreader.c
@@ -41,6 +41,10 @@
 #include "lz4.h"
 #endif
 
+#ifdef USE_ZSTD
+#include "zstd.h"
+#endif
+
 static void report_invalid_record(XLogReaderState *state, const char *fmt,...)
 			pg_attribute_printf(2, 3);
 static bool allocate_recordbuf(XLogReaderState *state, uint32 reclength);
@@ -1564,6 +1568,8 @@ wal_compression_name(WalCompression compression)
 			return "zlib";
 		case WAL_COMPRESSION_LZ4:
 			return "lz4";
+		case WAL_COMPRESSION_ZSTD:
+			return "zstd";
 		default:
 			return "???";
 	}
@@ -1621,6 +1627,16 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page)
 			break;
 #endif
 
+#ifdef USE_ZSTD
+		case WAL_COMPRESSION_ZSTD:
+			decomp_result = ZSTD_decompress(tmp.data, BLCKSZ-bkpb->hole_length,
+					ptr, bkpb->bimg_len);
+			// XXX: ZSTD_getErrorName
+			if (ZSTD_isError(decomp_result))
+				decomp_result = -1;
+			break;
+#endif
+
 		default:
 			report_invalid_record(record, "image at %X/%X is compressed with unsupported codec, block %d (%d/%s)",
 								  (uint32) (record->ReadRecPtr >> 32),
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index 76f494cb9b..d372e2a817 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -213,7 +213,7 @@
 					#   open_sync
 #full_page_writes = on			# recover from partial page writes
 #wal_compression = off			# enable compression of full-page writes
-#wal_compression_method = pglz		# pglz, zlib, lz4
+#wal_compression_method = pglz		# pglz, zlib, lz4, zstd
 #wal_log_hints = off			# also do full page writes of non-critical updates
 					# (change requires restart)
 #wal_init_zero = on			# zero-fill new WAL files
diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h
index e70886b81c..48b16b6083 100644
--- a/src/include/access/xlog_internal.h
+++ b/src/include/access/xlog_internal.h
@@ -329,6 +329,7 @@ typedef enum WalCompression
 	WAL_COMPRESSION_PGLZ,
 	WAL_COMPRESSION_ZLIB,
 	WAL_COMPRESSION_LZ4,
+	WAL_COMPRESSION_ZSTD,
 } WalCompression;
 
 extern const char *wal_compression_name(WalCompression compression);
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index 0a6422da4f..ad26393352 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -902,6 +902,9 @@
 /* Define to 1 to build with LZ4 support (--with-lz4) */
 #undef USE_LZ4
 
+/* Define to 1 if you have the `zstd' library (-lzstd). */
+#undef USE_ZSTD
+
 /* Define to select named POSIX semaphores. */
 #undef USE_NAMED_POSIX_SEMAPHORES
 
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index 14605371bb..fff0212087 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -486,6 +486,7 @@ sub GenerateFiles
 		USE_LIBXML                 => undef,
 		USE_LIBXSLT                => undef,
 		USE_LZ4                    => undef,
+		USE_ZSTD                   => $self->{options}->{zstd} ? 1 : undef,
 		USE_LDAP                   => $self->{options}->{ldap} ? 1 : undef,
 		USE_LLVM                   => undef,
 		USE_NAMED_POSIX_SEMAPHORES => undef,
-- 
2.17.0


--0qVF/w3MHQqLSynd
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment; filename="0008-Default-to-zstd.patch"



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: pgindent vs. pgperltidy command-line arguments
@ 2023-05-25 13:20 Tom Lane <[email protected]>
  2023-06-14 07:37 ` Re: pgindent vs. pgperltidy command-line arguments Peter Eisentraut <[email protected]>
  0 siblings, 1 reply; 8+ messages in thread

From: Tom Lane @ 2023-05-25 13:20 UTC (permalink / raw)
  To: Peter Eisentraut <[email protected]>; +Cc: pgsql-hackers

Peter Eisentraut <[email protected]> writes:
> Until PG15, calling pgindent without arguments would process the whole 
> tree.  Now you get
> No files to process at ./src/tools/pgindent/pgindent line 372.
> Is that intentional?

It was intentional, cf b16259b3c and the linked discussion.

> Also, pgperltidy accepts no arguments and always processes the whole 
> tree.  It would be nice if there were a way to process individual files 
> or directories, like pgindent can.

+1, although I wonder if we shouldn't follow pgindent's new lead
and require some argument(s).

> Attached is a patch for this.
> (It seems that it works ok to pass regular files (not directories) to 
> "find", but I'm not sure if it's portable.)

The POSIX spec for find(1) gives an example of applying find to
what they evidently intend to be a plain file:

	if [ -n "$(find file1 -prune -newer file2)" ]; then
	    printf %s\\n "file1 is newer than file2"
	fi

So while I don't see it written in so many words, I think you
can assume it's portable.

			regards, tom lane






^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: pgindent vs. pgperltidy command-line arguments
  2023-05-25 13:20 Re: pgindent vs. pgperltidy command-line arguments Tom Lane <[email protected]>
@ 2023-06-14 07:37 ` Peter Eisentraut <[email protected]>
  2023-06-20 15:38   ` Re: pgindent vs. pgperltidy command-line arguments Andrew Dunstan <[email protected]>
  0 siblings, 1 reply; 8+ messages in thread

From: Peter Eisentraut @ 2023-06-14 07:37 UTC (permalink / raw)
  To: Tom Lane <[email protected]>; +Cc: pgsql-hackers

On 25.05.23 15:20, Tom Lane wrote:
> Peter Eisentraut <[email protected]> writes:
>> Until PG15, calling pgindent without arguments would process the whole
>> tree.  Now you get
>> No files to process at ./src/tools/pgindent/pgindent line 372.
>> Is that intentional?
> 
> It was intentional, cf b16259b3c and the linked discussion.
> 
>> Also, pgperltidy accepts no arguments and always processes the whole
>> tree.  It would be nice if there were a way to process individual files
>> or directories, like pgindent can.
> 
> +1, although I wonder if we shouldn't follow pgindent's new lead
> and require some argument(s).

That makes sense to me.  Here is a small update with this behavior 
change and associated documentation update.

From 44f7bcdcc0849a55459d4c2da27ee1976c704933 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Wed, 14 Jun 2023 09:33:03 +0200
Subject: [PATCH v2] Allow and require passing files on command line of
 pgperltidy

pgperltidy as well as pgperlcritic and pgperlsyncheck now allow
passing files and directories on the command line, like pgindent does.
(Previously, they would always operate on the whole tree.)

Also, for consistency with pgindent's new behavior (as of b16259b3c1),
passing an argument is now required.  To get the previous default
behavior, use "pgperltidy ." for example.

Discussion: https://www.postgresql.org/message-id/flat/45aacd8a-5265-d9da-8df2-b8e2c0cf6a07%40eisentraut.org
---
 src/tools/perlcheck/find_perl_files | 8 ++++++--
 src/tools/perlcheck/pgperlcritic    | 2 +-
 src/tools/perlcheck/pgperlsyncheck  | 2 +-
 src/tools/pgindent/README           | 2 +-
 src/tools/pgindent/pgperltidy       | 2 +-
 5 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/tools/perlcheck/find_perl_files b/src/tools/perlcheck/find_perl_files
index fd99dab83b..20dceb800d 100644
--- a/src/tools/perlcheck/find_perl_files
+++ b/src/tools/perlcheck/find_perl_files
@@ -3,11 +3,15 @@
 # shell function to find all perl files in the source tree
 
 find_perl_files () {
+	if [ $# -eq 0 ]; then
+		echo 'No files to process' 1>&2
+		return
+	fi
     {
 		# take all .pl and .pm files
-		find . -type f -name '*.p[lm]' -print
+		find "$@" -type f -name '*.p[lm]' -print
 		# take executable files that file(1) thinks are perl files
-		find . -type f -perm -100 -exec file {} \; -print |
+		find "$@" -type f -perm -100 -exec file {} \; -print |
 		egrep -i ':.*perl[0-9]*\>' |
 		cut -d: -f1
 	} | sort -u | grep -v '^\./\.git/'
diff --git a/src/tools/perlcheck/pgperlcritic b/src/tools/perlcheck/pgperlcritic
index 1c2f787580..2ec6f20de3 100755
--- a/src/tools/perlcheck/pgperlcritic
+++ b/src/tools/perlcheck/pgperlcritic
@@ -14,7 +14,7 @@ PERLCRITIC=${PERLCRITIC:-perlcritic}
 
 . src/tools/perlcheck/find_perl_files
 
-find_perl_files | xargs $PERLCRITIC \
+find_perl_files "$@" | xargs $PERLCRITIC \
 	  --quiet \
 	  --program-extensions .pl \
 	  --profile=src/tools/perlcheck/perlcriticrc
diff --git a/src/tools/perlcheck/pgperlsyncheck b/src/tools/perlcheck/pgperlsyncheck
index 730f5927cd..da59c9727c 100755
--- a/src/tools/perlcheck/pgperlsyncheck
+++ b/src/tools/perlcheck/pgperlsyncheck
@@ -13,4 +13,4 @@ set -e
 # for zsh
 setopt shwordsplit 2>/dev/null || true
 
-find_perl_files | xargs -L 1 perl $INCLUDES -cw 2>&1 | grep -v OK
+find_perl_files "$@" | xargs -L 1 perl $INCLUDES -cw 2>&1 | grep -v OK
diff --git a/src/tools/pgindent/README b/src/tools/pgindent/README
index b2b134ee6a..f5fdfc5d2f 100644
--- a/src/tools/pgindent/README
+++ b/src/tools/pgindent/README
@@ -45,7 +45,7 @@ DOING THE INDENT RUN:
 
 4) Indent the Perl code using perltidy:
 
-	src/tools/pgindent/pgperltidy
+	src/tools/pgindent/pgperltidy .
 
    If you want to use some perltidy version that's not in your PATH,
    first set the PERLTIDY environment variable to point to it.
diff --git a/src/tools/pgindent/pgperltidy b/src/tools/pgindent/pgperltidy
index 5e704119eb..6af27d21d5 100755
--- a/src/tools/pgindent/pgperltidy
+++ b/src/tools/pgindent/pgperltidy
@@ -9,4 +9,4 @@ PERLTIDY=${PERLTIDY:-perltidy}
 
 . src/tools/perlcheck/find_perl_files
 
-find_perl_files | xargs $PERLTIDY --profile=src/tools/pgindent/perltidyrc
+find_perl_files "$@" | xargs $PERLTIDY --profile=src/tools/pgindent/perltidyrc

base-commit: 0f8cfaf8921fed35f0b92d918ce95eec7b46ff05
-- 
2.41.0



Attachments:

  [text/plain] v2-0001-Allow-and-require-passing-files-on-command-line-o.patch (3.5K, ../../[email protected]/2-v2-0001-Allow-and-require-passing-files-on-command-line-o.patch)
  download | inline diff:
From 44f7bcdcc0849a55459d4c2da27ee1976c704933 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Wed, 14 Jun 2023 09:33:03 +0200
Subject: [PATCH v2] Allow and require passing files on command line of
 pgperltidy

pgperltidy as well as pgperlcritic and pgperlsyncheck now allow
passing files and directories on the command line, like pgindent does.
(Previously, they would always operate on the whole tree.)

Also, for consistency with pgindent's new behavior (as of b16259b3c1),
passing an argument is now required.  To get the previous default
behavior, use "pgperltidy ." for example.

Discussion: https://www.postgresql.org/message-id/flat/45aacd8a-5265-d9da-8df2-b8e2c0cf6a07%40eisentraut.org
---
 src/tools/perlcheck/find_perl_files | 8 ++++++--
 src/tools/perlcheck/pgperlcritic    | 2 +-
 src/tools/perlcheck/pgperlsyncheck  | 2 +-
 src/tools/pgindent/README           | 2 +-
 src/tools/pgindent/pgperltidy       | 2 +-
 5 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/tools/perlcheck/find_perl_files b/src/tools/perlcheck/find_perl_files
index fd99dab83b..20dceb800d 100644
--- a/src/tools/perlcheck/find_perl_files
+++ b/src/tools/perlcheck/find_perl_files
@@ -3,11 +3,15 @@
 # shell function to find all perl files in the source tree
 
 find_perl_files () {
+	if [ $# -eq 0 ]; then
+		echo 'No files to process' 1>&2
+		return
+	fi
     {
 		# take all .pl and .pm files
-		find . -type f -name '*.p[lm]' -print
+		find "$@" -type f -name '*.p[lm]' -print
 		# take executable files that file(1) thinks are perl files
-		find . -type f -perm -100 -exec file {} \; -print |
+		find "$@" -type f -perm -100 -exec file {} \; -print |
 		egrep -i ':.*perl[0-9]*\>' |
 		cut -d: -f1
 	} | sort -u | grep -v '^\./\.git/'
diff --git a/src/tools/perlcheck/pgperlcritic b/src/tools/perlcheck/pgperlcritic
index 1c2f787580..2ec6f20de3 100755
--- a/src/tools/perlcheck/pgperlcritic
+++ b/src/tools/perlcheck/pgperlcritic
@@ -14,7 +14,7 @@ PERLCRITIC=${PERLCRITIC:-perlcritic}
 
 . src/tools/perlcheck/find_perl_files
 
-find_perl_files | xargs $PERLCRITIC \
+find_perl_files "$@" | xargs $PERLCRITIC \
 	  --quiet \
 	  --program-extensions .pl \
 	  --profile=src/tools/perlcheck/perlcriticrc
diff --git a/src/tools/perlcheck/pgperlsyncheck b/src/tools/perlcheck/pgperlsyncheck
index 730f5927cd..da59c9727c 100755
--- a/src/tools/perlcheck/pgperlsyncheck
+++ b/src/tools/perlcheck/pgperlsyncheck
@@ -13,4 +13,4 @@ set -e
 # for zsh
 setopt shwordsplit 2>/dev/null || true
 
-find_perl_files | xargs -L 1 perl $INCLUDES -cw 2>&1 | grep -v OK
+find_perl_files "$@" | xargs -L 1 perl $INCLUDES -cw 2>&1 | grep -v OK
diff --git a/src/tools/pgindent/README b/src/tools/pgindent/README
index b2b134ee6a..f5fdfc5d2f 100644
--- a/src/tools/pgindent/README
+++ b/src/tools/pgindent/README
@@ -45,7 +45,7 @@ DOING THE INDENT RUN:
 
 4) Indent the Perl code using perltidy:
 
-	src/tools/pgindent/pgperltidy
+	src/tools/pgindent/pgperltidy .
 
    If you want to use some perltidy version that's not in your PATH,
    first set the PERLTIDY environment variable to point to it.
diff --git a/src/tools/pgindent/pgperltidy b/src/tools/pgindent/pgperltidy
index 5e704119eb..6af27d21d5 100755
--- a/src/tools/pgindent/pgperltidy
+++ b/src/tools/pgindent/pgperltidy
@@ -9,4 +9,4 @@ PERLTIDY=${PERLTIDY:-perltidy}
 
 . src/tools/perlcheck/find_perl_files
 
-find_perl_files | xargs $PERLTIDY --profile=src/tools/pgindent/perltidyrc
+find_perl_files "$@" | xargs $PERLTIDY --profile=src/tools/pgindent/perltidyrc

base-commit: 0f8cfaf8921fed35f0b92d918ce95eec7b46ff05
-- 
2.41.0



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: pgindent vs. pgperltidy command-line arguments
  2023-05-25 13:20 Re: pgindent vs. pgperltidy command-line arguments Tom Lane <[email protected]>
  2023-06-14 07:37 ` Re: pgindent vs. pgperltidy command-line arguments Peter Eisentraut <[email protected]>
@ 2023-06-20 15:38   ` Andrew Dunstan <[email protected]>
  2023-06-21 09:09     ` Re: pgindent vs. pgperltidy command-line arguments Peter Eisentraut <[email protected]>
  0 siblings, 1 reply; 8+ messages in thread

From: Andrew Dunstan @ 2023-06-20 15:38 UTC (permalink / raw)
  To: Peter Eisentraut <[email protected]>; Tom Lane <[email protected]>; +Cc: pgsql-hackers


On 2023-06-14 We 03:37, Peter Eisentraut wrote:
> On 25.05.23 15:20, Tom Lane wrote:
>> Peter Eisentraut <[email protected]> writes:
>>> Until PG15, calling pgindent without arguments would process the whole
>>> tree.  Now you get
>>> No files to process at ./src/tools/pgindent/pgindent line 372.
>>> Is that intentional?
>>
>> It was intentional, cf b16259b3c and the linked discussion.
>>
>>> Also, pgperltidy accepts no arguments and always processes the whole
>>> tree.  It would be nice if there were a way to process individual files
>>> or directories, like pgindent can.
>>
>> +1, although I wonder if we shouldn't follow pgindent's new lead
>> and require some argument(s).
>
> That makes sense to me.  Here is a small update with this behavior 
> change and associated documentation update.


I'm intending to add some of the new pgindent features to pgperltidy. 
Preparatory to that here's a rewrite of pgperltidy in perl - no new 
features yet but it does remove the hardcoded path, and requires you to 
pass in one or more files / directories as arguments.


cheers


andrew

--
Andrew Dunstan
EDB:https://www.enterprisedb.com

#!/usr/bin/perl

# Copyright (c) 2023, PostgreSQL Global Development Group

# src/tools/pgindent/pgperltidy

use strict;
use warnings;

use File::Find;

my $perltidy = $ENV{PERLTIDY} || 'perltidy';

my @files;

die "No directories or files specified" unless @ARGV;

sub is_perl_exec
{
	my $name = shift;
	my $out = `file $name 2>/dev/null`;
	return $out =~ /:.*perl[0-9]*\b/i;
}

my $wanted = sub {

	my $name = $File::Find::name;
	my ($dev, $ino, $mode, $nlink, $uid, $gid);

	# check it's a plain file and either it has a perl extension (.p[lm])
	# or it's executable and `file` thinks it's a perl script.

	(($dev, $ino, $mode, $nlink, $uid, $gid) = lstat($_))
	  && -f _
	  && (/\.p[lm]$/ || ((($mode & 0100) == 0100) && is_perl_exec($_)))
	  && push(@files, $name);
};

File::Find::find({ wanted => $wanted }, @ARGV);

my $list = join(" ", @files);

system "$perltidy --profile=src/tools/pgindent/perltidyrc $list";


Attachments:

  [text/plain] pgperltidy (921B, ../../[email protected]/3-pgperltidy)
  download | inline:
#!/usr/bin/perl

# Copyright (c) 2023, PostgreSQL Global Development Group

# src/tools/pgindent/pgperltidy

use strict;
use warnings;

use File::Find;

my $perltidy = $ENV{PERLTIDY} || 'perltidy';

my @files;

die "No directories or files specified" unless @ARGV;

sub is_perl_exec
{
	my $name = shift;
	my $out = `file $name 2>/dev/null`;
	return $out =~ /:.*perl[0-9]*\b/i;
}

my $wanted = sub {

	my $name = $File::Find::name;
	my ($dev, $ino, $mode, $nlink, $uid, $gid);

	# check it's a plain file and either it has a perl extension (.p[lm])
	# or it's executable and `file` thinks it's a perl script.

	(($dev, $ino, $mode, $nlink, $uid, $gid) = lstat($_))
	  && -f _
	  && (/\.p[lm]$/ || ((($mode & 0100) == 0100) && is_perl_exec($_)))
	  && push(@files, $name);
};

File::Find::find({ wanted => $wanted }, @ARGV);

my $list = join(" ", @files);

system "$perltidy --profile=src/tools/pgindent/perltidyrc $list";

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: pgindent vs. pgperltidy command-line arguments
  2023-05-25 13:20 Re: pgindent vs. pgperltidy command-line arguments Tom Lane <[email protected]>
  2023-06-14 07:37 ` Re: pgindent vs. pgperltidy command-line arguments Peter Eisentraut <[email protected]>
  2023-06-20 15:38   ` Re: pgindent vs. pgperltidy command-line arguments Andrew Dunstan <[email protected]>
@ 2023-06-21 09:09     ` Peter Eisentraut <[email protected]>
  2023-06-21 11:35       ` Re: pgindent vs. pgperltidy command-line arguments Andrew Dunstan <[email protected]>
  0 siblings, 1 reply; 8+ messages in thread

From: Peter Eisentraut @ 2023-06-21 09:09 UTC (permalink / raw)
  To: Andrew Dunstan <[email protected]>; Tom Lane <[email protected]>; +Cc: pgsql-hackers

On 20.06.23 17:38, Andrew Dunstan wrote:
>>> +1, although I wonder if we shouldn't follow pgindent's new lead
>>> and require some argument(s).
>>
>> That makes sense to me.  Here is a small update with this behavior 
>> change and associated documentation update.
> 
> I'm intending to add some of the new pgindent features to pgperltidy. 
> Preparatory to that here's a rewrite of pgperltidy in perl - no new 
> features yet but it does remove the hardcoded path, and requires you to 
> pass in one or more files / directories as arguments.

Are you planning to touch pgperlcritic and pgperlsyncheck as well?  If 
not, part of my patch would still be useful.  Maybe I should commit my 
posted patch for PG16, to keep consistency with pgindent, and then your 
work would presumably be considered for PG17.






^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: pgindent vs. pgperltidy command-line arguments
  2023-05-25 13:20 Re: pgindent vs. pgperltidy command-line arguments Tom Lane <[email protected]>
  2023-06-14 07:37 ` Re: pgindent vs. pgperltidy command-line arguments Peter Eisentraut <[email protected]>
  2023-06-20 15:38   ` Re: pgindent vs. pgperltidy command-line arguments Andrew Dunstan <[email protected]>
  2023-06-21 09:09     ` Re: pgindent vs. pgperltidy command-line arguments Peter Eisentraut <[email protected]>
@ 2023-06-21 11:35       ` Andrew Dunstan <[email protected]>
  2023-06-21 14:36         ` Re: pgindent vs. pgperltidy command-line arguments Peter Eisentraut <[email protected]>
  2023-07-06 15:47         ` Re: pgindent vs. pgperltidy command-line arguments Andrew Dunstan <[email protected]>
  0 siblings, 2 replies; 8+ messages in thread

From: Andrew Dunstan @ 2023-06-21 11:35 UTC (permalink / raw)
  To: Peter Eisentraut <[email protected]>; Tom Lane <[email protected]>; +Cc: pgsql-hackers


On 2023-06-21 We 05:09, Peter Eisentraut wrote:
> On 20.06.23 17:38, Andrew Dunstan wrote:
>>>> +1, although I wonder if we shouldn't follow pgindent's new lead
>>>> and require some argument(s).
>>>
>>> That makes sense to me.  Here is a small update with this behavior 
>>> change and associated documentation update.
>>
>> I'm intending to add some of the new pgindent features to pgperltidy. 
>> Preparatory to that here's a rewrite of pgperltidy in perl - no new 
>> features yet but it does remove the hardcoded path, and requires you 
>> to pass in one or more files / directories as arguments.
>
> Are you planning to touch pgperlcritic and pgperlsyncheck as well? 


Yeah, it would make sense to.


> If not, part of my patch would still be useful.  Maybe I should commit 
> my posted patch for PG16, to keep consistency with pgindent, and then 
> your work would presumably be considered for PG17.


That sounds like a good plan.


cheers


andrew

--
Andrew Dunstan
EDB:https://www.enterprisedb.com


^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: pgindent vs. pgperltidy command-line arguments
  2023-05-25 13:20 Re: pgindent vs. pgperltidy command-line arguments Tom Lane <[email protected]>
  2023-06-14 07:37 ` Re: pgindent vs. pgperltidy command-line arguments Peter Eisentraut <[email protected]>
  2023-06-20 15:38   ` Re: pgindent vs. pgperltidy command-line arguments Andrew Dunstan <[email protected]>
  2023-06-21 09:09     ` Re: pgindent vs. pgperltidy command-line arguments Peter Eisentraut <[email protected]>
  2023-06-21 11:35       ` Re: pgindent vs. pgperltidy command-line arguments Andrew Dunstan <[email protected]>
@ 2023-06-21 14:36         ` Peter Eisentraut <[email protected]>
  1 sibling, 0 replies; 8+ messages in thread

From: Peter Eisentraut @ 2023-06-21 14:36 UTC (permalink / raw)
  To: Andrew Dunstan <[email protected]>; Tom Lane <[email protected]>; +Cc: pgsql-hackers

On 21.06.23 13:35, Andrew Dunstan wrote:
>> If not, part of my patch would still be useful.  Maybe I should commit 
>> my posted patch for PG16, to keep consistency with pgindent, and then 
>> your work would presumably be considered for PG17.
> 
> That sounds like a good plan.

done







^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: pgindent vs. pgperltidy command-line arguments
  2023-05-25 13:20 Re: pgindent vs. pgperltidy command-line arguments Tom Lane <[email protected]>
  2023-06-14 07:37 ` Re: pgindent vs. pgperltidy command-line arguments Peter Eisentraut <[email protected]>
  2023-06-20 15:38   ` Re: pgindent vs. pgperltidy command-line arguments Andrew Dunstan <[email protected]>
  2023-06-21 09:09     ` Re: pgindent vs. pgperltidy command-line arguments Peter Eisentraut <[email protected]>
  2023-06-21 11:35       ` Re: pgindent vs. pgperltidy command-line arguments Andrew Dunstan <[email protected]>
@ 2023-07-06 15:47         ` Andrew Dunstan <[email protected]>
  1 sibling, 0 replies; 8+ messages in thread

From: Andrew Dunstan @ 2023-07-06 15:47 UTC (permalink / raw)
  To: Peter Eisentraut <[email protected]>; Tom Lane <[email protected]>; +Cc: pgsql-hackers


On 2023-06-21 We 07:35, Andrew Dunstan wrote:
>
>
> On 2023-06-21 We 05:09, Peter Eisentraut wrote:
>> On 20.06.23 17:38, Andrew Dunstan wrote:
>>>>> +1, although I wonder if we shouldn't follow pgindent's new lead
>>>>> and require some argument(s).
>>>>
>>>> That makes sense to me.  Here is a small update with this behavior 
>>>> change and associated documentation update.
>>>
>>> I'm intending to add some of the new pgindent features to 
>>> pgperltidy. Preparatory to that here's a rewrite of pgperltidy in 
>>> perl - no new features yet but it does remove the hardcoded path, 
>>> and requires you to pass in one or more files / directories as 
>>> arguments.
>>
>> Are you planning to touch pgperlcritic and pgperlsyncheck as well? 
>
>
> Yeah, it would make sense to.
>


Here's a patch that turns all these into perl scripts.


cheers


andrew

--
Andrew Dunstan
EDB:https://www.enterprisedb.com


Attachments:

  [text/x-patch] perl-check-scripts-perl.patch (5.5K, ../../[email protected]/3-perl-check-scripts-perl.patch)
  download | inline diff:
diff --git a/src/tools/perlcheck/FindPerlFiles.pm b/src/tools/perlcheck/FindPerlFiles.pm
new file mode 100644
index 0000000000..3a098f6614
--- /dev/null
+++ b/src/tools/perlcheck/FindPerlFiles.pm
@@ -0,0 +1,62 @@
+
+# Copyright (c) 2023, PostgreSQL Global Development Group
+
+=pod
+
+=head1 NAME
+
+FindPerlFiles - module for finding perl files from a list of paths
+
+=head1 SYNOPSIS
+
+  use FindPerlFiles;
+
+  my @files = FindPerlFiles::findperl(path, ...);
+
+
+=head1 DESCRIPTION
+
+FindPerlFiles finds files which either have a perl extension (.pl or .pm) or
+are bot executable and found by the `file` program to be perl scripts.
+
+=cut
+
+
+package FindPerlFiles;
+
+use strict;
+use warnings;
+
+use File::Find;
+use File::stat;
+use Fcntl ':mode';
+
+my @files;
+
+sub _is_perl_exec
+{
+	my $name = shift;
+	my $out = `file $name 2>/dev/null`;
+	return $out =~ /:.*perl[0-9]*\b/i;
+}
+
+sub findperl
+{
+	my @files ;
+	my $wanted = sub
+	{
+		my $name = $File::Find::name;
+		my $st;
+		# check it's a plain file and either it has a perl extension (.p[lm])
+		# or it's executable and `file` thinks it's a perl script.
+		($st = lstat($_))
+		  && -f $st
+		  && (/\.p[lm]$/ || ((($st->mode & S_IXUSR) && _is_perl_exec($_))))
+		  && push(@files, $name);
+	};
+
+	File::Find::find({ wanted => $wanted }, @_);
+	return @files;
+}
+
+1;
diff --git a/src/tools/perlcheck/find_perl_files b/src/tools/perlcheck/find_perl_files
deleted file mode 100644
index 20dceb800d..0000000000
--- a/src/tools/perlcheck/find_perl_files
+++ /dev/null
@@ -1,18 +0,0 @@
-# src/tools/perlcheck/find_perl_files
-
-# shell function to find all perl files in the source tree
-
-find_perl_files () {
-	if [ $# -eq 0 ]; then
-		echo 'No files to process' 1>&2
-		return
-	fi
-    {
-		# take all .pl and .pm files
-		find "$@" -type f -name '*.p[lm]' -print
-		# take executable files that file(1) thinks are perl files
-		find "$@" -type f -perm -100 -exec file {} \; -print |
-		egrep -i ':.*perl[0-9]*\>' |
-		cut -d: -f1
-	} | sort -u | grep -v '^\./\.git/'
-}
diff --git a/src/tools/perlcheck/pgperlcritic b/src/tools/perlcheck/pgperlcritic
index 2ec6f20de3..87d5e92df7 100755
--- a/src/tools/perlcheck/pgperlcritic
+++ b/src/tools/perlcheck/pgperlcritic
@@ -1,20 +1,27 @@
-#!/bin/sh
+#!/usr/bin/perl
+
+# Copyright (c) 2023, PostgreSQL Global Development Group
 
 # src/tools/perlcheck/pgperlcritic
 
-test -f src/tools/perlcheck/perlcriticrc || {
-	echo could not find src/tools/perlcheck/perlcriticrc
-	exit 1
-	}
+use strict;
+use warnings;
 
-set -e
+use FindBin ();
+use lib "$FindBin::Bin";
+use FindPerlFiles;
+
+die "No directories or files specified\n" unless @ARGV;
+
+my $rc_loc = "$FindBin::Bin/perlcriticrc";
+
+die "no $rc_loc\n" unless -f $rc_loc;
 
 # set this to override default perlcritic program:
-PERLCRITIC=${PERLCRITIC:-perlcritic}
+my $perlcritic = $ENV{PERLCRITIC} || 'perlcritic';
 
-. src/tools/perlcheck/find_perl_files
+my @files = FindPerlFiles::findperl(@ARGV);
 
-find_perl_files "$@" | xargs $PERLCRITIC \
-	  --quiet \
-	  --program-extensions .pl \
-	  --profile=src/tools/perlcheck/perlcriticrc
+exit unless @files;
+
+exec $perlcritic, '--program-extensions',  '.pl', "--profile=$rc_loc", @files
diff --git a/src/tools/perlcheck/pgperlsyncheck b/src/tools/perlcheck/pgperlsyncheck
index da59c9727c..70ff248daf 100755
--- a/src/tools/perlcheck/pgperlsyncheck
+++ b/src/tools/perlcheck/pgperlsyncheck
@@ -1,16 +1,48 @@
-#!/bin/sh
+#!/usr/bin/perl
+
+# Copyright (c) 2023, PostgreSQL Global Development Group
 
 # script to detect compile time errors and warnings in all perl files
 
-INCLUDES="-I src/tools/msvc -I src/tools/msvc/dummylib -I src/backend/catalog"
-INCLUDES="-I src/test/perl -I src/backend/utils/mb/Unicode $INCLUDES"
-INCLUDES="-I src/bin/pg_rewind -I src/test/ssl/t $INCLUDES"
+use strict;
+use warnings;
 
-set -e
+use FindBin ();
+use lib "$FindBin::Bin";
 
-. src/tools/perlcheck/find_perl_files
+use Cwd qw(abs_path);
+use FindPerlFiles;
 
-# for zsh
-setopt shwordsplit 2>/dev/null || true
+die "No directories or files specified\n" unless @ARGV;
 
-find_perl_files "$@" | xargs -L 1 perl $INCLUDES -cw 2>&1 | grep -v OK
+my $srcroot = abs_path("$FindBin::Bin/../../..");
+
+my $includes="";
+
+my @incdirs = qw(
+    src/tools/msvc
+    src/tools/msvc/dummylib
+    src/backend/catalog
+    src/test/perl
+    src/backend/utils/mb/Unicode
+    src/bin/pg_rewind src/test/ssl/t
+);
+
+foreach my $inc (@incdirs)
+{
+    $includes .= "-I $srcroot/$inc ";
+}
+
+my @files =  FindPerlFiles::findperl(@ARGV);
+
+my $status = 0;
+
+foreach my $file (@files)
+{
+    my $out = `perl $includes -cw $file 2>&1`;
+    next if $out =~ /OK/;
+    $status = 1;
+    print $out;
+}
+
+exit $status;
diff --git a/src/tools/pgindent/pgperltidy b/src/tools/pgindent/pgperltidy
index 6af27d21d5..be433c1836 100755
--- a/src/tools/pgindent/pgperltidy
+++ b/src/tools/pgindent/pgperltidy
@@ -1,12 +1,22 @@
-#!/bin/sh
+#!/usr/bin/perl
+
+# Copyright (c) 2023, PostgreSQL Global Development Group
 
 # src/tools/pgindent/pgperltidy
 
-set -e
+use strict;
+use warnings;
 
-# set this to override default perltidy program:
-PERLTIDY=${PERLTIDY:-perltidy}
+use FindBin ();
+use lib "$FindBin::Bin/../perlcheck";
+use FindPerlFiles;
 
-. src/tools/perlcheck/find_perl_files
+my $perltidy = $ENV{PERLTIDY} || 'perltidy';
 
-find_perl_files "$@" | xargs $PERLTIDY --profile=src/tools/pgindent/perltidyrc
+die "No directories or files specified\n" unless @ARGV;
+
+my @files = FindPerlFiles::findperl(@ARGV);
+
+exit unless @files;
+
+exec "$perltidy", "--profile=$FindBin::Bin /perltidyrc", @files;


^ permalink  raw  reply  [nested|flat] 8+ messages in thread


end of thread, other threads:[~2023-07-06 15:47 UTC | newest]

Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-03-12 20:43 [PATCH 07/10] add wal_compression_method: zstd Justin Pryzby <[email protected]>
2023-05-25 13:20 Re: pgindent vs. pgperltidy command-line arguments Tom Lane <[email protected]>
2023-06-14 07:37 ` Re: pgindent vs. pgperltidy command-line arguments Peter Eisentraut <[email protected]>
2023-06-20 15:38   ` Re: pgindent vs. pgperltidy command-line arguments Andrew Dunstan <[email protected]>
2023-06-21 09:09     ` Re: pgindent vs. pgperltidy command-line arguments Peter Eisentraut <[email protected]>
2023-06-21 11:35       ` Re: pgindent vs. pgperltidy command-line arguments Andrew Dunstan <[email protected]>
2023-06-21 14:36         ` Re: pgindent vs. pgperltidy command-line arguments Peter Eisentraut <[email protected]>
2023-07-06 15:47         ` Re: pgindent vs. pgperltidy command-line arguments Andrew Dunstan <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox