MobilityDB  1.0
temporal_selfuncs.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 __TEMPORAL_SELFUNCS_H__
37 #define __TEMPORAL_SELFUNCS_H__
38 
39 #include <postgres.h>
40 #include <fmgr.h>
41 #include <catalog/pg_operator.h>
42 #include <commands/vacuum.h>
43 #include <utils/lsyscache.h>
44 #include <utils/rangetypes.h>
45 #include <utils/selfuncs.h>
46 #include <utils/typcache.h>
47 
48 #include "temporal.h"
49 #include "tempcache.h"
50 
51 #define BTREE_AM_OID 403
52 
53 #define DEFAULT_TEMP_SELECTIVITY 0.001
54 
55 /*****************************************************************************
56  * Internal selectivity functions for Temporal types.
57  *****************************************************************************/
58 
59 extern Selectivity scalarineqsel(PlannerInfo *root, Oid operator,
60  bool isgt, bool iseq, VariableStatData *vardata, Datum constval,
61  Oid consttype);
62 extern Selectivity temporal_sel_internal(PlannerInfo *root, VariableStatData *vardata,
63  Period *period, CachedOp cachedOp);
64 
65 
66 /*****************************************************************************
67  * Some other helper functions.
68  *****************************************************************************/
69 
70 #if POSTGRESQL_VERSION_NUMBER < 120000
71 extern double var_eq_const(VariableStatData *vardata, Oid operator,
72  Datum constval, bool constisnull, bool varonleft, bool negate);
73 #endif
74 
75 /*****************************************************************************/
76 
77 extern Datum temporal_sel(PG_FUNCTION_ARGS);
78 extern Datum temporal_joinsel(PG_FUNCTION_ARGS);
79 
80 /*****************************************************************************/
81 
82 #endif
Structure to represent periods.
Definition: timetypes.h:52
double var_eq_const(VariableStatData *vardata, Oid operator, Datum constval, bool constisnull, bool varonleft, bool negate)
Equal selectivity for var = const case.
Definition: temporal_selfuncs.c:94
Datum temporal_joinsel(PG_FUNCTION_ARGS)
Definition: temporal_selfuncs.c:477
Selectivity temporal_sel_internal(PlannerInfo *root, VariableStatData *vardata, Period *period, CachedOp cachedOp)
Returns an estimate of the selectivity of the search period and the operator for columns of temporal ...
Definition: temporal_selfuncs.c:342
Basic functions for temporal types of any subtype.
Datum temporal_sel(PG_FUNCTION_ARGS)
Estimate the selectivity value of the operators for temporal types whose bounding box is a period...
Definition: temporal_selfuncs.c:391
Functions for building a cache of type and operator Oids.
CachedOp
Enumeration that defines the classes of Boolean operators used in MobilityDB.
Definition: tempcache.h:108
Selectivity scalarineqsel(PlannerInfo *root, Oid operator, bool isgt, bool iseq, VariableStatData *vardata, Datum constval, Oid consttype)