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

Commit8c5463a

Browse files
committed
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 respondsto bug report from Keh-Cheng Chu pointing out that although 2 extra digitsshould be sufficient to dump and restore float8 exactly, it is possible toneed 3 extra digits for float4 values.
1 parent680bf32 commit8c5463a

File tree

6 files changed

+15
-13
lines changed

6 files changed

+15
-13
lines changed

‎doc/src/sgml/config.sgml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.226 2009/09/10 15:02:46 alvherre Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.227 2009/09/11 19:17:03 tgl Exp $ -->
22

33
<chapter Id="runtime-config">
44
<title>Server Configuration</title>
@@ -4291,7 +4291,7 @@ SET XML OPTION { DOCUMENT | CONTENT };
42914291
floating-point values, including <type>float4</>, <type>float8</>,
42924292
and geometric data types. The parameter value is added to the
42934293
standard number of digits (<literal>FLT_DIG</> or <literal>DBL_DIG</>
4294-
as appropriate). The value can be set as high as2, to include
4294+
as appropriate). The value can be set as high as3, to include
42954295
partially-significant digits; this is especially useful for dumping
42964296
float data that needs to be restored exactly. Or it can be set
42974297
negative to suppress unwanted digits.

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.162 2009/06/1114:49:03momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.163 2009/09/1119:17:03tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -334,7 +334,7 @@ float4out(PG_FUNCTION_ARGS)
334334
if (ndig<1)
335335
ndig=1;
336336

337-
sprintf(ascii,"%.*g",ndig,num);
337+
snprintf(ascii,MAXFLOATWIDTH+1,"%.*g",ndig,num);
338338
}
339339
}
340340

@@ -523,7 +523,7 @@ float8out(PG_FUNCTION_ARGS)
523523
if (ndig<1)
524524
ndig=1;
525525

526-
sprintf(ascii,"%.*g",ndig,num);
526+
snprintf(ascii,MAXDOUBLEWIDTH+1,"%.*g",ndig,num);
527527
}
528528
}
529529

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/adt/geo_ops.c,v 1.104 2009/08/27 15:59:22 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/geo_ops.c,v 1.105 2009/09/11 19:17:03 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -85,8 +85,8 @@ static Point* lseg_interpt_internal(LSEG *l1, LSEG *l2);
8585
#defineRDELIM_C'>'
8686

8787
/* Maximum number of characters printed by pair_encode() */
88-
/* ...+2+7 :2 accounts for extra_float_digits max value */
89-
#defineP_MAXLEN (2*(DBL_DIG+2+7)+1)
88+
/* ...+3+7 :3 accounts for extra_float_digits max value */
89+
#defineP_MAXLEN (2*(DBL_DIG+3+7)+1)
9090

9191

9292
/*

‎src/backend/utils/misc/guc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Written by Peter Eisentraut <peter_e@gmx.net>.
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.516 2009/09/0817:08:36 tgl Exp $
13+
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.517 2009/09/11 19:17:03 tgl Exp $
1414
*
1515
*--------------------------------------------------------------------
1616
*/
@@ -1684,7 +1684,7 @@ static struct config_int ConfigureNamesInt[] =
16841684
"(FLT_DIG or DBL_DIG as appropriate).")
16851685
},
16861686
&extra_float_digits,
1687-
0,-15,2,NULL,NULL
1687+
0,-15,3,NULL,NULL
16881688
},
16891689

16901690
{

‎src/backend/utils/misc/postgresql.conf.sample

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@
445445
# India
446446
# You can create your own file in
447447
# share/timezonesets/.
448-
#extra_float_digits = 0# min -15, max2
448+
#extra_float_digits = 0# min -15, max3
449449
#client_encoding = sql_ascii# actually, defaults to database
450450
# encoding
451451

‎src/bin/pg_dump/pg_dump.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*by PostgreSQL
1313
*
1414
* IDENTIFICATION
15-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.546 2009/08/04 19:46:51 tgl Exp $
15+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.547 2009/09/11 19:17:04 tgl Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -595,7 +595,9 @@ main(int argc, char **argv)
595595
* If supported, set extra_float_digits so that we can dump float data
596596
* exactly (given correctly implemented float I/O code, anyway)
597597
*/
598-
if (g_fout->remoteVersion >=70400)
598+
if (g_fout->remoteVersion >=80500)
599+
do_sql_command(g_conn,"SET extra_float_digits TO 3");
600+
elseif (g_fout->remoteVersion >=70400)
599601
do_sql_command(g_conn,"SET extra_float_digits TO 2");
600602

601603
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp