Обсуждение: BUG #19043: jdbc connection url is not case insensitive

Поиск
Список
Период
Сортировка

BUG #19043: jdbc connection url is not case insensitive

От
PG Bug reporting form
Дата:
The following bug has been logged on the website:

Bug reference:      19043
Logged by:          Marijo Kristo
Email address:      m.kristo@rewe-group.at
PostgreSQL version: 17.6
Operating system:   Linux
Description:

Hello,

when creating a database in Postgres with the name e.g. "testDB", postgres
creates a database in lowercase testdb.
So far so good, but when trying to connect via psql and passing as database
name "testDB" the connection fails, because it says the database does not
exists.
In my opinion, the libq library should also be case insensitive and
automatically convert this to a lowercase "testdb" and not return an error.

What are your thoughts ?

Best Regards
Ing. Marijo Kristo


Re: BUG #19043: jdbc connection url is not case insensitive

От
"David G. Johnston"
Дата:
On Thursday, September 4, 2025, PG Bug reporting form <noreply@postgresql.org> wrote:
The following bug has been logged on the website:

Bug reference:      19043
Logged by:          Marijo Kristo
Email address:      m.kristo@rewe-group.at
PostgreSQL version: 17.6
Operating system:   Linux
Description:       

Hello,

when creating a database in Postgres with the name e.g. "testDB", postgres
creates a database in lowercase testdb.
So far so good, but when trying to connect via psql and passing as database
name "testDB" the connection fails, because it says the database does not
exists.
In my opinion, the libq library should also be case insensitive and
automatically convert this to a lowercase "testdb" and not return an error.

What are your thoughts ?

Most/All usages of identifiers outside of an SQL Command identifier do not result in case-folding.  And besides, changing any that do is a breaking change that we are unlikely to accept.

David J.
 

Re: BUG #19043: jdbc connection url is not case insensitive

От
Tom Lane
Дата:
PG Bug reporting form <noreply@postgresql.org> writes:
> when creating a database in Postgres with the name e.g. "testDB", postgres
> creates a database in lowercase testdb.
> So far so good, but when trying to connect via psql and passing as database
> name "testDB" the connection fails, because it says the database does not
> exists.
> In my opinion, the libq library should also be case insensitive and
> automatically convert this to a lowercase "testdb" and not return an error.

Then it would become impossible to connect to databases that have
upper-case or mixed-case names.

Our general position on such matters is that automatic downcasing
happens in SQL commands, but not in any other context (such as
command-line arguments or connection strings).

            regards, tom lane



Re: BUG #19043: jdbc connection url is not case insensitive

От
Greg Sabino Mullane
Дата:
An alternate view: if you really care about case, double quote the database on creation, as per your "e.g.":

create database "testDB";

At that point, your psql connection will work. But as with all non-lowercase objects, extra care will be needed and it will need to be quoted in some contexts. It's so much easier to just leave database, schema, table, and column names as lowercase. Then everything just works.

Cheers,
Greg

AW: BUG #19043: jdbc connection url is not case insensitive

От
Kristo Marijo
Дата:
Hello,

thanks for the answers and you are absolutely right.
I think then we can close this issue.

Best Regards
Marijo

Von: Greg Sabino Mullane <htamfids@gmail.com>
Gesendet: Samstag, 6. September 2025 02:41
An: Kristo Marijo <m.kristo@rewe-group.at>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Betreff: Re: BUG #19043: jdbc connection url is not case insensitive
 

CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe. If you are unsure or already opened a link or attachment please contact your local IT helpdesk.

An alternate view: if you really care about case, double quote the database on creation, as per your "e.g.":

create database "testDB";

At that point, your psql connection will work. But as with all non-lowercase objects, extra care will be needed and it will need to be quoted in some contexts. It's so much easier to just leave database, schema, table, and column names as lowercase. Then everything just works.

Cheers,
Greg