Re: T_Float morph to T_Integer after nodeRead

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Kouhei Kaigai <kaigai(at)ak(dot)jp(dot)nec(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: T_Float morph to T_Integer after nodeRead
Date: 2017-01-06 02:02:32
Message-ID: 24661.1483668152@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Kouhei Kaigai <kaigai(at)ak(dot)jp(dot)nec(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2017-01-06 02:03:35 Re: Indirect indexes
Previous Message Tom Lane 2017-01-06 01:51:39 Re: Reporting planning time with EXPLAIN