diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2012-07-18 22:34:06 +0300 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2012-07-18 23:14:56 +0300 |
commit | a7a4add6c4243cbcf50a554bce4c34cb72a344b5 (patch) | |
tree | d6c67e623268a3342bb9263230943e7f16e43b01 /src/include/utils | |
parent | 80e373c3a8c43812bdc98fe0d433b9990acce5ad (diff) | |
download | postgresql-a7a4add6c4243cbcf50a554bce4c34cb72a344b5.tar.gz postgresql-a7a4add6c4243cbcf50a554bce4c34cb72a344b5.zip |
Refactor the way code is shared between some range type functions.
Functions like range_eq, range_before etc. are exposed at the SQL-level, but
they're also used internally by the GiST consistent support function. The
code sharing was done by a hack, TrickFunctionCall2, which relied on the
knowledge that all the functions used fn_extra the same way. This commit
splits the functions into internal versions that take a TypeCacheEntry as
argument, and thin wrappers to expose the functions at the SQL-level. The
internal versions can then be called directly and in a less hacky way from
the GiST consistent function.
This is just cosmetic, but backpatch to 9.2 anyway, to avoid having a
different version of this code in the 9.2 branch. That would make
backpatching fixes in this area more difficult.
Alexander Korotkov
Diffstat (limited to 'src/include/utils')
-rw-r--r-- | src/include/utils/rangetypes.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/include/utils/rangetypes.h b/src/include/utils/rangetypes.h index ad72df57dd6..a37401c8ec9 100644 --- a/src/include/utils/rangetypes.h +++ b/src/include/utils/rangetypes.h @@ -104,6 +104,8 @@ extern Datum range_upper_inf(PG_FUNCTION_ARGS); extern Datum range_contains_elem(PG_FUNCTION_ARGS); extern Datum elem_contained_by_range(PG_FUNCTION_ARGS); +extern bool range_contains_elem_internal(TypeCacheEntry *typcache, RangeType *r, Datum val); + /* range, range -> bool */ extern Datum range_eq(PG_FUNCTION_ARGS); extern Datum range_ne(PG_FUNCTION_ARGS); @@ -116,6 +118,28 @@ extern Datum range_overlaps(PG_FUNCTION_ARGS); extern Datum range_overleft(PG_FUNCTION_ARGS); extern Datum range_overright(PG_FUNCTION_ARGS); +/* internal versions of the above */ +extern bool range_eq_internal(TypeCacheEntry *typcache, RangeType *r1, + RangeType *r2); +extern bool range_ne_internal(TypeCacheEntry *typcache, RangeType *r1, + RangeType *r2); +extern bool range_contains_internal(TypeCacheEntry *typcache, RangeType *r1, + RangeType *r2); +extern bool range_contained_by_internal(TypeCacheEntry *typcache, RangeType *r1, + RangeType *r2); +extern bool range_before_internal(TypeCacheEntry *typcache, RangeType *r1, + RangeType *r2); +extern bool range_after_internal(TypeCacheEntry *typcache, RangeType *r1, + RangeType *r2); +extern bool range_adjacent_internal(TypeCacheEntry *typcache, RangeType *r1, + RangeType *r2); +extern bool range_overlaps_internal(TypeCacheEntry *typcache, RangeType *r1, + RangeType *r2); +extern bool range_overleft_internal(TypeCacheEntry *typcache, RangeType *r1, + RangeType *r2); +extern bool range_overright_internal(TypeCacheEntry *typcache, RangeType *r1, + RangeType *r2); + /* range, range -> range */ extern Datum range_minus(PG_FUNCTION_ARGS); extern Datum range_union(PG_FUNCTION_ARGS); |