Re: Making serial survive pg_dump

From: Joe Conway <mail(at)joeconway(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Rod Taylor <rbt(at)zort(dot)ca>, Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>, Hackers List <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Making serial survive pg_dump
Date: 2002-06-14 04:11:55
Message-ID: 3D096D0B.5030107@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:
> "Rod Taylor" <rbt(at)zort(dot)ca> writes:
>
>>>What happens is the sequence is shared between several tables (eg.
>>>invoice numbers or something)
>>
>
>>You cannot accomplish this situation by strictly using the SERIAL
>>type.
>
>
> But Chris is correct that there are borderline cases where we might
> do the wrong thing if we're not careful. The real question here,
> I suspect, is what rules pg_dump will use to decide that it ought
> to suppress a CREATE SEQUENCE command, DEFAULT clause, etc, in
> favor of emitting a SERIAL column datatype. In particular, ought it
> to depend on looking at the form of the name of the sequence?
> I can see arguments both ways on that...
>

I think that when SERIAL is used, the sequence should be tied
inextricably to the table which created it, and it should be hidden from
use for other purposes (perhaps similar to the way a toast table is). If
you *want* to use a sequence across several tables, then you don't use
SERIAL, you create a sequence.

Many people who come from an MS SQL Server background are used to an
IDENTITY column being tied transparently to the table in this fashion,
and they initially find sequences confusing. Conversely, people coming
from an Oracle background are quite comfortable with sequences, and
don't understand why it is necessary to have an IDENTITY type column at
all -- they seem too restrictive. We have people from both backgrounds
where I work, and both databases in use for various applications, and
this is at least what I have observed.

This is a chance for PostgreSQL to support people from both camps
equally well.

Anyway, just my 2c :-)

Joe

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2002-06-14 04:40:52 Re: [HACKERS] PATCH SSL_pending() checks in libpq/fe-misc.c
Previous Message Bruce Momjian 2002-06-14 03:37:57 Re: [HACKERS] First cut at SSL documentation