mirror of
https://github.com/postgres/postgres.git
synced 2025-04-22 23:02:54 +03:00
Use sprintf() to convert float8 to a string during conversion to numeric.
Original code used float8out(), but the resulting exponential notation was not handled (e.g. '3E9' was decoded as '3').
This commit is contained in:
parent
54067db642
commit
84e832a802
@ -5,7 +5,7 @@
|
|||||||
*
|
*
|
||||||
* 1998 Jan Wieck
|
* 1998 Jan Wieck
|
||||||
*
|
*
|
||||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.11 1999/03/14 16:49:32 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.12 1999/05/04 15:50:24 thomas Exp $
|
||||||
*
|
*
|
||||||
* ----------
|
* ----------
|
||||||
*/
|
*/
|
||||||
@ -1693,7 +1693,7 @@ float8_numeric(float64 val)
|
|||||||
{
|
{
|
||||||
Numeric res;
|
Numeric res;
|
||||||
NumericVar result;
|
NumericVar result;
|
||||||
char *tmp;
|
char buf[512];
|
||||||
|
|
||||||
if (val == NULL)
|
if (val == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -1703,12 +1703,11 @@ float8_numeric(float64 val)
|
|||||||
|
|
||||||
init_var(&result);
|
init_var(&result);
|
||||||
|
|
||||||
tmp = float8out(val);
|
sprintf(buf, "%f", *val);
|
||||||
set_var_from_str(tmp, &result);
|
set_var_from_str(buf, &result);
|
||||||
res = make_result(&result);
|
res = make_result(&result);
|
||||||
|
|
||||||
free_var(&result);
|
free_var(&result);
|
||||||
pfree(tmp);
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user