]> granicus.if.org Git - postgresql/blobdiff - src/include/utils/varbit.h
Update copyright via script for 2017
[postgresql] / src / include / utils / varbit.h
index 3f35b090a667f2f622dec06935b0b3fc9f0cb453..5b910407d59debd9fe1d9517abb9eaf3352c3438 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Code originally contributed by Adriaan Joubert.
  *
- * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * src/include/utils/varbit.h
@@ -15,6 +15,8 @@
 #ifndef VARBIT_H
 #define VARBIT_H
 
+#include <limits.h>
+
 #include "fmgr.h"
 
 /*
@@ -24,7 +26,8 @@ typedef struct
 {
        int32           vl_len_;                /* varlena header (do not touch directly!) */
        int32           bit_len;                /* number of valid bits */
-       bits8           bit_dat[1];             /* bit string, most sig. byte first */
+       bits8           bit_dat[FLEXIBLE_ARRAY_MEMBER]; /* bit string, most sig. byte
+                                                                                                * first */
 } VarBit;
 
 /*
@@ -53,6 +56,11 @@ typedef struct
 /* Number of bytes needed to store a bit string of a given length */
 #define VARBITTOTALLEN(BITLEN) (((BITLEN) + BITS_PER_BYTE-1)/BITS_PER_BYTE + \
                                                                 VARHDRSZ + VARBITHDRSZ)
+/*
+ * Maximum number of bits.  Several code sites assume no overflow from
+ * computing bitlen + X; VARBITTOTALLEN() has the largest such X.
+ */
+#define VARBITMAXLEN           (INT_MAX - BITS_PER_BYTE + 1)
 /* pointer beyond the end of the bit string (like end() in STL containers) */
 #define VARBITEND(PTR)         (((bits8 *) (PTR)) + VARSIZE(PTR))
 /* Mask that will cover exactly one byte, i.e. BITS_PER_BYTE bits */
@@ -72,6 +80,7 @@ extern Datum varbit_send(PG_FUNCTION_ARGS);
 extern Datum varbittypmodin(PG_FUNCTION_ARGS);
 extern Datum varbittypmodout(PG_FUNCTION_ARGS);
 extern Datum bit(PG_FUNCTION_ARGS);
+extern Datum varbit_transform(PG_FUNCTION_ARGS);
 extern Datum varbit(PG_FUNCTION_ARGS);
 extern Datum biteq(PG_FUNCTION_ARGS);
 extern Datum bitne(PG_FUNCTION_ARGS);
@@ -80,6 +89,7 @@ extern Datum bitle(PG_FUNCTION_ARGS);
 extern Datum bitgt(PG_FUNCTION_ARGS);
 extern Datum bitge(PG_FUNCTION_ARGS);
 extern Datum bitcmp(PG_FUNCTION_ARGS);
+
 /* avoid the names bitand and bitor, since they are C++ keywords */
 extern Datum bit_and(PG_FUNCTION_ARGS);
 extern Datum bit_or(PG_FUNCTION_ARGS);