@@ -104,15 +104,6 @@ SELECT pg_catalog.pg_extension_config_dump('@extschema@.pathman_config', '');
104
104
SELECT pg_catalog .pg_extension_config_dump (' @extschema@.pathman_config_params' ,' ' );
105
105
106
106
107
- CREATEOR REPLACE FUNCTION @extschema@.partitions_count(relation REGCLASS)
108
- RETURNSINT AS
109
- $$
110
- BEGIN
111
- RETURNcount (* )FROM pg_inheritsWHERE inhparent= relation;
112
- END
113
- $$
114
- LANGUAGE plpgsql STRICT;
115
-
116
107
/*
117
108
* Add a row describing the optional parameter to pathman_config_params.
118
109
*/
@@ -185,7 +176,8 @@ RETURNS TABLE (
185
176
partattrTEXT ,
186
177
range_minTEXT ,
187
178
range_maxTEXT )
188
- AS ' pg_pathman' ,' show_partition_list_internal' LANGUAGE C STRICT;
179
+ AS ' pg_pathman' ,' show_partition_list_internal'
180
+ LANGUAGE C STRICT;
189
181
190
182
/*
191
183
* View for show_partition_list().
@@ -206,7 +198,8 @@ RETURNS TABLE (
206
198
relidREGCLASS,
207
199
processedINT ,
208
200
statusTEXT )
209
- AS ' pg_pathman' ,' show_concurrent_part_tasks_internal' LANGUAGE C STRICT;
201
+ AS ' pg_pathman' ,' show_concurrent_part_tasks_internal'
202
+ LANGUAGE C STRICT;
210
203
211
204
/*
212
205
* View for show_concurrent_part_tasks().
353
346
$$
354
347
LANGUAGE plpgsql STRICT;
355
348
356
- /*
357
- * Validates relation name. It must be schema qualified.
358
- */
359
- CREATEOR REPLACE FUNCTION @extschema@.validate_relname(
360
- clsREGCLASS)
361
- RETURNSTEXT AS
362
- $$
363
- DECLARE
364
- relnameTEXT ;
365
-
366
- BEGIN
367
- relname= @extschema@.get_schema_qualified_name(cls);
368
-
369
- IF relname ISNULL THEN
370
- RAISE EXCEPTION' relation %s does not exist' , cls;
371
- END IF;
372
-
373
- RETURN relname;
374
- END
375
- $$
376
- LANGUAGE plpgsql;
377
-
378
349
/*
379
350
* Aggregates several common relation checks before partitioning.
380
351
* Suitable for every partitioning type.
444
415
$$
445
416
LANGUAGE plpgsql STRICT;
446
417
447
- /*
448
- * Returns the schema-qualified name of table.
449
- */
450
- CREATEOR REPLACE FUNCTION @extschema@.get_schema_qualified_name(
451
- clsREGCLASS,
452
- delimiterTEXT DEFAULT' .' ,
453
- suffixTEXT DEFAULT' ' )
454
- RETURNSTEXT AS
455
- $$
456
- BEGIN
457
- RETURN (SELECT quote_ident(relnamespace::regnamespace::text )||
458
- delimiter||
459
- quote_ident(relname|| suffix)
460
- FROM pg_catalog .pg_class
461
- WHERE oid = cls::oid );
462
- END
463
- $$
464
- LANGUAGE plpgsql STRICT;
465
-
466
418
/*
467
419
* Check if two relations have equal structures.
468
420
*/
@@ -662,41 +614,62 @@ RETURNS VOID AS 'pg_pathman', 'on_partitions_removed'
662
614
LANGUAGE C STRICT;
663
615
664
616
617
+ /*
618
+ * Get number of partitions managed by pg_pathman.
619
+ */
620
+ CREATEOR REPLACE FUNCTION @extschema@.get_number_of_partitions(
621
+ parent_relidREGCLASS)
622
+ RETURNS INT4AS ' pg_pathman' ,' get_number_of_partitions_pl'
623
+ LANGUAGE C STRICT;
624
+
665
625
/*
666
626
* Get parent of pg_pathman's partition.
667
627
*/
668
- CREATEOR REPLACE FUNCTION @extschema@.get_parent_of_partition(REGCLASS)
628
+ CREATEOR REPLACE FUNCTION @extschema@.get_parent_of_partition(
629
+ partition_relidREGCLASS)
669
630
RETURNS REGCLASSAS ' pg_pathman' ,' get_parent_of_partition_pl'
670
631
LANGUAGE C STRICT;
671
632
672
633
/*
673
634
* Extract basic type of a domain.
674
635
*/
675
- CREATEOR REPLACE FUNCTION @extschema@.get_base_type(REGTYPE)
636
+ CREATEOR REPLACE FUNCTION @extschema@.get_base_type(
637
+ typidREGTYPE)
676
638
RETURNS REGTYPEAS ' pg_pathman' ,' get_base_type_pl'
677
639
LANGUAGE C STRICT;
678
640
679
641
/*
680
642
* Returns attribute type name for relation.
681
643
*/
682
644
CREATEOR REPLACE FUNCTION @extschema@.get_attribute_type(
683
- REGCLASS,TEXT )
645
+ relidREGCLASS,
646
+ attnameTEXT )
684
647
RETURNS REGTYPEAS ' pg_pathman' ,' get_attribute_type_pl'
685
648
LANGUAGE C STRICT;
686
649
687
650
/*
688
651
* Return tablespace name for specified relation.
689
652
*/
690
- CREATEOR REPLACE FUNCTION @extschema@.get_rel_tablespace_name(REGCLASS)
691
- RETURNSTEXT AS ' pg_pathman' ,' get_rel_tablespace_name'
653
+ CREATEOR REPLACE FUNCTION @extschema@.get_tablespace(
654
+ relidREGCLASS)
655
+ RETURNSTEXT AS ' pg_pathman' ,' get_tablespace_pl'
692
656
LANGUAGE C STRICT;
693
657
694
658
659
+ /*
660
+ * Check that relation exists.
661
+ */
662
+ CREATEOR REPLACE FUNCTION @extschema@.validate_relname(
663
+ relidREGCLASS)
664
+ RETURNS VOIDAS ' pg_pathman' ,' validate_relname'
665
+ LANGUAGE C;
666
+
695
667
/*
696
668
* Checks if attribute is nullable
697
669
*/
698
670
CREATEOR REPLACE FUNCTION @extschema@.is_attribute_nullable(
699
- REGCLASS,TEXT )
671
+ relidREGCLASS,
672
+ attnameTEXT )
700
673
RETURNSBOOLEAN AS ' pg_pathman' ,' is_attribute_nullable'
701
674
LANGUAGE C STRICT;
702
675
@@ -713,25 +686,27 @@ LANGUAGE C STRICT;
713
686
* Build check constraint name for a specified relation's column.
714
687
*/
715
688
CREATEOR REPLACE FUNCTION @extschema@.build_check_constraint_name(
716
- REGCLASS, INT2)
689
+ partition_relidREGCLASS,
690
+ partitioned_colINT2)
717
691
RETURNSTEXT AS ' pg_pathman' ,' build_check_constraint_name_attnum'
718
692
LANGUAGE C STRICT;
719
693
720
694
CREATEOR REPLACE FUNCTION @extschema@.build_check_constraint_name(
721
- REGCLASS,TEXT )
695
+ partition_relidREGCLASS,
696
+ partitioned_colTEXT )
722
697
RETURNSTEXT AS ' pg_pathman' ,' build_check_constraint_name_attname'
723
698
LANGUAGE C STRICT;
724
699
725
700
/*
726
701
* Build update trigger and its underlying function's names.
727
702
*/
728
703
CREATEOR REPLACE FUNCTION @extschema@.build_update_trigger_name(
729
- REGCLASS)
704
+ relid REGCLASS)
730
705
RETURNSTEXT AS ' pg_pathman' ,' build_update_trigger_name'
731
706
LANGUAGE C STRICT;
732
707
733
708
CREATEOR REPLACE FUNCTION @extschema@.build_update_trigger_func_name(
734
- REGCLASS)
709
+ relid REGCLASS)
735
710
RETURNSTEXT AS ' pg_pathman' ,' build_update_trigger_func_name'
736
711
LANGUAGE C STRICT;
737
712
@@ -746,7 +721,8 @@ CREATE OR REPLACE FUNCTION @extschema@.add_to_pathman_config(
746
721
RETURNSBOOLEAN AS ' pg_pathman' ,' add_to_pathman_config'
747
722
LANGUAGE C;
748
723
749
- CREATEOR REPLACE FUNCTION @extschema@.invalidate_relcache(relidOID )
724
+ CREATEOR REPLACE FUNCTION @extschema@.invalidate_relcache(
725
+ OID )
750
726
RETURNS VOIDAS ' pg_pathman'
751
727
LANGUAGE C STRICT;
752
728
@@ -755,18 +731,18 @@ LANGUAGE C STRICT;
755
731
* Lock partitioned relation to restrict concurrent
756
732
* modification of partitioning scheme.
757
733
*/
758
- CREATEOR REPLACE FUNCTION @extschema@.lock_partitioned_relation(
759
- REGCLASS)
760
- RETURNS VOIDAS ' pg_pathman' ,' lock_partitioned_relation'
761
- LANGUAGE C STRICT;
734
+ CREATEOR REPLACE FUNCTION @extschema@.lock_partitioned_relation(
735
+ parent_relid REGCLASS)
736
+ RETURNS VOIDAS ' pg_pathman' ,' lock_partitioned_relation'
737
+ LANGUAGE C STRICT;
762
738
763
739
/*
764
740
* Lock relation to restrict concurrent modification of data.
765
741
*/
766
- CREATEOR REPLACE FUNCTION @extschema@.prevent_relation_modification(
767
- REGCLASS)
768
- RETURNS VOIDAS ' pg_pathman' ,' prevent_relation_modification'
769
- LANGUAGE C STRICT;
742
+ CREATEOR REPLACE FUNCTION @extschema@.prevent_relation_modification(
743
+ parent_relid REGCLASS)
744
+ RETURNS VOIDAS ' pg_pathman' ,' prevent_relation_modification'
745
+ LANGUAGE C STRICT;
770
746
771
747
772
748
/*