diff options
| author | Thomas Munro | 2025-04-08 08:52:47 +0000 |
|---|---|---|
| committer | Thomas Munro | 2025-04-08 09:35:38 +0000 |
| commit | f78ca6f3ebbbff8c675c34b8ee61047223073866 (patch) | |
| tree | c3543200c7b119226fb6b1266db6dfd463b02267 /src/include | |
| parent | 042a66291b04f473cbc72f95f07438abd75ae3a9 (diff) | |
Introduce file_copy_method setting.
It can be set to either COPY (the default) or CLONE if the system
supports it. CLONE causes callers of copydir(), currently CREATE
DATABASE ... STRATEGY=FILE_COPY and ALTER DATABASE ... SET TABLESPACE =
..., to use copy_file_range (Linux, FreeBSD) or copyfile (macOS) to copy
files instead of a read-write loop over the contents.
CLONE gives the kernel the opportunity to share block ranges on
copy-on-write file systems and push copying down to storage on others,
depending on configuration. On some systems CLONE can be used to clone
large databases quickly with CREATE DATABASE ... TEMPLATE=source
STRATEGY=FILE_COPY.
Other operating systems could be supported; patches welcome.
Co-authored-by: Nazir Bilal Yavuz <byavuz81@gmail.com>
Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Reviewed-by: Ranier Vilela <ranier.vf@gmail.com>
Discussion: https://postgr.es/m/CA%2BhUKGLM%2Bt%2BSwBU-cHeMUXJCOgBxSHLGZutV5zCwY4qrCcE02w%40mail.gmail.com
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/storage/copydir.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/include/storage/copydir.h b/src/include/storage/copydir.h index cf60e63f4e2..940d74462d1 100644 --- a/src/include/storage/copydir.h +++ b/src/include/storage/copydir.h @@ -13,6 +13,15 @@ #ifndef COPYDIR_H #define COPYDIR_H +typedef enum FileCopyMethod +{ + FILE_COPY_METHOD_COPY, + FILE_COPY_METHOD_CLONE, +} FileCopyMethod; + +/* GUC parameters */ +extern PGDLLIMPORT int file_copy_method; + extern void copydir(const char *fromdir, const char *todir, bool recurse); extern void copy_file(const char *fromfile, const char *tofile); |
