Re: Float output formatting options - Mailing list pgsql-hackers

From Pedro M. Ferreira
Subject Re: Float output formatting options
Date
Msg-id 3DC6C1BE.4060707@ualg.pt
Whole thread Raw
In response to Float output formatting options  ("Pedro M. Ferreira" <pfrazao@ualg.pt>)
Responses Re: Float output formatting options  ("Christopher Kings-Lynne" <chriskl@familyhealth.com.au>)
List pgsql-hackers
Tom Lane wrote:
> "Pedro M. Ferreira" <pfrazao@ualg.pt> writes:
> 
>>Is it ok to remove #define P_MAXDIG DBL_DIG,
>>change P_MAXLEN to 2*(DBL_DIG+7)+1) and
>>remove the line 'static int      digits8 = P_MAXDIG;' ?
> 
> Perhaps P_MAXLEN now needs to be (2*(DBL_DIG+2+7)+1), considering
> that we'll allow extra_float_digits to be up to 2.  What's it used for?

Yes. I guess so, because it is used in what I think is a memory 
allocation function. P_MAXLEN is only used twice:

* 1st use in path_encode() (allmost all the geo *_out functions use 
path_encode):

int        size = npts * (P_MAXLEN + 3) + 2;

/* Check for integer overflow */
if ((size - 2) / npts != (P_MAXLEN + 3))                elog(ERROR, "Too many points requested");


* 2nd use in circle_out(PG_FUNCTION_ARGS):

result = palloc(3 * (P_MAXLEN + 1) + 3);

I will do the changes tomorrow and send in the appropriate diff's.

Regards,
Pedro



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Float output formatting options
Next
From: Peter Eisentraut
Date:
Subject: Re: [CYGWIN] ipc-daemon