Re: [HACKERS] generated columns

Поиск
Список
Период
Сортировка
От Daniel Gustafsson
Тема Re: [HACKERS] generated columns
Дата
Msg-id FF486006-CA9E-47BA-BD0D-49FEC8EC1D69@yesql.se
обсуждение исходный текст
Ответ на Re: [HACKERS] generated columns  (Jaime Casanova <jaime.casanova@2ndquadrant.com>)
Список pgsql-hackers
> On 12 Sep 2017, at 21:35, Jaime Casanova <jaime.casanova@2ndquadrant.com> wrote:
>
> On 10 September 2017 at 00:08, Jaime Casanova
> <jaime.casanova@2ndquadrant.com> wrote:
>>
>> During my own tests, though, i found some problems:
>
> a few more tests:
>
> create table t1 (
> id serial,
> height_cm int,
> height_in int generated always as (height_cm * 10)
> ) ;
>
>
> """
> postgres=# alter table t1 alter height_cm type numeric;
> ERROR:  unexpected object depending on column: table t1 column height_in
> """
> should i drop the column and recreate it after the fact? this seems
> more annoying than the same problem with views (drop view & recreate),
> specially after you implement STORED
>
>
> """
> postgres=# alter table t1 alter height_in type numeric;
> ERROR:  found unexpected dependency type 'a'
> """
> uh!?
>
>
> also is interesting that in triggers, both before and after, the
> column has a null. that seems reasonable in a before trigger but not
> in an after trigger
> """
> create function f_trg1() returns trigger as $$
>  begin
>     raise notice '%', new.height_in;
>     return new;
>  end
> $$ language plpgsql;
>
> create trigger trg1 before insert on t1
> for each row execute procedure f_trg1();
>
> postgres=# insert into t1 values(default, 100);
> NOTICE:  <NULL>
> INSERT 0 1
>
> create trigger trg2 after insert on t1
> for each row execute procedure f_trg1();
>
> postgres=# insert into t1 values(default, 100);
> NOTICE:  <NULL>
> NOTICE:  <NULL>
> INSERT 0 1
> """
>
> the default value shouldn't be dropped.
> """
> postgres=# alter table t1 alter height_in drop default;
> ALTER TABLE
> postgres=# \d t1
>                              Table "public.t1"
>  Column   |  Type   | Collation | Nullable |            Default
> ----------------+---------+-----------+----------+--------------------------------
> id             | integer |           | not null |
> nextval('t1_id_seq'::regclass)
> height_cm | integer |           |          |
> height_in   | integer |           |          | generated always as ()
> “""

Based on this review, and the errors noted in upthread in the previous review,
I’m marking this Returned with feedback.  When an updated version of the patch
is ready, please re-submit it to an upcoming commitfest.

cheers ./daniel

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

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

Предыдущее
От: Daniel Gustafsson
Дата:
Сообщение: Re: [HACKERS] Support to COMMENT ON DATABASE CURRENT_DATABASE
Следующее
От: Robert Haas
Дата:
Сообщение: Re: [HACKERS] path toward faster partition pruning