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 DatumGetRangeTypeP(X)   ((RangeType *) PG_DETOAST_DATUM(X))
 
#define DatumGetRangeTypePCopy(X)   ((RangeType *) PG_DETOAST_DATUM_COPY(X))
 
#define RangeTypePGetDatum(X)   PointerGetDatum(X)
 
#define PG_GETARG_RANGE_P(n)   DatumGetRangeTypeP(PG_GETARG_DATUM(n))
 
#define PG_GETARG_RANGE_P_COPY(n)   DatumGetRangeTypePCopy(PG_GETARG_DATUM(n))
 
#define PG_RETURN_RANGE_P(x)   return RangeTypePGetDatum(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 DatumGetRangeTypePCopy (   X)    ((RangeType *) PG_DETOAST_DATUM_COPY(X))

Definition at line 72 of file rangetypes.h.

#define PG_GETARG_RANGE_P_COPY (   n)    DatumGetRangeTypePCopy(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(), hash_range_extended(), 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(), hash_range_extended(), 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:1792
#define RangeIsEmpty(r)
Definition: rangetypes.h:54
#define OidIsValid(objectId)
Definition: c.h:532
FmgrInfo rng_canonical_finfo
Definition: typcache.h:91
Oid fn_oid
Definition: fmgr.h:59
int range_cmp_bound_values(TypeCacheEntry *typcache, RangeBound *b1, RangeBound *b2)
Definition: rangetypes.c:1906
#define Assert(condition)
Definition: c.h:681
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 1941 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().

1942 {
1943  RangeBound lower;
1944  RangeBound upper;
1945 
1946  lower.val = (Datum) 0;
1947  lower.infinite = false;
1948  lower.inclusive = false;
1949  lower.lower = true;
1950 
1951  upper.val = (Datum) 0;
1952  upper.infinite = false;
1953  upper.inclusive = false;
1954  upper.lower = false;
1955 
1956  return make_range(typcache, &lower, &upper, true);
1957 }
RangeType * make_range(TypeCacheEntry *typcache, RangeBound *lower, RangeBound *upper, bool empty)
Definition: rangetypes.c:1792
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 1792 of file rangetypes.c.

References DatumGetRangeTypeP, FmgrInfo::fn_oid, FunctionCall1, OidIsValid, range(), range_serialize(), RangeIsEmpty, RangeTypePGetDatum, 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().

1794 {
1795  RangeType *range;
1796 
1797  range = range_serialize(typcache, lower, upper, empty);
1798 
1799  /* no need to call canonical on empty ranges ... */
1800  if (OidIsValid(typcache->rng_canonical_finfo.fn_oid) &&
1801  !RangeIsEmpty(range))
1803  RangeTypePGetDatum(range)));
1804 
1805  return range;
1806 }
#define RangeIsEmpty(r)
Definition: rangetypes.h:54
#define OidIsValid(objectId)
Definition: c.h:532
#define RangeTypePGetDatum(X)
Definition: rangetypes.h:73
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:1567
FmgrInfo rng_canonical_finfo
Definition: typcache.h:91
Oid fn_oid
Definition: fmgr.h:59
#define DatumGetRangeTypeP(X)
Definition: rangetypes.h:71
#define FunctionCall1(flinfo, arg1)
Definition: fmgr.h:603
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:1696
#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:1832
#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:1696
#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:1832
#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:1696
#define elog
Definition: elog.h:219
int range_cmp_bound_values ( TypeCacheEntry typcache,
RangeBound b1,
RangeBound b2 
)

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

1908 {
1909  /*
1910  * First, handle cases involving infinity, which don't require invoking
1911  * the comparison proc.
1912  */
1913  if (b1->infinite && b2->infinite)
1914  {
1915  /*
1916  * Both are infinity, so they are equal unless one is lower and the
1917  * other not.
1918  */
1919  if (b1->lower == b2->lower)
1920  return 0;
1921  else
1922  return b1->lower ? -1 : 1;
1923  }
1924  else if (b1->infinite)
1925  return b1->lower ? -1 : 1;
1926  else if (b2->infinite)
1927  return b2->lower ? 1 : -1;
1928 
1929  /*
1930  * Both boundaries are finite, so compare the held values.
1931  */
1933  typcache->rng_collation,
1934  b1->val, b2->val));
1935 }
FmgrInfo rng_cmp_proc_finfo
Definition: typcache.h:90
#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:1042
bool lower
Definition: rangetypes.h:65
bool infinite
Definition: rangetypes.h:63
Oid rng_collation
Definition: typcache.h:89
int range_cmp_bounds ( TypeCacheEntry typcache,
RangeBound b1,
RangeBound b2 
)

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

