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
-
45
1
/*
46
2
* Add new partition
47
3
*/
685
641
$$ LANGUAGE plpgsql
686
642
SET pg_pathman .enable_partitionfilter = off; /* ensures that PartitionFilter is OFF */
687
643
688
- -- deprecated
689
- CREATE OR REPLACE FUNCTION public .get_pathman_lib_version()
644
+ CREATE FUNCTION @extschema@.pathman_version()
690
645
RETURNS CSTRING AS ' pg_pathman' , ' pathman_version'
691
646
LANGUAGE C STRICT;
692
647
@@ -706,7 +661,8 @@ LANGUAGE sql STRICT;
706
661
/*
707
662
* Get partitioning key.
708
663
*/
709
- CREATE OR REPLACE FUNCTION @extschema@.get_partition_key(
664
+ DROP FUNCTION @extschema@.get_partition_key(REGCLASS);
665
+ CREATE FUNCTION @extschema@.get_partition_key(
710
666
parent_relid REGCLASS)
711
667
RETURNS TEXT AS
712
668
$$
@@ -719,14 +675,16 @@ LANGUAGE sql STRICT;
719
675
/*
720
676
* Get partitioning key type.
721
677
*/
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(
723
680
parent_relid REGCLASS)
724
681
RETURNS REGTYPE AS ' pg_pathman' , ' get_partition_key_type_pl'
725
682
LANGUAGE C STRICT;
726
683
727
684
/*
728
685
* Get partitioning type.
729
686
*/
687
+ DROP FUNCTION @extschema@.get_partition_type(REGCLASS);
730
688
CREATE OR REPLACE FUNCTION @extschema@.get_partition_type(
731
689
parent_relid REGCLASS)
732
690
RETURNS INT4 AS
@@ -798,7 +756,9 @@ $$ LANGUAGE plpgsql;
798
756
/*
799
757
* Show all existing concurrent partitioning tasks.
800
758
*/
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()
802
762
RETURNS TABLE (
803
763
userid REGROLE,
804
764
pid INT ,
@@ -809,6 +769,10 @@ RETURNS TABLE (
809
769
AS ' pg_pathman' , ' show_concurrent_part_tasks_internal'
810
770
LANGUAGE C STRICT;
811
771
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
+
812
776
/*
813
777
* Split RANGE partition in two using a pivot.
814
778
*/
@@ -821,13 +785,11 @@ CREATE OR REPLACE FUNCTION @extschema@.split_range_partition(
821
785
RETURNS REGCLASS AS ' pg_pathman' , ' split_range_partition'
822
786
LANGUAGE C;
823
787
824
- ALTER TABLE public .pathman_concurrent_part_tasks
825
- ALTER COLUMN processed SET TYPE bigint ;
826
-
827
788
DROP FUNCTION @extschema@.build_update_trigger_func_name(regclass);
828
789
DROP FUNCTION @extschema@.build_update_trigger_name(regclass);
829
790
DROP FUNCTION @extschema@.create_single_update_trigger(regclass, regclass);
830
791
DROP FUNCTION @extschema@.create_update_triggers(regclass);
831
792
DROP FUNCTION @extschema@.drop_triggers(regclass);
832
793
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