mirror of
https://github.com/postgres/postgres.git
synced 2025-07-07 00:36:50 +03:00
Move scanint8() to numutils.c
Move scanint8() to numutils.c and rename to pg_strtoint64(). We already have a "16" and "32" version of that, and the code inside the functions was aligned, so this move makes all three versions consistent. The API is also changed to no longer provide the errorOK case. Users that need the error checking can use strtoi64(). Reviewed-by: John Naylor <john.naylor@enterprisedb.com> Discussion: https://www.postgresql.org/message-id/flat/b239564c-cad0-b23e-c57e-166d883cb97d@enterprisedb.com
This commit is contained in:
@ -26,7 +26,6 @@
|
||||
#include "parser/parse_relation.h"
|
||||
#include "parser/parsetree.h"
|
||||
#include "utils/builtins.h"
|
||||
#include "utils/int8.h"
|
||||
#include "utils/lsyscache.h"
|
||||
#include "utils/syscache.h"
|
||||
#include "utils/varbit.h"
|
||||
@ -353,7 +352,6 @@ make_const(ParseState *pstate, A_Const *aconst)
|
||||
{
|
||||
Const *con;
|
||||
Datum val;
|
||||
int64 val64;
|
||||
Oid typeid;
|
||||
int typelen;
|
||||
bool typebyval;
|
||||
@ -384,8 +382,15 @@ make_const(ParseState *pstate, A_Const *aconst)
|
||||
break;
|
||||
|
||||
case T_Float:
|
||||
{
|
||||
/* could be an oversize integer as well as a float ... */
|
||||
if (scanint8(aconst->val.fval.fval, true, &val64))
|
||||
|
||||
int64 val64;
|
||||
char *endptr;
|
||||
|
||||
errno = 0;
|
||||
val64 = strtoi64(aconst->val.fval.fval, &endptr, 10);
|
||||
if (errno == 0 && *endptr == '\0')
|
||||
{
|
||||
/*
|
||||
* It might actually fit in int32. Probably only INT_MIN can
|
||||
@ -425,6 +430,7 @@ make_const(ParseState *pstate, A_Const *aconst)
|
||||
typebyval = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case T_Boolean:
|
||||
val = BoolGetDatum(boolVal(&aconst->val));
|
||||
|
Reference in New Issue
Block a user