PostgreSQL - automatically create a database for users on first login Is there a way to configure PostgreSQL to create a database whose name is the same as the username on the user's first login?

Scenario:

In pg_hba.conf there will be a rule something like:

local sameuser all ident sameuser


When a user connects to PostgreSQL via console/psql, 


If a database with the users name exists, just connect to database.
If it does not exist, create a database named after the user and connect the user to the newly created database.


There are a lot of users and I do not want to manually create these databases all at once, upfront.
No that's not possible. 

Even if it was possible: as you need to specify a database when you connect, the new database wouldn't be the one the user connected to (and there is no way to re-route the user to the newly created one).