Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc828ec8

Browse files
committed
Make pg_dump output more portable and more pleasing to look at.
The -n and -N options were removed. Quoting is now smart enough tosupply quotes if and only if necessary.Numerical types are now printed without quotes, except in cases ofspecial 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.
1 parent41298cf commitc828ec8

File tree

11 files changed

+421
-392
lines changed

11 files changed

+421
-392
lines changed

‎doc/src/sgml/ref/pg_dump.sgml‎

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/ref/pg_dump.sgml,v 1.47 2002/08/10 16:57:31 petere Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/pg_dump.sgml,v 1.48 2002/08/18 09:36:25 petere Exp $
33
PostgreSQL documentation
44
-->
55

@@ -29,7 +29,6 @@ PostgreSQL documentation
2929
<arg>-f <replaceable>file</replaceable></arg>
3030
<arg>-F <replaceable>format</replaceable></arg>
3131
<arg>-i</arg>
32-
<group> <arg>-n</arg> <arg>-N</arg> </group>
3332
<arg>-o</arg>
3433
<arg>-O</arg>
3534
<arg>-R</arg>
@@ -302,31 +301,6 @@ PostgreSQL documentation
302301
</listitem>
303302
</varlistentry>
304303

305-
<varlistentry>
306-
<term><option>-n</></term>
307-
<term><option>--no-quotes</></term>
308-
<listitem>
309-
<para>
310-
Suppress double quotes around identifiers unless absolutely necessary.
311-
This may cause trouble loading this dumped data if there are reserved words
312-
used for identifiers.
313-
This was the default behavior for
314-
<command>pg_dump</command> prior to version 6.4.
315-
</para>
316-
</listitem>
317-
</varlistentry>
318-
319-
<varlistentry>
320-
<term><option>-N</></term>
321-
<term><option>--quotes</></term>
322-
<listitem>
323-
<para>
324-
Include double quotes around identifiers.
325-
This is the default.
326-
</para>
327-
</listitem>
328-
</varlistentry>
329-
330304
<varlistentry>
331305
<term><option>-o</></term>
332306
<term><option>--oids</></term>

‎doc/src/sgml/release.sgml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/release.sgml,v 1.146 2002/08/11 21:17:34 tgl Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/release.sgml,v 1.147 2002/08/18 09:36:25 petere Exp $
33
-->
44

