提交 8c5463a5 编写于 作者: T Tom Lane

Increase the maximum value of extra_float_digits to 3, and have pg_dump

use that value when the backend is new enough to allow it.  This responds
to bug report from Keh-Cheng Chu pointing out that although 2 extra digits
should be sufficient to dump and restore float8 exactly, it is possible to
need 3 extra digits for float4 values.
上级 680bf326
<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.226 2009/09/10 15:02:46 alvherre Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.227 2009/09/11 19:17:03 tgl Exp $ -->
<chapter Id="runtime-config"> <chapter Id="runtime-config">
<title>Server Configuration</title> <title>Server Configuration</title>
...@@ -4291,7 +4291,7 @@ SET XML OPTION { DOCUMENT | CONTENT }; ...@@ -4291,7 +4291,7 @@ SET XML OPTION { DOCUMENT | CONTENT };
floating-point values, including <type>float4</>, <type>float8</>, floating-point values, including <type>float4</>, <type>float8</>,
and geometric data types. The parameter value is added to the and geometric data types. The parameter value is added to the
standard number of digits (<literal>FLT_DIG</> or <literal>DBL_DIG</> standard number of digits (<literal>FLT_DIG</> or <literal>DBL_DIG</>
as appropriate). The value can be set as high as 2, to include as appropriate). The value can be set as high as 3, to include
partially-significant digits; this is especially useful for dumping partially-significant digits; this is especially useful for dumping
float data that needs to be restored exactly. Or it can be set float data that needs to be restored exactly. Or it can be set
negative to suppress unwanted digits. negative to suppress unwanted digits.
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.162 2009/06/11 14:49:03 momjian Exp $ * $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.163 2009/09/11 19:17:03 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -334,7 +334,7 @@ float4out(PG_FUNCTION_ARGS) ...@@ -334,7 +334,7 @@ float4out(PG_FUNCTION_ARGS)
if (ndig < 1) if (ndig < 1)
ndig = 1; ndig = 1;
sprintf(ascii, "%.*g", ndig, num); snprintf(ascii, MAXFLOATWIDTH + 1, "%.*g", ndig, num);
} }
} }
...@@ -523,7 +523,7 @@ float8out(PG_FUNCTION_ARGS) ...@@ -523,7 +523,7 @@ float8out(PG_FUNCTION_ARGS)
if (ndig < 1) if (ndig < 1)
ndig = 1; ndig = 1;
sprintf(ascii, "%.*g", ndig, num); snprintf(ascii, MAXDOUBLEWIDTH + 1, "%.*g", ndig, num);
} }
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/geo_ops.c,v 1.104 2009/08/27 15:59:22 tgl Exp $ * $PostgreSQL: pgsql/src/backend/utils/adt/geo_ops.c,v 1.105 2009/09/11 19:17:03 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -85,8 +85,8 @@ static Point* lseg_interpt_internal(LSEG *l1, LSEG *l2); ...@@ -85,8 +85,8 @@ static Point* lseg_interpt_internal(LSEG *l1, LSEG *l2);
#define RDELIM_C '>' #define RDELIM_C '>'
/* Maximum number of characters printed by pair_encode() */ /* Maximum number of characters printed by pair_encode() */
/* ...+2+7 : 2 accounts for extra_float_digits max value */ /* ...+3+7 : 3 accounts for extra_float_digits max value */
#define P_MAXLEN (2*(DBL_DIG+2+7)+1) #define P_MAXLEN (2*(DBL_DIG+3+7)+1)
/* /*
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* Written by Peter Eisentraut <peter_e@gmx.net>. * Written by Peter Eisentraut <peter_e@gmx.net>.
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.516 2009/09/08 17:08:36 tgl Exp $ * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.517 2009/09/11 19:17:03 tgl Exp $
* *
*-------------------------------------------------------------------- *--------------------------------------------------------------------
*/ */
...@@ -1684,7 +1684,7 @@ static struct config_int ConfigureNamesInt[] = ...@@ -1684,7 +1684,7 @@ static struct config_int ConfigureNamesInt[] =
"(FLT_DIG or DBL_DIG as appropriate).") "(FLT_DIG or DBL_DIG as appropriate).")
}, },
&extra_float_digits, &extra_float_digits,
0, -15, 2, NULL, NULL 0, -15, 3, NULL, NULL
}, },
{ {
......
...@@ -445,7 +445,7 @@ ...@@ -445,7 +445,7 @@
# India # India
# You can create your own file in # You can create your own file in
# share/timezonesets/. # share/timezonesets/.
#extra_float_digits = 0 # min -15, max 2 #extra_float_digits = 0 # min -15, max 3
#client_encoding = sql_ascii # actually, defaults to database #client_encoding = sql_ascii # actually, defaults to database
# encoding # encoding
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* by PostgreSQL * by PostgreSQL
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.546 2009/08/04 19:46:51 tgl Exp $ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.547 2009/09/11 19:17:04 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -595,7 +595,9 @@ main(int argc, char **argv) ...@@ -595,7 +595,9 @@ main(int argc, char **argv)
* If supported, set extra_float_digits so that we can dump float data * If supported, set extra_float_digits so that we can dump float data
* exactly (given correctly implemented float I/O code, anyway) * exactly (given correctly implemented float I/O code, anyway)
*/ */
if (g_fout->remoteVersion >= 70400) if (g_fout->remoteVersion >= 80500)
do_sql_command(g_conn, "SET extra_float_digits TO 3");
else if (g_fout->remoteVersion >= 70400)
do_sql_command(g_conn, "SET extra_float_digits TO 2"); do_sql_command(g_conn, "SET extra_float_digits TO 2");
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册