Extended SERIAL parsing

From: Zoltan Boszormenyi <zboszor(at)dunaweb(dot)hu>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Extended SERIAL parsing
Date: 2006-06-11 22:38:50
Message-ID: 448C9B7A.6010000@dunaweb.hu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

after some experimentation, I came up with the attached patch,
which implements parsing the following SERIAL types:

SERIAL
SERIAL GENERATED { ALWAYS | BY DEFAULT }
SERIAL GENERATED [ ALWAYS | BY DEFAULT ] AS IDENTITY( sequence options )

The underlying type is still int4 or int8,
so the problems you discussed aren't solved.
But at least the current semantics is kept.

It passes all regression tests, and it works, too:

# create table proba (i serial generated as identity(minvalue 5 maxvalue
10) primary key, t text);
NOTICE: CREATE TABLE will create implicit sequence "proba_i_seq" for
serial column "proba.i"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"proba_pkey" for table "proba"
CREATE TABLE
# insert into proba (t) values ('a');
INSERT 0 1
# select * from proba;
i | t
---+---
5 | a
(1 row)

For now, GENERATED { ALWAYS | BY DEFAULT }
are just fillings.

The condition (column->is_serial && column->force_default)
can help enforcing GENERATED ALWAYS at INSERT time
and can also help fixing the two TODO entries about SERIAL.

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

Attachment Content-Type Size
psql-serial.diff text/x-diff 9.6 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Rod Taylor 2006-06-11 22:54:09 Re: Extended SERIAL parsing
Previous Message Alvaro Herrera 2006-06-11 22:20:22 The corresponding relminxid patch; try 1