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

2011-12-05 Thread Robert Haas
On Sun, Dec 4, 2011 at 4:26 PM, Tom Lane t...@sss.pgh.pa.us wrote: Tomas Vondra t...@fuzzy.cz writes: What about the pg_stat_activity - is it safe to access that from auth hook or is that just a coincidence that it works (and might stop working in the future)? It doesn't seem like a good

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

2011-12-05 Thread Tom Lane
Robert Haas robertmh...@gmail.com writes: I'm still puzzled that Tomas got it working at all. If MyDatabaseId hasn't been set yet, the how did we manage to build a relcache entry for anything - let alone an unshared catalog? Well, he wasn't actually issuing a SQL query, just calling some of

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

2011-12-05 Thread Robert Haas
On Mon, Dec 5, 2011 at 10:46 AM, Tom Lane t...@sss.pgh.pa.us wrote: Robert Haas robertmh...@gmail.com writes: I'm still puzzled that Tomas got it working at all.  If MyDatabaseId hasn't been set yet, the how did we manage to build a relcache entry for anything - let alone an unshared catalog?

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

2011-12-04 Thread Tomas Vondra
On 4.12.2011 05:19, Tom Lane wrote: Tomas Vondra t...@fuzzy.cz writes: That might explain why it fails at first and then works just fine, although it's a bit strange. Wouldn't that mean you can't access any catalogs from the auth hook? It should be possible to access shared catalogs from an

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

2011-12-04 Thread Tom Lane
Tomas Vondra t...@fuzzy.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

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

2011-12-04 Thread Tomas Vondra
On 4.12.2011 17:10, Tom Lane wrote: Tomas Vondra t...@fuzzy.cz writes: 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

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

2011-12-04 Thread Tom Lane
Tomas Vondra t...@fuzzy.cz writes: What about the pg_stat_activity - is it safe to access that from auth hook or is that just a coincidence that it works (and might stop working in the future)? It doesn't seem like a good thing to rely on. There's certainly no testing being done that would

[HACKERS] cannot read pg_class without having selected a database / is this a bug?

2011-12-03 Thread Tomas Vondra
Hi, I've written a simple extension that limits number of connection by IP/db/user, and I do receive this exception: psql: FATAL: cannot read pg_class without having selected a database I've found this happens because the extension defines a client auth hook that reads pg_stat_activity. The

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

2011-12-03 Thread Robert Haas
2011/12/3 Tomas Vondra t...@fuzzy.cz: psql: FATAL:  cannot read pg_class without having selected a database I've found this happens because the extension defines a client auth hook that reads pg_stat_activity. The really interesting thing is that this happens only when I start several

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

2011-12-03 Thread Tomas Vondra
On 3.12.2011 23:37, Robert Haas wrote: 2011/12/3 Tomas Vondra t...@fuzzy.cz: psql: FATAL: cannot read pg_class without having selected a database I've found this happens because the extension defines a client auth hook that reads pg_stat_activity. The really interesting thing is that this

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

2011-12-03 Thread Tom Lane
Tomas Vondra t...@fuzzy.cz writes: That might explain why it fails at first and then works just fine, although it's a bit strange. Wouldn't that mean you can't access any catalogs from the auth hook? It should be possible to access shared catalogs from an auth hook. pg_stat_activity is neither