drop table problem

Started by frank_lupoabout 23 years ago5 messagesgeneral
Jump to latest
#1frank_lupo
frank_lupo@email.it

I using
PostgreSQL 7.3.1 on i686-pc-cygwin, compiled by GCC gcc (GCC) 3.2 20020927 (prerelease)

If create a table and alter column add sequence. The relation on table and sequence is not present in pg_depend.
When drop table the sequence is not dropped.
Bye !!
Frank Lupo (Wolf) !!

/\_ _/\
\ o o /
--ooo-----ooo---

--
Prendi GRATIS l'email universale che... risparmia: http://www.email.it/f

Sponsor:
La tua macchina si avvia tossendo? Trova un elettrauto su QxService
cliccando qui
Clicca qui: http://adv2.email.it/cgi-bin/foclick.cgi?mid=846&d=24-1

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: frank_lupo (#1)
Re: drop table problem

"=?utf-8?Q?frank=5Flupo?=" <frank_lupo@email.it> writes:

If create a table and alter column add sequence. The relation on table and =
sequence is not present in pg_depend.

What are you doing, exactly? ADD COLUMN foo SERIAL doesn't work yet.

regression=# alter table vv add column f2 serial;
NOTICE: ALTER TABLE will create implicit sequence 'vv_f2_seq' for SERIAL column 'vv.f2'
ERROR: Adding columns with defaults is not implemented.
Add the column, then use ALTER TABLE SET DEFAULT.

SET DEFAULT nextval('foo') does not create an auto-drop dependency,
and should not IMHO.

regards, tom lane

#3frank_lupo
frank_lupo@email.it
In reply to: Tom Lane (#2)
Re: drop table problem

"=?utf-8?Q?frank=5Flupo?=" writes:

If create a table and alter column add sequence. The relation on table and =
sequence is not present in pg_depend.

What are you doing, exactly? ADD COLUMN foo SERIAL doesn't work yet.

regression=# alter table vv add column f2 serial;
NOTICE: ALTER TABLE will create implicit sequence 'vv_f2_seq' for SERIAL column 'vv.f2'
ERROR: Adding columns with defaults is not implemented.
Add the column, then use ALTER TABLE SET DEFAULT.

SET DEFAULT nextval('foo') does not create an auto-drop dependency,
and should not IMHO.

regards, tom lane

My problem is the field already exists, and the only way to associate a sequence is this.

SET DEFAULT nextval('foo')

Tanks

Bye !!
Frank Lupo (Wolf) !!

/\_ _/\
\ o o /
--ooo-----ooo---

--
Prendi GRATIS l'email universale che... risparmia: http://www.email.it/f

Sponsor:
Oro, argento, diamanti e pietre preziose: una miniera di meraviglie.
Clicca qui: http://adv2.email.it/cgi-bin/foclick.cgi?mid=772&amp;d=25-1

#4frank_lupo
frank_lupo@email.it
In reply to: frank_lupo (#3)
Re: drop table problem

"=?utf-8?Q?frank=5Flupo?=" writes:

If create a table and alter column add sequence. The relation on table and =
sequence is not present in pg_depend.

What are you doing, exactly? ADD COLUMN foo SERIAL doesn't work yet.

regression=# alter table vv add column f2 serial;
NOTICE: ALTER TABLE will create implicit sequence 'vv_f2_seq' for SERIAL column 'vv.f2'
ERROR: Adding columns with defaults is not implemented.
Add the column, then use ALTER TABLE SET DEFAULT.

SET DEFAULT nextval('foo') does not create an auto-drop dependency,
and should not IMHO.

regards, tom lane

An other problem and that if I create a table p1 with a field sequence and this sequence I associate it to one other table p2, when drop p1 the table p2 remains without sequence.

Tanks

Bye !!
Frank Lupo (Wolf) !!

/\_ _/\
\ o o /

--ooo---
-
-ooo---

#5Tom Lane
tgl@sss.pgh.pa.us
In reply to: frank_lupo (#4)
Re: Re: drop table problem

"=?utf-8?Q?frank=5Flupo?=" <frank_lupo@email.it> writes:

"=3D?utf-8?Q?frank=3D5Flupo?=3D" writes:=0D=0A> > If create a table and alter column add sequence. The relation on table and =3D=0D=0A> > sequence is not present in pg_depend.=0D=0A> =0D=0A> What are you doing, exactly? ADD COLUMN foo SERIAL doesn't work yet.=0D=0A> =0D=0A> regression=3D# alter table vv add column f2 serial;=0D=0A> NOTICE: ALTER TABLE will create implicit sequence 'vv_f2_seq' for SERIAL column 'vv.f2'=0D=0A> ERROR: Adding columns with defaults is not implemented.=0D=0A> Add the column, then use ALTER TABLE SET DEFAULT.=0D=0A> =0D=0A> SET DEFAULT nextval('foo') does not create an auto-drop dependency,=0D=0A> and should not IMHO.=0D=0A> =0D=0A> regards, tom lane=0D=0A> =0D=0A=0D=0AAn other problem and that if I create a table p1 with a field sequence and this sequence I associate it to one other table p2, when drop p1 the table p2 remains without sequence.=0D=0A=0D=0ATanks=0A=0ABye !!=0AFrank Lupo (Wolf) !!=0A=0A /\_ _/\=0A \ o o /=!

0A--ooo---

Might I ask you to stop MIME-encoding your mail?

Anyway, I think you're misusing serial sequences. If you create a
sequence "foo" and then use DEFAULT nextval('foo') for some tables,
then the sequence is an independent object and should *not* go away
when the tables are removed. If you declare a column as SERIAL, then
the fact that there is a sequence behind that is an implementation
detail --- you have no business messing with that sequence directly.

Having said that, it'd be good if nextval('foo') created an ordinary
(not auto-drop) dependency from the expression to the sequence foo.
That's not implemented yet, but we're thinking about it.

regards, tom lane