PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
rangetypes.h File Reference
#include "utils/typcache.h"
Include dependency graph for rangetypes.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  RangeType
 
struct  RangeBound
 

Macros

#define RangeTypeGetOid(r)   ((r)->rangetypid)
 
#define RANGE_EMPTY   0x01 /* range is empty */
 
#define RANGE_LB_INC   0x02 /* lower bound is inclusive */
 
#define RANGE_UB_INC   0x04 /* upper bound is inclusive */
 
#define RANGE_LB_INF   0x08 /* lower bound is -infinity */
 
#define RANGE_UB_INF   0x10 /* upper bound is +infinity */
 
#define RANGE_LB_NULL   0x20 /* lower bound is null (NOT USED) */
 
#define RANGE_UB_NULL   0x40 /* upper bound is null (NOT USED) */
 
#define RANGE_CONTAIN_EMPTY
 
#define RANGE_HAS_LBOUND(flags)
 
#define RANGE_HAS_UBOUND(flags)
 
#define RangeIsEmpty(r)   ((range_get_flags(r) & RANGE_EMPTY) != 0)
 
#define RangeIsOrContainsEmpty(r)   ((range_get_flags(r) & (RANGE_EMPTY | RANGE_CONTAIN_EMPTY)) != 0)
 
#define DatumGetRangeType(X)   ((RangeType *) PG_DETOAST_DATUM(X))
 
#define DatumGetRangeTypeCopy(X)   ((RangeType *) PG_DETOAST_DATUM_COPY(X))
 
#define RangeTypeGetDatum(X)   PointerGetDatum(X)
 
#define PG_GETARG_RANGE(n)   DatumGetRangeType(PG_GETARG_DATUM(n))
 
#define PG_GETARG_RANGE_COPY(n)   DatumGetRangeTypeCopy(PG_GETARG_DATUM(n))
 
#define PG_RETURN_RANGE(x)   return RangeTypeGetDatum(x)
 
#define RANGESTRAT_BEFORE   RTLeftStrategyNumber
 
#define RANGESTRAT_OVERLEFT   RTOverLeftStrategyNumber
 
#define RANGESTRAT_OVERLAPS   RTOverlapStrategyNumber
 
#define RANGESTRAT_OVERRIGHT   RTOverRightStrategyNumber
 
#define RANGESTRAT_AFTER   RTRightStrategyNumber
 
#define RANGESTRAT_ADJACENT   RTSameStrategyNumber
 
#define RANGESTRAT_CONTAINS   RTContainsStrategyNumber
 
#define RANGESTRAT_CONTAINED_BY   RTContainedByStrategyNumber
 
#define RANGESTRAT_CONTAINS_ELEM   RTContainsElemStrategyNumber
 
#define RANGESTRAT_EQ   RTEqualStrategyNumber
 

Functions

bool range_contains_elem_internal (TypeCacheEntry *typcache, RangeType *r, Datum val)
 
bool range_eq_internal (TypeCacheEntry *typcache, RangeType *r1, RangeType *r2)
 
bool range_ne_internal (TypeCacheEntry *typcache, RangeType *r1, RangeType *r2)
 
bool range_contains_internal (TypeCacheEntry *typcache, RangeType *r1, RangeType *r2)
 
bool range_contained_by_internal (TypeCacheEntry *typcache, RangeType *r1, RangeType *r2)
 
bool range_before_internal (TypeCacheEntry *typcache, RangeType *r1, RangeType *r2)
 
bool range_after_internal (TypeCacheEntry *typcache, RangeType *r1, RangeType *r2)
 
bool range_adjacent_internal (TypeCacheEntry *typcache, RangeType *r1, RangeType *r2)
 
bool range_overlaps_internal (TypeCacheEntry *typcache, RangeType *r1, RangeType *r2)
 
bool range_overleft_internal (TypeCacheEntry *typcache, RangeType *r1, RangeType *r2)
 
bool range_overright_internal (TypeCacheEntry *typcache, RangeType *r1, RangeType *r2)
 
TypeCacheEntryrange_get_typcache (FunctionCallInfo fcinfo, Oid rngtypid)
 
RangeTyperange_serialize (TypeCacheEntry *typcache, RangeBound *lower, RangeBound *upper, bool empty)
 
void range_deserialize (TypeCacheEntry *typcache, RangeType *range, RangeBound *lower, RangeBound *upper, bool *empty)
 
char range_get_flags (RangeType *range)
 
void range_set_contain_empty (RangeType *range)
 
RangeTypemake_range (TypeCacheEntry *typcache, RangeBound *lower, RangeBound *upper, bool empty)
 
int range_cmp_bounds (TypeCacheEntry *typcache, RangeBound *b1, RangeBound *b2)
 
int range_cmp_bound_values (TypeCacheEntry *typcache, RangeBound *b1, RangeBound *b2)
 
bool bounds_adjacent (TypeCacheEntry *typcache, RangeBound bound1, RangeBound bound2)
 
RangeTypemake_empty_range (TypeCacheEntry *typcache)
 

Macro Definition Documentation

#define DatumGetRangeTypeCopy (   X)    ((RangeType *) PG_DETOAST_DATUM_COPY(X))

Definition at line 72 of file rangetypes.h.

#define PG_GETARG_RANGE_COPY (   n)    DatumGetRangeTypeCopy(PG_GETARG_DATUM(n))

Definition at line 75 of file rangetypes.h.

#define RANGE_CONTAIN_EMPTY
Value:
0x80/* marks a GiST internal-page entry whose
* subtree contains some empty ranges */

Definition at line 43 of file rangetypes.h.

Referenced by get_gist_range_class(), range_set_contain_empty(), and range_super_union().

#define RANGE_EMPTY   0x01 /* range is empty */
#define RANGE_HAS_LBOUND (   flags)
Value:
(!((flags) & (RANGE_EMPTY | \
#define RANGE_EMPTY
Definition: rangetypes.h:36
#define RANGE_LB_INF
Definition: rangetypes.h:39
#define RANGE_LB_NULL
Definition: rangetypes.h:41

Definition at line 46 of file rangetypes.h.

Referenced by hash_range(), range_deparse(), range_deserialize(), range_in(), range_out(), range_recv(), range_send(), and range_serialize().

#define RANGE_HAS_UBOUND (   flags)
Value:
(!((flags) & (RANGE_EMPTY | \
#define RANGE_EMPTY
Definition: rangetypes.h:36
#define RANGE_UB_NULL
Definition: rangetypes.h:42
#define RANGE_UB_INF
Definition: rangetypes.h:40

Definition at line 50 of file rangetypes.h.

Referenced by hash_range(), range_deparse(), range_deserialize(), range_in(), range_out(), range_recv(), range_send(), and range_serialize().

#define RANGE_LB_INC   0x02 /* lower bound is inclusive */
#define RANGE_LB_INF   0x08 /* lower bound is -infinity */
#define RANGE_LB_NULL   0x20 /* lower bound is null (NOT USED) */

Definition at line 41 of file rangetypes.h.

#define RANGE_UB_INC   0x04 /* upper bound is inclusive */
#define RANGE_UB_INF   0x10 /* upper bound is +infinity */
#define RANGE_UB_NULL   0x40 /* upper bound is null (NOT USED) */

Definition at line 42 of file rangetypes.h.

#define RangeIsEmpty (   r)    ((range_get_flags(r) & RANGE_EMPTY) != 0)
#define RangeIsOrContainsEmpty (   r)    ((range_get_flags(r) & (RANGE_EMPTY | RANGE_CONTAIN_EMPTY)) != 0)

Definition at line 55 of file rangetypes.h.

Referenced by range_gist_consistent_int(), and range_gist_penalty().

Function Documentation

bool bounds_adjacent ( TypeCacheEntry typcache,
RangeBound  bound1,
RangeBound  bound2 
)

Definition at line 740 of file rangetypes.c.

References Assert, cmp(), FmgrInfo::fn_oid, RangeBound::inclusive, RangeBound::lower, make_range(), OidIsValid, range_cmp_bound_values(), RangeIsEmpty, and TypeCacheEntry::rng_canonical_finfo.

Referenced by adjacent_cmp_bounds(), and range_adjacent_internal().

741 {
742  int cmp;
743 
744  Assert(!boundA.lower && boundB.lower);
745 
746  cmp = range_cmp_bound_values(typcache, &boundA, &boundB);
747  if (cmp < 0)
748  {
749  RangeType *r;
750 
751  /*
752  * Bounds do not overlap; see if there are points in between.
753  */
754 
755  /* in a continuous subtype, there are assumed to be points between */
756  if (!OidIsValid(typcache->rng_canonical_finfo.fn_oid))
757  return false;
758 
759  /*
760  * The bounds are of a discrete range type; so make a range A..B and
761  * see if it's empty.
762  */
763 
764  /* flip the inclusion flags */
765  boundA.inclusive = !boundA.inclusive;
766  boundB.inclusive = !boundB.inclusive;
767  /* change upper/lower labels to avoid Assert failures */
768  boundA.lower = true;
769  boundB.lower = false;
770  r = make_range(typcache, &boundA, &boundB, false);
771  return RangeIsEmpty(r);
772  }
773  else if (cmp == 0)
774  return boundA.inclusive != boundB.inclusive;
775  else
776  return false; /* bounds overlap */
777 }
RangeType * make_range(TypeCacheEntry *typcache, RangeBound *lower, RangeBound *upper, bool empty)
Definition: rangetypes.c:1728
#define RangeIsEmpty(r)
Definition: rangetypes.h:54
#define OidIsValid(objectId)
Definition: c.h:538
FmgrInfo rng_canonical_finfo
Definition: typcache.h:87
Oid fn_oid
Definition: fmgr.h:59
int range_cmp_bound_values(TypeCacheEntry *typcache, RangeBound *b1, RangeBound *b2)
Definition: rangetypes.c:1842
#define Assert(condition)
Definition: c.h:675
static int cmp(const chr *x, const chr *y, size_t len)
Definition: regc_locale.c:742
RangeType* make_empty_range ( TypeCacheEntry typcache)

Definition at line 1877 of file rangetypes.c.

References RangeBound::inclusive, RangeBound::infinite, lower(), RangeBound::lower, make_range(), upper(), and RangeBound::val.

Referenced by range_intersect(), and range_minus().

1878 {
1879  RangeBound lower;
1880  RangeBound upper;
1881 
1882  lower.val = (Datum) 0;
1883  lower.infinite = false;
1884  lower.inclusive = false;
1885  lower.lower = true;
1886 
1887  upper.val = (Datum) 0;
1888  upper.infinite = false;
1889  upper.inclusive = false;
1890  upper.lower = false;
1891 
1892  return make_range(typcache, &lower, &upper, true);
1893 }
RangeType * make_range(TypeCacheEntry *typcache, RangeBound *lower, RangeBound *upper, bool empty)
Definition: rangetypes.c:1728
Datum lower(PG_FUNCTION_ARGS)
Definition: oracle_compat.c:43
Datum val
Definition: rangetypes.h:62
Datum upper(PG_FUNCTION_ARGS)
Definition: oracle_compat.c:74
bool inclusive
Definition: rangetypes.h:64
bool lower
Definition: rangetypes.h:65
uintptr_t Datum
Definition: postgres.h:372
bool infinite
Definition: rangetypes.h:63
RangeType* make_range ( TypeCacheEntry typcache,
RangeBound lower,
RangeBound upper,
bool  empty 
)

Definition at line 1728 of file rangetypes.c.

References DatumGetRangeType, FmgrInfo::fn_oid, FunctionCall1, OidIsValid, range(), range_serialize(), RangeIsEmpty, RangeTypeGetDatum, and TypeCacheEntry::rng_canonical_finfo.

Referenced by bounds_adjacent(), make_empty_range(), range_constructor2(), range_constructor3(), range_in(), range_intersect(), range_minus(), range_recv(), range_super_union(), and range_union_internal().

1730 {
1731  RangeType *range;
1732 
1733  range = range_serialize(typcache, lower, upper, empty);
1734 
1735  /* no need to call canonical on empty ranges ... */
1736  if (OidIsValid(typcache->rng_canonical_finfo.fn_oid) &&
1737  !RangeIsEmpty(range))
1739  RangeTypeGetDatum(range)));
1740 
1741  return range;
1742 }
#define RangeIsEmpty(r)
Definition: rangetypes.h:54
#define RangeTypeGetDatum(X)
Definition: rangetypes.h:73
#define DatumGetRangeType(X)
Definition: rangetypes.h:71
#define OidIsValid(objectId)
Definition: c.h:538
static struct cvec * range(struct vars *v, chr a, chr b, int cases)
Definition: regc_locale.c:416
RangeType * range_serialize(TypeCacheEntry *typcache, RangeBound *lower, RangeBound *upper, bool empty)
Definition: rangetypes.c:1503
FmgrInfo rng_canonical_finfo
Definition: typcache.h:87
Oid fn_oid
Definition: fmgr.h:59
#define FunctionCall1(flinfo, arg1)
Definition: fmgr.h:602
bool range_adjacent_internal ( TypeCacheEntry typcache,
RangeType r1,
RangeType r2 
)

Definition at line 781 of file rangetypes.c.

References bounds_adjacent(), elog, ERROR, range_deserialize(), and RangeTypeGetOid.

Referenced by range_adjacent(), range_gist_consistent_int(), range_gist_consistent_leaf(), range_union_internal(), and spg_range_quad_leaf_consistent().

782 {
783  RangeBound lower1,
784  lower2;
785  RangeBound upper1,
786  upper2;
787  bool empty1,
788  empty2;
789 
790  /* Different types should be prevented by ANYRANGE matching rules */
791  if (RangeTypeGetOid(r1) != RangeTypeGetOid(r2))
792  elog(ERROR, "range types do not match");
793 
794  range_deserialize(typcache, r1, &lower1, &upper1, &empty1);
795  range_deserialize(typcache, r2, &lower2, &upper2, &empty2);
796 
797  /* An empty range is not adjacent to any other range */
798  if (empty1 || empty2)
799  return false;
800 
801  /*
802  * Given two ranges A..B and C..D, the ranges are adjacent if and only if
803  * B is adjacent to C, or D is adjacent to A.
804  */
805  return (bounds_adjacent(typcache, upper1, lower2) ||
806  bounds_adjacent(typcache, upper2, lower1));
807 }
#define RangeTypeGetOid(r)
Definition: rangetypes.h:33
bool bounds_adjacent(TypeCacheEntry *typcache, RangeBound boundA, RangeBound boundB)
Definition: rangetypes.c:740
#define ERROR
Definition: elog.h:43
void range_deserialize(TypeCacheEntry *typcache, RangeType *range, RangeBound *lower, RangeBound *upper, bool *empty)
Definition: rangetypes.c:1632
#define elog
Definition: elog.h:219
bool range_after_internal ( TypeCacheEntry typcache,
RangeType r1,
RangeType r2 
)

Definition at line 685 of file rangetypes.c.

References elog, ERROR, range_cmp_bounds(), range_deserialize(), and RangeTypeGetOid.

Referenced by range_after(), range_gist_consistent_int(), range_gist_consistent_leaf(), and spg_range_quad_leaf_consistent().

686 {
687  RangeBound lower1,
688  lower2;
689  RangeBound upper1,
690  upper2;
691  bool empty1,
692  empty2;
693 
694  /* Different types should be prevented by ANYRANGE matching rules */
695  if (RangeTypeGetOid(r1) != RangeTypeGetOid(r2))
696  elog(ERROR, "range types do not match");
697 
698  range_deserialize(typcache, r1, &lower1, &upper1, &empty1);
699  range_deserialize(typcache, r2, &lower2, &upper2, &empty2);
700 
701  /* An empty range is neither before nor after any other range */
702  if (empty1 || empty2)
703  return false;
704 
705  return (range_cmp_bounds(typcache, &lower1, &upper2) > 0);
706 }
int range_cmp_bounds(TypeCacheEntry *typcache, RangeBound *b1, RangeBound *b2)
Definition: rangetypes.c:1768
#define RangeTypeGetOid(r)
Definition: rangetypes.h:33
#define ERROR
Definition: elog.h:43
void range_deserialize(TypeCacheEntry *typcache, RangeType *range, RangeBound *lower, RangeBound *upper, bool *empty)
Definition: rangetypes.c:1632
#define elog
Definition: elog.h:219
bool range_before_internal ( TypeCacheEntry typcache,
RangeType r1,
RangeType r2 
)

Definition at line 647 of file rangetypes.c.

References elog, ERROR, range_cmp_bounds(), range_deserialize(), and RangeTypeGetOid.

Referenced by range_before(), range_gist_consistent_int(), range_gist_consistent_leaf(), and spg_range_quad_leaf_consistent().

648 {
649  RangeBound lower1,
650  lower2;
651  RangeBound upper1,
652  upper2;
653  bool empty1,
654  empty2;
655 
656  /* Different types should be prevented by ANYRANGE matching rules */
657  if (RangeTypeGetOid(r1) != RangeTypeGetOid(r2))
658  elog(ERROR, "range types do not match");
659 
660  range_deserialize(typcache, r1, &lower1, &upper1, &empty1);
661  range_deserialize(typcache, r2, &lower2, &upper2, &empty2);
662 
663  /* An empty range is neither before nor after any other range */
664  if (empty1 || empty2)
665  return false;
666 
667  return (range_cmp_bounds(typcache, &upper1, &lower2) < 0);
668 }
int range_cmp_bounds(TypeCacheEntry *typcache, RangeBound *b1, RangeBound *b2)
Definition: rangetypes.c:1768
#define RangeTypeGetOid(r)
Definition: rangetypes.h:33
#define ERROR
Definition: elog.h:43
void range_deserialize(TypeCacheEntry *typcache, RangeType *range, RangeBound *lower, RangeBound *upper, bool *empty)
Definition: rangetypes.c:1632
#define elog
Definition: elog.h:219
int range_cmp_bound_values ( TypeCacheEntry typcache,
RangeBound b1,
RangeBound b2 
)

Definition at line 1842 of file rangetypes.c.

References DatumGetInt32, FunctionCall2Coll(), RangeBound::infinite, RangeBound::lower, TypeCacheEntry::rng_cmp_proc_finfo, TypeCacheEntry::rng_collation, and RangeBound::val.

Referenced by bounds_adjacent(), and range_serialize().

1844 {
1845  /*
1846  * First, handle cases involving infinity, which don't require invoking
1847  * the comparison proc.
1848  */
1849  if (b1->infinite && b2->infinite)
1850  {
1851  /*
1852  * Both are infinity, so they are equal unless one is lower and the
1853  * other not.
1854  */
1855  if (b1->lower == b2->lower)
1856  return 0;
1857  else
1858  return b1->lower ? -1 : 1;
1859  }
1860  else if (b1->infinite)
1861  return b1->lower ? -1 : 1;
1862  else if (b2->infinite)
1863  return b2->lower ? 1 : -1;
1864 
1865  /*
1866  * Both boundaries are finite, so compare the held values.
1867  */
1869  typcache->rng_collation,
1870  b1->val, b2->val));
1871 }
FmgrInfo rng_cmp_proc_finfo
Definition: typcache.h:86
#define DatumGetInt32(X)
Definition: postgres.h:478
Datum val
Definition: rangetypes.h:62
Datum FunctionCall2Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2)
Definition: fmgr.c:1047
bool lower
Definition: rangetypes.h:65
bool infinite
Definition: rangetypes.h:63
Oid rng_collation
Definition: typcache.h:85
int range_cmp_bounds ( TypeCacheEntry typcache,
RangeBound b1,
RangeBound b2 
)

Definition at line 1768 of file rangetypes.c.

References DatumGetInt32, FunctionCall2Coll(), RangeBound::inclusive, RangeBound::infinite, RangeBound::lower, result, TypeCacheEntry::rng_cmp_proc_finfo, TypeCacheEntry::rng_collation, and RangeBound::val.

Referenced by adjacent_cmp_bounds(), adjacent_inner_consistent(), bound_cmp(), calc_hist_selectivity_contained(), getQuadrant(), interval_cmp_lower(), interval_cmp_upper(), range_after_internal(), range_before_internal(), range_bound_qsort_cmp(), range_cmp(), range_contains_internal(), range_eq_internal(), range_gist_double_sorting_split(), range_gist_penalty(), range_intersect(), range_minus(), range_overlaps_internal(), range_overleft_internal(), range_overright_internal(), range_super_union(), range_union_internal(), rbound_bsearch(), single_bound_cmp(), and spg_range_quad_inner_consistent().

1769 {
1770  int32 result;
1771 
1772  /*
1773  * First, handle cases involving infinity, which don't require invoking
1774  * the comparison proc.
1775  */
1776  if (b1->infinite && b2->infinite)
1777  {
1778  /*
1779  * Both are infinity, so they are equal unless one is lower and the
1780  * other not.
1781  */
1782  if (b1->lower == b2->lower)
1783  return 0;
1784  else
1785  return b1->lower ? -1 : 1;
1786  }
1787  else if (b1->infinite)
1788  return b1->lower ? -1 : 1;
1789  else if (b2->infinite)
1790  return b2->lower ? 1 : -1;
1791 
1792  /*
1793  * Both boundaries are finite, so compare the held values.
1794  */
1796  typcache->rng_collation,
1797  b1->val, b2->val));
1798 
1799  /*
1800  * If the comparison is anything other than equal, we're done. If they
1801  * compare equal though, we still have to consider whether the boundaries
1802  * are inclusive or exclusive.
1803  */
1804  if (result == 0)
1805  {
1806  if (!b1->inclusive && !b2->inclusive)
1807  {
1808  /* both are exclusive */
1809  if (b1->lower == b2->lower)
1810  return 0;
1811  else
1812  return b1->lower ? 1 : -1;
1813  }
1814  else if (!b1->inclusive)
1815  return b1->lower ? 1 : -1;
1816  else if (!b2->inclusive)
1817  return b2->lower ? -1 : 1;
1818  else
1819  {
1820  /*
1821  * Both are inclusive and the values held are equal, so they are
1822  * equal regardless of whether they are upper or lower boundaries,
1823  * or a mix.
1824  */
1825  return 0;
1826  }
1827  }
1828 
1829  return result;
1830 }
FmgrInfo rng_cmp_proc_finfo
Definition: typcache.h:86
#define DatumGetInt32(X)
Definition: postgres.h:478
Datum val
Definition: rangetypes.h:62
return result
Definition: formatting.c:1618
Datum FunctionCall2Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2)
Definition: fmgr.c:1047
signed int int32
Definition: c.h:256
bool inclusive
Definition: rangetypes.h:64
bool lower
Definition: rangetypes.h:65
bool infinite
Definition: rangetypes.h:63
Oid rng_collation
Definition: typcache.h:85
bool range_contained_by_internal ( TypeCacheEntry typcache,
RangeType r1,
RangeType r2 
)

