RE: parse mistake in ecpg connect string

From: "Wang, Shenhao" <wangsh(dot)fnst(at)cn(dot)fujitsu(dot)com>
To: "horikyota(dot)ntt(at)gmail(dot)com" <horikyota(dot)ntt(at)gmail(dot)com>, "Kuroda, Hayato" <kuroda(dot)hayato(at)fujitsu(dot)com>
Cc: "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-08 08:34:47
Message-ID: e9b58b98783b4d0484c31c6ed1d7966b@G08CNEXMBPEKD06.g08.fujitsu.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi, Horiguchi-san, Kuroda-san:

Thank you for reviewing.

Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)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(dot)hayato(at)fujitsu(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Mark Rofail 2021-02-08 08:40:32 Re: [HACKERS] GSoC 2017: Foreign Key Arrays
Previous Message Kyotaro Horiguchi 2021-02-08 08:32:46 Re: Is Recovery actually paused?