Re: Generated column is not updated (Postgres 13)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Vitaly Ustinov <vitaly(at)ustinov(dot)ca>
Cc: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, pgsql-bugs(at)lists(dot)postgresql(dot)org, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Subject: Re: Generated column is not updated (Postgres 13)
Date: 2021-05-20 15:53:12
Message-ID: 3689916.1621525992@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

After looking at this further, I see that there already is a check
for system columns in GENERATED expressions; it's just in the
parser (scanNSItemForColumn), not where I was looking for it.
And it explicitly exempts tableoid. I continue to think that
that's a bad idea and we're gonna regret it, but at least the
issue in ATRewriteTable turns out to be trivial to fix.
So I did that and upgraded the test scenario to be a bit
more realistic, in 0001 below. 0002 then just disallows
whole-row variables. (I added an errdetail trying to
explain that restriction, too.)

It's worth pointing out here that what seems to me to be a
"more realistic" test scenario involves a regclass constant
for the table's own OID. If that doesn't scare you, it should,
because it implies all kinds of constraints on the order in which
these expressions are processed during CREATE or ALTER TABLE.
The test passes check-world, which includes dump/reload, but I am
sorely afraid that there are ways in which this sort of thing
would fail. Do we *really* want to buy into supporting it?

regards, tom lane

Attachment Content-Type Size
0001-fix-tableoid-in-ATRewriteTable.patch text/x-diff 3.6 KB
0002-forbid-whole-row-in-generated.patch text/x-diff 3.4 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message 'Bruce Momjian' 2021-05-20 18:29:50 Re: BUG #17020: meta command psql \reset does not clear the query buffer
Previous Message Vitaly Ustinov 2021-05-20 13:51:22 Re: Generated column is not updated (Postgres 13)