Re: Change atoi to strtol in same place - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: Change atoi to strtol in same place
Date
Msg-id 20190910053553.GB11737@paquier.xyz
Whole thread Raw
In response to Re: Change atoi to strtol in same place  (Joe Nelson <joe@begriffs.com>)
Responses Re: Change atoi to strtol in same place
Re: Change atoi to strtol in same place
List pgsql-hackers
On Mon, Sep 09, 2019 at 11:02:49PM -0500, Joe Nelson wrote:
> Alvaro Herrera from 2ndQuadrant wrote:
> > Okay, so who is submitting a new version here?  Surafel, Joe?
>
> I've attached a revision that uses pg_strtoint64 from str2int-10.patch
> (posted in <alpine.DEB.2.21.1909032007230.21690@lancre>). My patch is
> based off that one and c5bc7050af.
>
> It covers the same front-end utilities as atoi-to-strtol-v2.patch. Other
> utilities in the pg codebase still have atoi inside, but I thought I'd
> share my progress to see if people like the direction. If so, I can
> update the rest of the utils.
>
> I added a helper function to a new file in src/fe_utils, but had to
> modify Makefiles in ways that might not be too clean. Maybe there's a
> better place for the function.

Using a wrapper in src/fe_utils makes sense.  I would have used
options.c for the new file, or would that be too much generic?

The code indentation is weird, particularly the switch/case in
pg_strtoint64_range().

The error handling is awkward.  I think that you should just call
pg_log_error in pg_strtoint64_range instead of returning an error
string as you do.  You could do that by passing down the option name
to the routine, and generate a new set of error messages using that.

Why do you need to update common/Makefile?

The builds on Windows are broken.  You are adding one file into
fe_utils, but forgot to update @pgfeutilsfiles in Mkvcbuild.pm.
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: PostgreSQL 12 Beta 4
Next
From: Amit Kapila
Date:
Subject: Re: pgbench - allow to create partitioned tables