v3-0001-Add-copy_file_range-3-system-call-detection.-Futu.patch

application/octet-stream

Filename: v3-0001-Add-copy_file_range-3-system-call-detection.-Futu.patch
Type: application/octet-stream
Part: 0
Message: Re: pg_upgrade --copy-file-range

Patch

Format: format-patch
Series: patch v3-0001
Subject: Add copy_file_range(3) system call detection. Future patches may use it to optimize copying/cloning.
File+
configure 1 1
configure.ac 1 0
meson.build 1 0
src/include/pg_config.h.in 3 0
From 7216586c13d9a470e1c3da7349cb7f19e318d8a3 Mon Sep 17 00:00:00 2001
From: Jakub Wartak <jakub.wartak@enterprisedb.com>
Date: Thu, 4 Jan 2024 14:43:37 +0100
Subject: [PATCH v3 1/4] Add copy_file_range(3) system call detection. Future
 patches may use it to optimize copying/cloning.

Discussion: https://www.postgresql.org/message-id/flat/CA%2BhUKGJvLLNQtzb%3DZWcTsYF8kv8cR_%3DH17CX-eL8qNixeC4DAw%40mail.gmail.com#ce606227e39df74c6b2abf80b8eab04a
---
 configure                  | 2 +-
 configure.ac               | 1 +
 meson.build                | 1 +
 src/include/pg_config.h.in | 3 +++
 4 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index 217704e9ca..ca30f4f96a 100755
--- a/configure
+++ b/configure
@@ -15539,7 +15539,7 @@ fi
 LIBS_including_readline="$LIBS"
 LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'`
 
-for ac_func in backtrace_symbols copyfile getifaddrs getpeerucred inet_pton kqueue mbstowcs_l memset_s posix_fallocate ppoll pthread_is_threaded_np setproctitle setproctitle_fast strchrnul strsignal syncfs sync_file_range uselocale wcstombs_l
+for ac_func in backtrace_symbols copyfile copy_file_range getifaddrs getpeerucred inet_pton kqueue mbstowcs_l memset_s posix_fallocate ppoll pthread_is_threaded_np setproctitle setproctitle_fast strchrnul strsignal syncfs sync_file_range uselocale wcstombs_l
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
diff --git a/configure.ac b/configure.ac
index e49de9e4f0..a80c83dd45 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1769,6 +1769,7 @@ LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'`
 AC_CHECK_FUNCS(m4_normalize([
 	backtrace_symbols
 	copyfile
+	copy_file_range
 	getifaddrs
 	getpeerucred
 	inet_pton
diff --git a/meson.build b/meson.build
index 21abd7da85..cd69391d60 100644
--- a/meson.build
+++ b/meson.build
@@ -2419,6 +2419,7 @@ func_checks = [
   ['backtrace_symbols', {'dependencies': [execinfo_dep]}],
   ['clock_gettime', {'dependencies': [rt_dep], 'define': false}],
   ['copyfile'],
+  ['copy_file_range'],
   # gcc/clang's sanitizer helper library provides dlopen but not dlsym, thus
   # when enabling asan the dlopen check doesn't notice that -ldl is actually
   # required. Just checking for dlsym() ought to suffice.
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index 5f16918243..c848af34cb 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -78,6 +78,9 @@
 /* Define to 1 if you have the <copyfile.h> header file. */
 #undef HAVE_COPYFILE_H
 
+/* Define to 1 if you have the `copy_file_range' function. */
+#undef HAVE_COPY_FILE_RANGE
+
 /* Define to 1 if you have the <crtdefs.h> header file. */
 #undef HAVE_CRTDEFS_H
 
-- 
2.30.2