Re: Database name with semicolon

Lists: pgsql-general
From: Joby John <Joby(dot)John(at)nccgroup(dot)trust>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Database name with semicolon
Date: 2018-06-27 13:22:33
Message-ID: 2b0a3c93173a4bef8117c897bcca6957@MANDBSEXCH03.nccgroup.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Hi,

We have a windows application which communicate to Postgres database via PostgreSQL ODBC drivers for windows.
One of our customers has a database with semicolon in its name (e.g.: "db; name") and our application is failing to establish connection to that database saying like it could not find the database.
We tried all known possibilities by enclosing the DB name under quotes, curly brackets etc. but none solved the problem.

I wonder whether there is any possible way to achieve connection to such database. If not, probably it's better not to support semicolons within the database name.
Not sure whether I need to submit this query as a bug or not. Any help is much appreciated.

Thanks and Regards,
Joby John
________________________________
Joby John
Software Developer
NCC Group
Kings Court, Kingston Road, Leatherhead, KT22 7SL

Telephone: +44 1372 383 800<tel:+44%201372%20383%20800>
Mobile: <tel:>
Website: www.nccgroup.trust<http://www.nccgroup.trust>
Twitter: @NCCGroupplc<https://twitter.com/NCCGroupplc>
[https://www.nccgroup.trust/static/img/emaillogo/ncc-group-logo.png] <http://www.nccgroup.trust/>
________________________________

This email is sent for and on behalf of NCC Group. NCC Group is the trading name of NCC Services Limited (Registered in England CRN: 2802141). The ultimate holding company is NCC Group plc (Registered in England CRN: 4627044). This email may be confidential and/or legally privileged.


From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Joby John <Joby(dot)John(at)nccgroup(dot)trust>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Database name with semicolon
Date: 2018-06-27 14:25:38
Message-ID: CAFj8pRCTJUeRGRmRCTe-wTWpw20UHyEaTT0PcAJzM60HGz--Kw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Hi

2018-06-27 15:22 GMT+02:00 Joby John <Joby(dot)John(at)nccgroup(dot)trust>:

> Hi,
>
>
>
> We have a windows application which communicate to Postgres database via
> PostgreSQL ODBC drivers for windows.
>
> One of our customers has a database with semicolon in its name (e.g.: “db;
> name”) and our application is failing to establish connection to that
> database saying like it could not find the database.
>
> We tried all known possibilities by enclosing the DB name under quotes,
> curly brackets etc. but none solved the problem.
>
>
>
> I wonder whether there is any possible way to achieve connection to such
> database. If not, probably it’s better not to support semicolons within the
> database name.
>
> Not sure whether I need to submit this query as a bug or not. Any help is
> much appreciated.
>

modern Postgresql has not any problems with special chars

postgres=# create database "bad name ;;;;";
CREATE DATABASE
postgres=# \q
[pavel(at)nemesis ~]$ psql 'bad name ;;;;'
psql (11beta1)
Type "help" for help.

bad name ;;;;=#

What is version of Postgres?

Did you try double quotes?

Regards

Pavel

>
>
> Thanks and Regards,
>
> Joby John
> ------------------------------
> Joby John
> Software Developer
> NCC Group
> Kings Court, Kingston Road, Leatherhead, KT22 7SL
>
> Telephone: +44 1372 383 800 <+44%201372%20383%20800>
> Mobile:
> Website: www.nccgroup.trust
> Twitter: @NCCGroupplc <https://twitter.com/NCCGroupplc>
> <http://www.nccgroup.trust/>
> ------------------------------
>
> This email is sent for and on behalf of NCC Group. NCC Group is the
> trading name of NCC Services Limited (Registered in England CRN: 2802141).
> The ultimate holding company is NCC Group plc (Registered in England CRN:
> 4627044). This email may be confidential and/or legally privileged.
>


From: Joby John <Joby(dot)John(at)nccgroup(dot)trust>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: RE: EXTERNAL: Re: Database name with semicolon
Date: 2018-06-27 14:39:32
Message-ID: 0bd653e73c51493098da7621b28a958a@MANDBSEXCH03.nccgroup.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Hi Pavel,

Thanks for coming back to me.

The version of the Postgres server where I am trying is: 9.5.3
Yes, I tried putting the database name in double quotes with no luck.
Please note we are using PostgreSQL Unicode ODBC driver (version 10.2) to communicate with the server.

Regards,
Joby John

From: Pavel Stehule [mailto:pavel(dot)stehule(at)gmail(dot)com]
Sent: 27 June 2018 15:26
To: Joby John <Joby(dot)John(at)nccgroup(dot)trust>
Cc: pgsql-general(at)postgresql(dot)org
Subject: EXTERNAL: Re: Database name with semicolon

Hi

2018-06-27 15:22 GMT+02:00 Joby John <Joby(dot)John(at)nccgroup(dot)trust<mailto:Joby(dot)John(at)nccgroup(dot)trust>>:
Hi,

We have a windows application which communicate to Postgres database via PostgreSQL ODBC drivers for windows.
One of our customers has a database with semicolon in its name (e.g.: “db; name”) and our application is failing to establish connection to that database saying like it could not find the database.
We tried all known possibilities by enclosing the DB name under quotes, curly brackets etc. but none solved the problem.

I wonder whether there is any possible way to achieve connection to such database. If not, probably it’s better not to support semicolons within the database name.
Not sure whether I need to submit this query as a bug or not. Any help is much appreciated.

modern Postgresql has not any problems with special chars

postgres=# create database "bad name ;;;;";
CREATE DATABASE
postgres=# \q
[pavel(at)nemesis ~]$ psql 'bad name ;;;;'
psql (11beta1)
Type "help" for help.

bad name ;;;;=#

What is version of Postgres?

Did you try double quotes?

Regards

Pavel

Thanks and Regards,
Joby John
________________________________
Joby John
Software Developer
NCC Group
Kings Court, Kingston Road, Leatherhead, KT22 7SL

Telephone: +44 1372 383 800<tel:+44%201372%20383%20800>
Mobile:
Website: www.nccgroup.trust<http://www.nccgroup.trust>
Twitter: @NCCGroupplc<https://twitter.com/NCCGroupplc>

[https://www.nccgroup.trust/static/img/emaillogo/ncc-group-logo.png]<http://www.nccgroup.trust/>

________________________________

This email is sent for and on behalf of NCC Group. NCC Group is the trading name of NCC Services Limited (Registered in England CRN: 2802141). The ultimate holding company is NCC Group plc (Registered in England CRN: 4627044). This email may be confidential and/or legally privileged.

________________________________
Joby John
Software Developer
NCC Group
Kings Court, Kingston Road, Leatherhead, KT22 7SL

Telephone: +44 1372 383 800<tel:+44%201372%20383%20800>
Mobile: <tel:>
Website: www.nccgroup.trust<http://www.nccgroup.trust>
Twitter: @NCCGroupplc<https://twitter.com/NCCGroupplc>
[https://www.nccgroup.trust/static/img/emaillogo/ncc-group-logo.png] <http://www.nccgroup.trust/>
________________________________

This email is sent for and on behalf of NCC Group. NCC Group is the trading name of NCC Services Limited (Registered in England CRN: 2802141). The ultimate holding company is NCC Group plc (Registered in England CRN: 4627044). This email may be confidential and/or legally privileged.


From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Joby John <Joby(dot)John(at)nccgroup(dot)trust>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: EXTERNAL: Re: Database name with semicolon
Date: 2018-06-27 14:47:41
Message-ID: CAFj8pRDJQUazDDGvS2XzCUTHtA+xWhMQO9_OWCiFUDRq1EYJGw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Hi

2018-06-27 16:39 GMT+02:00 Joby John <Joby(dot)John(at)nccgroup(dot)trust>:

> Hi Pavel,
>
>
>
> Thanks for coming back to me.
>

please, don't top post
https://en.wikipedia.org/wiki/Posting_style#Top-posting

>
> The version of the Postgres server where I am trying is: 9.5.3
>

9.5 is modern Postgres. There should not be problems with names.

> Yes, I tried putting the database name in double quotes with no luck.
>
> Please note we are using PostgreSQL Unicode ODBC driver (version 10.2) to
> communicate with the server.
>

looks like ODBC issue - semicolon has some semantic there

https://stackoverflow.com/questions/22398212/escape-semicolon-in-odbc-connection-string-in-app-config-file

but probably you read these pages

Maybe some combination of quotes is necessary

https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ms722656(v=vs.85)

you can try

dbname = '"ssss; sss"'

>
> Regards,
>
> Joby John
>
>
>
> *From:* Pavel Stehule [mailto:pavel(dot)stehule(at)gmail(dot)com]
> *Sent:* 27 June 2018 15:26
> *To:* Joby John <Joby(dot)John(at)nccgroup(dot)trust>
> *Cc:* pgsql-general(at)postgresql(dot)org
> *Subject:* EXTERNAL: Re: Database name with semicolon
>
>
>
> Hi
>
>
>
> 2018-06-27 15:22 GMT+02:00 Joby John <Joby(dot)John(at)nccgroup(dot)trust>:
>
> Hi,
>
>
>
> We have a windows application which communicate to Postgres database via
> PostgreSQL ODBC drivers for windows.
>
> One of our customers has a database with semicolon in its name (e.g.: “db;
> name”) and our application is failing to establish connection to that
> database saying like it could not find the database.
>
> We tried all known possibilities by enclosing the DB name under quotes,
> curly brackets etc. but none solved the problem.
>
>
>
> I wonder whether there is any possible way to achieve connection to such
> database. If not, probably it’s better not to support semicolons within the
> database name.
>
> Not sure whether I need to submit this query as a bug or not. Any help is
> much appreciated.
>
>
>
> modern Postgresql has not any problems with special chars
>
>
>
> postgres=# create database "bad name ;;;;";
> CREATE DATABASE
> postgres=# \q
> [pavel(at)nemesis ~]$ psql 'bad name ;;;;'
> psql (11beta1)
> Type "help" for help.
>
> bad name ;;;;=#
>
>
>
> What is version of Postgres?
>
>
>
> Did you try double quotes?
>
>
>
> Regards
>
>
>
> Pavel
>
>
>
>
>
>
>
> Thanks and Regards,
>
> Joby John
> ------------------------------
>
> Joby John
> Software Developer
> NCC Group
> Kings Court, Kingston Road, Leatherhead, KT22 7SL
>
> Telephone: +44 1372 383 800 <+44%201372%20383%20800>
> Mobile:
> Website: www.nccgroup.trust
> Twitter: @NCCGroupplc <https://twitter.com/NCCGroupplc>
>
> <http://www.nccgroup.trust/>
> ------------------------------
>
> This email is sent for and on behalf of NCC Group. NCC Group is the
> trading name of NCC Services Limited (Registered in England CRN: 2802141).
> The ultimate holding company is NCC Group plc (Registered in England CRN:
> 4627044). This email may be confidential and/or legally privileged.
>
>
> ------------------------------
> Joby John
> Software Developer
> NCC Group
> Kings Court, Kingston Road, Leatherhead, KT22 7SL
>
> Telephone: +44 1372 383 800 <+44%201372%20383%20800>
> Mobile:
> Website: www.nccgroup.trust
> Twitter: @NCCGroupplc <https://twitter.com/NCCGroupplc>
> <http://www.nccgroup.trust/>
> ------------------------------
>
> This email is sent for and on behalf of NCC Group. NCC Group is the
> trading name of NCC Services Limited (Registered in England CRN: 2802141).
> The ultimate holding company is NCC Group plc (Registered in England CRN:
> 4627044). This email may be confidential and/or legally privileged.
>


From: Vick Khera <vivek(at)khera(dot)org>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Database name with semicolon
Date: 2018-06-27 18:54:24
Message-ID: CALd+dcdeWfFwYqatKO+GGDpc7L9nsoseG7FjC7EzygeOdvxCbg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Wed, Jun 27, 2018 at 10:25 AM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
wrote:

> Hi
>
>
> modern Postgresql has not any problems with special chars
>
>
I think the issue is that he cannot create a proper connection string to
pass to the ODBC driver, since semi-colon is used as a delimiter for the
fields.


From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Joby John <Joby(dot)John(at)nccgroup(dot)trust>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Database name with semicolon
Date: 2018-06-27 22:16:23
Message-ID: 2b53f43f-6f79-19c5-3595-ec90984f53e5@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On 06/27/2018 06:22 AM, Joby John wrote:
> Hi,
>
> We have a windows application which communicate to Postgres database via
> PostgreSQL ODBC drivers for windows.
>
> One of our customers has a database with semicolon in its name (e.g.:
> “db; name”) and our application is failing to establish connection to
> that database saying like it could not find the database.
>
> We tried all known possibilities by enclosing the DB name under quotes,
> curly brackets etc. but none solved the problem.
>
> I wonder whether there is any possible way to achieve connection to such
> database. If not, probably it’s better not to support semicolons within
> the database name.

https://msdn.microsoft.com/en-us/library/system.data.odbc.odbcconnection.connectionstring(v=vs.110).aspx

"
...

Applications do not have to add braces around the attribute value after
the Driver keyword unless the attribute contains a semicolon (;), in
which case the braces are required. If the attribute value that the
driver receives includes braces, the driver should not remove them but
they should be part of the returned connection string.

...

"

See if something like below works:

{db; name}

>
> Not sure whether I need to submit this query as a bug or not. Any help
> is much appreciated.
>
> Thanks and Regards,
>
> Joby John
>
> ------------------------------------------------------------------------
> Joby John
> Software Developer
> NCC Group
> Kings Court, Kingston Road, Leatherhead, KT22 7SL
>
> Telephone: +44 1372 383 800 <tel:+44 1372 383 800>
> Mobile: <tel:>
> Website: www.nccgroup.trust <http://www.nccgroup.trust>
> Twitter: @NCCGroupplc <https://twitter.com/NCCGroupplc>
> <http://www.nccgroup.trust/>
>
> ------------------------------------------------------------------------
>
> This email is sent for and on behalf of NCC Group. NCC Group is the
> trading name of NCC Services Limited (Registered in England CRN:
> 2802141). The ultimate holding company is NCC Group plc (Registered in
> England CRN: 4627044). This email may be confidential and/or legally
> privileged.
>

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


From: "joby(dot)john(at)nccgroup(dot)trust" <Joby(dot)John(at)nccgroup(dot)trust>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Database name with semicolon
Date: 2018-06-28 10:10:28
Message-ID: 1530180628088-0.post@n3.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

> See if something like below works:
> {db; name}

Hi,

Thanks for the responses.

I tried putting curly brackets around the value of database like you
mentioned.
{db; name}
But the server was treating the brackets as part of the database name and so
did not work.
I tried double quotes like
"db; name" which also didn't work.

Not sure what else I can try or whether the ODBC driver supports database
name with a semicolon at all.
I know that in the case of password we can put the string enclosed within
curly brackets to escape special characters but not appears to be working
for the database.

Regards,
Joby

--
Sent from: http://www.postgresql-archive.org/PostgreSQL-general-f1843780.html


From: Thiemo Kellner <thiemo(at)gelassene-pferde(dot)biz>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Database name with semicolon
Date: 2018-06-28 12:32:14
Message-ID: 20180628143214.15750cgekzvz2uds@www.gelassene-pferde.biz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Zitat von "joby(dot)john(at)nccgroup(dot)trust" <Joby(dot)John(at)nccgroup(dot)trust>:

> Not sure what else I can try or whether the ODBC driver supports database
> name with a semicolon at all.

Not knowing much about ODBC, how about single quotes?

And if you pass the entire URL, would it be possible to pass instead
values to Kind of function?

Kind regards Thiemo

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.


From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: "joby(dot)john(at)nccgroup(dot)trust" <Joby(dot)John(at)nccgroup(dot)trust>
Cc: "pgsql-general(at)postgresql(dot)org >> PG-General Mailing List" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Database name with semicolon
Date: 2018-06-28 15:48:56
Message-ID: CAFj8pRAXbJ5rkVH3Aj4yJ=fK3hy4zdJaRsanvGvi0PtDQfCQqw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

2018-06-28 12:10 GMT+02:00 joby(dot)john(at)nccgroup(dot)trust <
Joby(dot)John(at)nccgroup(dot)trust>:

> > See if something like below works:
> > {db; name}
>
>
>
> Hi,
>
> Thanks for the responses.
>
> I tried putting curly brackets around the value of database like you
> mentioned.
> {db; name}
> But the server was treating the brackets as part of the database name and
> so
> did not work.
> I tried double quotes like
> "db; name" which also didn't work.
>

please, can you try

'"db; name"' .. double quotes nested in apostrophes

> Not sure what else I can try or whether the ODBC driver supports database
> name with a semicolon at all.
> I know that in the case of password we can put the string enclosed within
> curly brackets to escape special characters but not appears to be working
> for the database.
>
> Regards,
> Joby
>
>
>
> --
> Sent from: http://www.postgresql-archive.org/PostgreSQL-general-
> f1843780.html
>
>


From: "joby(dot)john(at)nccgroup(dot)trust" <Joby(dot)John(at)nccgroup(dot)trust>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Database name with semicolon
Date: 2018-06-28 16:22:46
Message-ID: 1530202966938-0.post@n3.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Pavel Stehule wrote
> 2018-06-28 12:10 GMT+02:00 please, can you try'"db; name"' .. double
> quotes nested in apostrophes

I tried this with no luck. Also tried the other way, apostrophe nested in
double quotes with same results.Looks like an issue in ODBC driver as it's
not handling semicolon within database name. Probably needs to go back to
the client asking to rename the database.

--
Sent from: http://www.postgresql-archive.org/PostgreSQL-general-f1843780.html


From: Gavin Flower <GavinFlower(at)archidevsys(dot)co(dot)nz>
To: "joby(dot)john(at)nccgroup(dot)trust" <Joby(dot)John(at)nccgroup(dot)trust>, pgsql-general(at)postgresql(dot)org
Subject: Re: Database name with semicolon
Date: 2018-06-29 11:04:56
Message-ID: f08841ab-29c0-ff5a-4739-b94348bac4b1@archidevsys.co.nz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On 29/06/18 04:22, joby(dot)john(at)nccgroup(dot)trust wrote:
>
> Pavel Stehule wrote
> 2018-06-28 12:10 GMT+02:00 please, can you try '"db; name"' ..
> double quotes nested in apostrophes
>
> I tried this with no luck. Also tried the other way, apostrophe nested
> in double quotes with same results. Looks like an issue in ODBC driver
> as it's not handling semicolon within database name. Probably needs to
> go back to the client asking to rename the database.
> ------------------------------------------------------------------------
> Sent from the PostgreSQL - general mailing list archive
> <http://www.postgresql-archive.org/PostgreSQL-general-f1843780.html>
> at Nabble.com.

Reminds me of:
    https://xkcd.com/327/
'Little Bobby Tables'