@@ -104,15 +104,6 @@ SELECT pg_catalog.pg_extension_config_dump('@extschema@.pathman_config', '');
104104SELECT pg_catalog .pg_extension_config_dump (' @extschema@.pathman_config_params' , ' ' );
105105
106106
107- CREATE OR REPLACE FUNCTION @extschema@.partitions_count(relation REGCLASS)
108- RETURNS INT AS
109- $$
110- BEGIN
111- RETURN count (* ) FROM pg_inherits WHERE inhparent = relation;
112- END
113- $$
114- LANGUAGE plpgsql STRICT;
115-
116107/*
117108 * Add a row describing the optional parameter to pathman_config_params.
118109 */
@@ -185,7 +176,8 @@ RETURNS TABLE (
185176 partattr TEXT ,
186177 range_min TEXT ,
187178 range_max TEXT )
188- AS ' pg_pathman' , ' show_partition_list_internal' LANGUAGE C STRICT;
179+ AS ' pg_pathman' , ' show_partition_list_internal'
180+ LANGUAGE C STRICT;
189181
190182/*
191183 * View for show_partition_list().
@@ -206,7 +198,8 @@ RETURNS TABLE (
206198 relid REGCLASS,
207199 processed INT ,
208200 status TEXT )
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;
210203
211204/*
212205 * View for show_concurrent_part_tasks().
353346$$
354347LANGUAGE plpgsql STRICT;
355348
356- /*
357- * Validates relation name. It must be schema qualified.
358- */
359- CREATE OR REPLACE FUNCTION @extschema@.validate_relname(
360- cls REGCLASS)
361- RETURNS TEXT AS
362- $$
363- DECLARE
364- relname TEXT ;
365-
366- BEGIN
367- relname = @extschema@.get_schema_qualified_name(cls);
368-
369- IF relname IS NULL THEN
370- RAISE EXCEPTION ' relation %s does not exist' , cls;
371- END IF;
372-
373- RETURN relname;
374- END
375- $$
376- LANGUAGE plpgsql;
377-
378349/*
379350 * Aggregates several common relation checks before partitioning.
380351 * Suitable for every partitioning type.
444415$$
445416LANGUAGE plpgsql STRICT;
446417
447- /*
448- * Returns the schema-qualified name of table.
449- */
450- CREATE OR REPLACE FUNCTION @extschema@.get_schema_qualified_name(
451- cls REGCLASS,
452- delimiter TEXT DEFAULT ' .' ,
453- suffix TEXT DEFAULT ' ' )
454- RETURNS TEXT 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-
466418/*
467419 * Check if two relations have equal structures.
468420 */
@@ -662,41 +614,62 @@ RETURNS VOID AS 'pg_pathman', 'on_partitions_removed'
662614LANGUAGE C STRICT;
663615
664616
617+ /*
618+ * Get number of partitions managed by pg_pathman.
619+ */
620+ CREATE OR REPLACE FUNCTION @extschema@.get_number_of_partitions(
621+ parent_relid REGCLASS)
622+ RETURNS INT4 AS ' pg_pathman' , ' get_number_of_partitions_pl'
623+ LANGUAGE C STRICT;
624+
665625/*
666626 * Get parent of pg_pathman's partition.
667627 */
668- CREATE OR REPLACE FUNCTION @extschema@.get_parent_of_partition(REGCLASS)
628+ CREATE OR REPLACE FUNCTION @extschema@.get_parent_of_partition(
629+ partition_relid REGCLASS)
669630RETURNS REGCLASS AS ' pg_pathman' , ' get_parent_of_partition_pl'
670631LANGUAGE C STRICT;
671632
672633/*
673634 * Extract basic type of a domain.
674635 */
675- CREATE OR REPLACE FUNCTION @extschema@.get_base_type(REGTYPE)
636+ CREATE OR REPLACE FUNCTION @extschema@.get_base_type(
637+ typid REGTYPE)
676638RETURNS REGTYPE AS ' pg_pathman' , ' get_base_type_pl'
677639LANGUAGE C STRICT;
678640
679641/*
680642 * Returns attribute type name for relation.
681643 */
682644CREATE OR REPLACE FUNCTION @extschema@.get_attribute_type(
683- REGCLASS, TEXT )
645+ relid REGCLASS,
646+ attname TEXT )
684647RETURNS REGTYPE AS ' pg_pathman' , ' get_attribute_type_pl'
685648LANGUAGE C STRICT;
686649
687650/*
688651 * Return tablespace name for specified relation.
689652 */
690- CREATE OR REPLACE FUNCTION @extschema@.get_rel_tablespace_name(REGCLASS)
691- RETURNS TEXT AS ' pg_pathman' , ' get_rel_tablespace_name'
653+ CREATE OR REPLACE FUNCTION @extschema@.get_tablespace(
654+ relid REGCLASS)
655+ RETURNS TEXT AS ' pg_pathman' , ' get_tablespace_pl'
692656LANGUAGE C STRICT;
693657
694658
659+ /*
660+ * Check that relation exists.
661+ */
662+ CREATE OR REPLACE FUNCTION @extschema@.validate_relname(
663+ relid REGCLASS)
664+ RETURNS VOID AS ' pg_pathman' , ' validate_relname'
665+ LANGUAGE C;
666+
695667/*
696668 * Checks if attribute is nullable
697669 */
698670CREATE OR REPLACE FUNCTION @extschema@.is_attribute_nullable(
699- REGCLASS, TEXT )
671+ relid REGCLASS,
672+ attname TEXT )
700673RETURNS BOOLEAN AS ' pg_pathman' , ' is_attribute_nullable'
701674LANGUAGE C STRICT;
702675
@@ -713,25 +686,27 @@ LANGUAGE C STRICT;
713686 * Build check constraint name for a specified relation's column.
714687 */
715688CREATE OR REPLACE FUNCTION @extschema@.build_check_constraint_name(
716- REGCLASS, INT2)
689+ partition_relid REGCLASS,
690+ partitioned_col INT2)
717691RETURNS TEXT AS ' pg_pathman' , ' build_check_constraint_name_attnum'
718692LANGUAGE C STRICT;
719693
720694CREATE OR REPLACE FUNCTION @extschema@.build_check_constraint_name(
721- REGCLASS, TEXT )
695+ partition_relid REGCLASS,
696+ partitioned_col TEXT )
722697RETURNS TEXT AS ' pg_pathman' , ' build_check_constraint_name_attname'
723698LANGUAGE C STRICT;
724699
725700/*
726701 * Build update trigger and its underlying function's names.
727702 */
728703CREATE OR REPLACE FUNCTION @extschema@.build_update_trigger_name(
729- REGCLASS)
704+ relid REGCLASS)
730705RETURNS TEXT AS ' pg_pathman' , ' build_update_trigger_name'
731706LANGUAGE C STRICT;
732707
733708CREATE OR REPLACE FUNCTION @extschema@.build_update_trigger_func_name(
734- REGCLASS)
709+ relid REGCLASS)
735710RETURNS TEXT AS ' pg_pathman' , ' build_update_trigger_func_name'
736711LANGUAGE C STRICT;
737712
@@ -746,7 +721,8 @@ CREATE OR REPLACE FUNCTION @extschema@.add_to_pathman_config(
746721RETURNS BOOLEAN AS ' pg_pathman' , ' add_to_pathman_config'
747722LANGUAGE C;
748723
749- CREATE OR REPLACE FUNCTION @extschema@.invalidate_relcache(relid OID )
724+ CREATE OR REPLACE FUNCTION @extschema@.invalidate_relcache(
725+ OID )
750726RETURNS VOID AS ' pg_pathman'
751727LANGUAGE C STRICT;
752728
@@ -755,18 +731,18 @@ LANGUAGE C STRICT;
755731 * Lock partitioned relation to restrict concurrent
756732 * modification of partitioning scheme.
757733 */
758- CREATE OR REPLACE FUNCTION @extschema@.lock_partitioned_relation(
759- REGCLASS)
760- RETURNS VOID AS ' pg_pathman' , ' lock_partitioned_relation'
761- LANGUAGE C STRICT;
734+ CREATE OR REPLACE FUNCTION @extschema@.lock_partitioned_relation(
735+ parent_relid REGCLASS)
736+ RETURNS VOID AS ' pg_pathman' , ' lock_partitioned_relation'
737+ LANGUAGE C STRICT;
762738
763739/*
764740 * Lock relation to restrict concurrent modification of data.
765741 */
766- CREATE OR REPLACE FUNCTION @extschema@.prevent_relation_modification(
767- REGCLASS)
768- RETURNS VOID AS ' pg_pathman' , ' prevent_relation_modification'
769- LANGUAGE C STRICT;
742+ CREATE OR REPLACE FUNCTION @extschema@.prevent_relation_modification(
743+ parent_relid REGCLASS)
744+ RETURNS VOID AS ' pg_pathman' , ' prevent_relation_modification'
745+ LANGUAGE C STRICT;
770746
771747
772748/*
0 commit comments