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:1738
#define RangeIsEmpty(r)
Definition: rangetypes.h:54
#define OidIsValid(objectId)
Definition: c.h:533
FmgrInfo rng_canonical_finfo
Definition: typcache.h:87
Oid fn_oid
Definition: fmgr.h:56
int range_cmp_bound_values(TypeCacheEntry *typcache, RangeBound *b1, RangeBound *b2)
Definition: rangetypes.c:1852
#define Assert(condition)
Definition: c.h:670
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 1887 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().

1888 {
1889  RangeBound lower;
1890  RangeBound upper;
1891 
1892  lower.val = (Datum) 0;
1893  lower.infinite = false;
1894  lower.inclusive = false;
1895  lower.lower = true;
1896 
1897  upper.val = (Datum) 0;
1898  upper.infinite = false;
1899  upper.inclusive = false;
1900  upper.lower = false;
1901 
1902  return make_range(typcache, &lower, &upper, true);
1903 }
RangeType * make_range(TypeCacheEntry *typcache, RangeBound *lower, RangeBound *upper, bool empty)
Definition: rangetypes.c:1738
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:374
bool infinite
Definition: rangetypes.h:63
RangeType* make_range ( TypeCacheEntry typcache,
RangeBound lower,
RangeBound upper,
bool  empty 
)

Definition at line 1738 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().

1740 {
1741  RangeType *range;
1742 
1743  range = range_serialize(typcache, lower, upper, empty);
1744 
1745  /* no need to call canonical on empty ranges ... */
1746  if (OidIsValid(typcache->rng_canonical_finfo.fn_oid) &&
1747  !RangeIsEmpty(range))
1749  RangeTypeGetDatum(range)));
1750 
1751  return range;
1752 }
#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:533
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:1513
FmgrInfo rng_canonical_finfo
Definition: typcache.h:87
Oid fn_oid
Definition: fmgr.h:56
#define FunctionCall1(flinfo, arg1)
Definition: fmgr.h:573
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:1642
#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:1778
#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:1642
#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:1778
#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:1642
#define elog
Definition: elog.h:219
int range_cmp_bound_values ( TypeCacheEntry typcache,
RangeBound b1,
RangeBound b2 
)

Definition at line 1852 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().

1854 {
1855  /*
1856  * First, handle cases involving infinity, which don't require invoking
1857  * the comparison proc.
1858  */
1859  if (b1->infinite && b2->infinite)
1860  {
1861  /*
1862  * Both are infinity, so they are equal unless one is lower and the
1863  * other not.
1864  */
1865  if (b1->lower == b2->lower)
1866  return 0;
1867  else
1868  return b1->lower ? -1 : 1;
1869  }
1870  else if (b1->infinite)
1871  return b1->lower ? -1 : 1;
1872  else if (b2->infinite)
1873  return b2->lower ? 1 : -1;
1874 
1875  /*
1876  * Both boundaries are finite, so compare the held values.
1877  */
1879  typcache->rng_collation,
1880  b1->val, b2->val));
1881 }
FmgrInfo rng_cmp_proc_finfo
Definition: typcache.h:86
#define DatumGetInt32(X)
Definition: postgres.h:480
Datum val
Definition: rangetypes.h:62
Datum FunctionCall2Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2)
Definition: fmgr.c:1306
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 1778 of file rangetypes.c.

References DatumGetInt32, FunctionCall2Coll(), RangeBound::inclusive, RangeBound::infinite, RangeBound::lower, 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().

1779 {
1780  int32 result;
1781 
1782  /*
1783  * First, handle cases involving infinity, which don't require invoking
1784  * the comparison proc.
1785  */
1786  if (b1->infinite && b2->infinite)
1787  {
1788  /*
1789  * Both are infinity, so they are equal unless one is lower and the
1790  * other not.
1791  */
1792  if (b1->lower == b2->lower)
1793  return 0;
1794  else
1795  return b1->lower ? -1 : 1;
1796  }
1797  else if (b1->infinite)
1798  return b1->lower ? -1 : 1;
1799  else if (b2->infinite)
1800  return b2->lower ? 1 : -1;
1801 
1802  /*
1803  * Both boundaries are finite, so compare the held values.
1804  */
1806  typcache->rng_collation,
1807  b1->val, b2->val));
1808 
1809  /*
1810  * If the comparison is anything other than equal, we're done. If they
1811  * compare equal though, we still have to consider whether the boundaries
1812  * are inclusive or exclusive.
1813  */
1814  if (result == 0)
1815  {
1816  if (!b1->inclusive && !b2->inclusive)
1817  {
1818  /* both are exclusive */
1819  if (b1->lower == b2->lower)
1820  return 0;
1821  else
1822  return b1->lower ? 1 : -1;
1823  }
1824  else if (!b1->inclusive)
1825  return b1->lower ? 1 : -1;
1826  else if (!b2->inclusive)
1827  return b2->lower ? -1 : 1;
1828  else
1829  {
1830  /*
1831  * Both are inclusive and the values held are equal, so they are
1832  * equal regardless of whether they are upper or lower boundaries,
1833  * or a mix.
1834  */
1835  return 0;
1836  }
1837  }
1838 
1839  return result;
1840 }
FmgrInfo rng_cmp_proc_finfo
Definition: typcache.h:86
#define DatumGetInt32(X)
Definition: postgres.h:480
Datum val
Definition: rangetypes.h:62
Datum FunctionCall2Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2)
Definition: fmgr.c:1306
signed int int32
Definition: c.h:253
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 2278 of file rangetypes.c.

References range_contains_internal().

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

2279 {
2280  return range_contains_internal(typcache, r2, r1);
2281 }
bool range_contains_internal(TypeCacheEntry *typcache, RangeType *r1, RangeType *r2)
Definition: rangetypes.c:2246
bool range_contains_elem_internal ( TypeCacheEntry typcache,
RangeType r,
Datum  val 
)

Definition at line 2287 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().

2288 {
2289  RangeBound lower;
2290  RangeBound upper;
2291  bool empty;
2292  int32 cmp;
2293 
2294  range_deserialize(typcache, r, &lower, &upper, &empty);
2295 
2296  if (empty)
2297  return false;
2298 
2299  if (!lower.infinite)
2300  {
2302  typcache->rng_collation,
2303  lower.val, val));
2304  if (cmp > 0)
2305  return false;
2306  if (cmp == 0 && !lower.inclusive)
2307  return false;
2308  }
2309 
2310  if (!upper.infinite)
2311  {
2313  typcache->rng_collation,
2314  upper.val, val));
2315  if (cmp < 0)
2316  return false;
2317  if (cmp == 0 && !upper.inclusive)
2318  return false;
2319  }
2320 
2321  return true;
2322 }
FmgrInfo rng_cmp_proc_finfo
Definition: typcache.h:86
#define DatumGetInt32(X)
Definition: postgres.h:480
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:1306
signed int int32
Definition: c.h:253
bool inclusive
Definition: rangetypes.h:64
void range_deserialize(TypeCacheEntry *typcache, RangeType *range, RangeBound *lower, RangeBound *upper, bool *empty)
Definition: rangetypes.c:1642
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 2246 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().

2247 {
2248  RangeBound lower1;
2249  RangeBound upper1;
2250  bool empty1;
2251  RangeBound lower2;
2252  RangeBound upper2;
2253  bool empty2;
2254 
2255  /* Different types should be prevented by ANYRANGE matching rules */
2256  if (RangeTypeGetOid(r1) != RangeTypeGetOid(r2))
2257  elog(ERROR, "range types do not match");
2258 
2259  range_deserialize(typcache, r1, &lower1, &upper1, &empty1);
2260  range_deserialize(typcache, r2, &lower2, &upper2, &empty2);
2261 
2262  /* If either range is empty, the answer is easy */
2263  if (empty2)
2264  return true;
2265  else if (empty1)
2266  return false;
2267 
2268  /* Else we must have lower1 <= lower2 and upper1 >= upper2 */
2269  if (range_cmp_bounds(typcache, &lower1, &lower2) > 0)
2270  return false;
2271  if (range_cmp_bounds(typcache, &upper1, &upper2) < 0)
2272  return false;
2273 
2274  return true;
2275 }
int range_cmp_bounds(TypeCacheEntry *typcache, RangeBound *b1, RangeBound *b2)
Definition: rangetypes.c:1778
#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:1642
#define elog
Definition: elog.h:219
void range_deserialize ( TypeCacheEntry typcache,
RangeType range,
RangeBound lower,
RangeBound upper,
bool empty 
)

Definition at line 1642 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().

