diff --git a/ChangeLog b/ChangeLog deleted file mode 100644 index 7357c6f..0000000 --- a/ChangeLog +++ /dev/null @@ -1,174 +0,0 @@ -2010-12-29 Tom Lane - - * 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 - - * 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 - - * 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 - - * 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 - - * 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 - - * 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 - - * 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 - - * pg_filedump.c: Bumped version up to 3.0. - -2003-04-17 Patrick Macdonald - - * 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 - - * pg_filedump.c: Updated header, copyright and indentation. - * pg_filedump.h: ditto. - -2002-12-18 Patrick Macdonald - - * 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 - - * rhdb-utils.build: Updated branch level. - -2002-09-24 Andrew Overholt - - * rhdb-utils.build: Change cvsroot to reflect new server. - -2002-09-11 Andrew Overholt - - * rhdb-utils.spec: Change release number to 1. - -2002-07-29 Liam Stewart - - * 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 - - * rhdb-utils.build (build): Use rpmbuild instead of rpm; ignore - dependencies. - -2002-07-08 Liam Stewart - - * rhdb-utils.spec: Updated summary and description text. Bumped - release. - -2002-07-04 Liam Stewart - - * 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 - - * 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 - - * README.pg_filedump: sources merge. - -2002-02-04 Patrick Macdonald - - * 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 - - * 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 - - * pg_filedump.c: Added -B to valid control file - dump options. - * Makefile: Add -Wmissing-prototypes and - -Wmissing-declarations. - -2002-01-29 Patrick Macdonald - - * pg_filedump.c: Renamed from pgfiledump.c - -2002-01-29 Patrick Macdonald - - * 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 - - * pgfiledump.c: Added FormatControl() to support - dumping of the PostgreSQL control file. - -2002-01-25 Patrick Macdonald - - * Makefile, pgfiledump.c: New file. diff --git a/Makefile b/Makefile index d1cdb54..429971b 100644 --- a/Makefile +++ b/Makefile @@ -3,13 +3,12 @@ CC=gcc CFLAGS=-g -O -Wall -Wmissing-prototypes -Wmissing-declarations -INCLUDE=/usr/include/pgsql/server - # PGSQL MUST POINT TO pgsql SOURCE DIRECTORY -PGSQL=../../../../postgres/pgsql +PGSQL=../../pgsql -CRC_SRC=${PGSQL}/src/backend/utils/hash -CRC_INCLUDE=${PGSQL}/src +CRC_SRC_DIR=${PGSQL}/src/backend/utils/hash + +INCLUDE_DIR=${PGSQL}/src/include all: pg_filedump @@ -17,10 +16,10 @@ pg_filedump: pg_filedump.o pg_crc.o ${CC} ${CFLAGS} -o pg_filedump pg_filedump.o pg_crc.o pg_filedump.o: pg_filedump.c - ${CC} ${CFLAGS} -I${INCLUDE} pg_filedump.c -c + ${CC} ${CFLAGS} -I${INCLUDE_DIR} pg_filedump.c -c -pg_crc.o: ${CRC_SRC}/pg_crc.c - ${CC} ${CFLAGS} -I${CRC_INCLUDE} -I${INCLUDE} ${CRC_SRC}/pg_crc.c -c +pg_crc.o: ${CRC_SRC_DIR}/pg_crc.c + ${CC} ${CFLAGS} -I${INCLUDE_DIR} ${CRC_SRC_DIR}/pg_crc.c -c clean: - rm -rf *.o pg_filedump + rm -f *.o pg_filedump diff --git a/README.pg_filedump b/README.pg_filedump index 6a15fca..97127cf 100644 --- a/README.pg_filedump +++ b/README.pg_filedump @@ -1,20 +1,21 @@ -pg_filedump - Display formatted contents of a PostgreSQL heap/index/control - file. +pg_filedump - Display formatted contents of a PostgreSQL heap, index, + or control file. Copyright (c) 2002-2010 Red Hat, Inc. +Copyright (c) 2011, 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 the Free Software Foundation; either version 2 of the License, or (at your option) any later version. -Author: Patrick Macdonald +Original Author: Patrick Macdonald -Version: 9.0.0 -Overview: ------------------------------------------------------------------------ -pg_filedump is a utility to format PostgreSQL heap/index/control files +Overview: + +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, as listed in the Invocation section, as well as dumping straight binary. @@ -22,63 +23,40 @@ The type of file (heap/index) can usually be determined automatically by the content of the blocks within the file. However, to format a pg_control file you must use the -c option. -The default is to format the entire file using the block size listed on -block 0 (heap/index files) and display block relative addresses. These -defaults can be modified using run-time options. +The default is to format the entire file using the block size listed in +block 0 and display block relative addresses. These defaults can be +modified using run-time options. 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 -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: ------------------------------------------------------------------------ +Compile/Installation: + +To compile pg_filedump, you will need to have a properly configured +PostgreSQL source tree for the appropriate PostgreSQL major version. + There are two makefiles included in this package. Makefile is a -standalone makefile for pg_filedump. Alter the include and src -variables to point to the proper directories. Makefile.contrib can be -used if the package was untarred in the contrib directory of a -PostgreSQL build tree. +standalone makefile for pg_filedump. Alter the PGSQL variable to point +to the PostgreSQL source tree. Makefile.contrib can be used if this +package was untarred in the contrib directory of a PostgreSQL build tree. make make install (if in the contrib directory) +It is also possible to use Makefile.contrib without being in the contrib +directory: + make -f Makefile.contrib USE_PGXS=1 + +This will not eliminate the need to have a complete source tree, though. + + +------------------------------------------------------------------------ Invocation: ------------------------------------------------------------------------- + pg_filedump [-abcdfhixy] [-R startblock [endblock]] [-S blocksize] file Defaults are: relative addressing, range of the entire file, block size diff --git a/pg_filedump.c b/pg_filedump.c index 9cacdbe..02222c5 100644 --- a/pg_filedump.c +++ b/pg_filedump.c @@ -1,9 +1,9 @@ /* * pg_filedump.c - PostgreSQL file dump utility for dumping and * 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, 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 @@ -19,10 +19,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * Author: Patrick Macdonald - * - * Component of: PostgreSQL - Red Hat Edition - Utilities / Tools - * + * Original Author: Patrick Macdonald */ #include "pg_filedump.h" @@ -63,12 +60,15 @@ DisplayOptions (unsigned int validOptions) { if (validOptions == OPT_RC_COPYRIGHT) printf - ("\nVersion 9.0.0 (PostgreSQL 9.0) Copyright (c) 2002-2010 Red Hat, Inc.\n"); + ("\nVersion %s (for %s)" + "\nCopyright (c) 2002-2010 Red Hat, Inc." + "\nCopyright (c) 2011, PostgreSQL Global Development Group\n", + FD_VERSION, FD_PG_VERSION); printf ("\nUsage: pg_filedump [-abcdfhixy] [-R startblock [endblock]] [-S blocksize] file\n\n" "Display formatted contents of a PostgreSQL heap/index/control file\n" - " Defaults are: relative addressing, range of the entire file, block\n" + "Defaults are: relative addressing, range of the entire file, block\n" " size as listed on block 0 in the file\n\n" "The following options are valid for heap and index files:\n" " -a Display absolute addresses when formatting (Block header\n" @@ -91,7 +91,7 @@ DisplayOptions (unsigned int validOptions) " -c Interpret the file listed as a control file\n" " -f Display formatted content dump along with interpretation\n" " -S Force block size to [blocksize]\n" - "\nReport bugs to \n"); + "\nReport bugs to \n"); } // Iterate through the provided options and set the option flags. @@ -528,12 +528,13 @@ CreateDumpFileHeader (int numOptions, char **options) printf ("\n*******************************************************************\n" - "* PostgreSQL File/Block Formatted Dump Utility - Version 9.0.0\n*\n" + "* PostgreSQL File/Block Formatted Dump Utility - Version %s\n" + "*\n" "* File: %s\n" "* Options used: %s\n*\n" "* Dump created on: %s" "*******************************************************************\n", - fileName, (strlen (optionBuffer)) ? optionBuffer : "None", + FD_VERSION, fileName, (strlen (optionBuffer)) ? optionBuffer : "None", ctime (&rightNow)); } diff --git a/pg_filedump.h b/pg_filedump.h index e0cb19c..4defde8 100644 --- a/pg_filedump.h +++ b/pg_filedump.h @@ -1,9 +1,9 @@ /* * pg_filedump.h - PostgreSQL file dump utility for dumping and * 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, 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 @@ -19,25 +19,25 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * Author: Patrick Macdonald - * - * Component of: PostgreSQL - Red Hat Edition - Utilities / Tools - * + * Original Author: Patrick Macdonald */ -#include +#define FD_VERSION "9.0.0" /* version ID of pg_filedump */ +#define FD_PG_VERSION "PostgreSQL 9.0.x" /* PG version it works with */ + +#include "postgres.h" + #include #include -#include "postgres.h" -#include "storage/bufpage.h" -#include "access/hash.h" #include "access/gin.h" #include "access/gist.h" -#include "access/nbtree.h" -#include "access/itup.h" +#include "access/hash.h" #include "access/htup.h" +#include "access/itup.h" +#include "access/nbtree.h" #include "catalog/pg_control.h" +#include "storage/bufpage.h" // Options for Block formatting operations static unsigned int blockOptions = 0;