Re: Virtual generated columns

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-28 09:35:51
Message-ID: c44f28a7-542c-4044-b8b2-d578bd4e9926@eisentraut.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 12.11.24 17:08, Peter Eisentraut wrote:
> On 11.11.24 12:37, jian he wrote:
>> On Wed, Nov 6, 2024 at 12:17 AM Peter Eisentraut
>> <peter(at)eisentraut(dot)org> wrote:
>>>
>>> New patch version.  I've gone through the whole thread again and looked
>>> at all the feedback and various bug reports and test cases and made sure
>>> they are all addressed in the latest patch version.  (I'll send some
>>> separate messages to respond to some individual messages, but I'm
>>> keeping the latest patch here.)
>>
>> just quickly note the not good error message before you rebase.
>>
>> src7=# create domain d_fail as int4 constraint cc GENERATED ALWAYS AS
>> (2) ;
>> ERROR:  unrecognized constraint subtype: 4
>> src7=# create domain d_fail as int4 constraint cc GENERATED ALWAYS AS
>> (2) stored;
>> ERROR:  unrecognized constraint subtype: 4
>> src7=# create domain d_fail as int4 constraint cc GENERATED ALWAYS AS
>> (2) virtual;
>> ERROR:  unrecognized constraint subtype: 4
>>
>> reading gram.y, typedef struct Constraint seems cannot distinguish, we
>> are creating a domain or create table.
>> I cannot found a way to error out in gram.y.
>>
>> so we have to error out at DefineDomain.
>
> This appears to be a very old problem independent of this patch.  I'll
> take a look at fixing it.

Here is a patch.

I'm on the fence about taking out the default case. It does catch the
missing enum values, and I suppose if the struct arrives in
DefineDomain() with a corrupted contype value that is none of the enum
values, then we'd just do nothing with it. Maybe go ahead with this,
but for backpatching leave the default case in place?

Attachment Content-Type Size
0001-Fix-handling-of-CREATE-DOMAIN-with-GENERATED-constra.patch text/plain 1.7 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Gustafsson 2024-11-28 09:40:35 Re: More CppAsString2() in psql's describe.c
Previous Message Kirill Reshke 2024-11-28 09:31:27 Pass ParseState as down to utility functions.