From b34e3ecffa493b8037416805106c931105d9a9a3 Mon Sep 17 00:00:00 2001 From: Amul Sul Date: Tue, 9 Jul 2024 10:30:31 +0530 Subject: [PATCH v2 03/10] Refactor: move astreamer* files to fe_utils to make common availability of it. To make it accessible to other code, we need to move the ASTREAMER code (previously known as BBSTREAMER) to a common location. The appropriate place would be src/fe_utils, as it is a frontend infrastructure intended for shared use. --- 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 | 11 +++++++++-- 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 | 7 ++++++- .../pg_basebackup => include/fe_utils}/astreamer.h | 0 11 files changed, 22 insertions(+), 20 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/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..ff002f37d57 100644 --- a/src/fe_utils/Makefile +++ b/src/fe_utils/Makefile @@ -34,13 +34,20 @@ OBJS = \ simple_list.o \ string_utils.o +AOBJS = \ + astreamer_file.o \ + astreamer_gzip.o \ + astreamer_lz4.o \ + astreamer_tar.o \ + astreamer_zstd.o + ifeq ($(PORTNAME), win32) override CPPFLAGS += -DFD_SETSIZE=1024 endif all: libpgfeutils.a -libpgfeutils.a: $(OBJS) +libpgfeutils.a: $(AOBJS) $(OBJS) rm -f $@ $(AR) $(AROPT) $@ $^ @@ -59,5 +66,5 @@ uninstall: rm -f '$(DESTDIR)$(libdir)/libpgfeutils.a' clean distclean: - rm -f libpgfeutils.a $(OBJS) lex.backup + rm -f libpgfeutils.a $(AOBJS) $(OBJS) lex.backup rm -f psqlscan.c 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..0ec28e86af7 100644 --- a/src/fe_utils/meson.build +++ b/src/fe_utils/meson.build @@ -13,6 +13,11 @@ fe_utils_sources = files( 'recovery_gen.c', 'simple_list.c', 'string_utils.c', + 'astreamer_file.c', + 'astreamer_gzip.c', + 'astreamer_lz4.c', + 'astreamer_tar.c', + 'astreamer_zstd.c', ) psqlscan = custom_target('psqlscan', @@ -28,6 +33,6 @@ fe_utils = static_library('libpgfeutils', c_pch: pch_postgres_fe_h, include_directories: [postgres_inc, libpq_inc], c_args: host_system == 'windows' ? ['-DFD_SETSIZE=1024'] : [], - dependencies: frontend_common_code, + dependencies: [frontend_common_code, lz4, zlib, zstd], kwargs: default_lib_args, ) 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 -- 2.18.0