summaryrefslogtreecommitdiff
path: root/src/include/utils
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2011-11-14 13:59:34 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2011-11-14 13:59:34 -0500
commitf1585362856d4da17113ba2e4ba46cf83cba0cf2 (patch)
treea7bd6b1823d7c562cd6724c70c9f0d70ba207e6f /src/include/utils
parent1a2586c1d0d458235b3241834f3f755410301c64 (diff)
Fix copyright notices, other minor editing in new range-types code.
No functional changes in this commit (except I could not resist the temptation to re-word a couple of error messages). This is just manual cleanup after pgindent to make the code look reasonably like other PG code, in preparation for more detailed code review to come.
Diffstat (limited to 'src/include/utils')
-rw-r--r--src/include/utils/rangetypes.h117
1 files changed, 56 insertions, 61 deletions
diff --git a/src/include/utils/rangetypes.h b/src/include/utils/rangetypes.h
index a7595b15f60..e218a91d1a8 100644
--- a/src/include/utils/rangetypes.h
+++ b/src/include/utils/rangetypes.h
@@ -3,47 +3,57 @@
* rangetypes.h
* Declarations for Postgres range types.
*
+ *
+ * Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
+ *
+ * src/include/utils/rangetypes.h
+ *
+ *-------------------------------------------------------------------------
*/
-
#ifndef RANGETYPES_H
#define RANGETYPES_H
#include "fmgr.h"
+
+/* All ranges are represented as varlena objects */
typedef struct varlena RangeType;
+/* Internal representation of either bound of a range (not what's on disk) */
typedef struct
{
- Datum val;
- Oid rngtypid;
- bool infinite;
- bool lower;
- bool inclusive;
+ Datum val; /* the bound value, if any */
+ Oid rngtypid; /* OID of the range type itself */
+ bool infinite; /* bound is +/- infinity */
+ bool lower; /* this is the lower (vs upper) bound */
+ bool inclusive; /* bound is inclusive (vs exclusive) */
} RangeBound;
+/* Standard runtime-cached data for a range type */
typedef struct
{
- FmgrInfo canonicalFn;
- FmgrInfo cmpFn;
- FmgrInfo subdiffFn;
- Oid rngtypid;
- Oid subtype;
- Oid collation;
- int16 subtyplen;
- char subtypalign;
- char subtypstorage;
- bool subtypbyval;
+ FmgrInfo canonicalFn; /* canonicalization function, if any */
+ FmgrInfo cmpFn; /* element type's btree comparison function */
+ FmgrInfo subdiffFn; /* element type difference function, if any */
+ Oid rngtypid; /* OID of the range type itself */
+ Oid subtype; /* OID of the element type */
+ Oid collation; /* collation for comparisons, if any */
+ int16 subtyplen; /* typlen of element type */
+ char subtypalign; /* typalign of element type */
+ char subtypstorage; /* typstorage of element type */
+ bool subtypbyval; /* typbyval of element type */
} RangeTypeInfo;
/*
* fmgr macros for range type objects
*/
-#define DatumGetRangeType(X) ((RangeType *) PG_DETOAST_DATUM(X))
-#define DatumGetRangeTypeCopy(X) ((RangeType *) PG_DETOAST_DATUM_COPY(X))
-#define RangeTypeGetDatum(X) PointerGetDatum(X)
-#define PG_GETARG_RANGE(n) DatumGetRangeType(PG_GETARG_DATUM(n))
-#define PG_GETARG_RANGE_COPY(n) DatumGetRangeTypeCopy(PG_GETARG_DATUM(n))
-#define PG_RETURN_RANGE(x) return RangeTypeGetDatum(x)
+#define DatumGetRangeType(X) ((RangeType *) PG_DETOAST_DATUM(X))
+#define DatumGetRangeTypeCopy(X) ((RangeType *) PG_DETOAST_DATUM_COPY(X))
+#define RangeTypeGetDatum(X) PointerGetDatum(X)
+#define PG_GETARG_RANGE(n) DatumGetRangeType(PG_GETARG_DATUM(n))
+#define PG_GETARG_RANGE_COPY(n) DatumGetRangeTypeCopy(PG_GETARG_DATUM(n))
+#define PG_RETURN_RANGE(x) return RangeTypeGetDatum(x)
/*
* prototypes for functions defined in rangetypes.c
@@ -62,16 +72,6 @@ extern Datum range_constructor0(PG_FUNCTION_ARGS);
extern Datum range_constructor1(PG_FUNCTION_ARGS);
extern Datum range_constructor2(PG_FUNCTION_ARGS);
extern Datum range_constructor3(PG_FUNCTION_ARGS);
-extern Datum range_make1(PG_FUNCTION_ARGS);
-extern Datum range_linf_(PG_FUNCTION_ARGS);
-extern Datum range_uinf_(PG_FUNCTION_ARGS);
-extern Datum range_linfi(PG_FUNCTION_ARGS);
-extern Datum range_uinfi(PG_FUNCTION_ARGS);
-extern Datum range(PG_FUNCTION_ARGS);
-extern Datum range__(PG_FUNCTION_ARGS);
-extern Datum range_i(PG_FUNCTION_ARGS);
-extern Datum rangei_(PG_FUNCTION_ARGS);
-extern Datum rangeii(PG_FUNCTION_ARGS);
/* range -> subtype */
extern Datum range_lower(PG_FUNCTION_ARGS);
@@ -84,7 +84,7 @@ extern Datum range_upper_inc(PG_FUNCTION_ARGS);
extern Datum range_lower_inf(PG_FUNCTION_ARGS);
extern Datum range_upper_inf(PG_FUNCTION_ARGS);
-/* range, point -> bool */
+/* range, element -> bool */
extern Datum range_contains_elem(PG_FUNCTION_ARGS);
extern Datum elem_contained_by_range(PG_FUNCTION_ARGS);
@@ -115,45 +115,40 @@ extern Datum range_gt(PG_FUNCTION_ARGS);
/* Hash support */
extern Datum hash_range(PG_FUNCTION_ARGS);
-/* GiST support (rangetypes_gist.c) */
-extern Datum range_gist_consistent(PG_FUNCTION_ARGS);
-extern Datum range_gist_compress(PG_FUNCTION_ARGS);
-extern Datum range_gist_decompress(PG_FUNCTION_ARGS);
-extern Datum range_gist_union(PG_FUNCTION_ARGS);
-extern Datum range_gist_penalty(PG_FUNCTION_ARGS);
-extern Datum range_gist_picksplit(PG_FUNCTION_ARGS);
-extern Datum range_gist_same(PG_FUNCTION_ARGS);
-
/* Canonical functions */
-Datum int4range_canonical(PG_FUNCTION_ARGS);
-Datum int8range_canonical(PG_FUNCTION_ARGS);
-Datum daterange_canonical(PG_FUNCTION_ARGS);
+extern Datum int4range_canonical(PG_FUNCTION_ARGS);
+extern Datum int8range_canonical(PG_FUNCTION_ARGS);
+extern Datum daterange_canonical(PG_FUNCTION_ARGS);
/* Subtype Difference functions */
-Datum int4range_subdiff(PG_FUNCTION_ARGS);
-Datum int8range_subdiff(PG_FUNCTION_ARGS);
-Datum numrange_subdiff(PG_FUNCTION_ARGS);
-Datum daterange_subdiff(PG_FUNCTION_ARGS);
-Datum tsrange_subdiff(PG_FUNCTION_ARGS);
-Datum tstzrange_subdiff(PG_FUNCTION_ARGS);
-
-/* for defining more generic functions */
-extern Datum make_range(FunctionCallInfo fcinfo, RangeBound *lower,
- RangeBound *upper, bool empty);
+extern Datum int4range_subdiff(PG_FUNCTION_ARGS);
+extern Datum int8range_subdiff(PG_FUNCTION_ARGS);
+extern Datum numrange_subdiff(PG_FUNCTION_ARGS);
+extern Datum daterange_subdiff(PG_FUNCTION_ARGS);
+extern Datum tsrange_subdiff(PG_FUNCTION_ARGS);
+extern Datum tstzrange_subdiff(PG_FUNCTION_ARGS);
+
+/* assorted support functions */
+extern Datum range_serialize(FunctionCallInfo fcinfo, RangeBound *lower,
+ RangeBound *upper, bool empty);
extern void range_deserialize(FunctionCallInfo fcinfo, RangeType *range,
RangeBound *lower, RangeBound *upper,
bool *empty);
+extern Datum make_range(FunctionCallInfo fcinfo, RangeBound *lower,
+ RangeBound *upper, bool empty);
extern int range_cmp_bounds(FunctionCallInfo fcinfo, RangeBound *b1,
RangeBound *b2);
extern RangeType *make_empty_range(FunctionCallInfo fcinfo, Oid rngtypid);
extern void range_gettypinfo(FunctionCallInfo fcinfo, Oid rngtypid,
RangeTypeInfo *rngtypinfo);
-/* for defining a range "canonicalize" function */
-extern Datum range_serialize(FunctionCallInfo fcinfo, RangeBound *lower,
- RangeBound *upper, bool empty);
-
-/* for use in DefineRange */
-extern char range_parse_flags(char *flags_str);
+/* GiST support (in rangetypes_gist.c) */
+extern Datum range_gist_consistent(PG_FUNCTION_ARGS);
+extern Datum range_gist_compress(PG_FUNCTION_ARGS);
+extern Datum range_gist_decompress(PG_FUNCTION_ARGS);
+extern Datum range_gist_union(PG_FUNCTION_ARGS);
+extern Datum range_gist_penalty(PG_FUNCTION_ARGS);
+extern Datum range_gist_picksplit(PG_FUNCTION_ARGS);
+extern Datum range_gist_same(PG_FUNCTION_ARGS);
#endif /* RANGETYPES_H */