]> granicus.if.org Git - postgresql/commitdiff
Move logging.h and logging.c from src/fe_utils/ to src/common/.
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 14 May 2019 18:19:49 +0000 (14:19 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 14 May 2019 18:20:10 +0000 (14:20 -0400)
The original placement of this module in src/fe_utils/ is ill-considered,
because several src/common/ modules have dependencies on it, meaning that
libpgcommon and libpgfeutils now have mutual dependencies.  That makes it
pointless to have distinct libraries at all.  The intended design is that
libpgcommon is lower-level than libpgfeutils, so only dependencies from
the latter to the former are acceptable.

We already have the precedent that fe_memutils and a couple of other
modules in src/common/ are frontend-only, so it's not stretching anything
out of whack to treat logging.c as a frontend-only module in src/common/.
To the extent that such modules help provide a common frontend/backend
environment for the rest of common/ to use, it's a reasonable design.
(logging.c does not yet provide an ereport() emulation, but one can
dream.)

Hence, move these files over, and revert basically all of the build-system
changes made by commit cc8d41511.  There are no places that need to grow
new dependencies on libpgcommon, further reinforcing the idea that this
is the right solution.

Discussion: https://postgr.es/m/a912ffff-f6e4-778a-c86a-cf5c47a12933@2ndquadrant.com

71 files changed:
src/bin/initdb/initdb.c
src/bin/pg_archivecleanup/Makefile
src/bin/pg_archivecleanup/pg_archivecleanup.c
src/bin/pg_basebackup/pg_basebackup.c
src/bin/pg_basebackup/pg_receivewal.c
src/bin/pg_basebackup/pg_recvlogical.c
src/bin/pg_basebackup/receivelog.c
src/bin/pg_basebackup/streamutil.c
src/bin/pg_checksums/Makefile
src/bin/pg_checksums/pg_checksums.c
src/bin/pg_controldata/Makefile
src/bin/pg_controldata/pg_controldata.c
src/bin/pg_ctl/Makefile
src/bin/pg_ctl/pg_ctl.c
src/bin/pg_dump/common.c
src/bin/pg_dump/pg_backup_archiver.c
src/bin/pg_dump/pg_backup_custom.c
src/bin/pg_dump/pg_backup_db.c
src/bin/pg_dump/pg_backup_utils.h
src/bin/pg_dump/pg_dump.c
src/bin/pg_dump/pg_dump_sort.c
src/bin/pg_dump/pg_dumpall.c
src/bin/pg_dump/pg_restore.c
src/bin/pg_resetwal/Makefile
src/bin/pg_resetwal/pg_resetwal.c
src/bin/pg_rewind/Makefile
src/bin/pg_rewind/datapagemap.c
src/bin/pg_rewind/pg_rewind.h
src/bin/pg_test_fsync/Makefile
src/bin/pg_test_fsync/pg_test_fsync.c
src/bin/pg_upgrade/pg_upgrade.c
src/bin/pg_waldump/Makefile
src/bin/pg_waldump/pg_waldump.c
src/bin/pgbench/pgbench.c
src/bin/psql/command.c
src/bin/psql/common.c
src/bin/psql/copy.c
src/bin/psql/crosstabview.c
src/bin/psql/describe.c
src/bin/psql/help.c
src/bin/psql/input.c
src/bin/psql/large_obj.c
src/bin/psql/mainloop.c
src/bin/psql/psqlscanslash.l
src/bin/psql/startup.c
src/bin/psql/variables.c
src/bin/scripts/clusterdb.c
src/bin/scripts/common.c
src/bin/scripts/createdb.c
src/bin/scripts/createuser.c
src/bin/scripts/dropdb.c
src/bin/scripts/dropuser.c
src/bin/scripts/pg_isready.c
src/bin/scripts/reindexdb.c
src/bin/scripts/vacuumdb.c
src/common/Makefile
src/common/controldata_utils.c
src/common/file_utils.c
src/common/logging.c [moved from src/fe_utils/logging.c with 92% similarity]
src/common/pgfnames.c
src/common/restricted_token.c
src/common/rmtree.c
src/fe_utils/Makefile
src/fe_utils/psqlscan.l
src/include/common/logging.h [moved from src/include/fe_utils/logging.h with 92% similarity]
src/interfaces/ecpg/test/Makefile
src/nls-global.mk
src/test/isolation/Makefile
src/test/regress/GNUmakefile
src/test/regress/pg_regress.c
src/tools/msvc/Mkvcbuild.pm

index 09b59c83246d9f6734b98acf6e232c26ddbb6e78..5abc64f5f78443776eaecade93f11439849b732c 100644 (file)
@@ -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"
index 14e834677b2bdaf3e3f10fffcfd74335f3d57925..c5bf99db0f43159b232c2dfa6f155a90e170f8a5 100644 (file)
@@ -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
index b297f210df616ea97eaa8194d4ee0eb66beb3a8c..8f89be64cd4ccecabbba2fc397c96fb4ee1ff394 100644 (file)
@@ -17,7 +17,7 @@
 
 #include "pg_getopt.h"
 
-#include "fe_utils/logging.h"
+#include "common/logging.h"
 
 #include "access/xlog_internal.h"
 
index 1a735b80467c43760591cc697f4f95a19603b4c1..74d7c856648ece5324503bf4375e3c4c5db3c27c 100644 (file)
@@ -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"
index 9e4d296129c521261f8e572ce5b3da48ddd1bd36..5301e8837540c926c419940a1e6c79e7f9ff744b 100644 (file)
@@ -20,7 +20,7 @@
 #include <unistd.h>
 
 #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"
index 3c95f231a2a98201f8d8fb029a627cc010e9eba4..547eb8de8614d2e496e224e7954bda4cf1cfc28f 100644 (file)
@@ -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"
index 0ff9aa19a9e8dd6a04538181f82a99fea97437f3..e9854527e23857d181242d5e5a01e48d83693cf3 100644 (file)
@@ -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 */
index ab2e55d69508a246405b115934fca883dd22de47..79f17e4089f53c840285319ac1343c16207cdb78 100644 (file)
@@ -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"
 
index 13a25f5e3346d16817ad515ddac57556fb944205..278b7a0f2ec04ff128063ea066216201a58106a5 100644 (file)
@@ -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
index 768d038d79b2d140bbeb05bc95bb879b247550fc..37fe20bb756c54e15618e7a3c6dff2cdecc5e9ac 100644 (file)
@@ -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"
index 4d9c1370fe73dbdd30f55731db440fc2df5a3d4e..2d5c56213182b323066b3add0036b5ced78ac078 100644 (file)
@@ -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
index a674f52f0b8f321c145bf96abd3235e4ddb733f4..d955b97c0b80bb0fc4e89a515d95c82e9ab33b8a 100644 (file)
@@ -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"
 
index b931b14a3f566459663669efc08a53d456fa3ff5..83cbf97ed8815450ee971d8726eaaa73e4cdcc58 100644 (file)
@@ -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
index 400763dea787d247cc254dc4217869537148b195..dfb6c19f5a4920b38441e33c9fc2dedfb7d48be3 100644 (file)
@@ -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"
 
index 5958f42a847545e9dce4bffed6cdbb1218bbd85b..b402e49896080513957ed08583bcdac84f82a11c 100644 (file)
@@ -22,7 +22,6 @@
 #include <ctype.h>
 
 #include "catalog/pg_class_d.h"
-#include "fe_utils/logging.h"
 #include "fe_utils/string_utils.h"
 
 
index 821fb4def05f9a1f3e93b557bed609cc13e16a40..d764d36936daccab94393f9512b0e91e13da8639 100644 (file)
@@ -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"
index 5641d5d20fcd0cc08ed7c4b384e261b1b787f89c..ae5306b9dad0a80b5df4196bc48aed3301ce5c13 100644 (file)
@@ -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
index 1d636dac19de918f7fe0ed10a24c756eb2cec2be..9fd3b8a79f6a450f5550dc14c87b3be5c1ddf88b 100644 (file)
  */
 #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"
index c47c19af6c1a50c042e713b36d680192390e9319..619c9fe08c8241e16636d6353b90fd8091e6ba18 100644 (file)
@@ -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 */
 {
index 8b993d6eae88c9e2c7fe76e2465ffdbe9b27db41..a8f1ad7333654065032749a9f8b42b427811824e 100644 (file)
@@ -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"
 
 
index 80641cd79a2e6ce0a10bd55218b10d22ac369ed5..90ec67ca671fbfbaaa3f20bf6b4dc89bc13a2229 100644 (file)
@@ -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.
index 3244a527f62c203e4e75fc2d051a423368ba14ae..102731ea0c67482d28f0b49a77cd09ef72ed7afe 100644 (file)
@@ -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 */
index 9a5b17758f995a9f8f81c3873857d79fc425dc72..8a3fad3d16dd6e2e1ed7ec0d02c65f00f9721ab6 100644 (file)
@@ -51,8 +51,6 @@
 #include "parallel.h"
 #include "pg_backup_utils.h"
 
-#include "fe_utils/logging.h"
-
 
 static void usage(const char *progname);
 
index 09ede1efd2a4a094f3e0dd65b1299a031b54b2a9..2a3835691fdd436ed6fb77e200c183f7a5e3600e 100644 (file)
@@ -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
index 82a8ec993deb0ab819e134ea3745e19e78d140f3..2734f873187ac4589788d508ae03e166629ef2fb 100644 (file)
@@ -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"
index 5455fd4e296decc65e43bf2128891722b3ac89ec..859d3abc41bcd633e85d0991e415957768dbca55 100644 (file)
@@ -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/%
index fc70fe570624da1a02b05c9bd699b25dd9fe733e..93165f697cd592645a644035c505b0e0cd3774fa 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "datapagemap.h"
 
-#include "fe_utils/logging.h"
+#include "common/logging.h"
 
 struct datapagemap_iterator
 {
index 9e6f9474d5900f5eb1a6f79348fbce894d80338a..a54a5d7fd4e0956d67821c778ebfa5b803887d37 100644 (file)
@@ -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;
index 769daecf2b119c1a77ebd682031619a75f342c40..90496df566d17cfcca0098c8e6f78fbd6b26e346 100644 (file)
@@ -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
index 83771061a466f1bbb2e9785c594404ca54c55d81..225557e6c57b123b3471b23f645356bae56c14ee 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "getopt_long.h"
 #include "access/xlogdefs.h"
-#include "fe_utils/logging.h"
+#include "common/logging.h"
 
 
 /*
index 0b304bbd56ab0204396838618e86dfad757c2812..ff78929707ef12699a7579274693f6020c54c755 100644 (file)
@@ -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
index bfe9498b800144729a3806161d449ae6d133b7f7..f5957bd75a6aef71beaa12e60b6260fffc0e642f 100644 (file)
@@ -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/%
index f61505ade36143123df11a09e60d24e65da45fcb..dab9525c68441de1ff267b232552fed7fb76e3a6 100644 (file)
@@ -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"
 
index a03ab281a5f104c2def5c222da22c9b686dc71f8..a81383eb579016c6152091e11cb82eacdb619348 100644 (file)
@@ -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"
index 8254d6109996c96010f79fad084e5316bee0d112..a2c0ec0b7ff7d7e4ed6750aae45aa3cb377db637 100644 (file)
@@ -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"
index bd284446f8d7dc93aabf33d884c4810870f49350..9579e106304023cf2d6bfb771d22e033e718675d 100644 (file)
@@ -6,7 +6,6 @@
  * src/bin/psql/common.c
  */
 #include "postgres_fe.h"
-#include "common.h"
 
 #include <ctype.h>
 #include <limits.h>
 #include <win32.h>
 #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);
index def177693ed66de1d6586a49083ee8a7886f6cbd..b02177a5c2abf54246e344687bcfadf4cb20484f 100644 (file)
@@ -24,7 +24,7 @@
 #include "prompt.h"
 #include "stringutils.h"
 
-#include "fe_utils/logging.h"
+#include "common/logging.h"
 
 /*
  * parse_slash_copy
index 6afd3e0939ce148264ee7bec6421c960dc97e36f..390f750c41221f1f343693b4d6e6d0e72b26ac61 100644 (file)
@@ -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
index ee00c5da08aabcf03d4ab19d9f7b2cd422ff3e4b..773107227ddd4cbacc01fdb77405c79bfa7feab7 100644 (file)
 #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"
 
index d6d41b51d5370ae43f2b0fbd436adf83416b49d0..5fb1baadc574dd8524a97c41a123f53898690523 100644 (file)
 #include <termios.h>
 #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
index 93c0d4c49e4a28c7f9a773a1f9152923aa9ec93d..5a18ac9bbc4b29f4f60aaa093ac1285b61aec975 100644 (file)
@@ -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"
index cecb4897f5a20bce04818a47acb86ef84843a40d..2713f15d4f3d1c3e8a72c7de7363196516be7cd6 100644 (file)
@@ -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);
 
index 3ae447041fa626a99f8d93f78925a658d7017339..e386d9888d7194b75f6ede91333de51d913bcb7e 100644 (file)
@@ -14,7 +14,7 @@
 #include "prompt.h"
 #include "settings.h"
 
-#include "fe_utils/logging.h"
+#include "common/logging.h"
 #include "mb/pg_wchar.h"
 
 
index f7818e6e60388abb2828dadd3b9ab605ef77e1ca..c2e3bfe9d0c4cb567e29bdaa8edd0c52875450cd 100644 (file)
@@ -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"
 }
index 855133bbcb4703b88ddf4c960f65c4f53c49ff0e..7c5b45f7ccebc0824e6c1e6e412d9171ab2d5c5d 100644 (file)
 
 #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"
 
 
index 5d47d5a8ab03006df18db106573c9d27121ba0a9..e456b9db2f804bef2d72e7fa40f7e75e5d497f41 100644 (file)
@@ -10,7 +10,7 @@
 #include "common.h"
 #include "variables.h"
 
-#include "fe_utils/logging.h"
+#include "common/logging.h"
 
 
 /*
index dd0ba68864da9156553ff81ddd9701a8fdd888c2..a1b4119efa565e998a1ee4669ed35f21d092e434 100644 (file)
@@ -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"
 
index a42afd490b06d3818411d935e1246b11113358dc..296029d809308d94765c94d06e30927694c6018a 100644 (file)
@@ -18,8 +18,8 @@
 #include <unistd.h>
 
 #include "common.h"
+#include "common/logging.h"
 #include "fe_utils/connect.h"
-#include "fe_utils/logging.h"
 #include "fe_utils/string_utils.h"
 
 
index e4b497859b556b2c3059737c08ebe6de990155d1..64bcc20cb4877171891b09e00c75b68c5522b4be 100644 (file)
@@ -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"
 
 
index 6db0dbf2a37bc7cac92156259b6b98e872f6be89..973ba525b25757b4faed47613cd34f988a8abd82 100644 (file)
@@ -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"
 
index 42a9bd468601237f40e87479a9b654d12ce4317e..dacd8e5f1dcc9a60c6370c703d402591923f1e74 100644 (file)
@@ -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"
 
 
index 831243815a3299931cbc8e93a582eb48c9338718..3501a06ecb1105728a760aa8f4f9e00017985887 100644 (file)
@@ -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"
 
 
index fe15507caf73403b45257289401df9cfc414bb50..079447f9510bbae8085f26cf5dbe5f03cf85c97b 100644 (file)
@@ -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"
 
index 897ad9a71a2c70415f69bec312683525f1d2ac2c..ba4d10e65c176e3dfb3dba6c6233715ab2408387 100644 (file)
@@ -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"
 
index e9da74c3bae3e818785a40c1bdc36a0c11289f75..6d216aab6b82949d192189f00241db18e3273e1d 100644 (file)
@@ -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"
 
index d84c7b6e6aec14856e5672bfabfd622c1d9cf983..2f22b9b101d6097c163f1393bcafc6b896fe8339 100644 (file)
@@ -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)
index efca14ba5445b26b279e01f589ba97d614846fc7..2c28e51e1112efe17d36c64a230b88d3cc69985b 100644 (file)
@@ -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"
 
index a43c82b4b44944398888edc8328eb64e339ffe3d..eaec568819ea7b86733a78aafefc45dcf3bfc1b7 100644 (file)
@@ -20,7 +20,7 @@
 #include <unistd.h>
 
 #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 */
similarity index 92%
rename from src/fe_utils/logging.c
rename to src/common/logging.c
index 2f571ae3c9898907482eb2df6d9e6dd1e228f040..59f60445c726c9b66319819a57c902a62b103ac9 100644 (file)
@@ -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
  *
  *-------------------------------------------------------------------------
  */
 
 #include <unistd.h>
 
-#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);
 }
index 95b17e47d8987a0e5ca7cc300a6a36ce50b6d2b3..c99c4822015bc6bfead91abf18937b0302854ccc 100644 (file)
@@ -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
 
 /*
index 3f57ff8b40bb20c94e0f651be361e7fea38e02c5..dd077a6e0e2c5e4212013f2b26b8c524d4e70160 100644 (file)
@@ -20,8 +20,8 @@
 
 #include "postgres_fe.h"
 
+#include "common/logging.h"
 #include "common/restricted_token.h"
-#include "fe_utils/logging.h"
 
 #ifdef WIN32
 
index b31da3adff896d7f2395100c340c553751fb8e0e..2c3c4dd2d444587876aa4dd21e57b5ebb08de123 100644 (file)
@@ -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
 
 
index 960ecf0b6ab797c4f4e0e9ebedd66b2eef0c1f9d..7d738003237161b097d8d8ea83d41f2e1c43feb0 100644 (file)
@@ -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
 
index 850754ea9524c92f9e929bf508a6ed47adb50112..ce20936339992a3b8cd0b66352f91ccc333105a7 100644 (file)
@@ -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"
similarity index 92%
rename from src/include/fe_utils/logging.h
rename to src/include/common/logging.h
index b5f0ddc83472488f4d4b606a2a1f3ab2201fbeed..5a3249198aeb6efcff966d34b86bd85ed6ea5d3d 100644 (file)
@@ -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 */
index e6d6f80eef07a4c55aa1cd787faac87eeef0cac9..be53b7b94dc610255b0e4a7a5e256219113663a8 100644 (file)
@@ -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
 
index 797e0dd683db28ed1a2f782ce6874d6f7aaffc5f..5bb77b40ebbe838aa0a30ccd0f88751c722aca4c 100644 (file)
@@ -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
index fbbbca05c51c7cd27cbc8e9472851a0d98708a4e..c3c8280ea23d4403246ede5be33a6c9e5defd006 100644 (file)
@@ -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
index 38fd25e56999068293f604bb402d5c00a0cb2b32..a24cfd4e016200b83c8847a2d1a8aec921c1516b 100644 (file)
@@ -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
index 0902b1fa97a0105f976cc74f6bca8799d371b212..a1a3d4874828a7b17a46bce81b9610031f0eb518 100644 (file)
@@ -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"
index f466df88477dda63861da61fb56af2596827a5a7..e07e4593cdaba9cb696b643659380431b0f0d3f6 100644 (file)
@@ -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