diff options
Diffstat (limited to 'contrib/intarray/_int.h')
-rw-r--r-- | contrib/intarray/_int.h | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/contrib/intarray/_int.h b/contrib/intarray/_int.h index 702dfaade53..ec09b149733 100644 --- a/contrib/intarray/_int.h +++ b/contrib/intarray/_int.h @@ -19,13 +19,24 @@ /* useful macros for accessing int4 arrays */ #define ARRPTR(x) ( (int4 *) ARR_DATA_PTR(x) ) -#define ARRNELEMS(x) ArrayGetNItems( ARR_NDIM(x), ARR_DIMS(x)) +#define ARRNELEMS(x) ArrayGetNItems(ARR_NDIM(x), ARR_DIMS(x)) -#define ARRISVOID(x) ( (x) ? ( ( ARR_NDIM(x) == NDIM ) ? ( ( ARRNELEMS( x ) ) ? 0 : 1 ) : ( ( ARR_NDIM(x) ) ? ( \ - ereport(ERROR, \ - (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR), \ - errmsg("array must be one-dimensional, not %d dimensions", ARRNELEMS( x )))) \ - ,1) : 0 ) ) : 0 ) +/* reject arrays we can't handle; but allow a NULL or empty array */ +#define CHECKARRVALID(x) \ + do { \ + if (x) { \ + if (ARR_NDIM(x) != NDIM && ARR_NDIM(x) != 0) \ + ereport(ERROR, \ + (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR), \ + errmsg("array must be one-dimensional"))); \ + if (ARR_HASNULL(x)) \ + ereport(ERROR, \ + (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), \ + errmsg("array must not contain nulls"))); \ + } \ + } while(0) + +#define ARRISVOID(x) ((x) == NULL || ARRNELEMS(x) == 0) #define SORT(x) \ do { \ @@ -52,9 +63,6 @@ typedef char BITVEC[SIGLEN]; typedef char *BITVECP; -#define SIGPTR(x) ( (BITVECP) ARR_DATA_PTR(x) ) - - #define LOOPBYTE(a) \ for(i=0;i<SIGLEN;i++) {\ a;\ |