pg_prepared_xacts returns transactions that are foreign to the caller

Started by Vladimir Sitnikovabout 1 year ago2 messages
#1Vladimir Sitnikov
sitnikov.vladimir@gmail.com

Hi,

"select * from pg_prepared_xacts" might produce transactions created by a
different user, so the caller won't be able to issue "commit prepared".

I think there should be a view that returns only the transactions that the
caller can commit or rollback.
Is it something that can be implemented at the backend?

Currently, the backend checks owner and database when user calls "commit
prepared", so I believe the similar filter should be implemented in
pg_prepared_xacts view:
https://github.com/postgres/postgres/blob/15afb7d61c142a9254a6612c6774aff4f358fb69/src/backend/access/transam/twophase.c#L583C32-L599

Vladimir

#2Andrey M. Borodin
x4mmm@yandex-team.ru
In reply to: Vladimir Sitnikov (#1)
Re: pg_prepared_xacts returns transactions that are foreign to the caller

On 20 Nov 2024, at 12:48, Vladimir Sitnikov <sitnikov.vladimir@gmail.com> wrote:

"select * from pg_prepared_xacts" might produce transactions created by a different user, so the caller won't be able to issue "commit prepared".

I think there should be a view that returns only the transactions that the caller can commit or rollback.
Is it something that can be implemented at the backend?

Like "select * from pg_prepared_xacts where pg_has_role(current_user, owner, 'member');"?

Best regards, Andrey Borodin.