pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedCREATE TABLE glitch -fix request for 7.2
5+ messages / 4 participants
[nested] [flat]
* CREATE TABLE glitch -fix request for 7.2
@ 2002-01-14 16:47 Josh Berkus <josh@agliodbs.com>
0 siblings, 2 replies; 5+ messages in thread
From: Josh Berkus @ 2002-01-14 16:47 UTC (permalink / raw)
To: pgsql-sql
Tom, Peter, Stephan, et al.:
Here's a glitch that's bothered me for a while (ver 7.0 -> 7.2b4 ) in
PostgreSQL DDL statements. I was thinking that since 7.2 is still in beta,
that you could fix it this version.
To produce the glitch:
1. Create a SQL script file that drops a table, then creates that table with a
SERIAL primary key (I do this all the time to build my databases)
2. Run the script once to create the table. You'll get a error (no table to
drop) but that doesn't matter.
3. Run the script a second time, as if you were making changes to the data
structure and needed to rebuild.
4. You will get an error telling you that "table1_id_seq" already exists, and
the CREATE TABLE statement will fail.
This is very user-unfriendly behaviour, especially in a database that still
does not support about 50% of ALTER TABLE. I spend a fair amount of extra
time deleting SERIAL sequences when I am doing the database-building part of
the development process.
Can we change this behavior, please? I'd suppose that it would require you to
create some sort of permanent link between SERIAL columns and the sequences
they spawn.
-Josh Berkus
______AGLIO DATABASE SOLUTIONS___________________________
Josh Berkus
Complete information technology josh@agliodbs.com
and data management solutions (415) 565-7293
for law firms, small businesses fax 621-2533
and non-profit organizations. San Francisco
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: CREATE TABLE glitch -fix request for 7.2
@ 2002-01-14 18:07 Bruce Momjian <pgman@candle.pha.pa.us>
parent: Josh Berkus <josh@agliodbs.com>
1 sibling, 1 reply; 5+ messages in thread
From: Bruce Momjian @ 2002-01-14 18:07 UTC (permalink / raw)
To: Josh Berkus <josh@agliodbs.com>; +Cc: pgsql-sql
Josh Berkus wrote:
> Tom, Peter, Stephan, et al.:
>
> Here's a glitch that's bothered me for a while (ver 7.0 -> 7.2b4 ) in
> PostgreSQL DDL statements. I was thinking that since 7.2 is still in beta,
> that you could fix it this version.
>
> To produce the glitch:
> 1. Create a SQL script file that drops a table, then creates that table with a
> SERIAL primary key (I do this all the time to build my databases)
> 2. Run the script once to create the table. You'll get a error (no table to
> drop) but that doesn't matter.
> 3. Run the script a second time, as if you were making changes to the data
> structure and needed to rebuild.
> 4. You will get an error telling you that "table1_id_seq" already exists, and
> the CREATE TABLE statement will fail.
>
> This is very user-unfriendly behaviour, especially in a database that still
> does not support about 50% of ALTER TABLE. I spend a fair amount of extra
> time deleting SERIAL sequences when I am doing the database-building part of
> the development process.
>
> Can we change this behavior, please? I'd suppose that it would require you to
> create some sort of permanent link between SERIAL columns and the sequences
> they spawn.
We need pg_depend table to track dependency of sequence on specific
tables, hopefully in >=7.3.
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: CREATE TABLE glitch -fix request for 7.2
@ 2002-01-14 18:18 Tom Lane <tgl@sss.pgh.pa.us>
parent: Josh Berkus <josh@agliodbs.com>
1 sibling, 1 reply; 5+ messages in thread
From: Tom Lane @ 2002-01-14 18:18 UTC (permalink / raw)
To: Josh Berkus <josh@agliodbs.com>; +Cc: pgsql-sql
"Josh Berkus" <josh@agliodbs.com> writes:
> I was thinking that since 7.2 is still in beta,
> that you could fix it this version.
Not a chance. Sorry. If you'd cared to submit some code six months
ago... but this is a nontrivial change, the problem has been of long
standing and yet hasn't especially motivated anyone to work on it, and
we are *not* holding up 7.2 any more for anything but critical bugs.
regards, tom lane
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: CREATE TABLE glitch -fix request for 7.2
@ 2002-01-14 21:23 Josh Berkus <josh@agliodbs.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 5+ messages in thread
From: Josh Berkus @ 2002-01-14 21:23 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; Josh Berkus <josh@agliodbs.com>; +Cc: pgsql-sql
Tom,
> Not a chance. Sorry. If you'd cared to submit some code six months
> ago... but this is a nontrivial change, the problem has been of long
> standing and yet hasn't especially motivated anyone to work on it, and
> we are *not* holding up 7.2 any more for anything but critical bugs.
OK. In 7.3, then? Maybe?
-Josh
______AGLIO DATABASE SOLUTIONS___________________________
Josh Berkus
Complete information technology josh@agliodbs.com
and data management solutions (415) 565-7293
for law firms, small businesses fax 621-2533
and non-profit organizations. San Francisco
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: CREATE TABLE glitch -fix request for 7.2
@ 2002-01-14 21:55 Jason Earl <jason.earl@simplot.com>
parent: Bruce Momjian <pgman@candle.pha.pa.us>
0 siblings, 0 replies; 5+ messages in thread
From: Jason Earl @ 2002-01-14 21:55 UTC (permalink / raw)
To: Bruce Momjian <pgman@candle.pha.pa.us>; +Cc: Josh Berkus <josh@agliodbs.com>; pgsql-sql
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> Josh Berkus wrote:
> > Tom, Peter, Stephan, et al.:
> >
> > Here's a glitch that's bothered me for a while (ver 7.0 -> 7.2b4 ) in
> > PostgreSQL DDL statements. I was thinking that since 7.2 is still in beta,
> > that you could fix it this version.
> >
> > To produce the glitch:
> > 1. Create a SQL script file that drops a table, then creates that table with a
> > SERIAL primary key (I do this all the time to build my databases)
> > 2. Run the script once to create the table. You'll get a error (no table to
> > drop) but that doesn't matter.
> > 3. Run the script a second time, as if you were making changes to the data
> > structure and needed to rebuild.
> > 4. You will get an error telling you that "table1_id_seq" already exists, and
> > the CREATE TABLE statement will fail.
> >
> > This is very user-unfriendly behaviour, especially in a database that still
> > does not support about 50% of ALTER TABLE. I spend a fair amount of extra
> > time deleting SERIAL sequences when I am doing the database-building part of
> > the development process.
> >
> > Can we change this behavior, please? I'd suppose that it would require you to
> > create some sort of permanent link between SERIAL columns and the sequences
> > they spawn.
>
> We need pg_depend table to track dependency of sequence on specific
> tables, hopefully in >=7.3.
In the meantime Josh the simple workaround is to not use the SERIAL
type. Instead when you create your SQL script create the sequences
manually (that way you can drop them manually as well. My SQL scripts
look like this:
DROP TABLE prod_journal;
DROP SEQUENCE prod_journal_id_seq;
BEGIN;
CREATE SEQUENCE prod_journal_id_seq;
CREATE TABLE prod_journal (
id int PRIMARY KEY
DEFAULT nextval('prod_journal_id_seq'),
...
You undoubtedly get the picture by now. With the right text editor
creating a template for this sort of thing is almost as easy as using
the SERIAL keyword and a whole lot more flexible.
More importantly, if I want to run the script again and rebuild my
schema, everything works as expected.
Jason
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2002-01-14 21:55 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-01-14 16:47 CREATE TABLE glitch -fix request for 7.2 Josh Berkus <josh@agliodbs.com>
2002-01-14 18:07 ` Bruce Momjian <pgman@candle.pha.pa.us>
2002-01-14 21:55 ` Jason Earl <jason.earl@simplot.com>
2002-01-14 18:18 ` Tom Lane <tgl@sss.pgh.pa.us>
2002-01-14 21:23 ` Josh Berkus <josh@agliodbs.com>
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