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

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

From: Zoltan Boszormenyi <zb(at)cybertec(dot)at>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
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-14 22:44:22
Message-ID: 46215946.1030207@cybertec.at (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-patches
Tom Lane írta:
> Zoltan Boszormenyi <zb(at)cybertec(dot)at> writes:
>   
>> So, I should allow DROP DEFAULT, implement
>> SET DEFAULT GENERATED ALWAYS AS
>> and modify the catalog so the GENERATED property
>> is part of pg_attrdef.
>>     
>
> Sounds good.
>   

Finally here it is.

>> What about IDENTITY?
>> Should it also be part of pg_attrdef? There are two ways
>> to implement it: have or don't have a notion of it.
>> The latter would treat GENERATED BY DEFAULT AS IDENTITY
>> the same as SERIAL.
>>     
>
> Is there any good reason to distinguish the two?
>   

Actually, I needed to have a flag for IDENTITY
but not for the reason above. I need it to distinguish
between GENERATED ALWAYS AS IDENTITY
and GENERATED ALWAYS AS ( expr ).

Changes:
- Rewritten the GENERATED/IDENTITY flags to be part of the default 
pg_attrdef
   This made the patch MUCH smaller.
- SERIALs are now the same as INTEGER GENERATED BY DEFAULT AS IDENTITY
- Allow DROP DEFAULT on GENERATED/IDENTITY columns
- Implemented SET GENERATED ALWAYS AS
- Modified syntax of SET GENERATED {ALWAYS | BY DEFAULT} AS IDENTITY
    so it reads as SET IDENTITY GENERATED {ALWAYS | BY DEFAULT}
    so compiling gram.y/gram.c doesn't give me errors.
    This DDL statement isn't part of SQL:2003 so it might be accepted
    as a PostgreSQL extension.
- Modified behaviour of SET IDENTITY to also restore the DEFAULT
    expression. Someone might have done did a DROP DEFAULT before
    but kept the OWNED sequence.
- Fixed behaviour of GENERATED columns regarding
    INSERT ... OVERRIDING SYSTEM VALUE and
    only those GENERATED columns get UPDATEd that
    are either explicitly modified with SET column = DEFAULT
    or one of their referenced columns are modified.
- Testcase and documentation is modified to reflect the above.

Please, review.

-- 
----------------------------------
Zoltán Böszörményi
Cybertec Geschwinde & Schönig GmbH
http://www.postgresql.at/


Attachment: psql-serial-39.diff.gz
Description: application/x-tar (29.6 KB)

In response to

Responses

pgsql-hackers by date

Next:From: Zoltan BoszormenyiDate: 2007-04-14 22:49:02
Subject: Re: IDENTITY/GENERATED v36 Re: Final version of IDENTITY/GENERATED patch
Previous:From: Tom LaneDate: 2007-04-14 22:02:53
Subject: Re: [HACKERS] choose_bitmap_and again (was Re: [PERFORM] Strangely Variable Query Performance)

pgsql-patches by date

Next:From: Zoltan BoszormenyiDate: 2007-04-14 22:49:02
Subject: Re: IDENTITY/GENERATED v36 Re: Final version of IDENTITY/GENERATED patch
Previous:From: Tom LaneDate: 2007-04-14 22:02:53
Subject: Re: [HACKERS] choose_bitmap_and again (was Re: [PERFORM] Strangely Variable Query Performance)

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