Code

d9df4af255258897d55faecec38ffd68e73ae6eb
[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 rrtimeslice_to_timestamptz(PG_FUNCTION_ARGS);
84 /* comparison operators */
85 Datum
86 rrtimeslice_cmp(PG_FUNCTION_ARGS);
88 /* sequence comparison operators */
89 Datum
90 rrtimeslice_seq_eq(PG_FUNCTION_ARGS);
91 Datum
92 rrtimeslice_seq_ne(PG_FUNCTION_ARGS);
93 Datum
94 rrtimeslice_seq_lt(PG_FUNCTION_ARGS);
95 Datum
96 rrtimeslice_seq_le(PG_FUNCTION_ARGS);
97 Datum
98 rrtimeslice_seq_gt(PG_FUNCTION_ARGS);
99 Datum
100 rrtimeslice_seq_ge(PG_FUNCTION_ARGS);
101 Datum
102 rrtimeslice_seq_cmp(PG_FUNCTION_ARGS);
103 Datum
104 rrtimeslice_seq_hash(PG_FUNCTION_ARGS);
106 /*
107  * internal (not fmgr-callable) functions
108  */
110 /*
111  * compare two RRTimeslices
112  *
113  * returns:
114  *  - -2 if ts1 < ts2 (sequence numbers don't match)
115  *  - -1 if ts1 < ts2 (sequence numbers match)
116  *  -  0 if ts1 = ts2
117  *  -  1 if ts1 > ts2 (sequence numbers match)
118  *  -  2 if ts1 > ts2 (sequence numbers don't match)
119  */
120 int
121 rrtimeslice_cmp_internal(rrtimeslice_t *ts1, rrtimeslice_t *ts2);
123 /*
124  * compare sequence numbers of two RRTimeslices
125  *
126  * returns:
127  *  - -1 if ts1 < ts2
128  *  -  0 if ts1 = ts2
129  *  -  1 if ts1 > ts2
130  */
131 int
132 rrtimeslice_seq_cmp_internal(rrtimeslice_t *ts1, rrtimeslice_t *ts2);
134 /*
135  * CData data type
136  */
138 struct cdata;
139 typedef struct cdata cdata_t;
141 #define PG_GETARG_CDATA_P(n) (cdata_t *)PG_GETARG_POINTER(n)
142 #define PG_RETURN_CDATA_P(p) PG_RETURN_POINTER(p)
144 Datum
145 cdata_validate(PG_FUNCTION_ARGS);
147 /* I/O functions */
148 Datum
149 cdata_in(PG_FUNCTION_ARGS);
150 Datum
151 cdata_out(PG_FUNCTION_ARGS);
152 Datum
153 cdata_typmodin(PG_FUNCTION_ARGS);
154 Datum
155 cdata_typmodout(PG_FUNCTION_ARGS);
157 /* casts */
158 Datum
159 cdata_to_cdata(PG_FUNCTION_ARGS);
160 Datum
161 int32_to_cdata(PG_FUNCTION_ARGS);
162 Datum
163 cdata_to_float8(PG_FUNCTION_ARGS);
165 /* aux. functions */
166 Datum
167 cdata_update(PG_FUNCTION_ARGS);
169 #endif /* ! POSTRR_H */
171 /* vim: set tw=78 sw=4 ts=4 noexpandtab : */