Re: parse mistake in ecpg connect string

From: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
To: wangsh(dot)fnst(at)cn(dot)fujitsu(dot)com
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: parse mistake in ecpg connect string
Date: 2021-02-08 03:00:20
Message-ID: 20210208.120020.951157389505813521.horikyota.ntt@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

At Thu, 4 Feb 2021 09:25:00 +0000, "Wang, Shenhao" <wangsh(dot)fnst(at)cn(dot)fujitsu(dot)com> wrote in
> Hi, hacker
>
> I found in function ECPGconnect, the connect string in comment is written as:
>
> /*------
> * new style:
> * <tcp|unix>:postgresql://server[:port|:/unixsocket/path:]
> * [/db-name][?options]
> *------
> */
>
> But, the parse logical seems wrong, like:

Actually it looks like broken, but..

> [1] https://www.postgresql.org/docs/13/ecpg-connect.html#ECPG-CONNECTING

The comment and related code seem to be remnants of an ancient syntax
of hostname/socket-path style, which should have been cleaned up in
2000. I guess that the tcp: and unix: style target remains just for
backward compatibility, I'm not sure, though. Nowadays you can do
that by using the "dbname[(at)hostname][:port]" style target.

EXEC SQL CONNECT TO 'postgres@/tmp:5432';
EXEC SQL CONNECT TO 'unix:postgresql://localhost:5432/postgres?host=/tmp';

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.

And, since the documentation is saying that the bare target
specification is somewhat unstable, I'm not sure we dare to *fix* the
ecpg syntax.

In [1]
> In practice, it is probably less error-prone to use a (single-quoted)
> string literal or a variable reference.

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

regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center

Attachment Content-Type Size
remove-unix-socket-syntax-in-ecpgconnect.diff text/x-patch 1.8 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message kuroda.hayato@fujitsu.com 2021-02-08 03:02:26 RE: parse mistake in ecpg connect string
Previous Message Yugo NAGATA 2021-02-08 02:47:21 Re: Is Recovery actually paused?