Move from contrib to src/bin
authorHeikki Linnakangas <[email protected]>
Fri, 9 Jan 2015 13:27:56 +0000 (15:27 +0200)
committerHeikki Linnakangas <[email protected]>
Fri, 16 Jan 2015 11:46:57 +0000 (13:46 +0200)
Also add logging.c and logging.h files I forgot to "git add" earlier

28 files changed:
contrib/Makefile
contrib/pg_rewind/Makefile [deleted file]
doc/src/sgml/contrib.sgml
doc/src/sgml/filelist.sgml
doc/src/sgml/ref/allfiles.sgml
doc/src/sgml/ref/pg_rewind.sgml [moved from doc/src/sgml/pgrewind.sgml with 98% similarity]
doc/src/sgml/reference.sgml
src/bin/pg_rewind/.gitignore [moved from contrib/pg_rewind/.gitignore with 100% similarity]
src/bin/pg_rewind/Makefile [new file with mode: 0644]
src/bin/pg_rewind/RewindTest.pm [moved from contrib/pg_rewind/RewindTest.pm with 100% similarity]
src/bin/pg_rewind/copy_fetch.c [moved from contrib/pg_rewind/copy_fetch.c with 100% similarity]
src/bin/pg_rewind/datapagemap.c [moved from contrib/pg_rewind/datapagemap.c with 100% similarity]
src/bin/pg_rewind/datapagemap.h [moved from contrib/pg_rewind/datapagemap.h with 100% similarity]
src/bin/pg_rewind/fetch.c [moved from contrib/pg_rewind/fetch.c with 100% similarity]
src/bin/pg_rewind/fetch.h [moved from contrib/pg_rewind/fetch.h with 100% similarity]
src/bin/pg_rewind/filemap.c [moved from contrib/pg_rewind/filemap.c with 100% similarity]
src/bin/pg_rewind/filemap.h [moved from contrib/pg_rewind/filemap.h with 100% similarity]
src/bin/pg_rewind/libpq_fetch.c [moved from contrib/pg_rewind/libpq_fetch.c with 100% similarity]
src/bin/pg_rewind/logging.c [new file with mode: 0644]
src/bin/pg_rewind/logging.h [new file with mode: 0644]
src/bin/pg_rewind/parsexlog.c [moved from contrib/pg_rewind/parsexlog.c with 100% similarity]
src/bin/pg_rewind/pg_rewind.c [moved from contrib/pg_rewind/pg_rewind.c with 100% similarity]
src/bin/pg_rewind/pg_rewind.h [moved from contrib/pg_rewind/pg_rewind.h with 100% similarity]
src/bin/pg_rewind/t/001_basic.pl [moved from contrib/pg_rewind/t/001_basic.pl with 100% similarity]
src/bin/pg_rewind/t/002_databases.pl [moved from contrib/pg_rewind/t/002_databases.pl with 100% similarity]
src/bin/pg_rewind/t/003_extrafiles.pl [moved from contrib/pg_rewind/t/003_extrafiles.pl with 100% similarity]
src/bin/pg_rewind/timeline.c [moved from contrib/pg_rewind/timeline.c with 100% similarity]
src/tools/msvc/Mkvcbuild.pm

index 2fe861f439557ddf81f303d5470f62fa4613302e..195d4472c573ae233b271c4df7e8a7922b925f2e 100644 (file)
@@ -32,7 +32,6 @@ SUBDIRS = \
                pg_buffercache  \
                pg_freespacemap \
                pg_prewarm      \
-               pg_rewind       \
                pg_standby      \
                pg_stat_statements \
                pg_test_fsync   \
