@@ -138,7 +138,7 @@ BEGIN
138
138
p_attribute,
139
139
p_start_value,
140
140
p_start_value + p_interval * p_count,
141
- pg_typeof(p_start_value));
141
+ @extschema@.get_base_type( pg_typeof(p_start_value)):: TEXT );
142
142
END IF;
143
143
144
144
/* Create sequence for child partitions names */
@@ -153,7 +153,7 @@ BEGIN
153
153
FOR i IN 1 ..p_count
154
154
LOOP
155
155
EXECUTE format(' SELECT @extschema@.create_single_range_partition($1, $2, $3::%s)' ,
156
- pg_typeof(p_start_value))
156
+ @extschema@.get_base_type( pg_typeof(p_start_value)):: TEXT )
157
157
USING parent_relid, p_start_value, p_start_value + p_interval;
158
158
159
159
p_start_value := p_start_value + p_interval;
@@ -283,7 +283,7 @@ CREATE OR REPLACE FUNCTION @extschema@.create_partitions_from_range(
283
283
p_start_value ANYELEMENT,
284
284
p_end_value ANYELEMENT,
285
285
p_interval ANYELEMENT,
286
- partition_data BOOLEAN DEFAULT true)
286
+ partition_data BOOLEAN DEFAULT true)
287
287
RETURNS INTEGER AS
288
288
$$
289
289
DECLARE
@@ -353,7 +353,7 @@ CREATE OR REPLACE FUNCTION @extschema@.create_partitions_from_range(
353
353
p_start_value ANYELEMENT,
354
354
p_end_value ANYELEMENT,
355
355
p_interval INTERVAL,
356
- partition_data BOOLEAN DEFAULT true)
356
+ partition_data BOOLEAN DEFAULT true)
357
357
RETURNS INTEGER AS
358
358
$$
359
359
DECLARE
@@ -389,7 +389,7 @@ BEGIN
389
389
WHILE p_start_value <= p_end_value
390
390
LOOP
391
391
EXECUTE format(' SELECT @extschema@.create_single_range_partition($1, $2, $3::%s);' ,
392
- pg_typeof(p_start_value))
392
+ @extschema@.get_base_type( pg_typeof(p_start_value)):: TEXT )
393
393
USING parent_relid, p_start_value, p_start_value + p_interval;
394
394
395
395
p_start_value := p_start_value + p_interval;
@@ -588,7 +588,7 @@ DECLARE
588
588
v_parent_relid2 REGCLASS;
589
589
v_attname TEXT ;
590
590
v_part_type INTEGER ;
591
- v_atttype TEXT ;
591
+ v_atttype REGTYPE ;
592
592
593
593
BEGIN
594
594
IF partition1 = partition2 THEN
@@ -623,10 +623,10 @@ BEGIN
623
623
RAISE EXCEPTION ' Specified partitions aren' ' t RANGE partitions' ;
624
624
END IF;
625
625
626
- v_atttype := @extschema@.get_attribute_type_name (partition1, v_attname);
626
+ v_atttype := @extschema@.get_attribute_type (partition1, v_attname);
627
627
628
628
EXECUTE format(' SELECT @extschema@.merge_range_partitions_internal($1, $2, $3, NULL::%s)' ,
629
- v_atttype)
629
+ @extschema@.get_base_type( v_atttype):: TEXT )
630
630
USING v_parent_relid1, partition1, partition2;
631
631
632
632
/* Tell backend to reload configuration */
@@ -713,7 +713,7 @@ RETURNS TEXT AS
713
713
$$
714
714
DECLARE
715
715
v_attname TEXT ;
716
- v_atttype TEXT ;
716
+ v_atttype REGTYPE ;
717
717
v_part_name TEXT ;
718
718
v_interval TEXT ;
719
719
@@ -730,12 +730,11 @@ BEGIN
730
730
RAISE EXCEPTION ' Table "%" is not partitioned' , parent_relid::TEXT ;
731
731
END IF;
732
732
733
- v_atttype := @extschema@.get_attribute_type_name (parent_relid, v_attname);
733
+ v_atttype := @extschema@.get_attribute_type (parent_relid, v_attname);
734
734
735
735
EXECUTE
736
- format(
737
- ' SELECT @extschema@.append_partition_internal($1, $2, $3, ARRAY[]::%s[], $4)' ,
738
- v_atttype)
736
+ format(' SELECT @extschema@.append_partition_internal($1, $2, $3, ARRAY[]::%s[], $4)' ,
737
+ @extschema@.get_base_type(v_atttype)::TEXT )
739
738
USING
740
739
parent_relid,
741
740
v_atttype,
@@ -759,7 +758,7 @@ LANGUAGE plpgsql;
759
758
*/
760
759
CREATE OR REPLACE FUNCTION @extschema@.append_partition_internal(
761
760
parent_relid REGCLASS,
762
- p_atttype TEXT ,
761
+ p_atttype REGTYPE ,
763
762
p_interval TEXT ,
764
763
p_range ANYARRAY DEFAULT NULL ,
765
764
partition_name TEXT DEFAULT NULL )
@@ -775,17 +774,16 @@ BEGIN
775
774
776
775
p_range := @extschema@.get_range_by_idx(parent_relid, - 1 , 0 );
777
776
778
- IF @extschema@.is_date_type(p_atttype::regtype ) THEN
777
+ IF @extschema@.is_date_type(p_atttype) THEN
779
778
v_part_name := @extschema@.create_single_range_partition(
780
779
parent_relid,
781
780
p_range[2 ],
782
781
p_range[2 ] + p_interval::interval,
783
782
partition_name);
784
783
ELSE
785
784
EXECUTE
786
- format(
787
- ' SELECT @extschema@.create_single_range_partition($1, $2, $2 + $3::%s, $4)' ,
788
- p_atttype)
785
+ format(' SELECT @extschema@.create_single_range_partition($1, $2, $2 + $3::%s, $4)' ,
786
+ @extschema@.get_base_type(p_atttype)::TEXT )
789
787
USING
790
788
parent_relid,
791
789
p_range[2 ],
@@ -811,7 +809,7 @@ RETURNS TEXT AS
811
809
$$
812
810
DECLARE
813
811
v_attname TEXT ;
814
- v_atttype TEXT ;
812
+ v_atttype REGTYPE ;
815
813
v_part_name TEXT ;
816
814
v_interval TEXT ;
817
815
@@ -825,12 +823,11 @@ BEGIN
825
823
RAISE EXCEPTION ' Table "%" is not partitioned' , parent_relid::TEXT ;
826
824
END IF;
827
825
828
- v_atttype := @extschema@.get_attribute_type_name (parent_relid, v_attname);
826
+ v_atttype := @extschema@.get_attribute_type (parent_relid, v_attname);
829
827
830
828
EXECUTE
831
- format(
832
- ' SELECT @extschema@.prepend_partition_internal($1, $2, $3, ARRAY[]::%s[], $4)' ,
833
- v_atttype)
829
+ format(' SELECT @extschema@.prepend_partition_internal($1, $2, $3, ARRAY[]::%s[], $4)' ,
830
+ @extschema@.get_base_type(v_atttype)::TEXT )
834
831
USING
835
832
parent_relid,
836
833
v_atttype,
@@ -854,7 +851,7 @@ LANGUAGE plpgsql;
854
851
*/
855
852
CREATE OR REPLACE FUNCTION @extschema@.prepend_partition_internal(
856
853
parent_relid REGCLASS,
857
- p_atttype TEXT ,
854
+ p_atttype REGTYPE ,
858
855
p_interval TEXT ,
859
856
p_range ANYARRAY DEFAULT NULL ,
860
857
partition_name TEXT DEFAULT NULL )
@@ -870,17 +867,16 @@ BEGIN
870
867
871
868
p_range := @extschema@.get_range_by_idx(parent_relid, 0 , 0 );
872
869
873
- IF @extschema@.is_date_type(p_atttype::regtype ) THEN
870
+ IF @extschema@.is_date_type(p_atttype) THEN
874
871
v_part_name := @extschema@.create_single_range_partition(
875
872
parent_relid,
876
873
p_range[1 ] - p_interval::interval,
877
874
p_range[1 ],
878
875
partition_name);
879
876
ELSE
880
877
EXECUTE
881
- format(
882
- ' SELECT @extschema@.create_single_range_partition($1, $2 - $3::%s, $2, $4)' ,
883
- p_atttype)
878
+ format(' SELECT @extschema@.create_single_range_partition($1, $2 - $3::%s, $2, $4)' ,
879
+ @extschema@.get_base_type(p_atttype)::TEXT )
884
880
USING
885
881
parent_relid,
886
882
p_range[1 ],
0 commit comments