Code

RRTimeslice: Added cast from timestamptz to rrtimeslice.
[postrr.git] / src / postrr.h.in
1 /*
2  * PostRR - src/postrr.h
3  * Copyright (C) 2012 Sebastian 'tokkee' Harl <sh@tokkee.org>
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
19  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
28 /*
29  * PostgreSQL Round-Robin Extension
30  */
32 #ifndef POSTRR_H
33 #define POSTRR_H 1
35 #include <postgres.h>
36 #include <fmgr.h>
38 #define POSTRR_VERSION_MAJOR @POSTRR_VERSION_MAJOR@
39 #define POSTRR_VERSION_MINOR @POSTRR_VERSION_MINOR@
40 #define POSTRR_VERSION_PATCH @POSTRR_VERSION_PATCH@
42 #define POSTRR_VERSION_EXTRA "@POSTRR_VERSION_EXTRA@"
44 #define POSTRR_VERSION_STRING "@POSTRR_VERSION_STRING@"
46 #define POSTRR_VERSION_ENCODE(major, minor, patch) \
47         ((major) * 10000 + (minor) * 100 + (patch))
49 #define POSTRR_VERSION POSTRR_VERSION_ENCODE(POSTRR_VERSION_MAJOR, \
50                 POSTRR_VERSION_MINOR, POSTRR_VERSION_PATCH)
52 Datum
53 postrr_version(PG_FUNCTION_ARGS);
55 /*
56  * RRTimeslice data type
57  */
59 struct rrtimeslice;
60 typedef struct rrtimeslice rrtimeslice_t;
62 #define PG_GETARG_RRTIMESLICE_P(n) (rrtimeslice_t *)PG_GETARG_POINTER(n)
63 #define PG_RETURN_RRTIMESLICE_P(p) PG_RETURN_POINTER(p)
65 Datum
66 rrtimeslice_validate(PG_FUNCTION_ARGS);
68 /* I/O functions */
69 Datum
70 rrtimeslice_in(PG_FUNCTION_ARGS);
71 Datum
72 rrtimeslice_out(PG_FUNCTION_ARGS);
73 Datum
74 rrtimeslice_typmodin(PG_FUNCTION_ARGS);
75 Datum
76 rrtimeslice_typmodout(PG_FUNCTION_ARGS);
78 /* casts */
79 Datum
80 rrtimeslice_to_rrtimeslice(PG_FUNCTION_ARGS);
81 Datum
82 timestamptz_to_rrtimeslice(PG_FUNCTION_ARGS);
83 Datum
84 rrtimeslice_to_timestamptz(PG_FUNCTION_ARGS);
86 /* comparison operators */
87 Datum
88 rrtimeslice_cmp(PG_FUNCTION_ARGS);
90 /* sequence comparison operators */
91 Datum
92 rrtimeslice_seq_eq(PG_FUNCTION_ARGS);
93 Datum
94 rrtimeslice_seq_ne(PG_FUNCTION_ARGS);
95 Datum
96 rrtimeslice_seq_lt(PG_FUNCTION_ARGS);
97 Datum
98 rrtimeslice_seq_le(PG_FUNCTION_ARGS);
99 Datum
100 rrtimeslice_seq_gt(PG_FUNCTION_ARGS);
101 Datum
102 rrtimeslice_seq_ge(PG_FUNCTION_ARGS);
103 Datum
104 rrtimeslice_seq_cmp(PG_FUNCTION_ARGS);
105 Datum
106 rrtimeslice_seq_hash(PG_FUNCTION_ARGS);
108 /*
109  * internal (not fmgr-callable) functions
110  */
112 /*
113  * compare two RRTimeslices
114  *
115  * returns:
116  *  - -2 if ts1 < ts2 (sequence numbers don't match)
117  *  - -1 if ts1 < ts2 (sequence numbers match)
118  *  -  0 if ts1 = ts2
119  *  -  1 if ts1 > ts2 (sequence numbers match)
120  *  -  2 if ts1 > ts2 (sequence numbers don't match)
121  */
122 int
123 rrtimeslice_cmp_internal(rrtimeslice_t *ts1, rrtimeslice_t *ts2);
125 /*
126  * compare sequence numbers of two RRTimeslices
127  *
128  * returns:
129  *  - -1 if ts1 < ts2
130  *  -  0 if ts1 = ts2
131  *  -  1 if ts1 > ts2
132  */
133 int
134 rrtimeslice_seq_cmp_internal(rrtimeslice_t *ts1, rrtimeslice_t *ts2);
136 /*
137  * CData data type
138  */
140 struct cdata;
141 typedef struct cdata cdata_t;
143 #define PG_GETARG_CDATA_P(n) (cdata_t *)PG_GETARG_POINTER(n)
144 #define PG_RETURN_CDATA_P(p) PG_RETURN_POINTER(p)
146 Datum
147 cdata_validate(PG_FUNCTION_ARGS);
149 /* I/O functions */
150 Datum
151 cdata_in(PG_FUNCTION_ARGS);
152 Datum
153 cdata_out(PG_FUNCTION_ARGS);
154 Datum
155 cdata_typmodin(PG_FUNCTION_ARGS);
156 Datum
157 cdata_typmodout(PG_FUNCTION_ARGS);
159 /* casts */
160 Datum
161 cdata_to_cdata(PG_FUNCTION_ARGS);
162 Datum
163 int32_to_cdata(PG_FUNCTION_ARGS);
164 Datum
165 cdata_to_float8(PG_FUNCTION_ARGS);
167 /* aux. functions */
168 Datum
169 cdata_update(PG_FUNCTION_ARGS);
171 #endif /* ! POSTRR_H */
173 /* vim: set tw=78 sw=4 ts=4 noexpandtab : */