RE: parse mistake in ecpg connect string - Mailing list pgsql-hackers

From Wang, Shenhao
Subject RE: parse mistake in ecpg connect string
Date
Msg-id 4de157df4ed540b4bb1be5cd471f761f@G08CNEXMBPEKD06.g08.fujitsu.local
Whole thread Raw
In response to Re: parse mistake in ecpg connect string  (Kyotaro Horiguchi <horikyota.ntt@gmail.com>)
Responses RE: parse mistake in ecpg connect string
List pgsql-hackers
Hi, Horiguchi-san

Kyotaro Horiguchi <horikyota.ntt@gmail.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






pgsql-hackers by date:

Previous
From: Kyotaro Horiguchi
Date:
Subject: Re: libpq debug log
Next
From: Bharath Rupireddy
Date:
Subject: Re: Is Recovery actually paused?