Re: Question about password character in ECPG's connection string

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: "Egashira, Yusuke" <egashira(dot)yusuke(at)jp(dot)fujitsu(dot)com>, 'Giuseppe Sacco' <giuseppe(at)eppesuigoccas(dot)homedns(dot)org>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Question about password character in ECPG's connection string
Date: 2019-08-28 13:59:44
Message-ID: d9b3700d-40bd-1229-2e26-167fafab5c8a@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 8/27/19 6:18 PM, Egashira, Yusuke wrote:
> Hi, Giuseppe,
>
> Thanks to response to my question!
>
>> It seems to me that ECPG documentation does not allow specifying
>> username and/or password in the connection string. The correct syntax
>> should be:
>>
>> EXEC SQL CONNECT TO "unix:postgresql://localhost/connectdb" USER
>> "myuser" IDENTIFIED BY "pass&word"
>
> Yes, I could connect to database with "USER" and "IDENTIFIED BY" phrase in CONNECT statement.
> However, I could also connect to database with password in connection string when my password does not contains '&' character.
>
> 1. In database,
> > CREATE ROLE myuser LOGIN PASSWORD 'password';
> 2. In ECPG application,
> EXEC SQL CONNECT "tcp:postgresql://localhost?user=myuser&password=password";
> -> The connection was succeeded.
>
> This behavior confuse me.

My guess it that what is happening is:

1) Given password: my&pwd

2) "tcp:postgresql://localhost?user=myuser&password=password" looks like

"tcp:postgresql://localhost?user=myuser&password=my&pwd"

and password is parsed on the & and you also end up with an extra
parameter pwd

Have you tried quoting the password?

>
> If user and password cannot write in connection string, what are parameters allowed in "connection_option" ?
> I hope I can get this information from the ECPG documentation.
>
> Regards.
>
> --
> Yusuke, Egashira.
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2019-08-28 14:07:26 Re: How to log 'user time' in postgres logs
Previous Message Tom Lane 2019-08-28 13:54:51 Re: