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