1644 {
1645  char flags;
1646  int16 typlen;
1647  bool typbyval;
1648  char typalign;
1649  Pointer ptr;
1650  Datum lbound;
1651  Datum ubound;
1652 
1653  /* assert caller passed the right typcache entry */
1654  Assert(RangeTypeGetOid(range) == typcache->type_id);
1655 
1656  /* fetch the flag byte from datum's last byte */
1657  flags = *((char *) range + VARSIZE(range) - 1);
1658 
1659  /* fetch information about range's element type */
1660  typlen = typcache->rngelemtype->typlen;
1661  typbyval = typcache->rngelemtype->typbyval;
1662  typalign = typcache->rngelemtype->typalign;
1663 
1664  /* initialize data pointer just after the range OID */
1665  ptr = (Pointer) (range + 1);
1666 
1667  /* fetch lower bound, if any */
1668  if (RANGE_HAS_LBOUND(flags))
1669  {
1670  /* att_align_pointer cannot be necessary here */
1671  lbound = fetch_att(ptr, typbyval, typlen);
1672  ptr = (Pointer) att_addlength_pointer(ptr, typlen, ptr);
1673  }
1674  else
1675  lbound = (Datum) 0;
1676 
1677  /* fetch upper bound, if any */
1678  if (RANGE_HAS_UBOUND(flags))
1679  {
1680  ptr = (Pointer) att_align_pointer(ptr, typalign, typlen, ptr);
1681  ubound = fetch_att(ptr, typbyval, typlen);
1682  /* no need for att_addlength_pointer */
1683  }
1684  else
1685  ubound = (Datum) 0;
1686 
1687  /* emit results */
1688 
1689  *empty = (flags & RANGE_EMPTY) != 0;
1690 
1691  lower->val = lbound;
1692  lower->infinite = (flags & RANGE_LB_INF) != 0;
1693  lower->inclusive = (flags & RANGE_LB_INC) != 0;
1694  lower->lower = true;
1695 
1696  upper->val = ubound;
1697  upper->infinite = (flags & RANGE_UB_INF) != 0;
1698  upper->inclusive = (flags & RANGE_UB_INC) != 0;
1699  upper->lower = false;
1700 }
#define RANGE_HAS_UBOUND(flags)
Definition: rangetypes.h:50
signed short int16
Definition: c.h:252
#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:306
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:242
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:374
#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:670
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:1778
#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:1642
#define elog
Definition: elog.h:219
char range_get_flags ( RangeType range)

Definition at line 1709 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().

1710 {
1711  /* fetch the flag byte from datum's last byte */
1712  return *((char *) range + VARSIZE(range) - 1);
1713 }
#define VARSIZE(PTR)
Definition: postgres.h:306
TypeCacheEntry* range_get_typcache ( FunctionCallInfo  fcinfo,
Oid  rngtypid 
)

Definition at line 1489 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().

1490 {
1491  TypeCacheEntry *typcache = (TypeCacheEntry *) fcinfo->flinfo->fn_extra;
1492 
1493  if (typcache == NULL ||
1494  typcache->type_id != rngtypid)
1495  {
1496  typcache = lookup_type_cache(rngtypid, TYPECACHE_RANGE_INFO);
1497  if (typcache->rngelemtype == NULL)
1498  elog(ERROR, "type %u is not a range type", rngtypid);
1499  fcinfo->flinfo->fn_extra = (void *) typcache;
1500  }
1501 
1502  return typcache;
1503 }
#define TYPECACHE_RANGE_INFO
Definition: typcache.h:121
FmgrInfo * flinfo
Definition: fmgr.h:71
#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:226
void * fn_extra
Definition: fmgr.h:61
#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:1778
#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:1642
#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:1778
#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:1642
#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:1778
#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:1642
#define elog
Definition: elog.h:219
RangeType* range_serialize ( TypeCacheEntry typcache,
RangeBound lower,
RangeBound upper,
bool  empty 
)

Definition at line 1513 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().

