ALTER TABLE support for dropping generation expression

Lists: pgsql-hackers
From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: ALTER TABLE support for dropping generation expression
Date: 2019-12-09 07:53:54
Message-ID: 2f7f1d9c-946e-0453-d841-4f38eb9d69b6@2ndquadrant.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

A small add-on to the generated columns feature: Add an ALTER TABLE
subcommand for dropping the generated property from a column, per SQL
standard.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachment Content-Type Size
0001-ALTER-TABLE-.-ALTER-COLUMN-.-DROP-EXPRESSION.patch text/plain 16.3 KB

From: Sergei Kornilov <sk(at)zsrv(dot)org>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Cc: Peter Eisentraut <peter(at)eisentraut(dot)org>
Subject: Re: ALTER TABLE support for dropping generation expression
Date: 2019-12-25 11:01:34
Message-ID: 157727169476.1198.15296771283556567409.pgcf@coridan.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

The following review has been posted through the commitfest application:
make installcheck-world: not tested
Implements feature: tested, failed
Spec compliant: not tested
Documentation: tested, passed

Hello

Patch does not apply to master. Could you rebase?

Code looks good and very similar to "ALTER TABLE ... ALTER COLUMN ... DROP IDENTITY"

I noticed one bug:

create table testdrop (i int, b int, m int GENERATED ALWAYS AS ( i*2) stored);
insert into testdrop(i,b) values (3,4);
alter table testdrop alter COLUMN m drop expression ;
alter table testdrop drop column i;

Here is no "m" column anymore. Possible due some forgotten dependency?

regards, Sergei

The new status of this patch is: Waiting on Author


From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: Sergei Kornilov <sk(at)zsrv(dot)org>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: ALTER TABLE support for dropping generation expression
Date: 2019-12-28 17:05:28
Message-ID: 879ef3c3-3302-40b6-715a-b4cb32ba5660@2ndquadrant.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On 2019-12-25 12:01, Sergei Kornilov wrote:
> Patch does not apply to master. Could you rebase?

done

> I noticed one bug:
>
> create table testdrop (i int, b int, m int GENERATED ALWAYS AS ( i*2) stored);
> insert into testdrop(i,b) values (3,4);
> alter table testdrop alter COLUMN m drop expression ;
> alter table testdrop drop column i;
>
> Here is no "m" column anymore. Possible due some forgotten dependency?

fixed -- good catch

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachment Content-Type Size
v2-0001-ALTER-TABLE-.-ALTER-COLUMN-.-DROP-EXPRESSION.patch text/plain 18.4 KB

From: Sergei Kornilov <sk(at)zsrv(dot)org>
To: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: ALTER TABLE support for dropping generation expression
Date: 2020-01-10 12:20:38
Message-ID: 1058161578658838@vla4-87a00c2d2b1b.qloud-c.yandex.net
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

Hello

Thank you, but I am late: patch has another merge conflict.

Conflict seems trivial and patch looks fine for me.

regards, Sergei


From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: Sergei Kornilov <sk(at)zsrv(dot)org>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: ALTER TABLE support for dropping generation expression
Date: 2020-01-11 06:35:44
Message-ID: 131f19d2-9aaf-1e7a-c9a6-7fbe90b5e8ca@2ndquadrant.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On 2020-01-10 13:20, Sergei Kornilov wrote:
> Thank you, but I am late: patch has another merge conflict.
>
> Conflict seems trivial and patch looks fine for me.

Here is another patch version. I have resolved the conflict and also
added a check that you don't drop the generation expression from an
inherited column.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachment Content-Type Size
v3-0001-ALTER-TABLE-.-ALTER-COLUMN-.-DROP-EXPRESSION.patch text/plain 19.5 KB

From: Sergei Kornilov <sk(at)zsrv(dot)org>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Cc: Peter Eisentraut <peter(at)eisentraut(dot)org>
Subject: Re: ALTER TABLE support for dropping generation expression
Date: 2020-01-13 09:56:41
Message-ID: 157890940187.709.7669832463307505686.pgcf@coridan.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

The following review has been posted through the commitfest application:
make installcheck-world: tested, passed
Implements feature: tested, passed
Spec compliant: not tested
Documentation: tested, passed

Thank you!
Looks good to me. I have no further comments. I'll mark as ready for committer.

The new status of this patch is: Ready for Committer


From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: Sergei Kornilov <sk(at)zsrv(dot)org>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: ALTER TABLE support for dropping generation expression
Date: 2020-01-14 12:47:14
Message-ID: 7e2d1ca7-bc91-c26b-01e6-dfad4b462292@2ndquadrant.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On 2020-01-13 10:56, Sergei Kornilov wrote:
> The following review has been posted through the commitfest application:
> make installcheck-world: tested, passed
> Implements feature: tested, passed
> Spec compliant: not tested
> Documentation: tested, passed
>
> Thank you!
> Looks good to me. I have no further comments. I'll mark as ready for committer.
>
> The new status of this patch is: Ready for Committer

committed, thanks

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services