Skip site navigation (1) Skip section navigation (2)

Re: cannot read pg_class without having selected a database / is this a bug?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Tomas Vondra <tv(at)fuzzy(dot)cz>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: cannot read pg_class without having selected a database / is this a bug?
Date: 2011-12-04 16:10:17
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
Tomas Vondra <tv(at)fuzzy(dot)cz> writes:
> On 4.12.2011 05:19, Tom Lane wrote:
>> It should be possible to access shared catalogs from an auth hook.
>> pg_stat_activity is neither shared nor a catalog.  Like Robert,
>> I find it astonishing that this works ever, because the info needed
>> simply isn't available until you've connected to a particular database.
>> The fact that the view is actually defined the same in every database
>> doesn't enter into that ...

> Hmmm, I do admit this is the first time I play with these things
> (relcache, catalogs ...) so closely. so there are obviously things I'm
> not aware of. For example I'm a bit confused what is / is not a shared
> catalogue. Thanks in advance for your patience.

See pg_class.relisshared.

> Anyway, the code I posted does not fail because of pg_stat_activity, it
> fails because it attempts for find the dbname/username for the backends
> (read from pg_stat_activity).

Well, get_database_name tries to do a syscache lookup, and the syscache
infrastructure isn't working yet.  It is possible to read a shared
catalog at this stage, but you have to use lower-level access mechanisms
--- for an example with some comments, look at GetDatabaseTuple in

			regards, tom lane

In response to


pgsql-hackers by date

Next:From: Andrew DunstanDate: 2011-12-04 16:10:38
Subject: Re: [PATCH] PostgreSQL fails to build with 32bit MinGW-w64
Previous:From: Jaime CasanovaDate: 2011-12-04 14:27:06
Subject: Re: [PATCH] Caching for stable expressions with constant arguments v3

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group