mirror of
https://github.com/postgres/postgres.git
synced 2025-08-08 06:02:22 +03:00
Fix multiple bugs in extension dropping.
When we implemented extensions, we made findDependentObjects() treat EXTENSION dependency links similarly to INTERNAL links. However, that logic contained an implicit assumption that an object could have at most one INTERNAL dependency, so it did not work correctly for objects having both INTERNAL and DEPENDENCY links. This led to failure to drop some extension member objects when dropping the extension. Furthermore, we'd never actually exercised the case of recursing to an internally-referenced (owning) object from anything other than a NORMAL dependency, and it turns out that passing the incoming dependency's flags to the owning object is the Wrong Thing. This led to sometimes dropping a whole extension silently when we should have rejected the drop command for lack of CASCADE. Since we obviously were under-testing extension drop scenarios, add some regression test cases. Unfortunately, such test cases require some extensions (duh), so we can't test for problems in the core regression tests. I chose to add them to the earthdistance contrib module, which is a good test case because it has a dependency on the cube contrib module. Back-patch to 9.1. Arguably these are pre-existing bugs in INTERNAL dependency handling, but since it appears that the cases can never arise pre-9.1, I'll refrain from back-patching the logic changes further than that.
This commit is contained in:
@@ -1,7 +1,14 @@
|
||||
--
|
||||
-- Test earth distance functions
|
||||
-- Test earthdistance extension
|
||||
--
|
||||
-- In this file we also do some testing of extension create/drop scenarios.
|
||||
-- That's really exercising the core database's dependency logic, so ideally
|
||||
-- we'd do it in the core regression tests, but we can't for lack of suitable
|
||||
-- guaranteed-available extensions. earthdistance is a good test case because
|
||||
-- it has a dependency on the cube extension.
|
||||
--
|
||||
|
||||
CREATE EXTENSION earthdistance; -- fail, must install cube first
|
||||
CREATE EXTENSION cube;
|
||||
CREATE EXTENSION earthdistance;
|
||||
|
||||
@@ -291,3 +298,68 @@ SELECT is_point(ll_to_earth(-30,-90));
|
||||
SELECT cube_dim(ll_to_earth(-30,-90)) <= 3;
|
||||
SELECT abs(cube_distance(ll_to_earth(-30,-90), '(0)'::cube) / earth() - 1) <
|
||||
'10e-12'::float8;
|
||||
|
||||
--
|
||||
-- Now we are going to test extension create/drop scenarios.
|
||||
--
|
||||
|
||||
-- list what's installed
|
||||
\dT
|
||||
\df
|
||||
\do
|
||||
|
||||
drop extension cube; -- fail, earthdistance requires it
|
||||
|
||||
drop extension earthdistance;
|
||||
|
||||
drop type cube; -- fail, extension cube requires it
|
||||
|
||||
-- list what's installed
|
||||
\dT
|
||||
\df
|
||||
\do
|
||||
|
||||
create table foo (f1 cube, f2 int);
|
||||
|
||||
drop extension cube; -- fail, foo.f1 requires it
|
||||
|
||||
drop table foo;
|
||||
|
||||
drop extension cube;
|
||||
|
||||
-- list what's installed
|
||||
\dT
|
||||
\df
|
||||
\do
|
||||
|
||||
create schema c;
|
||||
|
||||
create extension cube with schema c;
|
||||
|
||||
-- list what's installed
|
||||
\dT public.*
|
||||
\df public.*
|
||||
\do public.*
|
||||
\dT c.*
|
||||
\df c.*
|
||||
\do c.*
|
||||
|
||||
create table foo (f1 c.cube, f2 int);
|
||||
|
||||
drop extension cube; -- fail, foo.f1 requires it
|
||||
|
||||
drop schema c; -- fail, cube requires it
|
||||
|
||||
drop extension cube cascade;
|
||||
|
||||
\d foo
|
||||
|
||||
-- list what's installed
|
||||
\dT public.*
|
||||
\df public.*
|
||||
\do public.*
|
||||
\dT c.*
|
||||
\df c.*
|
||||
\do c.*
|
||||
|
||||
drop schema c;
|
||||
|
Reference in New Issue
Block a user