Re: [HACKERS] T_Float morph to T_Integer after nodeRead - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [HACKERS] T_Float morph to T_Integer after nodeRead
Date
Msg-id 24661.1483668152@sss.pgh.pa.us
Whole thread Raw
In response to [HACKERS] T_Float morph to T_Integer after nodeRead  (Kouhei Kaigai <kaigai@ak.jp.nec.com>)
Responses Re: [HACKERS] T_Float morph to T_Integer after nodeRead  (Kouhei Kaigai <kaigai@ak.jp.nec.com>)
List pgsql-hackers
Kouhei Kaigai <kaigai@ak.jp.nec.com> writes:
> Simplified description of what I did is:
>   fval = makeFloat(psprintf("%.0f", plan_nrows));
>   custom_scan->custom_private = list_make1(fval);

So don't do that.  The lexer would never produce T_Float for an
integer-looking string, so I think it's out of scope for nodeRead()
to be able to reconstitute such a thing.  You could use %.1f, perhaps.
But actually, if you're worried about reconstituting exactly what you
had, aren't you risking precision loss anyway?  Maybe something like
psprintf("%.*e", DBL_DIG+3, plan_nrows) would be safer.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [HACKERS] Reporting planning time with EXPLAIN
Next
From: Bruce Momjian
Date:
Subject: Re: [HACKERS] Indirect indexes