diff options
author | Peter Eisentraut | 2022-02-14 20:29:45 +0000 |
---|---|---|
committer | Peter Eisentraut | 2022-02-14 20:57:26 +0000 |
commit | cfc7191dfea330dd7a71e940d59de78129bb6175 (patch) | |
tree | d1d6bc5dbade67b536fc09457b2e71a6fad61c4a /src/backend/replication/pgoutput/pgoutput.c | |
parent | 291ec6e45ebe1a87f930a250ad3c6672472b9b19 (diff) |
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 <[email protected]>
Discussion: https://www.postgresql.org/message-id/flat/[email protected]
Diffstat (limited to 'src/backend/replication/pgoutput/pgoutput.c')
-rw-r--r-- | src/backend/replication/pgoutput/pgoutput.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/backend/replication/pgoutput/pgoutput.c b/src/backend/replication/pgoutput/pgoutput.c index 6df705f90ff..4162bb8de7b 100644 --- a/src/backend/replication/pgoutput/pgoutput.c +++ b/src/backend/replication/pgoutput/pgoutput.c @@ -21,7 +21,6 @@ #include "replication/logicalproto.h" #include "replication/origin.h" #include "replication/pgoutput.h" -#include "utils/int8.h" #include "utils/inval.h" #include "utils/lsyscache.h" #include "utils/memutils.h" @@ -207,7 +206,8 @@ parse_output_parameters(List *options, PGOutputData *data) /* Check each param, whether or not we recognize it */ if (strcmp(defel->defname, "proto_version") == 0) { - int64 parsed; + unsigned long parsed; + char *endptr; if (protocol_version_given) ereport(ERROR, @@ -215,12 +215,14 @@ parse_output_parameters(List *options, PGOutputData *data) errmsg("conflicting or redundant options"))); protocol_version_given = true; - if (!scanint8(strVal(defel->arg), true, &parsed)) + errno = 0; + parsed = strtoul(strVal(defel->arg), &endptr, 10); + if (errno != 0 || *endptr != '\0') ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("invalid proto_version"))); - if (parsed > PG_UINT32_MAX || parsed < 0) + if (parsed > PG_UINT32_MAX) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("proto_version \"%s\" out of range", |