Skip to content

Commit 2d0a3a6

Browse files
committed
fix append and prepend funcs for DATE partitioning key
1 parent 588b292 commit 2d0a3a6

File tree

1 file changed

+28
-34
lines changed

1 file changed

+28
-34
lines changed

range.sql

Lines changed: 28 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,7 @@ $$
750750
DECLARE
751751
v_part_name TEXT;
752752
v_atttype REGTYPE;
753+
v_args_format TEXT;
753754

754755
BEGIN
755756
IF @extschema@.get_number_of_partitions(parent_relid) = 0 THEN
@@ -769,26 +770,22 @@ BEGIN
769770
END IF;
770771

771772
IF @extschema@.is_date_type(p_atttype) THEN
772-
v_part_name := @extschema@.create_single_range_partition(
773-
parent_relid,
774-
p_range[2],
775-
p_range[2] + p_interval::interval,
776-
partition_name,
777-
tablespace);
773+
v_args_format := format('$1, $2, ($2 + $3::interval)::%s, $4, $5', v_atttype::TEXT);
778774
ELSE
779-
EXECUTE
780-
format('SELECT @extschema@.create_single_range_partition($1, $2, $2 + $3::%s, $4, $5)',
781-
v_atttype::TEXT)
782-
USING
783-
parent_relid,
784-
p_range[2],
785-
p_interval,
786-
partition_name,
787-
tablespace
788-
INTO
789-
v_part_name;
775+
v_args_format := format('$1, $2, $2 + $3::%s, $4, $5', v_atttype::TEXT);
790776
END IF;
791777

778+
EXECUTE
779+
format('SELECT @extschema@.create_single_range_partition(%s)', v_args_format)
780+
USING
781+
parent_relid,
782+
p_range[2],
783+
p_interval,
784+
partition_name,
785+
tablespace
786+
INTO
787+
v_part_name;
788+
792789
RETURN v_part_name;
793790
END
794791
$$
@@ -864,6 +861,7 @@ $$
864861
DECLARE
865862
v_part_name TEXT;
866863
v_atttype REGTYPE;
864+
v_args_format TEXT;
867865

868866
BEGIN
869867
IF @extschema@.get_number_of_partitions(parent_relid) = 0 THEN
@@ -883,26 +881,22 @@ BEGIN
883881
END IF;
884882

885883
IF @extschema@.is_date_type(p_atttype) THEN
886-
v_part_name := @extschema@.create_single_range_partition(
887-
parent_relid,
888-
p_range[1] - p_interval::interval,
889-
p_range[1],
890-
partition_name,
891-
tablespace);
884+
v_args_format := format('$1, ($2 - $3::interval)::%s, $2, $4, $5', v_atttype::TEXT);
892885
ELSE
893-
EXECUTE
894-
format('SELECT @extschema@.create_single_range_partition($1, $2 - $3::%s, $2, $4, $5)',
895-
v_atttype::TEXT)
896-
USING
897-
parent_relid,
898-
p_range[1],
899-
p_interval,
900-
partition_name,
901-
tablespace
902-
INTO
903-
v_part_name;
886+
v_args_format := format('$1, $2 - $3::%s, $2, $4, $5', v_atttype::TEXT);
904887
END IF;
905888

889+
EXECUTE
890+
format('SELECT @extschema@.create_single_range_partition(%s)', v_args_format)
891+
USING
892+
parent_relid,
893+
p_range[1],
894+
p_interval,
895+
partition_name,
896+
tablespace
897+
INTO
898+
v_part_name;
899+
906900
RETURN v_part_name;
907901
END
908902
$$

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy