MobilityDB 1.1
skiplist.h
Go to the documentation of this file.
1/*****************************************************************************
2 *
3 * This MobilityDB code is provided under The PostgreSQL License.
4 * Copyright (c) 2016-2023, Université libre de Bruxelles and MobilityDB
5 * contributors
6 *
7 * MobilityDB includes portions of PostGIS version 3 source code released
8 * under the GNU General Public License (GPLv2 or later).
9 * Copyright (c) 2001-2023, PostGIS contributors
10 *
11 * Permission to use, copy, modify, and distribute this software and its
12 * documentation for any purpose, without fee, and without a written
13 * agreement is hereby granted, provided that the above copyright notice and
14 * this paragraph and the following two paragraphs appear in all copies.
15 *
16 * IN NO EVENT SHALL UNIVERSITE LIBRE DE BRUXELLES BE LIABLE TO ANY PARTY FOR
17 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
18 * LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
19 * EVEN IF UNIVERSITE LIBRE DE BRUXELLES HAS BEEN ADVISED OF THE POSSIBILITY
20 * OF SUCH DAMAGE.
21 *
22 * UNIVERSITE LIBRE DE BRUXELLES SPECIFICALLY DISCLAIMS ANY WARRANTIES,
23 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
24 * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON
25 * AN "AS IS" BASIS, AND UNIVERSITE LIBRE DE BRUXELLES HAS NO OBLIGATIONS TO
26 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 
27 *
28 *****************************************************************************/
29
34#ifndef __PG_SKIPLIST_H__
35#define __PG_SKIPLIST_H__
36
37/* PostgreSQL */
38#include <postgres.h>
39#include <fmgr.h>
40#include <utils/palloc.h>
41/* MEOS */
42#include "general/temporal.h"
43/* MobilityDB */
44#include "pg_general/temporal.h"
45
46/*****************************************************************************/
47
48extern FunctionCallInfo fetch_fcinfo();
49extern void store_fcinfo(FunctionCallInfo fcinfo);
50extern MemoryContext set_aggregation_context(FunctionCallInfo fcinfo);
51extern void unset_aggregation_context(MemoryContext ctx);
52
53/*****************************************************************************/
54
58#define INPUT_AGG_TRANS_STATE(fcinfo, state) \
59 do { \
60 MemoryContext ctx = set_aggregation_context(fcinfo); \
61 state = PG_ARGISNULL(0) ? NULL : (SkipList *) PG_GETARG_POINTER(0); \
62 if (PG_ARGISNULL(1)) \
63 { \
64 if (state) \
65 PG_RETURN_POINTER(state); \
66 else \
67 PG_RETURN_NULL(); \
68 } \
69 unset_aggregation_context(ctx); \
70 } while (0)
71
72#define INPUT_AGG_COMB_STATE(fcinfo, state1, state2) \
73 do { \
74 MemoryContext ctx = set_aggregation_context(fcinfo); \
75 state1 = PG_ARGISNULL(0) ? NULL : (SkipList *) PG_GETARG_POINTER(0); \
76 state2 = PG_ARGISNULL(1) ? NULL : (SkipList *) PG_GETARG_POINTER(1); \
77 if (state1 == NULL && state2 == NULL) \
78 PG_RETURN_NULL(); \
79 unset_aggregation_context(ctx); \
80 } while (0)
81
82/*****************************************************************************/
83
84#endif
MemoryContext set_aggregation_context(FunctionCallInfo fcinfo)
Functions manipulating skiplists.
Definition: skiplist.c:65
void store_fcinfo(FunctionCallInfo fcinfo)
Store in the cache the fcinfo of the external function.
Definition: temporal.c:126
void unset_aggregation_context(MemoryContext ctx)
Switch to the given memory context.
Definition: skiplist.c:78
FunctionCallInfo fetch_fcinfo()
Skiplist data structure used for performing aggregates.
Definition: temporal.c:116