Commit be7dadff authored by Christoph Berg's avatar Christoph Berg

New upstream version 10.1

parent e53d2066
# View README.pg_filedump first
# note this must match version macros in pg_filedump.h
FD_VERSION=10.0
FD_VERSION=10.1
# If working with a PG source directory, point PGSQL_INCLUDE_DIR to its
# src/include subdirectory. If working with an installed tree, point to
# the server include subdirectory, eg /usr/local/include/postgresql/server
PG_CONFIG=pg_config
PGSQL_CFLAGS=$(shell $(PG_CONFIG) --cflags)
PGSQL_INCLUDE_DIR=$(shell $(PG_CONFIG) --includedir-server)
PGSQL_LDFLAGS=$(shell $(PG_CONFIG) --ldflags)
PGSQL_LIB_DIR=$(shell $(PG_CONFIG) --libdir)
PGSQL_BIN_DIR=$(shell $(PG_CONFIG) --bindir)
PROGRAM = pg_filedump
OBJS = pg_filedump.o decode.o stringinfo.o pg_lzcompress.o
DISTFILES= README.pg_filedump Makefile Makefile.contrib \
pg_filedump.h pg_filedump.c decode.h decode.c stringinfo.c pg_lzcompress.c
all: pg_filedump
pg_filedump: pg_filedump.o decode.o stringinfo.o pg_lzcompress.o
${CC} ${PGSQL_LDFLAGS} ${LDFLAGS} -o pg_filedump pg_filedump.o decode.o stringinfo.o pg_lzcompress.o -L${PGSQL_LIB_DIR} -lpgport
pg_filedump.o: pg_filedump.c
${CC} ${PGSQL_CFLAGS} ${CFLAGS} -I${PGSQL_INCLUDE_DIR} pg_filedump.c -c
PG_CONFIG = pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)
decode.o: decode.c
${CC} ${PGSQL_CFLAGS} ${CFLAGS} -I${PGSQL_INCLUDE_DIR} decode.c -c
# avoid linking against all libs that the server links against (xml, selinux, ...)
LIBS = $(libpq_pgport)
stringinfo.o: stringinfo.c
${CC} ${PGSQL_CFLAGS} ${CFLAGS} -I${PGSQL_INCLUDE_DIR} stringinfo.c -c
pg_lzcompress.o: pg_lzcompress.c
${CC} ${PGSQL_CFLAGS} ${CFLAGS} -I${PGSQL_INCLUDE_DIR} pg_lzcompress.c -c
DISTFILES= README.pg_filedump Makefile Makefile.contrib \
pg_filedump.h pg_filedump.c decode.h decode.c stringinfo.c pg_lzcompress.c
dist:
rm -rf pg_filedump-${FD_VERSION} pg_filedump-${FD_VERSION}.tar.gz
......@@ -40,9 +23,3 @@ dist:
tar cfz pg_filedump-${FD_VERSION}.tar.gz pg_filedump-${FD_VERSION}
rm -rf pg_filedump-${FD_VERSION}
install: pg_filedump
mkdir -p $(DESTDIR)$(PGSQL_BIN_DIR)
install pg_filedump $(DESTDIR)$(PGSQL_BIN_DIR)
clean:
rm -f *.o pg_filedump
PROGRAM = pg_filedump
OBJS = pg_filedump.o
OBJS = decode.o pg_filedump.o pg_lzcompress.o stringinfo.o
DOCS = README.pg_filedump
......@@ -13,3 +13,6 @@ else
include $(top_builddir)/src/Makefile.global
include $(top_srcdir)/contrib/contrib-global.mk
endif
# avoid linking against all libs that the server links against (xml, selinux, ...)
LIBS = $(libpq_pgport)
......@@ -2,7 +2,7 @@ pg_filedump - Display formatted contents of a PostgreSQL heap, index,
or control file.
Copyright (c) 2002-2010 Red Hat, Inc.
Copyright (c) 2011-2017, PostgreSQL Global Development Group
Copyright (c) 2011-2018, PostgreSQL Global Development Group
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -40,19 +40,18 @@ PostgreSQL source tree or complete install tree (with include files)
of the appropriate PostgreSQL major version.
There are two makefiles included in this package. Makefile is a standalone
makefile for pg_filedump. Alter its PGSQL_INCLUDE_DIR variable to point to
the PostgreSQL include files. Makefile.contrib can be used if this package
makefile for pg_filedump. Makefile.contrib can be used if this package
was untarred in the contrib directory of a PostgreSQL build tree.
make
make install (if using Makefile.contrib)
make install
It is also possible to use Makefile.contrib without being in the contrib
directory:
make -f Makefile.contrib USE_PGXS=1
This method requires that the pg_config program be in your PATH, but should
Both methods require that the pg_config program be in your PATH, but should
not require any manual adjustments of the Makefile.
......
This diff is collapsed.
......@@ -2,9 +2,17 @@
#define _PG_FILEDUMP_DECODE_H_
int
ParseAttributeTypesString(const char* str);
ParseAttributeTypesString(const char *str);
void
FormatDecode(const char* tupleData, unsigned int tupleSize);
FormatDecode(const char *tupleData, unsigned int tupleSize);
void
ToastChunkDecode(const char* tuple_data,
unsigned int tuple_size,
Oid toast_oid,
uint32 *chunk_id,
char *chunk_data,
unsigned int *chunk_data_size);
#endif
This diff is collapsed.
......@@ -3,7 +3,7 @@
* formatting heap (data), index and control files.
*
* Copyright (c) 2002-2010 Red Hat, Inc.
* Copyright (c) 2011-2017, PostgreSQL Global Development Group
* Copyright (c) 2011-2018, PostgreSQL Global Development Group
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -22,7 +22,7 @@
* Original Author: Patrick Macdonald <patrickm@redhat.com>
*/
#define FD_VERSION "10.0" /* version ID of pg_filedump */
#define FD_VERSION "10.1" /* version ID of pg_filedump */
#define FD_PG_VERSION "PostgreSQL 10.x" /* PG version it works with */
#include "postgres.h"
......@@ -42,37 +42,39 @@
#include "storage/bufpage.h"
/* Options for Block formatting operations */
static unsigned int blockOptions = 0;
extern unsigned int blockOptions;
typedef enum blockSwitches
{
BLOCK_ABSOLUTE = 0x00000001, /* -a: Absolute(vs Relative) addressing */
BLOCK_BINARY = 0x00000002, /* -b: Binary dump of block */
BLOCK_FORMAT = 0x00000004, /* -f: Formatted dump of blocks / control file */
BLOCK_FORCED = 0x00000008, /* -S: Block size forced */
BLOCK_NO_INTR = 0x00000010, /* -d: Dump straight blocks */
BLOCK_RANGE = 0x00000020, /* -R: Specific block range to dump */
BLOCK_CHECKSUMS = 0x00000040, /* -k: verify block checksums */
BLOCK_DECODE = 0x00000080 /* -D: Try to decode tuples */
BLOCK_ABSOLUTE = 0x00000001, /* -a: Absolute(vs Relative) addressing */
BLOCK_BINARY = 0x00000002, /* -b: Binary dump of block */
BLOCK_FORMAT = 0x00000004, /* -f: Formatted dump of blocks / control file */
BLOCK_FORCED = 0x00000008, /* -S: Block size forced */
BLOCK_NO_INTR = 0x00000010, /* -d: Dump straight blocks */
BLOCK_RANGE = 0x00000020, /* -R: Specific block range to dump */
BLOCK_CHECKSUMS = 0x00000040, /* -k: verify block checksums */
BLOCK_DECODE = 0x00000080, /* -D: Try to decode tuples */
BLOCK_DECODE_TOAST = 0x00000100, /* -t: Try to decode TOAST values */
BLOCK_IGNORE_OLD = 0x00000200 /* -o: Decode old values */
} blockSwitches;
/* Segment-related options */
static unsigned int segmentOptions = 0;
extern unsigned int segmentOptions;
typedef enum segmentSwitches
{
SEGMENT_SIZE_FORCED = 0x00000001, /* -s: Segment size forced */
SEGMENT_NUMBER_FORCED = 0x00000002, /* -n: Segment number forced */
} segmentSwitches;
SEGMENT_NUMBER_FORCED = 0x00000002, /* -n: Segment number forced */
} segmentSwitches;
/* -R[start]:Block range start */
static int blockStart = -1;
extern int blockStart;
/* -R[end]:Block range end */
static int blockEnd = -1;
extern int blockEnd;
/* Options for Item formatting operations */
static unsigned int itemOptions = 0;
extern unsigned int itemOptions;
typedef enum itemSwitches
{
......@@ -84,13 +86,13 @@ typedef enum itemSwitches
} itemSwitches;
/* Options for Control File formatting operations */
static unsigned int controlOptions = 0;
extern unsigned int controlOptions;
typedef enum controlSwitches
{
CONTROL_DUMP = 0x00000001, /* -c: Dump control file */
CONTROL_FORMAT = BLOCK_FORMAT, /* -f: Formatted dump of control file */
CONTROL_FORCED = BLOCK_FORCED /* -S: Block size forced */
CONTROL_FORMAT = BLOCK_FORMAT, /* -f: Formatted dump of control file */
CONTROL_FORCED = BLOCK_FORCED /* -S: Block size forced */
} controlSwitches;
/* Possible value types for the Special Section */
......@@ -105,13 +107,13 @@ typedef enum specialSectionTypes
SPEC_SECT_INDEX_SPGIST, /* SP - GIST index info in special section */
SPEC_SECT_ERROR_UNKNOWN, /* Unknown error */
SPEC_SECT_ERROR_BOUNDARY /* Boundary error */
} specialSectionTypes;
} specialSectionTypes;
static unsigned int specialType = SPEC_SECT_NONE;
extern unsigned int specialType;
/* Possible return codes from option validation routine. */
/* pg_filedump doesn't do much with them now but maybe in */
/* the future... */
/* Possible return codes from option validation routine.
* pg_filedump doesn't do much with them now but maybe in
* the future... */
typedef enum optionReturnCodes
{
OPT_RC_VALID, /* All options are valid */
......@@ -119,10 +121,10 @@ typedef enum optionReturnCodes
OPT_RC_FILE, /* File problems */
OPT_RC_DUPLICATE, /* Duplicate option encountered */
OPT_RC_COPYRIGHT /* Copyright should be displayed */
} optionReturnCodes;
} optionReturnCodes;
/* Simple macro to check for duplicate options and then set */
/* an option flag for later consumption */
/* Simple macro to check for duplicate options and then set
* an option flag for later consumption */
#define SET_OPTION(_x,_y,_z) if (_x & _y) \
{ \
rc = OPT_RC_DUPLICATE; \
......@@ -134,3 +136,14 @@ typedef enum optionReturnCodes
#define SEQUENCE_MAGIC 0x1717 /* PostgreSQL defined magic number */
#define EOF_ENCOUNTERED (-1) /* Indicator for partial read */
#define BYTES_PER_LINE 16 /* Format the binary 16 bytes per line */
extern char *fileName;
/*
* Function Prototypes
*/
unsigned int GetBlockSize(FILE *fp);
int DumpFileContents(unsigned int blockOptions, unsigned int controlOptions,
FILE *fp, unsigned int blockSize, int blockStart,
int blockEnd, bool isToast, Oid toastOid,
unsigned int toastExternalSize, char *toastValue);
......@@ -166,7 +166,7 @@
*
* Jan Wieck
*
* Copyright (c) 1999-2017, PostgreSQL Global Development Group
* Copyright (c) 1999-2018, PostgreSQL Global Development Group
*
* src/common/pg_lzcompress.c
* ----------
......@@ -752,7 +752,7 @@ pglz_decompress(const char *source, int32 slen, char *dest,
* An unset control bit means LITERAL BYTE. So we just copy
* one from INPUT to OUTPUT.
*/
if (dp >= destend) /* check for buffer overrun */
if (dp >= destend) /* check for buffer overrun */
break; /* do not clobber memory */
*dp++ = *sp++;
......
......@@ -36,7 +36,7 @@
void
initStringInfo(StringInfo str)
{
int size = 1024; /* initial default buffer size */
int size = 1024; /* initial default buffer size */
str->data = (char *) malloc(size);
str->maxlen = size;
......@@ -111,7 +111,7 @@ enlargeStringInfo(StringInfo str, int needed)
{
Size newlen;
Size limit;
char* old_data;
char *old_data;
limit = MaxAllocSize;
......@@ -119,7 +119,7 @@ enlargeStringInfo(StringInfo str, int needed)
* Guard against out-of-range "needed" values. Without this, we can get
* an overflow or infinite loop in the following.
*/
if (needed < 0) /* should not happen */
if (needed < 0) /* should not happen */
{
printf("Error: invalid string enlargement request size: %d", needed);
exit(1);
......@@ -128,16 +128,16 @@ enlargeStringInfo(StringInfo str, int needed)
if (((Size) needed) >= (limit - (Size) str->len))
{
printf("Error: cannot enlarge string buffer containing %d bytes by %d more bytes.",
str->len, needed);
str->len, needed);
exit(1);
}
needed += str->len + 1; /* total space required now */
needed += str->len + 1; /* total space required now */
/* Because of the above test, we now have needed <= limit */
if (needed <= str->maxlen)
return; /* got enough space already */
return; /* got enough space already */
/*
* We don't want to allocate just a little more space with each append;
......@@ -158,7 +158,7 @@ enlargeStringInfo(StringInfo str, int needed)
old_data = str->data;
str->data = (char *) realloc(str->data, (Size) newlen);
if(str->data == NULL)
if (str->data == NULL)
{
free(old_data);
printf("Error: realloc() failed!\n");
......@@ -167,4 +167,3 @@ enlargeStringInfo(StringInfo str, int needed)
str->maxlen = newlen;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment