Commit c828ec88 authored by Peter Eisentraut's avatar Peter Eisentraut

Make pg_dump output more portable and more pleasing to look at.

The -n and -N options were removed.  Quoting is now smart enough to
supply quotes if and only if necessary.

Numerical types are now printed without quotes, except in cases of
special values such as NaN.

Boolean values printed as true and false.

Most string literals now do not escape whitespace characters (newlines,
etc.) for portability.

SET SESSION AUTHORIZATION argument is a string literal, to follow SQL.

Made commands output by pg_dump use consistent spacing and indentation.
parent 41298cf8
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/pg_dump.sgml,v 1.47 2002/08/10 16:57:31 petere Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/ref/pg_dump.sgml,v 1.48 2002/08/18 09:36:25 petere Exp $
PostgreSQL documentation
-->
......@@ -29,7 +29,6 @@ PostgreSQL documentation
<arg>-f <replaceable>file</replaceable></arg>
<arg>-F <replaceable>format</replaceable></arg>
<arg>-i</arg>
<group> <arg>-n</arg> <arg>-N</arg> </group>
<arg>-o</arg>
<arg>-O</arg>
<arg>-R</arg>
......@@ -302,31 +301,6 @@ PostgreSQL documentation
</listitem>
</varlistentry>
<varlistentry>
<term><option>-n</></term>
<term><option>--no-quotes</></term>
<listitem>
<para>
Suppress double quotes around identifiers unless absolutely necessary.
This may cause trouble loading this dumped data if there are reserved words
used for identifiers.
This was the default behavior for
<command>pg_dump</command> prior to version 6.4.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-N</></term>
<term><option>--quotes</></term>
<listitem>
<para>
Include double quotes around identifiers.
This is the default.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-o</></term>
<term><option>--oids</></term>
......
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/release.sgml,v 1.146 2002/08/11 21:17:34 tgl Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/release.sgml,v 1.147 2002/08/18 09:36:25 petere Exp $
-->
<appendix id="release">
......@@ -24,6 +24,7 @@ CDATA means the content is "SGML-free", so you can write without
worries about funny characters.
-->
<literallayout><![CDATA[
pg_dump -n and -N options have been removed. The new behavior is like -n but knows about key words.
CLUSTER is no longer hazardous to your schema
COPY accepts a list of columns to copy
ALTER TABLE DROP COLUMN
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.124 2002/08/06 05:40:45 ishii Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.125 2002/08/18 09:36:25 petere Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -20,6 +20,8 @@
#include "parser/keywords.h"
#include "parser/parse.h"
/* NB: This file is also used by pg_dump. */
/*
* List of (keyword-name, keyword-token-value) pairs.
*
......
......@@ -3,7 +3,7 @@
* back to source text
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.116 2002/08/16 23:01:19 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.117 2002/08/18 09:36:25 petere Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
......@@ -2529,14 +2529,42 @@ get_const_expr(Const *constval, deparse_context *context)
{
case INT2OID:
case INT4OID:
case OIDOID: /* int types */
case INT8OID:
case OIDOID:
case FLOAT4OID:
case FLOAT8OID: /* float types */
/* These types are printed without quotes */
appendStringInfo(buf, extval);
case FLOAT8OID:
case NUMERICOID:
{
/*
* These types are printed without quotes unless they
* contain values that aren't accepted by the scanner
* unquoted (e.g., 'NaN'). Note that strtod() and friends
* might accept NaN, so we can't use that to test.
*
* In reality we only need to defend against infinity and
* NaN, so we need not get too crazy about pattern
* matching here.
*/
if (strspn(extval, "0123456789 +-eE.") == strlen(extval))
appendStringInfo(buf, extval);
else
appendStringInfo(buf, "'%s'", extval);
}
break;
case BITOID:
case VARBITOID:
appendStringInfo(buf, "B'%s'", extval);
break;
default:
case BOOLOID:
if (strcmp(extval, "t")==0)
appendStringInfo(buf, "true");
else
appendStringInfo(buf, "false");
break;
default:
/*
* We must quote any funny characters in the constant's
* representation. XXX Any MULTIBYTE considerations here?
......@@ -2564,6 +2592,7 @@ get_const_expr(Const *constval, deparse_context *context)
switch (constval->consttype)
{
case BOOLOID:
case INT4OID:
case FLOAT8OID:
case UNKNOWNOID:
......
......@@ -5,7 +5,7 @@
# Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
# Portions Copyright (c) 1994, Regents of the University of California
#
# $Header: /cvsroot/pgsql/src/bin/pg_dump/Makefile,v 1.36 2002/07/27 20:10:05 petere Exp $
# $Header: /cvsroot/pgsql/src/bin/pg_dump/Makefile,v 1.37 2002/08/18 09:36:25 petere Exp $
#
#-------------------------------------------------------------------------
......@@ -16,15 +16,18 @@ include $(top_builddir)/src/Makefile.global
OBJS= pg_backup_archiver.o pg_backup_db.o pg_backup_custom.o \
pg_backup_files.o pg_backup_null.o pg_backup_tar.o sprompt.o
EXTRA_OBJS = $(top_builddir)/src/backend/parser/keywords.o
override CPPFLAGS := -I$(libpq_srcdir) $(CPPFLAGS)
all: submake-libpq submake-libpgport pg_dump pg_restore pg_dumpall
all: submake-libpq submake-libpgport submake-backend pg_dump pg_restore pg_dumpall
pg_dump: pg_dump.o common.o $(OBJS) $(libpq_builddir)/libpq.a
$(CC) $(CFLAGS) pg_dump.o common.o $(OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@
$(CC) $(CFLAGS) pg_dump.o common.o $(OBJS) $(EXTRA_OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@
pg_restore: pg_restore.o $(OBJS) $(libpq_builddir)/libpq.a
$(CC) $(CFLAGS) pg_restore.o $(OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@
$(CC) $(CFLAGS) pg_restore.o $(OBJS) $(EXTRA_OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@
pg_dumpall: pg_dumpall.sh
sed -e 's,@VERSION@,$(VERSION),g' \
......@@ -33,6 +36,11 @@ pg_dumpall: pg_dumpall.sh
$< >$@
chmod a+x $@
.PHONY: submake-backend
submake-backend:
$(MAKE) -C $(top_builddir)/src/backend/parser
install: all installdirs
$(INSTALL_PROGRAM) pg_dump$(X) $(DESTDIR)$(bindir)/pg_dump$(X)
$(INSTALL_PROGRAM) pg_restore$(X) $(DESTDIR)$(bindir)/pg_restore$(X)
......
......@@ -15,7 +15,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup.h,v 1.20 2002/07/04 15:35:07 momjian Exp $
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup.h,v 1.21 2002/08/18 09:36:25 petere Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -26,6 +26,7 @@
#include "postgres_fe.h"
#include "libpq-fe.h"
#include "pqexpbuffer.h"
#define atooid(x) ((Oid) strtoul((x), NULL, 10))
#define oidcmp(x,y) ( ((x) < (y) ? -1 : ((x) > (y)) ? 1 : 0) )
......@@ -119,7 +120,9 @@ __attribute__((format(printf, 3, 4)));
extern char *simple_prompt(const char *prompt, int maxlen, bool echo);
extern const char *fmtId(const char *identifier, bool force_quotes);
extern const char *fmtId(const char *identifier);
extern void appendStringLiteral(PQExpBuffer buf, const char *str, bool escapeAll);
/* Lets the archive know we have a DB connection to shutdown if it dies */
......
This diff is collapsed.
......@@ -5,7 +5,7 @@
* Implements the basic DB functions used by the archiver.
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.36 2002/08/10 16:57:31 petere Exp $
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.37 2002/08/18 09:36:25 petere Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -590,9 +590,9 @@ FixupBlobRefs(ArchiveHandle *AH, TocEntry *te)
if (te->namespace && strlen(te->namespace) > 0)
appendPQExpBuffer(tblName, "%s.",
fmtId(te->namespace, false));
fmtId(te->namespace));
appendPQExpBuffer(tblName, "%s",
fmtId(te->tag, false));
fmtId(te->tag));
appendPQExpBuffer(tblQry,
"SELECT a.attname FROM "
......@@ -624,13 +624,13 @@ FixupBlobRefs(ArchiveHandle *AH, TocEntry *te)
/* Can't use fmtId twice in one call... */
appendPQExpBuffer(tblQry,
"UPDATE %s SET %s = %s.newOid",
tblName->data, fmtId(attr, false),
tblName->data, fmtId(attr),
BLOB_XREF_TABLE);
appendPQExpBuffer(tblQry,
" FROM %s WHERE %s.oldOid = %s.%s",
BLOB_XREF_TABLE,
BLOB_XREF_TABLE,
tblName->data, fmtId(attr, false));
tblName->data, fmtId(attr));
ahlog(AH, 10, "SQL: %s\n", tblQry->data);
......
This diff is collapsed.
......@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: pg_dump.h,v 1.95 2002/08/15 16:36:06 momjian Exp $
* $Id: pg_dump.h,v 1.96 2002/08/18 09:36:26 petere Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -15,7 +15,6 @@
#define PG_DUMP_H
#include "pg_backup.h"
#include "pqexpbuffer.h"
/*
* The data structures used to store system catalog information
......
......@@ -1314,7 +1314,7 @@ SELECT tablename, rulename, definition FROM pg_rules
tablename | rulename | definition
---------------+-----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
pg_settings | pg_settings_n | CREATE RULE pg_settings_n AS ON UPDATE TO pg_settings DO INSTEAD NOTHING;
pg_settings | pg_settings_u | CREATE RULE pg_settings_u AS ON UPDATE TO pg_settings WHERE (new.name = old.name) DO SELECT set_config(old.name, new.setting, 'f'::boolean) AS set_config;
pg_settings | pg_settings_u | CREATE RULE pg_settings_u AS ON UPDATE TO pg_settings WHERE (new.name = old.name) DO SELECT set_config(old.name, new.setting, false) AS set_config;
rtest_emp | rtest_emp_del | CREATE RULE rtest_emp_del AS ON DELETE TO rtest_emp DO INSERT INTO rtest_emplog (ename, who, "action", newsal, oldsal) VALUES (old.ename, "current_user"(), 'fired '::bpchar, '$0.00'::money, old.salary);
rtest_emp | rtest_emp_ins | CREATE RULE rtest_emp_ins AS ON INSERT TO rtest_emp DO INSERT INTO rtest_emplog (ename, who, "action", newsal, oldsal) VALUES (new.ename, "current_user"(), 'hired '::bpchar, new.salary, '$0.00'::money);
rtest_emp | rtest_emp_upd | CREATE RULE rtest_emp_upd AS ON UPDATE TO rtest_emp WHERE (new.salary <> old.salary) DO INSERT INTO rtest_emplog (ename, who, "action", newsal, oldsal) VALUES (new.ename, "current_user"(), 'honored '::bpchar, new.salary, old.salary);
......
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