Re: Virtual generated columns
От | Peter Eisentraut |
---|---|
Тема | Re: Virtual generated columns |
Дата | |
Msg-id | 73368b20-52c5-4171-aa08-77748ab6be1d@eisentraut.org обсуждение исходный текст |
Ответ на | Re: Virtual generated columns (jian he <jian.universality@gmail.com>) |
Список | pgsql-hackers |
On 13.11.24 04:30, jian he wrote: > in > transformColumnDefinition > we can add parser_errposition for the error report. > if (column->is_not_null && column->generated == > ATTRIBUTE_GENERATED_VIRTUAL) > ereport(ERROR, > (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), > errmsg("not-null constraints are not supported on > virtual generated columns"), > parser_errposition(cxt->pstate, > constraint->location))); > sometimes, it points to the word "generated", sometimes "not". I guess > this should be fine. > example: > create table t13 (a int, b bool generated always as ((true )) VIRTUAL not null); > create table t13 (a int, b bool not null generated always as ((true )) VIRTUAL); Ok, done in v10. > These 3 functions will call StoreRelNotNull to store the not-null constraint. > StoreConstraints > AddRelationNotNullConstraints > AddRelationNewConstraints > related tests: > create table t12(b int, a int generated always as (11) virtual, > constraint nn not null a); > create table t12(b int, constraint nn not null a, a int generated > always as (11) virtual); > > drop table if exists t14; > create table t14(b int, a int generated always as (11) virtual); > alter table t14 add constraint nn not null a; > alter table t14 add constraint nn not null a no inherit; Ok, I have added the missing checks and added these test cases to v10. I didn't put the checks in StoreRelNotNull(), I think that is too late in the process. (It's already trying to store it. The checking should come earlier.) I put the checks into AddRelationNewConstraints() and AddRelationNotNullConstraints(), which already have similar checks.
В списке pgsql-hackers по дате отправления: