/* * PostRR - src/postrr.h * Copyright (C) 2012 Sebastian 'tokkee' Harl * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * PostgreSQL Round-Robin Extension */ #ifndef POSTRR_H #define POSTRR_H 1 #include #include #define POSTRR_VERSION_MAJOR @POSTRR_VERSION_MAJOR@ #define POSTRR_VERSION_MINOR @POSTRR_VERSION_MINOR@ #define POSTRR_VERSION_PATCH @POSTRR_VERSION_PATCH@ #define POSTRR_VERSION_EXTRA "@POSTRR_VERSION_EXTRA@" #define POSTRR_VERSION_STRING "@POSTRR_VERSION_STRING@" #define POSTRR_VERSION_ENCODE(major, minor, patch) \ ((major) * 10000 + (minor) * 100 + (patch)) #define POSTRR_VERSION POSTRR_VERSION_ENCODE(POSTRR_VERSION_MAJOR, \ POSTRR_VERSION_MINOR, POSTRR_VERSION_PATCH) Datum postrr_version(PG_FUNCTION_ARGS); /* * RRTimeslice data type */ struct rrtimeslice; typedef struct rrtimeslice rrtimeslice_t; #define PG_GETARG_RRTIMESLICE_P(n) (rrtimeslice_t *)PG_GETARG_POINTER(n) #define PG_RETURN_RRTIMESLICE_P(p) PG_RETURN_POINTER(p) Datum rrtimeslice_validate(PG_FUNCTION_ARGS); /* I/O functions */ Datum rrtimeslice_in(PG_FUNCTION_ARGS); Datum rrtimeslice_out(PG_FUNCTION_ARGS); Datum rrtimeslice_typmodin(PG_FUNCTION_ARGS); Datum rrtimeslice_typmodout(PG_FUNCTION_ARGS); /* casts */ Datum rrtimeslice_to_rrtimeslice(PG_FUNCTION_ARGS); Datum timestamptz_to_rrtimeslice(PG_FUNCTION_ARGS); Datum rrtimeslice_to_timestamptz(PG_FUNCTION_ARGS); /* comparison operators */ Datum rrtimeslice_cmp(PG_FUNCTION_ARGS); /* sequence comparison operators */ Datum rrtimeslice_seq_eq(PG_FUNCTION_ARGS); Datum rrtimeslice_seq_ne(PG_FUNCTION_ARGS); Datum rrtimeslice_seq_lt(PG_FUNCTION_ARGS); Datum rrtimeslice_seq_le(PG_FUNCTION_ARGS); Datum rrtimeslice_seq_gt(PG_FUNCTION_ARGS); Datum rrtimeslice_seq_ge(PG_FUNCTION_ARGS); Datum rrtimeslice_seq_cmp(PG_FUNCTION_ARGS); Datum rrtimeslice_seq_hash(PG_FUNCTION_ARGS); /* * internal (not fmgr-callable) functions */ /* * compare two RRTimeslices * * returns: * - -2 if ts1 < ts2 (sequence numbers don't match) * - -1 if ts1 < ts2 (sequence numbers match) * - 0 if ts1 = ts2 * - 1 if ts1 > ts2 (sequence numbers match) * - 2 if ts1 > ts2 (sequence numbers don't match) */ int rrtimeslice_cmp_internal(rrtimeslice_t *ts1, rrtimeslice_t *ts2); /* * compare sequence numbers of two RRTimeslices * * returns: * - -1 if ts1 < ts2 * - 0 if ts1 = ts2 * - 1 if ts1 > ts2 */ int rrtimeslice_seq_cmp_internal(rrtimeslice_t *ts1, rrtimeslice_t *ts2); /* * CData data type */ struct cdata; typedef struct cdata cdata_t; #define PG_GETARG_CDATA_P(n) (cdata_t *)PG_GETARG_POINTER(n) #define PG_RETURN_CDATA_P(p) PG_RETURN_POINTER(p) Datum cdata_validate(PG_FUNCTION_ARGS); /* I/O functions */ Datum cdata_in(PG_FUNCTION_ARGS); Datum cdata_out(PG_FUNCTION_ARGS); Datum cdata_typmodin(PG_FUNCTION_ARGS); Datum cdata_typmodout(PG_FUNCTION_ARGS); /* casts */ Datum cdata_to_cdata(PG_FUNCTION_ARGS); Datum int32_to_cdata(PG_FUNCTION_ARGS); Datum cdata_to_float8(PG_FUNCTION_ARGS); /* aux. functions */ Datum cdata_update(PG_FUNCTION_ARGS); #endif /* ! POSTRR_H */ /* vim: set tw=78 sw=4 ts=4 noexpandtab : */