mirror of https://github.com/citusdata/citus.git
Ensure no dependencies to index before drop
(cherry picked from commit 11a9a3771f
)
release-10.2-fix-for-move-pg-dist-object
parent
f3ebea7e64
commit
8fd0aff620
|
@ -10,6 +10,17 @@
|
|||
--
|
||||
-- To do that, drop stripe_first_row_number_idx and create a unique
|
||||
-- constraint with the same name to keep the code change at minimum.
|
||||
--
|
||||
-- If we have a pg_depend entry for this index, we can not drop it as
|
||||
-- the extension depends on it. Remove the pg_depend entry if it exists.
|
||||
DELETE FROM pg_depend
|
||||
WHERE classid = 'pg_am'::regclass::oid
|
||||
AND objid IN (select oid from pg_am where amname = 'columnar')
|
||||
AND objsubid = 0
|
||||
AND refclassid = 'pg_class'::regclass::oid
|
||||
AND refobjid = 'columnar.stripe_first_row_number_idx'::regclass::oid
|
||||
AND refobjsubid = 0
|
||||
AND deptype = 'n';
|
||||
DROP INDEX columnar.stripe_first_row_number_idx;
|
||||
ALTER TABLE columnar.stripe ADD CONSTRAINT stripe_first_row_number_idx
|
||||
UNIQUE (storage_id, first_row_number);
|
||||
|
|
|
@ -8,5 +8,16 @@ DROP FUNCTION citus_internal.upgrade_columnar_storage(regclass);
|
|||
DROP FUNCTION citus_internal.downgrade_columnar_storage(regclass);
|
||||
|
||||
-- drop "first_row_number" column and the index defined on it
|
||||
--
|
||||
-- If we have a pg_depend entry for this index, we can not drop it as
|
||||
-- the extension depends on it. Remove the pg_depend entry if it exists.
|
||||
DELETE FROM pg_depend
|
||||
WHERE classid = 'pg_am'::regclass::oid
|
||||
AND objid IN (select oid from pg_am where amname = 'columnar')
|
||||
AND objsubid = 0
|
||||
AND refclassid = 'pg_class'::regclass::oid
|
||||
AND refobjid = 'columnar.stripe_first_row_number_idx'::regclass::oid
|
||||
AND refobjsubid = 0
|
||||
AND deptype = 'n';
|
||||
DROP INDEX columnar.stripe_first_row_number_idx;
|
||||
ALTER TABLE columnar.stripe DROP COLUMN first_row_number;
|
||||
|
|
|
@ -1,4 +1,14 @@
|
|||
-- columnar--10.2-3--10.2-2.sql
|
||||
|
||||
--
|
||||
-- If we have a pg_depend entry for this index, we can not drop it as
|
||||
-- the extension depends on it. Remove the pg_depend entry if it exists.
|
||||
DELETE FROM pg_depend
|
||||
WHERE classid = 'pg_am'::regclass::oid
|
||||
AND objid IN (select oid from pg_am where amname = 'columnar')
|
||||
AND objsubid = 0
|
||||
AND refclassid = 'pg_class'::regclass::oid
|
||||
AND refobjid = 'columnar.stripe_first_row_number_idx'::regclass::oid
|
||||
AND refobjsubid = 0
|
||||
AND deptype = 'n';
|
||||
ALTER TABLE columnar.stripe DROP CONSTRAINT stripe_first_row_number_idx;
|
||||
CREATE INDEX stripe_first_row_number_idx ON columnar.stripe USING BTREE(storage_id, first_row_number);
|
||||
|
|
|
@ -918,11 +918,7 @@ SELECT * FROM multi_extension.print_extension_changes();
|
|||
-- There was a bug when downgrading to 10.2-2 from 10.2-4
|
||||
-- Test that we do not have any issues with this particular downgrade
|
||||
ALTER EXTENSION citus UPDATE TO '10.2-2';
|
||||
ERROR: cannot drop constraint stripe_first_row_number_idx on table columnar.stripe because other objects depend on it
|
||||
DETAIL: access method columnar depends on index columnar.stripe_first_row_number_idx
|
||||
HINT: Use DROP ... CASCADE to drop the dependent objects too.
|
||||
ALTER EXTENSION citus UPDATE TO '10.2-4';
|
||||
NOTICE: version "10.2-4" of extension "citus" is already installed
|
||||
SELECT * FROM multi_extension.print_extension_changes();
|
||||
previous_object | current_object
|
||||
---------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue