Re: bug in stored generated column over domain with constraints.
От | jian he |
---|---|
Тема | Re: bug in stored generated column over domain with constraints. |
Дата | |
Msg-id | CACJufxF0xJ1D6ZBvqopMA=vKRKbFrtUbaMJ8bm0b8d9KLDC4Ag@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: bug in stored generated column over domain with constraints. (jian he <jian.universality@gmail.com>) |
Ответы |
Re: bug in stored generated column over domain with constraints.
|
Список | pgsql-hackers |
hi. new patch attached. rewriteTargetListIU, expand_insert_targetlist these two places can make a null Const TargetEntry for the generated column in an INSERT operation. but since this problem only occurs in INSERT, so i placed the logic within expand_insert_targetlist would be appropriate? The following are excerpts of the commit message. -------------------------------- create domain d3 as int check (value is not null); create table t0(b int, a d3 GENERATED ALWAYS as (b + 11) stored); insert into t0 values (1, default); ERROR: value for domain d3 violates check constraint "d3_check" explain(costs off, verbose) insert into t0 values (1, default); QUERY PLAN --------------------------------------- Insert on public.t0 -> Result Output: 1, NULL::integer For INSERT operation, for Query->targetList, we should not make a generated column over domain with constraint to a CoerceToDomain node, instead, we make it as a simple null Const over domain's base type. When a column is a generated column in an INSERT, expand_insert_targetlist should unconditionally generate a null Const to be inserted. If we are not doing this way, we might end up wrapping the null Const in a CoerceToDomain node, which may trigger runtime error earlier if the domain has a NOT NULL constraint. That's not fine, as generated columns are already handled in ExecComputeStoredGenerated. --------------------------------
Вложения
В списке pgsql-hackers по дате отправления: