Thread: Problem with createdb & case (7.1.3)

Problem with createdb & case (7.1.3)

From
"Chr. Rossmanith"
Date:
Hi,

I'd like to create a database named "NEUROMR". The
command "createdb
NEUROMR" succeeds. But, connecting to this DB fails:

# psql "NEUROMR"
Connection to database 'neuromr' failed.
FATAL 1:  Database "neuromr" does not exist in the
system catalog.


Just to assure the DB exists I've executed "createdb
NEUROMR" a second
time and (as expected) got the message:

ERROR:  CREATE DATABASE: database "NEUROMR" already
exists
createdb: database creation failed


Does anybody out there have an explanation for this
behaviour? I'm using
PostgreSQL 7.1.3.


Thank you,

Christina Rossmanith




Re: Problem with createdb & case (7.1.3)

From
Tom Lane
Date:
"Chr. Rossmanith" <cr@neuro.ma.uni-heidelberg.de> writes:
> # psql "NEUROMR"
> Connection to database 'neuromr' failed.

Hmm.  psql seems to be downcasing your database name for you.
But it hasn't done that in a long time ... not since 7.0, at least,
which is the oldest version I have handy to check.  Are you
sure your psql program is up to date?  (Try psql -V to see the
version of psql itself.  If it doesn't give you one, it's
definitely too old.)

I think that in older psql versions it would work to say
    psql '"NEUROMR"'
(you need the extra quoting level to keep the shell from stripping
off the double quotes).  But we got rid of the auto-downcasing
feature for database names entered on the command line, because
this was too much of a pain in the neck.

            regards, tom lane

Re: Problem with createdb & case (7.1.3)

From
Vijay Deval
Date:
Hi

from the # prompt, it appears that you are already connected to some
database.

   #\c NEUROMR

should connect you to the new database.

Vijay

"Chr. Rossmanith" wrote:
>
> Hi,
>
> I'd like to create a database named "NEUROMR". The
> command "createdb
> NEUROMR" succeeds. But, connecting to this DB fails:
>
> # psql "NEUROMR"
> Connection to database 'neuromr' failed.
> FATAL 1:  Database "neuromr" does not exist in the



Re: Problem with createdb & case (7.1.3)

From
"Oliver Elphick"
Date:
Vijay Deval wrote:
  >Hi
  >
  >from the # prompt, it appears that you are already connected to some
  >database.
  >
  >   #\c NEUROMR
  >
  >should connect you to the new database.

The # is the root prompt from Unix.  (It's not a good idea to run as root
if you don't have to.)

  >Vijay
  >
  >"Chr. Rossmanith" wrote:
  >>
  >> Hi,
  >>
  >> I'd like to create a database named "NEUROMR". The
  >> command "createdb
  >> NEUROMR" succeeds. But, connecting to this DB fails:
  >>
  >> # psql "NEUROMR"
  >> Connection to database 'neuromr' failed.
  >> FATAL 1:  Database "neuromr" does not exist in the

Your problem is that you have created a database with an uppercase name, but
psql is translating it to lowercase.  It probably means you are using an
older version of PostgreSQL, because this doesn't happen for me with 7.1.3.

I don't know how to tell psql from the command line not to do this, so
your best bet is to drop the database (dropdb NEUROMR) and recreate it with
a normal lowercase name.

If you _have_ to connect to NEUROMR, you could try this:

psql -d template1
\c NEUROMR

--
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C

     "I press toward the mark for the prize of the high
      calling of God in Christ Jesus."
                                   Philippians 3:14



Re: Problem with createdb & case (7.1.3)

From
"Chr. Rossmanith"
Date:
Hi,

thanks a lot for your responses to my question concerning psql and case.
The hint from Tom Lane was the best. There was an old psql which was
found first in the search path...what a stupid mistake. Now, when using
the correct psql everything works like expected...without any quotes.
(In my original posting I used quotes just to separate commands entered
from my question. I never entered a quoted psql command with options...)

Christina Rossmanith


Vijay Deval wrote:

> Hi
>
> from the # prompt, it appears that you are already connected to some
> database.
>
>    #\c NEUROMR
>
> should connect you to the new database.
>
> Vijay

No, this was just the root users prompt.

>
>
> "Chr. Rossmanith" wrote:
> >
> > Hi,
> >
> > I'd like to create a database named "NEUROMR". The
> > command "createdb
> > NEUROMR" succeeds. But, connecting to this DB fails:
> >
> > # psql "NEUROMR"
> > Connection to database 'neuromr' failed.
> > FATAL 1:  Database "neuromr" does not exist in the