Re: Quick question

From: Brent Verner <brent(at)rcfile(dot)org>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>, Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Quick question
Date: 2001-11-13 17:59:04
Message-ID: 20011113125904.A7508@rcfile.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 13 Nov 2001 at 12:33 (-0500), Bruce Momjian wrote:
| > On 13 Nov 2001 at 18:00 (+0800), Christopher Kings-Lynne wrote:
| > | Could someone please give me a quick tip as to where in the source code the
| > | bit that auto-generates sequence names is?
| >
| > I used cscope (http://cscope.sourceforge.net/) and did a text search
| > for 'implicit sequence'. A bit of backtracking from there led me to
| > src/backend/parser/anaylyz.c:783
| > sname = makeObjectName(cxt->relname, column->colname, "seq");
| >
| > That function is in the same file, and has some comments related to
| > name collision above it. I believe this is where you'll want to work.
|
| I think we handled this. Have you tried 7.2 beta2?

I believe the following demonstrates the problem Christopher would
like to solve.

brent=# select version();
version
---------------------------------------------------------------
PostgreSQL 7.2b2 on i686-pc-linux-gnu, compiled by GCC 2.95.4
(1 row)

brent=# create table test (id serial);
NOTICE: CREATE TABLE will create implicit sequence 'test_id_seq' for SERIAL column 'test.id'
NOTICE: CREATE TABLE / UNIQUE will create implicit index 'test_id_key' for table 'test'
ERROR: Relation 'test_id_seq' already exists

ISTM, that these sequences created by way of a SERIAL type should
be named "pg_serial_test_id_HASH" or similar, since they are system
(bookkeeping) rels. Also, I /personally/ would like it if the sequence
was dropped along with the table using it, provided that no other atts
in the system are using it. I'm not sure right now if this behavior
is even feasible.

That said, there is certainly immediate benefit in making sure the
CREATE TABLE with a SERIAL will succeed if the (initial choice for)
sequence name already exists.

cheers.
brent

--
"Develop your talent, man, and leave the world something. Records are
really gifts from people. To think that an artist would love you enough
to share his music with anyone is a beautiful thing." -- Duane Allman

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2001-11-13 18:01:21 Re: Open items
Previous Message Marc G. Fournier 2001-11-13 17:57:04 Re: Open items