diff --git a/contrib/pg_rewind/Makefile b/contrib/pg_rewind/Makefile
deleted file mode 100644 (file)
index a6550e2..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-# Makefile for pg_rewind
-#
-# Copyright (c) 2013-2015, PostgreSQL Global Development Group
-#
-
-PGFILEDESC = "pg_rewind - repurpose an old master server as standby"
-PGAPPICON = win32
-
-PROGRAM = pg_rewind
-OBJS   = pg_rewind.o parsexlog.o xlogreader.o datapagemap.o timeline.o \
-       fetch.o copy_fetch.o libpq_fetch.o filemap.o logging.o $(WIN32RES)
-
-PG_CPPFLAGS = -I$(libpq_srcdir)
-PG_LIBS = $(libpq_pgport)
-
-override CPPFLAGS := -DFRONTEND $(CPPFLAGS)
-
-EXTRA_CLEAN = $(RMGRDESCSOURCES) xlogreader.c
-
-all: pg_rewind
-
-ifdef USE_PGXS
-PG_CONFIG = pg_config
-PGXS := $(shell $(PG_CONFIG) --pgxs)
-include $(PGXS)
-else
-subdir = contrib/pg_rewind
-top_builddir = ../..
-include $(top_builddir)/src/Makefile.global
-include $(top_srcdir)/contrib/contrib-global.mk
-endif
-
-xlogreader.c: % : $(top_srcdir)/src/backend/access/transam/%
-       rm -f $@ && $(LN_S) $< .
-
-check: all
-       $(prove_check)
index 10e6e2bbccc39e55c0761e2e0f2bafc925b2fd60..a698d0fb2f89a14a23e0d426a6c784f5ebdd677c 100644 (file)
@@ -203,7 +203,6 @@ pages.
   </para>
 
  &pgarchivecleanup;
- &pgrewind;
  &pgstandby;
  &pgtestfsync;
  &pgtesttiming;
index d42de276a9431420b8bc6a1c1dcab5e41a120ba1..f03b72ab1dbc4cd4880caf336685bbd2124cdae1 100644 (file)
 <!ENTITY pgcrypto        SYSTEM "pgcrypto.sgml">
 <!ENTITY pgfreespacemap  SYSTEM "pgfreespacemap.sgml">
 <!ENTITY pgprewarm       SYSTEM "pgprewarm.sgml">
-<!ENTITY pgrewind        SYSTEM "pgrewind.sgml">
 <!ENTITY pgrowlocks      SYSTEM "pgrowlocks.sgml">
 <!ENTITY pgstandby       SYSTEM "pgstandby.sgml">
 <!ENTITY pgstatstatements SYSTEM "pgstatstatements.sgml">
index 7aa3128090d801168432f37d1871188c3de9ad0e..5b4692fb6d8dacd923a4a1ab66edbff05ab0a6fe 100644 (file)
@@ -190,6 +190,7 @@ Complete list of usable sgml source files in this directory.
 <!ENTITY pgRecvlogical      SYSTEM "pg_recvlogical.sgml">
 <!ENTITY pgResetxlog        SYSTEM "pg_resetxlog.sgml">
 <!ENTITY pgRestore          SYSTEM "pg_restore.sgml">
+<!ENTITY pgRewind           SYSTEM "pg_rewind.sgml">
 <!ENTITY postgres           SYSTEM "postgres-ref.sgml">
 <!ENTITY postmaster         SYSTEM "postmaster.sgml">
 <!ENTITY psqlRef            SYSTEM "psql-ref.sgml">
similarity index 98%
rename from doc/src/sgml/pgrewind.sgml
rename to doc/src/sgml/ref/pg_rewind.sgml
index d6711da6e7a0643cc80438e4d9ef613d35eb7c1a..028d4480115448b7002806a4d199d770f847aa4c 100644 (file)
@@ -1,4 +1,7 @@
-<!-- doc/src/sgml/pgrewind.sgml -->
+<!--
+doc/src/sgml/pg_rewind.sgml
+PostgreSQL documentation
+-->
 
 <refentry id="pgrewind">
  <indexterm zone="pgrewind">
index 10c9a6d4030606296c5533f9b7e9e26689a42aac..65ad795afe97b8ce0bd6496b8d7654e9a3401ea9 100644 (file)
    &pgControldata;
    &pgCtl;
    &pgResetxlog;
+   &pgRewind;
    &postgres;
    &postmaster;
 