Definition at line 2268 of file rangetypes.c.

References range_contains_internal().

Referenced by range_contained_by(), range_gist_consistent_leaf(), and spg_range_quad_leaf_consistent().

2269 {
2270  return range_contains_internal(typcache, r2, r1);
2271 }
bool range_contains_internal(TypeCacheEntry *typcache, RangeType *r1, RangeType *r2)
Definition: rangetypes.c:2236
bool range_contains_elem_internal ( TypeCacheEntry typcache,
RangeType r,
Datum  val 
)

Definition at line 2277 of file rangetypes.c.

References cmp(), DatumGetInt32, FunctionCall2Coll(), RangeBound::inclusive, RangeBound::infinite, lower(), range_deserialize(), TypeCacheEntry::rng_cmp_proc_finfo, TypeCacheEntry::rng_collation, upper(), and RangeBound::val.

Referenced by elem_contained_by_range(), range_contains_elem(), range_gist_consistent_int(), range_gist_consistent_leaf(), and spg_range_quad_leaf_consistent().

2278 {
2279  RangeBound lower;
2280  RangeBound upper;
2281  bool empty;
2282  int32 cmp;
2283 
2284  range_deserialize(typcache, r, &lower, &upper, &empty);
2285 
2286  if (empty)
2287  return false;
2288 
2289  if (!lower.infinite)
2290  {
2292  typcache->rng_collation,
2293  lower.val, val));
2294  if (cmp > 0)
2295  return false;
2296  if (cmp == 0 && !lower.inclusive)
2297  return false;
2298  }
2299 
2300  if (!upper.infinite)
2301  {
2303  typcache->rng_collation,
2304  upper.val, val));
2305  if (cmp < 0)
2306  return false;
2307  if (cmp == 0 && !upper.inclusive)
2308  return false;
2309  }
2310 
2311  return true;
2312 }
FmgrInfo rng_cmp_proc_finfo
Definition: typcache.h:86
#define DatumGetInt32(X)
Definition: postgres.h:478
Datum lower(PG_FUNCTION_ARGS)
Definition: oracle_compat.c:43
Datum val
Definition: rangetypes.h:62
Datum upper(PG_FUNCTION_ARGS)
Definition: oracle_compat.c:74
Datum FunctionCall2Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2)
Definition: fmgr.c:1047
signed int int32
Definition: c.h:256
bool inclusive
Definition: rangetypes.h:64
void range_deserialize(TypeCacheEntry *typcache, RangeType *range, RangeBound *lower, RangeBound *upper, bool *empty)
Definition: rangetypes.c:1632
bool infinite
Definition: rangetypes.h:63
Oid rng_collation
Definition: typcache.h:85
long val
Definition: informix.c:689
static int cmp(const chr *x, const chr *y, size_t len)
Definition: regc_locale.c:742
bool range_contains_internal ( TypeCacheEntry typcache,
RangeType r1,
RangeType r2 
)

Definition at line 2236 of file rangetypes.c.

References elog, ERROR, range_cmp_bounds(), range_deserialize(), and RangeTypeGetOid.

Referenced by range_contained_by_internal(), range_contains(), range_gist_consistent_int(), range_gist_consistent_leaf(), and spg_range_quad_leaf_consistent().

2237 {
2238  RangeBound lower1;
2239  RangeBound upper1;
2240  bool empty1;
2241  RangeBound lower2;
2242  RangeBound upper2;
2243  bool empty2;
2244 
2245  /* Different types should be prevented by ANYRANGE matching rules */
2246  if (RangeTypeGetOid(r1) != RangeTypeGetOid(r2))
2247  elog(ERROR, "range types do not match");
2248 
2249  range_deserialize(typcache, r1, &lower1, &upper1, &empty1);
2250  range_deserialize(typcache, r2, &lower2, &upper2, &empty2);
2251 
2252  /* If either range is empty, the answer is easy */
2253  if (empty2)
2254  return true;
2255  else if (empty1)
2256  return false;
2257 
2258  /* Else we must have lower1 <= lower2 and upper1 >= upper2 */
2259  if (range_cmp_bounds(typcache, &lower1, &lower2) > 0)
2260  return false;
2261  if (range_cmp_bounds(typcache, &upper1, &upper2) < 0)
2262  return false;
2263 
2264  return true;
2265 }
int range_cmp_bounds(TypeCacheEntry *typcache, RangeBound *b1, RangeBound *b2)
Definition: rangetypes.c:1768
#define RangeTypeGetOid(r)
Definition: rangetypes.h:33
#define ERROR
Definition: elog.h:43
void range_deserialize(TypeCacheEntry *typcache, RangeType *range, RangeBound *lower, RangeBound *upper, bool *empty)
Definition: rangetypes.c:1632
#define elog
Definition: elog.h:219
void range_deserialize ( TypeCacheEntry typcache,
RangeType range,
RangeBound lower,
RangeBound upper,
bool empty 
)

Definition at line 1632 of file rangetypes.c.

References Assert, att_addlength_pointer, att_align_pointer, fetch_att, RangeBound::inclusive, RangeBound::infinite, RangeBound::lower, RANGE_EMPTY, RANGE_HAS_LBOUND, RANGE_HAS_UBOUND, RANGE_LB_INC, RANGE_LB_INF, RANGE_UB_INC, RANGE_UB_INF, RangeTypeGetOid, TypeCacheEntry::rngelemtype, TypeCacheEntry::typalign, TypeCacheEntry::typbyval, TypeCacheEntry::type_id, TypeCacheEntry::typlen, RangeBound::val, and VARSIZE.

Referenced by calc_hist_selectivity(), compute_range_stats(), daterange_canonical(), getQuadrant(), hash_range(), int4range_canonical(), int8range_canonical(), range_adjacent_internal(), range_after_internal(), range_before_internal(), range_cmp(), range_contains_elem_internal(), range_contains_internal(), range_eq_internal(), range_gist_double_sorting_split(), range_gist_penalty(), range_gist_single_sorting_split(), range_intersect(), range_lower(), range_minus(), range_out(), range_overlaps_internal(), range_overleft_internal(), range_overright_internal(), range_send(), range_super_union(), range_union_internal(), range_upper(), spg_range_quad_inner_consistent(), spg_range_quad_picksplit(), TQExamineRange(), and TQRemapRange().

1634 {
1635  char flags;
1636  int16 typlen;
1637  bool typbyval;
1638  char typalign;
1639  Pointer ptr;
1640  Datum lbound;
1641  Datum ubound;
1642 
1643  /* assert caller passed the right typcache entry */
1644  Assert(RangeTypeGetOid(range) == typcache->type_id);
1645 
1646  /* fetch the flag byte from datum's last byte */
1647  flags = *((char *) range + VARSIZE(range) - 1);
1648 
1649  /* fetch information about range's element type */
1650  typlen = typcache->rngelemtype->typlen;
1651  typbyval = typcache->rngelemtype->typbyval;
1652  typalign = typcache->rngelemtype->typalign;
1653 
1654  /* initialize data pointer just after the range OID */
1655  ptr = (Pointer) (range + 1);
1656 
1657  /* fetch lower bound, if any */
1658  if (RANGE_HAS_LBOUND(flags))
1659  {
1660  /* att_align_pointer cannot be necessary here */
1661  lbound = fetch_att(ptr, typbyval, typlen);
1662  ptr = (Pointer) att_addlength_pointer(ptr, typlen, ptr);
1663  }
1664  else
1665  lbound = (Datum) 0;
1666 
1667  /* fetch upper bound, if any */
1668  if (RANGE_HAS_UBOUND(flags))
1669  {
1670  ptr = (Pointer) att_align_pointer(ptr, typalign, typlen, ptr);
1671  ubound = fetch_att(ptr, typbyval, typlen);
1672  /* no need for att_addlength_pointer */
1673  }
1674  else
1675  ubound = (Datum) 0;
1676 
1677  /* emit results */
1678 
1679  *empty = (flags & RANGE_EMPTY) != 0;
1680 
1681  lower->val = lbound;
1682  lower->infinite = (flags & RANGE_LB_INF) != 0;
1683  lower->inclusive = (flags & RANGE_LB_INC) != 0;
1684  lower->lower = true;
1685 
1686  upper->val = ubound;
1687  upper->infinite = (flags & RANGE_UB_INF) != 0;
1688  upper->inclusive = (flags & RANGE_UB_INC) != 0;
1689  upper->lower = false;
1690 }
#define RANGE_HAS_UBOUND(flags)
Definition: rangetypes.h:50
signed short int16
Definition: c.h:255
#define RANGE_HAS_LBOUND(flags)
Definition: rangetypes.h:46
#define RANGE_EMPTY
Definition: rangetypes.h:36
#define RangeTypeGetOid(r)
Definition: rangetypes.h:33
#define VARSIZE(PTR)
Definition: postgres.h:304
Datum val
Definition: rangetypes.h:62
int16 typlen
Definition: typcache.h:35
#define RANGE_LB_INF
Definition: rangetypes.h:39
bool typbyval
Definition: typcache.h:36
char * Pointer
Definition: c.h:245
bool inclusive
Definition: rangetypes.h:64
#define RANGE_UB_INC
Definition: rangetypes.h:38
#define att_addlength_pointer(cur_offset, attlen, attptr)
Definition: tupmacs.h:172
bool lower
Definition: rangetypes.h:65
struct TypeCacheEntry * rngelemtype
Definition: typcache.h:84
uintptr_t Datum
Definition: postgres.h:372
#define att_align_pointer(cur_offset, attalign, attlen, attptr)
Definition: tupmacs.h:122
#define RANGE_LB_INC
Definition: rangetypes.h:37
#define Assert(condition)
Definition: c.h:675
bool infinite
Definition: rangetypes.h:63
#define RANGE_UB_INF
Definition: rangetypes.h:40
char typalign
Definition: typcache.h:37
#define fetch_att(T, attbyval, attlen)
Definition: tupmacs.h:71
bool range_eq_internal ( TypeCacheEntry typcache,
RangeType r1,
RangeType r2 
)

Definition at line 556 of file rangetypes.c.

References elog, ERROR, range_cmp_bounds(), range_deserialize(), and RangeTypeGetOid.

Referenced by range_eq(), range_gist_consistent_leaf(), range_gist_same(), range_ne_internal(), and spg_range_quad_leaf_consistent().

557 {
558  RangeBound lower1,
559  lower2;
560  RangeBound upper1,
561  upper2;
562  bool empty1,
563  empty2;
564 
565  /* Different types should be prevented by ANYRANGE matching rules */
566  if (RangeTypeGetOid(r1) != RangeTypeGetOid(r2))
567  elog(ERROR, "range types do not match");
568 
569  range_deserialize(typcache, r1, &lower1, &upper1, &empty1);
570  range_deserialize(typcache, r2, &lower2, &upper2, &empty2);
571 
572  if (empty1 && empty2)
573  return true;
574  if (empty1 != empty2)
575  return false;
576 
577  if (range_cmp_bounds(typcache, &lower1, &lower2) != 0)
578  return false;
579 
580  if (range_cmp_bounds(typcache, &upper1, &upper2) != 0)
581  return false;
582 
583  return true;
584 }
int range_cmp_bounds(TypeCacheEntry *typcache, RangeBound *b1, RangeBound *b2)
Definition: rangetypes.c:1768
#define RangeTypeGetOid(r)
Definition: rangetypes.h:33
#define ERROR
Definition: elog.h:43
void range_deserialize(TypeCacheEntry *typcache, RangeType *range, RangeBound *lower, RangeBound *upper, bool *empty)
Definition: rangetypes.c:1632
#define elog
Definition: elog.h:219
char range_get_flags ( RangeType range)

Definition at line 1699 of file rangetypes.c.

References VARSIZE.

Referenced by get_gist_range_class(), hash_range(), range_empty(), range_gist_same(), range_lower_inc(), range_lower_inf(), range_out(), range_send(), range_super_union(), range_upper_inc(), and range_upper_inf().

1700 {
1701  /* fetch the flag byte from datum's last byte */
1702  return *((char *) range + VARSIZE(range) - 1);
1703 }
#define VARSIZE(PTR)
Definition: postgres.h:304
TypeCacheEntry* range_get_typcache ( FunctionCallInfo  fcinfo,
Oid  rngtypid 
)

Definition at line 1479 of file rangetypes.c.

References elog, ERROR, FunctionCallInfoData::flinfo, FmgrInfo::fn_extra, lookup_type_cache(), NULL, TypeCacheEntry::rngelemtype, TypeCacheEntry::type_id, and TYPECACHE_RANGE_INFO.

Referenced by daterange_canonical(), elem_contained_by_range(), hash_range(), int4range_canonical(), int8range_canonical(), range_adjacent(), range_after(), range_before(), range_cmp(), range_constructor2(), range_constructor3(), range_contained_by(), range_contains(), range_contains_elem(), range_eq(), range_gist_consistent(), range_gist_penalty(), range_gist_picksplit(), range_gist_same(), range_gist_union(), range_intersect(), range_lower(), range_merge(), range_minus(), range_ne(), range_overlaps(), range_overleft(), range_overright(), range_typanalyze(), range_union(), range_upper(), rangesel(), spg_range_quad_choose(), spg_range_quad_inner_consistent(), spg_range_quad_leaf_consistent(), and spg_range_quad_picksplit().

1480 {
1481  TypeCacheEntry *typcache = (TypeCacheEntry *) fcinfo->flinfo->fn_extra;
1482 
1483  if (typcache == NULL ||
1484  typcache->type_id != rngtypid)
1485  {
1486  typcache = lookup_type_cache(rngtypid, TYPECACHE_RANGE_INFO);
1487  if (typcache->rngelemtype == NULL)
1488  elog(ERROR, "type %u is not a range type", rngtypid);
1489  fcinfo->flinfo->fn_extra = (void *) typcache;
1490  }
1491 
1492  return typcache;
1493 }
#define TYPECACHE_RANGE_INFO
Definition: typcache.h:121
FmgrInfo * flinfo
Definition: fmgr.h:79
#define ERROR
Definition: elog.h:43
struct TypeCacheEntry * rngelemtype
Definition: typcache.h:84
TypeCacheEntry * lookup_type_cache(Oid type_id, int flags)
Definition: typcache.c:191
#define NULL
Definition: c.h:229
void * fn_extra
Definition: fmgr.h:64
#define elog
Definition: elog.h:219
bool range_ne_internal ( TypeCacheEntry typcache,
RangeType r1,
RangeType r2 
)

Definition at line 601 of file rangetypes.c.

References range_eq_internal().

Referenced by range_ne().

602 {
603  return (!range_eq_internal(typcache, r1, r2));
604 }
bool range_eq_internal(TypeCacheEntry *typcache, RangeType *r1, RangeType *r2)
Definition: rangetypes.c:556
bool range_overlaps_internal ( TypeCacheEntry typcache,
RangeType r1,
RangeType r2 
)

Definition at line 824 of file rangetypes.c.

References elog, ERROR, range_cmp_bounds(), range_deserialize(), and RangeTypeGetOid.

Referenced by range_gist_consistent_int(), range_gist_consistent_leaf(), range_overlaps(), range_union_internal(), and spg_range_quad_leaf_consistent().

