Re: pg_locks relation cant be found in pg_class

From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: Mariel Cherkassky <mariel(dot)cherkassky(at)gmail(dot)com>, pgsql-admin(at)lists(dot)postgresql(dot)org
Subject: Re: pg_locks relation cant be found in pg_class
Date: 2019-07-24 13:35:04
Message-ID: 8f74acca-9f9d-19b1-0aef-8b700291e409@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On 2019-07-24 11:15, Mariel Cherkassky wrote:
> However, I'm getting only relations of system catalogs and not other
> relations.. pg_locks contains rows for many relations, for example : 
> postgres=# select relation,count(*) from pg_locks where
> locktype='relation' group by relation order by count desc;
>  relation | count
> ----------+-------
>     16531 |     4
>    320587 |     3
>     16535 |     3
>    320585 |     3
>
> but in the result of my first query I dont get the relation name. For
> example : 
> postgres=# select count(*) from pg_class where oid in (16531,320587,16535);
>  count
> -------
>      0
>

"pg_locks provides a global view of all locks in the database cluster,
not only those relevant to the current database. Although its relation
column can be joined against pg_class.oid to identify locked relations,
this will only work correctly for relations in the current database
(those for which the database column is either the current database's
OID or zero)." (from the documentation)

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Swanand Kshirsagar 2019-07-24 16:47:08 Re: Restrict permissions on schema to hide pl/pgsql code
Previous Message David G. Johnston 2019-07-24 13:28:05 Re: Restrict permissions on schema to hide pl/pgsql code