RE: About limitation characters in ECPG's connection string

"Egashira, Yusuke" <[email protected]>
Newsgroups gmane.comp.db.postgresql.devel.documentation
Message-ID <848B1649C8A6274AA527C4472CA11EDD5FCA20CC@G01JPEXMBYT02>
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 extract options 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:[email protected]] 
Sent: Wednesday, September 18, 2019 12:55 AM
To: Egashira, Yusuke/  <[email protected]>
Cc: [email protected]
Subject: Re: About limitation characters in ECPG's connection string

PG Doc comments form <[email protected]> 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.