diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c index 09b59c8324..5abc64f5f7 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -65,9 +65,9 @@ #include "catalog/pg_collation_d.h" #include "common/file_perm.h" #include "common/file_utils.h" +#include "common/logging.h" #include "common/restricted_token.h" #include "common/username.h" -#include "fe_utils/logging.h" #include "fe_utils/string_utils.h" #include "getaddrinfo.h" #include "getopt_long.h" diff --git a/src/bin/pg_archivecleanup/Makefile b/src/bin/pg_archivecleanup/Makefile index 14e834677b..c5bf99db0f 100644 --- a/src/bin/pg_archivecleanup/Makefile +++ b/src/bin/pg_archivecleanup/Makefile @@ -7,13 +7,11 @@ subdir = src/bin/pg_archivecleanup top_builddir = ../../.. include $(top_builddir)/src/Makefile.global -LDFLAGS_INTERNAL += -L$(top_builddir)/src/fe_utils -lpgfeutils - OBJS = pg_archivecleanup.o $(WIN32RES) all: pg_archivecleanup -pg_archivecleanup: $(OBJS) | submake-libpgport submake-libpgfeutils +pg_archivecleanup: $(OBJS) | submake-libpgport $(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X) install: all installdirs diff --git a/src/bin/pg_archivecleanup/pg_archivecleanup.c b/src/bin/pg_archivecleanup/pg_archivecleanup.c index b297f210df..8f89be64cd 100644 --- a/src/bin/pg_archivecleanup/pg_archivecleanup.c +++ b/src/bin/pg_archivecleanup/pg_archivecleanup.c @@ -17,7 +17,7 @@ #include "pg_getopt.h" -#include "fe_utils/logging.h" +#include "common/logging.h" #include "access/xlog_internal.h" diff --git a/src/bin/pg_basebackup/pg_basebackup.c b/src/bin/pg_basebackup/pg_basebackup.c index 1a735b8046..74d7c85664 100644 --- a/src/bin/pg_basebackup/pg_basebackup.c +++ b/src/bin/pg_basebackup/pg_basebackup.c @@ -29,8 +29,8 @@ #include "access/xlog_internal.h" #include "common/file_perm.h" #include "common/file_utils.h" +#include "common/logging.h" #include "common/string.h" -#include "fe_utils/logging.h" #include "fe_utils/string_utils.h" #include "getopt_long.h" #include "libpq-fe.h" diff --git a/src/bin/pg_basebackup/pg_receivewal.c b/src/bin/pg_basebackup/pg_receivewal.c index 9e4d296129..5301e88375 100644 --- a/src/bin/pg_basebackup/pg_receivewal.c +++ b/src/bin/pg_basebackup/pg_receivewal.c @@ -20,7 +20,7 @@ #include #include "common/file_perm.h" -#include "fe_utils/logging.h" +#include "common/logging.h" #include "libpq-fe.h" #include "access/xlog_internal.h" #include "getopt_long.h" diff --git a/src/bin/pg_basebackup/pg_recvlogical.c b/src/bin/pg_basebackup/pg_recvlogical.c index 3c95f231a2..547eb8de86 100644 --- a/src/bin/pg_basebackup/pg_recvlogical.c +++ b/src/bin/pg_basebackup/pg_recvlogical.c @@ -25,7 +25,7 @@ #include "access/xlog_internal.h" #include "common/file_perm.h" #include "common/fe_memutils.h" -#include "fe_utils/logging.h" +#include "common/logging.h" #include "getopt_long.h" #include "libpq-fe.h" #include "libpq/pqsignal.h" diff --git a/src/bin/pg_basebackup/receivelog.c b/src/bin/pg_basebackup/receivelog.c index 0ff9aa19a9..e9854527e2 100644 --- a/src/bin/pg_basebackup/receivelog.c +++ b/src/bin/pg_basebackup/receivelog.c @@ -27,7 +27,7 @@ #include "libpq-fe.h" #include "access/xlog_internal.h" #include "common/file_utils.h" -#include "fe_utils/logging.h" +#include "common/logging.h" /* fd and filename for currently open WAL file */ diff --git a/src/bin/pg_basebackup/streamutil.c b/src/bin/pg_basebackup/streamutil.c index ab2e55d695..79f17e4089 100644 --- a/src/bin/pg_basebackup/streamutil.c +++ b/src/bin/pg_basebackup/streamutil.c @@ -24,9 +24,9 @@ #include "access/xlog_internal.h" #include "common/fe_memutils.h" #include "common/file_perm.h" +#include "common/logging.h" #include "datatype/timestamp.h" #include "fe_utils/connect.h" -#include "fe_utils/logging.h" #include "port/pg_bswap.h" #include "pqexpbuffer.h" diff --git a/src/bin/pg_checksums/Makefile b/src/bin/pg_checksums/Makefile index 13a25f5e33..278b7a0f2e 100644 --- a/src/bin/pg_checksums/Makefile +++ b/src/bin/pg_checksums/Makefile @@ -15,13 +15,11 @@ subdir = src/bin/pg_checksums top_builddir = ../../.. include $(top_builddir)/src/Makefile.global -LDFLAGS_INTERNAL += -L$(top_builddir)/src/fe_utils -lpgfeutils - OBJS= pg_checksums.o $(WIN32RES) all: pg_checksums -pg_checksums: $(OBJS) | submake-libpgport submake-libpgfeutils +pg_checksums: $(OBJS) | submake-libpgport $(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X) install: all installdirs diff --git a/src/bin/pg_checksums/pg_checksums.c b/src/bin/pg_checksums/pg_checksums.c index 768d038d79..37fe20bb75 100644 --- a/src/bin/pg_checksums/pg_checksums.c +++ b/src/bin/pg_checksums/pg_checksums.c @@ -23,7 +23,7 @@ #include "common/controldata_utils.h" #include "common/file_perm.h" #include "common/file_utils.h" -#include "fe_utils/logging.h" +#include "common/logging.h" #include "getopt_long.h" #include "pg_getopt.h" #include "storage/bufpage.h" diff --git a/src/bin/pg_controldata/Makefile b/src/bin/pg_controldata/Makefile index 4d9c1370fe..2d5c562131 100644 --- a/src/bin/pg_controldata/Makefile +++ b/src/bin/pg_controldata/Makefile @@ -15,13 +15,11 @@ subdir = src/bin/pg_controldata top_builddir = ../../.. include $(top_builddir)/src/Makefile.global -LDFLAGS_INTERNAL += -L$(top_builddir)/src/fe_utils -lpgfeutils - OBJS= pg_controldata.o $(WIN32RES) all: pg_controldata -pg_controldata: $(OBJS) | submake-libpgport submake-libpgfeutils +pg_controldata: $(OBJS) | submake-libpgport $(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X) install: all installdirs diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c index a674f52f0b..d955b97c0b 100644 --- a/src/bin/pg_controldata/pg_controldata.c +++ b/src/bin/pg_controldata/pg_controldata.c @@ -25,7 +25,7 @@ #include "access/xlog_internal.h" #include "catalog/pg_control.h" #include "common/controldata_utils.h" -#include "fe_utils/logging.h" +#include "common/logging.h" #include "pg_getopt.h" #include "getopt_long.h" diff --git a/src/bin/pg_ctl/Makefile b/src/bin/pg_ctl/Makefile index b931b14a3f..83cbf97ed8 100644 --- a/src/bin/pg_ctl/Makefile +++ b/src/bin/pg_ctl/Makefile @@ -16,8 +16,6 @@ subdir = src/bin/pg_ctl top_builddir = ../../.. include $(top_builddir)/src/Makefile.global -LDFLAGS_INTERNAL += -L$(top_builddir)/src/fe_utils -lpgfeutils - # On Windows, we need to link with libpq, just for use of pqexpbuffer; # but let's not pull that in on platforms where we don't need it. ifeq ($(PORTNAME), win32) @@ -30,7 +28,7 @@ OBJS= pg_ctl.o $(WIN32RES) all: pg_ctl -pg_ctl: $(OBJS) | submake-libpgport submake-libpgfeutils $(SUBMAKE_LIBPQ) +pg_ctl: $(OBJS) | submake-libpgport $(SUBMAKE_LIBPQ) $(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X) install: all installdirs diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 400763dea7..dfb6c19f5a 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,7 +26,7 @@ #include "catalog/pg_control.h" #include "common/controldata_utils.h" #include "common/file_perm.h" -#include "fe_utils/logging.h" +#include "common/logging.h" #include "getopt_long.h" #include "utils/pidfile.h" diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 5958f42a84..b402e49896 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -22,7 +22,6 @@ #include #include "catalog/pg_class_d.h" -#include "fe_utils/logging.h" #include "fe_utils/string_utils.h" diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c index 821fb4def0..d764d36936 100644 --- a/src/bin/pg_dump/pg_backup_archiver.c +++ b/src/bin/pg_dump/pg_backup_archiver.c @@ -35,7 +35,6 @@ #include "pg_backup_db.h" #include "pg_backup_utils.h" #include "dumputils.h" -#include "fe_utils/logging.h" #include "fe_utils/string_utils.h" #include "libpq/libpq-fs.h" diff --git a/src/bin/pg_dump/pg_backup_custom.c b/src/bin/pg_dump/pg_backup_custom.c index 5641d5d20f..ae5306b9da 100644 --- a/src/bin/pg_dump/pg_backup_custom.c +++ b/src/bin/pg_dump/pg_backup_custom.c @@ -29,7 +29,7 @@ #include "parallel.h" #include "pg_backup_utils.h" #include "common/file_utils.h" -#include "fe_utils/logging.h" + /*-------- * Routines in the format interface diff --git a/src/bin/pg_dump/pg_backup_db.c b/src/bin/pg_dump/pg_backup_db.c index 1d636dac19..9fd3b8a79f 100644 --- a/src/bin/pg_dump/pg_backup_db.c +++ b/src/bin/pg_dump/pg_backup_db.c @@ -11,10 +11,10 @@ */ #include "postgres_fe.h" -#include "dumputils.h" #include "fe_utils/connect.h" -#include "fe_utils/logging.h" #include "fe_utils/string_utils.h" + +#include "dumputils.h" #include "parallel.h" #include "pg_backup_archiver.h" #include "pg_backup_db.h" diff --git a/src/bin/pg_dump/pg_backup_utils.h b/src/bin/pg_dump/pg_backup_utils.h index c47c19af6c..619c9fe08c 100644 --- a/src/bin/pg_dump/pg_backup_utils.h +++ b/src/bin/pg_dump/pg_backup_utils.h @@ -15,7 +15,7 @@ #ifndef PG_BACKUP_UTILS_H #define PG_BACKUP_UTILS_H -#include "fe_utils/logging.h" +#include "common/logging.h" typedef enum /* bits returned by set_dump_section */ { diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 8b993d6eae..a8f1ad7333 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -63,7 +63,6 @@ #include "pg_backup_utils.h" #include "pg_dump.h" #include "fe_utils/connect.h" -#include "fe_utils/logging.h" #include "fe_utils/string_utils.h" diff --git a/src/bin/pg_dump/pg_dump_sort.c b/src/bin/pg_dump/pg_dump_sort.c index 80641cd79a..90ec67ca67 100644 --- a/src/bin/pg_dump/pg_dump_sort.c +++ b/src/bin/pg_dump/pg_dump_sort.c @@ -20,7 +20,6 @@ #include "pg_dump.h" #include "catalog/pg_class_d.h" -#include "fe_utils/logging.h" /* * Sort priority for database object types. diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c index 3244a527f6..102731ea0c 100644 --- a/src/bin/pg_dump/pg_dumpall.c +++ b/src/bin/pg_dump/pg_dumpall.c @@ -23,8 +23,8 @@ #include "dumputils.h" #include "pg_backup.h" #include "common/file_utils.h" +#include "common/logging.h" #include "fe_utils/connect.h" -#include "fe_utils/logging.h" #include "fe_utils/string_utils.h" /* version string we expect back from pg_dump */ diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.c index 9a5b17758f..8a3fad3d16 100644 --- a/src/bin/pg_dump/pg_restore.c +++ b/src/bin/pg_dump/pg_restore.c @@ -51,8 +51,6 @@ #include "parallel.h" #include "pg_backup_utils.h" -#include "fe_utils/logging.h" - static void usage(const char *progname); diff --git a/src/bin/pg_resetwal/Makefile b/src/bin/pg_resetwal/Makefile index 09ede1efd2..2a3835691f 100644 --- a/src/bin/pg_resetwal/Makefile +++ b/src/bin/pg_resetwal/Makefile @@ -15,13 +15,11 @@ subdir = src/bin/pg_resetwal top_builddir = ../../.. include $(top_builddir)/src/Makefile.global -LDFLAGS_INTERNAL += -L$(top_builddir)/src/fe_utils -lpgfeutils - OBJS= pg_resetwal.o $(WIN32RES) all: pg_resetwal -pg_resetwal: $(OBJS) | submake-libpgport submake-libpgfeutils +pg_resetwal: $(OBJS) | submake-libpgport $(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X) install: all installdirs diff --git a/src/bin/pg_resetwal/pg_resetwal.c b/src/bin/pg_resetwal/pg_resetwal.c index 82a8ec993d..2734f87318 100644 --- a/src/bin/pg_resetwal/pg_resetwal.c +++ b/src/bin/pg_resetwal/pg_resetwal.c @@ -52,8 +52,8 @@ #include "common/controldata_utils.h" #include "common/fe_memutils.h" #include "common/file_perm.h" +#include "common/logging.h" #include "common/restricted_token.h" -#include "fe_utils/logging.h" #include "storage/large_object.h" #include "pg_getopt.h" #include "getopt_long.h" diff --git a/src/bin/pg_rewind/Makefile b/src/bin/pg_rewind/Makefile index 5455fd4e29..859d3abc41 100644 --- a/src/bin/pg_rewind/Makefile +++ b/src/bin/pg_rewind/Makefile @@ -16,7 +16,7 @@ top_builddir = ../../.. include $(top_builddir)/src/Makefile.global override CPPFLAGS := -I$(libpq_srcdir) -DFRONTEND $(CPPFLAGS) -LDFLAGS_INTERNAL += -L$(top_builddir)/src/fe_utils -lpgfeutils $(libpq_pgport) +LDFLAGS_INTERNAL += $(libpq_pgport) OBJS = pg_rewind.o parsexlog.o xlogreader.o datapagemap.o timeline.o \ fetch.o file_ops.o copy_fetch.o libpq_fetch.o filemap.o \ @@ -26,7 +26,7 @@ EXTRA_CLEAN = xlogreader.c all: pg_rewind -pg_rewind: $(OBJS) | submake-libpq submake-libpgport submake-libpgfeutils +pg_rewind: $(OBJS) | submake-libpq submake-libpgport $(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X) xlogreader.c: % : $(top_srcdir)/src/backend/access/transam/% diff --git a/src/bin/pg_rewind/datapagemap.c b/src/bin/pg_rewind/datapagemap.c index fc70fe5706..93165f697c 100644 --- a/src/bin/pg_rewind/datapagemap.c +++ b/src/bin/pg_rewind/datapagemap.c @@ -14,7 +14,7 @@ #include "datapagemap.h" -#include "fe_utils/logging.h" +#include "common/logging.h" struct datapagemap_iterator { diff --git a/src/bin/pg_rewind/pg_rewind.h b/src/bin/pg_rewind/pg_rewind.h index 9e6f9474d5..a54a5d7fd4 100644 --- a/src/bin/pg_rewind/pg_rewind.h +++ b/src/bin/pg_rewind/pg_rewind.h @@ -17,7 +17,7 @@ #include "storage/block.h" #include "storage/relfilenode.h" -#include "fe_utils/logging.h" +#include "common/logging.h" /* Configuration options */ extern char *datadir_target; diff --git a/src/bin/pg_test_fsync/Makefile b/src/bin/pg_test_fsync/Makefile index 769daecf2b..90496df566 100644 --- a/src/bin/pg_test_fsync/Makefile +++ b/src/bin/pg_test_fsync/Makefile @@ -7,13 +7,11 @@ subdir = src/bin/pg_test_fsync top_builddir = ../../.. include $(top_builddir)/src/Makefile.global -LDFLAGS_INTERNAL += -L$(top_builddir)/src/fe_utils -lpgfeutils - OBJS = pg_test_fsync.o $(WIN32RES) all: pg_test_fsync -pg_test_fsync: $(OBJS) | submake-libpgport submake-libpgfeutils +pg_test_fsync: $(OBJS) | submake-libpgport $(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X) install: all installdirs diff --git a/src/bin/pg_test_fsync/pg_test_fsync.c b/src/bin/pg_test_fsync/pg_test_fsync.c index 83771061a4..225557e6c5 100644 --- a/src/bin/pg_test_fsync/pg_test_fsync.c +++ b/src/bin/pg_test_fsync/pg_test_fsync.c @@ -14,7 +14,7 @@ #include "getopt_long.h" #include "access/xlogdefs.h" -#include "fe_utils/logging.h" +#include "common/logging.h" /* diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c index 0b304bbd56..ff78929707 100644 --- a/src/bin/pg_upgrade/pg_upgrade.c +++ b/src/bin/pg_upgrade/pg_upgrade.c @@ -40,8 +40,8 @@ #include "pg_upgrade.h" #include "catalog/pg_class_d.h" #include "common/file_perm.h" +#include "common/logging.h" #include "common/restricted_token.h" -#include "fe_utils/logging.h" #include "fe_utils/string_utils.h" #ifdef HAVE_LANGINFO_H diff --git a/src/bin/pg_waldump/Makefile b/src/bin/pg_waldump/Makefile index bfe9498b80..f5957bd75a 100644 --- a/src/bin/pg_waldump/Makefile +++ b/src/bin/pg_waldump/Makefile @@ -11,7 +11,6 @@ OBJS = pg_waldump.o compat.o xlogreader.o rmgrdesc.o \ $(RMGRDESCOBJS) $(WIN32RES) override CPPFLAGS := -DFRONTEND $(CPPFLAGS) -LDFLAGS_INTERNAL += -L$(top_builddir)/src/fe_utils -lpgfeutils RMGRDESCSOURCES = $(sort $(notdir $(wildcard $(top_srcdir)/src/backend/access/rmgrdesc/*desc.c))) RMGRDESCOBJS = $(patsubst %.c,%.o,$(RMGRDESCSOURCES)) @@ -19,7 +18,7 @@ RMGRDESCOBJS = $(patsubst %.c,%.o,$(RMGRDESCSOURCES)) all: pg_waldump -pg_waldump: $(OBJS) | submake-libpgport submake-libpgfeutils +pg_waldump: $(OBJS) | submake-libpgport $(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X) xlogreader.c: % : $(top_srcdir)/src/backend/access/transam/% diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c index f61505ade3..dab9525c68 100644 --- a/src/bin/pg_waldump/pg_waldump.c +++ b/src/bin/pg_waldump/pg_waldump.c @@ -21,7 +21,7 @@ #include "access/xlog_internal.h" #include "access/transam.h" #include "common/fe_memutils.h" -#include "fe_utils/logging.h" +#include "common/logging.h" #include "getopt_long.h" #include "rmgrdesc.h" diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c index a03ab281a5..a81383eb57 100644 --- a/src/bin/pgbench/pgbench.c +++ b/src/bin/pgbench/pgbench.c @@ -33,8 +33,8 @@ #include "postgres_fe.h" #include "common/int.h" +#include "common/logging.h" #include "fe_utils/conditional.h" -#include "fe_utils/logging.h" #include "getopt_long.h" #include "libpq-fe.h" #include "portability/instr_time.h" diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 8254d61099..a2c0ec0b7f 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -28,7 +28,8 @@ #include "libpq-fe.h" #include "pqexpbuffer.h" -#include "fe_utils/logging.h" +#include "common/logging.h" +#include "fe_utils/print.h" #include "fe_utils/string_utils.h" #include "common.h" @@ -39,7 +40,6 @@ #include "input.h" #include "large_obj.h" #include "mainloop.h" -#include "fe_utils/print.h" #include "psqlscanslash.h" #include "settings.h" #include "variables.h" diff --git a/src/bin/psql/common.c b/src/bin/psql/common.c index bd284446f8..9579e10630 100644 --- a/src/bin/psql/common.c +++ b/src/bin/psql/common.c @@ -6,7 +6,6 @@ * src/bin/psql/common.c */ #include "postgres_fe.h" -#include "common.h" #include #include @@ -19,15 +18,16 @@ #include #endif -#include "fe_utils/logging.h" +#include "common/logging.h" +#include "fe_utils/mbprint.h" #include "fe_utils/string_utils.h" #include "portability/instr_time.h" -#include "settings.h" #include "command.h" +#include "common.h" #include "copy.h" #include "crosstabview.h" -#include "fe_utils/mbprint.h" +#include "settings.h" static bool DescribeQuery(const char *query, double *elapsed_msec); diff --git a/src/bin/psql/copy.c b/src/bin/psql/copy.c index def177693e..b02177a5c2 100644 --- a/src/bin/psql/copy.c +++ b/src/bin/psql/copy.c @@ -24,7 +24,7 @@ #include "prompt.h" #include "stringutils.h" -#include "fe_utils/logging.h" +#include "common/logging.h" /* * parse_slash_copy diff --git a/src/bin/psql/crosstabview.c b/src/bin/psql/crosstabview.c index 6afd3e0939..390f750c41 100644 --- a/src/bin/psql/crosstabview.c +++ b/src/bin/psql/crosstabview.c @@ -13,7 +13,7 @@ #include "psqlscanslash.h" #include "settings.h" -#include "fe_utils/logging.h" +#include "common/logging.h" /* * Value/position from the resultset that goes into the horizontal or vertical diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index ee00c5da08..773107227d 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -18,13 +18,14 @@ #include "catalog/pg_cast_d.h" #include "catalog/pg_class_d.h" #include "catalog/pg_default_acl_d.h" -#include "fe_utils/logging.h" + +#include "common/logging.h" +#include "fe_utils/mbprint.h" +#include "fe_utils/print.h" #include "fe_utils/string_utils.h" #include "common.h" #include "describe.h" -#include "fe_utils/mbprint.h" -#include "fe_utils/print.h" #include "settings.h" #include "variables.h" diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c index d6d41b51d5..5fb1baadc5 100644 --- a/src/bin/psql/help.c +++ b/src/bin/psql/help.c @@ -21,15 +21,15 @@ #include #endif -#include "common.h" +#include "common/logging.h" #include "common/username.h" + +#include "common.h" #include "help.h" #include "input.h" #include "settings.h" #include "sql_help.h" -#include "fe_utils/logging.h" - /* * PLEASE: * If you change something in this file, also make the same changes diff --git a/src/bin/psql/input.c b/src/bin/psql/input.c index 93c0d4c49e..5a18ac9bbc 100644 --- a/src/bin/psql/input.c +++ b/src/bin/psql/input.c @@ -18,7 +18,7 @@ #include "tab-complete.h" #include "common.h" -#include "fe_utils/logging.h" +#include "common/logging.h" #ifndef WIN32 #define PSQLHISTORY ".psql_history" diff --git a/src/bin/psql/large_obj.c b/src/bin/psql/large_obj.c index cecb4897f5..2713f15d4f 100644 --- a/src/bin/psql/large_obj.c +++ b/src/bin/psql/large_obj.c @@ -11,7 +11,7 @@ #include "settings.h" #include "common.h" -#include "fe_utils/logging.h" +#include "common/logging.h" static void print_lo_result(const char *fmt,...) pg_attribute_printf(1, 2); diff --git a/src/bin/psql/mainloop.c b/src/bin/psql/mainloop.c index 3ae447041f..e386d9888d 100644 --- a/src/bin/psql/mainloop.c +++ b/src/bin/psql/mainloop.c @@ -14,7 +14,7 @@ #include "prompt.h" #include "settings.h" -#include "fe_utils/logging.h" +#include "common/logging.h" #include "mb/pg_wchar.h" diff --git a/src/bin/psql/psqlscanslash.l b/src/bin/psql/psqlscanslash.l index f7818e6e60..c2e3bfe9d0 100644 --- a/src/bin/psql/psqlscanslash.l +++ b/src/bin/psql/psqlscanslash.l @@ -19,8 +19,8 @@ #include "postgres_fe.h" #include "psqlscanslash.h" +#include "common/logging.h" #include "fe_utils/conditional.h" -#include "fe_utils/logging.h" #include "libpq-fe.h" } diff --git a/src/bin/psql/startup.c b/src/bin/psql/startup.c index 855133bbcb..7c5b45f7cc 100644 --- a/src/bin/psql/startup.c +++ b/src/bin/psql/startup.c @@ -16,14 +16,15 @@ #include "getopt_long.h" +#include "common/logging.h" +#include "fe_utils/print.h" + #include "command.h" #include "common.h" #include "describe.h" #include "help.h" #include "input.h" #include "mainloop.h" -#include "fe_utils/logging.h" -#include "fe_utils/print.h" #include "settings.h" diff --git a/src/bin/psql/variables.c b/src/bin/psql/variables.c index 5d47d5a8ab..e456b9db2f 100644 --- a/src/bin/psql/variables.c +++ b/src/bin/psql/variables.c @@ -10,7 +10,7 @@ #include "common.h" #include "variables.h" -#include "fe_utils/logging.h" +#include "common/logging.h" /* diff --git a/src/bin/scripts/clusterdb.c b/src/bin/scripts/clusterdb.c index dd0ba68864..a1b4119efa 100644 --- a/src/bin/scripts/clusterdb.c +++ b/src/bin/scripts/clusterdb.c @@ -11,7 +11,7 @@ #include "postgres_fe.h" #include "common.h" -#include "fe_utils/logging.h" +#include "common/logging.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" diff --git a/src/bin/scripts/common.c b/src/bin/scripts/common.c index a42afd490b..296029d809 100644 --- a/src/bin/scripts/common.c +++ b/src/bin/scripts/common.c @@ -18,8 +18,8 @@ #include #include "common.h" +#include "common/logging.h" #include "fe_utils/connect.h" -#include "fe_utils/logging.h" #include "fe_utils/string_utils.h" diff --git a/src/bin/scripts/createdb.c b/src/bin/scripts/createdb.c index e4b497859b..64bcc20cb4 100644 --- a/src/bin/scripts/createdb.c +++ b/src/bin/scripts/createdb.c @@ -12,7 +12,7 @@ #include "postgres_fe.h" #include "common.h" -#include "fe_utils/logging.h" +#include "common/logging.h" #include "fe_utils/string_utils.h" diff --git a/src/bin/scripts/createuser.c b/src/bin/scripts/createuser.c index 6db0dbf2a3..973ba525b2 100644 --- a/src/bin/scripts/createuser.c +++ b/src/bin/scripts/createuser.c @@ -12,7 +12,7 @@ #include "postgres_fe.h" #include "common.h" -#include "fe_utils/logging.h" +#include "common/logging.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" diff --git a/src/bin/scripts/dropdb.c b/src/bin/scripts/dropdb.c index 42a9bd4686..dacd8e5f1d 100644 --- a/src/bin/scripts/dropdb.c +++ b/src/bin/scripts/dropdb.c @@ -12,7 +12,7 @@ #include "postgres_fe.h" #include "common.h" -#include "fe_utils/logging.h" +#include "common/logging.h" #include "fe_utils/string_utils.h" diff --git a/src/bin/scripts/dropuser.c b/src/bin/scripts/dropuser.c index 831243815a..3501a06ecb 100644 --- a/src/bin/scripts/dropuser.c +++ b/src/bin/scripts/dropuser.c @@ -12,7 +12,7 @@ #include "postgres_fe.h" #include "common.h" -#include "fe_utils/logging.h" +#include "common/logging.h" #include "fe_utils/string_utils.h" diff --git a/src/bin/scripts/pg_isready.c b/src/bin/scripts/pg_isready.c index fe15507caf..079447f951 100644 --- a/src/bin/scripts/pg_isready.c +++ b/src/bin/scripts/pg_isready.c @@ -11,7 +11,7 @@ #include "postgres_fe.h" #include "common.h" -#include "fe_utils/logging.h" +#include "common/logging.h" #define DEFAULT_CONNECT_TIMEOUT "3" diff --git a/src/bin/scripts/reindexdb.c b/src/bin/scripts/reindexdb.c index 897ad9a71a..ba4d10e65c 100644 --- a/src/bin/scripts/reindexdb.c +++ b/src/bin/scripts/reindexdb.c @@ -11,7 +11,7 @@ #include "postgres_fe.h" #include "common.h" -#include "fe_utils/logging.h" +#include "common/logging.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" diff --git a/src/bin/scripts/vacuumdb.c b/src/bin/scripts/vacuumdb.c index e9da74c3ba..6d216aab6b 100644 --- a/src/bin/scripts/vacuumdb.c +++ b/src/bin/scripts/vacuumdb.c @@ -19,8 +19,8 @@ #include "catalog/pg_class_d.h" #include "common.h" +#include "common/logging.h" #include "fe_utils/connect.h" -#include "fe_utils/logging.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" diff --git a/src/common/Makefile b/src/common/Makefile index d84c7b6e6a..2f22b9b101 100644 --- a/src/common/Makefile +++ b/src/common/Makefile @@ -59,7 +59,9 @@ OBJS_COMMON += sha2.o endif # A few files are currently only built for frontend, not server -OBJS_FRONTEND = $(OBJS_COMMON) fe_memutils.o file_utils.o restricted_token.o +# (Mkvcbuild.pm has a copy of this list, too) +OBJS_FRONTEND = $(OBJS_COMMON) fe_memutils.o file_utils.o \ + logging.o restricted_token.o # foo.o, foo_shlib.o, and foo_srv.o are all built from foo.c OBJS_SHLIB = $(OBJS_FRONTEND:%.o=%_shlib.o) diff --git a/src/common/controldata_utils.c b/src/common/controldata_utils.c index efca14ba54..2c28e51e11 100644 --- a/src/common/controldata_utils.c +++ b/src/common/controldata_utils.c @@ -29,7 +29,7 @@ #include "common/controldata_utils.h" #include "common/file_perm.h" #ifdef FRONTEND -#include "fe_utils/logging.h" +#include "common/logging.h" #endif #include "port/pg_crc32c.h" diff --git a/src/common/file_utils.c b/src/common/file_utils.c index a43c82b4b4..eaec568819 100644 --- a/src/common/file_utils.c +++ b/src/common/file_utils.c @@ -20,7 +20,7 @@ #include #include "common/file_utils.h" -#include "fe_utils/logging.h" +#include "common/logging.h" /* Define PG_FLUSH_DATA_WORKS if we have an implementation for pg_flush_data */ diff --git a/src/fe_utils/logging.c b/src/common/logging.c similarity index 92% rename from src/fe_utils/logging.c rename to src/common/logging.c index 2f571ae3c9..59f60445c7 100644 --- a/src/fe_utils/logging.c +++ b/src/common/logging.c @@ -1,9 +1,9 @@ /*------------------------------------------------------------------------- * Logging framework for frontend programs * - * Copyright (c) 2018, PostgreSQL Global Development Group + * Copyright (c) 2018-2019, PostgreSQL Global Development Group * - * src/fe_utils/logging.c + * src/common/logging.c * *------------------------------------------------------------------------- */ @@ -11,14 +11,15 @@ #include -#include "fe_utils/logging.h" - -static const char *progname; +#include "common/logging.h" enum pg_log_level __pg_log_level; + +static const char *progname; static int log_flags; -void (*log_pre_callback)(void); -void (*log_locus_callback)(const char **, uint64 *); + +static void (*log_pre_callback)(void); +static void (*log_locus_callback)(const char **, uint64 *); static const char *sgr_error = NULL; static const char *sgr_warning = NULL; @@ -146,7 +147,12 @@ pg_log_generic_v(enum pg_log_level level, const char * pg_restrict fmt, va_list Assert(fmt); Assert(fmt[strlen(fmt) - 1] != '\n'); + /* + * Flush stdout before output to stderr, to ensure sync even when stdout + * is buffered. + */ fflush(stdout); + if (log_pre_callback) log_pre_callback(); @@ -220,9 +226,10 @@ pg_log_generic_v(enum pg_log_level level, const char * pg_restrict fmt, va_list vsnprintf(buf, required_len, fmt, ap); /* strip one newline, for PQerrorMessage() */ - if (buf[required_len - 2] == '\n') + if (required_len >= 2 && buf[required_len - 2] == '\n') buf[required_len - 2] = '\0'; fprintf(stderr, "%s\n", buf); + free(buf); } diff --git a/src/common/pgfnames.c b/src/common/pgfnames.c index 95b17e47d8..c99c482201 100644 --- a/src/common/pgfnames.c +++ b/src/common/pgfnames.c @@ -23,7 +23,7 @@ #ifndef FRONTEND #define pg_log_warning(...) elog(WARNING, __VA_ARGS__) #else -#include "fe_utils/logging.h" +#include "common/logging.h" #endif /* diff --git a/src/common/restricted_token.c b/src/common/restricted_token.c index 3f57ff8b40..dd077a6e0e 100644 --- a/src/common/restricted_token.c +++ b/src/common/restricted_token.c @@ -20,8 +20,8 @@ #include "postgres_fe.h" +#include "common/logging.h" #include "common/restricted_token.h" -#include "fe_utils/logging.h" #ifdef WIN32 diff --git a/src/common/rmtree.c b/src/common/rmtree.c index b31da3adff..2c3c4dd2d4 100644 --- a/src/common/rmtree.c +++ b/src/common/rmtree.c @@ -23,7 +23,7 @@ #ifndef FRONTEND #define pg_log_warning(...) elog(WARNING, __VA_ARGS__) #else -#include "fe_utils/logging.h" +#include "common/logging.h" #endif diff --git a/src/fe_utils/Makefile b/src/fe_utils/Makefile index 960ecf0b6a..7d73800323 100644 --- a/src/fe_utils/Makefile +++ b/src/fe_utils/Makefile @@ -19,7 +19,7 @@ include $(top_builddir)/src/Makefile.global override CPPFLAGS := -DFRONTEND -I$(libpq_srcdir) $(CPPFLAGS) -OBJS = logging.o mbprint.o print.o psqlscan.o simple_list.o string_utils.o conditional.o +OBJS = mbprint.o print.o psqlscan.o simple_list.o string_utils.o conditional.o all: libpgfeutils.a diff --git a/src/fe_utils/psqlscan.l b/src/fe_utils/psqlscan.l index 850754ea95..ce20936339 100644 --- a/src/fe_utils/psqlscan.l +++ b/src/fe_utils/psqlscan.l @@ -34,7 +34,7 @@ */ #include "postgres_fe.h" -#include "fe_utils/logging.h" +#include "common/logging.h" #include "fe_utils/psqlscan.h" #include "libpq-fe.h" diff --git a/src/include/fe_utils/logging.h b/src/include/common/logging.h similarity index 92% rename from src/include/fe_utils/logging.h rename to src/include/common/logging.h index b5f0ddc834..5a3249198a 100644 --- a/src/include/fe_utils/logging.h +++ b/src/include/common/logging.h @@ -1,14 +1,14 @@ /*------------------------------------------------------------------------- * Logging framework for frontend programs * - * Copyright (c) 2018, PostgreSQL Global Development Group + * Copyright (c) 2018-2019, PostgreSQL Global Development Group * - * src/include/fe_utils/logging.h + * src/include/common/logging.h * *------------------------------------------------------------------------- */ -#ifndef FE_UTILS_LOGGING_H -#define FE_UTILS_LOGGING_H +#ifndef COMMON_LOGGING_H +#define COMMON_LOGGING_H /* * Log levels are informational only. They do not affect program flow. @@ -92,4 +92,4 @@ void pg_log_generic_v(enum pg_log_level level, const char * pg_restrict fmt, va_ if (unlikely(__pg_log_level <= PG_LOG_DEBUG)) pg_log_generic(PG_LOG_DEBUG, __VA_ARGS__); \ } while(0) -#endif /* FE_UTILS_LOGGING_H */ +#endif /* COMMON_LOGGING_H */ diff --git a/src/interfaces/ecpg/test/Makefile b/src/interfaces/ecpg/test/Makefile index e6d6f80eef..be53b7b94d 100644 --- a/src/interfaces/ecpg/test/Makefile +++ b/src/interfaces/ecpg/test/Makefile @@ -15,8 +15,6 @@ override CPPFLAGS := \ '-DDLSUFFIX="$(DLSUFFIX)"' \ $(CPPFLAGS) -LDFLAGS_INTERNAL += -L$(top_builddir)/src/fe_utils -lpgfeutils - # default encoding for regression tests ENCODING = SQL_ASCII diff --git a/src/nls-global.mk b/src/nls-global.mk index 797e0dd683..5bb77b40eb 100644 --- a/src/nls-global.mk +++ b/src/nls-global.mk @@ -67,7 +67,7 @@ BACKEND_COMMON_GETTEXT_FLAGS = \ errhint:1:c-format \ errcontext:1:c-format -FRONTEND_COMMON_GETTEXT_FILES = $(top_srcdir)/src/fe_utils/logging.c +FRONTEND_COMMON_GETTEXT_FILES = $(top_srcdir)/src/common/logging.c FRONTEND_COMMON_GETTEXT_TRIGGERS = \ pg_log_fatal pg_log_error pg_log_warning pg_log_info pg_log_generic:2 pg_log_generic_v:2 diff --git a/src/test/isolation/Makefile b/src/test/isolation/Makefile index fbbbca05c5..c3c8280ea2 100644 --- a/src/test/isolation/Makefile +++ b/src/test/isolation/Makefile @@ -10,7 +10,6 @@ top_builddir = ../../.. include $(top_builddir)/src/Makefile.global override CPPFLAGS := -I$(srcdir) -I$(libpq_srcdir) -I$(srcdir)/../regress $(CPPFLAGS) -LDFLAGS_INTERNAL += -L$(top_builddir)/src/fe_utils -lpgfeutils OBJS = specparse.o isolationtester.o $(WIN32RES) @@ -32,7 +31,7 @@ pg_regress.o: | submake-regress pg_isolation_regress$(X): isolation_main.o pg_regress.o $(WIN32RES) $(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@ -isolationtester$(X): $(OBJS) | submake-libpq submake-libpgport submake-libpgfeutils +isolationtester$(X): $(OBJS) | submake-libpq submake-libpgport $(CC) $(CFLAGS) $^ $(libpq_pgport) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@ distprep: specparse.c specscanner.c diff --git a/src/test/regress/GNUmakefile b/src/test/regress/GNUmakefile index 38fd25e569..a24cfd4e01 100644 --- a/src/test/regress/GNUmakefile +++ b/src/test/regress/GNUmakefile @@ -23,8 +23,6 @@ ifdef MAX_CONNECTIONS MAXCONNOPT += --max-connections=$(MAX_CONNECTIONS) endif -LDFLAGS_INTERNAL += -L$(top_builddir)/src/fe_utils -lpgfeutils - # stuff to pass into build of pg_regress EXTRADEFS = '-DHOST_TUPLE="$(host_tuple)"' \ '-DSHELLPROG="$(SHELL)"' \ @@ -38,7 +36,7 @@ EXTRADEFS = '-DHOST_TUPLE="$(host_tuple)"' \ all: pg_regress$(X) -pg_regress$(X): pg_regress.o pg_regress_main.o $(WIN32RES) | submake-libpgport submake-libpgfeutils +pg_regress$(X): pg_regress.o pg_regress_main.o $(WIN32RES) | submake-libpgport $(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@ # dependencies ensure that path changes propagate diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c index 0902b1fa97..a1a3d48748 100644 --- a/src/test/regress/pg_regress.c +++ b/src/test/regress/pg_regress.c @@ -31,9 +31,9 @@ #include "pg_regress.h" +#include "common/logging.h" #include "common/restricted_token.h" #include "common/username.h" -#include "fe_utils/logging.h" #include "getopt_long.h" #include "libpq/pqcomm.h" /* needed for UNIXSOCK_PATH() */ #include "pg_config_paths.h" diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index f466df8847..e07e4593cd 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -136,12 +136,12 @@ sub mkvcbuild our @pgcommonfrontendfiles = ( @pgcommonallfiles, qw(fe_memutils.c file_utils.c - restricted_token.c)); + logging.c restricted_token.c)); our @pgcommonbkndfiles = @pgcommonallfiles; our @pgfeutilsfiles = qw( - conditional.c logging.c mbprint.c print.c psqlscan.l psqlscan.c simple_list.c string_utils.c); + conditional.c mbprint.c print.c psqlscan.l psqlscan.c simple_list.c string_utils.c); $libpgport = $solution->AddProject('libpgport', 'lib', 'misc'); $libpgport->AddDefine('FRONTEND'); @@ -321,7 +321,7 @@ sub mkvcbuild $pgregress_ecpg->AddDefine('HOST_TUPLE="i686-pc-win32vc"'); $pgregress_ecpg->AddLibrary('ws2_32.lib'); $pgregress_ecpg->AddDirResourceFile('src/interfaces/ecpg/test'); - $pgregress_ecpg->AddReference($libpgfeutils, $libpgcommon, $libpgport); + $pgregress_ecpg->AddReference($libpgcommon, $libpgport); my $isolation_tester = $solution->AddProject('isolationtester', 'exe', 'misc'); @@ -347,7 +347,7 @@ sub mkvcbuild $pgregress_isolation->AddDefine('HOST_TUPLE="i686-pc-win32vc"'); $pgregress_isolation->AddLibrary('ws2_32.lib'); $pgregress_isolation->AddDirResourceFile('src/test/isolation'); - $pgregress_isolation->AddReference($libpgfeutils, $libpgcommon, $libpgport); + $pgregress_isolation->AddReference($libpgcommon, $libpgport); # src/bin my $D; @@ -826,7 +826,7 @@ sub mkvcbuild $pgregress->AddDefine('HOST_TUPLE="i686-pc-win32vc"'); $pgregress->AddLibrary('ws2_32.lib'); $pgregress->AddDirResourceFile('src/test/regress'); - $pgregress->AddReference($libpgfeutils, $libpgcommon, $libpgport); + $pgregress->AddReference($libpgcommon, $libpgport); # fix up pg_waldump once it's been set up # files symlinked on Unix are copied on windows