Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Basic support for 8.3 (a few macros from tupmacs.h).

  • Loading branch information...
commit fa0b786bb226c91e402247cb73f9852143cd4549 1 parent 19ecc50
@tvondra authored
Showing with 99 additions and 1 deletion.
  1. +99 −1 src/quantile.c
View
100 src/quantile.c
@@ -51,7 +51,7 @@ PG_MODULE_MAGIC;
elog(ERROR, "%s called in non-aggregate context", fname); \
}
-#else
+#elseif (PG_VERSION_NUM >= 80400)
#define GET_AGG_CONTEXT(fname, fcinfo, aggcontext) \
if (fcinfo->context && IsA(fcinfo->context, AggState)) { \
@@ -71,6 +71,104 @@ PG_MODULE_MAGIC;
elog(ERROR, "%s called in non-aggregate context", fname); \
}
+#else
+
+#define GET_AGG_CONTEXT(fname, fcinfo, aggcontext) \
+ if (fcinfo->context && IsA(fcinfo->context, AggState)) { \
+ aggcontext = ((AggState *) fcinfo->context)->aggcontext; \
+ } else { \
+ elog(ERROR, "%s called in non-aggregate context", fname); \
+ aggcontext = NULL; \
+ }
+
+#define CHECK_AGG_CONTEXT(fname, fcinfo) \
+ if (!(fcinfo->context && \
+ (IsA(fcinfo->context, AggState)))) \
+ { \
+ elog(ERROR, "%s called in non-aggregate context", fname); \
+ }
+
+/* backward compatibility with 8.3 (macros copied mostly from src/include/access/tupmacs.h) */
+
+#if SIZEOF_DATUM == 8
+
+#define fetch_att(T,attbyval,attlen) \
+( \
+ (attbyval) ? \
+ ( \
+ (attlen) == (int) sizeof(Datum) ? \
+ *((Datum *)(T)) \
+ : \
+ ( \
+ (attlen) == (int) sizeof(int32) ? \
+ Int32GetDatum(*((int32 *)(T))) \
+ : \
+ ( \
+ (attlen) == (int) sizeof(int16) ? \
+ Int16GetDatum(*((int16 *)(T))) \
+ : \
+ ( \
+ AssertMacro((attlen) == 1), \
+ CharGetDatum(*((char *)(T))) \
+ ) \
+ ) \
+ ) \
+ ) \
+ : \
+ PointerGetDatum((char *) (T)) \
+)
+#else /* SIZEOF_DATUM != 8 */
+
+#define fetch_att(T,attbyval,attlen) \
+( \
+ (attbyval) ? \
+ ( \
+ (attlen) == (int) sizeof(int32) ? \
+ Int32GetDatum(*((int32 *)(T))) \
+ : \
+ ( \
+ (attlen) == (int) sizeof(int16) ? \
+ Int16GetDatum(*((int16 *)(T))) \
+ : \
+ ( \
+ AssertMacro((attlen) == 1), \
+ CharGetDatum(*((char *)(T))) \
+ ) \
+ ) \
+ ) \
+ : \
+ PointerGetDatum((char *) (T)) \
+)
+#endif /* SIZEOF_DATUM == 8 */
+
+#define att_addlength_pointer(cur_offset, attlen, attptr) \
+( \
+ ((attlen) > 0) ? \
+ ( \
+ (cur_offset) + (attlen) \
+ ) \
+ : (((attlen) == -1) ? \
+ ( \
+ (cur_offset) + VARSIZE_ANY(attptr) \
+ ) \
+ : \
+ ( \
+ AssertMacro((attlen) == -2), \
+ (cur_offset) + (strlen((char *) (attptr)) + 1) \
+ )) \
+)
+
+#define att_align_nominal(cur_offset, attalign) \
+( \
+ ((attalign) == 'i') ? INTALIGN(cur_offset) : \
+ (((attalign) == 'c') ? (long) (cur_offset) : \
+ (((attalign) == 'd') ? DOUBLEALIGN(cur_offset) : \
+ ( \
+ AssertMacro((attalign) == 's'), \
+ SHORTALIGN(cur_offset) \
+ ))) \
+)
+
#endif
#define SLICE_SIZE 1024
Please sign in to comment.
Something went wrong with that request. Please try again.