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 e9b58b98783b4d0484c31c6ed1d7966b@G08CNEXMBPEKD06.g08.fujitsu.local
Whole thread Raw
In response to RE: parse mistake in ecpg connect string  ("kuroda.hayato@fujitsu.com" <kuroda.hayato@fujitsu.com>)
Responses Re: parse mistake in ecpg connect string
List pgsql-hackers
Hi, Horiguchi-san, Kuroda-san:

Thank you for reviewing.

Kyotaro Horiguchi <horikyota.ntt@gmail.com> wrote:

>FWIW, directly embedding /unixsocket/path syntax in a URL is broken in
>the view of URI. It is the reason why the current connection URI takes
>the way shown above. So I think we want to remove that code rather
>than to fix it.

It seems that remove that code is better.

>That being said, we might need a description about how we can specify
>a unix socket directory in ecpg-connect.

After remove the code, if target is:
1. dbname@/unixsocket/path:port
2. unix:postgresql://localhost:port/dbname?host=/unixsocket/path
The ecpg will report an error.

But, if target is:
3. a (single-quoted) string literal of 1 or 2 listed above.
4. a variable reference of 1 or 2 listed above.
The ecpg will precompile successfully. That means if we want to use a unix socket directory in ecpg-connect.
We can only use No.3 and No.4 listed above.

I think we can add some description on docs, but I don't have ability to write description in English,
Can someone help me write a description?

Kuroda, Hayato/黒田 隼人 <kuroda.hayato@fujitsu.com> wrote:

>Digress from the main topic, but the following cannot be accepted for the precompiler.
>This should be fixed, isn't it?
>
>EXEC SQL CONNECT TO postgres@/tmp:5432;

First, thank you for adding a bison rule.

I think add the bison rule is a little difficult because in PG13 windows can also support unix-socket,
In your patch:
> dir_name: '/' dir_name        { $$ = make2_str(mm_strdup("/"), $2); }
>         | ecpg_ident        { $$ = $1; }
>        ;
Windows will remains wrong(I'm not sure ecpg on windows can use unix socket connection).

And if we add the rules in bison files, both ecpg and ecpglib will both parse the host in different ways.
Ecpg parse the host by bison rules, and ecpglib parse the host by splitting the connect string use char '@' or char
'='.
I think it's not a good action.

But If we add some description on docs, these problem can be solved in an easy way.
Therefore, I prefer to add some description on docs.


Best regards
Shenhao Wang





pgsql-hackers by date:

Previous
From: Kyotaro Horiguchi
Date:
Subject: Re: Is Recovery actually paused?
Next
From: Mark Rofail
Date:
Subject: Re: [HACKERS] GSoC 2017: Foreign Key Arrays