diff --git a/src/bin/pg_rewind/Makefile b/src/bin/pg_rewind/Makefile
new file mode 100644 (file)
index 0000000..21e0e8b
--- /dev/null
@@ -0,0 +1,49 @@
+#-------------------------------------------------------------------------
+#
+# Makefile for src/bin/pg_basebackup
+#
+# Portions Copyright (c) 2013-2015, PostgreSQL Global Development Group
+#
+# src/bin/pg_rewind/Makefile
+#
+#-------------------------------------------------------------------------
+
+PGFILEDESC = "pg_rewind - repurpose an old master server as standby"
+PGAPPICON = win32
+
+subdir = src/bin/pg_rewind
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+PG_CPPFLAGS = -I$(libpq_srcdir)
+PG_LIBS = $(libpq_pgport)
+
+override CPPFLAGS := -I$(libpq_srcdir) -DFRONTEND $(CPPFLAGS)
+
+OBJS   = pg_rewind.o parsexlog.o xlogreader.o datapagemap.o timeline.o \
+       fetch.o copy_fetch.o libpq_fetch.o filemap.o logging.o $(WIN32RES)
+
+EXTRA_CLEAN = $(RMGRDESCSOURCES) xlogreader.c
+
+all: pg_rewind
+
+pg_rewind: $(OBJS) | submake-libpq submake-libpgport
+       $(CC) $(CFLAGS) $^ $(libpq_pgport) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
+xlogreader.c: % : $(top_srcdir)/src/backend/access/transam/%
+       rm -f $@ && $(LN_S) $< .
+
+install: all installdirs
+       $(INSTALL_PROGRAM) pg_rewind$(X) '$(DESTDIR)$(bindir)/pg_rewind$(X)'
+
+installdirs:
+       $(MKDIR_P) '$(DESTDIR)$(bindir)'
+
+uninstall:
+       rm -f '$(DESTDIR)$(bindir)/pg_rewind$(X)'
+
+clean distclean maintainer-clean:
+       rm -f pg_rewind$(X) $(OBJS) xlogreader.c
+
+check: all
+       $(prove_check)
diff --git a/src/bin/pg_rewind/logging.c b/src/bin/pg_rewind/logging.c
new file mode 100644 (file)
index 0000000..6f8c1e0
--- /dev/null
@@ -0,0 +1,94 @@
+/*-------------------------------------------------------------------------
+ *
+ * logging.c
+ *      logging functions
+ *
+ *     Copyright (c) 2010-2015, PostgreSQL Global Development Group
+ *
+ *-------------------------------------------------------------------------
+ */
+#include "postgres_fe.h"
+
+#include <unistd.h>
+
+#include "logging.h"
+
+#define QUERY_ALLOC                    8192
+
+#define MESSAGE_WIDTH          60
+
+LogOpts                log_opts;
+
+static
+__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 0)))
+void
+pg_log_v(eLogType type, const char *fmt, va_list ap)
+{
+       char            message[QUERY_ALLOC];
+
+       vsnprintf(message, sizeof(message), fmt, ap);
+
+       switch (type)
+       {
+               case PG_VERBOSE:
+                       if (log_opts.verbose)
+                               printf("%s", _(message));
+                       break;
+
+               case PG_STATUS:
+                       /* for output to a display, do leading truncation and append \r */
+                       if (isatty(fileno(stdout)))
+                               /* -2 because we use a 2-space indent */
+                               printf("  %s%-*.*s\r",
+                               /* prefix with "..." if we do leading truncation */
+                                          strlen(message) <= MESSAGE_WIDTH - 2 ? "" : "...",
+                                          MESSAGE_WIDTH - 2, MESSAGE_WIDTH - 2,
+                               /* optional leading truncation */
+                                          strlen(message) <= MESSAGE_WIDTH - 2 ? message :
+                                          message + strlen(message) - MESSAGE_WIDTH + 3 + 2);
+                       else
+                               printf("  %s\n", _(message));
+                       break;
+
+               case PG_REPORT:
+               case PG_WARNING:
+                       printf("%s", _(message));
+                       break;
+
+               case PG_FATAL:
+                       printf("\n%s", _(message));
+                       printf("Failure, exiting\n");
+                       exit(1);
+                       break;
+
+               default:
+                       break;
+       }
+       fflush(stdout);
+}
+
+
+void
+pg_log(eLogType type, const char *fmt,...)
+{
+       va_list         args;
+
+       va_start(args, fmt);
+       pg_log_v(type, fmt, args);
+       va_end(args);
+}
+
+
+void
+pg_fatal(const char *fmt,...)
+{
+       va_list         args;
+
+       va_start(args, fmt);
+       pg_log_v(PG_FATAL, fmt, args);
+       va_end(args);
+       printf("Failure, exiting\n");
+       exit(1);
+}
+
+
diff --git a/src/bin/pg_rewind/logging.h b/src/bin/pg_rewind/logging.h
new file mode 100644 (file)
index 0000000..688d1bc
--- /dev/null
@@ -0,0 +1,44 @@
+/*-------------------------------------------------------------------------
+ *
+ * logging.h
+ *      prototypes for logging functions
+ *
+ *
+ * Portions Copyright (c) 1996-2015, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef PG_REWIND_LOGGING_H
+#define PG_REWIND_LOGGING_H
+
+/*
+ * Enumeration to denote pg_log modes
+ */
+typedef enum
+{
+       PG_VERBOSE,
+       PG_STATUS,
+       PG_REPORT,
+       PG_WARNING,
+       PG_FATAL
+} eLogType;
+
+/*
+ * LogOpts
+ */
+typedef struct
+{
+       FILE       *internal;           /* internal log FILE */
+       bool            verbose;                /* TRUE -> be verbose in messages */
+       bool            retain;                 /* retain log files on success */
+} LogOpts;
+
+extern void
+pg_log(eLogType type, const char *fmt,...)
+__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3)));
+extern void
+pg_fatal(const char *fmt,...)
+__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2), noreturn));
+
+#endif
index 43d1729527f9105bf8619dbd5f37dd37fd9d5d61..2adbd3731c5a73dea2f4e835a5a6ba518f279835 100644 (file)
@@ -30,26 +30,21 @@ my $postgres;
 my $libpq;
 
 my $contrib_defines = { 'refint' => 'REFINT_VERBOSE' };
