Re: Change atoi to strtol in same place

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Joe Nelson <joe(at)begriffs(dot)com>
Cc: Alvaro Herrera from 2ndQuadrant <alvherre(at)alvh(dot)no-ip(dot)org>, David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>, Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>, Surafel Temesgen <surafel3000(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Change atoi to strtol in same place
Date: 2019-09-10 05:35:53
Message-ID: 20190910053553.GB11737@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(dot)DEB(dot)2(dot)21(dot)1909032007230(dot)21690(at)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2019-09-10 05:48:12 Re: pgbench - allow to create partitioned tables
Previous Message Michael Paquier 2019-09-10 05:13:55 Re: PostgreSQL 12 Beta 4