Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 4f932ab

Browse files
committed
Fix migration script
1 parent 77ab2c4 commit 4f932ab

File tree

2 files changed

+17
-54
lines changed

2 files changed

+17
-54
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ DATA_built = pg_pathman--$(EXTVERSION).sql
2525
DATA = pg_pathman--1.0--1.1.sql \
2626
pg_pathman--1.1--1.2.sql \
2727
pg_pathman--1.2--1.3.sql \
28-
pg_pathman--1.3--1.4.sql
28+
pg_pathman--1.3--1.4.sql \
29+
pg_pathman--1.4--1.5.sql
2930

3031
PGFILEDESC = "pg_pathman - partitioning tool for PostgreSQL"
3132

pg_pathman--1.4--1.5.sql

Lines changed: 15 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,3 @@
1-
/*
2-
* Drop triggers
3-
*/
4-
CREATE OR REPLACE FUNCTION @extschema@.drop_triggers(
5-
parent_relid REGCLASS)
6-
RETURNS VOID AS $$
7-
DECLARE
8-
triggername TEXT;
9-
relation OID;
10-
11-
BEGIN
12-
triggername := concat(parent_relid::text, '_upd_trig');
13-
14-
/* Drop trigger for each partition if exists */
15-
FOR relation IN (SELECT pg_catalog.pg_inherits.inhrelid
16-
FROM pg_catalog.pg_inherits
17-
JOIN pg_catalog.pg_trigger ON inhrelid = tgrelid
18-
WHERE inhparent = parent_relid AND tgname = triggername)
19-
LOOP
20-
EXECUTE format('DROP TRIGGER IF EXISTS %s ON %s',
21-
triggername,
22-
relation::REGCLASS);
23-
END LOOP;
24-
25-
/* Drop trigger on parent */
26-
IF EXISTS (SELECT * FROM pg_catalog.pg_trigger
27-
WHERE tgname = triggername AND tgrelid = parent_relid)
28-
THEN
29-
EXECUTE format('DROP TRIGGER IF EXISTS %s ON %s',
30-
triggername,
31-
parent_relid::TEXT);
32-
END IF;
33-
END
34-
$$ LANGUAGE plpgsql STRICT;
35-
36-
DO $$
37-
DECLARE r record;
38-
BEGIN
39-
FOR r IN SELECT parent_relid FROM @extschema@.pathman_config
40-
LOOP
41-
PERFORM @extschema@.drop_triggers(r.parent_relid); +
42-
END LOOP;
43-
END$$;
44-
451
/*
462
* Add new partition
473
*/
@@ -685,8 +641,7 @@ END
685641
$$ LANGUAGE plpgsql
686642
SET pg_pathman.enable_partitionfilter = off; /* ensures that PartitionFilter is OFF */
687643

688-
-- deprecated
689-
CREATE OR REPLACE FUNCTION public.get_pathman_lib_version()
644+
CREATE FUNCTION @extschema@.pathman_version()
690645
RETURNS CSTRING AS 'pg_pathman', 'pathman_version'
691646
LANGUAGE C STRICT;
692647

@@ -706,7 +661,8 @@ LANGUAGE sql STRICT;
706661
/*
707662
* Get partitioning key.
708663
*/
709-
CREATE OR REPLACE FUNCTION @extschema@.get_partition_key(
664+
DROP FUNCTION @extschema@.get_partition_key(REGCLASS);
665+
CREATE FUNCTION @extschema@.get_partition_key(
710666
parent_relid REGCLASS)
711667
RETURNS TEXT AS
712668
$$
@@ -719,14 +675,16 @@ LANGUAGE sql STRICT;
719675
/*
720676
* Get partitioning key type.
721677
*/
722-
CREATE OR REPLACE FUNCTION @extschema@.get_partition_key_type(
678+
DROP FUNCTION @extschema@.get_partition_key_type(REGCLASS);
679+
CREATE FUNCTION @extschema@.get_partition_key_type(
723680
parent_relid REGCLASS)
724681
RETURNS REGTYPE AS 'pg_pathman', 'get_partition_key_type_pl'
725682
LANGUAGE C STRICT;
726683

727684
/*
728685
* Get partitioning type.
729686
*/
687+
DROP FUNCTION @extschema@.get_partition_type(REGCLASS);
730688
CREATE OR REPLACE FUNCTION @extschema@.get_partition_type(
731689
parent_relid REGCLASS)
732690
RETURNS INT4 AS
@@ -798,7 +756,9 @@ $$ LANGUAGE plpgsql;
798756
/*
799757
* Show all existing concurrent partitioning tasks.
800758
*/
801-
CREATE OR REPLACE FUNCTION @extschema@.show_concurrent_part_tasks()
759+
DROP VIEW @extschema@.pathman_concurrent_part_tasks;
760+
DROP FUNCTION @extschema@.show_concurrent_part_tasks();
761+
CREATE FUNCTION @extschema@.show_concurrent_part_tasks()
802762
RETURNS TABLE (
803763
userid REGROLE,
804764
pid INT,
@@ -809,6 +769,10 @@ RETURNS TABLE (
809769
AS 'pg_pathman', 'show_concurrent_part_tasks_internal'
810770
LANGUAGE C STRICT;
811771

772+
CREATE VIEW @extschema@.pathman_concurrent_part_tasks
773+
AS SELECT * FROM @extschema@.show_concurrent_part_tasks();
774+
GRANT SELECT ON @extschema@.pathman_concurrent_part_tasks TO PUBLIC;
775+
812776
/*
813777
* Split RANGE partition in two using a pivot.
814778
*/
@@ -821,13 +785,11 @@ CREATE OR REPLACE FUNCTION @extschema@.split_range_partition(
821785
RETURNS REGCLASS AS 'pg_pathman', 'split_range_partition'
822786
LANGUAGE C;
823787

824-
ALTER TABLE public.pathman_concurrent_part_tasks
825-
ALTER COLUMN processed SET TYPE bigint;
826-
827788
DROP FUNCTION @extschema@.build_update_trigger_func_name(regclass);
828789
DROP FUNCTION @extschema@.build_update_trigger_name(regclass);
829790
DROP FUNCTION @extschema@.create_single_update_trigger(regclass, regclass);
830791
DROP FUNCTION @extschema@.create_update_triggers(regclass);
831792
DROP FUNCTION @extschema@.drop_triggers(regclass);
832793
DROP FUNCTION @extschema@.has_update_trigger(regclass);
833-
DROP FUNCTION @extschema@.pathman_update_trigger_func();
794+
DROP FUNCTION @extschema@.pathman_update_trigger_func() CASCADE;
795+
DROP FUNCTION @extschema@.get_pathman_lib_version();

0 commit comments

Comments
 (0)