1833 {
1834  int32 result;
1835 
1836  /*
1837  * First, handle cases involving infinity, which don't require invoking
1838  * the comparison proc.
1839  */
1840  if (b1->infinite && b2->infinite)
1841  {
1842  /*
1843  * Both are infinity, so they are equal unless one is lower and the
1844  * other not.
1845  */
1846  if (b1->lower == b2->lower)
1847  return 0;
1848  else
1849  return b1->lower ? -1 : 1;
1850  }
1851  else if (b1->infinite)
1852  return b1->lower ? -1 : 1;
1853  else if (b2->infinite)
1854  return b2->lower ? 1 : -1;
1855 
1856  /*
1857  * Both boundaries are finite, so compare the held values.
1858  */
1860  typcache->rng_collation,
1861  b1->val, b2->val));
1862 
1863  /*
1864  * If the comparison is anything other than equal, we're done. If they
1865  * compare equal though, we still have to consider whether the boundaries
1866  * are inclusive or exclusive.
1867  */
1868  if (result == 0)
1869  {
1870  if (!b1->inclusive && !b2->inclusive)
1871  {
1872  /* both are exclusive */
1873  if (b1->lower == b2->lower)
1874  return 0;
1875  else
1876  return b1->lower ? 1 : -1;
1877  }
1878  else if (!b1->inclusive)
1879  return b1->lower ? 1 : -1;
1880  else if (!b2->inclusive)
1881  return b2->lower ? -1 : 1;
1882  else
1883  {
1884  /*
1885  * Both are inclusive and the values held are equal, so they are
1886  * equal regardless of whether they are upper or lower boundaries,
1887  * or a mix.
1888  */
1889  return 0;
1890  }
1891  }
1892 
1893  return result;
1894 }
FmgrInfo rng_cmp_proc_finfo
Definition: typcache.h:90
#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:1042
signed int int32
Definition: c.h:246
bool inclusive
Definition: rangetypes.h:64
bool lower
Definition: rangetypes.h:65
bool infinite
Definition: rangetypes.h:63
Oid rng_collation
Definition: typcache.h:89
bool range_contained_by_internal ( TypeCacheEntry typcache,
RangeType r1,
RangeType r2 
)

Definition at line 2332 of file rangetypes.c.

References range_contains_internal().

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

2333 {
2334  return range_contains_internal(typcache, r2, r1);
2335 }
bool range_contains_internal(TypeCacheEntry *typcache, RangeType *r1, RangeType *r2)
Definition: rangetypes.c:2300
bool range_contains_elem_internal ( TypeCacheEntry typcache,
RangeType r,
Datum  val 
)

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

2342 {
2343  RangeBound lower;
2344  RangeBound upper;
2345  bool empty;
2346  int32 cmp;
2347 
2348  range_deserialize(typcache, r, &lower, &upper, &empty);
2349 
2350  if (empty)
2351  return false;
2352 
2353  if (!lower.infinite)
2354  {
2356  typcache->rng_collation,
2357  lower.val, val));
2358  if (cmp > 0)
2359  return false;
2360  if (cmp == 0 && !lower.inclusive)
2361  return false;
2362  }
2363 
2364  if (!upper.infinite)
2365  {
2367  typcache->rng_collation,
2368  upper.val, val));
2369  if (cmp < 0)
2370  return false;
2371  if (cmp == 0 && !upper.inclusive)
2372  return false;
2373  }
2374 
2375  return true;
2376 }
FmgrInfo rng_cmp_proc_finfo
Definition: typcache.h:90
#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:1042
signed int int32
Definition: c.h:246
bool inclusive
Definition: rangetypes.h:64
void range_deserialize(TypeCacheEntry *typcache, RangeType *range, RangeBound *lower, RangeBound *upper, bool *empty)
Definition: rangetypes.c:1696
bool infinite
Definition: rangetypes.h:63
Oid rng_collation
Definition: typcache.h:89
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 2300 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().