-my @contrib_uselibpq = (
-   'dblink',         'oid2name',
-   'pgbench',        'pg_upgrade',
-   'postgres_fdw',   'vacuumlo',
-   'pg_rewind');
+my @contrib_uselibpq =
+  ('dblink', 'oid2name', 'pgbench', 'pg_upgrade', 'postgres_fdw', 'vacuumlo');
 my @contrib_uselibpgport = (
        'oid2name',      'pgbench',
        'pg_standby',    'pg_archivecleanup',
        'pg_test_fsync', 'pg_test_timing',
        'pg_upgrade',    'pg_xlogdump',
-       'pg_rewind',     'vacuumlo');
+       'vacuumlo');
 my @contrib_uselibpgcommon = (
        'oid2name',      'pgbench',
        'pg_standby',    'pg_archivecleanup',
        'pg_test_fsync', 'pg_test_timing',
        'pg_upgrade',    'pg_xlogdump',
-       'pg_rewind',     'vacuumlo');
-my $contrib_extralibs = {
-    'pgbench' => ['ws2_32.lib'],
-    'pg_rewind' => ['ws2_32.lib'] };
+       'vacuumlo');
+my $contrib_extralibs = { 'pgbench' => ['ws2_32.lib'] };
 my $contrib_extraincludes =
   { 'tsearch2' => ['contrib/tsearch2'], 'dblink' => ['src/backend'] };
 my $contrib_extrasource = {
@@ -403,6 +398,9 @@ sub mkvcbuild
        $pgrecvlogical->AddFile('src\bin\pg_basebackup\pg_recvlogical.c');
        $pgrecvlogical->AddLibrary('ws2_32.lib');
 
+       my $pgrewind = AddSimpleFrontend('pg_rewind', 1);
+       $pgrewind->AddLibrary('ws2_32.lib');
+
        my $pgconfig = AddSimpleFrontend('pg_config');
 
        my $pgcontrol = AddSimpleFrontend('pg_controldata');