Re: [HACKERS] generated columns

From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Sergei Kornilov <sk(at)zsrv(dot)org>, Jaime Casanova <jaime(dot)casanova(at)2ndquadrant(dot)com>
Subject: Re: [HACKERS] generated columns
Date: 2019-02-27 07:05:02
Message-ID: a9dcee31-6ae9-f581-f362-a27774cbe156@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2019-02-26 06:30, Michael Paquier wrote:
> + if (attgenerated)
> + {
> + /*
> + * Generated column: Dropping anything that the generation expression
> + * refers to automatically drops the generated column.
> + */
> + recordDependencyOnSingleRelExpr(&colobject, expr, RelationGetRelid(rel),
> + DEPENDENCY_AUTO,
> + DEPENDENCY_AUTO, false);
> + }
> A CCI is not necessary I think here, still the recent thread about
> automatic dependencies with identity columns had a much similar
> pattern...

Yeah, worth taking another look.

>
> + else if (generated[0] == ATTRIBUTE_GENERATED_VIRTUAL)
> + default_str = psprintf("generated always as (%s)", PQgetvalue(res, i, attrdef_col));
> Nit: I would add VIRTUAL instead of relying on the default option.

I suppose we'll decide that when the virtual columns are actually added.
I see your point.

> Another thing I was thinking about: could it be possible to add a
> sanity check in sanity_check.sql so as a column more that one
> field in attidentity, attgenerated and atthasdef set at the same time?

There is something like that at the top of
src/test/regress/sql/generated.sql. I can expand that. But it only
covers the tests. For run time checks, you'd want something like
pg_catcheck.

--
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 Peter Eisentraut 2019-02-27 07:08:04 Re: [HACKERS] generated columns
Previous Message Fabien COELHO 2019-02-27 06:59:31 Re: Offline enabling/disabling of data checksums