2301 {
2302  RangeBound lower1;
2303  RangeBound upper1;
2304  bool empty1;
2305  RangeBound lower2;
2306  RangeBound upper2;
2307  bool empty2;
2308 
2309  /* Different types should be prevented by ANYRANGE matching rules */
2310  if (RangeTypeGetOid(r1) != RangeTypeGetOid(r2))
2311  elog(ERROR, "range types do not match");
2312 
2313  range_deserialize(typcache, r1, &lower1, &upper1, &empty1);
2314  range_deserialize(typcache, r2, &lower2, &upper2, &empty2);
2315 
2316  /* If either range is empty, the answer is easy */
2317  if (empty2)
2318  return true;
2319  else if (empty1)
2320  return false;
2321 
2322  /* Else we must have lower1 <= lower2 and upper1 >= upper2 */
2323  if (range_cmp_bounds(typcache, &lower1, &lower2) > 0)
2324  return false;
2325  if (range_cmp_bounds(typcache, &upper1, &upper2) < 0)
2326  return false;
2327 
2328  return true;
2329 }
int range_cmp_bounds(TypeCacheEntry *typcache, RangeBound *b1, RangeBound *b2)
Definition: rangetypes.c:1832
#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:1696
#define elog
Definition: elog.h:219
void range_deserialize ( TypeCacheEntry typcache,
RangeType range,
RangeBound lower,
RangeBound upper,
bool empty 
)

Definition at line 1696 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(), hash_range_extended(), 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(), and spg_range_quad_picksplit().

1698 {
1699  char flags;
1700  int16 typlen;
1701  bool typbyval;
1702  char typalign;
1703  Pointer ptr;
1704  Datum lbound;
1705  Datum ubound;
1706 
1707  /* assert caller passed the right typcache entry */
1708  Assert(RangeTypeGetOid(range) == typcache->type_id);
1709 
1710  /* fetch the flag byte from datum's last byte */
1711  flags = *((char *) range + VARSIZE(range) - 1);
1712 
1713  /* fetch information about range's element type */
1714  typlen = typcache->rngelemtype->typlen;
1715  typbyval = typcache->rngelemtype->typbyval;
1716  typalign = typcache->rngelemtype->typalign;
1717 
1718  /* initialize data pointer just after the range OID */
1719  ptr = (Pointer) (range + 1);
1720 
1721  /* fetch lower bound, if any */
1722  if (RANGE_HAS_LBOUND(flags))
1723  {
1724  /* att_align_pointer cannot be necessary here */
1725  lbound = fetch_att(ptr, typbyval, typlen);
1726  ptr = (Pointer) att_addlength_pointer(ptr, typlen, ptr);
1727  }
1728  else
1729  lbound = (Datum) 0;
1730 
1731  /* fetch upper bound, if any */
1732  if (RANGE_HAS_UBOUND(flags))
1733  {
1734  ptr = (Pointer) att_align_pointer(ptr, typalign, typlen, ptr);
1735  ubound = fetch_att(ptr, typbyval, typlen);
1736  /* no need for att_addlength_pointer */
1737  }
1738  else
1739  ubound = (Datum) 0;
1740 
1741  /* emit results */
1742 
1743  *empty = (flags & RANGE_EMPTY) != 0;
1744 
1745  lower->val = lbound;
1746  lower->infinite = (flags & RANGE_LB_INF) != 0;
1747  lower->inclusive = (flags & RANGE_LB_INC) != 0;
1748  lower->lower = true;
1749 
1750  upper->val = ubound;
1751  upper->infinite = (flags & RANGE_UB_INF) != 0;
1752  upper->inclusive = (flags & RANGE_UB_INC) != 0;
1753  upper->lower = false;
1754 }
#define RANGE_HAS_UBOUND(flags)
Definition: rangetypes.h:50
signed short int16
Definition: c.h:245
#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:37
#define RANGE_LB_INF
Definition: rangetypes.h:39
bool typbyval
Definition: typcache.h:38
char * Pointer
Definition: c.h:235
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:88
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:681
bool infinite
Definition: rangetypes.h:63
#define RANGE_UB_INF
Definition: rangetypes.h:40
char typalign
Definition: typcache.h:39
#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:1832
#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:1696
#define elog
Definition: elog.h:219
char range_get_flags ( RangeType range)

