From: | Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com> |
---|---|
To: | Joe Conway <mail(at)joeconway(dot)com>, Jaime Casanova <jaime(dot)casanova(at)2ndquadrant(dot)com> |
Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: [HACKERS] Re: [HACKERS] generated columns |
Date: | 2017-12-31 17:38:15 |
Message-ID: | b5c27634-1d44-feba-7494-ce5a31f914ca@2ndquadrant.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 12/30/17 16:04, Joe Conway wrote:
> +<para>
> + The generation expression can refer to other columns in the table, but
> + not other generated columns. Any functions and operators used must be
> + immutable. References to other tables are not allowed.
> +</para>
>
> Question -- when the "stored" kind of generated column is implemented,
> will the immutable restriction be relaxed? I would like, for example, be
> able to have a stored generated column that executes now() whenever the
> row is written/rewritten.
That restriction is from the SQL standard, and I think it will stay.
The virtual vs. stored choice is an optimization, but not meant to
affect semantics. For example, you might want to automatically
substitute a precomputed generated column into an expression, but that
will become complicated and confusing if the expression is not
deterministic.
Another problem with your example is that a stored generated column
would only be updated if a column it depends on is updated. So a column
whose generation expression is just now() would never get updated.
Maybe some of this could be relaxed at some point, but we would have to
think it through carefully. For now, a trigger would still be the best
implementation for your use case, I think.
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2017-12-31 17:50:32 | Re: What does Time.MAX_VALUE actually represent? |
Previous Message | Ivan Kartyshov | 2017-12-31 17:30:25 | [Patch] Checksums for SLRU files |