Oliver Jowett <oliver(at)opencloud(dot)com> writes:
> (later) A bit of experimentation yields this (I'm sure there's a better
> way):
> select transaction from pg_locks where pid = pg_backend_pid();
You'd need to qualify that more, since as-is it will also show rows for
other locks the transaction holds. Possibly "where transaction is not
null" will be sufficient.
regards, tom lane