1818 * range_interval - base interval for RANGE partitioning as string
1919 */
2020CREATE TABLE IF NOT EXISTS @extschema@.pathman_config (
21- id SERIAL PRIMARY KEY ,
22- partrel REGCLASS NOT NULL ,
21+ partrel REGCLASS NOT NULL PRIMARY KEY ,
2322 attname TEXT NOT NULL ,
2423 parttype INTEGER NOT NULL ,
2524 range_interval TEXT ,
309308DECLARE
310309 v_rec RECORD;
311310 is_referenced BOOLEAN ;
311+ rel_persistence CHAR ;
312312
313313BEGIN
314+ /* Ignore temporary tables */
315+ SELECT relpersistence FROM pg_catalog .pg_class
316+ WHERE oid = p_relation INTO rel_persistence;
317+
318+ IF rel_persistence = ' t' ::CHAR THEN
319+ RAISE EXCEPTION ' Temporary table "%" cannot be partitioned' ,
320+ quote_ident(p_relation::TEXT );
321+ END IF;
322+
314323 IF EXISTS (SELECT * FROM @extschema@.pathman_config
315324 WHERE partrel = p_relation) THEN
316325 RAISE EXCEPTION ' Relation "%" has already been partitioned' , p_relation;
@@ -320,7 +329,7 @@ BEGIN
320329 RAISE EXCEPTION ' Partitioning key ' ' %' ' must be NOT NULL' , p_attribute;
321330 END IF;
322331
323- /* Check if there are foreign keys reference to the relation */
332+ /* Check if there are foreign keys that reference the relation */
324333 FOR v_rec IN (SELECT *
325334 FROM pg_constraint WHERE confrelid = p_relation::regclass::oid )
326335 LOOP
@@ -469,12 +478,9 @@ CREATE OR REPLACE FUNCTION @extschema@.drop_triggers(
469478 parent_relid REGCLASS)
470479RETURNS VOID AS
471480$$
472- DECLARE
473- funcname TEXT ;
474-
475481BEGIN
476- funcname : = @extschema@.build_update_trigger_func_name(parent_relid);
477- EXECUTE format( ' DROP FUNCTION IF EXISTS %s() CASCADE ' , funcname );
482+ EXECUTE format( ' DROP FUNCTION IF EXISTS %s() CASCADE ' ,
483+ @extschema@.build_update_trigger_func_name(parent_relid) );
478484END
479485$$ LANGUAGE plpgsql;
480486
@@ -545,12 +551,14 @@ EXECUTE PROCEDURE @extschema@.pathman_ddl_trigger_func();
545551
546552
547553/*
548- * Check if regclass is date or timestamp
554+ * Attach partitioned table
549555 */
550- CREATE OR REPLACE FUNCTION @extschema@.is_date_type(
551- typid REGTYPE)
552- RETURNS BOOLEAN AS ' pg_pathman' , ' is_date_type'
553- LANGUAGE C STRICT;
556+ CREATE OR REPLACE FUNCTION @extschema@.add_to_pathman_config(
557+ parent_relid REGCLASS,
558+ attname TEXT ,
559+ range_interval TEXT DEFAULT NULL )
560+ RETURNS BOOLEAN AS ' pg_pathman' , ' add_to_pathman_config'
561+ LANGUAGE C;
554562
555563
556564CREATE OR REPLACE FUNCTION @extschema@.on_create_partitions(
@@ -569,6 +577,21 @@ RETURNS VOID AS 'pg_pathman', 'on_partitions_removed'
569577LANGUAGE C STRICT;
570578
571579
580+ /*
581+ * Get parent of pg_pathman's partition.
582+ */
583+ CREATE OR REPLACE FUNCTION @extschema@.get_parent_of_partition(REGCLASS)
584+ RETURNS REGCLASS AS ' pg_pathman' , ' get_parent_of_partition_pl'
585+ LANGUAGE C STRICT;
586+
587+ /*
588+ * Check if regclass is date or timestamp
589+ */
590+ CREATE OR REPLACE FUNCTION @extschema@.is_date_type(
591+ typid REGTYPE)
592+ RETURNS BOOLEAN AS ' pg_pathman' , ' is_date_type'
593+ LANGUAGE C STRICT;
594+
572595/*
573596 * Checks if attribute is nullable
574597 */
@@ -617,10 +640,3 @@ LANGUAGE C STRICT;
617640CREATE OR REPLACE FUNCTION @extschema@.debug_capture()
618641RETURNS VOID AS ' pg_pathman' , ' debug_capture'
619642LANGUAGE C STRICT;
620-
621- /*
622- * Get parent of pg_pathman's partition.
623- */
624- CREATE OR REPLACE FUNCTION @extschema@.get_parent_of_partition(REGCLASS)
625- RETURNS REGCLASS AS ' pg_pathman' , ' get_parent_of_partition_pl'
626- LANGUAGE C STRICT;
0 commit comments