Обсуждение: BUG #14434: Drop a table with a serial in an extension
VGhlIGZvbGxvd2luZyBidWcgaGFzIGJlZW4gbG9nZ2VkIG9uIHRoZSB3ZWJz aXRlOgoKQnVnIHJlZmVyZW5jZTogICAgICAxNDQzNApMb2dnZWQgYnk6ICAg ICAgICAgIFBoaWxpcHBlIEJFQVVET0lOCkVtYWlsIGFkZHJlc3M6ICAgICAg cGhiMDdAYXByYS5hc3NvLmZyClBvc3RncmVTUUwgdmVyc2lvbjogOS42LjEK T3BlcmF0aW5nIHN5c3RlbTogICBMaW51eCBVYnVudHUKRGVzY3JpcHRpb246 ICAgICAgICAKCkkgcmVhY2ggc29tZXRoaW5nIHN0cmFuZ2UgcmVjZW50bHkg d2hlbiBkZXZlbG9waW5nIGFuIHVwZ3JhZGUgc2NyaXB0IGZvciBhbgpleHRl bnNpb24uDQoNCkxldCdzIGNyZWF0ZSBhIHRhYmxlIHdpdGggYSBzZXJpYWwg Y29sdW1uIChvdXRzaWRlIGFueSBleHRlbnNpb24pLg0KVGhlbiBsZXQncyBs aW5rIHRoZSB0YWJsZSB3aXRoIGl0cyBzZXF1ZW5jZSB0byBhIG5ldyBleHRl bnNpb24gdXNpbmcgQUxURVIKRVhURU5TSU9OIEFERCAuLi4gaW4gdGhlIGV4 dGVuc2lvbiBzY3JpcHQuDQpFdmVuIHRob3VnaCB0aGUgZG9jdW1lbnRhdGlv biBpcyBub3QgY2xlYXIgb24gdGhhdCBwb2ludCwgaXQgaXMgbmVjZXNzYXJ5 IHRvCmV4cGxpY2l0bHkgbGluayB0aGUgc2VxdWVuY2UgdG8gdGhlIGV4dGVu c2lvbiwgbm90IHRvIGJlIGluIHRyb3VibGUgd2l0aApwZ19kdW1wIGZvciBp bnN0YW5jZS4NClNvIGZhciBzbyBnb29kLiBFdmVyeXRoaW5nIHJlYWN0cyBh cyBpZiB0aGUgdGFibGUgaGFkIGJlZW4gY3JlYXRlZCBpbnNpZGUKdGhlIGV4 dGVuc2lvbi4NCg0KQnV0IG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AgIDAg fCBlDQooMyByb3dzKQ0KDQpUaGlzIHJlZmxlY3RzIGNvcnJlY3RseSB0aGUg ZXhwZWN0ZWQgZGVwZW5kYW5jaWVzIChhdCBsZWFzdCB0byBtZSkNCioqKiBw Z19kdW1wIGVmZmVjdGl2ZWx5IGRvZXNuJ3QgY29uc2lkZXIgdGhlIDJuZCBz ZXF1ZW5jZSBhcyBtZW1iZXIgb2YgdGhlCmV4dGVuc2lvbg0KQ1JFQVRFIFNF UVVFTkNFIG9sZF90YmwyX2NvbDJfc2VxDQoqKiogVHJ5IHRvIHVwZGF0ZSB0 aGUgZXh0ZW5zaW9uDQpFUlJPUjogIGNhbm5vdCBkcm9wIHRhYmxlIG9sZF90 YmwxIGJlY2F1c2Ugb3RoZXIgb2JqZWN0cyBkZXBlbmQgb24gaXQNCkRFVEFJ TDogIGV4dGVuc2lvbiBleHQxIGRlcGVuZHMgb24gdGFibGUgb2xkX3RibDEN CkhJTlQ6ICBVc2UgRFJPUCAuLi4gQ0FTQ0FERSB0byBkcm9wIHRoZSBkZXBl bmRlbnQgb2JqZWN0cyB0b28uDQogICAgIExpc3Qgb2YgaW5zdGFsbGVkIGV4 dGVuc2lvbnMNCiBOYW1lIHwgVmVyc2lvbiB8IFNjaGVtYSB8IERlc2NyaXB0 aW9uDQotLS0tLS0rLS0tLS0tLS0tKy0tLS0tLS0tKy0tLS0tLS0tLS0tLS0N CiBleHQxIHwgMSAgICAgICB8IHB1YmxpYyB8DQooMSByb3cpDQoNCioqKiBF bmQgb2YgdGVzdA0KRFJPUCBFWFRFTlNJT04KCg==
phb07@apra.asso.fr writes: > Let's create a table with a serial column (outside any extension). > Then let's link the table with its sequence to a new extension using ALTER > EXTENSION ADD ... in the extension script. > Even though the documentation is not clear on that point, it is necessary to > explicitly link the sequence to the extension, not to be in trouble with > pg_dump for instance. > So far so good. Everything reacts as if the table had been created inside > the extension. > But an error occurs when I try to drop this table in the next extension > upgrade script: > ERROR: cannot drop table old_tbl1 because other objects depend on it > DETAIL: extension ext1 depends on table old_tbl1 > HINT: Use DROP ... CASCADE to drop the dependent objects too. > As a workaround, the sequence can be unlinked from the extension just before > dropping the table. Don't see why that's a "workaround". You added the extension membership for the sequence explicitly, why wouldn't you expect to need to drop it explicitly? Seems to me the system is behaving properly. If you want to drop the table but keep the sequence, you need to unlink the sequence from the table, a la alter sequence old_tbl1_col1_seq owned by none; before dropping the table. regards, tom lane
Thanks Tom, Le 26/11/2016 à 01:59, Tom Lane a écrit : > phb07@apra.asso.fr writes: >> Let's create a table with a serial column (outside any extension). >> Then let's link the table with its sequence to a new extension using ALTER >> EXTENSION ADD ... in the extension script. >> Even though the documentation is not clear on that point, it is necessary to >> explicitly link the sequence to the extension, not to be in trouble with >> pg_dump for instance. >> So far so good. Everything reacts as if the table had been created inside >> the extension. >> But an error occurs when I try to drop this table in the next extension >> upgrade script: >> ERROR: cannot drop table old_tbl1 because other objects depend on it >> DETAIL: extension ext1 depends on table old_tbl1 >> HINT: Use DROP ... CASCADE to drop the dependent objects too. >> As a workaround, the sequence can be unlinked from the extension just before >> dropping the table. > Don't see why that's a "workaround". You added the extension membership > for the sequence explicitly, why wouldn't you expect to need to drop it > explicitly? Seems to me the system is behaving properly. Because depending on the way a table has been included in the extension (either directly created inside the extension or first created outside and then linked to the extension) the procedure to drop it some versions later would be different. Of course it would be normal to get this error if the sequence would have been linked to another extension. But my feeling is that dropping a table that generates a sequence drop, both belonging to the same extension, shouldn't be refused. If the current behaviour is considered as "normal", then the error message looks strange anyway. In particular the DETAIL output doesn't reflect the real issue as it doesn't mention the faulting sequence. And the DROP TABLE ... CASCADE suggested in the HINT doesn't help too. And a short sentence in the documentation (in the ALTER EXTENSION page for instance) would also probably help. > If you want to drop the table but keep the sequence, you need to unlink > the sequence from the table, a la > > alter sequence old_tbl1_col1_seq owned by none; > > before dropping the table. OK, but in this case, I didn't want to keep the sequence. > regards, tom lane > Regards. Philippe Beaudoin
phb07 <phb07@apra.asso.fr> writes: > Le 26/11/2016 à 01:59, Tom Lane a écrit : >> Don't see why that's a "workaround". You added the extension membership >> for the sequence explicitly, why wouldn't you expect to need to drop it >> explicitly? Seems to me the system is behaving properly. > Because depending on the way a table has been included in the extension > (either directly created inside the extension or first created outside > and then linked to the extension) the procedure to drop it some versions > later would be different. Well, no it wouldn't be, but nonetheless on closer study I think you're right that this is a bug. There is code in there that intends to make it unnecessary to issue "ALTER EXTENSION DROP member" when an extension update script drops a member object; it should be sufficient to just drop the object. It was failing to fire in this case because the drop was indirect, but it should work anyway. I've applied a patch for that. Thanks for the report! regards, tom lane
Le 26/11/2016 à 19:36, Tom Lane a écrit : > phb07 <phb07@apra.asso.fr> writes: >> Le 26/11/2016 à 01:59, Tom Lane a écrit : >>> Don't see why that's a "workaround". You added the extension membership >>> for the sequence explicitly, why wouldn't you expect to need to drop it >>> explicitly? Seems to me the system is behaving properly. >> Because depending on the way a table has been included in the extension >> (either directly created inside the extension or first created outside >> and then linked to the extension) the procedure to drop it some versions >> later would be different. > Well, no it wouldn't be, but nonetheless on closer study I think you're > right that this is a bug. There is code in there that intends to make it > unnecessary to issue "ALTER EXTENSION DROP member" when an extension > update script drops a member object; it should be sufficient to just > drop the object. It was failing to fire in this case because the drop > was indirect, but it should work anyway. > > I've applied a patch for that. Thanks for the report! Thank You very much, Tom. > > regards, tom lane >