@@ -423,6 +423,10 @@ BEGIN
423423 v_attname := attnameFROM @extschema@.pathman_config
424424WHERE relname::regclass= p_parent;
425425
426+ IF v_attname ISNULL THEN
427+ RAISE EXCEPTION' Table % is not partitioned' , quote_ident(p_parent::TEXT );
428+ END IF;
429+
426430SELECT * INTO v_plain_schema, v_plain_relname
427431FROM @extschema@.get_plain_schema_and_relname(p_parent);
428432
@@ -494,9 +498,15 @@ BEGIN
494498FROM pg_inherits
495499WHERE inhrelid= v_child_relid;
496500
497- SELECT attname, parttype INTO v_attname, v_part_type
501+ SELECT attname, parttype
498502FROM @extschema@.pathman_config
499- WHERE relname::regclass= v_parent_relid::regclass;
503+ WHERE relname::regclass= v_parent_relid::regclass
504+ INTO v_attname, v_part_type;
505+
506+ IF v_attname ISNULL THEN
507+ RAISE EXCEPTION' Table % is not partitioned' ,
508+ quote_ident(v_parent_relid::regclass::text );
509+ END IF;
500510
501511SELECT * INTO v_plain_schema, v_plain_relname
502512FROM @extschema@.get_plain_schema_and_relname(p_partition);
@@ -591,9 +601,15 @@ BEGIN
591601RAISE EXCEPTION' Cannot merge partitions having different parents' ;
592602END IF;
593603
594- SELECT attname, parttype INTO v_attname, v_part_type
604+ SELECT attname, parttype
595605FROM @extschema@.pathman_config
596- WHERE relname::regclass= v_parent_relid1::regclass;
606+ WHERE relname::regclass= v_parent_relid1::regclass
607+ INTO v_attname, v_part_type;
608+
609+ IF v_attname ISNULL THEN
610+ RAISE EXCEPTION' Table % is not partitioned' ,
611+ quote_ident(v_parent_relid1::regclass::text );
612+ END IF;
597613
598614/* Check if this is RANGE partition*/
599615IF v_part_type!= 2 THEN
@@ -637,8 +653,14 @@ DECLARE
637653v_child_relnameTEXT ;
638654v_check_nameTEXT ;
639655BEGIN
640- SELECT attname INTO v_attnameFROM @extschema@.pathman_config
641- WHERE relname::regclass= p_parent_relid::regclass;
656+ SELECT attnameFROM @extschema@.pathman_config
657+ WHERE relname::regclass= p_parent_relid::regclass
658+ INTO v_attname;
659+
660+ IF v_attname ISNULL THEN
661+ RAISE EXCEPTION' Table % is not partitioned' ,
662+ quote_ident(p_parent_relid::regclass::text );
663+ END IF;
642664
643665SELECT * INTO v_plain_schema, v_plain_relname
644666FROM @extschema@.get_plain_schema_and_relname(p_part1);
@@ -694,16 +716,22 @@ CREATE OR REPLACE FUNCTION @extschema@.append_range_partition(
694716RETURNSTEXT AS
695717$$
696718DECLARE
697- v_attnameTEXT ;
698- v_atttypeTEXT ;
699- v_part_nameTEXT ;
700- v_intervalTEXT ;
719+ v_attnameTEXT ;
720+ v_atttypeTEXT ;
721+ v_part_nameTEXT ;
722+ v_intervalTEXT ;
701723BEGIN
702724/* Prevent concurrent partition creation*/
703725PERFORM @extschema@.acquire_partitions_lock();
704726
705- SELECT attname, range_interval INTO v_attname, v_interval
706- FROM @extschema@.pathman_configWHERE relname::regclass= p_relation;
727+ SELECT attname, range_interval
728+ FROM @extschema@.pathman_config
729+ WHERE relname::regclass= p_relation
730+ INTO v_attname, v_interval;
731+
732+ IF v_attname ISNULL THEN
733+ RAISE EXCEPTION' Table % is not partitioned' , quote_ident(p_relation::TEXT );
734+ END IF;
707735
708736v_atttype := @extschema@.get_attribute_type_name(p_relation, v_attname);
709737
@@ -770,8 +798,15 @@ BEGIN
770798/* Prevent concurrent partition creation*/
771799PERFORM @extschema@.acquire_partitions_lock();
772800
773- SELECT attname, range_interval INTO v_attname, v_interval
774- FROM @extschema@.pathman_configWHERE relname::regclass= p_relation;
801+ SELECT attname, range_interval
802+ FROM @extschema@.pathman_config
803+ WHERE relname::regclass= p_relation
804+ INTO v_attname, v_interval;
805+
806+ IF v_attname ISNULL THEN
807+ RAISE EXCEPTION' Table % is not partitioned' , quote_ident(p_relation::TEXT );
808+ END IF;
809+
775810v_atttype := @extschema@.get_attribute_type_name(p_relation, v_attname);
776811
777812EXECUTE format(' SELECT @extschema@.prepend_partition_internal($1, $2, $3, ARRAY[]::%s[])' , v_atttype)
@@ -946,7 +981,14 @@ BEGIN
946981 , p_relation);
947982
948983/* Set check constraint*/
949- v_attname := attnameFROM @extschema@.pathman_configWHERE relname::regclass= p_relation;
984+ v_attname := attname
985+ FROM @extschema@.pathman_config
986+ WHERE relname::regclass= p_relation;
987+
988+ IF v_attname ISNULL THEN
989+ RAISE EXCEPTION' Table % is not partitioned' , quote_ident(p_relation::TEXT );
990+ END IF;
991+
950992v_cond := @extschema@.get_range_condition(v_attname, p_start_value, p_end_value);
951993
952994/* Plain partition name and schema*/
@@ -1072,7 +1114,7 @@ $$ LANGUAGE plpgsql;
10721114 * Creates an update trigger
10731115*/
10741116CREATEOR REPLACE FUNCTION @extschema@.create_range_update_trigger(
1075- IN relationTEXT )
1117+ IN relationREGCLASS )
10761118RETURNSTEXT AS
10771119$$
10781120DECLARE
@@ -1107,8 +1149,7 @@ DECLARE
11071149numINTEGER := 0 ;
11081150attrTEXT ;
11091151BEGIN
1110- relation := @extschema@.validate_relname(relation);
1111- relid := relation::regclass::oid ;
1152+ relid := relation::oid ;
11121153SELECT string_agg(attname,' ,' ),
11131154 string_agg(' OLD.' || attname,' ,' ),
11141155 string_agg(' NEW.' || attname,' ,' ),
@@ -1123,7 +1164,14 @@ BEGIN
11231164 att_val_fmt,
11241165 att_fmt;
11251166
1126- attr := attnameFROM @extschema@.pathman_configWHERE relname= relation;
1167+ attr := attname
1168+ FROM @extschema@.pathman_config
1169+ WHERE relname::regclass= relation;
1170+
1171+ IF attr ISNULL THEN
1172+ RAISE EXCEPTION' Table % is not partitioned' , quote_ident(relation::TEXT );
1173+ END IF;
1174+
11271175EXECUTE format(func, relation, attr,0 , att_val_fmt,
11281176 old_fields, att_fmt, new_fields);
11291177FOR recin (SELECT * FROM pg_inheritsWHERE inhparent= relation::regclass::oid )
@@ -1215,7 +1263,6 @@ CREATE OR REPLACE FUNCTION @extschema@.append_partitions_on_demand_internal(
12151263RETURNSOID AS
12161264$$
12171265DECLARE
1218- v_relationTEXT ;
12191266v_cntINTEGER := 0 ;
12201267iINTEGER := 0 ;
12211268v_partTEXT ;
@@ -1227,11 +1274,16 @@ DECLARE
12271274v_next_value p_new_value%TYPE;
12281275v_is_dateBOOLEAN ;
12291276BEGIN
1230- v_relation := @extschema@.validate_relname(p_relid::regclass::text );
1231-
12321277/* get attribute name and interval*/
1233- SELECT attname, range_interval INTO v_attname, v_interval
1234- FROM @extschema@.pathman_configWHERE relname= v_relation;
1278+ SELECT attname, range_interval
1279+ FROM @extschema@.pathman_config
1280+ WHERE relname::regclass= p_relid::regclass
1281+ INTO v_attname, v_interval;
1282+
1283+ IF v_attname ISNULL THEN
1284+ RAISE EXCEPTION' Table % is not partitioned' ,
1285+ quote_ident(p_relid::regclass::text );
1286+ END IF;
12351287
12361288v_min := @extschema@.get_min_range_value(p_relid::regclass::oid , p_new_value);
12371289v_max := @extschema@.get_max_range_value(p_relid::regclass::oid , p_new_value);