Compare commits
18 Commits
Author | SHA1 | Date | |
---|---|---|---|
67f438986f | |||
1c9dd6b728 | |||
052ed01129 | |||
b163cdaa53 | |||
42257f58af | |||
10d27139e2 | |||
595225c836 | |||
9eb845b233 | |||
17dafd471e | |||
81982fa168 | |||
e3b9612db0 | |||
093effb3f8 | |||
bbd992bc26 | |||
4f71071d5b | |||
883c674f6f | |||
3551cfe252 | |||
2c9c61c841 | |||
ac96dfbaca |
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
/pg_filedump.o
|
||||||
|
/pg_filedump
|
174
ChangeLog
174
ChangeLog
@ -1,174 +0,0 @@
|
|||||||
2010-12-29 Tom Lane <tgl@redhat.com>
|
|
||||||
|
|
||||||
* pg_filedump.c, .h: Update version and copyright date for
|
|
||||||
PostgreSQL 9.0 (there aren't any on-disk layout changes in 9.0).
|
|
||||||
|
|
||||||
2009-07-08 Tom Lane <tgl@redhat.com>
|
|
||||||
|
|
||||||
* pg_filedump.c: Update for changes in pg_control contents in
|
|
||||||
PostgreSQL 8.4.
|
|
||||||
* pg_filedump.c, .h: Update version and copyright date.
|
|
||||||
|
|
||||||
2008-02-08 Tom Lane <tgl@redhat.com>
|
|
||||||
|
|
||||||
* pg_filedump.c: Updates for various representation changes in
|
|
||||||
PostgreSQL 8.3; in particular there is finally a trustworthy way
|
|
||||||
to tell apart the various types of index special space.
|
|
||||||
* pg_filedump.c, .h: Update version and copyright date.
|
|
||||||
|
|
||||||
2007-02-14 Tom Lane <tgl@redhat.com>
|
|
||||||
|
|
||||||
* pg_filedump.c, .h: Remove rtree support (gone in PostgreSQL 8.2)
|
|
||||||
and add GIN support. Other updates for changes in index special
|
|
||||||
section contents in 8.2.
|
|
||||||
* pg_filedump.c: Repair old bug that misreported header length by
|
|
||||||
4 bytes.
|
|
||||||
* pg_filedump.c, .h: Update version and copyright date.
|
|
||||||
|
|
||||||
2005-11-21 Tom Lane <tgl@redhat.com>
|
|
||||||
|
|
||||||
* pg_filedump.c, .h: Adjust to support PostgreSQL 8.1 tuple format
|
|
||||||
and control file layout.
|
|
||||||
* pg_filedump.c, .h: Update version and copyright date.
|
|
||||||
* Makefile.contrib: Update for PGXS changes.
|
|
||||||
|
|
||||||
2005-02-10 Tom Lane <tgl@redhat.com>
|
|
||||||
|
|
||||||
* pg_filedump.c, .h: Adjust to support PostgreSQL 8.0 tuple format.
|
|
||||||
* pg_filedump.c, .h: Update version and copyright date.
|
|
||||||
|
|
||||||
2003-09-29 Patrick Macdonald <patrickm@redhat.com>
|
|
||||||
|
|
||||||
* pg_filedump.c (GetSpecialSectionType): Distinguish between btree and
|
|
||||||
hash index pages using the hasho_filler field.
|
|
||||||
(FormatHeader): Verify index page header is btree before dumping meta
|
|
||||||
data.
|
|
||||||
(FormatSpecial): Format index areas based on precalculated special
|
|
||||||
section type.
|
|
||||||
* pg_filedump.h: Add distinct index special section types.
|
|
||||||
|
|
||||||
2003-05-30 Patrick Macdonald <patrickm@redhat.com>
|
|
||||||
|
|
||||||
* pg_filedump.c: Bumped version up to 3.0.
|
|
||||||
|
|
||||||
2003-04-17 Patrick Macdonald <patrickm@redhat.com>
|
|
||||||
|
|
||||||
* pg_filedump.c (DisplayOptions): Update version and copyright
|
|
||||||
date.
|
|
||||||
(FormatHeader): Display btree meta data as part of the header
|
|
||||||
if this is a btree meta page.
|
|
||||||
(FormatItem): Remove older version defines.
|
|
||||||
(FormatSpecial): Add new btree defines.
|
|
||||||
(FormatControl): Remove older version defines.
|
|
||||||
* pg_filedump.h: Update version and copyright date, remove older
|
|
||||||
version structure defines.
|
|
||||||
|
|
||||||
2003-04-17 Patrick Macdonald <patrickm@redhat.com>
|
|
||||||
|
|
||||||
* pg_filedump.c: Updated header, copyright and indentation.
|
|
||||||
* pg_filedump.h: ditto.
|
|
||||||
|
|
||||||
2002-12-18 Patrick Macdonald <patrickm@redhat.com>
|
|
||||||
|
|
||||||
* pg_filedump.c: Version 1.1 of the tool, moved
|
|
||||||
declarations to proper header,
|
|
||||||
(GetBlockSize): Cache block size locally,
|
|
||||||
(CreateDumpFileHeader): Increment the release minor,
|
|
||||||
(FormatHeader): Add block version number to output,
|
|
||||||
(FormatItem): Support new heap tuple layout,
|
|
||||||
(FormatControl): Support additional entries in the
|
|
||||||
control file.
|
|
||||||
* pg_filedump.h: New file.
|
|
||||||
* README.pg_filedump: Updated for version control.
|
|
||||||
|
|
||||||
2002-10-16 Patrick Macdonald <patrickm@redhat.com>
|
|
||||||
|
|
||||||
* rhdb-utils.build: Updated branch level.
|
|
||||||
|
|
||||||
2002-09-24 Andrew Overholt <overholt@redhat.com>
|
|
||||||
|
|
||||||
* rhdb-utils.build: Change cvsroot to reflect new server.
|
|
||||||
|
|
||||||
2002-09-11 Andrew Overholt <overholt@redhat.com>
|
|
||||||
|
|
||||||
* rhdb-utils.spec: Change release number to 1.
|
|
||||||
|
|
||||||
2002-07-29 Liam Stewart <liams@redhat.com>
|
|
||||||
|
|
||||||
* rhdb-utils.build: Tightened the cvs module so checkouts don't
|
|
||||||
take forever.
|
|
||||||
(get_cvs): Checkout instead of export.
|
|
||||||
(build): Call build_srpm to build SRPM.
|
|
||||||
|
|
||||||
2002-07-10 Liam Stewart <liams@redhat.com>
|
|
||||||
|
|
||||||
* rhdb-utils.build (build): Use rpmbuild instead of rpm; ignore
|
|
||||||
dependencies.
|
|
||||||
|
|
||||||
2002-07-08 Liam Stewart <liams@redhat.com>
|
|
||||||
|
|
||||||
* rhdb-utils.spec: Updated summary and description text. Bumped
|
|
||||||
release.
|
|
||||||
|
|
||||||
2002-07-04 Liam Stewart <liams@redhat.com>
|
|
||||||
|
|
||||||
* rhdb-utils.build: $download -> $downloaddir
|
|
||||||
* rhdb-utils.spec: New file.
|
|
||||||
* rhdb-utils.build: New file.
|
|
||||||
* rpm-extras/pg_filedump-crc.patch: New file.
|
|
||||||
* rpm-extras/pg_filedump-make.patch: New file.
|
|
||||||
|
|
||||||
2002-03-08 Patrick Macdonald <patrickm@redhat.com>
|
|
||||||
|
|
||||||
* pg_filedump.c (FormatItem): Remove EXTENDED,
|
|
||||||
add XMAX_COMMITED and XMAX_INVALID, add proper
|
|
||||||
t_bits[] processing, fix typo.
|
|
||||||
* Makefile.contrib: New file.
|
|
||||||
|
|
||||||
2002-03-04 Patrick Macdonald <patrickm@redhat.com>
|
|
||||||
|
|
||||||
* README.pg_filedump: sources merge.
|
|
||||||
|
|
||||||
2002-02-04 Patrick Macdonald <patrickm@redhat.com>
|
|
||||||
|
|
||||||
* pg_filedump.c: Add macro to set options and
|
|
||||||
flag duplicates, move copyright out of the
|
|
||||||
header block, use MAXALIGN when determining
|
|
||||||
special section size
|
|
||||||
* README.pg_filedump: New file.
|
|
||||||
|
|
||||||
2002-02-01 Patrick Macdonald <patrickm@redhat.com>
|
|
||||||
|
|
||||||
* pg_filedump.c: Alter copyright info to GPL.
|
|
||||||
* pg_filedump.c: Minor tweaks to printf() formatting,
|
|
||||||
(FormatItem): Add new parameter to receive the
|
|
||||||
formatting method.
|
|
||||||
(FormatItemBlock): Determine and pass the format
|
|
||||||
method to FormatItem().
|
|
||||||
|
|
||||||
2002-01-30 Patrick Macdonald <patrickm@redhat.com>
|
|
||||||
|
|
||||||
* pg_filedump.c: Added -B to valid control file
|
|
||||||
dump options.
|
|
||||||
* Makefile: Add -Wmissing-prototypes and
|
|
||||||
-Wmissing-declarations.
|
|
||||||
|
|
||||||
2002-01-29 Patrick Macdonald <patrickm@redhat.com>
|
|
||||||
|
|
||||||
* pg_filedump.c: Renamed from pgfiledump.c
|
|
||||||
|
|
||||||
2002-01-29 Patrick Macdonald <patrickm@redhat.com>
|
|
||||||
|
|
||||||
* pgfiledump.c: Scrubbed the code, added support
|
|
||||||
for CRC checking, improved readability, fixed
|
|
||||||
unsigned vs signed problems.
|
|
||||||
* Makefile: Added pg_crc.c to support CRC checks.
|
|
||||||
|
|
||||||
2002-01-28 Patrick Macdonald <patrickm@redhat.com>
|
|
||||||
|
|
||||||
* pgfiledump.c: Added FormatControl() to support
|
|
||||||
dumping of the PostgreSQL control file.
|
|
||||||
|
|
||||||
2002-01-25 Patrick Macdonald <patrickm@redhat.com>
|
|
||||||
|
|
||||||
* Makefile, pgfiledump.c: New file.
|
|
32
Makefile
32
Makefile
@ -1,26 +1,36 @@
|
|||||||
# View README.pg_filedump first
|
# View README.pg_filedump first
|
||||||
|
|
||||||
|
# note this must match version macros in pg_filedump.h
|
||||||
|
FD_VERSION=9.6.0
|
||||||
|
|
||||||
CC=gcc
|
CC=gcc
|
||||||
CFLAGS=-g -O -Wall -Wmissing-prototypes -Wmissing-declarations
|
CFLAGS=-g -O -Wall -Wmissing-prototypes -Wmissing-declarations
|
||||||
|
|
||||||
INCLUDE=/usr/include/pgsql/server
|
# 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_INCLUDE_DIR=$(shell $(PG_CONFIG) --includedir-server)
|
||||||
|
PGSQL_LIB_DIR=$(shell $(PG_CONFIG) --libdir)
|
||||||
|
|
||||||
# PGSQL MUST POINT TO pgsql SOURCE DIRECTORY
|
|
||||||
PGSQL=../../../../postgres/pgsql
|
|
||||||
|
|
||||||
CRC_SRC=${PGSQL}/src/backend/utils/hash
|
DISTFILES= README.pg_filedump Makefile Makefile.contrib \
|
||||||
CRC_INCLUDE=${PGSQL}/src
|
pg_filedump.h pg_filedump.c
|
||||||
|
|
||||||
all: pg_filedump
|
all: pg_filedump
|
||||||
|
|
||||||
pg_filedump: pg_filedump.o pg_crc.o
|
pg_filedump: pg_filedump.o
|
||||||
${CC} ${CFLAGS} -o pg_filedump pg_filedump.o pg_crc.o
|
${CC} ${LDFLAGS} -o pg_filedump pg_filedump.o -L${PGSQL_LIB_DIR} -lpgport
|
||||||
|
|
||||||
pg_filedump.o: pg_filedump.c
|
pg_filedump.o: pg_filedump.c
|
||||||
${CC} ${CFLAGS} -I${INCLUDE} pg_filedump.c -c
|
${CC} ${CFLAGS} -I${PGSQL_INCLUDE_DIR} pg_filedump.c -c
|
||||||
|
|
||||||
pg_crc.o: ${CRC_SRC}/pg_crc.c
|
dist:
|
||||||
${CC} ${CFLAGS} -I${CRC_INCLUDE} -I${INCLUDE} ${CRC_SRC}/pg_crc.c -c
|
rm -rf pg_filedump-${FD_VERSION} pg_filedump-${FD_VERSION}.tar.gz
|
||||||
|
mkdir pg_filedump-${FD_VERSION}
|
||||||
|
cp -p ${DISTFILES} pg_filedump-${FD_VERSION}
|
||||||
|
tar cfz pg_filedump-${FD_VERSION}.tar.gz pg_filedump-${FD_VERSION}
|
||||||
|
rm -rf pg_filedump-${FD_VERSION}
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf *.o pg_filedump
|
rm -f *.o pg_filedump
|
||||||
|
@ -1,20 +1,15 @@
|
|||||||
PROGRAM = pg_filedump
|
PROGRAM = pg_filedump
|
||||||
OBJS = pg_filedump.o pg_crc.o
|
OBJS = pg_filedump.o
|
||||||
|
|
||||||
EXTRA_CLEAN = pg_crc.c
|
|
||||||
|
|
||||||
DOCS = README.pg_filedump
|
DOCS = README.pg_filedump
|
||||||
|
|
||||||
ifdef USE_PGXS
|
ifdef USE_PGXS
|
||||||
PG_CONFIG = pg_config
|
PG_CONFIG = pg_config
|
||||||
PGXS := $(shell $(PG_CONFIG) --pgxs)
|
PGXS := $(shell $(PG_CONFIG) --pgxs)
|
||||||
include $(PGXS)
|
include $(PGXS)
|
||||||
else
|
else
|
||||||
subdir = contrib/pg_filedump
|
subdir = contrib/pg_filedump
|
||||||
top_builddir = ../..
|
top_builddir = ../..
|
||||||
include $(top_builddir)/src/Makefile.global
|
include $(top_builddir)/src/Makefile.global
|
||||||
include $(top_srcdir)/contrib/contrib-global.mk
|
include $(top_srcdir)/contrib/contrib-global.mk
|
||||||
endif
|
endif
|
||||||
|
|
||||||
pg_crc.c: $(top_srcdir)/src/backend/utils/hash/pg_crc.c
|
|
||||||
rm -f $@ && $(LN_S) $< .
|
|
||||||
|
@ -1,19 +1,20 @@
|
|||||||
pg_filedump - Display formatted contents of a PostgreSQL heap/index/control
|
pg_filedump - Display formatted contents of a PostgreSQL heap, index,
|
||||||
file.
|
or control file.
|
||||||
|
|
||||||
Copyright (c) 2002-2010 Red Hat, Inc.
|
Copyright (c) 2002-2010 Red Hat, Inc.
|
||||||
|
Copyright (c) 2011-2016, PostgreSQL Global Development Group
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
Author: Patrick Macdonald <patrickm@redhat.com>
|
Original Author: Patrick Macdonald <patrickm@redhat.com>
|
||||||
|
|
||||||
Version: 9.0.0
|
|
||||||
|
|
||||||
Overview:
|
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
|
Overview:
|
||||||
|
|
||||||
pg_filedump is a utility to format PostgreSQL heap/index/control files
|
pg_filedump is a utility to format PostgreSQL heap/index/control files
|
||||||
into a human-readable form. You can format/dump the files several ways,
|
into a human-readable form. You can format/dump the files several ways,
|
||||||
as listed in the Invocation section, as well as dumping straight binary.
|
as listed in the Invocation section, as well as dumping straight binary.
|
||||||
@ -22,64 +23,43 @@ The type of file (heap/index) can usually be determined automatically
|
|||||||
by the content of the blocks within the file. However, to format a
|
by the content of the blocks within the file. However, to format a
|
||||||
pg_control file you must use the -c option.
|
pg_control file you must use the -c option.
|
||||||
|
|
||||||
The default is to format the entire file using the block size listed on
|
The default is to format the entire file using the block size listed in
|
||||||
block 0 (heap/index files) and display block relative addresses. These
|
block 0 and display block relative addresses. These defaults can be
|
||||||
defaults can be modified using run-time options.
|
modified using run-time options.
|
||||||
|
|
||||||
Some options may seem strange but they're there for a reason. For
|
Some options may seem strange but they're there for a reason. For
|
||||||
example, block size. It's there because if the header of block 0 is
|
example, block size. It's there because if the header of block 0 is
|
||||||
corrupt, you need a method of forcing a block size.
|
corrupt, you need a method of forcing a block size.
|
||||||
|
|
||||||
|
|
||||||
Release Notes / Databases Supported
|
|
||||||
-----------------------------------------------------------------------
|
|
||||||
V9.0.0 Must be compiled against a PostgreSQL 9.0 installation.
|
|
||||||
Supports: PostgreSQL 9.0.x
|
|
||||||
|
|
||||||
V8.4.0 Must be compiled against a PostgreSQL 8.4 installation.
|
|
||||||
Supports: PostgreSQL 8.4.x
|
|
||||||
|
|
||||||
V8.3.0 Must be compiled against a PostgreSQL 8.3 installation.
|
|
||||||
Supports: PostgreSQL 8.3.x
|
|
||||||
|
|
||||||
V8.2.0 Must be compiled against a PostgreSQL 8.2 installation.
|
|
||||||
Supports: PostgreSQL 8.2.x
|
|
||||||
|
|
||||||
V8.1.1 Must be compiled against a PostgreSQL 8.1 installation.
|
|
||||||
Supports: PostgreSQL 8.1.x
|
|
||||||
|
|
||||||
V4.0 Must be compiled against a PostgreSQL 8.0 installation.
|
|
||||||
Supports: PostgreSQL 8.0.x
|
|
||||||
|
|
||||||
V3.0 Must be compiled against a PostgreSQL 7.4 installation.
|
|
||||||
Supports: PostgreSQL 7.4.x
|
|
||||||
|
|
||||||
V2.0 Must be compiled against a PostgreSQL 7.3 installation.
|
|
||||||
Supports: PostgreSQL - Red Hat Edition 3.0,
|
|
||||||
Red Hat Database 2.x, Red Hat Database 1.x
|
|
||||||
PostgreSQL 7.3.x, PostgreSQL 7.2.x, PostgreSQL 7.1.x
|
|
||||||
|
|
||||||
V1.0 Must be compiled against a PostgreSQL 7.1 or PostgreSQL 7.2
|
|
||||||
installation.
|
|
||||||
Supports: Red Hat Database 2.x, Red Hat Database 1.x
|
|
||||||
PostgreSQL 7.2.x, PostgreSQL 7.1.x
|
|
||||||
|
|
||||||
|
|
||||||
Compile/Installation:
|
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
There are two makefiles included in this package. Makefile is a
|
Compile/Installation:
|
||||||
standalone makefile for pg_filedump. Alter the include and src
|
|
||||||
variables to point to the proper directories. Makefile.contrib can be
|
To compile pg_filedump, you will need to have a properly configured
|
||||||
used if the package was untarred in the contrib directory of a
|
PostgreSQL source tree or complete install tree (with include files)
|
||||||
PostgreSQL build tree.
|
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
|
||||||
|
was untarred in the contrib directory of a PostgreSQL build tree.
|
||||||
|
|
||||||
make
|
make
|
||||||
make install (if in the contrib directory)
|
make install (if using Makefile.contrib)
|
||||||
|
|
||||||
|
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
|
||||||
|
not require any manual adjustments of the Makefile.
|
||||||
|
|
||||||
|
|
||||||
Invocation:
|
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
pg_filedump [-abcdfhixy] [-R startblock [endblock]] [-S blocksize] file
|
Invocation:
|
||||||
|
|
||||||
|
pg_filedump [-abcdfhikxy] [-R startblock [endblock]] [-S blocksize] [-s segsize] [-n segnumber] file
|
||||||
|
|
||||||
Defaults are: relative addressing, range of the entire file, block size
|
Defaults are: relative addressing, range of the entire file, block size
|
||||||
as listed on block 0 in the file
|
as listed on block 0 in the file
|
||||||
@ -94,11 +74,14 @@ The following options are valid for heap and index files:
|
|||||||
-f Display formatted block content dump along with interpretation
|
-f Display formatted block content dump along with interpretation
|
||||||
-h Display this information
|
-h Display this information
|
||||||
-i Display interpreted item details
|
-i Display interpreted item details
|
||||||
|
-k Verify block checksums
|
||||||
-R Display specific block ranges within the file (Blocks are
|
-R Display specific block ranges within the file (Blocks are
|
||||||
indexed from 0)
|
indexed from 0)
|
||||||
[startblock]: block to start at
|
[startblock]: block to start at
|
||||||
[endblock]: block to end at
|
[endblock]: block to end at
|
||||||
A startblock without an endblock will format the single block
|
A startblock without an endblock will format the single block
|
||||||
|
-s Force segment size to [segsize]
|
||||||
|
-n Force segment number to [segnumber]
|
||||||
-S Force block size to [blocksize]
|
-S Force block size to [blocksize]
|
||||||
-x Force interpreted formatting of block items as index items
|
-x Force interpreted formatting of block items as index items
|
||||||
-y Force interpreted formatting of block items as heap items
|
-y Force interpreted formatting of block items as heap items
|
||||||
@ -107,3 +90,6 @@ The following options are valid for control files:
|
|||||||
-c Interpret the file listed as a control file
|
-c Interpret the file listed as a control file
|
||||||
-f Display formatted content dump along with interpretation
|
-f Display formatted content dump along with interpretation
|
||||||
-S Force block size to [blocksize]
|
-S Force block size to [blocksize]
|
||||||
|
|
||||||
|
In most cases it's recommended to use the -i and -f options to get
|
||||||
|
the most useful dump output.
|
||||||
|
1332
pg_filedump.c
1332
pg_filedump.c
File diff suppressed because it is too large
Load Diff
155
pg_filedump.h
155
pg_filedump.h
@ -1,9 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
* pg_filedump.h - PostgreSQL file dump utility for dumping and
|
* pg_filedump.h - PostgreSQL file dump utility for dumping and
|
||||||
* formatting heap (data), index and control files.
|
* formatting heap (data), index and control files.
|
||||||
* Version 9.0.0 for PostgreSQL 9.0
|
|
||||||
*
|
*
|
||||||
* Copyright (c) 2002-2010 Red Hat, Inc. All rights reserved.
|
* Copyright (c) 2002-2010 Red Hat, Inc.
|
||||||
|
* Copyright (c) 2011-2016, PostgreSQL Global Development Group
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -19,92 +19,109 @@
|
|||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*
|
*
|
||||||
* Author: Patrick Macdonald <patrickm@redhat.com>
|
* Original Author: Patrick Macdonald <patrickm@redhat.com>
|
||||||
*
|
|
||||||
* Component of: PostgreSQL - Red Hat Edition - Utilities / Tools
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#define FD_VERSION "9.6.0" /* version ID of pg_filedump */
|
||||||
|
#define FD_PG_VERSION "PostgreSQL 9.6.x" /* PG version it works with */
|
||||||
|
|
||||||
|
#include "postgres.h"
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "postgres.h"
|
#include "access/gin_private.h"
|
||||||
#include "storage/bufpage.h"
|
|
||||||
#include "access/hash.h"
|
|
||||||
#include "access/gin.h"
|
|
||||||
#include "access/gist.h"
|
#include "access/gist.h"
|
||||||
#include "access/nbtree.h"
|
#include "access/hash.h"
|
||||||
#include "access/itup.h"
|
|
||||||
#include "access/htup.h"
|
#include "access/htup.h"
|
||||||
|
#include "access/htup_details.h"
|
||||||
|
#include "access/itup.h"
|
||||||
|
#include "access/nbtree.h"
|
||||||
|
#include "access/spgist_private.h"
|
||||||
#include "catalog/pg_control.h"
|
#include "catalog/pg_control.h"
|
||||||
|
#include "storage/bufpage.h"
|
||||||
|
|
||||||
// Options for Block formatting operations
|
/* Options for Block formatting operations */
|
||||||
static unsigned int blockOptions = 0;
|
static unsigned int blockOptions = 0;
|
||||||
typedef enum
|
|
||||||
|
typedef enum blockSwitches
|
||||||
{
|
{
|
||||||
BLOCK_ABSOLUTE = 0x00000001, // -a: Absolute (vs Relative) addressing
|
BLOCK_ABSOLUTE = 0x00000001, /* -a: Absolute(vs Relative) addressing */
|
||||||
BLOCK_BINARY = 0x00000002, // -b: Binary dump of block
|
BLOCK_BINARY = 0x00000002, /* -b: Binary dump of block */
|
||||||
BLOCK_FORMAT = 0x00000004, // -f: Formatted dump of blocks / control file
|
BLOCK_FORMAT = 0x00000004, /* -f: Formatted dump of blocks / control file */
|
||||||
BLOCK_FORCED = 0x00000008, // -S: Block size forced
|
BLOCK_FORCED = 0x00000008, /* -S: Block size forced */
|
||||||
BLOCK_NO_INTR = 0x00000010, // -d: Dump straight blocks
|
BLOCK_NO_INTR = 0x00000010, /* -d: Dump straight blocks */
|
||||||
BLOCK_RANGE = 0x00000020 // -R: Specific block range to dump
|
BLOCK_RANGE = 0x00000020, /* -R: Specific block range to dump */
|
||||||
}
|
BLOCK_CHECKSUMS = 0x00000040 /* -k: verify block checksums */
|
||||||
blockSwitches;
|
} blockSwitches;
|
||||||
|
|
||||||
static int blockStart = -1; // -R [start]: Block range start
|
/* Segment-related options */
|
||||||
static int blockEnd = -1; // -R [end]: Block range end
|
static unsigned int segmentOptions = 0;
|
||||||
|
|
||||||
// Options for Item formatting operations
|
typedef enum segmentSwitches
|
||||||
|
{
|
||||||
|
SEGMENT_SIZE_FORCED = 0x00000001, /* -s: Segment size forced */
|
||||||
|
SEGMENT_NUMBER_FORCED = 0x00000002, /* -n: Segment number forced */
|
||||||
|
} segmentSwitches;
|
||||||
|
|
||||||
|
/* -R[start]:Block range start */
|
||||||
|
static int blockStart = -1;
|
||||||
|
|
||||||
|
/* -R[end]:Block range end */
|
||||||
|
static int blockEnd = -1;
|
||||||
|
|
||||||
|
/* Options for Item formatting operations */
|
||||||
static unsigned int itemOptions = 0;
|
static unsigned int itemOptions = 0;
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
ITEM_DETAIL = 0x00000001, // -i: Display interpreted items
|
|
||||||
ITEM_HEAP = 0x00000002, // -y: Blocks contain heap items
|
|
||||||
ITEM_INDEX = 0x00000004 // -x: Blocks contain index items
|
|
||||||
}
|
|
||||||
itemSwitches;
|
|
||||||
|
|
||||||
// Options for Control File formatting operations
|
typedef enum itemSwitches
|
||||||
|
{
|
||||||
|
ITEM_DETAIL = 0x00000001, /* -i: Display interpreted items */
|
||||||
|
ITEM_HEAP = 0x00000002, /* -y: Blocks contain HeapTuple items */
|
||||||
|
ITEM_INDEX = 0x00000004, /* -x: Blocks contain IndexTuple items */
|
||||||
|
ITEM_SPG_INNER = 0x00000008, /* Blocks contain SpGistInnerTuple items */
|
||||||
|
ITEM_SPG_LEAF = 0x00000010 /* Blocks contain SpGistLeafTuple items */
|
||||||
|
} itemSwitches;
|
||||||
|
|
||||||
|
/* Options for Control File formatting operations */
|
||||||
static unsigned int controlOptions = 0;
|
static unsigned int controlOptions = 0;
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
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
|
|
||||||
}
|
|
||||||
controlSwitches;
|
|
||||||
|
|
||||||
// Possible value types for the Special Section
|
typedef enum controlSwitches
|
||||||
typedef enum
|
|
||||||
{
|
{
|
||||||
SPEC_SECT_NONE, // No special section on block
|
CONTROL_DUMP = 0x00000001, /* -c: Dump control file */
|
||||||
SPEC_SECT_SEQUENCE, // Sequence info in special section
|
CONTROL_FORMAT = BLOCK_FORMAT, /* -f: Formatted dump of control file */
|
||||||
SPEC_SECT_INDEX_BTREE, // BTree index info in special section
|
CONTROL_FORCED = BLOCK_FORCED /* -S: Block size forced */
|
||||||
SPEC_SECT_INDEX_HASH, // Hash index info in special section
|
} controlSwitches;
|
||||||
SPEC_SECT_INDEX_GIST, // GIST index info in special section
|
|
||||||
SPEC_SECT_INDEX_GIN, // GIN index info in special section
|
/* Possible value types for the Special Section */
|
||||||
SPEC_SECT_ERROR_UNKNOWN, // Unknown error
|
typedef enum specialSectionTypes
|
||||||
SPEC_SECT_ERROR_BOUNDARY // Boundary error
|
{
|
||||||
}
|
SPEC_SECT_NONE, /* No special section on block */
|
||||||
specialSectionTypes;
|
SPEC_SECT_SEQUENCE, /* Sequence info in special section */
|
||||||
|
SPEC_SECT_INDEX_BTREE, /* BTree index info in special section */
|
||||||
|
SPEC_SECT_INDEX_HASH, /* Hash index info in special section */
|
||||||
|
SPEC_SECT_INDEX_GIST, /* GIST index info in special section */
|
||||||
|
SPEC_SECT_INDEX_GIN, /* GIN index info in special section */
|
||||||
|
SPEC_SECT_INDEX_SPGIST, /* SP - GIST index info in special section */
|
||||||
|
SPEC_SECT_ERROR_UNKNOWN, /* Unknown error */
|
||||||
|
SPEC_SECT_ERROR_BOUNDARY /* Boundary error */
|
||||||
|
} specialSectionTypes;
|
||||||
|
|
||||||
static unsigned int specialType = SPEC_SECT_NONE;
|
static unsigned int specialType = SPEC_SECT_NONE;
|
||||||
|
|
||||||
// Possible return codes from option validation routine.
|
/* Possible return codes from option validation routine. */
|
||||||
// pg_filedump doesn't do much with them now but maybe in
|
/* pg_filedump doesn't do much with them now but maybe in */
|
||||||
// the future...
|
/* the future... */
|
||||||
typedef enum
|
typedef enum optionReturnCodes
|
||||||
{
|
{
|
||||||
OPT_RC_VALID, // All options are valid
|
OPT_RC_VALID, /* All options are valid */
|
||||||
OPT_RC_INVALID, // Improper option string
|
OPT_RC_INVALID, /* Improper option string */
|
||||||
OPT_RC_FILE, // File problems
|
OPT_RC_FILE, /* File problems */
|
||||||
OPT_RC_DUPLICATE, // Duplicate option encountered
|
OPT_RC_DUPLICATE, /* Duplicate option encountered */
|
||||||
OPT_RC_COPYRIGHT // Copyright should be displayed
|
OPT_RC_COPYRIGHT /* Copyright should be displayed */
|
||||||
}
|
} optionReturnCodes;
|
||||||
optionReturnCodes;
|
|
||||||
|
|
||||||
// Simple macro to check for duplicate options and then set
|
/* Simple macro to check for duplicate options and then set */
|
||||||
// an option flag for later consumption
|
/* an option flag for later consumption */
|
||||||
#define SET_OPTION(_x,_y,_z) if (_x & _y) \
|
#define SET_OPTION(_x,_y,_z) if (_x & _y) \
|
||||||
{ \
|
{ \
|
||||||
rc = OPT_RC_DUPLICATE; \
|
rc = OPT_RC_DUPLICATE; \
|
||||||
@ -113,6 +130,6 @@ optionReturnCodes;
|
|||||||
else \
|
else \
|
||||||
_x |= _y;
|
_x |= _y;
|
||||||
|
|
||||||
#define SEQUENCE_MAGIC 0x1717 // PostgreSQL defined magic number
|
#define SEQUENCE_MAGIC 0x1717 /* PostgreSQL defined magic number */
|
||||||
#define EOF_ENCOUNTERED (-1) // Indicator for partial read
|
#define EOF_ENCOUNTERED (-1) /* Indicator for partial read */
|
||||||
#define BYTES_PER_LINE 16 // Format the binary 16 bytes per line
|
#define BYTES_PER_LINE 16 /* Format the binary 16 bytes per line */
|
||||||
|
Reference in New Issue
Block a user