55
<appendix id="release">
@@ -24,6 +24,7 @@ CDATA means the content is "SGML-free", so you can write without
2424
worries about funny characters.
2525
-->
2626
<literallayout><![CDATA[
27+
pg_dump -n and -N options have been removed. The new behavior is like -n but knows about key words.
2728
CLUSTER is no longer hazardous to your schema
2829
COPY accepts a list of columns to copy
2930
ALTER TABLE DROP COLUMN

‎src/backend/parser/keywords.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.124 2002/08/06 05:40:45 ishii Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.125 2002/08/18 09:36:25 petere Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -20,6 +20,8 @@
2020
#include"parser/keywords.h"
2121
#include"parser/parse.h"
2222

23+
/* NB: This file is also used by pg_dump. */
24+
2325
/*
2426
* List of (keyword-name, keyword-token-value) pairs.
2527
*

‎src/backend/utils/adt/ruleutils.c‎

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*back to source text
44
*
55
* IDENTIFICATION
6-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.116 2002/08/16 23:01:19 tgl Exp $
6+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.117 2002/08/18 09:36:25 petere Exp $
77
*
88
* This software is copyrighted by Jan Wieck - Hamburg.
99
*
@@ -2529,14 +2529,42 @@ get_const_expr(Const *constval, deparse_context *context)
25292529
{
25302530
caseINT2OID:
25312531
caseINT4OID:
2532-
caseOIDOID:/* int types */
2532+
caseINT8OID:
2533+
caseOIDOID:
25332534
caseFLOAT4OID:
2534-
caseFLOAT8OID:/* float types */
2535-
/* These types are printed without quotes */
2536-
appendStringInfo(buf,extval);
2535+
caseFLOAT8OID:
2536+
caseNUMERICOID:
2537+
{
2538+
/*
2539+
* These types are printed without quotes unless they
2540+
* contain values that aren't accepted by the scanner
2541+
* unquoted (e.g., 'NaN'). Note that strtod() and friends
2542+
* might accept NaN, so we can't use that to test.
2543+
*
2544+
* In reality we only need to defend against infinity and
2545+
* NaN, so we need not get too crazy about pattern
2546+
* matching here.
2547+
*/
2548+
if (strspn(extval,"0123456789 +-eE.")==strlen(extval))
2549+
appendStringInfo(buf,extval);
2550+
else
2551+
appendStringInfo(buf,"'%s'",extval);
2552+
}
2553+
break;
2554+
2555+
caseBITOID:
2556+
caseVARBITOID:
2557+
appendStringInfo(buf,"B'%s'",extval);
25372558
break;
2538-
default:
25392559

2560+
caseBOOLOID:
2561+
if (strcmp(extval,"t")==0)
2562+
appendStringInfo(buf,"true");
2563+
else
2564+
appendStringInfo(buf,"false");
2565+
break;
2566+
2567+
default:
25402568
/*
25412569
* We must quote any funny characters in the constant's
25422570
* representation. XXX Any MULTIBYTE considerations here?
@@ -2564,6 +2592,7 @@ get_const_expr(Const *constval, deparse_context *context)
25642592

25652593
switch (constval->consttype)
25662594
{
2595+
caseBOOLOID:
25672596
caseINT4OID:
25682597
caseFLOAT8OID:
25692598
caseUNKNOWNOID:

‎src/bin/pg_dump/Makefile‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
66
# Portions Copyright (c) 1994, Regents of the University of California
77
#
8-
# $Header: /cvsroot/pgsql/src/bin/pg_dump/Makefile,v 1.36 2002/07/27 20:10:05 petere Exp $
8+
# $Header: /cvsroot/pgsql/src/bin/pg_dump/Makefile,v 1.37 2002/08/18 09:36:25 petere Exp $
99
#
1010
#-------------------------------------------------------------------------
1111

@@ -16,15 +16,18 @@ include $(top_builddir)/src/Makefile.global
1616
OBJS= pg_backup_archiver.o pg_backup_db.o pg_backup_custom.o\
1717
pg_backup_files.o pg_backup_null.o pg_backup_tar.o sprompt.o
1818

19+
EXTRA_OBJS =$(top_builddir)/src/backend/parser/keywords.o
20+
1921
overrideCPPFLAGS := -I$(libpq_srcdir)$(CPPFLAGS)
2022

21-
all: submake-libpq submake-libpgport pg_dump pg_restore pg_dumpall
23+
24+
all: submake-libpq submake-libpgport submake-backend pg_dump pg_restore pg_dumpall
2225

2326
pg_dump: pg_dump.o common.o$(OBJS)$(libpq_builddir)/libpq.a
24-
$(CC)$(CFLAGS) pg_dump.o common.o$(OBJS)$(libpq)$(LDFLAGS)$(LIBS) -o$@
27+
$(CC)$(CFLAGS) pg_dump.o common.o$(OBJS)$(EXTRA_OBJS)$(libpq)$(LDFLAGS)$(LIBS) -o$@
2528

2629
pg_restore: pg_restore.o$(OBJS)$(libpq_builddir)/libpq.a
27-
$(CC)$(CFLAGS) pg_restore.o$(OBJS)$(libpq)$(LDFLAGS)$(LIBS) -o$@
30+
$(CC)$(CFLAGS) pg_restore.o$(OBJS)$(EXTRA_OBJS)$(libpq)$(LDFLAGS)$(LIBS) -o$@
2831

2932
pg_dumpall: pg_dumpall.sh
3033
sed -e's,@VERSION@,$(VERSION),g'\
@@ -33,6 +36,11 @@ pg_dumpall: pg_dumpall.sh
3336
$<>$@
3437
chmod a+x$@
3538

39+
.PHONY: submake-backend
40+
submake-backend:
41+
$(MAKE) -C$(top_builddir)/src/backend/parser
42+
43+
3644
install: all installdirs
3745
$(INSTALL_PROGRAM) pg_dump$(X)$(DESTDIR)$(bindir)/pg_dump$(X)
3846
$(INSTALL_PROGRAM) pg_restore$(X)$(DESTDIR)$(bindir)/pg_restore$(X)

‎src/bin/pg_dump/pg_backup.h‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*
1717
* IDENTIFICATION
18-
*$Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup.h,v 1.20 2002/07/04 15:35:07 momjian Exp $
18+
*$Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup.h,v 1.21 2002/08/18 09:36:25 petere Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -26,6 +26,7 @@
2626
#include"postgres_fe.h"
2727

2828
#include"libpq-fe.h"
29+
#include"pqexpbuffer.h"
2930

3031
#defineatooid(x) ((Oid) strtoul((x), NULL, 10))
3132
#defineoidcmp(x,y) ( ((x) < (y) ? -1 : ((x) > (y)) ? 1 : 0) )
@@ -119,7 +120,9 @@ __attribute__((format(printf, 3, 4)));
119120

120121
externchar*simple_prompt(constchar*prompt,intmaxlen,boolecho);
121122

122-
externconstchar*fmtId(constchar*identifier,boolforce_quotes);
123+
externconstchar*fmtId(constchar*identifier);
124+
externvoidappendStringLiteral(PQExpBufferbuf,constchar*str,boolescapeAll);
125+
123126

124127
/* Lets the archive know we have a DB connection to shutdown if it dies */
125128

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp