mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +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:
@@ -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",
|
||||
|
Reference in New Issue
Block a user