1515 {
1516  RangeType *range;
1517  int cmp;
1518  Size msize;
1519  Pointer ptr;
1520  int16 typlen;
1521  bool typbyval;
1522  char typalign;
1523  char typstorage;
1524  char flags = 0;
1525 
1526  /*
1527  * Verify range is not invalid on its face, and construct flags value,
1528  * preventing any non-canonical combinations such as infinite+inclusive.
1529  */
1530  Assert(lower->lower);
1531  Assert(!upper->lower);
1532 
1533  if (empty)
1534  flags |= RANGE_EMPTY;
1535  else
1536  {
1537  cmp = range_cmp_bound_values(typcache, lower, upper);
1538 
1539  /* error check: if lower bound value is above upper, it's wrong */
1540  if (cmp > 0)
1541  ereport(ERROR,
1542  (errcode(ERRCODE_DATA_EXCEPTION),
1543  errmsg("range lower bound must be less than or equal to range upper bound")));
1544 
1545  /* if bounds are equal, and not both inclusive, range is empty */
1546  if (cmp == 0 && !(lower->inclusive && upper->inclusive))
1547  flags |= RANGE_EMPTY;
1548  else
1549  {
1550  /* infinite boundaries are never inclusive */
1551  if (lower->infinite)
1552  flags |= RANGE_LB_INF;
1553  else if (lower->inclusive)
1554  flags |= RANGE_LB_INC;
1555  if (upper->infinite)
1556  flags |= RANGE_UB_INF;
1557  else if (upper->inclusive)
1558  flags |= RANGE_UB_INC;
1559  }
1560  }
1561 
1562  /* Fetch information about range's element type */
1563  typlen = typcache->rngelemtype->typlen;
1564  typbyval = typcache->rngelemtype->typbyval;
1565  typalign = typcache->rngelemtype->typalign;
1566  typstorage = typcache->rngelemtype->typstorage;
1567 
1568  /* Count space for varlena header and range type's OID */
1569  msize = sizeof(RangeType);
1570  Assert(msize == MAXALIGN(msize));
1571 
1572  /* Count space for bounds */
1573  if (RANGE_HAS_LBOUND(flags))
1574  {
1575  /*
1576  * Make sure item to be inserted is not toasted. It is essential that
1577  * we not insert an out-of-line toast value pointer into a range
1578  * object, for the same reasons that arrays and records can't contain
1579  * them. It would work to store a compressed-in-line value, but we
1580  * prefer to decompress and then let compression be applied to the
1581  * whole range object if necessary. But, unlike arrays, we do allow
1582  * short-header varlena objects to stay as-is.
1583  */
1584  if (typlen == -1)
1585  lower->val = PointerGetDatum(PG_DETOAST_DATUM_PACKED(lower->val));
1586 
1587  msize = datum_compute_size(msize, lower->val, typbyval, typalign,
1588  typlen, typstorage);
1589  }
1590 
1591  if (RANGE_HAS_UBOUND(flags))
1592  {
1593  /* Make sure item to be inserted is not toasted */
1594  if (typlen == -1)
1595  upper->val = PointerGetDatum(PG_DETOAST_DATUM_PACKED(upper->val));
1596 
1597  msize = datum_compute_size(msize, upper->val, typbyval, typalign,
1598  typlen, typstorage);
1599  }
1600 
1601  /* Add space for flag byte */
1602  msize += sizeof(char);
1603 
1604  /* Note: zero-fill is required here, just as in heap tuples */
1605  range = (RangeType *) palloc0(msize);
1606  SET_VARSIZE(range, msize);
1607 
1608  /* Now fill in the datum */
1609  range->rangetypid = typcache->type_id;
1610 
1611  ptr = (char *) (range + 1);
1612 
1613  if (RANGE_HAS_LBOUND(flags))
1614  {
1615  Assert(lower->lower);
1616  ptr = datum_write(ptr, lower->val, typbyval, typalign, typlen,
1617  typstorage);
1618  }
1619 
1620  if (RANGE_HAS_UBOUND(flags))
1621  {
1622  Assert(!upper->lower);
1623  ptr = datum_write(ptr, upper->val, typbyval, typalign, typlen,
1624  typstorage);
1625  }
1626 
1627  *((char *) ptr) = flags;
1628 
1629  return range;
1630 }
#define RANGE_HAS_UBOUND(flags)
Definition: rangetypes.h:50
signed short int16
Definition: c.h:252
#define RANGE_HAS_LBOUND(flags)
Definition: rangetypes.h:46
#define RANGE_EMPTY
Definition: rangetypes.h:36
#define PointerGetDatum(X)
Definition: postgres.h:564
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:242
bool inclusive
Definition: rangetypes.h:64
#define ERROR
Definition: elog.h:43
#define PG_DETOAST_DATUM_PACKED(datum)
Definition: fmgr.h:204
static Size datum_compute_size(Size sz, Datum datum, bool typbyval, char typalign, int16 typlen, char typstorage)
Definition: rangetypes.c:2342
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:920
static Pointer datum_write(Pointer ptr, Datum datum, bool typbyval, char typalign, int16 typlen, char typstorage)
Definition: rangetypes.c:2368
#define RANGE_LB_INC
Definition: rangetypes.h:37
int range_cmp_bound_values(TypeCacheEntry *typcache, RangeBound *b1, RangeBound *b2)
Definition: rangetypes.c:1852
#define Assert(condition)
Definition: c.h:670
size_t Size
Definition: c.h:352
bool infinite
Definition: rangetypes.h:63
#define MAXALIGN(LEN)
Definition: c.h:583
#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:330
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 1723 of file rangetypes.c.

References RANGE_CONTAIN_EMPTY, and VARSIZE.

Referenced by range_super_union().

1724 {
1725  char *flagsp;
1726 
1727  /* flag byte is datum's last byte */
1728  flagsp = (char *) range + VARSIZE(range) - 1;
1729 
1730  *flagsp |= RANGE_CONTAIN_EMPTY;
1731 }
#define VARSIZE(PTR)
Definition: postgres.h:306
#define RANGE_CONTAIN_EMPTY
Definition: rangetypes.h:43