From: | PG Bug reporting form <noreply(at)postgresql(dot)org> |
---|---|
To: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
Cc: | m(dot)walczak(at)megavision(dot)pl |
Subject: | BUG #19069: pg_advisory_xact_lock() in a WITH query doesn't work |
Date: | 2025-10-02 13:11:37 |
Message-ID: | 19069-f5c72e4e4f921a7c@postgresql.org |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
The following bug has been logged on the website:
Bug reference: 19069
Logged by: Maciej Walczak
Email address: m(dot)walczak(at)megavision(dot)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.
From | Date | Subject | |
---|---|---|---|
Next Message | PG Bug reporting form | 2025-10-02 16:25:58 | BUG #19070: issue with DETACH PARTITION CONCURRENTLY on a hash partition table |
Previous Message | PG Bug reporting form | 2025-10-02 11:08:10 | BUG #19068: postgresql-server-dev-17 from apt.postgresql.org installs libpq-int.h for 18 version |