825 {
826  RangeBound lower1,
827  lower2;
828  RangeBound upper1,
829  upper2;
830  bool empty1,
831  empty2;
832 
833  /* Different types should be prevented by ANYRANGE matching rules */
834  if (RangeTypeGetOid(r1) != RangeTypeGetOid(r2))
835  elog(ERROR, "range types do not match");
836 
837  range_deserialize(typcache, r1, &lower1, &upper1, &empty1);
838  range_deserialize(typcache, r2, &lower2, &upper2, &empty2);
839 
840  /* An empty range does not overlap any other range */
841  if (empty1 || empty2)
842  return false;
843 
844  if (range_cmp_bounds(typcache, &lower1, &lower2) >= 0 &&
845  range_cmp_bounds(typcache, &lower1, &upper2) <= 0)
846  return true;
847 
848  if (range_cmp_bounds(typcache, &lower2, &lower1) >= 0 &&
849  range_cmp_bounds(typcache, &lower2, &upper1) <= 0)
850  return true;
851 
852  return false;
853 }
int range_cmp_bounds(TypeCacheEntry *typcache, RangeBound *b1, RangeBound *b2)
Definition: rangetypes.c:1768
#define RangeTypeGetOid(r)
Definition: rangetypes.h:33
#define ERROR
Definition: elog.h:43
void range_deserialize(TypeCacheEntry *typcache, RangeType *range, RangeBound *lower, RangeBound *upper, bool *empty)
Definition: rangetypes.c:1632
#define elog
Definition: elog.h:219
bool range_overleft_internal ( TypeCacheEntry typcache,
RangeType r1,
RangeType r2 
)

Definition at line 870 of file rangetypes.c.

References elog, ERROR, range_cmp_bounds(), range_deserialize(), and RangeTypeGetOid.

Referenced by range_gist_consistent_int(), range_gist_consistent_leaf(), range_overleft(), and spg_range_quad_leaf_consistent().

871 {
872  RangeBound lower1,
873  lower2;
874  RangeBound upper1,
875  upper2;
876  bool empty1,
877  empty2;
878 
879  /* Different types should be prevented by ANYRANGE matching rules */
880  if (RangeTypeGetOid(r1) != RangeTypeGetOid(r2))
881  elog(ERROR, "range types do not match");
882 
883  range_deserialize(typcache, r1, &lower1, &upper1, &empty1);
884  range_deserialize(typcache, r2, &lower2, &upper2, &empty2);
885 
886  /* An empty range is neither before nor after any other range */
887  if (empty1 || empty2)
888  return false;
889 
890  if (range_cmp_bounds(typcache, &upper1, &upper2) <= 0)
891  return true;
892 
893  return false;
894 }
int range_cmp_bounds(TypeCacheEntry *typcache, RangeBound *b1, RangeBound *b2)
Definition: rangetypes.c:1768
#define RangeTypeGetOid(r)
Definition: rangetypes.h:33
#define ERROR
Definition: elog.h:43
void range_deserialize(TypeCacheEntry *typcache, RangeType *range, RangeBound *lower, RangeBound *upper, bool *empty)
Definition: rangetypes.c:1632
#define elog
Definition: elog.h:219
bool range_overright_internal ( TypeCacheEntry typcache,
RangeType r1,
RangeType r2 
)

Definition at line 911 of file rangetypes.c.

References elog, ERROR, range_cmp_bounds(), range_deserialize(), and RangeTypeGetOid.

Referenced by range_gist_consistent_int(), range_gist_consistent_leaf(), range_overright(), and spg_range_quad_leaf_consistent().

912 {
913  RangeBound lower1,
914  lower2;
915  RangeBound upper1,
916  upper2;
917  bool empty1,
918  empty2;
919 
920  /* Different types should be prevented by ANYRANGE matching rules */
921  if (RangeTypeGetOid(r1) != RangeTypeGetOid(r2))
922  elog(ERROR, "range types do not match");
923 
924  range_deserialize(typcache, r1, &lower1, &upper1, &empty1);
925  range_deserialize(typcache, r2, &lower2, &upper2, &empty2);
926 
927  /* An empty range is neither before nor after any other range */
928  if (empty1 || empty2)
929  return false;
930 
931  if (range_cmp_bounds(typcache, &lower1, &lower2) >= 0)
932  return true;
933 
934  return false;
935 }
int range_cmp_bounds(TypeCacheEntry *typcache, RangeBound *b1, RangeBound *b2)
Definition: rangetypes.c:1768
#define RangeTypeGetOid(r)
Definition: rangetypes.h:33
#define ERROR
Definition: elog.h:43
void range_deserialize(TypeCacheEntry *typcache, RangeType *range, RangeBound *lower, RangeBound *upper, bool *empty)
Definition: rangetypes.c:1632
#define elog
Definition: elog.h:219
RangeType* range_serialize ( TypeCacheEntry typcache,
RangeBound lower,
RangeBound upper,
bool  empty 
)

Definition at line 1503 of file rangetypes.c.

References Assert, cmp(), datum_compute_size(), datum_write(), ereport, errcode(), errmsg(), ERROR, RangeBound::inclusive, RangeBound::infinite, RangeBound::lower, MAXALIGN, palloc0(), PG_DETOAST_DATUM_PACKED, PointerGetDatum, range(), range_cmp_bound_values(), RANGE_EMPTY, RANGE_HAS_LBOUND, RANGE_HAS_UBOUND, RANGE_LB_INC, RANGE_LB_INF, RANGE_UB_INC, RANGE_UB_INF, RangeType::rangetypid, TypeCacheEntry::rngelemtype, SET_VARSIZE, TypeCacheEntry::typalign, TypeCacheEntry::typbyval, TypeCacheEntry::type_id, TypeCacheEntry::typlen, TypeCacheEntry::typstorage, and RangeBound::val.

Referenced by compute_range_stats(), daterange_canonical(), int4range_canonical(), int8range_canonical(), make_range(), rangesel(), spg_range_quad_picksplit(), and TQRemapRange().

