Re: [HACKERS] generated columns - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: [HACKERS] generated columns
Date
Msg-id 20190320025103.GG3488@paquier.xyz
Whole thread Raw
In response to Re: [HACKERS] generated columns  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: [HACKERS] generated columns
List pgsql-hackers
On Mon, Mar 18, 2019 at 03:14:09PM +0100, Pavel Stehule wrote:
> postgres=# update foo set name = 'bbbxx' where id = 1; -- error
> ERROR:  no generation expression found for column number 3 of table
> "foo"

Yes I can see the problem after adding a generated column and dropping
it on an INSERT query.

I have read through the code once.

+       if (relid && attnum && get_attgenerated(relid, attnum))
Better to use OidIsValid here?

+       (walrcv_server_version(wrconn) >= 120000 ? "AND a.attgenerated = ''" : ""),
I think that it is better to always have version-related references
stored as defines.

+CREATE TABLE gtest22a (a int PRIMARY KEY, b int GENERATED ALWAYS AS (a * 2) STORED UNIQUE);
+CREATE TABLE gtest22b (a int, b int GENERATED ALWAYS AS (a * 2) STORED, PRIMARY KEY (a, b));
Some tests for unique constraints with a generated column should be in
place?

It would be nice to have extra tests for forbidden expression types
on generated columns especially SRF, subquery and aggregates/window
functions.
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Andrey Borodin
Date:
Subject: Re: Sparse bit set data structure
Next
From: "Imai, Yoshikazu"
Date:
Subject: RE: speeding up planning with partitions