@@ -35,6 +35,7 @@ LANGUAGE C;
3535CREATE TABLE IF NOT EXISTS @extschema@.pathman_config (
3636 partrel REGCLASS NOT NULL PRIMARY KEY ,
3737 attname TEXT NOT NULL ,
38+ atttype OID NOT NULL ,
3839 parttype INTEGER NOT NULL ,
3940 range_interval TEXT ,
4041
@@ -427,7 +428,7 @@ LANGUAGE plpgsql STRICT;
427428 */
428429CREATE OR REPLACE FUNCTION @extschema@.common_relation_checks(
429430 relation REGCLASS,
430- p_attribute TEXT )
431+ expression TEXT )
431432RETURNS BOOLEAN AS
432433$$
433434DECLARE
@@ -450,8 +451,8 @@ BEGIN
450451 RAISE EXCEPTION ' relation "%" has already been partitioned' , relation;
451452 END IF;
452453
453- IF @extschema@.is_attribute_nullable (relation, p_attribute ) THEN
454- RAISE EXCEPTION ' partitioning key "%" must be NOT NULL ' , p_attribute ;
454+ IF NOT @extschema@.is_expression_suitable (relation, expression ) THEN
455+ RAISE EXCEPTION ' partitioning expression "%" is not suitable ' , expression ;
455456 END IF;
456457
457458 /* Check if there are foreign keys that reference the relation */
@@ -467,7 +468,7 @@ BEGIN
467468 RAISE EXCEPTION ' relation "%" is referenced from other relations' , relation;
468469 END IF;
469470
470- RETURN TRUE ;
471+ RETURN FALSE ;
471472END
472473$$
473474LANGUAGE plpgsql;
@@ -796,6 +797,15 @@ CREATE OR REPLACE FUNCTION @extschema@.is_attribute_nullable(
796797RETURNS BOOLEAN AS ' pg_pathman' , ' is_attribute_nullable'
797798LANGUAGE C STRICT;
798799
800+ /*
801+ * Checks if expression is suitable
802+ */
803+ CREATE OR REPLACE FUNCTION @extschema@.is_expression_suitable(
804+ relid REGCLASS,
805+ expr TEXT )
806+ RETURNS BOOLEAN AS ' pg_pathman' , ' is_expression_suitable'
807+ LANGUAGE C STRICT;
808+
799809/*
800810 * Check if regclass is date or timestamp.
801811 */
0 commit comments