Thread: Re: [GENERAL] Variable case database names

Re: [GENERAL] Variable case database names

From
Peter Eisentraut
Date:
There is some code in libpq which converts all database names to
lower-case, unless it's double quoted. That seems a little ill-conceived
to me, since you'd actually have to pass it something like
PGconnectdb("dbname=\"Newnham\"");

If anything, this would make it inconvenient it psql, because you'd have
to write
\c '"Newnham"'
since
\c "Newnham"
is interpreted differently.

Does anyone have an explanation for this? Why not leave the name as is?



On 2000-01-20, Patrick Welche mentioned:

>    List of databases
>   Database  |  Owner   
> ------------+----------
>  Newnham    | prlw1
> 
> % psql Newnham
> psql: connection to database "newnham" failed - FATAL 1:  Database "newnham" does not exist in the system catalog.
> 
> template1=> \c 'Newnham'
> FATAL 1:  Database "newnham" does not exist in the system catalog.
> Previous connection kept
> 
> 
> How can I connect to a database with a variable case name?
> 
> Cheers,
> 
> Patrick
> 
> ************
> 
> 

-- 
Peter Eisentraut                  Sernanders väg 10:115
peter_e@gmx.net                   75262 Uppsala
http://yi.org/peter-e/            Sweden




Re: [HACKERS] Re: [GENERAL] Variable case database names

From
Bruce Momjian
Date:
[Charset ISO-8859-1 unsupported, filtering to ASCII...]
> There is some code in libpq which converts all database names to
> lower-case, unless it's double quoted. That seems a little ill-conceived
> to me, since you'd actually have to pass it something like
> PGconnectdb("dbname=\"Newnham\"");
> 
> If anything, this would make it inconvenient it psql, because you'd have
> to write
> \c '"Newnham"'
> since
> \c "Newnham"
> is interpreted differently.
> 
> Does anyone have an explanation for this? Why not leave the name as is?

We do the same thing with queries, right?  We force identifiers to lower
case unless quoted.

--  Bruce Momjian                        |  http://www.op.net/~candle pgman@candle.pha.pa.us               |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


Re: [HACKERS] Re: [GENERAL] Variable case database names

From
Tom Lane
Date:
Peter Eisentraut <peter_e@gmx.net> writes:
> There is some code in libpq which converts all database names to
> lower-case, unless it's double quoted. That seems a little ill-conceived
> to me,

I think you are probably right.  The backend might try to lowercase the
name when it gets it, but it seems like libpq shouldn't be doing so
(any more than it's responsible for downcasing identifiers used in
SQL commands).

If the backend *does* lowercase the DB name used in a connect command,
is there any way to use a mixed-case DB name?  I'm not sure there is...
        regards, tom lane


Re: [HACKERS] Re: [GENERAL] Variable case database names

From
Patrick Welche
Date:
On Thu, Jan 20, 2000 at 05:04:45PM -0500, Bruce Momjian wrote:
> [Charset ISO-8859-1 unsupported, filtering to ASCII...]
> > There is some code in libpq which converts all database names to
> > lower-case, unless it's double quoted. That seems a little ill-conceived
> > to me, since you'd actually have to pass it something like
> > PGconnectdb("dbname=\"Newnham\"");
> > 
> > If anything, this would make it inconvenient it psql, because you'd have
> > to write
> > \c '"Newnham"'
> > since
> > \c "Newnham"
> > is interpreted differently.
> > 
> > Does anyone have an explanation for this? Why not leave the name as is?
> 
> We do the same thing with queries, right?  We force identifiers to lower
> case unless quoted.

The point was: the database name was quoted. I didn't think to quote it
a second time. (single quoting for the create was sufficient, and the export
from access didn't mind about the case)

Cheers,

Patrick


Re: [HACKERS] Re: [GENERAL] Variable case database names

From
Peter Eisentraut
Date:
On 2000-01-20, Tom Lane mentioned:

> Peter Eisentraut <peter_e@gmx.net> writes:
> > There is some code in libpq which converts all database names to
> > lower-case, unless it's double quoted. That seems a little ill-conceived
> > to me,
> 
> I think you are probably right.  The backend might try to lowercase the
> name when it gets it, but it seems like libpq shouldn't be doing so
> (any more than it's responsible for downcasing identifiers used in
> SQL commands).
> 
> If the backend *does* lowercase the DB name used in a connect command,
> is there any way to use a mixed-case DB name?  I'm not sure there is...

The backend doesn't lower case it. I removed that part in libpq and now
it works fine.

-- 
Peter Eisentraut                  Sernanders väg 10:115
peter_e@gmx.net                   75262 Uppsala
http://yi.org/peter-e/            Sweden