1505 {
1506  RangeType *range;
1507  int cmp;
1508  Size msize;
1509  Pointer ptr;
1510  int16 typlen;
1511  bool typbyval;
1512  char typalign;
1513  char typstorage;
1514  char flags = 0;
1515 
1516  /*
1517  * Verify range is not invalid on its face, and construct flags value,
1518  * preventing any non-canonical combinations such as infinite+inclusive.
1519  */
1520  Assert(lower->lower);
1521  Assert(!upper->lower);
1522 
1523  if (empty)
1524  flags |= RANGE_EMPTY;
1525  else
1526  {
1527  cmp = range_cmp_bound_values(typcache, lower, upper);
1528 
1529  /* error check: if lower bound value is above upper, it's wrong */
1530  if (cmp > 0)
1531  ereport(ERROR,
1532  (errcode(ERRCODE_DATA_EXCEPTION),
1533  errmsg("range lower bound must be less than or equal to range upper bound")));
1534 
1535  /* if bounds are equal, and not both inclusive, range is empty */
1536  if (cmp == 0 && !(lower->inclusive && upper->inclusive))
1537  flags |= RANGE_EMPTY;
1538  else
1539  {
1540  /* infinite boundaries are never inclusive */
1541  if (lower->infinite)
1542  flags |= RANGE_LB_INF;
1543  else if (lower->inclusive)
1544  flags |= RANGE_LB_INC;
1545  if (upper->infinite)
1546  flags |= RANGE_UB_INF;
1547  else if (upper->inclusive)
1548  flags |= RANGE_UB_INC;
1549  }
1550  }
1551 
1552  /* Fetch information about range's element type */
1553  typlen = typcache->rngelemtype->typlen;
1554  typbyval = typcache->rngelemtype->typbyval;
1555  typalign = typcache->rngelemtype->typalign;
1556  typstorage = typcache->rngelemtype->typstorage;
1557 
1558  /* Count space for varlena header and range type's OID */
1559  msize = sizeof(RangeType);
1560  Assert(msize == MAXALIGN(msize));
1561 
1562  /* Count space for bounds */
1563  if (RANGE_HAS_LBOUND(flags))
1564  {
1565  /*
1566  * Make sure item to be inserted is not toasted. It is essential that
1567  * we not insert an out-of-line toast value pointer into a range
1568  * object, for the same reasons that arrays and records can't contain
1569  * them. It would work to store a compressed-in-line value, but we
1570  * prefer to decompress and then let compression be applied to the
1571  * whole range object if necessary. But, unlike arrays, we do allow
1572  * short-header varlena objects to stay as-is.
1573  */
1574  if (typlen == -1)
1575  lower->val = PointerGetDatum(PG_DETOAST_DATUM_PACKED(lower->val));
1576 
1577  msize = datum_compute_size(msize, lower->val, typbyval, typalign,
1578  typlen, typstorage);
1579  }
1580 
1581  if (RANGE_HAS_UBOUND(flags))
1582  {
1583  /* Make sure item to be inserted is not toasted */
1584  if (typlen == -1)
1585  upper->val = PointerGetDatum(PG_DETOAST_DATUM_PACKED(upper->val));
1586 
1587  msize = datum_compute_size(msize, upper->val, typbyval, typalign,
1588  typlen, typstorage);
1589  }
1590 
1591  /* Add space for flag byte */
1592  msize += sizeof(char);
1593 
1594  /* Note: zero-fill is required here, just as in heap tuples */
1595  range = (RangeType *) palloc0(msize);
1596  SET_VARSIZE(range, msize);
1597 
1598  /* Now fill in the datum */
1599  range->rangetypid = typcache->type_id;
1600 
1601  ptr = (char *) (range + 1);
1602 
1603  if (RANGE_HAS_LBOUND(flags))
1604  {
1605  Assert(lower->lower);
1606  ptr = datum_write(ptr, lower->val, typbyval, typalign, typlen,
1607  typstorage);
1608  }
1609 
1610  if (RANGE_HAS_UBOUND(flags))
1611  {
1612  Assert(!upper->lower);
1613  ptr = datum_write(ptr, upper->val, typbyval, typalign, typlen,
1614  typstorage);
1615  }
1616 
1617  *((char *) ptr) = flags;
1618 
1619  return range;
1620 }
#define RANGE_HAS_UBOUND(flags)
Definition: rangetypes.h:50
signed short int16
Definition: c.h:255
#define RANGE_HAS_LBOUND(flags)
Definition: rangetypes.h:46
#define RANGE_EMPTY
Definition: rangetypes.h:36
#define PointerGetDatum(X)
Definition: postgres.h:562
Datum val
Definition: rangetypes.h:62
int errcode(int sqlerrcode)
Definition: elog.c:575
int16 typlen
Definition: typcache.h:35
#define RANGE_LB_INF
Definition: rangetypes.h:39
bool typbyval
Definition: typcache.h:36
Oid rangetypid
Definition: rangetypes.h:28
char * Pointer
Definition: c.h:245
bool inclusive
Definition: rangetypes.h:64
#define ERROR
Definition: elog.h:43
#define PG_DETOAST_DATUM_PACKED(datum)
Definition: fmgr.h:213
static Size datum_compute_size(Size sz, Datum datum, bool typbyval, char typalign, int16 typlen, char typstorage)
Definition: rangetypes.c:2332
char typstorage
Definition: typcache.h:38
#define RANGE_UB_INC
Definition: rangetypes.h:38
static struct cvec * range(struct vars *v, chr a, chr b, int cases)
Definition: regc_locale.c:416
#define ereport(elevel, rest)
Definition: elog.h:122
bool lower
Definition: rangetypes.h:65
struct TypeCacheEntry * rngelemtype
Definition: typcache.h:84
void * palloc0(Size size)
Definition: mcxt.c:878
static Pointer datum_write(Pointer ptr, Datum datum, bool typbyval, char typalign, int16 typlen, char typstorage)
Definition: rangetypes.c:2358
#define RANGE_LB_INC
Definition: rangetypes.h:37
int range_cmp_bound_values(TypeCacheEntry *typcache, RangeBound *b1, RangeBound *b2)
Definition: rangetypes.c:1842
#define Assert(condition)
Definition: c.h:675
size_t Size
Definition: c.h:356
bool infinite
Definition: rangetypes.h:63
#define MAXALIGN(LEN)
Definition: c.h:588
#define RANGE_UB_INF
Definition: rangetypes.h:40
char typalign
Definition: typcache.h:37
int errmsg(const char *fmt,...)
Definition: elog.c:797
#define SET_VARSIZE(PTR, len)
Definition: postgres.h:328
static int cmp(const chr *x, const chr *y, size_t len)
Definition: regc_locale.c:742
void range_set_contain_empty ( RangeType range)

Definition at line 1713 of file rangetypes.c.

References RANGE_CONTAIN_EMPTY, and VARSIZE.

Referenced by range_super_union().

1714 {
1715  char *flagsp;
1716 
1717  /* flag byte is datum's last byte */
1718  flagsp = (char *) range + VARSIZE(range) - 1;
1719 
1720  *flagsp |= RANGE_CONTAIN_EMPTY;
1721 }
#define VARSIZE(PTR)
Definition: postgres.h:304
#define RANGE_CONTAIN_EMPTY
Definition: rangetypes.h:43