diff options
author | Peter Eisentraut <peter@eisentraut.org> | 2022-02-14 21:29:45 +0100 |
---|---|---|
committer | Peter Eisentraut <peter@eisentraut.org> | 2022-02-14 21:57:26 +0100 |
commit | cfc7191dfea330dd7a71e940d59de78129bb6175 (patch) | |
tree | d1d6bc5dbade67b536fc09457b2e71a6fad61c4a /src/backend/parser/parse_node.c | |
parent | 291ec6e45ebe1a87f930a250ad3c6672472b9b19 (diff) | |
download | postgresql-cfc7191dfea330dd7a71e940d59de78129bb6175.tar.gz postgresql-cfc7191dfea330dd7a71e940d59de78129bb6175.zip |
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
Diffstat (limited to 'src/backend/parser/parse_node.c')
-rw-r--r-- | src/backend/parser/parse_node.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/backend/parser/parse_node.c b/src/backend/parser/parse_node.c index 35db6b6c988..a49c985d36e 100644 --- a/src/backend/parser/parse_node.c +++ b/src/backend/parser/parse_node.c @@ -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)); |