BUG #19069: pg_advisory_xact_lock() in a WITH query doesn't work

Поиск
Список
Период
Сортировка
От PG Bug reporting form
Тема BUG #19069: pg_advisory_xact_lock() in a WITH query doesn't work
Дата
Msg-id 19069-f5c72e4e4f921a7c@postgresql.org
обсуждение исходный текст
Ответы Re: BUG #19069: pg_advisory_xact_lock() in a WITH query doesn't work
Список pgsql-bugs
The following bug has been logged on the website:

Bug reference:      19069
Logged by:          Maciej Walczak
Email address:      m.walczak@megavision.pl
PostgreSQL version: 18.0
Operating system:   Windows 11 Pro 24H2
Description:

This doesn't actually do any locking:

BEGIN;
WITH my_lock AS (
        SELECT pg_advisory_xact_lock(1)
)
INSERT INTO my_table (...) VALUES (...);
COMMIT;

To reproduce just run this code in two sessions in parallel without
commiting.
Both inserts will immediately complete without blocking.

I'm not sure if this is a bug. If it's not, perhaps the documentation should
be clarified.
Side-effects of WITH queries are mentioned here, so I would expect my code
to work:
https://www.postgresql.org/docs/16/queries-with.html#QUERIES-WITH-CTE-MATERIALIZATION

Tested on Postgres 18.0 and 16.10.


В списке pgsql-bugs по дате отправления: