Re: Fwd: Identify system databases

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: Dominique Devienne <ddevienne(at)gmail(dot)com>
Cc: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Igor Korot <ikorot01(at)gmail(dot)com>, "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Fwd: Identify system databases
Date: 2025-04-16 12:30:27
Message-ID: 2dffe860b085b927726a052bcfe16ede704ab923.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, 2025-04-16 at 10:09 +0200, Dominique Devienne wrote:
> On Wed, Apr 16, 2025 at 9:32 AM Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at> wrote:
> > On Tue, 2025-04-15 at 17:24 -0700, Adrian Klaver wrote:
> > But then you fortunately cannot drop all databases, because you cannot
> > drop the database you are connected to.
> >
> > Still, a cluster that is missing "postgres" will give beginners trouble
>
> Right. Given shared "cluster-wide" objects like roles, databases, etc...
> I'm always found it weird that one must know "a priori" the name of one
> database to connect to, to do anything with PostgreSQL.

It is documented, and it is the default database if you are connecting
with the default database user "postgres", so it is not that bad.

Also, tools like "createdb" connect to that database by default.

> Not being able to drop the DB one's connected to is also a pita.
> If one have the right to do it, then it should just be done, and the
> connection closed.

No, it is a life saver, at least in my opinion.

> Authentication is cluster-wide, not DB specific, so I'd welcome a way to connect
> to the cluster, not a specific DB, and introspect shared-objects,
> including databases
> I'm allowed to connect to, which could be an empty list.

It is deep in the DNA of PostgreSQL that you always have to connect to
a database, unless you establish a replication connection.
I am surprised that you perceive that as a problem or limitation.

> FWIW. And a little OT. And implicit cluster-level mini-DB given access
> just to a subset of catalogs, or at least some limited queries like
> my databases and my roles, nothing else, would be very welcome IMHO. --DD

Well, that's the "postgres" database.

Yours,
Laurenz Albe

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ron Johnson 2025-04-16 12:36:06 Re: Best Tool for PostgreSQL Auditing and Storing Audit Logs Separately
Previous Message Anton Shepelev 2025-04-16 09:27:49 Cannot turn track_counts on