RE: parse mistake in ecpg connect string

From: "Wang, Shenhao" <wangsh(dot)fnst(at)cn(dot)fujitsu(dot)com>
To: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, "Kuroda, Hayato" <kuroda(dot)hayato(at)fujitsu(dot)com>
Cc: "tgl(at)sss(dot)pgh(dot)pa(dot)us" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: RE: parse mistake in ecpg connect string
Date: 2021-02-09 06:56:01
Message-ID: 4de157df4ed540b4bb1be5cd471f761f@G08CNEXMBPEKD06.g08.fujitsu.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi, Horiguchi-san

Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com> wrote:

> How about the attached?

I think, this patch is good.

> > > Should we allow "::1" here as well? On the other hand, colons are
> > > already overloaded in this syntax, so maybe allowing them in the
> > > host part is a bad idea.

> Yeah, that made me smile for the same reason:p

It seems that ecpg cannot parse the connect str with ipv6 correctly.

Such as:
EXEC SQL CONNECT TO 'tcp:postgresql://::1:5432/postgres'
connect to the server successfully, but
EXEC SQL CONNECT TO 'tcp:postgresql://::1/postgres'
failed to connect to server.

And ecpg will always wrong when parse a connect str
EXEC SQL CONNECT TO tcp:postgresql://::1:5432/postgres;
Ecpg error :
a.pgc:16: ERROR: syntax error at or near "::"

Maybe we should support ipv6 like libpq.
In [1],
> The host part may be either host name or an IP address. To specify an IPv6 host address, enclose it in square brackets:

How about using square brackets like libpq, such as:
EXEC SQL CONNECT TO 'tcp:postgresql://[::1]/postgres'

Maybe we can create a new thread to talk about how ecpg support ipv6

[1] https://www.postgresql.org/docs/13/libpq-connect.html#LIBPQ-CONNSTRING

Best regards
Shenhao Wang

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bharath Rupireddy 2021-02-09 06:57:21 Re: Is Recovery actually paused?
Previous Message Kyotaro Horiguchi 2021-02-09 06:49:49 Re: libpq debug log