IDENTITY/GENERATED columns

From: Zoltan Boszormenyi <zboszor(at)dunaweb(dot)hu>
To: pgsql-patches(at)postgresql(dot)org
Subject: IDENTITY/GENERATED columns
Date: 2006-08-07 17:57:35
Message-ID: 44D77F0F.3070505@dunaweb.hu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Hi,

my last patch didn't make it to the -hackers list,
here's a newer one. Let me list what this patch does now:

- CREATE TABLE/ALTER TABLE ADD syntax support for
GENERATED { ALWAYS | BY DEFAULT } AS
{ ( expr ) | IDENTITY ( seq_opts ) }
- catalog indicators of the above properties
- INSERT|COPY syntax support for OVERRIDING { SYSTEM | USER } VALUE
- INSERT|COPY fails for non-owner when using OVERRIDING SYSTEM VALUE
on tables with GENERATED ALWAYS columns
- UPDATE fails when using other than DEFAULT literal for
GENERATED ALWAYS columns
- GRANT {INSERT|UPDATE|ALL} ON table automatically
gives UPDATE permission for the supporting sequence
(missing: ALTER TABLE ADD should give permission
for the new sequence)
- ALTER TABLE tab ALTER col { SET seq_opts | RESTART [WITH] N }
syntax support to alter the supporting sequence
- ALTER TABLE tab RENAME also renames the supporting sequence
on both table and column renaming
- ALTER TABLE SET/DROP default is disallowed
- pg_dump support for exporting the above properties including
sequence parameters. Data dump uses OVERRIDING SYSTEM VALUE
when the table has GENERATED ALWAYS columns
- test cases for some operations
- documented

With this version, I mostly covered these TODO entries:

* Add support for SQL-standard GENERATED/IDENTITY columns (almost
done :-) )
* %Disallow changing DEFAULT expression of a SERIAL column? (done)
* %Disallow ALTER SEQUENCE changes for SERIAL sequences because
pg_dump does not dump the changes
(pg_dump dumps the sequence options)
* Add DEFAULT .. AS OWNER so permission checks are done as the table
owner
This would be useful for SERIAL nextval() calls and CHECK
constraints.
(GRANT TABLE grants UPDATE on the supporting sequence,
ALTER TABLE ADD COLUMN will be implemented)
* %Have ALTER TABLE RENAME rename SERIAL sequence names (done)
* Allow SERIAL sequences to inherit permissions from the base table?
(not needed because INSERT is a fastpath, permissions added
with GRANT TABLE, and [will be] extended on ALTER TABLE ADD COLUMN)

I am considering using ALTER TABLE tab ALTER col TYPE
to add (and drop) GENERATED ALWAYS and GENERATED AS IDENTITY
properties to existing columns. As it stands now, ALTER TYPE
doesn't change these column attributes.

Please, review.

Best regards,
Zoltán Böszörményi

Attachment Content-Type Size
psql-serial-21.diff.gz application/x-tar 25.1 KB

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Alvaro Herrera 2006-08-07 18:52:43 Re: CSStorm occurred again by postgreSQL8.2
Previous Message Tom Lane 2006-08-07 17:05:38 Re: [HACKERS] Restartable Recovery