@@ -89,6 +89,7 @@ RETURNS INTEGER AS
89
89
$$
90
90
DECLARE
91
91
v_rows_count INTEGER ;
92
+ v_atttype REGTYPE;
92
93
v_max p_start_value%TYPE;
93
94
v_cur_value p_start_value%TYPE := p_start_value;
94
95
p_end_value p_start_value%TYPE;
@@ -128,6 +129,8 @@ BEGIN
128
129
END LOOP;
129
130
END IF;
130
131
132
+ v_atttype := @extschema@.get_base_type(pg_typeof(p_start_value));
133
+
131
134
/*
132
135
* In case when user doesn't want to automatically create partitions
133
136
* and specifies partition count as 0 then do not check boundaries
@@ -146,7 +149,7 @@ BEGIN
146
149
p_attribute,
147
150
p_start_value,
148
151
p_end_value,
149
- @extschema@.get_base_type(pg_typeof(p_start_value)) ::TEXT );
152
+ v_atttype ::TEXT );
150
153
END IF;
151
154
152
155
/* Create sequence for child partitions names */
@@ -162,7 +165,7 @@ BEGIN
162
165
LOOP
163
166
EXECUTE
164
167
format(' SELECT @extschema@.create_single_range_partition($1, $2, $3::%s, tablespace:=$4)' ,
165
- @extschema@.get_base_type(pg_typeof(p_start_value)) ::TEXT )
168
+ v_atttype ::TEXT )
166
169
USING
167
170
parent_relid,
168
171
p_start_value,
@@ -831,15 +834,18 @@ RETURNS TEXT AS
831
834
$$
832
835
DECLARE
833
836
v_part_name TEXT ;
837
+ v_atttype REGTYPE;
834
838
835
839
BEGIN
836
840
IF @extschema@.partitions_count(parent_relid) = 0 THEN
837
841
RAISE EXCEPTION ' cannot append to empty partitions set' ;
838
842
END IF;
839
843
844
+ v_atttype := @extschema@.get_base_type(p_atttype);
845
+
840
846
/* We have to pass fake NULL casted to column's type */
841
847
EXECUTE format(' SELECT @extschema@.get_part_range($1, -1, NULL::%s)' ,
842
- @extschema@.get_base_type(p_atttype) ::TEXT )
848
+ v_atttype ::TEXT )
843
849
USING parent_relid
844
850
INTO p_range;
845
851
@@ -853,7 +859,7 @@ BEGIN
853
859
ELSE
854
860
EXECUTE
855
861
format(' SELECT @extschema@.create_single_range_partition($1, $2, $2 + $3::%s, $4, $5)' ,
856
- @extschema@.get_base_type(p_atttype) ::TEXT )
862
+ v_atttype ::TEXT )
857
863
USING
858
864
parent_relid,
859
865
p_range[2 ],
@@ -933,15 +939,18 @@ RETURNS TEXT AS
933
939
$$
934
940
DECLARE
935
941
v_part_name TEXT ;
942
+ v_atttype REGTYPE;
936
943
937
944
BEGIN
938
945
IF @extschema@.partitions_count(parent_relid) = 0 THEN
939
946
RAISE EXCEPTION ' cannot prepend to empty partitions set' ;
940
947
END IF;
941
948
949
+ v_atttype := @extschema@.get_base_type(p_atttype);
950
+
942
951
/* We have to pass fake NULL casted to column's type */
943
952
EXECUTE format(' SELECT @extschema@.get_part_range($1, 0, NULL::%s)' ,
944
- @extschema@.get_base_type(p_atttype) ::TEXT )
953
+ v_atttype ::TEXT )
945
954
USING parent_relid
946
955
INTO p_range;
947
956
@@ -955,7 +964,7 @@ BEGIN
955
964
ELSE
956
965
EXECUTE
957
966
format(' SELECT @extschema@.create_single_range_partition($1, $2 - $3::%s, $2, $4, $5)' ,
958
- @extschema@.get_base_type(p_atttype) ::TEXT )
967
+ v_atttype ::TEXT )
959
968
USING
960
969
parent_relid,
961
970
p_range[1 ],
@@ -1117,7 +1126,7 @@ DECLARE
1117
1126
parent_relid REGCLASS;
1118
1127
1119
1128
BEGIN
1120
- parent_relid = @extschema@.get_parent_of_partition(p_partition);
1129
+ parent_relid : = @extschema@.get_parent_of_partition(p_partition);
1121
1130
1122
1131
/* Acquire lock on parent */
1123
1132
PERFORM @extschema@.lock_partitioned_relation(parent_relid);
0 commit comments