1
0
mirror of https://github.com/postgres/postgres.git synced 2026-01-05 23:38:41 +03:00

Move pg_xlogdump from contrib/ to src/bin/

Reviewed-by: Michael Paquier <michael.paquier@gmail.com>
This commit is contained in:
Peter Eisentraut
2015-03-10 22:33:24 -04:00
parent 0275ecf31c
commit b0a738f428
14 changed files with 33 additions and 28 deletions

View File

@@ -37,7 +37,6 @@ SUBDIRS = \
pgcrypto \
pgrowlocks \
pgstattuple \
pg_xlogdump \
postgres_fdw \
seg \
spi \

View File

@@ -1,21 +0,0 @@
/pg_xlogdump
# Source files copied from src/backend/access/
/brindesc.c
/clogdesc.c
/committsdesc.c
/dbasedesc.c
/gindesc.c
/gistdesc.c
/hashdesc.c
/heapdesc.c
/mxactdesc.c
/nbtdesc.c
/relmapdesc.c
/seqdesc.c
/smgrdesc.c
/spgdesc.c
/standbydesc.c
/tblspcdesc.c
/xactdesc.c
/xlogdesc.c
/xlogreader.c

View File

@@ -1,31 +0,0 @@
# contrib/pg_xlogdump/Makefile
PGFILEDESC = "pg_xlogdump - decode and display WAL"
PGAPPICON=win32
PROGRAM = pg_xlogdump
OBJS = pg_xlogdump.o compat.o xlogreader.o rmgrdesc.o \
$(RMGRDESCOBJS) $(WIN32RES)
RMGRDESCSOURCES = $(notdir $(wildcard $(top_srcdir)/src/backend/access/rmgrdesc/*desc.c))
RMGRDESCOBJS = $(patsubst %.c,%.o,$(RMGRDESCSOURCES))
EXTRA_CLEAN = $(RMGRDESCSOURCES) xlogreader.c
ifdef USE_PGXS
$(error "pg_xlogdump cannot be built with PGXS")
endif
subdir = contrib/pg_xlogdump
top_builddir = ../..
include $(top_builddir)/src/Makefile.global
include $(top_srcdir)/contrib/contrib-global.mk
override CPPFLAGS := -DFRONTEND $(CPPFLAGS)
xlogreader.c: % : $(top_srcdir)/src/backend/access/transam/%
rm -f $@ && $(LN_S) $< .
$(RMGRDESCSOURCES): % : $(top_srcdir)/src/backend/access/rmgrdesc/%
rm -f $@ && $(LN_S) $< .

View File

@@ -1,99 +0,0 @@
/*-------------------------------------------------------------------------
*
* compat.c
* Reimplementations of various backend functions.
*
* Portions Copyright (c) 2013-2015, PostgreSQL Global Development Group
*
* IDENTIFICATION
* contrib/pg_xlogdump/compat.c
*
* This file contains client-side implementations for various backend
* functions that the rm_desc functions in *desc.c files rely on.
*
*-------------------------------------------------------------------------
*/
/* ugly hack, same as in e.g pg_controldata */
#define FRONTEND 1
#include "postgres.h"
#include <time.h>
#include "utils/datetime.h"
#include "lib/stringinfo.h"
/* copied from timestamp.c */
pg_time_t
timestamptz_to_time_t(TimestampTz t)
{
pg_time_t result;
#ifdef HAVE_INT64_TIMESTAMP
result = (pg_time_t) (t / USECS_PER_SEC +
((POSTGRES_EPOCH_JDATE - UNIX_EPOCH_JDATE) * SECS_PER_DAY));
#else
result = (pg_time_t) (t +
((POSTGRES_EPOCH_JDATE - UNIX_EPOCH_JDATE) * SECS_PER_DAY));
#endif
return result;
}
/*
* Stopgap implementation of timestamptz_to_str that doesn't depend on backend
* infrastructure. This will work for timestamps that are within the range
* of the platform time_t type. (pg_time_t is compatible except for possibly
* being wider.)
*
* XXX the return value points to a static buffer, so beware of using more
* than one result value concurrently.
*
* XXX: The backend timestamp infrastructure should instead be split out and
* moved into src/common. That's a large project though.
*/
const char *
timestamptz_to_str(TimestampTz dt)
{
static char buf[MAXDATELEN + 1];
char ts[MAXDATELEN + 1];
char zone[MAXDATELEN + 1];
time_t result = (time_t) timestamptz_to_time_t(dt);
struct tm *ltime = localtime(&result);
strftime(ts, sizeof(ts), "%Y-%m-%d %H:%M:%S", ltime);
strftime(zone, sizeof(zone), "%Z", ltime);
#ifdef HAVE_INT64_TIMESTAMP
sprintf(buf, "%s.%06d %s", ts, (int) (dt % USECS_PER_SEC), zone);
#else
sprintf(buf, "%s.%.6f %s", ts, fabs(dt - floor(dt)), zone);
#endif
return buf;
}
/*
* Provide a hacked up compat layer for StringInfos so xlog desc functions can
* be linked/called.
*/
void
appendStringInfo(StringInfo str, const char *fmt,...)
{
va_list args;
va_start(args, fmt);
vprintf(fmt, args);
va_end(args);
}
void
appendStringInfoString(StringInfo str, const char *string)
{
appendStringInfo(str, "%s", string);
}
void
appendStringInfoChar(StringInfo str, char ch)
{
appendStringInfo(str, "%c", ch);
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,37 +0,0 @@
/*
* rmgrdesc.c
*
* pg_xlogdump resource managers definition
*
* contrib/pg_xlogdump/rmgrdesc.c
*/
#define FRONTEND 1
#include "postgres.h"
#include "access/brin_xlog.h"
#include "access/clog.h"
#include "access/commit_ts.h"
#include "access/gin.h"
#include "access/gist_private.h"
#include "access/hash.h"
#include "access/heapam_xlog.h"
#include "access/multixact.h"
#include "access/nbtree.h"
#include "access/rmgr.h"
#include "access/spgist.h"
#include "access/xact.h"
#include "access/xlog_internal.h"
#include "catalog/storage_xlog.h"
#include "commands/dbcommands_xlog.h"
#include "commands/sequence.h"
#include "commands/tablespace.h"
#include "rmgrdesc.h"
#include "storage/standby.h"
#include "utils/relmapper.h"
#define PG_RMGR(symname,name,redo,desc,identify,startup,cleanup) \
{ name, desc, identify},
const RmgrDescData RmgrDescTable[RM_MAX_ID + 1] = {
#include "access/rmgrlist.h"
};

View File

@@ -1,22 +0,0 @@
/*
* rmgrdesc.h
*
* pg_xlogdump resource managers declaration
*
* contrib/pg_xlogdump/rmgrdesc.h
*/
#ifndef RMGRDESC_H
#define RMGRDESC_H
#include "lib/stringinfo.h"
typedef struct RmgrDescData
{
const char *rm_name;
void (*rm_desc) (StringInfo buf, XLogReaderState *record);
const char *(*rm_identify) (uint8 info);
} RmgrDescData;
extern const RmgrDescData RmgrDescTable[];
#endif /* RMGRDESC_H */