Skip to content

Commit 757e249

Browse files
committed
Merge branch 'rel_future_beta' of github.com:postgrespro/pg_pathman into rel_future_beta
2 parents 20ed60b + cca1e8b commit 757e249

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

expected/pathman_interval.out

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ ERROR: cannot find appropriate partition for key '250'
2020
/* Set a trivial interval */
2121
SELECT set_interval('abc', 0);
2222
ERROR: interval must not be trivial
23+
/* Set a negative interval */
24+
SELECT set_interval('abc', -100);
25+
ERROR: interval must not be negative
2326
/* We also shouldn't be able to set a trivial interval directly in pathman_config table */
2427
UPDATE pathman_config SET range_interval = '0' WHERE partrel = 'abc'::REGCLASS;
2528
ERROR: interval must not be trivial

sql/pathman_interval.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ SELECT set_interval('abc', NULL::INTEGER);
99
INSERT INTO abc VALUES (250);
1010
/* Set a trivial interval */
1111
SELECT set_interval('abc', 0);
12+
/* Set a negative interval */
13+
SELECT set_interval('abc', -100);
1214
/* We also shouldn't be able to set a trivial interval directly in pathman_config table */
1315
UPDATE pathman_config SET range_interval = '0' WHERE partrel = 'abc'::REGCLASS;
1416
/* Set a normal interval */

src/pl_range_funcs.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,7 @@ interval_is_trivial(Oid atttype, Datum interval, Oid interval_type)
684684
Operator op;
685685
Oid op_func;
686686
FmgrInfo cmp_func;
687+
int32 cmp_result;
687688

688689
/* Generate default value */
689690
switch(atttype)
@@ -754,8 +755,13 @@ interval_is_trivial(Oid atttype, Datum interval, Oid interval_type)
754755
fill_type_cmp_fmgr_info(&cmp_func,
755756
getBaseType(atttype),
756757
getBaseType(op_result_type));
757-
if (DatumGetInt32(FunctionCall2(&cmp_func, default_value, op_result)) == 0)
758+
cmp_result = DatumGetInt32(FunctionCall2(&cmp_func,
759+
default_value,
760+
op_result));
761+
if (cmp_result == 0)
758762
return true;
763+
else if (cmp_result > 0) /* Negative interval? */
764+
elog(ERROR, "interval must not be negative");
759765

760766
return false;
761767
}

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