Skip site navigation (1) Skip section navigation (2)

Re: IDENTITY/GENERATED v36 Re: Final version of IDENTITY/GENERATED patch

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Zoltan Boszormenyi <zb(at)cybertec(dot)at>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, pgsql-patches(at)postgresql(dot)org
Subject: Re: IDENTITY/GENERATED v36 Re: Final version of IDENTITY/GENERATED patch
Date: 2007-04-04 16:12:02
Message-ID: 22514.1175703122@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-patches
I wrote:
> I see another problem with this patch: the code added to
> ATExecDropColumn is a crude hack.  It doesn't work anyway since this is
> not the only possible way for columns to be dropped (another one that
> comes to mind immediately is DROP TYPE ... CASCADE).  The only correct
> way to handle things is to let the dependency mechanism do it.

Actually, the whole question of dependencies for generated columns
probably needs some thought.  What should happen if a function or
operator used in a GENERATED expression gets dropped?  The result
for a normal column's default expression is that the default expression
goes away, but the column is still there.  I suspect we don't want
that for a GENERATED column --- it would then be effectively a plain
column.

Along the same lines, is ALTER COLUMN DROP DEFAULT a legal operation
on a generated column?  What about just replacing the expression with
ALTER COLUMN SET DEFAULT?

Before you get too excited about making generated columns disappear
automatically in all these cases, consider that dropping a column
is not something to be done lightly --- it might contain irreplaceable
data.

On second thought maybe the right approach is just to allow the default
expression to be dropped the same as it would be for an ordinary column,
and to make sure that if a GENERATED column doesn't (currently) have a
default, it is treated the same as an ordinary column.

This leads to the further thought that maybe GENERATED is not a property
of a column at all, but of its default (ie, it should be stored in
pg_attrdef not pg_attribute, which would certainly make the patch less
messy).  AFAICS plain GENERATED merely indicates that the default
expression can depend on other columns, which is certainly a property
of the default --- you could imagine ALTER COLUMN SET DEFAULT GENERATED
AS ... to make a formerly plain column into a GENERATED one.  I'm not
entirely sure about ALWAYS though.

			regards, tom lane

In response to

Responses

pgsql-hackers by date

Next:From: Markus SchiltknechtDate: 2007-04-04 16:33:05
Subject: Re: Auto Partitioning
Previous:From: Peter EisentrautDate: 2007-04-04 15:57:57
Subject: Re: Bug in UTF8-Validation Code?

pgsql-patches by date

Next:From: Markus SchiltknechtDate: 2007-04-04 16:33:05
Subject: Re: Auto Partitioning
Previous:From: Tom LaneDate: 2007-04-04 15:39:56
Subject: Re: IDENTITY/GENERATED v36 Re: Final version of IDENTITY/GENERATED patch

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group