MobilityDB  1.0
rangetypes_ext.h
Go to the documentation of this file.
1 /*****************************************************************************
2  *
3  * This MobilityDB code is provided under The PostgreSQL License.
4  *
5  * Copyright (c) 2016-2021, Université libre de Bruxelles and MobilityDB
6  * contributors
7  *
8  * MobilityDB includes portions of PostGIS version 3 source code released
9  * under the GNU General Public License (GPLv2 or later).
10  * Copyright (c) 2001-2021, PostGIS contributors
11  *
12  * Permission to use, copy, modify, and distribute this software and its
13  * documentation for any purpose, without fee, and without a written
14  * agreement is hereby granted, provided that the above copyright notice and
15  * this paragraph and the following two paragraphs appear in all copies.
16  *
17  * IN NO EVENT SHALL UNIVERSITE LIBRE DE BRUXELLES BE LIABLE TO ANY PARTY FOR
18  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
19  * LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
20  * EVEN IF UNIVERSITE LIBRE DE BRUXELLES HAS BEEN ADVISED OF THE POSSIBILITY
21  * OF SUCH DAMAGE.
22  *
23  * UNIVERSITE LIBRE DE BRUXELLES SPECIFICALLY DISCLAIMS ANY WARRANTIES,
24  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
25  * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON
26  * AN "AS IS" BASIS, AND UNIVERSITE LIBRE DE BRUXELLES HAS NO OBLIGATIONS TO
27  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 
28  *
29  *****************************************************************************/
30 
36 #ifndef __RANGETYPES_EXT_H__
37 #define __RANGETYPES_EXT_H__
38 
39 #include <postgres.h>
40 #include <catalog/pg_type.h>
41 #include <utils/rangetypes.h>
42 
43 #include "temporaltypes.h"
44 
45 /*****************************************************************************/
46 
47 extern const char *range_to_string(const RangeType *range);
48 extern Datum lower_datum(const RangeType *range);
49 extern Datum upper_datum(const RangeType *range);
50 
51 #if POSTGRESQL_VERSION_NUMBER < 130000
52 extern bool lower_inc(RangeType *range);
53 extern bool upper_inc(RangeType *range);
54 #else
55 extern bool lower_inc(const RangeType *range);
56 extern bool upper_inc(const RangeType *range);
57 #endif
58 
59 extern void range_bounds(const RangeType *range, double *xmin, double *xmax);
60 extern RangeType *range_make(Datum from, Datum to, bool lower_inc,
61  bool upper_inc, Oid basetypid);
62 extern RangeType **rangearr_normalize(RangeType **ranges, int count,
63  int *newcount);
64 
65 extern Datum intrange_canonical(PG_FUNCTION_ARGS);
66 
67 extern Datum range_left_elem(PG_FUNCTION_ARGS);
68 extern Datum range_overleft_elem(PG_FUNCTION_ARGS);
69 extern Datum range_right_elem(PG_FUNCTION_ARGS);
70 extern Datum range_overright_elem(PG_FUNCTION_ARGS);
71 extern Datum range_adjacent_elem(PG_FUNCTION_ARGS);
72 
73 extern Datum elem_left_range(PG_FUNCTION_ARGS);
74 extern Datum elem_overleft_range(PG_FUNCTION_ARGS);
75 extern Datum elem_right_range(PG_FUNCTION_ARGS);
76 extern Datum elem_overright_range(PG_FUNCTION_ARGS);
77 extern Datum elem_adjacent_range(PG_FUNCTION_ARGS);
78 
79 /*****************************************************************************/
80 
81 #endif
General functions for temporal types.
Datum lower_datum(const RangeType *range)
Returns the string representation of the range value, used for debugging.
Definition: rangetypes_ext.c:68
RangeType * range_make(Datum from, Datum to, bool lower_inc, bool upper_inc, Oid basetypid)
Construct a range value from given arguments.
Definition: rangetypes_ext.c:138
Datum range_adjacent_elem(PG_FUNCTION_ARGS)
Returns true if the range value and the value are adjacent.
Definition: rangetypes_ext.c:509
Datum intrange_canonical(PG_FUNCTION_ARGS)
Canonical function for defining the intrange type.
Definition: rangetypes_ext.c:329
const char * range_to_string(const RangeType *range)
void range_bounds(const RangeType *range, double *xmin, double *xmax)
Get the bounds of the range as double values.
Definition: rangetypes_ext.c:119
Datum range_left_elem(PG_FUNCTION_ARGS)
Returns true if the range value is strictly to the left of the value.
Definition: rangetypes_ext.c:469
Datum range_overright_elem(PG_FUNCTION_ARGS)
Returns true if the range value does not extend to the left of the value.
Definition: rangetypes_ext.c:499
RangeType ** rangearr_normalize(RangeType **ranges, int count, int *newcount)
Normalize an array of ranges, which may be non contiguous.
Definition: rangetypes_ext.c:233
Datum elem_adjacent_range(PG_FUNCTION_ARGS)
Returns true if the value and the range value are adjacent.
Definition: rangetypes_ext.c:597
Datum elem_overright_range(PG_FUNCTION_ARGS)
Returns true if the value does not extend to the left of the range value.
Definition: rangetypes_ext.c:587
Datum elem_overleft_range(PG_FUNCTION_ARGS)
Returns true if the value does not extend to the right of the range value.
Definition: rangetypes_ext.c:567
bool upper_inc(RangeType *range)
Returns true if the upper bound of the range value is inclusive.
Definition: rangetypes_ext.c:104
Datum range_overleft_elem(PG_FUNCTION_ARGS)
Returns true if the range value does not extend to the right of the value.
Definition: rangetypes_ext.c:479
Datum upper_datum(const RangeType *range)
Returns the upper bound of the range value.
Definition: rangetypes_ext.c:77
bool lower_inc(RangeType *range)
Returns true if the lower bound of the range value is inclusive.
Definition: rangetypes_ext.c:91
Datum range_right_elem(PG_FUNCTION_ARGS)
Returns true if the range value is strictly to the right of the value.
Definition: rangetypes_ext.c:489
Datum elem_left_range(PG_FUNCTION_ARGS)
Returns true if the value is strictly to the left of the range value.
Definition: rangetypes_ext.c:557
Datum elem_right_range(PG_FUNCTION_ARGS)
Returns true if the value is strictly to the right of the range value.
Definition: rangetypes_ext.c:577