From: Kris Jurka <books@ejurka.com>
To: Andrei Ilitchev <andrei.ilitchev@oracle.com>
Cc: pgsql-jdbc@postgresql.org
Cc: Marina Vatkina <Marina.Vatkina@Sun.COM>
Subject: Re: Fw: postgresql experts please help
Date: Thu, 18 Oct 2007 19:34:36 -0400 (EDT)
Message-ID: <Pine.BSO.4.64.0710181927161.5403@leary.csoft.net> (raw)
In-Reply-To: <011701c811ca$03cea740$4c349c0a@ca.oracle.com>
References: <001101c81189$2f3f52d0$4c349c0a@ca.oracle.com>
<Pine.BSO.4.64.0710181343220.25640@leary.csoft.net>
<00d601c811b7$47c1a6e0$4c349c0a@ca.oracle.com>
<Pine.BSO.4.64.0710181506040.30980@leary.csoft.net>
<011701c811ca$03cea740$4c349c0a@ca.oracle.com>
On Thu, 18 Oct 2007, Andrei Ilitchev wrote:
> IMO this behaviour (if there's existing sequence create another one with the
> same name but in some other place) is very wrong - be predictible, throw
> exception.
This is not true, but it can be confusing. A serial's sequence will
always be put in the same schema as the table it's attached to. If
another sequence exists with the same name in that schema, it will choose
another name for the serial sequence:
jurka=# create sequence t2_a_seq;
CREATE SEQUENCE
jurka=# create table t2 (a serial);
NOTICE: CREATE TABLE will create implicit sequence "t2_a_seq1" for serial
column "t2.a"
CREATE TABLE
Notice that it created "t2_a_seq1" to avoid the conflict with the existing
"t2_a_seq" sequence. If you've got another sequence with the same name in
another schema it does not conflict, but depending on your search_path you
can get them mixed up. Both of these problems are solved by using
pg_get_serial_sequence, which should perhaps be mentioned more prominently
in the documentation. There is definitely a use for keeping multiple
tables/sequences with identical names in different schemas and not having
them conflict. In fact that's the primary use case for having schemas at
all.
Kris Jurka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: books@ejurka.com, andrei.ilitchev@oracle.com, Marina.Vatkina@Sun.COM
Subject: Re: Fw: postgresql experts please help
In-Reply-To: <Pine.BSO.4.64.0710181927161.5403@leary.csoft.net>
References: <001101c81189$2f3f52d0$4c349c0a@ca.oracle.com> <Pine.BSO.4.64.0710181343220.25640@leary.csoft.net> <00d601c811b7$47c1a6e0$4c349c0a@ca.oracle.com> <Pine.BSO.4.64.0710181506040.30980@leary.csoft.net> <011701c811ca$03cea740$4c349c0a@ca.oracle.com> <Pine.BSO.4.64.0710181927161.5403@leary.csoft.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox