Comment 2 for bug 370360

Revision history for this message
Sander van Schouwenburg (Sandworm) (sander-sinaasappel) wrote :

My point is: PostgreSQL does NOT convert the value to float. It is just a bigint, only the result from pg_field_type() will return 'numeric'. The string is just a bigint. But since anewt sees 'numeric' and thinks thats a float, it will convert it to a float with less precision.

The following code:

$rs = pg_query('SELECT SUM(large_value*9999999) FROM sometable');
$rs = pg_query($sql);
echo pg_field_type($rs, 0);
$value = pg_fetch_result($rs, 0);
echo $value;
echo (float)$value; // <-- this is what anewt does

Will return the following output (adjusted for whitespace):

numeric
107629173119941611714
1.0762917311994E+20

Which proves that some precision is lost.

Only when I made the input one factor larger did postgres complain about an overflow.