From: | PG Bug reporting form <noreply(at)postgresql(dot)org> |
---|---|
To: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
Cc: | hisahiro(at)freemind(dot)co(dot)jp |
Subject: | BUG #17823: Generated columns not always updated correctly |
Date: | 2023-03-06 07:26:42 |
Message-ID: | 17823-b64909cf7d63de84@postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
The following bug has been logged on the website:
Bug reference: 17823
Logged by: Hisahiro Kauchi
Email address: hisahiro(at)freemind(dot)co(dot)jp
PostgreSQL version: 15.2
Operating system: CentOS 7
Description:
I found that the generated columns are sometimes not updated.
1. Create a table with a generated column, and insert a row:
test=# create table test(id serial primary key, a int, b int generated
always as (a + 1) stored);
CREATE TABLE
test=# insert into test(a) values (1);
INSERT 0 1
test=# select * from test;
id | a | b
----+---+---
1 | 1 | 2
(1 row)
2. Start Transaction A and update the row:
==== Transaction A ====
test=# begin;
BEGIN
test=*# update test set a=2 where id=1;
UPDATE 1
test=*# select * from test;
id | a | b
----+---+---
1 | 2 | 3
(1 row)
3. Before committing transaction A, start Transaction B to update the same
row:
==== Transaction B ====
test=# begin;
BEGIN
test=*# update test set a=3 where id=1;
(Waiting for Transaction A to commit)
4. Commit Transaction A:
==== Transaction A ====
test=*# end;
COMMIT
5. The UPDATE of Transaction B is executed:
==== Transaction B ====
UPDATE 1
test=*# end;
COMMIT
6. Check the result:
test=*# select * from test;
id | a | b
----+---+---
1 | 3 | 3
(1 row)
The generated column "b" should be updated correctly to reflect the new
value of "a" (i.e., b=4).
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2023-03-06 16:35:29 | Re: BUG #17823: Generated columns not always updated correctly |
Previous Message | Marco Boeringa | 2023-03-06 06:46:49 | Fwd: 'CLUSTER' in one database prevents running it in two others on the same database cluster (PG15.2) |