Re: [HACKERS] Re: [HACKERS] generated columns

Поиск
Список
Период
Сортировка
От Peter Eisentraut
Тема Re: [HACKERS] Re: [HACKERS] generated columns
Дата
Msg-id b5c27634-1d44-feba-7494-ce5a31f914ca@2ndquadrant.com
обсуждение исходный текст
Ответ на Re: [HACKERS] Re: [HACKERS] generated columns  (Joe Conway <mail@joeconway.com>)
Ответы Re: [HACKERS] Re: [HACKERS] generated columns  (Joe Conway <mail@joeconway.com>)
Список 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


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Ivan Kartyshov
Дата:
Сообщение: [Patch] Checksums for SLRU files
Следующее
От: Tom Lane
Дата:
Сообщение: Re: What does Time.MAX_VALUE actually represent?