Definition at line 1763 of file rangetypes.c.

References VARSIZE.

Referenced by get_gist_range_class(), hash_range(), hash_range_extended(), 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().

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

Definition at line 1543 of file rangetypes.c.

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

Referenced by daterange_canonical(), elem_contained_by_range(), hash_range(), hash_range_extended(), 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().

1544 {
1545  TypeCacheEntry *typcache = (TypeCacheEntry *) fcinfo->flinfo->fn_extra;
1546 
1547  if (typcache == NULL ||
1548  typcache->type_id != rngtypid)
1549  {
1550  typcache = lookup_type_cache(rngtypid, TYPECACHE_RANGE_INFO);
1551  if (typcache->rngelemtype == NULL)
1552  elog(ERROR, "type %u is not a range type", rngtypid);
1553  fcinfo->flinfo->fn_extra = (void *) typcache;
1554  }
1555 
1556  return typcache;
1557 }
#define TYPECACHE_RANGE_INFO
Definition: typcache.h:125
FmgrInfo * flinfo
Definition: fmgr.h:79
#define ERROR
Definition: elog.h:43
struct TypeCacheEntry * rngelemtype
Definition: typcache.h:88
TypeCacheEntry * lookup_type_cache(Oid type_id, int flags)
Definition: typcache.c:305
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:1832
#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:1696
#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:1832
#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:1696
#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:1832
#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:1696
#define elog
Definition: elog.h:219
RangeType* range_serialize ( TypeCacheEntry typcache,
RangeBound lower,
RangeBound upper,
bool  empty 
)

Definition at line 1567 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(), and spg_range_quad_picksplit().

