Re: Try to fix endless loop in ecpg with informix mode

From: 高增琦 <pgf00a(at)gmail(dot)com>
To: Michael Meskes <meskes(at)postgresql(dot)org>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Try to fix endless loop in ecpg with informix mode
Date: 2017-11-03 06:20:16
Message-ID: CAFmBtr07GAjS_TSiLhampZghz92vCEgWsjGG+3WuSS=kiB+sdQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

I found the last commit changed as:

```
/* skip invalid characters */
do {
(*scan_length)++;
- } while (**scan_length != ' ' && **scan_length != '\0' &&
isdigit(**scan_length));
+ } while (isdigit(**scan_length));
return false;
}
```

It will still return false if we got non-digital characters after ".",
then it will error out "invalid input syntax for type int" for "a" . (if
input is "7.a")

Although this error message is not wrong, I think it should be better to
give error message as "invalid input syntax for type int" for "7.a".
This could be done by delete "return false;" after "while(...)", let
the following if to decide which to return.

2017-11-02 15:25 GMT+08:00 Michael Meskes <meskes(at)postgresql(dot)org>:

> > I am afraid the changes may separate "7.a" to "7" and "a", then error
> > out
> > with "invalid input syntax for type int" for "a".
>
> Which is correct, is it not?
>
> > How about changes as below? (use following the if to decide true or
> > false)
> > ...
> > return false;
> > + } while (isdigit(**scan_length));
>
> Yes, this is certainly correct and better than what I committed. What
> was I thinking yesterday?
>
> I think the same function is used for identifying garbage in floats
> which might ask for different logic. Let me check.
>
> Michael
> --
> Michael Meskes
> Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
> Meskes at (Debian|Postgresql) dot Org
> Jabber: michael at xmpp dot meskes dot org
> VfL Borussia! Força Barça! SF 49ers! Use Debian GNU/Linux, PostgreSQL
>

--
GaoZengqi
pgf00a(at)gmail(dot)com
zengqigao(at)gmail(dot)com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Satyanarayana Narlapuram 2017-11-03 06:31:18 Re: Client Connection redirection support for PostgreSQL
Previous Message Craig Ringer 2017-11-03 06:16:09 Re: ArrayLists instead of List (for some things)