![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
The following queries result in a dropped sequence, but IMO should not: create table foo(id serial); create table bar(id integer not null nextval('foo_id_seq'::text)); alter table foo alter column id drop default; drop table foo; |
#3
| |||
| |||
|
|
On Sunday December 5 2004 12:34, Ed L. wrote: The following queries result in a dropped sequence, but IMO should not: create table foo(id serial); create table bar(id integer not null nextval('foo_id_seq'::text)); alter table foo alter column id drop default; drop table foo; Once dependence between foo and foo_id_seq has been removed, a drop of foo should not drop foo_id_seq, particularly if someone else is using it as a default. This occurs in 7.3.4 and 7.4.6. I don't think that follows at all. The sequence is associated with the column because of use of the "serial" declaration; dropping the default expression doesn't change that. If you want to use a single sequence to feed two different columns, declare it as an object in its own right. If I were to change anything at all about the above example, it would to find a way to disallow you from referencing the foo.id sequence for bar.id, because you are poking into the internals of the SERIAL abstraction when you do that. |
#4
| |||
| |||
|
|
On Sun, 05 Dec 2004 14:54:38, Tom Lane wrote: On Sunday December 5 2004 12:34, Ed L. wrote: The following queries result in a dropped sequence, but IMO should not: create table foo(id serial); create table bar(id integer not null nextval('foo_id_seq'::text)); alter table foo alter column id drop default; drop table foo; I don't think that follows at all. The sequence is associated with the column because of use of the "serial" declaration; dropping the default expression doesn't change that. |
#5
| |||
| |||
|
|
I can see the point of *not* dropping the sequence unless the owning column is dropped. I just don't see the point of disabling the useful ability to decouple the sequence-column association, and dropping the default seems the most reasonable way to do that. |
#6
| |||
| |||
|
|
"Ed L." <pgsql (AT) bluepolka (DOT) net> writes: I can see the point of *not* dropping the sequence unless the owning column is dropped. I just don't see the point of disabling the useful ability to decouple the sequence-column association, and dropping the default seems the most reasonable way to do that. Where we part ways is on the claim that this is useful. As I said before, if you think they are independent objects then you should create 'em that way. |
![]() |
| Thread Tools | |
| Display Modes | |
| |