@@ -4877,7 +4877,7 @@ NUM_processor(FormatNode *node, NUMDesc *Num, char *inout, char *number,
4877
4877
*/
4878
4878
#define NUM_TOCHAR_prepare \
4879
4879
do { \
4880
- len = VARSIZE_ANY_EXHDR(fmt); \
4880
+ int len = VARSIZE_ANY_EXHDR(fmt); \
4881
4881
if (len <= 0 || len >= (INT_MAX-VARHDRSZ)/NUM_MAX_ITEM_SIZ) \
4882
4882
PG_RETURN_TEXT_P(cstring_to_text("")); \
4883
4883
result = (text *) palloc0((len * NUM_MAX_ITEM_SIZ) + 1 + VARHDRSZ); \
@@ -4890,6 +4890,8 @@ do { \
4890
4890
*/
4891
4891
#define NUM_TOCHAR_finish \
4892
4892
do { \
4893
+ int len; \
4894
+ \
4893
4895
NUM_processor(format, &Num, VARDATA(result), numstr, plen, sign, true, PG_GET_COLLATION()); \
4894
4896
\
4895
4897
if (shouldFree) \
@@ -4961,8 +4963,7 @@ numeric_to_char(PG_FUNCTION_ARGS)
4961
4963
FormatNode * format ;
4962
4964
text * result ;
4963
4965
bool shouldFree ;
4964
- int len = 0 ,
4965
- plen = 0 ,
4966
+ int plen = 0 ,
4966
4967
sign = 0 ;
4967
4968
char * numstr ,
4968
4969
* orgnum ,
@@ -5008,16 +5009,15 @@ numeric_to_char(PG_FUNCTION_ARGS)
5008
5009
numstr = (char * ) palloc (strlen (orgnum ) + 2 );
5009
5010
* numstr = ' ' ;
5010
5011
strcpy (numstr + 1 , orgnum );
5011
- len = strlen (numstr );
5012
5012
}
5013
5013
else
5014
5014
{
5015
5015
numstr = orgnum ;
5016
- len = strlen (orgnum );
5017
5016
}
5018
5017
}
5019
5018
else
5020
5019
{
5020
+ int len ;
5021
5021
Numeric val = value ;
5022
5022
5023
5023
if (IS_MULTI (& Num ))
@@ -5084,8 +5084,7 @@ int4_to_char(PG_FUNCTION_ARGS)
5084
5084
FormatNode * format ;
5085
5085
text * result ;
5086
5086
bool shouldFree ;
5087
- int len = 0 ,
5088
- plen = 0 ,
5087
+ int plen = 0 ,
5089
5088
sign = 0 ;
5090
5089
char * numstr ,
5091
5090
* orgnum ;
@@ -5111,11 +5110,12 @@ int4_to_char(PG_FUNCTION_ARGS)
5111
5110
if (* orgnum == '+' )
5112
5111
* orgnum = ' ' ;
5113
5112
5114
- len = strlen (orgnum );
5115
5113
numstr = orgnum ;
5116
5114
}
5117
5115
else
5118
5116
{
5117
+ int len ;
5118
+
5119
5119
if (IS_MULTI (& Num ))
5120
5120
{
5121
5121
orgnum = DatumGetCString (DirectFunctionCall1 (int4out ,
@@ -5175,8 +5175,7 @@ int8_to_char(PG_FUNCTION_ARGS)
5175
5175
FormatNode * format ;
5176
5176
text * result ;
5177
5177
bool shouldFree ;
5178
- int len = 0 ,
5179
- plen = 0 ,
5178
+ int plen = 0 ,
5180
5179
sign = 0 ;
5181
5180
char * numstr ,
5182
5181
* orgnum ;
@@ -5211,16 +5210,16 @@ int8_to_char(PG_FUNCTION_ARGS)
5211
5210
numstr = (char * ) palloc (strlen (orgnum ) + 2 );
5212
5211
* numstr = ' ' ;
5213
5212
strcpy (numstr + 1 , orgnum );
5214
- len = strlen (numstr );
5215
5213
}
5216
5214
else
5217
5215
{
5218
5216
numstr = orgnum ;
5219
- len = strlen (orgnum );
5220
5217
}
5221
5218
}
5222
5219
else
5223
5220
{
5221
+ int len ;
5222
+
5224
5223
if (IS_MULTI (& Num ))
5225
5224
{
5226
5225
double multi = pow ((double ) 10 , (double ) Num .multi );
@@ -5282,8 +5281,7 @@ float4_to_char(PG_FUNCTION_ARGS)
5282
5281
FormatNode * format ;
5283
5282
text * result ;
5284
5283
bool shouldFree ;
5285
- int len = 0 ,
5286
- plen = 0 ,
5284
+ int plen = 0 ,
5287
5285
sign = 0 ;
5288
5286
char * numstr ,
5289
5287
* orgnum ,
@@ -5317,13 +5315,13 @@ float4_to_char(PG_FUNCTION_ARGS)
5317
5315
if (* orgnum == '+' )
5318
5316
* orgnum = ' ' ;
5319
5317
5320
- len = strlen (orgnum );
5321
5318
numstr = orgnum ;
5322
5319
}
5323
5320
}
5324
5321
else
5325
5322
{
5326
5323
float4 val = value ;
5324
+ int len ;
5327
5325
5328
5326
if (IS_MULTI (& Num ))
5329
5327
{
@@ -5386,8 +5384,7 @@ float8_to_char(PG_FUNCTION_ARGS)
5386
5384
FormatNode * format ;
5387
5385
text * result ;
5388
5386
bool shouldFree ;
5389
- int len = 0 ,
5390
- plen = 0 ,
5387
+ int plen = 0 ,
5391
5388
sign = 0 ;
5392
5389
char * numstr ,
5393
5390
* orgnum ,
@@ -5421,13 +5418,13 @@ float8_to_char(PG_FUNCTION_ARGS)
5421
5418
if (* orgnum == '+' )
5422
5419
* orgnum = ' ' ;
5423
5420
5424
- len = strlen (orgnum );
5425
5421
numstr = orgnum ;
5426
5422
}
5427
5423
}
5428
5424
else
5429
5425
{
5430
5426
float8 val = value ;
5427
+ int len ;
5431
5428
5432
5429
if (IS_MULTI (& Num ))
5433
5430
{
0 commit comments