Re: [HACKERS] generated columns

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Sergei Kornilov <sk(at)zsrv(dot)org>, Jaime Casanova <jaime(dot)casanova(at)2ndquadrant(dot)com>
Subject: Re: [HACKERS] generated columns
Date: 2019-03-26 19:50:01
Message-ID: CAFj8pRD3L9pZqrh-2BuBaBHa2A-h3-xAoO0v2dujwaKtfeS1OQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi

út 26. 3. 2019 v 14:33 odesílatel Peter Eisentraut <
peter(dot)eisentraut(at)2ndquadrant(dot)com> napsal:

> On 2019-03-20 03:51, Michael Paquier wrote:
> > 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.
>
> fixed
>
> > + if (relid && attnum && get_attgenerated(relid, attnum))
> > Better to use OidIsValid here?
>
> fixed
>
> > + (walrcv_server_version(wrconn) >= 120000 ? "AND a.attgenerated =
> ''" : ""),
> > I think that it is better to always have version-related references
> > stored as defines.
>
> A valid idea, but I don't see it widely done (see psql, pg_dump).
>
> > +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?
>
> done
>
> > It would be nice to have extra tests for forbidden expression types
> > on generated columns especially SRF, subquery and aggregates/window
> > functions.
>
> done
>

I checked this functionality and it looks very well.

1. there are not any warning or any compilation issue.
2. all tests passed, check-world passed
3. documentation is checked
4. source code is readable, commented, and well formatted
5. regress tests are enough
6. I checked a functionality and did comparison with db that implements
this function already and there are not differences
7. I tested performance and I got significantly better times against
trigger based solution - up tu 2x

It is great feature and I'll mark this feature as ready for commit

Regards

Pavel

>
> --
> Peter Eisentraut http://www.2ndQuadrant.com/
> PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2019-03-26 20:04:53 Re: explain plans with information about (modified) gucs
Previous Message Pavel Stehule 2019-03-26 19:26:23 Re: [HACKERS] generated columns