Litao Wu <litaowu@yahoo.com> writes:
> How about:
> select c.relname, l.pid, l.mode, l.granted,
> a.current_query
> from pg_locks l, pg_class c, pg_stat_activity a
> where
>   l.relation = c.oid
>   AND l.pid =  a.procpid
> order by l.granted, l.pid;
You can't join to pg_class without eliminating the transaction lock rows
(because they have NULLs in the relation field).
            regards, tom lane