Re: [HACKERS] Serial Data Type

Поиск
Список
Период
Сортировка
От Thomas G. Lockhart
Тема Re: [HACKERS] Serial Data Type
Дата
Msg-id 35FA0D60.EE08294D@alumni.caltech.edu
обсуждение исходный текст
Ответ на Serial Data Type  (David Hartwig <daveh@insightdist.com>)
Список pgsql-hackers
> I have a couple minor issues  regarding the 6.4 implementation of the
> SERIAL data type.
> 1. Should the sequence created by the serial type declaration, be
> dropped as a result of dropping the parent table?

Yes. But it isn't. And I don't know how we would do that on short
notice. I implemented the serial type with ~20 minutes work using the
hooks I'd put in to implement primary keys, and of course Vadim's
sequence capability. The difference is that indices were already
automatically removed when tables are dropped, so I didn't have to deal
with it.

> 2.  Can a declared serial column be also a primary key? If so, what
> will be the side effected? Specifically, how will the unique index be
> named? The ODBC driver uses the {relname}_pkey to identify the primary
> key of a table.  The driver must be able to identify primary keys.

Hmm.

postgres=> create table xx (s serial primary key, i int4);
ERROR:  parser: parse error at or near "primary"
postgres=> create table xx (s int4 primary key, i int4);
NOTICE:  CREATE TABLE/PRIMARY KEY will create implicit index xx_pkey for
table xx
CREATE

So, at the moment the syntax doesn't allow anything in addition to the
serial type declaration. We should be able to fix that up and allow
both, but perhaps it should wait for Vadim's primary key/foreign key
features, which may be available for v6.4.

I'd expect to be able to get the name to line up with the "_pkey"
convention, though perhaps by then you will be able to look in a column
in a table for real primary/foreign key flags to do this.

                       - Tom

В списке pgsql-hackers по дате отправления:

Предыдущее
От: "Thomas G. Lockhart"
Дата:
Сообщение: Re: [HACKERS] pg_user problem
Следующее
От: "Thomas G. Lockhart"
Дата:
Сообщение: Re: [HACKERS] SERIAL data type