1569 {
1570  RangeType *range;
1571  int cmp;
1572  Size msize;
1573  Pointer ptr;
1574  int16 typlen;
1575  bool typbyval;
1576  char typalign;
1577  char typstorage;
1578  char flags = 0;
1579 
1580  /*
1581  * Verify range is not invalid on its face, and construct flags value,
1582  * preventing any non-canonical combinations such as infinite+inclusive.
1583  */
1584  Assert(lower->lower);
1585  Assert(!upper->lower);
1586 
1587  if (empty)
1588  flags |= RANGE_EMPTY;
1589  else
1590  {
1591  cmp = range_cmp_bound_values(typcache, lower, upper);
1592 
1593  /* error check: if lower bound value is above upper, it's wrong */
1594  if (cmp > 0)
1595  ereport(ERROR,
1596  (errcode(ERRCODE_DATA_EXCEPTION),
1597  errmsg("range lower bound must be less than or equal to range upper bound")));
1598 
1599  /* if bounds are equal, and not both inclusive, range is empty */
1600  if (cmp == 0 && !(lower->inclusive && upper->inclusive))
1601  flags |= RANGE_EMPTY;
1602  else
1603  {
1604  /* infinite boundaries are never inclusive */
1605  if (lower->infinite)
1606  flags |= RANGE_LB_INF;
1607  else if (lower->inclusive)
1608  flags |= RANGE_LB_INC;
1609  if (upper->infinite)
1610  flags |= RANGE_UB_INF;
1611  else if (upper->inclusive)
1612  flags |= RANGE_UB_INC;
1613  }
1614  }
1615 
1616  /* Fetch information about range's element type */
1617  typlen = typcache->rngelemtype->typlen;
1618  typbyval = typcache->rngelemtype->typbyval;
1619  typalign = typcache->rngelemtype->typalign;
1620  typstorage = typcache->rngelemtype->typstorage;
1621 
1622  /* Count space for varlena header and range type's OID */
1623  msize = sizeof(RangeType);
1624  Assert(msize == MAXALIGN(msize));
1625 
1626  /* Count space for bounds */
1627  if (RANGE_HAS_LBOUND(flags))
1628  {
1629  /*
1630  * Make sure item to be inserted is not toasted. It is essential that
1631  * we not insert an out-of-line toast value pointer into a range
1632  * object, for the same reasons that arrays and records can't contain
1633  * them. It would work to store a compressed-in-line value, but we
1634  * prefer to decompress and then let compression be applied to the
1635  * whole range object if necessary. But, unlike arrays, we do allow
1636  * short-header varlena objects to stay as-is.
1637  */
1638  if (typlen == -1)
1639  lower->val = PointerGetDatum(PG_DETOAST_DATUM_PACKED(lower->val));
1640 
1641  msize = datum_compute_size(msize, lower->val, typbyval, typalign,
1642  typlen, typstorage);
1643  }
1644 
1645  if (RANGE_HAS_UBOUND(flags))
1646  {
1647  /* Make sure item to be inserted is not toasted */
1648  if (typlen == -1)
1649  upper->val = PointerGetDatum(PG_DETOAST_DATUM_PACKED(upper->val));
1650 
1651  msize = datum_compute_size(msize, upper->val, typbyval, typalign,
1652  typlen, typstorage);
1653  }
1654 
1655  /* Add space for flag byte */
1656  msize += sizeof(char);
1657 
1658  /* Note: zero-fill is required here, just as in heap tuples */
1659  range = (RangeType *) palloc0(msize);
1660  SET_VARSIZE(range, msize);
1661 
1662  /* Now fill in the datum */
1663  range->rangetypid = typcache->type_id;
1664 
1665  ptr = (char *) (range + 1);
1666 
1667  if (RANGE_HAS_LBOUND(flags))
1668  {
1669  Assert(lower->lower);
1670  ptr = datum_write(ptr, lower->val, typbyval, typalign, typlen,
1671  typstorage);
1672  }
1673 
1674  if (RANGE_HAS_UBOUND(flags))
1675  {
1676  Assert(!upper->lower);
1677  ptr = datum_write(ptr, upper->val, typbyval, typalign, typlen,
1678  typstorage);
1679  }
1680 
1681  *((char *) ptr) = flags;
1682 
1683  return range;
1684 }
#define RANGE_HAS_UBOUND(flags)
Definition: rangetypes.h:50
signed short int16
Definition: c.h:245
#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:37
#define RANGE_LB_INF
Definition: rangetypes.h:39
bool typbyval
Definition: typcache.h:38
Oid rangetypid
Definition: rangetypes.h:28
char * Pointer
Definition: c.h:235
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:2396
char typstorage
Definition: typcache.h:40
#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:88
void * palloc0(Size size)
Definition: mcxt.c:877
static Pointer datum_write(Pointer ptr, Datum datum, bool typbyval, char typalign, int16 typlen, char typstorage)
Definition: rangetypes.c:2422
#define RANGE_LB_INC
Definition: rangetypes.h:37
int range_cmp_bound_values(TypeCacheEntry *typcache, RangeBound *b1, RangeBound *b2)
Definition: rangetypes.c:1906
#define Assert(condition)
Definition: c.h:681
size_t Size
Definition: c.h:350
bool infinite
Definition: rangetypes.h:63
#define MAXALIGN(LEN)
Definition: c.h:576
#define RANGE_UB_INF
Definition: rangetypes.h:40
char typalign
Definition: typcache.h:39
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 1777 of file rangetypes.c.

References RANGE_CONTAIN_EMPTY, and VARSIZE.

Referenced by range_super_union().

1778 {
1779  char *flagsp;
1780 
1781  /* flag byte is datum's last byte */
1782  flagsp = (char *) range + VARSIZE(range) - 1;
1783 
1784  *flagsp |= RANGE_CONTAIN_EMPTY;
1785 }
#define VARSIZE(PTR)
Definition: postgres.h:304
#define RANGE_CONTAIN_EMPTY
Definition: rangetypes.h:43