1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-14 18:42:34 +03:00

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.
This commit is contained in:
Peter Eisentraut
2002-08-18 09:36:26 +00:00
parent 41298cf8a6
commit c828ec8820
11 changed files with 421 additions and 392 deletions

View File

@ -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);
break;
default:
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;
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: