Move logging.h and logging.c from src/fe_utils/ to src/common/.

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
pull/41/head
Tom Lane 6 years ago
parent b71dad22ce
commit fc9a62af3f
  1. 2
      src/bin/initdb/initdb.c
  2. 4
      src/bin/pg_archivecleanup/Makefile
  3. 2
      src/bin/pg_archivecleanup/pg_archivecleanup.c
  4. 2
      src/bin/pg_basebackup/pg_basebackup.c
  5. 2
      src/bin/pg_basebackup/pg_receivewal.c
  6. 2
      src/bin/pg_basebackup/pg_recvlogical.c
  7. 2
      src/bin/pg_basebackup/receivelog.c
  8. 2
      src/bin/pg_basebackup/streamutil.c
  9. 4
      src/bin/pg_checksums/Makefile
  10. 2
      src/bin/pg_checksums/pg_checksums.c
  11. 4
      src/bin/pg_controldata/Makefile
  12. 2
      src/bin/pg_controldata/pg_controldata.c
  13. 4
      src/bin/pg_ctl/Makefile
  14. 2
      src/bin/pg_ctl/pg_ctl.c
  15. 1
      src/bin/pg_dump/common.c
  16. 1
      src/bin/pg_dump/pg_backup_archiver.c
  17. 2
      src/bin/pg_dump/pg_backup_custom.c
  18. 4
      src/bin/pg_dump/pg_backup_db.c
  19. 2
      src/bin/pg_dump/pg_backup_utils.h
  20. 1
      src/bin/pg_dump/pg_dump.c
  21. 1
      src/bin/pg_dump/pg_dump_sort.c
  22. 2
      src/bin/pg_dump/pg_dumpall.c
  23. 2
      src/bin/pg_dump/pg_restore.c
  24. 4
      src/bin/pg_resetwal/Makefile
  25. 2
      src/bin/pg_resetwal/pg_resetwal.c
  26. 4
      src/bin/pg_rewind/Makefile
  27. 2
      src/bin/pg_rewind/datapagemap.c
  28. 2
      src/bin/pg_rewind/pg_rewind.h
  29. 4
      src/bin/pg_test_fsync/Makefile
  30. 2
      src/bin/pg_test_fsync/pg_test_fsync.c
  31. 2
      src/bin/pg_upgrade/pg_upgrade.c
  32. 3
      src/bin/pg_waldump/Makefile
  33. 2
      src/bin/pg_waldump/pg_waldump.c
  34. 2
      src/bin/pgbench/pgbench.c
  35. 4
      src/bin/psql/command.c
  36. 8
      src/bin/psql/common.c
  37. 2
      src/bin/psql/copy.c
  38. 2
      src/bin/psql/crosstabview.c
  39. 7
      src/bin/psql/describe.c
  40. 6
      src/bin/psql/help.c
  41. 2
      src/bin/psql/input.c
  42. 2
      src/bin/psql/large_obj.c
  43. 2
      src/bin/psql/mainloop.c
  44. 2
      src/bin/psql/psqlscanslash.l
  45. 5
      src/bin/psql/startup.c
  46. 2
      src/bin/psql/variables.c
  47. 2
      src/bin/scripts/clusterdb.c
  48. 2
      src/bin/scripts/common.c
  49. 2
      src/bin/scripts/createdb.c
  50. 2
      src/bin/scripts/createuser.c
  51. 2
      src/bin/scripts/dropdb.c
  52. 2
      src/bin/scripts/dropuser.c
  53. 2
      src/bin/scripts/pg_isready.c
  54. 2
      src/bin/scripts/reindexdb.c
  55. 2
      src/bin/scripts/vacuumdb.c
  56. 4
      src/common/Makefile
  57. 2
      src/common/controldata_utils.c
  58. 2
      src/common/file_utils.c
  59. 23
      src/common/logging.c
  60. 2
      src/common/pgfnames.c
  61. 2
      src/common/restricted_token.c
  62. 2
      src/common/rmtree.c
  63. 2
      src/fe_utils/Makefile
  64. 2
      src/fe_utils/psqlscan.l
  65. 10
      src/include/common/logging.h
  66. 2
      src/interfaces/ecpg/test/Makefile
  67. 2
      src/nls-global.mk
  68. 3
      src/test/isolation/Makefile
  69. 4
      src/test/regress/GNUmakefile
  70. 2
      src/test/regress/pg_regress.c
  71. 10
      src/tools/msvc/Mkvcbuild.pm

@ -65,9 +65,9 @@
#include "catalog/pg_collation_d.h" #include "catalog/pg_collation_d.h"
#include "common/file_perm.h" #include "common/file_perm.h"
#include "common/file_utils.h" #include "common/file_utils.h"
#include "common/logging.h"
#include "common/restricted_token.h" #include "common/restricted_token.h"
#include "common/username.h" #include "common/username.h"
#include "fe_utils/logging.h"
#include "fe_utils/string_utils.h" #include "fe_utils/string_utils.h"
#include "getaddrinfo.h" #include "getaddrinfo.h"
#include "getopt_long.h" #include "getopt_long.h"

@ -7,13 +7,11 @@ subdir = src/bin/pg_archivecleanup
top_builddir = ../../.. top_builddir = ../../..
include $(top_builddir)/src/Makefile.global include $(top_builddir)/src/Makefile.global
LDFLAGS_INTERNAL += -L$(top_builddir)/src/fe_utils -lpgfeutils
OBJS = pg_archivecleanup.o $(WIN32RES) OBJS = pg_archivecleanup.o $(WIN32RES)
all: pg_archivecleanup all: pg_archivecleanup
pg_archivecleanup: $(OBJS) | submake-libpgport submake-libpgfeutils pg_archivecleanup: $(OBJS) | submake-libpgport
$(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X) $(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
install: all installdirs install: all installdirs

@ -17,7 +17,7 @@
#include "pg_getopt.h" #include "pg_getopt.h"
#include "fe_utils/logging.h" #include "common/logging.h"
#include "access/xlog_internal.h" #include "access/xlog_internal.h"

@ -29,8 +29,8 @@
#include "access/xlog_internal.h" #include "access/xlog_internal.h"
#include "common/file_perm.h" #include "common/file_perm.h"
#include "common/file_utils.h" #include "common/file_utils.h"
#include "common/logging.h"
#include "common/string.h" #include "common/string.h"
#include "fe_utils/logging.h"
#include "fe_utils/string_utils.h" #include "fe_utils/string_utils.h"
#include "getopt_long.h" #include "getopt_long.h"
#include "libpq-fe.h" #include "libpq-fe.h"

@ -20,7 +20,7 @@
#include <unistd.h> #include <unistd.h>
#include "common/file_perm.h" #include "common/file_perm.h"
#include "fe_utils/logging.h" #include "common/logging.h"
#include "libpq-fe.h" #include "libpq-fe.h"
#include "access/xlog_internal.h" #include "access/xlog_internal.h"
#include "getopt_long.h" #include "getopt_long.h"

@ -25,7 +25,7 @@
#include "access/xlog_internal.h" #include "access/xlog_internal.h"
#include "common/file_perm.h" #include "common/file_perm.h"
#include "common/fe_memutils.h" #include "common/fe_memutils.h"
#include "fe_utils/logging.h" #include "common/logging.h"
#include "getopt_long.h" #include "getopt_long.h"
#include "libpq-fe.h" #include "libpq-fe.h"
#include "libpq/pqsignal.h" #include "libpq/pqsignal.h"

@ -27,7 +27,7 @@
#include "libpq-fe.h" #include "libpq-fe.h"
#include "access/xlog_internal.h" #include "access/xlog_internal.h"
#include "common/file_utils.h" #include "common/file_utils.h"
#include "fe_utils/logging.h" #include "common/logging.h"
/* fd and filename for currently open WAL file */ /* fd and filename for currently open WAL file */

@ -24,9 +24,9 @@
#include "access/xlog_internal.h" #include "access/xlog_internal.h"
#include "common/fe_memutils.h" #include "common/fe_memutils.h"
#include "common/file_perm.h" #include "common/file_perm.h"
#include "common/logging.h"
#include "datatype/timestamp.h" #include "datatype/timestamp.h"
#include "fe_utils/connect.h" #include "fe_utils/connect.h"
#include "fe_utils/logging.h"
#include "port/pg_bswap.h" #include "port/pg_bswap.h"
#include "pqexpbuffer.h" #include "pqexpbuffer.h"

@ -15,13 +15,11 @@ subdir = src/bin/pg_checksums
top_builddir = ../../.. top_builddir = ../../..
include $(top_builddir)/src/Makefile.global include $(top_builddir)/src/Makefile.global
LDFLAGS_INTERNAL += -L$(top_builddir)/src/fe_utils -lpgfeutils
OBJS= pg_checksums.o $(WIN32RES) OBJS= pg_checksums.o $(WIN32RES)
all: pg_checksums all: pg_checksums
pg_checksums: $(OBJS) | submake-libpgport submake-libpgfeutils pg_checksums: $(OBJS) | submake-libpgport
$(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X) $(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
install: all installdirs install: all installdirs

@ -23,7 +23,7 @@
#include "common/controldata_utils.h" #include "common/controldata_utils.h"
#include "common/file_perm.h" #include "common/file_perm.h"
#include "common/file_utils.h" #include "common/file_utils.h"
#include "fe_utils/logging.h" #include "common/logging.h"
#include "getopt_long.h" #include "getopt_long.h"
#include "pg_getopt.h" #include "pg_getopt.h"
#include "storage/bufpage.h" #include "storage/bufpage.h"

@ -15,13 +15,11 @@ subdir = src/bin/pg_controldata
top_builddir = ../../.. top_builddir = ../../..
include $(top_builddir)/src/Makefile.global include $(top_builddir)/src/Makefile.global
LDFLAGS_INTERNAL += -L$(top_builddir)/src/fe_utils -lpgfeutils
OBJS= pg_controldata.o $(WIN32RES) OBJS= pg_controldata.o $(WIN32RES)
all: pg_controldata all: pg_controldata
pg_controldata: $(OBJS) | submake-libpgport submake-libpgfeutils pg_controldata: $(OBJS) | submake-libpgport
$(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X) $(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
install: all installdirs install: all installdirs

@ -25,7 +25,7 @@
#include "access/xlog_internal.h" #include "access/xlog_internal.h"
#include "catalog/pg_control.h" #include "catalog/pg_control.h"
#include "common/controldata_utils.h" #include "common/controldata_utils.h"
#include "fe_utils/logging.h" #include "common/logging.h"
#include "pg_getopt.h" #include "pg_getopt.h"
#include "getopt_long.h" #include "getopt_long.h"

@ -16,8 +16,6 @@ subdir = src/bin/pg_ctl
top_builddir = ../../.. top_builddir = ../../..
include $(top_builddir)/src/Makefile.global 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; # 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. # but let's not pull that in on platforms where we don't need it.
ifeq ($(PORTNAME), win32) ifeq ($(PORTNAME), win32)
@ -30,7 +28,7 @@ OBJS= pg_ctl.o $(WIN32RES)
all: pg_ctl 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) $(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
install: all installdirs install: all installdirs

@ -26,7 +26,7 @@
#include "catalog/pg_control.h" #include "catalog/pg_control.h"
#include "common/controldata_utils.h" #include "common/controldata_utils.h"
#include "common/file_perm.h" #include "common/file_perm.h"
#include "fe_utils/logging.h" #include "common/logging.h"
#include "getopt_long.h" #include "getopt_long.h"
#include "utils/pidfile.h" #include "utils/pidfile.h"

@ -22,7 +22,6 @@
#include <ctype.h> #include <ctype.h>
#include "catalog/pg_class_d.h" #include "catalog/pg_class_d.h"
#include "fe_utils/logging.h"
#include "fe_utils/string_utils.h" #include "fe_utils/string_utils.h"

@ -35,7 +35,6 @@
#include "pg_backup_db.h" #include "pg_backup_db.h"
#include "pg_backup_utils.h" #include "pg_backup_utils.h"
#include "dumputils.h" #include "dumputils.h"
#include "fe_utils/logging.h"
#include "fe_utils/string_utils.h" #include "fe_utils/string_utils.h"
#include "libpq/libpq-fs.h" #include "libpq/libpq-fs.h"

@ -29,7 +29,7 @@
#include "parallel.h" #include "parallel.h"
#include "pg_backup_utils.h" #include "pg_backup_utils.h"
#include "common/file_utils.h" #include "common/file_utils.h"
#include "fe_utils/logging.h"
/*-------- /*--------
* Routines in the format interface * Routines in the format interface

@ -11,10 +11,10 @@
*/ */
#include "postgres_fe.h" #include "postgres_fe.h"
#include "dumputils.h"
#include "fe_utils/connect.h" #include "fe_utils/connect.h"
#include "fe_utils/logging.h"
#include "fe_utils/string_utils.h" #include "fe_utils/string_utils.h"
#include "dumputils.h"
#include "parallel.h" #include "parallel.h"
#include "pg_backup_archiver.h" #include "pg_backup_archiver.h"
#include "pg_backup_db.h" #include "pg_backup_db.h"

@ -15,7 +15,7 @@
#ifndef PG_BACKUP_UTILS_H #ifndef PG_BACKUP_UTILS_H
#define 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 */ typedef enum /* bits returned by set_dump_section */
{ {

@ -63,7 +63,6 @@
#include "pg_backup_utils.h" #include "pg_backup_utils.h"
#include "pg_dump.h" #include "pg_dump.h"
#include "fe_utils/connect.h" #include "fe_utils/connect.h"
#include "fe_utils/logging.h"
#include "fe_utils/string_utils.h" #include "fe_utils/string_utils.h"

@ -20,7 +20,6 @@
#include "pg_dump.h" #include "pg_dump.h"
#include "catalog/pg_class_d.h" #include "catalog/pg_class_d.h"
#include "fe_utils/logging.h"
/* /*
* Sort priority for database object types. * Sort priority for database object types.

@ -23,8 +23,8 @@
#include "dumputils.h" #include "dumputils.h"
#include "pg_backup.h" #include "pg_backup.h"
#include "common/file_utils.h" #include "common/file_utils.h"
#include "common/logging.h"
#include "fe_utils/connect.h" #include "fe_utils/connect.h"
#include "fe_utils/logging.h"
#include "fe_utils/string_utils.h" #include "fe_utils/string_utils.h"
/* version string we expect back from pg_dump */ /* version string we expect back from pg_dump */

@ -51,8 +51,6 @@
#include "parallel.h" #include "parallel.h"
#include "pg_backup_utils.h" #include "pg_backup_utils.h"
#include "fe_utils/logging.h"
static void usage(const char *progname); static void usage(const char *progname);

@ -15,13 +15,11 @@ subdir = src/bin/pg_resetwal
top_builddir = ../../.. top_builddir = ../../..
include $(top_builddir)/src/Makefile.global include $(top_builddir)/src/Makefile.global
LDFLAGS_INTERNAL += -L$(top_builddir)/src/fe_utils -lpgfeutils
OBJS= pg_resetwal.o $(WIN32RES) OBJS= pg_resetwal.o $(WIN32RES)
all: pg_resetwal all: pg_resetwal
pg_resetwal: $(OBJS) | submake-libpgport submake-libpgfeutils pg_resetwal: $(OBJS) | submake-libpgport
$(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X) $(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
install: all installdirs install: all installdirs

@ -52,8 +52,8 @@
#include "common/controldata_utils.h" #include "common/controldata_utils.h"
#include "common/fe_memutils.h" #include "common/fe_memutils.h"
#include "common/file_perm.h" #include "common/file_perm.h"
#include "common/logging.h"
#include "common/restricted_token.h" #include "common/restricted_token.h"
#include "fe_utils/logging.h"
#include "storage/large_object.h" #include "storage/large_object.h"
#include "pg_getopt.h" #include "pg_getopt.h"
#include "getopt_long.h" #include "getopt_long.h"

@ -16,7 +16,7 @@ top_builddir = ../../..
include $(top_builddir)/src/Makefile.global include $(top_builddir)/src/Makefile.global
override CPPFLAGS := -I$(libpq_srcdir) -DFRONTEND $(CPPFLAGS) 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 \ 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 \ fetch.o file_ops.o copy_fetch.o libpq_fetch.o filemap.o \
@ -26,7 +26,7 @@ EXTRA_CLEAN = xlogreader.c
all: pg_rewind 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) $(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
xlogreader.c: % : $(top_srcdir)/src/backend/access/transam/% xlogreader.c: % : $(top_srcdir)/src/backend/access/transam/%

@ -14,7 +14,7 @@
#include "datapagemap.h" #include "datapagemap.h"
#include "fe_utils/logging.h" #include "common/logging.h"
struct datapagemap_iterator struct datapagemap_iterator
{ {

@ -17,7 +17,7 @@
#include "storage/block.h" #include "storage/block.h"
#include "storage/relfilenode.h" #include "storage/relfilenode.h"
#include "fe_utils/logging.h" #include "common/logging.h"
/* Configuration options */ /* Configuration options */
extern char *datadir_target; extern char *datadir_target;

@ -7,13 +7,11 @@ subdir = src/bin/pg_test_fsync
top_builddir = ../../.. top_builddir = ../../..
include $(top_builddir)/src/Makefile.global include $(top_builddir)/src/Makefile.global
LDFLAGS_INTERNAL += -L$(top_builddir)/src/fe_utils -lpgfeutils
OBJS = pg_test_fsync.o $(WIN32RES) OBJS = pg_test_fsync.o $(WIN32RES)
all: pg_test_fsync 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) $(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
install: all installdirs install: all installdirs

@ -14,7 +14,7 @@
#include "getopt_long.h" #include "getopt_long.h"
#include "access/xlogdefs.h" #include "access/xlogdefs.h"
#include "fe_utils/logging.h" #include "common/logging.h"
/* /*

@ -40,8 +40,8 @@
#include "pg_upgrade.h" #include "pg_upgrade.h"
#include "catalog/pg_class_d.h" #include "catalog/pg_class_d.h"
#include "common/file_perm.h" #include "common/file_perm.h"
#include "common/logging.h"
#include "common/restricted_token.h" #include "common/restricted_token.h"
#include "fe_utils/logging.h"
#include "fe_utils/string_utils.h" #include "fe_utils/string_utils.h"
#ifdef HAVE_LANGINFO_H #ifdef HAVE_LANGINFO_H

@ -11,7 +11,6 @@ OBJS = pg_waldump.o compat.o xlogreader.o rmgrdesc.o \
$(RMGRDESCOBJS) $(WIN32RES) $(RMGRDESCOBJS) $(WIN32RES)
override CPPFLAGS := -DFRONTEND $(CPPFLAGS) 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))) RMGRDESCSOURCES = $(sort $(notdir $(wildcard $(top_srcdir)/src/backend/access/rmgrdesc/*desc.c)))
RMGRDESCOBJS = $(patsubst %.c,%.o,$(RMGRDESCSOURCES)) RMGRDESCOBJS = $(patsubst %.c,%.o,$(RMGRDESCSOURCES))
@ -19,7 +18,7 @@ RMGRDESCOBJS = $(patsubst %.c,%.o,$(RMGRDESCSOURCES))
all: pg_waldump all: pg_waldump
pg_waldump: $(OBJS) | submake-libpgport submake-libpgfeutils pg_waldump: $(OBJS) | submake-libpgport
$(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X) $(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
xlogreader.c: % : $(top_srcdir)/src/backend/access/transam/% xlogreader.c: % : $(top_srcdir)/src/backend/access/transam/%

@ -21,7 +21,7 @@
#include "access/xlog_internal.h" #include "access/xlog_internal.h"
#include "access/transam.h" #include "access/transam.h"
#include "common/fe_memutils.h" #include "common/fe_memutils.h"
#include "fe_utils/logging.h" #include "common/logging.h"
#include "getopt_long.h" #include "getopt_long.h"
#include "rmgrdesc.h" #include "rmgrdesc.h"

@ -33,8 +33,8 @@
#include "postgres_fe.h" #include "postgres_fe.h"
#include "common/int.h" #include "common/int.h"
#include "common/logging.h"
#include "fe_utils/conditional.h" #include "fe_utils/conditional.h"
#include "fe_utils/logging.h"
#include "getopt_long.h" #include "getopt_long.h"
#include "libpq-fe.h" #include "libpq-fe.h"
#include "portability/instr_time.h" #include "portability/instr_time.h"

@ -28,7 +28,8 @@
#include "libpq-fe.h" #include "libpq-fe.h"
#include "pqexpbuffer.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 "fe_utils/string_utils.h"
#include "common.h" #include "common.h"
@ -39,7 +40,6 @@
#include "input.h" #include "input.h"
#include "large_obj.h" #include "large_obj.h"
#include "mainloop.h" #include "mainloop.h"
#include "fe_utils/print.h"
#include "psqlscanslash.h" #include "psqlscanslash.h"
#include "settings.h" #include "settings.h"
#include "variables.h" #include "variables.h"

@ -6,7 +6,6 @@
* src/bin/psql/common.c * src/bin/psql/common.c
*/ */
#include "postgres_fe.h" #include "postgres_fe.h"
#include "common.h"
#include <ctype.h> #include <ctype.h>
#include <limits.h> #include <limits.h>
@ -19,15 +18,16 @@
#include <win32.h> #include <win32.h>
#endif #endif
#include "fe_utils/logging.h" #include "common/logging.h"
#include "fe_utils/mbprint.h"
#include "fe_utils/string_utils.h" #include "fe_utils/string_utils.h"
#include "portability/instr_time.h" #include "portability/instr_time.h"
#include "settings.h"
#include "command.h" #include "command.h"
#include "common.h"
#include "copy.h" #include "copy.h"
#include "crosstabview.h" #include "crosstabview.h"
#include "fe_utils/mbprint.h" #include "settings.h"
static bool DescribeQuery(const char *query, double *elapsed_msec); static bool DescribeQuery(const char *query, double *elapsed_msec);

@ -24,7 +24,7 @@
#include "prompt.h" #include "prompt.h"
#include "stringutils.h" #include "stringutils.h"
#include "fe_utils/logging.h" #include "common/logging.h"
/* /*
* parse_slash_copy * parse_slash_copy

@ -13,7 +13,7 @@
#include "psqlscanslash.h" #include "psqlscanslash.h"
#include "settings.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 * Value/position from the resultset that goes into the horizontal or vertical

@ -18,13 +18,14 @@
#include "catalog/pg_cast_d.h" #include "catalog/pg_cast_d.h"
#include "catalog/pg_class_d.h" #include "catalog/pg_class_d.h"
#include "catalog/pg_default_acl_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 "fe_utils/string_utils.h"
#include "common.h" #include "common.h"
#include "describe.h" #include "describe.h"
#include "fe_utils/mbprint.h"
#include "fe_utils/print.h"
#include "settings.h" #include "settings.h"
#include "variables.h" #include "variables.h"

@ -21,15 +21,15 @@
#include <termios.h> #include <termios.h>
#endif #endif
#include "common.h" #include "common/logging.h"
#include "common/username.h" #include "common/username.h"
#include "common.h"
#include "help.h" #include "help.h"
#include "input.h" #include "input.h"
#include "settings.h" #include "settings.h"
#include "sql_help.h" #include "sql_help.h"
#include "fe_utils/logging.h"
/* /*
* PLEASE: * PLEASE:
* If you change something in this file, also make the same changes * If you change something in this file, also make the same changes

@ -18,7 +18,7 @@
#include "tab-complete.h" #include "tab-complete.h"
#include "common.h" #include "common.h"
#include "fe_utils/logging.h" #include "common/logging.h"
#ifndef WIN32 #ifndef WIN32
#define PSQLHISTORY ".psql_history" #define PSQLHISTORY ".psql_history"

@ -11,7 +11,7 @@
#include "settings.h" #include "settings.h"
#include "common.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); static void print_lo_result(const char *fmt,...) pg_attribute_printf(1, 2);

@ -14,7 +14,7 @@
#include "prompt.h" #include "prompt.h"
#include "settings.h" #include "settings.h"
#include "fe_utils/logging.h" #include "common/logging.h"
#include "mb/pg_wchar.h" #include "mb/pg_wchar.h"

@ -19,8 +19,8 @@
#include "postgres_fe.h" #include "postgres_fe.h"
#include "psqlscanslash.h" #include "psqlscanslash.h"
#include "common/logging.h"
#include "fe_utils/conditional.h" #include "fe_utils/conditional.h"
#include "fe_utils/logging.h"
#include "libpq-fe.h" #include "libpq-fe.h"
} }

@ -16,14 +16,15 @@
#include "getopt_long.h" #include "getopt_long.h"
#include "common/logging.h"
#include "fe_utils/print.h"
#include "command.h" #include "command.h"
#include "common.h" #include "common.h"
#include "describe.h" #include "describe.h"
#include "help.h" #include "help.h"
#include "input.h" #include "input.h"
#include "mainloop.h" #include "mainloop.h"
#include "fe_utils/logging.h"
#include "fe_utils/print.h"
#include "settings.h" #include "settings.h"

@ -10,7 +10,7 @@
#include "common.h" #include "common.h"
#include "variables.h" #include "variables.h"
#include "fe_utils/logging.h" #include "common/logging.h"
/* /*

@ -11,7 +11,7 @@
#include "postgres_fe.h" #include "postgres_fe.h"
#include "common.h" #include "common.h"
#include "fe_utils/logging.h" #include "common/logging.h"
#include "fe_utils/simple_list.h" #include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h" #include "fe_utils/string_utils.h"

@ -18,8 +18,8 @@
#include <unistd.h> #include <unistd.h>
#include "common.h" #include "common.h"
#include "common/logging.h"
#include "fe_utils/connect.h" #include "fe_utils/connect.h"
#include "fe_utils/logging.h"
#include "fe_utils/string_utils.h" #include "fe_utils/string_utils.h"

@ -12,7 +12,7 @@
#include "postgres_fe.h" #include "postgres_fe.h"
#include "common.h" #include "common.h"
#include "fe_utils/logging.h" #include "common/logging.h"
#include "fe_utils/string_utils.h" #include "fe_utils/string_utils.h"

@ -12,7 +12,7 @@
#include "postgres_fe.h" #include "postgres_fe.h"
#include "common.h" #include "common.h"
#include "fe_utils/logging.h" #include "common/logging.h"
#include "fe_utils/simple_list.h" #include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h" #include "fe_utils/string_utils.h"

@ -12,7 +12,7 @@
#include "postgres_fe.h" #include "postgres_fe.h"
#include "common.h" #include "common.h"
#include "fe_utils/logging.h" #include "common/logging.h"
#include "fe_utils/string_utils.h" #include "fe_utils/string_utils.h"

@ -12,7 +12,7 @@
#include "postgres_fe.h" #include "postgres_fe.h"
#include "common.h" #include "common.h"
#include "fe_utils/logging.h" #include "common/logging.h"
#include "fe_utils/string_utils.h" #include "fe_utils/string_utils.h"

@ -11,7 +11,7 @@
#include "postgres_fe.h" #include "postgres_fe.h"
#include "common.h" #include "common.h"
#include "fe_utils/logging.h" #include "common/logging.h"
#define DEFAULT_CONNECT_TIMEOUT "3" #define DEFAULT_CONNECT_TIMEOUT "3"

@ -11,7 +11,7 @@
#include "postgres_fe.h" #include "postgres_fe.h"
#include "common.h" #include "common.h"
#include "fe_utils/logging.h" #include "common/logging.h"
#include "fe_utils/simple_list.h" #include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h" #include "fe_utils/string_utils.h"

@ -19,8 +19,8 @@
#include "catalog/pg_class_d.h" #include "catalog/pg_class_d.h"
#include "common.h" #include "common.h"
#include "common/logging.h"
#include "fe_utils/connect.h" #include "fe_utils/connect.h"
#include "fe_utils/logging.h"
#include "fe_utils/simple_list.h" #include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h" #include "fe_utils/string_utils.h"

@ -59,7 +59,9 @@ OBJS_COMMON += sha2.o
endif endif
# A few files are currently only built for frontend, not server # 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 # foo.o, foo_shlib.o, and foo_srv.o are all built from foo.c
OBJS_SHLIB = $(OBJS_FRONTEND:%.o=%_shlib.o) OBJS_SHLIB = $(OBJS_FRONTEND:%.o=%_shlib.o)

@ -29,7 +29,7 @@
#include "common/controldata_utils.h" #include "common/controldata_utils.h"
#include "common/file_perm.h" #include "common/file_perm.h"
#ifdef FRONTEND #ifdef FRONTEND
#include "fe_utils/logging.h" #include "common/logging.h"
#endif #endif
#include "port/pg_crc32c.h" #include "port/pg_crc32c.h"

@ -20,7 +20,7 @@
#include <unistd.h> #include <unistd.h>
#include "common/file_utils.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 */ /* Define PG_FLUSH_DATA_WORKS if we have an implementation for pg_flush_data */

@ -1,9 +1,9 @@
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
* Logging framework for frontend programs * 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 <unistd.h> #include <unistd.h>
#include "fe_utils/logging.h" #include "common/logging.h"
static const char *progname;
enum pg_log_level __pg_log_level; enum pg_log_level __pg_log_level;
static const char *progname;
static int log_flags; 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_error = NULL;
static const char *sgr_warning = 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);
Assert(fmt[strlen(fmt) - 1] != '\n'); Assert(fmt[strlen(fmt) - 1] != '\n');
/*
* Flush stdout before output to stderr, to ensure sync even when stdout
* is buffered.
*/
fflush(stdout); fflush(stdout);
if (log_pre_callback) if (log_pre_callback)
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); vsnprintf(buf, required_len, fmt, ap);
/* strip one newline, for PQerrorMessage() */ /* 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'; buf[required_len - 2] = '\0';
fprintf(stderr, "%s\n", buf); fprintf(stderr, "%s\n", buf);
free(buf); free(buf);
} }

@ -23,7 +23,7 @@
#ifndef FRONTEND #ifndef FRONTEND
#define pg_log_warning(...) elog(WARNING, __VA_ARGS__) #define pg_log_warning(...) elog(WARNING, __VA_ARGS__)
#else #else
#include "fe_utils/logging.h" #include "common/logging.h"
#endif #endif
/* /*

@ -20,8 +20,8 @@
#include "postgres_fe.h" #include "postgres_fe.h"
#include "common/logging.h"
#include "common/restricted_token.h" #include "common/restricted_token.h"
#include "fe_utils/logging.h"
#ifdef WIN32 #ifdef WIN32

@ -23,7 +23,7 @@
#ifndef FRONTEND #ifndef FRONTEND
#define pg_log_warning(...) elog(WARNING, __VA_ARGS__) #define pg_log_warning(...) elog(WARNING, __VA_ARGS__)
#else #else
#include "fe_utils/logging.h" #include "common/logging.h"
#endif #endif

@ -19,7 +19,7 @@ include $(top_builddir)/src/Makefile.global
override CPPFLAGS := -DFRONTEND -I$(libpq_srcdir) $(CPPFLAGS) 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 all: libpgfeutils.a

@ -34,7 +34,7 @@
*/ */
#include "postgres_fe.h" #include "postgres_fe.h"
#include "fe_utils/logging.h" #include "common/logging.h"
#include "fe_utils/psqlscan.h" #include "fe_utils/psqlscan.h"
#include "libpq-fe.h" #include "libpq-fe.h"

@ -1,14 +1,14 @@
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
* Logging framework for frontend programs * 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 #ifndef COMMON_LOGGING_H
#define FE_UTILS_LOGGING_H #define COMMON_LOGGING_H
/* /*
* Log levels are informational only. They do not affect program flow. * 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__); \ if (unlikely(__pg_log_level <= PG_LOG_DEBUG)) pg_log_generic(PG_LOG_DEBUG, __VA_ARGS__); \
} while(0) } while(0)
#endif /* FE_UTILS_LOGGING_H */ #endif /* COMMON_LOGGING_H */

@ -15,8 +15,6 @@ override CPPFLAGS := \
'-DDLSUFFIX="$(DLSUFFIX)"' \ '-DDLSUFFIX="$(DLSUFFIX)"' \
$(CPPFLAGS) $(CPPFLAGS)
LDFLAGS_INTERNAL += -L$(top_builddir)/src/fe_utils -lpgfeutils
# default encoding for regression tests # default encoding for regression tests
ENCODING = SQL_ASCII ENCODING = SQL_ASCII

@ -67,7 +67,7 @@ BACKEND_COMMON_GETTEXT_FLAGS = \
errhint:1:c-format \ errhint:1:c-format \
errcontext: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 = \ 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 pg_log_fatal pg_log_error pg_log_warning pg_log_info pg_log_generic:2 pg_log_generic_v:2

@ -10,7 +10,6 @@ top_builddir = ../../..
include $(top_builddir)/src/Makefile.global include $(top_builddir)/src/Makefile.global
override CPPFLAGS := -I$(srcdir) -I$(libpq_srcdir) -I$(srcdir)/../regress $(CPPFLAGS) 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) 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) pg_isolation_regress$(X): isolation_main.o pg_regress.o $(WIN32RES)
$(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@ $(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 $@ $(CC) $(CFLAGS) $^ $(libpq_pgport) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@
distprep: specparse.c specscanner.c distprep: specparse.c specscanner.c

@ -23,8 +23,6 @@ ifdef MAX_CONNECTIONS
MAXCONNOPT += --max-connections=$(MAX_CONNECTIONS) MAXCONNOPT += --max-connections=$(MAX_CONNECTIONS)
endif endif
LDFLAGS_INTERNAL += -L$(top_builddir)/src/fe_utils -lpgfeutils
# stuff to pass into build of pg_regress # stuff to pass into build of pg_regress
EXTRADEFS = '-DHOST_TUPLE="$(host_tuple)"' \ EXTRADEFS = '-DHOST_TUPLE="$(host_tuple)"' \
'-DSHELLPROG="$(SHELL)"' \ '-DSHELLPROG="$(SHELL)"' \
@ -38,7 +36,7 @@ EXTRADEFS = '-DHOST_TUPLE="$(host_tuple)"' \
all: pg_regress$(X) 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 $@ $(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@
# dependencies ensure that path changes propagate # dependencies ensure that path changes propagate

@ -31,9 +31,9 @@
#include "pg_regress.h" #include "pg_regress.h"
#include "common/logging.h"
#include "common/restricted_token.h" #include "common/restricted_token.h"
#include "common/username.h" #include "common/username.h"
#include "fe_utils/logging.h"
#include "getopt_long.h" #include "getopt_long.h"
#include "libpq/pqcomm.h" /* needed for UNIXSOCK_PATH() */ #include "libpq/pqcomm.h" /* needed for UNIXSOCK_PATH() */
#include "pg_config_paths.h" #include "pg_config_paths.h"

@ -136,12 +136,12 @@ sub mkvcbuild
our @pgcommonfrontendfiles = ( our @pgcommonfrontendfiles = (
@pgcommonallfiles, qw(fe_memutils.c file_utils.c @pgcommonallfiles, qw(fe_memutils.c file_utils.c
restricted_token.c)); logging.c restricted_token.c));
our @pgcommonbkndfiles = @pgcommonallfiles; our @pgcommonbkndfiles = @pgcommonallfiles;
our @pgfeutilsfiles = qw( 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 = $solution->AddProject('libpgport', 'lib', 'misc');
$libpgport->AddDefine('FRONTEND'); $libpgport->AddDefine('FRONTEND');
@ -321,7 +321,7 @@ sub mkvcbuild
$pgregress_ecpg->AddDefine('HOST_TUPLE="i686-pc-win32vc"'); $pgregress_ecpg->AddDefine('HOST_TUPLE="i686-pc-win32vc"');
$pgregress_ecpg->AddLibrary('ws2_32.lib'); $pgregress_ecpg->AddLibrary('ws2_32.lib');
$pgregress_ecpg->AddDirResourceFile('src/interfaces/ecpg/test'); $pgregress_ecpg->AddDirResourceFile('src/interfaces/ecpg/test');
$pgregress_ecpg->AddReference($libpgfeutils, $libpgcommon, $libpgport); $pgregress_ecpg->AddReference($libpgcommon, $libpgport);
my $isolation_tester = my $isolation_tester =
$solution->AddProject('isolationtester', 'exe', 'misc'); $solution->AddProject('isolationtester', 'exe', 'misc');
@ -347,7 +347,7 @@ sub mkvcbuild
$pgregress_isolation->AddDefine('HOST_TUPLE="i686-pc-win32vc"'); $pgregress_isolation->AddDefine('HOST_TUPLE="i686-pc-win32vc"');
$pgregress_isolation->AddLibrary('ws2_32.lib'); $pgregress_isolation->AddLibrary('ws2_32.lib');
$pgregress_isolation->AddDirResourceFile('src/test/isolation'); $pgregress_isolation->AddDirResourceFile('src/test/isolation');
$pgregress_isolation->AddReference($libpgfeutils, $libpgcommon, $libpgport); $pgregress_isolation->AddReference($libpgcommon, $libpgport);
# src/bin # src/bin
my $D; my $D;
@ -826,7 +826,7 @@ sub mkvcbuild
$pgregress->AddDefine('HOST_TUPLE="i686-pc-win32vc"'); $pgregress->AddDefine('HOST_TUPLE="i686-pc-win32vc"');
$pgregress->AddLibrary('ws2_32.lib'); $pgregress->AddLibrary('ws2_32.lib');
$pgregress->AddDirResourceFile('src/test/regress'); $pgregress->AddDirResourceFile('src/test/regress');
$pgregress->AddReference($libpgfeutils, $libpgcommon, $libpgport); $pgregress->AddReference($libpgcommon, $libpgport);
# fix up pg_waldump once it's been set up # fix up pg_waldump once it's been set up
# files symlinked on Unix are copied on windows # files symlinked on Unix are copied on windows

Loading…
Cancel
Save