From: | Peter Eisentraut <peter(at)eisentraut(dot)org> |
---|---|
To: | jian he <jian(dot)universality(at)gmail(dot)com> |
Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> |
Subject: | Re: Virtual generated columns |
Date: | 2024-11-29 09:50:19 |
Message-ID: | 73368b20-52c5-4171-aa08-77748ab6be1d@eisentraut.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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.
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Eisentraut | 2024-11-29 10:01:29 | Re: Virtual generated columns |
Previous Message | Peter Eisentraut | 2024-11-29 09:47:46 | Re: Virtual generated columns |