Dear Ashutosh, > I see the same behaviour. The code in pgbench which decided the > database to connect to, looks similar to the relevant code in > createdb. But createdb documentation is in agreement with the code. > [1] > ``` > dbname > > Specifies the name of the database to be created. The name must be > unique among all PostgreSQL databases in this cluster. The default is > to create a database with the same name as the current system user. > ```
Thanks for the confirmation. I found below executables seem to have the same logic to decide the dbname: - pg_amcheck - pgbench - clusterdb - createdb - reindexdb - vacuumdb Also, I found that clusterdb/reindexdb/vacuumdb has the same description like "If that is not set, the user name specified for the connection is used.", it was not correct. IIUC createdb has the good description [1] and it can be re-used everywhere. > I couldn't locate the code in psql which calculates the name of the > database from a quick read of psql/startup.c. I think pgbench should > behave like psql, not like createdb. Yes, it is same as feeling. IIUC libpq functions accept that dbname is NULL, so no need to do something. One consideration is the compatibility issue - Users may surprise because the default behavior is changed. Based on the discussion, I've created two patches. 0001 contains changes for the pgbench, and 0002 is a doc patch for other applications. [1]: description in created.sgml: ``` The default is to create a database with the same name as the current system user. ``` ------ Best regards, Hayato Kuroda
0001-pgbench-Use-default-connection-when-dbname-is-not-sp.patch
Description: 0001-pgbench-Use-default-connection-when-dbname-is-not-sp.patch
0002-Unify-descriptions-when-dbname-is-not-specified.patch
Description: 0002-Unify-descriptions-when-dbname-is-not-specified.patch