From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Michael Paquier <michael@paquier.xyz>
Cc: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Cc: David Rowley <david.rowley@2ndquadrant.com>
Cc: pgsql-committers <pgsql-committers@postgresql.org>
Subject: Re: pgsql: Move strtoint() to common
Date: Thu, 15 Mar 2018 16:15:24 -0300
Message-ID: <20180315191524.ga2fdjbnuz4y43fg@alvherre.pgsql> (raw)
In-Reply-To: <27178.1521132652@sss.pgh.pa.us>
Tom Lane wrote:
> Alvaro Herrera <alvherre@alvh.no-ip.org> writes:
> > Michael Paquier wrote:
> >> Attached is a patch which fixes the compilation failure on Windows for
> >> me. That should put the buildfarm back to green.
>
> > Pushed, thanks -- let's see how that goes.
>
> build now works, ecpg tests fail.
I stared at the code for a while, didn't notice anything amiss. I'm
mystified. Peter?
I think the guilty bit is the one below, but
1) I don't see how the new code fails to work exactly like the old code
2) I don't understand why it would only fail on Windows.
I thought it may be a port difference in strtol, but I don't see what
it'd be.
Also: it seems strtol per spec returns LONG_MAX/LONG_MIN on
overflow/underflow, and our strtoint doesn't do (an equivalent of) that.
But I don't see how that would affect the failing ecpg test.
inline patch 1: src/interfaces/ecpg/preproc/pgc.l (+3/-0 lines) download inline-1.patchdiff --git a/src/interfaces/ecpg/preproc/pgc.l b/src/interfaces/ecpg/preproc/pgc.lindex ba1798c77e..405dee73b0 100644
*** a/src/interfaces/ecpg/preproc/pgc.l
--- b/src/interfaces/ecpg/preproc/pgc.l
***************
*** 723,744 **** cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
return Op;
}
<SQL>{param} {
base_yylval.ival = atol(yytext+1);
return PARAM;
}
<C,SQL>{integer} {
! long val;
char* endptr;
errno = 0;
! val = strtol((char *)yytext, &endptr,10);
! if (*endptr != '\0' || errno == ERANGE ||
! /* check for overflow of int */
! val != (int) val)
{
errno = 0;
base_yylval.str = mm_strdup(yytext);
return FCONST;
}
base_yylval.ival = val;
return ICONST;
--- 725,744 ----
return Op;
}
<SQL>{param} {
base_yylval.ival = atol(yytext+1);
return PARAM;
}
<C,SQL>{integer} {
! int val;
char* endptr;
errno = 0;
! val = strtoint(yytext, &endptr, 10);
! if (*endptr != '\0' || errno == ERANGE)
{
errno = 0;
base_yylval.str = mm_strdup(yytext);
return FCONST;
}
base_yylval.ival = val;
return ICONST;
--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: alvherre@alvh.no-ip.org, tgl@sss.pgh.pa.us, michael@paquier.xyz, peter.eisentraut@2ndquadrant.com, david.rowley@2ndquadrant.com
Subject: Re: pgsql: Move strtoint() to common
In-Reply-To: <20180315191524.ga2fdjbnuz4y43fg@alvherre.pgsql>
References: <27178.1521132652@sss.pgh.pa.us> <20180315191524.ga2fdjbnuz4y43fg@alvherre.pgsql>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox