From: | "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com> |
---|---|
To: | 'Ashutosh Bapat' <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com> |
Cc: | "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | RE: pgbench without dbname worked differently with psql and pg_dump |
Date: | 2025-01-22 01:54:19 |
Message-ID: | OSCPR01MB149667BAC97F9657F1A7482B8F5E12@OSCPR01MB14966.jpnprd01.prod.outlook.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
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
Attachment | Content-Type | Size |
---|---|---|
0001-pgbench-Use-default-connection-when-dbname-is-not-sp.patch | application/octet-stream | 1.0 KB |
0002-Unify-descriptions-when-dbname-is-not-specified.patch | application/octet-stream | 3.4 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2025-01-22 02:59:58 | Re: allow trigger to get updated columns |
Previous Message | jian he | 2025-01-22 01:36:42 | Re: Statistics Import and Export |