From: | hubert depesz lubaczewski <depesz(at)depesz(dot)com> |
---|---|
To: | Neha Khatri <nehakhatri5(at)gmail(dot)com> |
Cc: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: Why psql connection assumes default database name as the username |
Date: | 2017-03-24 08:57:58 |
Message-ID: | 20170324085758.GA6674@depesz.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
On Fri, Mar 24, 2017 at 08:39:30AM +0000, Neha Khatri wrote:
> Yes, so psql should say "Not sure which database to connect to. Please
> specify a valid database name using -d option".
> For backwards compatibility, psql can still attempt to connect to db with
> name same as the username, but the error message could be more like
> providing the information, what can be done next.
Sorry, but I don't agree.
I use databases named like users all the time, and love the fact that
I don't have to provide dbname when it's obvious.
Error message is, in my opinion, clear enough - you're trying to connect
to database that doesn't exist. Why you are trying to - impossible to
tell. Maybe you made a typo. Maybe you forgot to add option. Maybe you
forgot to export env variable.
What is being chosen as user/database name is documented in psql docs.
Additionally - if you want to require that user provides database name,
why don't require also host and port? After all, you need all
four parameters to connect: host, port, username and database name.
If all you ever want is to connect to db named "x", then why not using
psql -d x, or even setting PGDATABASE to x?
depesz
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Zakharov | 2017-03-24 09:52:13 | Undo all changes made by production release |
Previous Message | Neha Khatri | 2017-03-24 08:39:30 | Re: Why psql connection assumes default database name as the username |