From f80b09bac87d6b49f5dbb6131da5fbd9b9773c5c Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Mon, 5 Aug 2024 11:40:29 -0400 Subject: [PATCH] Move astreamer (except astreamer_inject) to fe_utils. This allows the code to be used by other frontend applications. Amul Sul, reviewed by Sravan Kumar, Andres Freund (whose input I specifically solicited regarding the meson.build changes), and me. Discussion: http://postgr.es/m/CAAJ_b94StvLWrc_p4q-f7n3OPfr6GhL8_XuAg2aAaYZp1tF-nw@mail.gmail.com --- meson.build | 2 +- src/bin/pg_basebackup/Makefile | 7 +------ src/bin/pg_basebackup/astreamer_inject.h | 2 +- src/bin/pg_basebackup/meson.build | 5 ----- src/fe_utils/Makefile | 5 +++++ src/{bin/pg_basebackup => fe_utils}/astreamer_file.c | 2 +- src/{bin/pg_basebackup => fe_utils}/astreamer_gzip.c | 2 +- src/{bin/pg_basebackup => fe_utils}/astreamer_lz4.c | 2 +- src/{bin/pg_basebackup => fe_utils}/astreamer_tar.c | 2 +- src/{bin/pg_basebackup => fe_utils}/astreamer_zstd.c | 2 +- src/fe_utils/meson.build | 5 +++++ src/{bin/pg_basebackup => include/fe_utils}/astreamer.h | 0 12 files changed, 18 insertions(+), 18 deletions(-) rename src/{bin/pg_basebackup => fe_utils}/astreamer_file.c (99%) rename src/{bin/pg_basebackup => fe_utils}/astreamer_gzip.c (99%) rename src/{bin/pg_basebackup => fe_utils}/astreamer_lz4.c (99%) rename src/{bin/pg_basebackup => fe_utils}/astreamer_tar.c (99%) rename src/{bin/pg_basebackup => fe_utils}/astreamer_zstd.c (99%) rename src/{bin/pg_basebackup => include/fe_utils}/astreamer.h (100%) diff --git a/meson.build b/meson.build index 21e7134d863..cc176f11b5d 100644 --- a/meson.build +++ b/meson.build @@ -3037,7 +3037,7 @@ frontend_common_code = declare_dependency( compile_args: ['-DFRONTEND'], include_directories: [postgres_inc], sources: generated_headers, - dependencies: [os_deps, zlib, zstd], + dependencies: [os_deps, zlib, zstd, lz4], ) backend_common_code = declare_dependency( diff --git a/src/bin/pg_basebackup/Makefile b/src/bin/pg_basebackup/Makefile index a71af2d48a7..f1e73058b23 100644 --- a/src/bin/pg_basebackup/Makefile +++ b/src/bin/pg_basebackup/Makefile @@ -37,12 +37,7 @@ OBJS = \ BBOBJS = \ pg_basebackup.o \ - astreamer_file.o \ - astreamer_gzip.o \ - astreamer_inject.o \ - astreamer_lz4.o \ - astreamer_tar.o \ - astreamer_zstd.o + astreamer_inject.o all: pg_basebackup pg_createsubscriber pg_receivewal pg_recvlogical diff --git a/src/bin/pg_basebackup/astreamer_inject.h b/src/bin/pg_basebackup/astreamer_inject.h index 8504b3f5e0d..aeed533862b 100644 --- a/src/bin/pg_basebackup/astreamer_inject.h +++ b/src/bin/pg_basebackup/astreamer_inject.h @@ -12,7 +12,7 @@ #ifndef ASTREAMER_INJECT_H #define ASTREAMER_INJECT_H -#include "astreamer.h" +#include "fe_utils/astreamer.h" #include "pqexpbuffer.h" extern astreamer *astreamer_recovery_injector_new(astreamer *next, diff --git a/src/bin/pg_basebackup/meson.build b/src/bin/pg_basebackup/meson.build index a68dbd7837d..9101fc18438 100644 --- a/src/bin/pg_basebackup/meson.build +++ b/src/bin/pg_basebackup/meson.build @@ -1,12 +1,7 @@ # Copyright (c) 2022-2024, PostgreSQL Global Development Group common_sources = files( - 'astreamer_file.c', - 'astreamer_gzip.c', 'astreamer_inject.c', - 'astreamer_lz4.c', - 'astreamer_tar.c', - 'astreamer_zstd.c', 'receivelog.c', 'streamutil.c', 'walmethods.c', diff --git a/src/fe_utils/Makefile b/src/fe_utils/Makefile index 946c05258f0..2694be4b859 100644 --- a/src/fe_utils/Makefile +++ b/src/fe_utils/Makefile @@ -21,6 +21,11 @@ override CPPFLAGS := -DFRONTEND -I$(libpq_srcdir) $(CPPFLAGS) OBJS = \ archive.o \ + astreamer_file.o \ + astreamer_gzip.o \ + astreamer_lz4.o \ + astreamer_tar.o \ + astreamer_zstd.o \ cancel.o \ conditional.o \ connect_utils.o \ diff --git a/src/bin/pg_basebackup/astreamer_file.c b/src/fe_utils/astreamer_file.c similarity index 99% rename from src/bin/pg_basebackup/astreamer_file.c rename to src/fe_utils/astreamer_file.c index 2742385e103..13d1192c6e6 100644 --- a/src/bin/pg_basebackup/astreamer_file.c +++ b/src/fe_utils/astreamer_file.c @@ -13,10 +13,10 @@ #include -#include "astreamer.h" #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "fe_utils/astreamer.h" typedef struct astreamer_plain_writer { diff --git a/src/bin/pg_basebackup/astreamer_gzip.c b/src/fe_utils/astreamer_gzip.c similarity index 99% rename from src/bin/pg_basebackup/astreamer_gzip.c rename to src/fe_utils/astreamer_gzip.c index 6f7c27afbbc..dd28defac7b 100644 --- a/src/bin/pg_basebackup/astreamer_gzip.c +++ b/src/fe_utils/astreamer_gzip.c @@ -17,10 +17,10 @@ #include #endif -#include "astreamer.h" #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "fe_utils/astreamer.h" #ifdef HAVE_LIBZ typedef struct astreamer_gzip_writer diff --git a/src/bin/pg_basebackup/astreamer_lz4.c b/src/fe_utils/astreamer_lz4.c similarity index 99% rename from src/bin/pg_basebackup/astreamer_lz4.c rename to src/fe_utils/astreamer_lz4.c index 1c40d7d8ad5..d8b2a367e47 100644 --- a/src/bin/pg_basebackup/astreamer_lz4.c +++ b/src/fe_utils/astreamer_lz4.c @@ -17,10 +17,10 @@ #include #endif -#include "astreamer.h" #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "fe_utils/astreamer.h" #ifdef USE_LZ4 typedef struct astreamer_lz4_frame diff --git a/src/bin/pg_basebackup/astreamer_tar.c b/src/fe_utils/astreamer_tar.c similarity index 99% rename from src/bin/pg_basebackup/astreamer_tar.c rename to src/fe_utils/astreamer_tar.c index 673690cd18f..f5d3562d280 100644 --- a/src/bin/pg_basebackup/astreamer_tar.c +++ b/src/fe_utils/astreamer_tar.c @@ -23,8 +23,8 @@ #include -#include "astreamer.h" #include "common/logging.h" +#include "fe_utils/astreamer.h" #include "pgtar.h" typedef struct astreamer_tar_parser diff --git a/src/bin/pg_basebackup/astreamer_zstd.c b/src/fe_utils/astreamer_zstd.c similarity index 99% rename from src/bin/pg_basebackup/astreamer_zstd.c rename to src/fe_utils/astreamer_zstd.c index 58dc679ef99..45f6cb67363 100644 --- a/src/bin/pg_basebackup/astreamer_zstd.c +++ b/src/fe_utils/astreamer_zstd.c @@ -17,8 +17,8 @@ #include #endif -#include "astreamer.h" #include "common/logging.h" +#include "fe_utils/astreamer.h" #ifdef USE_ZSTD diff --git a/src/fe_utils/meson.build b/src/fe_utils/meson.build index 14d0482a2cc..043021d826d 100644 --- a/src/fe_utils/meson.build +++ b/src/fe_utils/meson.build @@ -2,6 +2,11 @@ fe_utils_sources = files( 'archive.c', + 'astreamer_file.c', + 'astreamer_gzip.c', + 'astreamer_lz4.c', + 'astreamer_tar.c', + 'astreamer_zstd.c', 'cancel.c', 'conditional.c', 'connect_utils.c', diff --git a/src/bin/pg_basebackup/astreamer.h b/src/include/fe_utils/astreamer.h similarity index 100% rename from src/bin/pg_basebackup/astreamer.h rename to src/include/fe_utils/astreamer.h