RE: About limitation characters in ECPG's connection string

Поиск
Список
Период
Сортировка
От Egashira, Yusuke
Тема RE: About limitation characters in ECPG's connection string
Дата
Msg-id 848B1649C8A6274AA527C4472CA11EDD5FCA20CC@G01JPEXMBYT02
обсуждение исходный текст
Ответ на Re: About limitation characters in ECPG's connection string  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-docs
Hi Tom,

> We put in a change about that last month:
> 
> https://git.postgresql.org/gitweb/?p=postgresql.git&a=commitdiff&h=756349c87

Thank you for accepting my claim and updating document!
And sorry for not checking the development version of the document.


> > Note that this parameter does not allow the symbols with special meaning of
> > the URI parts, e.g. "&" and "?". 
> 
> Hm, I agree that the options part doesn't accept "&", but I don't see
> anything preventing use of a "?" there.

I have checked additional pattern about this limitation, and I found also "?" is not able to use in below case.
  user             : tst
  password         : test?pass
  connection string: tcp:postgresql://localhost/egashira?user=tst&password=test?pss

This seems to be caused by ECPGconnect's parsing routine.
https://github.com/postgres/postgres/blob/master/src/interfaces/ecpg/ecpglib/connect.c#L371

----
            if (strncmp(dbname + offset, "postgresql://", strlen("postgresql://")) == 0)
            {

                /*------
                 * new style:
                 *    <tcp|unix>:postgresql://server[:port|:/unixsocket/path:]
                 *    [/db-name][?options]
                 *------
                 */
                offset += strlen("postgresql://");

                tmp = strrchr(dbname + offset, '?');
                if (tmp != NULL)    /* options given */
                {
                    options = ecpg_strdup(tmp + 1, lineno);
                    *tmp = '\0';
                }
----

In "tcp:postgresql://" style connection string, ECPGconnect searches for "?" from the end of the connection string to
extractoptions part.
 
If "?" is in options string part (e.g. as a password value) , the extracting will be failed.

Regards.
Yusuke Egashira.


-----Original Message-----
From: Tom Lane [mailto:tgl@sss.pgh.pa.us] 
Sent: Wednesday, September 18, 2019 12:55 AM
To: Egashira, Yusuke/江頭 勇佑 <egashira.yusuke@jp.fujitsu.com>
Cc: pgsql-docs@lists.postgresql.org
Subject: Re: About limitation characters in ECPG's connection string

PG Doc comments form <noreply@postgresql.org> writes:
> Please add the note about the limitation characters in connection string.
> For example, I think that below explanation should be in the Parameter
> section of connection_target.

We put in a change about that last month:

https://git.postgresql.org/gitweb/?p=postgresql.git&a=commitdiff&h=756349c87

Although that hasn't yet propagated to any released branches,
you can see it in the "devel" version of that documentation page:

https://www.postgresql.org/docs/devel/ecpg-connect.html#ECPG-CONNECTING

> Note that this parameter does not allow the symbols with special meaning of
> the URI parts, e.g. "&" and "?". 

Hm, I agree that the options part doesn't accept "&", but I don't see
anything preventing use of a "?" there.

            regards, tom lane





В списке pgsql-docs по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: About limitation characters in ECPG's connection string
Следующее
От: Michael Paquier
Дата:
Сообщение: Re: Is it typo of connection_name?