Subject: [PATCH v2 1/1] remove bits* types

From: Nathan Bossart <[email-masked]>
Date: Wed, 18 Mar 2026 16:37:47 -0500

---
 contrib/dblink/dblink.c                     |  2 +-
 contrib/pageinspect/gistfuncs.c             |  2 +-
 contrib/pageinspect/heapfuncs.c             | 16 ++---
 contrib/postgres_fdw/deparse.c              |  2 +-
 doc/src/sgml/fdwhandler.sgml                |  4 +-
 src/backend/access/brin/brin_tuple.c        | 20 +++---
 src/backend/access/common/heaptuple.c       | 16 ++---
 src/backend/access/common/indextuple.c      | 12 ++--
 src/backend/access/common/reloptions.c      | 28 ++++----
 src/backend/access/heap/heapam.c            |  8 +--
 src/backend/access/heap/heapam_handler.c    |  4 +-
 src/backend/access/spgist/spgutils.c        | 10 +--
 src/backend/catalog/index.c                 |  6 +-
 src/backend/catalog/indexing.c              |  2 +-
 src/backend/catalog/objectaddress.c         | 12 ++--
 src/backend/commands/indexcmds.c            |  4 +-
 src/backend/commands/subscriptioncmds.c     |  8 +--
 src/backend/commands/tablecmds.c            |  2 +-
 src/backend/commands/vacuum.c               |  4 +-
 src/backend/executor/execExprInterp.c       |  8 +--
 src/backend/executor/execIndexing.c         |  2 +-
 src/backend/executor/execReplication.c      |  4 +-
 src/backend/executor/execTuples.c           |  2 +-
 src/backend/executor/nodeModifyTable.c      |  2 +-
 src/backend/foreign/foreign.c               |  4 +-
 src/backend/nodes/gen_node_support.pl       |  3 +-
 src/backend/postmaster/bgworker.c           |  4 +-
 src/backend/postmaster/syslogger.c          |  2 +-
 src/backend/utils/activity/pgstat_backend.c |  2 +-
 src/backend/utils/adt/array_userfuncs.c     | 10 +--
 src/backend/utils/adt/arrayfuncs.c          | 68 +++++++++----------
 src/backend/utils/adt/format_type.c         |  4 +-
 src/backend/utils/adt/misc.c                |  2 +-
 src/backend/utils/adt/regproc.c             |  4 +-
 src/backend/utils/adt/ruleutils.c           |  2 +-
 src/backend/utils/adt/varbit.c              | 74 ++++++++++-----------
 src/backend/utils/adt/varlena.c             |  2 +-
 src/backend/utils/fmgr/funcapi.c            |  2 +-
 src/backend/utils/init/postinit.c           |  2 +-
 src/bin/pg_basebackup/pg_createsubscriber.c |  2 +-
 src/bin/psql/tab-complete.in.c              |  4 +-
 src/bin/scripts/vacuumdb.c                  |  4 +-
 src/bin/scripts/vacuuming.h                 |  2 +-
 src/include/access/heapam.h                 |  4 +-
 src/include/access/htup_details.h           |  6 +-
 src/include/access/itup.h                   |  6 +-
 src/include/access/reloptions.h             | 14 ++--
 src/include/access/tableam.h                | 16 ++---
 src/include/access/tupmacs.h                |  8 +--
 src/include/c.h                             |  8 ---
 src/include/catalog/index.h                 |  8 +--
 src/include/commands/cluster.h              |  2 +-
 src/include/commands/vacuum.h               |  6 +-
 src/include/common/jsonapi.h                |  2 +-
 src/include/executor/executor.h             |  2 +-
 src/include/executor/instrument_node.h      |  2 +-
 src/include/foreign/foreign.h               |  4 +-
 src/include/funcapi.h                       |  2 +-
 src/include/miscadmin.h                     |  2 +-
 src/include/nodes/parsenodes.h              |  2 +-
 src/include/port/pg_bitutils.h              |  8 +--
 src/include/postmaster/syslogger.h          |  2 +-
 src/include/replication/reorderbuffer.h     |  2 +-
 src/include/replication/walsender_private.h |  2 +-
 src/include/utils/array.h                   | 10 +--
 src/include/utils/arrayaccess.h             |  2 +-
 src/include/utils/builtins.h                |  2 +-
 src/include/utils/pgstat_internal.h         |  2 +-
 src/include/utils/regproc.h                 |  4 +-
 src/include/utils/ruleutils.h               |  2 +-
 src/include/utils/varbit.h                  |  6 +-
 src/pl/plpython/plpy_typeio.c               |  8 +--
 src/port/pg_bitutils.c                      |  4 +-
 src/port/pg_popcount_aarch64.c              | 16 ++---
 src/port/pg_popcount_x86.c                  | 14 ++--
 src/test/modules/worker_spi/worker_spi.c    |  8 +--
 src/tools/pgindent/typedefs.list            |  3 -
 77 files changed, 277 insertions(+), 289 deletions(-)

diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c
index ac6127ec1b5..134b52085b7 100644
--- a/contrib/dblink/dblink.c
+++ b/contrib/dblink/dblink.c
@@ -2077,7 +2077,7 @@ get_text_array_contents(ArrayType *array, int *numitems)
 	uint8		typalignby;
 	char	  **values;
 	char	   *ptr;
-	bits8	   *bitmap;
+	uint8	   *bitmap;
 	int			bitmask;
 	int			i;
 
diff --git a/contrib/pageinspect/gistfuncs.c b/contrib/pageinspect/gistfuncs.c
index e56c7d8a601..89678d377c7 100644
--- a/contrib/pageinspect/gistfuncs.c
+++ b/contrib/pageinspect/gistfuncs.c
@@ -203,7 +203,7 @@ gist_page_items(PG_FUNCTION_ARGS)
 	TupleDesc	tupdesc;
 	Page		page;
 	uint16		flagbits;
-	bits16		printflags = 0;
+	uint16		printflags = 0;
 	OffsetNumber offset;
 	OffsetNumber maxoff = InvalidOffsetNumber;
 	char	   *index_columns;
diff --git a/contrib/pageinspect/heapfuncs.c b/contrib/pageinspect/heapfuncs.c
index 3a61954e1d9..4f0f3bd53e7 100644
--- a/contrib/pageinspect/heapfuncs.c
+++ b/contrib/pageinspect/heapfuncs.c
@@ -56,11 +56,11 @@ HeapTupleHeaderGetOidOld(const HeapTupleHeaderData *tup)
 /*
  * bits_to_text
  *
- * Converts a bits8-array of 'len' bits to a human-readable
+ * Converts a uint8-array of 'len' bits to a human-readable
  * c-string representation.
  */
 static char *
-bits_to_text(bits8 *bits, int len)
+bits_to_text(uint8 *bits, int len)
 {
 	int			i;
 	char	   *str;
@@ -79,13 +79,13 @@ bits_to_text(bits8 *bits, int len)
 /*
  * text_to_bits
  *
- * Converts a c-string representation of bits into a bits8-array. This is
+ * Converts a c-string representation of bits into a uint8-array. This is
  * the reverse operation of previous routine.
  */
-static bits8 *
+static uint8 *
 text_to_bits(char *str, int len)
 {
-	bits8	   *bits;
+	uint8	   *bits;
 	int			off = 0;
 	char		byte = 0;
 
@@ -305,7 +305,7 @@ heap_page_items(PG_FUNCTION_ARGS)
 static Datum
 tuple_data_split_internal(Oid relid, char *tupdata,
 						  uint16 tupdata_len, uint16 t_infomask,
-						  uint16 t_infomask2, bits8 *t_bits,
+						  uint16 t_infomask2, uint8 *t_bits,
 						  bool do_detoast)
 {
 	ArrayBuildState *raw_attrs;
@@ -434,7 +434,7 @@ tuple_data_split(PG_FUNCTION_ARGS)
 	uint16		t_infomask2;
 	char	   *t_bits_str;
 	bool		do_detoast = false;
-	bits8	   *t_bits = NULL;
+	uint8	   *t_bits = NULL;
 	Datum		res;
 
 	relid = PG_GETARG_OID(0);
@@ -456,7 +456,7 @@ tuple_data_split(PG_FUNCTION_ARGS)
 		PG_RETURN_NULL();
 
 	/*
-	 * Convert t_bits string back to the bits8 array as represented in the
+	 * Convert t_bits string back to the uint8 array as represented in the
 	 * tuple header.
 	 */
 	if (t_infomask & HEAP_HASNULL)
diff --git a/contrib/postgres_fdw/deparse.c b/contrib/postgres_fdw/deparse.c
index ebe2c3a596a..c159ecd1558 100644
--- a/contrib/postgres_fdw/deparse.c
+++ b/contrib/postgres_fdw/deparse.c
@@ -1189,7 +1189,7 @@ is_foreign_pathkey(PlannerInfo *root,
 static char *
 deparse_type_name(Oid type_oid, int32 typemod)
 {
-	bits16		flags = FORMAT_TYPE_TYPEMOD_GIVEN;
+	uint16		flags = FORMAT_TYPE_TYPEMOD_GIVEN;
 
 	if (!is_builtin(type_oid))
 		flags |= FORMAT_TYPE_FORCE_QUALIFY;
diff --git a/doc/src/sgml/fdwhandler.sgml b/doc/src/sgml/fdwhandler.sgml
index 9826e09f983..f601d22d191 100644
--- a/doc/src/sgml/fdwhandler.sgml
+++ b/doc/src/sgml/fdwhandler.sgml
@@ -1702,7 +1702,7 @@ ReparameterizeForeignPathByChild(PlannerInfo *root, List *fdw_private,
     <para>
 <programlisting>
 ForeignDataWrapper *
-GetForeignDataWrapperExtended(Oid fdwid, bits16 flags);
+GetForeignDataWrapperExtended(Oid fdwid, uint16 flags);
 </programlisting>
 
      This function returns a <structname>ForeignDataWrapper</structname>
@@ -1731,7 +1731,7 @@ GetForeignDataWrapper(Oid fdwid);
     <para>
 <programlisting>
 ForeignServer *
-GetForeignServerExtended(Oid serverid, bits16 flags);
+GetForeignServerExtended(Oid serverid, uint16 flags);
 </programlisting>
 
      This function returns a <structname>ForeignServer</structname> object
diff --git a/src/backend/access/brin/brin_tuple.c b/src/backend/access/brin/brin_tuple.c
index 742ac089a28..af39d448962 100644
--- a/src/backend/access/brin/brin_tuple.c
+++ b/src/backend/access/brin/brin_tuple.c
@@ -50,7 +50,7 @@

 static inline void brin_deconstruct_tuple(BrinDesc *brdesc,
-										  char *tp, bits8 *nullbits, bool nulls,
+										  char *tp, uint8 *nullbits, bool nulls,
 										  Datum *values, bool *allnulls, bool *hasnulls);

@@ -107,7 +107,7 @@ brin_form_tuple(BrinDesc *brdesc, BlockNumber blkno, BrinMemTuple *tuple,
 	int			keyno;
 	int			idxattno;
 	uint16		phony_infomask = 0;
-	bits8	   *phony_nullbitmap;
+	uint8	   *phony_nullbitmap;
 	Size		len,
 				hoff,
 				data_len;
@@ -122,7 +122,7 @@ brin_form_tuple(BrinDesc *brdesc, BlockNumber blkno, BrinMemTuple *tuple,
 
 	values = palloc_array(Datum, brdesc->bd_totalstored);
 	nulls = palloc0_array(bool, brdesc->bd_totalstored);
-	phony_nullbitmap = palloc_array(bits8, BITMAPLEN(brdesc->bd_totalstored));
+	phony_nullbitmap = palloc_array(uint8, BITMAPLEN(brdesc->bd_totalstored));
 
 #ifdef TOAST_INDEX_HACK
 	untoasted_values = palloc_array(Datum, brdesc->bd_totalstored);
@@ -322,7 +322,7 @@ brin_form_tuple(BrinDesc *brdesc, BlockNumber blkno, BrinMemTuple *tuple,
 	 */
 	if (anynulls)
 	{
-		bits8	   *bitP;
+		uint8	   *bitP;
 		int			bitmask;
 
 		rettuple->bt_info |= BRIN_NULLS_MASK;
@@ -332,7 +332,7 @@ brin_form_tuple(BrinDesc *brdesc, BlockNumber blkno, BrinMemTuple *tuple,
 		 * store a 1 for a null attribute rather than a 0.  So we must reverse
 		 * the sense of the att_isnull test in brin_deconstruct_tuple as well.
 		 */
-		bitP = ((bits8 *) ((char *) rettuple + SizeOfBrinTuple)) - 1;
+		bitP = ((uint8 *) ((char *) rettuple + SizeOfBrinTuple)) - 1;
 		bitmask = HIGHBIT;
 		for (keyno = 0; keyno < brdesc->bd_tupdesc->natts; keyno++)
 		{
@@ -391,7 +391,7 @@ brin_form_placeholder_tuple(BrinDesc *brdesc, BlockNumber blkno, Size *size)
 	Size		hoff;
 	BrinTuple  *rettuple;
 	int			keyno;
-	bits8	   *bitP;
+	uint8	   *bitP;
 	int			bitmask;
 
 	/* compute total space needed: always add nulls */
@@ -404,7 +404,7 @@ brin_form_placeholder_tuple(BrinDesc *brdesc, BlockNumber blkno, Size *size)
 	rettuple->bt_info = hoff;
 	rettuple->bt_info |= BRIN_NULLS_MASK | BRIN_PLACEHOLDER_MASK | BRIN_EMPTY_RANGE_MASK;
 
-	bitP = ((bits8 *) ((char *) rettuple + SizeOfBrinTuple)) - 1;
+	bitP = ((uint8 *) ((char *) rettuple + SizeOfBrinTuple)) - 1;
 	bitmask = HIGHBIT;
 	/* set allnulls true for all attributes */
 	for (keyno = 0; keyno < brdesc->bd_tupdesc->natts; keyno++)
@@ -557,7 +557,7 @@ brin_deform_tuple(BrinDesc *brdesc, BrinTuple *tuple, BrinMemTuple *dMemtuple)
 	bool	   *allnulls;
 	bool	   *hasnulls;
 	char	   *tp;
-	bits8	   *nullbits;
+	uint8	   *nullbits;
 	int			keyno;
 	int			valueno;
 	MemoryContext oldcxt;
@@ -581,7 +581,7 @@ brin_deform_tuple(BrinDesc *brdesc, BrinTuple *tuple, BrinMemTuple *dMemtuple)
 	tp = (char *) tuple + BrinTupleDataOffset(tuple);
 
 	if (BrinTupleHasNulls(tuple))
-		nullbits = (bits8 *) ((char *) tuple + SizeOfBrinTuple);
+		nullbits = (uint8 *) ((char *) tuple + SizeOfBrinTuple);
 	else
 		nullbits = NULL;
 	brin_deconstruct_tuple(brdesc,
@@ -643,7 +643,7 @@ brin_deform_tuple(BrinDesc *brdesc, BrinTuple *tuple, BrinMemTuple *dMemtuple)
  */
 static inline void
 brin_deconstruct_tuple(BrinDesc *brdesc,
-					   char *tp, bits8 *nullbits, bool nulls,
+					   char *tp, uint8 *nullbits, bool nulls,
 					   Datum *values, bool *allnulls, bool *hasnulls)
 {
 	int			attnum;
diff --git a/src/backend/access/common/heaptuple.c b/src/backend/access/common/heaptuple.c
index 46d3fd13a9e..dce97a162a5 100644
--- a/src/backend/access/common/heaptuple.c
+++ b/src/backend/access/common/heaptuple.c
@@ -273,7 +273,7 @@ heap_compute_data_size(TupleDesc tupleDesc,
  */
 static inline void
 fill_val(CompactAttribute *att,
-		 bits8 **bit,
+		 uint8 **bit,
 		 int *bitmask,
 		 char **dataP,
 		 uint16 *infomask,
@@ -401,9 +401,9 @@ void
 heap_fill_tuple(TupleDesc tupleDesc,
 				const Datum *values, const bool *isnull,
 				char *data, Size data_size,
-				uint16 *infomask, bits8 *bit)
+				uint16 *infomask, uint8 *bit)
 {
-	bits8	   *bitP;
+	uint8	   *bitP;
 	int			bitmask;
 	int			i;
 	int			numberOfAttributes = tupleDesc->natts;
@@ -513,7 +513,7 @@ nocachegetattr(HeapTuple tup,
 	CompactAttribute *cattr;
 	HeapTupleHeader td = tup->t_data;
 	char	   *tp;				/* ptr to data part of tuple */
-	bits8	   *bp = td->t_bits;	/* ptr to null bitmap in tuple */
+	uint8	   *bp = td->t_bits;	/* ptr to null bitmap in tuple */
 	int			off;			/* current offset within data */
 	int			startAttr;
 	int			firstNullAttr;
@@ -766,7 +766,7 @@ expand_tuple(HeapTuple *targetHeapTuple,
 	Size		targetDataLen;
 	Size		len;
 	int			hoff;
-	bits8	   *nullBits = NULL;
+	uint8	   *nullBits = NULL;
 	int			bitMask = 0;
 	char	   *targetData;
 	uint16	   *infoMask;
@@ -878,7 +878,7 @@ expand_tuple(HeapTuple *targetHeapTuple,
 		/* We also make sure that t_ctid is invalid unless explicitly set */
 		ItemPointerSetInvalid(&(targetTHeader->t_ctid));
 		if (targetNullLen > 0)
-			nullBits = (bits8 *) ((char *) (*targetHeapTuple)->t_data
+			nullBits = (uint8 *) ((char *) (*targetHeapTuple)->t_data
 								  + offsetof(HeapTupleHeaderData, t_bits));
 		targetData = (char *) (*targetHeapTuple)->t_data + hoff;
 		infoMask = &(targetTHeader->t_infomask);
@@ -896,7 +896,7 @@ expand_tuple(HeapTuple *targetHeapTuple,
 		/* Same macro works for MinimalTuples */
 		HeapTupleHeaderSetNatts(*targetMinimalTuple, natts);
 		if (targetNullLen > 0)
-			nullBits = (bits8 *) ((char *) *targetMinimalTuple
+			nullBits = (uint8 *) ((char *) *targetMinimalTuple
 								  + offsetof(MinimalTupleData, t_bits));
 		targetData = (char *) *targetMinimalTuple + hoff;
 		infoMask = &((*targetMinimalTuple)->t_infomask);
@@ -1274,7 +1274,7 @@ heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc,
 	int			attnum;
 	char	   *tp;				/* ptr to tuple data */
 	uint32		off;			/* offset in tuple data */
-	bits8	   *bp = tup->t_bits;	/* ptr to null bitmap in tuple */
+	uint8	   *bp = tup->t_bits;	/* ptr to null bitmap in tuple */
 	int			firstNonCacheOffsetAttr;
 	int			firstNullAttr;
 
diff --git a/src/backend/access/common/indextuple.c b/src/backend/access/common/indextuple.c
index 6abb222cf10..a2db55e9b73 100644
--- a/src/backend/access/common/indextuple.c
+++ b/src/backend/access/common/indextuple.c
@@ -175,7 +175,7 @@ index_form_tuple_context(TupleDesc tupleDescriptor,
 					tp + hoff,
 					data_size,
 					&tupmask,
-					(hasnull ? (bits8 *) tp + sizeof(IndexTupleData) : NULL));
+					(hasnull ? (uint8 *) tp + sizeof(IndexTupleData) : NULL));
 
 #ifdef TOAST_INDEX_HACK
 	for (i = 0; i < numberOfAttributes; i++)
@@ -232,7 +232,7 @@ nocache_index_getattr(IndexTuple tup,
 {
 	CompactAttribute *cattr;
 	char	   *tp;				/* ptr to data part of tuple */
-	bits8	   *bp = NULL;		/* ptr to null bitmap in tuple */
+	uint8	   *bp = NULL;		/* ptr to null bitmap in tuple */
 	int			data_off;		/* tuple data offset */
 	int			off;			/* current offset within data */
 	int			startAttr;
@@ -255,7 +255,7 @@ nocache_index_getattr(IndexTuple tup,
 	 */
 	if (hasnulls)
 	{
-		bp = (bits8 *) ((char *) tup + sizeof(IndexTupleData));
+		bp = (uint8 *) ((char *) tup + sizeof(IndexTupleData));
 		firstNullAttr = first_null_attr(bp, attnum);
 	}
 	else
@@ -365,10 +365,10 @@ index_deform_tuple(IndexTuple tup, TupleDesc tupleDescriptor,
 				   Datum *values, bool *isnull)
 {
 	char	   *tp;				/* ptr to tuple data */
-	bits8	   *bp;				/* ptr to null bitmap in tuple */
+	uint8	   *bp;				/* ptr to null bitmap in tuple */
 
 	/* XXX "knows" t_bits are just after fixed tuple header! */
-	bp = (bits8 *) ((char *) tup + sizeof(IndexTupleData));
+	bp = (uint8 *) ((char *) tup + sizeof(IndexTupleData));
 
 	tp = (char *) tup + IndexInfoFindDataOffset(tup->t_info);
 
@@ -386,7 +386,7 @@ index_deform_tuple(IndexTuple tup, TupleDesc tupleDescriptor,
 void
 index_deform_tuple_internal(TupleDesc tupleDescriptor,
 							Datum *values, bool *isnull,
-							char *tp, bits8 *bp, int hasnulls)
+							char *tp, uint8 *bp, int hasnulls)
 {
 	CompactAttribute *cattr;
 	int			natts = tupleDescriptor->natts; /* number of atts to extract */
diff --git a/src/backend/access/common/reloptions.c b/src/backend/access/common/reloptions.c
index a6002ae9b07..b41eafd7691 100644
--- a/src/backend/access/common/reloptions.c
+++ b/src/backend/access/common/reloptions.c
@@ -585,7 +585,7 @@ static relopt_string stringRelOpts[] =
 };
 
 static relopt_gen **relOpts = NULL;
-static bits32 last_assigned_kind = RELOPT_KIND_LAST_DEFAULT;
+static uint32 last_assigned_kind = RELOPT_KIND_LAST_DEFAULT;
 
 static int	num_custom_options = 0;
 static relopt_gen **custom_options = NULL;
@@ -821,7 +821,7 @@ add_local_reloption(local_relopts *relopts, relopt_gen *newoption, int offset)
  *		(for types other than string)
  */
 static relopt_gen *
-allocate_reloption(bits32 kinds, int type, const char *name, const char *desc,
+allocate_reloption(uint32 kinds, int type, const char *name, const char *desc,
 				   LOCKMODE lockmode)
 {
 	MemoryContext oldcxt;
@@ -881,7 +881,7 @@ allocate_reloption(bits32 kinds, int type, const char *name, const char *desc,
  *		Allocate and initialize a new boolean reloption
  */
 static relopt_bool *
-init_bool_reloption(bits32 kinds, const char *name, const char *desc,
+init_bool_reloption(uint32 kinds, const char *name, const char *desc,
 					bool default_val, LOCKMODE lockmode)
 {
 	relopt_bool *newoption;
@@ -898,7 +898,7 @@ init_bool_reloption(bits32 kinds, const char *name, const char *desc,
  *		Add a new boolean reloption
  */
 void
-add_bool_reloption(bits32 kinds, const char *name, const char *desc,
+add_bool_reloption(uint32 kinds, const char *name, const char *desc,
 				   bool default_val, LOCKMODE lockmode)
 {
 	relopt_bool *newoption = init_bool_reloption(kinds, name, desc,
@@ -929,7 +929,7 @@ add_local_bool_reloption(local_relopts *relopts, const char *name,
  *		Allocate and initialize a new ternary reloption
  */
 static relopt_ternary *
-init_ternary_reloption(bits32 kinds, const char *name, const char *desc,
+init_ternary_reloption(uint32 kinds, const char *name, const char *desc,
 					   LOCKMODE lockmode)
 {
 	relopt_ternary *newoption;
@@ -945,7 +945,7 @@ init_ternary_reloption(bits32 kinds, const char *name, const char *desc,
  *		Add a new ternary reloption
  */
 void
-add_ternary_reloption(bits32 kinds, const char *name, const char *desc,
+add_ternary_reloption(uint32 kinds, const char *name, const char *desc,
 					  LOCKMODE lockmode)
 {
 	relopt_ternary *newoption;
@@ -979,7 +979,7 @@ add_local_ternary_reloption(local_relopts *relopts, const char *name,
  *		Allocate and initialize a new integer reloption
  */
 static relopt_int *
-init_int_reloption(bits32 kinds, const char *name, const char *desc,
+init_int_reloption(uint32 kinds, const char *name, const char *desc,
 				   int default_val, int min_val, int max_val,
 				   LOCKMODE lockmode)
 {
@@ -999,7 +999,7 @@ init_int_reloption(bits32 kinds, const char *name, const char *desc,
  *		Add a new integer reloption
  */
 void
-add_int_reloption(bits32 kinds, const char *name, const char *desc, int default_val,
+add_int_reloption(uint32 kinds, const char *name, const char *desc, int default_val,
 				  int min_val, int max_val, LOCKMODE lockmode)
 {
 	relopt_int *newoption = init_int_reloption(kinds, name, desc,
@@ -1032,7 +1032,7 @@ add_local_int_reloption(local_relopts *relopts, const char *name,
  *		Allocate and initialize a new real reloption
  */
 static relopt_real *
-init_real_reloption(bits32 kinds, const char *name, const char *desc,
+init_real_reloption(uint32 kinds, const char *name, const char *desc,
 					double default_val, double min_val, double max_val,
 					LOCKMODE lockmode)
 {
@@ -1052,7 +1052,7 @@ init_real_reloption(bits32 kinds, const char *name, const char *desc,
  *		Add a new float reloption
  */
 void
-add_real_reloption(bits32 kinds, const char *name, const char *desc,
+add_real_reloption(uint32 kinds, const char *name, const char *desc,
 				   double default_val, double min_val, double max_val,
 				   LOCKMODE lockmode)
 {
@@ -1087,7 +1087,7 @@ add_local_real_reloption(local_relopts *relopts, const char *name,
  *		Allocate and initialize a new enum reloption
  */
 static relopt_enum *
-init_enum_reloption(bits32 kinds, const char *name, const char *desc,
+init_enum_reloption(uint32 kinds, const char *name, const char *desc,
 					relopt_enum_elt_def *members, int default_val,
 					const char *detailmsg, LOCKMODE lockmode)
 {
@@ -1116,7 +1116,7 @@ init_enum_reloption(bits32 kinds, const char *name, const char *desc,
  * they are valid throughout the life of the process.
  */
 void
-add_enum_reloption(bits32 kinds, const char *name, const char *desc,
+add_enum_reloption(uint32 kinds, const char *name, const char *desc,
 				   relopt_enum_elt_def *members, int default_val,
 				   const char *detailmsg, LOCKMODE lockmode)
 {
@@ -1151,7 +1151,7 @@ add_local_enum_reloption(local_relopts *relopts, const char *name,
  *		Allocate and initialize a new string reloption
  */
 static relopt_string *
-init_string_reloption(bits32 kinds, const char *name, const char *desc,
+init_string_reloption(uint32 kinds, const char *name, const char *desc,
 					  const char *default_val,
 					  validate_string_relopt validator,
 					  fill_string_relopt filler,
@@ -1196,7 +1196,7 @@ init_string_reloption(bits32 kinds, const char *name, const char *desc,
  * the validation.
  */
 void
-add_string_reloption(bits32 kinds, const char *name, const char *desc,
+add_string_reloption(uint32 kinds, const char *name, const char *desc,
 					 const char *default_val, validate_string_relopt validator,
 					 LOCKMODE lockmode)
 {
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
index 882deda6b95..4db4a2068ee 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -57,7 +57,7 @@

 static HeapTuple heap_prepare_insert(Relation relation, HeapTuple tup,
-									 TransactionId xid, CommandId cid, bits32 options);
+									 TransactionId xid, CommandId cid, uint32 options);
 static XLogRecPtr log_heap_update(Relation reln, Buffer oldbuf,
 								  Buffer newbuf, HeapTuple oldtup,
 								  HeapTuple newtup, HeapTuple old_key_tuple,
@@ -2148,7 +2148,7 @@ ReleaseBulkInsertStatePin(BulkInsertState bistate)
  */
 void
 heap_insert(Relation relation, HeapTuple tup, CommandId cid,
-			bits32 options, BulkInsertState bistate)
+			uint32 options, BulkInsertState bistate)
 {
 	TransactionId xid = GetCurrentTransactionId();
 	HeapTuple	heaptup;
@@ -2339,7 +2339,7 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid,
  */
 static HeapTuple
 heap_prepare_insert(Relation relation, HeapTuple tup, TransactionId xid,
-					CommandId cid, bits32 options)
+					CommandId cid, uint32 options)
 {
 	/*
 	 * To allow parallel inserts, we need to ensure that they are safe to be
@@ -2419,7 +2419,7 @@ heap_multi_insert_pages(HeapTuple *heaptuples, int done, int ntuples, Size saveF
  */
 void
 heap_multi_insert(Relation relation, TupleTableSlot **slots, int ntuples,
-				  CommandId cid, bits32 options, BulkInsertState bistate)
+				  CommandId cid, uint32 options, BulkInsertState bistate)
 {
 	TransactionId xid = GetCurrentTransactionId();
 	HeapTuple  *heaptuples;
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index 4de1eab4a73..e63b12c3c61 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -253,7 +253,7 @@ heapam_tuple_satisfies_snapshot(Relation rel, TupleTableSlot *slot,
 
 static void
 heapam_tuple_insert(Relation relation, TupleTableSlot *slot, CommandId cid,
-					bits32 options, BulkInsertState bistate)
+					uint32 options, BulkInsertState bistate)
 {
 	bool		shouldFree = true;
 	HeapTuple	tuple = ExecFetchSlotHeapTuple(slot, true, &shouldFree);
@@ -272,7 +272,7 @@ heapam_tuple_insert(Relation relation, TupleTableSlot *slot, CommandId cid,
 
 static void
 heapam_tuple_insert_speculative(Relation relation, TupleTableSlot *slot,
-								CommandId cid, bits32 options,
+								CommandId cid, uint32 options,
 								BulkInsertState bistate, uint32 specToken)
 {
 	bool		shouldFree = true;
diff --git a/src/backend/access/spgist/spgutils.c b/src/backend/access/spgist/spgutils.c
index a4694bd8065..f2ee333f60d 100644
--- a/src/backend/access/spgist/spgutils.c
+++ b/src/backend/access/spgist/spgutils.c
@@ -929,12 +929,12 @@ spgFormLeafTuple(SpGistState *state, const ItemPointerData *heapPtr,
 
 	if (needs_null_mask)
 	{
-		bits8	   *bp;			/* ptr to null bitmap in tuple */
+		uint8	   *bp;			/* ptr to null bitmap in tuple */
 
 		/* Set nullmask presence bit in SpGistLeafTuple header */
 		SGLT_SET_HASNULLMASK(tup, true);
 		/* Fill the data area and null mask */
-		bp = (bits8 *) ((char *) tup + sizeof(SpGistLeafTupleData));
+		bp = (uint8 *) ((char *) tup + sizeof(SpGistLeafTupleData));
 		heap_fill_tuple(tupleDescriptor, datums, isnulls, tp, data_size,
 						&tupmask, bp);
 	}
@@ -942,7 +942,7 @@ spgFormLeafTuple(SpGistState *state, const ItemPointerData *heapPtr,
 	{
 		/* Fill data area only */
 		heap_fill_tuple(tupleDescriptor, datums, isnulls, tp, data_size,
-						&tupmask, (bits8 *) NULL);
+						&tupmask, (uint8 *) NULL);
 	}
 	/* otherwise we have no data, nor a bitmap, to fill */
 
@@ -1116,7 +1116,7 @@ spgDeformLeafTuple(SpGistLeafTuple tup, TupleDesc tupleDescriptor,
 {
 	bool		hasNullsMask = SGLT_GET_HASNULLMASK(tup);
 	char	   *tp;				/* ptr to tuple data */
-	bits8	   *bp;				/* ptr to null bitmap in tuple */
+	uint8	   *bp;				/* ptr to null bitmap in tuple */
 
 	if (keyColumnIsNull && tupleDescriptor->natts == 1)
 	{
@@ -1137,7 +1137,7 @@ spgDeformLeafTuple(SpGistLeafTuple tup, TupleDesc tupleDescriptor,
 	}
 
 	tp = (char *) tup + SGLTHDRSZ(hasNullsMask);
-	bp = (bits8 *) ((char *) tup + sizeof(SpGistLeafTupleData));
+	bp = (uint8 *) ((char *) tup + sizeof(SpGistLeafTupleData));
 
 	index_deform_tuple_internal(tupleDescriptor,
 								datums, isnulls,
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index d8219b18c48..1ccfa687f05 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -740,8 +740,8 @@ index_create(Relation heapRelation,
 			 const int16 *coloptions,
 			 const NullableDatum *stattargets,
 			 Datum reloptions,
-			 bits16 flags,
-			 bits16 constr_flags,
+			 uint16 flags,
+			 uint16 constr_flags,
 			 bool allow_system_table_mods,
 			 bool is_internal,
 			 Oid *constraintId)
@@ -1889,7 +1889,7 @@ index_constraint_create(Relation heapRelation,
 						const IndexInfo *indexInfo,
 						const char *constraintName,
 						char constraintType,
-						bits16 constr_flags,
+						uint16 constr_flags,
 						bool allow_system_table_mods,
 						bool is_internal)
 {
diff --git a/src/backend/catalog/indexing.c b/src/backend/catalog/indexing.c
index 0a1a68e0644..fd7d2ec0e3a 100644
--- a/src/backend/catalog/indexing.c
+++ b/src/backend/catalog/indexing.c
@@ -201,7 +201,7 @@ CatalogTupleCheckConstraints(Relation heapRel, HeapTuple tup)
 	if (HeapTupleHasNulls(tup))
 	{
 		TupleDesc	tupdesc = RelationGetDescr(heapRel);
-		bits8	   *bp = tup->t_data->t_bits;
+		uint8	   *bp = tup->t_data->t_bits;
 
 		for (int attnum = 0; attnum < tupdesc->natts; attnum++)
 		{
diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c
index 7c93f5240ed..9771c6a9b63 100644
--- a/src/backend/catalog/objectaddress.c
+++ b/src/backend/catalog/objectaddress.c
@@ -3039,7 +3039,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
 
 		case ProcedureRelationId:
 			{
-				bits16		flags = FORMAT_PROC_INVALID_AS_NULL;
+				uint16		flags = FORMAT_PROC_INVALID_AS_NULL;
 				char	   *proname = format_procedure_extended(object->objectId,
 																flags);
 
@@ -3052,7 +3052,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
 
 		case TypeRelationId:
 			{
-				bits16		flags = FORMAT_TYPE_INVALID_AS_NULL;
+				uint16		flags = FORMAT_TYPE_INVALID_AS_NULL;
 				char	   *typname = format_type_extended(object->objectId, -1,
 														   flags);
 
@@ -3245,7 +3245,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
 
 		case OperatorRelationId:
 			{
-				bits16		flags = FORMAT_OPERATOR_INVALID_AS_NULL;
+				uint16		flags = FORMAT_OPERATOR_INVALID_AS_NULL;
 				char	   *oprname = format_operator_extended(object->objectId,
 															   flags);
 
@@ -5160,7 +5160,7 @@ getObjectIdentityParts(const ObjectAddress *object,
 
 		case ProcedureRelationId:
 			{
-				bits16		flags = FORMAT_PROC_FORCE_QUALIFY | FORMAT_PROC_INVALID_AS_NULL;
+				uint16		flags = FORMAT_PROC_FORCE_QUALIFY | FORMAT_PROC_INVALID_AS_NULL;
 				char	   *proname = format_procedure_extended(object->objectId,
 																flags);
 
@@ -5176,7 +5176,7 @@ getObjectIdentityParts(const ObjectAddress *object,
 
 		case TypeRelationId:
 			{
-				bits16		flags = FORMAT_TYPE_INVALID_AS_NULL | FORMAT_TYPE_FORCE_QUALIFY;
+				uint16		flags = FORMAT_TYPE_INVALID_AS_NULL | FORMAT_TYPE_FORCE_QUALIFY;
 				char	   *typeout;
 
 				typeout = format_type_extended(object->objectId, -1, flags);
@@ -5383,7 +5383,7 @@ getObjectIdentityParts(const ObjectAddress *object,
 
 		case OperatorRelationId:
 			{
-				bits16		flags = FORMAT_OPERATOR_FORCE_QUALIFY | FORMAT_OPERATOR_INVALID_AS_NULL;
+				uint16		flags = FORMAT_OPERATOR_FORCE_QUALIFY | FORMAT_OPERATOR_INVALID_AS_NULL;
 				char	   *oprname = format_operator_extended(object->objectId,
 															   flags);
 
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c
index dd593ccbc1c..373e8234794 100644
--- a/src/backend/commands/indexcmds.c
+++ b/src/backend/commands/indexcmds.c
@@ -581,8 +581,8 @@ DefineIndex(ParseState *pstate,
 	Datum		reloptions;
 	int16	   *coloptions;
 	IndexInfo  *indexInfo;
-	bits16		flags;
-	bits16		constr_flags;
+	uint16		flags;
+	uint16		constr_flags;
 	int			numberOfAttributes;
 	int			numberOfKeyAttributes;
 	TransactionId limitXmin;
diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c
index 7375e214cb4..3a30d8ddb1f 100644
--- a/src/backend/commands/subscriptioncmds.c
+++ b/src/backend/commands/subscriptioncmds.c
@@ -89,7 +89,7 @@
  */
 typedef struct SubOpts
 {
-	bits32		specified_opts;
+	uint32		specified_opts;
 	char	   *slot_name;
 	char	   *synchronous_commit;
 	bool		connect;
@@ -150,7 +150,7 @@ static void CheckAlterSubOption(Subscription *sub, const char *option,
  */
 static void
 parse_subscription_options(ParseState *pstate, List *stmt_options,
-						   bits32 supported_opts, SubOpts *opts)
+						   uint32 supported_opts, SubOpts *opts)
 {
 	ListCell   *lc;
 
@@ -626,7 +626,7 @@ CreateSubscription(ParseState *pstate, CreateSubscriptionStmt *stmt,
 	char	   *conninfo;
 	char		originname[NAMEDATALEN];
 	List	   *publications;
-	bits32		supported_opts;
+	uint32		supported_opts;
 	SubOpts		opts = {0};
 	AclResult	aclresult;
 
@@ -1430,7 +1430,7 @@ AlterSubscription(ParseState *pstate, AlterSubscriptionStmt *stmt,
 	char	   *origin;
 	Subscription *sub;
 	Form_pg_subscription form;
-	bits32		supported_opts;
+	uint32		supported_opts;
 	SubOpts		opts = {0};
 
 	rel = table_open(SubscriptionRelationId, RowExclusiveLock);
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index cfb60940f4d..8b4ebc6f226 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -9787,7 +9787,7 @@ ATExecAddIndexConstraint(AlteredTableInfo *tab, Relation rel,
 	char	   *constraintName;
 	char		constraintType;
 	ObjectAddress address;
-	bits16		flags;
+	uint16		flags;
 
 	Assert(IsA(stmt, IndexStmt));
 	Assert(OidIsValid(index_oid));
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
index bce3a2daa24..766a518c7a1 100644
--- a/src/backend/commands/vacuum.c
+++ b/src/backend/commands/vacuum.c
@@ -717,7 +717,7 @@ vacuum(List *relations, const VacuumParams params, BufferAccessStrategy bstrateg
  */
 bool
 vacuum_is_permitted_for_relation(Oid relid, Form_pg_class reltuple,
-								 bits32 options)
+								 uint32 options)
 {
 	char	   *relname;
 
@@ -768,7 +768,7 @@ vacuum_is_permitted_for_relation(Oid relid, Form_pg_class reltuple,
  * or locked, a log is emitted if possible.
  */
 Relation
-vacuum_open_relation(Oid relid, RangeVar *relation, bits32 options,
+vacuum_open_relation(Oid relid, RangeVar *relation, uint32 options,
 					 bool verbose, LOCKMODE lmode)
 {
 	Relation	rel;
diff --git a/src/backend/executor/execExprInterp.c b/src/backend/executor/execExprInterp.c
index 43116431edf..3c4843cde86 100644
--- a/src/backend/executor/execExprInterp.c
+++ b/src/backend/executor/execExprInterp.c
@@ -3442,7 +3442,7 @@ ExecEvalArrayExpr(ExprState *state, ExprEvalStep *op)
 		bool		havenulls = false;
 		bool		haveempty = false;
 		char	  **subdata;
-		bits8	  **subbitmaps;
+		uint8	  **subbitmaps;
 		int		   *subbytes;
 		int		   *subnitems;
 		int32		dataoffset;
@@ -3450,7 +3450,7 @@ ExecEvalArrayExpr(ExprState *state, ExprEvalStep *op)
 		int			iitem;
 
 		subdata = (char **) palloc(nelems * sizeof(char *));
-		subbitmaps = (bits8 **) palloc(nelems * sizeof(bits8 *));
+		subbitmaps = (uint8 **) palloc(nelems * sizeof(uint8 *));
 		subbytes = (int *) palloc(nelems * sizeof(int));
 		subnitems = (int *) palloc(nelems * sizeof(int));
 
@@ -4036,7 +4036,7 @@ ExecEvalScalarArrayOp(ExprState *state, ExprEvalStep *op)
 	char		typalign;
 	uint8		typalignby;
 	char	   *s;
-	bits8	   *bitmap;
+	uint8	   *bitmap;
 	int			bitmask;
 
 	/*
@@ -4263,7 +4263,7 @@ ExecEvalHashedScalarArrayOp(ExprState *state, ExprEvalStep *op, ExprContext *eco
 		int			nitems;
 		bool		has_nulls = false;
 		char	   *s;
-		bits8	   *bitmap;
+		uint8	   *bitmap;
 		int			bitmask;
 		MemoryContext oldcontext;
 		ArrayType  *arr;
diff --git a/src/backend/executor/execIndexing.c b/src/backend/executor/execIndexing.c
index cc6eb3a6ee9..4363e154c0f 100644
--- a/src/backend/executor/execIndexing.c
+++ b/src/backend/executor/execIndexing.c
@@ -309,7 +309,7 @@ ExecCloseIndices(ResultRelInfo *resultRelInfo)
 List *
 ExecInsertIndexTuples(ResultRelInfo *resultRelInfo,
 					  EState *estate,
-					  bits32 flags,
+					  uint32 flags,
 					  TupleTableSlot *slot,
 					  List *arbiterIndexes,
 					  bool *specConflict)
diff --git a/src/backend/executor/execReplication.c b/src/backend/executor/execReplication.c
index fea8991cb04..b2ca5cbf117 100644
--- a/src/backend/executor/execReplication.c
+++ b/src/backend/executor/execReplication.c
@@ -851,7 +851,7 @@ ExecSimpleRelationInsert(ResultRelInfo *resultRelInfo,
 
 		if (resultRelInfo->ri_NumIndices > 0)
 		{
-			bits32		flags;
+			uint32		flags;
 
 			if (conflictindexes != NIL)
 				flags = EIIT_NO_DUPE_ERROR;
@@ -955,7 +955,7 @@ ExecSimpleRelationUpdate(ResultRelInfo *resultRelInfo,
 
 		if (resultRelInfo->ri_NumIndices > 0 && (update_indexes != TU_None))
 		{
-			bits32		flags = EIIT_IS_UPDATE;
+			uint32		flags = EIIT_IS_UPDATE;
 
 			if (conflictindexes != NIL)
 				flags |= EIIT_NO_DUPE_ERROR;
diff --git a/src/backend/executor/execTuples.c b/src/backend/executor/execTuples.c
index 9d900147a55..f08982a43cc 100644
--- a/src/backend/executor/execTuples.c
+++ b/src/backend/executor/execTuples.c
@@ -1059,7 +1059,7 @@ slot_deform_heap_tuple(TupleTableSlot *slot, HeapTuple tuple, uint32 *offp,
 		natts = Min(natts, reqnatts);
 		if (natts > firstNonGuaranteedAttr)
 		{
-			bits8	   *bp = tup->t_bits;
+			uint8	   *bp = tup->t_bits;
 
 			/* Find the first NULL attr */
 			firstNullAttr = first_null_attr(bp, natts);
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index 4cd5e262e0f..582bcc367c0 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2357,7 +2357,7 @@ ExecUpdateEpilogue(ModifyTableContext *context, UpdateContext *updateCxt,
 	/* insert index entries for tuple if necessary */
 	if (resultRelInfo->ri_NumIndices > 0 && (updateCxt->updateIndexes != TU_None))
 	{
-		bits32		flags = EIIT_IS_UPDATE;
+		uint32		flags = EIIT_IS_UPDATE;
 
 		if (updateCxt->updateIndexes == TU_Summarizing)
 			flags |= EIIT_ONLY_SUMMARIZING;
diff --git a/src/backend/foreign/foreign.c b/src/backend/foreign/foreign.c
index 005282f17f6..821d45c1e11 100644
--- a/src/backend/foreign/foreign.c
+++ b/src/backend/foreign/foreign.c
@@ -48,7 +48,7 @@ GetForeignDataWrapper(Oid fdwid)
  * be found instead of raising an error.
  */
 ForeignDataWrapper *
-GetForeignDataWrapperExtended(Oid fdwid, bits16 flags)
+GetForeignDataWrapperExtended(Oid fdwid, uint16 flags)
 {
 	Form_pg_foreign_data_wrapper fdwform;
 	ForeignDataWrapper *fdw;
@@ -123,7 +123,7 @@ GetForeignServer(Oid serverid)
  * instead of raising an error.
  */
 ForeignServer *
-GetForeignServerExtended(Oid serverid, bits16 flags)
+GetForeignServerExtended(Oid serverid, uint16 flags)
 {
 	Form_pg_foreign_server serverform;
 	ForeignServer *server;
diff --git a/src/backend/nodes/gen_node_support.pl b/src/backend/nodes/gen_node_support.pl
index 4308751f787..a21f5a754bf 100644
--- a/src/backend/nodes/gen_node_support.pl
+++ b/src/backend/nodes/gen_node_support.pl
@@ -135,7 +135,7 @@ my @nodetag_only;
 
 # types that are copied by straight assignment
 my @scalar_types = qw(
-  bits32 bool char double int int8 int16 int32 int64 long uint8 uint16 uint32 uint64
+  bool char double int int8 int16 int32 int64 long uint8 uint16 uint32 uint64
   AclMode AttrNumber Cardinality Cost Index Oid RelFileNumber Selectivity Size StrategyNumber SubTransactionId TimeLineID XLogRecPtr
 );
 
@@ -1031,7 +1031,6 @@ _read${n}(void)
 			print $rff "\tREAD_INT_FIELD($f);\n" unless $no_read;
 		}
 		elsif ($t eq 'uint32'
-			|| $t eq 'bits32'
 			|| $t eq 'BlockNumber'
 			|| $t eq 'Index'
 			|| $t eq 'SubTransactionId')
diff --git a/src/backend/postmaster/bgworker.c b/src/backend/postmaster/bgworker.c
index 4d8b46adb46..f2a62489d9c 100644
--- a/src/backend/postmaster/bgworker.c
+++ b/src/backend/postmaster/bgworker.c
@@ -861,7 +861,7 @@ void
 BackgroundWorkerInitializeConnection(const char *dbname, const char *username, uint32 flags)
 {
 	BackgroundWorker *worker = MyBgworkerEntry;
-	bits32		init_flags = 0; /* never honor session_preload_libraries */
+	uint32		init_flags = 0; /* never honor session_preload_libraries */
 
 	/* ignore datallowconn and ACL_CONNECT? */
 	if (flags & BGWORKER_BYPASS_ALLOWCONN)
@@ -895,7 +895,7 @@ void
 BackgroundWorkerInitializeConnectionByOid(Oid dboid, Oid useroid, uint32 flags)
 {
 	BackgroundWorker *worker = MyBgworkerEntry;
-	bits32		init_flags = 0; /* never honor session_preload_libraries */
+	uint32		init_flags = 0; /* never honor session_preload_libraries */
 
 	/* ignore datallowconn and ACL_CONNECT? */
 	if (flags & BGWORKER_BYPASS_ALLOWCONN)
diff --git a/src/backend/postmaster/syslogger.c b/src/backend/postmaster/syslogger.c
index 9792f638718..0c2a7bc8578 100644
--- a/src/backend/postmaster/syslogger.c
+++ b/src/backend/postmaster/syslogger.c
@@ -887,7 +887,7 @@ process_pipe_input(char *logbuffer, int *bytes_in_logbuffer)
 	{
 		PipeProtoHeader p;
 		int			chunklen;
-		bits8		dest_flags;
+		uint8		dest_flags;
 
 		/* Do we have a valid header? */
 		memcpy(&p, cursor, offsetof(PipeProtoHeader, data));
diff --git a/src/backend/utils/activity/pgstat_backend.c b/src/backend/utils/activity/pgstat_backend.c
index f2f8d3ff75f..7727fed3bda 100644
--- a/src/backend/utils/activity/pgstat_backend.c
+++ b/src/backend/utils/activity/pgstat_backend.c
@@ -268,7 +268,7 @@ pgstat_flush_backend_entry_wal(PgStat_EntryRef *entry_ref)
  * if some statistics could not be flushed due to lock contention.
  */
 bool
-pgstat_flush_backend(bool nowait, bits32 flags)
+pgstat_flush_backend(bool nowait, uint32 flags)
 {
 	PgStat_EntryRef *entry_ref;
 	bool		has_pending_data = false;
diff --git a/src/backend/utils/adt/array_userfuncs.c b/src/backend/utils/adt/array_userfuncs.c
index 453a53a65fb..50c81a088df 100644
--- a/src/backend/utils/adt/array_userfuncs.c
+++ b/src/backend/utils/adt/array_userfuncs.c
@@ -337,7 +337,7 @@ array_cat(PG_FUNCTION_ARGS)
 	int			i;
 	char	   *dat1,
 			   *dat2;
-	bits8	   *bitmap1,
+	uint8	   *bitmap1,
 			   *bitmap2;
 	Oid			element_type;
 	Oid			element_type1;
@@ -1013,7 +1013,7 @@ array_agg_array_combine(PG_FUNCTION_ARGS)
 		{
 			int			size = (state2->aitems + 7) / 8;
 
-			state1->nullbitmap = (bits8 *) palloc(size);
+			state1->nullbitmap = (uint8 *) palloc(size);
 			memcpy(state1->nullbitmap, state2->nullbitmap, size);
 		}
 
@@ -1084,7 +1084,7 @@ array_agg_array_combine(PG_FUNCTION_ARGS)
 				 * previous inputs by marking all their items non-null.
 				 */
 				state1->aitems = pg_nextpower2_32(Max(256, newnitems + 1));
-				state1->nullbitmap = (bits8 *) palloc((state1->aitems + 7) / 8);
+				state1->nullbitmap = (uint8 *) palloc((state1->aitems + 7) / 8);
 				array_bitmap_copy(state1->nullbitmap, 0,
 								  NULL, 0,
 								  state1->nitems);
@@ -1094,7 +1094,7 @@ array_agg_array_combine(PG_FUNCTION_ARGS)
 				int			newaitems = state1->aitems + state2->aitems;
 
 				state1->aitems = pg_nextpower2_32(newaitems);
-				state1->nullbitmap = (bits8 *)
+				state1->nullbitmap = (uint8 *)
 					repalloc(state1->nullbitmap, (state1->aitems + 7) / 8);
 			}
 			array_bitmap_copy(state1->nullbitmap, state1->nitems,
@@ -1238,7 +1238,7 @@ array_agg_array_deserialize(PG_FUNCTION_ARGS)
 	{
 		int			size = (result->aitems + 7) / 8;
 
-		result->nullbitmap = (bits8 *) palloc(size);
+		result->nullbitmap = (uint8 *) palloc(size);
 		temp = pq_getmsgbytes(&buf, size);
 		memcpy(result->nullbitmap, temp, size);
 	}
diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c
index 734e5fea45e..2933a95c4a5 100644
--- a/src/backend/utils/adt/arrayfuncs.c
+++ b/src/backend/utils/adt/arrayfuncs.c
@@ -70,7 +70,7 @@ typedef struct ArrayIteratorData
 {
 	/* basic info about the array, set up during array_create_iterator() */
 	ArrayType  *arr;			/* array we're iterating through */
-	bits8	   *nullbitmap;		/* its null bitmap, if any */
+	uint8	   *nullbitmap;		/* its null bitmap, if any */
 	int			nitems;			/* total number of elements in array */
 	int16		typlen;			/* element type's length */
 	bool		typbyval;		/* element type's byval property */
@@ -120,26 +120,26 @@ static Datum array_set_element_expanded(Datum arraydatum,
 										Datum dataValue, bool isNull,
 										int arraytyplen,
 										int elmlen, bool elmbyval, char elmalign);
-static bool array_get_isnull(const bits8 *nullbitmap, int offset);
-static void array_set_isnull(bits8 *nullbitmap, int offset, bool isNull);
+static bool array_get_isnull(const uint8 *nullbitmap, int offset);
+static void array_set_isnull(uint8 *nullbitmap, int offset, bool isNull);
 static Datum ArrayCast(char *value, bool byval, int len);
 static int	ArrayCastAndSet(Datum src,
 							int typlen, bool typbyval, uint8 typalignby,
 							char *dest);
-static char *array_seek(char *ptr, int offset, bits8 *nullbitmap, int nitems,
+static char *array_seek(char *ptr, int offset, uint8 *nullbitmap, int nitems,
 						int typlen, bool typbyval, char typalign);
-static int	array_nelems_size(char *ptr, int offset, bits8 *nullbitmap,
+static int	array_nelems_size(char *ptr, int offset, uint8 *nullbitmap,
 							  int nitems, int typlen, bool typbyval, char typalign);
 static int	array_copy(char *destptr, int nitems,
-					   char *srcptr, int offset, bits8 *nullbitmap,
+					   char *srcptr, int offset, uint8 *nullbitmap,
 					   int typlen, bool typbyval, char typalign);
-static int	array_slice_size(char *arraydataptr, bits8 *arraynullsptr,
+static int	array_slice_size(char *arraydataptr, uint8 *arraynullsptr,
 							 int ndim, int *dim, int *lb,
 							 int *st, int *endp,
 							 int typlen, bool typbyval, char typalign);
 static void array_extract_slice(ArrayType *newarray,
 								int ndim, int *dim, int *lb,
-								char *arraydataptr, bits8 *arraynullsptr,
+								char *arraydataptr, uint8 *arraynullsptr,
 								int *st, int *endp,
 								int typlen, bool typbyval, char typalign);
 static void array_insert_slice(ArrayType *destArray, ArrayType *origArray,
@@ -972,7 +972,7 @@ CopyArrayEls(ArrayType *array,
 			 bool freedata)
 {
 	char	   *p = ARR_DATA_PTR(array);
-	bits8	   *bitmap = ARR_NULLBITMAP(array);
+	uint8	   *bitmap = ARR_NULLBITMAP(array);
 	int			bitval = 0;
 	int			bitmask = 1;
 	uint8		typalignby = typalign_to_alignby(typalign);
@@ -1839,7 +1839,7 @@ array_get_element(Datum arraydatum,
 				fixedLb[1];
 	char	   *arraydataptr,
 			   *retptr;
-	bits8	   *arraynullsptr;
+	uint8	   *arraynullsptr;
 
 	if (arraytyplen > 0)
 	{
@@ -2053,7 +2053,7 @@ array_get_slice(Datum arraydatum,
 				fixedLb[1];
 	Oid			elemtype;
 	char	   *arraydataptr;
-	bits8	   *arraynullsptr;
+	uint8	   *arraynullsptr;
 	int32		dataoffset;
 	int			bytes,
 				span[MAXDIM];
@@ -2221,7 +2221,7 @@ array_set_element(Datum arraydatum,
 				offset;
 	char	   *elt_ptr;
 	bool		newhasnulls;
-	bits8	   *oldnullbitmap;
+	uint8	   *oldnullbitmap;
 	int			oldnitems,
 				newnitems,
 				olddatasize,
@@ -2467,7 +2467,7 @@ array_set_element(Datum arraydatum,
 	 */
 	if (newhasnulls)
 	{
-		bits8	   *newnullbitmap = ARR_NULLBITMAP(newarray);
+		uint8	   *newnullbitmap = ARR_NULLBITMAP(newarray);
 
 		/* palloc0 above already marked any inserted positions as nulls */
 		/* Fix the inserted value */
@@ -3059,7 +3059,7 @@ array_set_slice(Datum arraydatum,
 		int			slicelb = Max(oldlb, lowerIndx[0]);
 		int			sliceub = Min(oldub, upperIndx[0]);
 		char	   *oldarraydata = ARR_DATA_PTR(array);
-		bits8	   *oldarraybitmap = ARR_NULLBITMAP(array);
+		uint8	   *oldarraybitmap = ARR_NULLBITMAP(array);
 
 		/* count/size of old array entries that will go before the slice */
 		itemsbefore = Min(slicelb, oldub + 1) - oldlb;
@@ -3121,8 +3121,8 @@ array_set_slice(Datum arraydatum,
 		/* fill in nulls bitmap if needed */
 		if (newhasnulls)
 		{
-			bits8	   *newnullbitmap = ARR_NULLBITMAP(newarray);
-			bits8	   *oldnullbitmap = ARR_NULLBITMAP(array);
+			uint8	   *newnullbitmap = ARR_NULLBITMAP(newarray);
+			uint8	   *oldnullbitmap = ARR_NULLBITMAP(array);
 
 			/* palloc0 above already marked any inserted positions as nulls */
 			array_bitmap_copy(newnullbitmap, addedbefore,
@@ -3644,7 +3644,7 @@ deconstruct_array(const ArrayType *array,
 	bool	   *nulls;
 	int			nelems;
 	char	   *p;
-	bits8	   *bitmap;
+	uint8	   *bitmap;
 	int			bitmask;
 	int			i;
 	uint8		elmalignby = typalign_to_alignby(elmalign);
@@ -3781,7 +3781,7 @@ bool
 array_contains_nulls(const ArrayType *array)
 {
 	int			nelems;
-	bits8	   *bitmap;
+	uint8	   *bitmap;
 	int			bitmask;
 
 	/* Easy answer if there's no null bitmap */
@@ -4791,7 +4791,7 @@ array_free_iterator(ArrayIterator iterator)
  * offset: 0-based linear element number of array element
  */
 static bool
-array_get_isnull(const bits8 *nullbitmap, int offset)
+array_get_isnull(const uint8 *nullbitmap, int offset)
 {
 	if (nullbitmap == NULL)
 		return false;			/* assume not null */
@@ -4808,7 +4808,7 @@ array_get_isnull(const bits8 *nullbitmap, int offset)
  * isNull: null status to set
  */
 static void
-array_set_isnull(bits8 *nullbitmap, int offset, bool isNull)
+array_set_isnull(uint8 *nullbitmap, int offset, bool isNull)
 {
 	int			bitmask;
 
@@ -4876,7 +4876,7 @@ ArrayCastAndSet(Datum src,
  * It is caller's responsibility to ensure that nitems is within range
  */
 static char *
-array_seek(char *ptr, int offset, bits8 *nullbitmap, int nitems,
+array_seek(char *ptr, int offset, uint8 *nullbitmap, int nitems,
 		   int typlen, bool typbyval, char typalign)
 {
 	uint8		typalignby = typalign_to_alignby(typalign);
@@ -4925,7 +4925,7 @@ array_seek(char *ptr, int offset, bits8 *nullbitmap, int nitems,
  * Parameters same as for array_seek
  */
 static int
-array_nelems_size(char *ptr, int offset, bits8 *nullbitmap, int nitems,
+array_nelems_size(char *ptr, int offset, uint8 *nullbitmap, int nitems,
 				  int typlen, bool typbyval, char typalign)
 {
 	return array_seek(ptr, offset, nullbitmap, nitems,
@@ -4948,7 +4948,7 @@ array_nelems_size(char *ptr, int offset, bits8 *nullbitmap, int nitems,
  */
 static int
 array_copy(char *destptr, int nitems,
-		   char *srcptr, int offset, bits8 *nullbitmap,
+		   char *srcptr, int offset, uint8 *nullbitmap,
 		   int typlen, bool typbyval, char typalign)
 {
 	int			numbytes;
@@ -4977,8 +4977,8 @@ array_copy(char *destptr, int nitems,
  * to make it worth worrying too much.  For the moment, KISS.
  */
 void
-array_bitmap_copy(bits8 *destbitmap, int destoffset,
-				  const bits8 *srcbitmap, int srcoffset,
+array_bitmap_copy(uint8 *destbitmap, int destoffset,
+				  const uint8 *srcbitmap, int srcoffset,
 				  int nitems)
 {
 	int			destbitmask,
@@ -5048,7 +5048,7 @@ array_bitmap_copy(bits8 *destbitmap, int destoffset,
  * We assume the caller has verified that the slice coordinates are valid.
  */
 static int
-array_slice_size(char *arraydataptr, bits8 *arraynullsptr,
+array_slice_size(char *arraydataptr, uint8 *arraynullsptr,
 				 int ndim, int *dim, int *lb,
 				 int *st, int *endp,
 				 int typlen, bool typbyval, char typalign)
@@ -5114,7 +5114,7 @@ array_extract_slice(ArrayType *newarray,
 					int *dim,
 					int *lb,
 					char *arraydataptr,
-					bits8 *arraynullsptr,
+					uint8 *arraynullsptr,
 					int *st,
 					int *endp,
 					int typlen,
@@ -5122,7 +5122,7 @@ array_extract_slice(ArrayType *newarray,
 					char typalign)
 {
 	char	   *destdataptr = ARR_DATA_PTR(newarray);
-	bits8	   *destnullsptr = ARR_NULLBITMAP(newarray);
+	uint8	   *destnullsptr = ARR_NULLBITMAP(newarray);
 	char	   *srcdataptr;
 	int			src_offset,
 				dest_offset,
@@ -5197,9 +5197,9 @@ array_insert_slice(ArrayType *destArray,
 	char	   *destPtr = ARR_DATA_PTR(destArray);
 	char	   *origPtr = ARR_DATA_PTR(origArray);
 	char	   *srcPtr = ARR_DATA_PTR(srcArray);
-	bits8	   *destBitmap = ARR_NULLBITMAP(destArray);
-	bits8	   *origBitmap = ARR_NULLBITMAP(origArray);
-	bits8	   *srcBitmap = ARR_NULLBITMAP(srcArray);
+	uint8	   *destBitmap = ARR_NULLBITMAP(destArray);
+	uint8	   *origBitmap = ARR_NULLBITMAP(origArray);
+	uint8	   *srcBitmap = ARR_NULLBITMAP(srcArray);
 	int			orignitems = ArrayGetNItems(ARR_NDIM(origArray),
 											ARR_DIMS(origArray));
 	int			dest_offset,
@@ -5679,7 +5679,7 @@ accumArrayResultArr(ArrayBuildStateArr *astate,
 			 * previous inputs by marking all their items non-null.
 			 */
 			astate->aitems = pg_nextpower2_32(Max(256, newnitems + 1));
-			astate->nullbitmap = (bits8 *) palloc((astate->aitems + 7) / 8);
+			astate->nullbitmap = (uint8 *) palloc((astate->aitems + 7) / 8);
 			array_bitmap_copy(astate->nullbitmap, 0,
 							  NULL, 0,
 							  astate->nitems);
@@ -5687,7 +5687,7 @@ accumArrayResultArr(ArrayBuildStateArr *astate,
 		else if (newnitems > astate->aitems)
 		{
 			astate->aitems = Max(astate->aitems * 2, newnitems);
-			astate->nullbitmap = (bits8 *)
+			astate->nullbitmap = (uint8 *)
 				repalloc(astate->nullbitmap, (astate->aitems + 7) / 8);
 		}
 		array_bitmap_copy(astate->nullbitmap, astate->nitems,
@@ -6419,7 +6419,7 @@ array_replace_internal(ArrayType *array,
 	char		typalign;
 	uint8		typalignby;
 	char	   *arraydataptr;
-	bits8	   *bitmap;
+	uint8	   *bitmap;
 	int			bitmask;
 	bool		changed = false;
 	TypeCacheEntry *typentry;
diff --git a/src/backend/utils/adt/format_type.c b/src/backend/utils/adt/format_type.c
index 3cd5053d118..7a5695c6245 100644
--- a/src/backend/utils/adt/format_type.c
+++ b/src/backend/utils/adt/format_type.c
@@ -62,7 +62,7 @@ format_type(PG_FUNCTION_ARGS)
 	Oid			type_oid;
 	int32		typemod;
 	char	   *result;
-	bits16		flags = FORMAT_TYPE_ALLOW_INVALID;
+	uint16		flags = FORMAT_TYPE_ALLOW_INVALID;
 
 	/* Since this function is not strict, we must test for null args */
 	if (PG_ARGISNULL(0))
@@ -109,7 +109,7 @@ format_type(PG_FUNCTION_ARGS)
  * Returns a palloc'd string, or NULL.
  */
 char *
-format_type_extended(Oid type_oid, int32 typemod, bits16 flags)
+format_type_extended(Oid type_oid, int32 typemod, uint16 flags)
 {
 	HeapTuple	tuple;
 	Form_pg_type typeform;
diff --git a/src/backend/utils/adt/misc.c b/src/backend/utils/adt/misc.c
index 29ef800d992..c033e68ba15 100644
--- a/src/backend/utils/adt/misc.c
+++ b/src/backend/utils/adt/misc.c
@@ -88,7 +88,7 @@ count_nulls(FunctionCallInfo fcinfo,
 		int			ndims,
 					nitems,
 				   *dims;
-		bits8	   *bitmap;
+		uint8	   *bitmap;
 
 		Assert(PG_NARGS() == 1);
 
diff --git a/src/backend/utils/adt/regproc.c b/src/backend/utils/adt/regproc.c
index ee34d1d85f8..64f293f4e98 100644
--- a/src/backend/utils/adt/regproc.c
+++ b/src/backend/utils/adt/regproc.c
@@ -329,7 +329,7 @@ format_procedure_qualified(Oid procedure_oid)
  *			always schema-qualify procedure names, regardless of search_path
  */
 char *
-format_procedure_extended(Oid procedure_oid, bits16 flags)
+format_procedure_extended(Oid procedure_oid, uint16 flags)
 {
 	char	   *result;
 	HeapTuple	proctup;
@@ -727,7 +727,7 @@ to_regoperator(PG_FUNCTION_ARGS)
  *			always schema-qualify operator names, regardless of search_path
  */
 char *
-format_operator_extended(Oid operator_oid, bits16 flags)
+format_operator_extended(Oid operator_oid, uint16 flags)
 {
 	char	   *result;
 	HeapTuple	opertup;
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 7bc12589e40..e5f2b6082ce 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1255,7 +1255,7 @@ pg_get_indexdef_columns(Oid indexrelid, bool pretty)
 
 /* Internal version, extensible with flags to control its behavior */
 char *
-pg_get_indexdef_columns_extended(Oid indexrelid, bits16 flags)
+pg_get_indexdef_columns_extended(Oid indexrelid, uint16 flags)
 {
 	bool		pretty = ((flags & RULE_INDEXDEF_PRETTY) != 0);
 	bool		keys_only = ((flags & RULE_INDEXDEF_KEYS_ONLY) != 0);
diff --git a/src/backend/utils/adt/varbit.c b/src/backend/utils/adt/varbit.c
index c46b5bae70d..7dde1b6db53 100644
--- a/src/backend/utils/adt/varbit.c
+++ b/src/backend/utils/adt/varbit.c
@@ -154,13 +154,13 @@ bit_in(PG_FUNCTION_ARGS)
 	Node	   *escontext = fcinfo->context;
 	VarBit	   *result;			/* The resulting bit string			  */
 	char	   *sp;				/* pointer into the character string  */
-	bits8	   *r;				/* pointer into the result */
+	uint8	   *r;				/* pointer into the result */
 	int			len,			/* Length of the whole data structure */
 				bitlen,			/* Number of bits in the bit string   */
 				slen;			/* Length of the input string		  */
 	bool		bit_not_hex;	/* false = hex string  true = bit string */
 	int			bc;
-	bits8		x = 0;
+	uint8		x = 0;
 
 	/* Check that the first character is a b or an x */
 	if (input_string[0] == 'b' || input_string[0] == 'B')
@@ -248,11 +248,11 @@ bit_in(PG_FUNCTION_ARGS)
 		for (bc = 0; *sp; sp++)
 		{
 			if (*sp >= '0' && *sp <= '9')
-				x = (bits8) (*sp - '0');
+				x = (uint8) (*sp - '0');
 			else if (*sp >= 'A' && *sp <= 'F')
-				x = (bits8) (*sp - 'A') + 10;
+				x = (uint8) (*sp - 'A') + 10;
 			else if (*sp >= 'a' && *sp <= 'f')
-				x = (bits8) (*sp - 'a') + 10;
+				x = (uint8) (*sp - 'a') + 10;
 			else
 				ereturn(escontext, (Datum) 0,
 						(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
@@ -291,7 +291,7 @@ bit_out(PG_FUNCTION_ARGS)
 	VarBit	   *s = PG_GETARG_VARBIT_P(0);
 	char	   *result,
 			   *r;
-	bits8	   *sp;
+	uint8	   *sp;
 	int			i,
 				len,
 				bitlen;
@@ -459,13 +459,13 @@ varbit_in(PG_FUNCTION_ARGS)
 	Node	   *escontext = fcinfo->context;
 	VarBit	   *result;			/* The resulting bit string			  */
 	char	   *sp;				/* pointer into the character string  */
-	bits8	   *r;				/* pointer into the result */
+	uint8	   *r;				/* pointer into the result */
 	int			len,			/* Length of the whole data structure */
 				bitlen,			/* Number of bits in the bit string   */
 				slen;			/* Length of the input string		  */
 	bool		bit_not_hex;	/* false = hex string  true = bit string */
 	int			bc;
-	bits8		x = 0;
+	uint8		x = 0;
 
 	/* Check that the first character is a b or an x */
 	if (input_string[0] == 'b' || input_string[0] == 'B')
@@ -549,11 +549,11 @@ varbit_in(PG_FUNCTION_ARGS)
 		for (bc = 0; *sp; sp++)
 		{
 			if (*sp >= '0' && *sp <= '9')
-				x = (bits8) (*sp - '0');
+				x = (uint8) (*sp - '0');
 			else if (*sp >= 'A' && *sp <= 'F')
-				x = (bits8) (*sp - 'A') + 10;
+				x = (uint8) (*sp - 'A') + 10;
 			else if (*sp >= 'a' && *sp <= 'f')
-				x = (bits8) (*sp - 'a') + 10;
+				x = (uint8) (*sp - 'a') + 10;
 			else
 				ereturn(escontext, (Datum) 0,
 						(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
@@ -589,8 +589,8 @@ varbit_out(PG_FUNCTION_ARGS)
 	VarBit	   *s = PG_GETARG_VARBIT_P(0);
 	char	   *result,
 			   *r;
-	bits8	   *sp;
-	bits8		x;
+	uint8	   *sp;
+	uint8		x;
 	int			i,
 				k,
 				len;
@@ -982,7 +982,7 @@ bit_catenate(VarBit *arg1, VarBit *arg2)
 				bytelen,
 				bit1pad,
 				bit2shift;
-	bits8	   *pr,
+	uint8	   *pr,
 			   *pa;
 
 	bitlen1 = VARBITLEN(arg1);
@@ -1063,7 +1063,7 @@ bitsubstring(VarBit *arg, int32 s, int32 l, bool length_not_specified)
 	int32		e,
 				s1,
 				e1;
-	bits8	   *r,
+	uint8	   *r,
 			   *ps;
 
 	bitlen = VARBITLEN(arg);
@@ -1249,7 +1249,7 @@ bit_and(PG_FUNCTION_ARGS)
 				bitlen1,
 				bitlen2,
 				i;
-	bits8	   *p1,
+	uint8	   *p1,
 			   *p2,
 			   *r;
 
@@ -1290,7 +1290,7 @@ bit_or(PG_FUNCTION_ARGS)
 				bitlen1,
 				bitlen2,
 				i;
-	bits8	   *p1,
+	uint8	   *p1,
 			   *p2,
 			   *r;
 
@@ -1330,7 +1330,7 @@ bitxor(PG_FUNCTION_ARGS)
 				bitlen1,
 				bitlen2,
 				i;
-	bits8	   *p1,
+	uint8	   *p1,
 			   *p2,
 			   *r;
 
@@ -1366,7 +1366,7 @@ bitnot(PG_FUNCTION_ARGS)
 {
 	VarBit	   *arg = PG_GETARG_VARBIT_P(0);
 	VarBit	   *result;
-	bits8	   *p,
+	uint8	   *p,
 			   *r;
 
 	result = (VarBit *) palloc(VARSIZE(arg));
@@ -1397,7 +1397,7 @@ bitshiftleft(PG_FUNCTION_ARGS)
 	int			byte_shift,
 				ishift,
 				len;
-	bits8	   *p,
+	uint8	   *p,
 			   *r;
 
 	/* Negative shift is a shift to the right */
@@ -1464,7 +1464,7 @@ bitshiftright(PG_FUNCTION_ARGS)
 	int			byte_shift,
 				ishift,
 				len;
-	bits8	   *p,
+	uint8	   *p,
 			   *r;
 
 	/* Negative shift is a shift to the left */
@@ -1533,7 +1533,7 @@ bitfromint4(PG_FUNCTION_ARGS)
 	int32		a = PG_GETARG_INT32(0);
 	int32		typmod = PG_GETARG_INT32(1);
 	VarBit	   *result;
-	bits8	   *r;
+	uint8	   *r;
 	int			rlen;
 	int			destbitsleft,
 				srcbitsleft;
@@ -1554,7 +1554,7 @@ bitfromint4(PG_FUNCTION_ARGS)
 	/* sign-fill any excess bytes in output */
 	while (destbitsleft >= srcbitsleft + 8)
 	{
-		*r++ = (bits8) ((a < 0) ? BITMASK : 0);
+		*r++ = (uint8) ((a < 0) ? BITMASK : 0);
 		destbitsleft -= 8;
 	}
 	/* store first fractional byte */
@@ -1565,19 +1565,19 @@ bitfromint4(PG_FUNCTION_ARGS)
 		/* Force sign-fill in case the compiler implements >> as zero-fill */
 		if (a < 0)
 			val |= ((unsigned int) -1) << (srcbitsleft + 8 - destbitsleft);
-		*r++ = (bits8) (val & BITMASK);
+		*r++ = (uint8) (val & BITMASK);
 		destbitsleft -= 8;
 	}
 	/* Now srcbitsleft and destbitsleft are the same, need not track both */
 	/* store whole bytes */
 	while (destbitsleft >= 8)
 	{
-		*r++ = (bits8) ((a >> (destbitsleft - 8)) & BITMASK);
+		*r++ = (uint8) ((a >> (destbitsleft - 8)) & BITMASK);
 		destbitsleft -= 8;
 	}
 	/* store last fractional byte */
 	if (destbitsleft > 0)
-		*r = (bits8) ((a << (8 - destbitsleft)) & BITMASK);
+		*r = (uint8) ((a << (8 - destbitsleft)) & BITMASK);
 
 	PG_RETURN_VARBIT_P(result);
 }
@@ -1587,7 +1587,7 @@ bittoint4(PG_FUNCTION_ARGS)
 {
 	VarBit	   *arg = PG_GETARG_VARBIT_P(0);
 	uint32		result;
-	bits8	   *r;
+	uint8	   *r;
 
 	/* Check that the bit string is not too long */
 	if (VARBITLEN(arg) > sizeof(result) * BITS_PER_BYTE)
@@ -1613,7 +1613,7 @@ bitfromint8(PG_FUNCTION_ARGS)
 	int64		a = PG_GETARG_INT64(0);
 	int32		typmod = PG_GETARG_INT32(1);
 	VarBit	   *result;
-	bits8	   *r;
+	uint8	   *r;
 	int			rlen;
 	int			destbitsleft,
 				srcbitsleft;
@@ -1634,7 +1634,7 @@ bitfromint8(PG_FUNCTION_ARGS)
 	/* sign-fill any excess bytes in output */
 	while (destbitsleft >= srcbitsleft + 8)
 	{
-		*r++ = (bits8) ((a < 0) ? BITMASK : 0);
+		*r++ = (uint8) ((a < 0) ? BITMASK : 0);
 		destbitsleft -= 8;
 	}
 	/* store first fractional byte */
@@ -1645,19 +1645,19 @@ bitfromint8(PG_FUNCTION_ARGS)
 		/* Force sign-fill in case the compiler implements >> as zero-fill */
 		if (a < 0)
 			val |= ((unsigned int) -1) << (srcbitsleft + 8 - destbitsleft);
-		*r++ = (bits8) (val & BITMASK);
+		*r++ = (uint8) (val & BITMASK);
 		destbitsleft -= 8;
 	}
 	/* Now srcbitsleft and destbitsleft are the same, need not track both */
 	/* store whole bytes */
 	while (destbitsleft >= 8)
 	{
-		*r++ = (bits8) ((a >> (destbitsleft - 8)) & BITMASK);
+		*r++ = (uint8) ((a >> (destbitsleft - 8)) & BITMASK);
 		destbitsleft -= 8;
 	}
 	/* store last fractional byte */
 	if (destbitsleft > 0)
-		*r = (bits8) ((a << (8 - destbitsleft)) & BITMASK);
+		*r = (uint8) ((a << (8 - destbitsleft)) & BITMASK);
 
 	PG_RETURN_VARBIT_P(result);
 }
@@ -1667,7 +1667,7 @@ bittoint8(PG_FUNCTION_ARGS)
 {
 	VarBit	   *arg = PG_GETARG_VARBIT_P(0);
 	uint64		result;
-	bits8	   *r;
+	uint8	   *r;
 
 	/* Check that the bit string is not too long */
 	if (VARBITLEN(arg) > sizeof(result) * BITS_PER_BYTE)
@@ -1703,9 +1703,9 @@ bitposition(PG_FUNCTION_ARGS)
 				str_length,
 				i,
 				is;
-	bits8	   *s,				/* pointer into substring */
+	uint8	   *s,				/* pointer into substring */
 			   *p;				/* pointer into str */
-	bits8		cmp,			/* shifted substring byte to compare */
+	uint8		cmp,			/* shifted substring byte to compare */
 				mask1,			/* mask for substring byte shifted right */
 				mask2,			/* mask for substring byte shifted left */
 				end_mask,		/* pad mask for last substring byte */
@@ -1812,7 +1812,7 @@ bitsetbit(PG_FUNCTION_ARGS)
 	VarBit	   *result;
 	int			len,
 				bitlen;
-	bits8	   *r,
+	uint8	   *r,
 			   *p;
 	int			byteNo,
 				bitNo;
@@ -1871,7 +1871,7 @@ bitgetbit(PG_FUNCTION_ARGS)
 	VarBit	   *arg1 = PG_GETARG_VARBIT_P(0);
 	int32		n = PG_GETARG_INT32(1);
 	int			bitlen;
-	bits8	   *p;
+	uint8	   *p;
 	int			byteNo,
 				bitNo;
 
diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c
index 7b1ee61bde6..ecad6d62184 100644
--- a/src/backend/utils/adt/varlena.c
+++ b/src/backend/utils/adt/varlena.c
@@ -3952,7 +3952,7 @@ array_to_text_internal(FunctionCallInfo fcinfo, ArrayType *v,
 	StringInfoData buf;
 	bool		printed = false;
 	char	   *p;
-	bits8	   *bitmap;
+	uint8	   *bitmap;
 	int			bitmask;
 	int			i;
 	ArrayMetaState *my_extra;
diff --git a/src/backend/utils/fmgr/funcapi.c b/src/backend/utils/fmgr/funcapi.c
index 516d02cfb82..6f0785067b8 100644
--- a/src/backend/utils/fmgr/funcapi.c
+++ b/src/backend/utils/fmgr/funcapi.c
@@ -73,7 +73,7 @@ static TypeFuncClass get_type_func_class(Oid typid, Oid *base_typeid);
  * RECORD datatype.
  */
 void
-InitMaterializedSRF(FunctionCallInfo fcinfo, bits32 flags)
+InitMaterializedSRF(FunctionCallInfo fcinfo, uint32 flags)
 {
 	bool		random_access;
 	ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c
index 26118661f07..577ef5effbb 100644
--- a/src/backend/utils/init/postinit.c
+++ b/src/backend/utils/init/postinit.c
@@ -718,7 +718,7 @@ BaseInit(void)
 void
 InitPostgres(const char *in_dbname, Oid dboid,
 			 const char *username, Oid useroid,
-			 bits32 flags,
+			 uint32 flags,
 			 char *out_dbname)
 {
 	bool		bootstrap = IsBootstrapProcessingMode();
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index 44c10a71d29..37631f700af 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -94,7 +94,7 @@ struct LogicalRepInfos
 {
 	struct LogicalRepInfo *dbinfo;
 	bool		two_phase;		/* enable-two-phase option */
-	bits32		objecttypes_to_clean;	/* flags indicating which object types
+	uint32		objecttypes_to_clean;	/* flags indicating which object types
 										 * to clean up on subscriber */
 };
 
diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c
index 523d3f39fc5..adcff1f6ffb 100644
--- a/src/bin/psql/tab-complete.in.c
+++ b/src/bin/psql/tab-complete.in.c
@@ -1296,7 +1296,7 @@ typedef struct
 	const VersionedQuery *vquery;	/* versioned query, or NULL */
 	const SchemaQuery *squery;	/* schema query, or NULL */
 	const char *const *keywords;	/* keywords to be offered as well */
-	const bits32 flags;			/* visibility flags, see below */
+	const uint32 flags;			/* visibility flags, see below */
 } pgsql_thing_t;
 
 #define THING_NO_CREATE		(1 << 0)	/* should not show up after CREATE */
@@ -5839,7 +5839,7 @@ match_previous_words(int pattern_id,
  * Entries that have 'excluded' flags are not returned.
  */
 static char *
-create_or_drop_command_generator(const char *text, int state, bits32 excluded)
+create_or_drop_command_generator(const char *text, int state, uint32 excluded)
 {
 	static int	list_index,
 				string_length;
diff --git a/src/bin/scripts/vacuumdb.c b/src/bin/scripts/vacuumdb.c
index e0c4dd7086c..ccc7f88a291 100644
--- a/src/bin/scripts/vacuumdb.c
+++ b/src/bin/scripts/vacuumdb.c
@@ -20,7 +20,7 @@
 #include "vacuuming.h"
 
 static void help(const char *progname);
-static void check_objfilter(bits32 objfilter);
+static void check_objfilter(uint32 objfilter);

 int
@@ -322,7 +322,7 @@ main(int argc, char *argv[])
  * Verify that the filters used at command line are compatible.
  */
 void
-check_objfilter(bits32 objfilter)
+check_objfilter(uint32 objfilter)
 {
 	if ((objfilter & OBJFILTER_ALL_DBS) &&
 		(objfilter & OBJFILTER_DATABASE))
diff --git a/src/bin/scripts/vacuuming.h b/src/bin/scripts/vacuuming.h
index be4a75ef2f4..5a491db2526 100644
--- a/src/bin/scripts/vacuuming.h
+++ b/src/bin/scripts/vacuuming.h
@@ -32,7 +32,7 @@ typedef enum
 typedef struct vacuumingOptions
 {
 	RunMode		mode;
-	bits32		objfilter;
+	uint32		objfilter;
 	bool		verbose;
 	bool		and_analyze;
 	bool		full;
diff --git a/src/include/access/heapam.h b/src/include/access/heapam.h
index 4e982d76889..696b1f49a9d 100644
--- a/src/include/access/heapam.h
+++ b/src/include/access/heapam.h
@@ -376,9 +376,9 @@ extern void FreeBulkInsertState(BulkInsertState);
 extern void ReleaseBulkInsertStatePin(BulkInsertState bistate);
 
 extern void heap_insert(Relation relation, HeapTuple tup, CommandId cid,
-						bits32 options, BulkInsertState bistate);
+						uint32 options, BulkInsertState bistate);
 extern void heap_multi_insert(Relation relation, TupleTableSlot **slots,
-							  int ntuples, CommandId cid, bits32 options,
+							  int ntuples, CommandId cid, uint32 options,
 							  BulkInsertState bistate);
 extern TM_Result heap_delete(Relation relation, const ItemPointerData *tid,
 							 CommandId cid, Snapshot crosscheck, bool wait,
diff --git a/src/include/access/htup_details.h b/src/include/access/htup_details.h
index 75f8b159b8a..77a6c48fd71 100644
--- a/src/include/access/htup_details.h
+++ b/src/include/access/htup_details.h
@@ -175,7 +175,7 @@ struct HeapTupleHeaderData
 	/* ^ - 23 bytes - ^ */
 
 #define FIELDNO_HEAPTUPLEHEADERDATA_BITS 5
-	bits8		t_bits[FLEXIBLE_ARRAY_MEMBER];	/* bitmap of NULLs */
+	uint8		t_bits[FLEXIBLE_ARRAY_MEMBER];	/* bitmap of NULLs */
 
 	/* MORE DATA FOLLOWS AT END OF STRUCT */
 };
@@ -680,7 +680,7 @@ struct MinimalTupleData
 
 	/* ^ - 23 bytes - ^ */
 
-	bits8		t_bits[FLEXIBLE_ARRAY_MEMBER];	/* bitmap of NULLs */
+	uint8		t_bits[FLEXIBLE_ARRAY_MEMBER];	/* bitmap of NULLs */
 
 	/* MORE DATA FOLLOWS AT END OF STRUCT */
 };
@@ -797,7 +797,7 @@ extern Size heap_compute_data_size(TupleDesc tupleDesc,
 extern void heap_fill_tuple(TupleDesc tupleDesc,
 							const Datum *values, const bool *isnull,
 							char *data, Size data_size,
-							uint16 *infomask, bits8 *bit);
+							uint16 *infomask, uint8 *bit);
 extern bool heap_attisnull(HeapTuple tup, int attnum, TupleDesc tupleDesc);
 extern Datum nocachegetattr(HeapTuple tup, int attnum,
 							TupleDesc tupleDesc);
diff --git a/src/include/access/itup.h b/src/include/access/itup.h
index 57e4daafb0d..5758bbdf6eb 100644
--- a/src/include/access/itup.h
+++ b/src/include/access/itup.h
@@ -54,7 +54,7 @@ typedef IndexTupleData *IndexTuple;
 
 typedef struct IndexAttributeBitMapData
 {
-	bits8		bits[(INDEX_MAX_KEYS + 8 - 1) / 8];
+	uint8		bits[(INDEX_MAX_KEYS + 8 - 1) / 8];
 }			IndexAttributeBitMapData;
 
 typedef IndexAttributeBitMapData * IndexAttributeBitMap;
@@ -99,7 +99,7 @@ extern void index_deform_tuple(IndexTuple tup, TupleDesc tupleDescriptor,
 							   Datum *values, bool *isnull);
 extern void index_deform_tuple_internal(TupleDesc tupleDescriptor,
 										Datum *values, bool *isnull,
-										char *tp, bits8 *bp, int hasnulls);
+										char *tp, uint8 *bp, int hasnulls);
 extern IndexTuple CopyIndexTuple(IndexTuple source);
 extern IndexTuple index_truncate_tuple(TupleDesc sourceDescriptor,
 									   IndexTuple source, int leavenatts);
@@ -151,7 +151,7 @@ index_getattr(IndexTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
 	}
 	else
 	{
-		if (att_isnull(attnum - 1, (bits8 *) tup + sizeof(IndexTupleData)))
+		if (att_isnull(attnum - 1, (uint8 *) tup + sizeof(IndexTupleData)))
 		{
 			*isnull = true;
 			return (Datum) 0;
diff --git a/src/include/access/reloptions.h b/src/include/access/reloptions.h
index c228147420a..e8cb7f7a627 100644
--- a/src/include/access/reloptions.h
+++ b/src/include/access/reloptions.h
@@ -66,7 +66,7 @@ typedef struct relopt_gen
 	const char *name;			/* must be first (used as list termination
 								 * marker) */
 	const char *desc;
-	bits32		kinds;
+	uint32		kinds;
 	LOCKMODE	lockmode;
 	int			namelen;
 	relopt_type type;
@@ -187,20 +187,20 @@ typedef struct local_relopts
 	 (char *)(optstruct) + (optstruct)->member)
 
 extern relopt_kind add_reloption_kind(void);
-extern void add_bool_reloption(bits32 kinds, const char *name, const char *desc,
+extern void add_bool_reloption(uint32 kinds, const char *name, const char *desc,
 							   bool default_val, LOCKMODE lockmode);
-extern void add_ternary_reloption(bits32 kinds, const char *name,
+extern void add_ternary_reloption(uint32 kinds, const char *name,
 								  const char *desc, LOCKMODE lockmode);
-extern void add_int_reloption(bits32 kinds, const char *name, const char *desc,
+extern void add_int_reloption(uint32 kinds, const char *name, const char *desc,
 							  int default_val, int min_val, int max_val,
 							  LOCKMODE lockmode);
-extern void add_real_reloption(bits32 kinds, const char *name, const char *desc,
+extern void add_real_reloption(uint32 kinds, const char *name, const char *desc,
 							   double default_val, double min_val, double max_val,
 							   LOCKMODE lockmode);
-extern void add_enum_reloption(bits32 kinds, const char *name, const char *desc,
+extern void add_enum_reloption(uint32 kinds, const char *name, const char *desc,
 							   relopt_enum_elt_def *members, int default_val,
 							   const char *detailmsg, LOCKMODE lockmode);
-extern void add_string_reloption(bits32 kinds, const char *name, const char *desc,
+extern void add_string_reloption(uint32 kinds, const char *name, const char *desc,
 								 const char *default_val, validate_string_relopt validator,
 								 LOCKMODE lockmode);
 
diff --git a/src/include/access/tableam.h b/src/include/access/tableam.h
index cd14f242d65..e0d27afa876 100644
--- a/src/include/access/tableam.h
+++ b/src/include/access/tableam.h
@@ -530,14 +530,14 @@ typedef struct TableAmRoutine
 
 	/* see table_tuple_insert() for reference about parameters */
 	void		(*tuple_insert) (Relation rel, TupleTableSlot *slot,
-								 CommandId cid, bits32 options,
+								 CommandId cid, uint32 options,
 								 BulkInsertStateData *bistate);
 
 	/* see table_tuple_insert_speculative() for reference about parameters */
 	void		(*tuple_insert_speculative) (Relation rel,
 											 TupleTableSlot *slot,
 											 CommandId cid,
-											 bits32 options,
+											 uint32 options,
 											 BulkInsertStateData *bistate,
 											 uint32 specToken);
 
@@ -549,7 +549,7 @@ typedef struct TableAmRoutine
 
 	/* see table_multi_insert() for reference about parameters */
 	void		(*multi_insert) (Relation rel, TupleTableSlot **slots, int nslots,
-								 CommandId cid, bits32 options, BulkInsertStateData *bistate);
+								 CommandId cid, uint32 options, BulkInsertStateData *bistate);
 
 	/* see table_tuple_delete() for reference about parameters */
 	TM_Result	(*tuple_delete) (Relation rel,
@@ -596,7 +596,7 @@ typedef struct TableAmRoutine
 	 *
 	 * Optional callback.
 	 */
-	void		(*finish_bulk_insert) (Relation rel, bits32 options);
+	void		(*finish_bulk_insert) (Relation rel, uint32 options);

 	/* ------------------------------------------------------------------------
@@ -1440,7 +1440,7 @@ table_index_delete_tuples(Relation rel, TM_IndexDeleteOp *delstate)
  */
 static inline void
 table_tuple_insert(Relation rel, TupleTableSlot *slot, CommandId cid,
-				   bits32 options, BulkInsertStateData *bistate)
+				   uint32 options, BulkInsertStateData *bistate)
 {
 	rel->rd_tableam->tuple_insert(rel, slot, cid, options,
 								  bistate);
@@ -1459,7 +1459,7 @@ table_tuple_insert(Relation rel, TupleTableSlot *slot, CommandId cid,
  */
 static inline void
 table_tuple_insert_speculative(Relation rel, TupleTableSlot *slot,
-							   CommandId cid, bits32 options,
+							   CommandId cid, uint32 options,
 							   BulkInsertStateData *bistate,
 							   uint32 specToken)
 {
@@ -1495,7 +1495,7 @@ table_tuple_complete_speculative(Relation rel, TupleTableSlot *slot,
  */
 static inline void
 table_multi_insert(Relation rel, TupleTableSlot **slots, int nslots,
-				   CommandId cid, bits32 options, BulkInsertStateData *bistate)
+				   CommandId cid, uint32 options, BulkInsertStateData *bistate)
 {
 	rel->rd_tableam->multi_insert(rel, slots, nslots,
 								  cid, options, bistate);
@@ -1636,7 +1636,7 @@ table_tuple_lock(Relation rel, ItemPointer tid, Snapshot snapshot,
  * tuple_insert and multi_insert with a BulkInsertState specified.
  */
 static inline void
-table_finish_bulk_insert(Relation rel, bits32 options)
+table_finish_bulk_insert(Relation rel, uint32 options)
 {
 	/* optional callback */
 	if (rel->rd_tableam && rel->rd_tableam->finish_bulk_insert)
diff --git a/src/include/access/tupmacs.h b/src/include/access/tupmacs.h
index a447b41c128..fa76d0f2eac 100644
--- a/src/include/access/tupmacs.h
+++ b/src/include/access/tupmacs.h
@@ -25,7 +25,7 @@
  * non-null.
  */
 static inline bool
-att_isnull(int ATT, const bits8 *BITS)
+att_isnull(int ATT, const uint8 *BITS)
 {
 	return !(BITS[ATT >> 3] & (1 << (ATT & 0x07)));
 }
@@ -40,7 +40,7 @@ att_isnull(int ATT, const bits8 *BITS)
  * effectively as if natts is rounded up to the next multiple of 8.
  */
 static inline void
-populate_isnull_array(const bits8 *bits, int natts, bool *isnull)
+populate_isnull_array(const uint8 *bits, int natts, bool *isnull)
 {
 	int			nbytes = (natts + 7) >> 3;
 
@@ -60,7 +60,7 @@ populate_isnull_array(const bits8 *bits, int natts, bool *isnull)
 	for (int i = 0; i < nbytes; i++, isnull += 8)
 	{
 		uint64		isnull_8;
-		bits8		nullbyte = ~bits[i];
+		uint8		nullbyte = ~bits[i];
 
 		/* Convert the lower 4 bits of NULL bitmap word into a 64 bit int */
 		isnull_8 = (nullbyte & 0xf) * SPREAD_BITS_MULTIPLIER_32;
@@ -241,7 +241,7 @@ align_fetch_then_add(const char *tupptr, uint32 *off, bool attbyval, int attlen,
  * case.
  */
 static inline int
-first_null_attr(const bits8 *bits, int natts)
+first_null_attr(const uint8 *bits, int natts)
 {
 	int			nattByte = natts >> 3;
 	int			bytenum;
diff --git a/src/include/c.h b/src/include/c.h
index fd6b093bb3a..0b2eb9ce866 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -618,14 +618,6 @@ typedef uint16_t uint16;
 typedef uint32_t uint32;
 typedef uint64_t uint64;
 
-/*
- * bitsN
- *		Unit of bitwise operation, AT LEAST N BITS IN SIZE.
- */
-typedef uint8 bits8;			/* >= 8 bits */
-typedef uint16 bits16;			/* >= 16 bits */
-typedef uint32 bits32;			/* >= 32 bits */
-
 /*
  * 64-bit integers
  */
diff --git a/src/include/catalog/index.h b/src/include/catalog/index.h
index 36b70689254..a38e95bc0eb 100644
--- a/src/include/catalog/index.h
+++ b/src/include/catalog/index.h
@@ -38,7 +38,7 @@ typedef enum
 /* options for REINDEX */
 typedef struct ReindexParams
 {
-	bits32		options;		/* bitmask of REINDEXOPT_* */
+	uint32		options;		/* bitmask of REINDEXOPT_* */
 	Oid			tablespaceOid;	/* New tablespace to move indexes to.
 								 * InvalidOid to do nothing. */
 } ReindexParams;
@@ -88,8 +88,8 @@ extern Oid	index_create(Relation heapRelation,
 						 const int16 *coloptions,
 						 const NullableDatum *stattargets,
 						 Datum reloptions,
-						 bits16 flags,
-						 bits16 constr_flags,
+						 uint16 flags,
+						 uint16 constr_flags,
 						 bool allow_system_table_mods,
 						 bool is_internal,
 						 Oid *constraintId);
@@ -122,7 +122,7 @@ extern ObjectAddress index_constraint_create(Relation heapRelation,
 											 const IndexInfo *indexInfo,
 											 const char *constraintName,
 											 char constraintType,
-											 bits16 constr_flags,
+											 uint16 constr_flags,
 											 bool allow_system_table_mods,
 											 bool is_internal);
 
diff --git a/src/include/commands/cluster.h b/src/include/commands/cluster.h
index c79cd2d0e19..d6b62c747e8 100644
--- a/src/include/commands/cluster.h
+++ b/src/include/commands/cluster.h
@@ -29,7 +29,7 @@
 /* options for CLUSTER */
 typedef struct ClusterParams
 {
-	bits32		options;		/* bitmask of CLUOPT_* */
+	uint32		options;		/* bitmask of CLUOPT_* */
 } ClusterParams;

diff --git a/src/include/commands/vacuum.h b/src/include/commands/vacuum.h
index 1f45bca015c..5d351f0df33 100644
--- a/src/include/commands/vacuum.h
+++ b/src/include/commands/vacuum.h
@@ -215,7 +215,7 @@ typedef enum VacOptValue
  */
 typedef struct VacuumParams
 {
-	bits32		options;		/* bitmask of VACOPT_* */
+	uint32		options;		/* bitmask of VACOPT_* */
 	int			freeze_min_age; /* min freeze age, -1 to use default */
 	int			freeze_table_age;	/* age at which to scan whole table */
 	int			multixact_freeze_min_age;	/* min multixact freeze age, -1 to
@@ -389,9 +389,9 @@ extern bool vacuum_xid_failsafe_check(const struct VacuumCutoffs *cutoffs);
 extern void vac_update_datfrozenxid(void);
 extern void vacuum_delay_point(bool is_analyze);
 extern bool vacuum_is_permitted_for_relation(Oid relid, Form_pg_class reltuple,
-											 bits32 options);
+											 uint32 options);
 extern Relation vacuum_open_relation(Oid relid, RangeVar *relation,
-									 bits32 options, bool verbose,
+									 uint32 options, bool verbose,
 									 LOCKMODE lmode);
 extern IndexBulkDeleteResult *vac_bulkdel_one_index(IndexVacuumInfo *ivinfo,
 													IndexBulkDeleteResult *istat,
diff --git a/src/include/common/jsonapi.h b/src/include/common/jsonapi.h
index 71310c85f2e..85cc9a11d97 100644
--- a/src/include/common/jsonapi.h
+++ b/src/include/common/jsonapi.h
@@ -108,7 +108,7 @@ typedef struct JsonLexContext
 	bool		incremental;
 	JsonTokenType token_type;
 	int			lex_level;
-	bits32		flags;
+	uint32		flags;
 	int			line_number;	/* line number, starting from 1 */
 	const char *line_start;		/* where that line starts within input */
 	JsonParserStack *pstack;
diff --git a/src/include/executor/executor.h b/src/include/executor/executor.h
index 07f4b1f7490..773e47144aa 100644
--- a/src/include/executor/executor.h
+++ b/src/include/executor/executor.h
@@ -749,7 +749,7 @@ extern void ExecCloseIndices(ResultRelInfo *resultRelInfo);
 #define		EIIT_NO_DUPE_ERROR		(1<<1)
 #define		EIIT_ONLY_SUMMARIZING	(1<<2)
 extern List *ExecInsertIndexTuples(ResultRelInfo *resultRelInfo, EState *estate,
-								   bits32 options, TupleTableSlot *slot,
+								   uint32 options, TupleTableSlot *slot,
 								   List *arbiterIndexes,
 								   bool *specConflict);
 extern bool ExecCheckIndexConstraints(ResultRelInfo *resultRelInfo,
diff --git a/src/include/executor/instrument_node.h b/src/include/executor/instrument_node.h
index 8847d7f94fa..2a0ff377a73 100644
--- a/src/include/executor/instrument_node.h
+++ b/src/include/executor/instrument_node.h
@@ -192,7 +192,7 @@ typedef struct IncrementalSortGroupInfo
 	int64		totalDiskSpaceUsed;
 	int64		maxMemorySpaceUsed;
 	int64		totalMemorySpaceUsed;
-	bits32		sortMethods;	/* bitmask of TuplesortMethod */
+	uint32		sortMethods;	/* bitmask of TuplesortMethod */
 } IncrementalSortGroupInfo;
 
 typedef struct IncrementalSortInfo
diff --git a/src/include/foreign/foreign.h b/src/include/foreign/foreign.h
index 564c3cc1b7f..92a55214fee 100644
--- a/src/include/foreign/foreign.h
+++ b/src/include/foreign/foreign.h
@@ -67,7 +67,7 @@ typedef struct ForeignTable
 
 extern ForeignServer *GetForeignServer(Oid serverid);
 extern ForeignServer *GetForeignServerExtended(Oid serverid,
-											   bits16 flags);
+											   uint16 flags);
 extern ForeignServer *GetForeignServerByName(const char *srvname,
 											 bool missing_ok);
 extern char *ForeignServerConnectionString(Oid userid,
@@ -75,7 +75,7 @@ extern char *ForeignServerConnectionString(Oid userid,
 extern UserMapping *GetUserMapping(Oid userid, Oid serverid);
 extern ForeignDataWrapper *GetForeignDataWrapper(Oid fdwid);
 extern ForeignDataWrapper *GetForeignDataWrapperExtended(Oid fdwid,
-														 bits16 flags);
+														 uint16 flags);
 extern ForeignDataWrapper *GetForeignDataWrapperByName(const char *fdwname,
 													   bool missing_ok);
 extern ForeignTable *GetForeignTable(Oid relid);
diff --git a/src/include/funcapi.h b/src/include/funcapi.h
index eb119d9854f..a31d6857a35 100644
--- a/src/include/funcapi.h
+++ b/src/include/funcapi.h
@@ -296,7 +296,7 @@ HeapTupleGetDatum(const HeapTupleData *tuple)
 #define MAT_SRF_USE_EXPECTED_DESC	0x01	/* use expectedDesc as tupdesc. */
 #define MAT_SRF_BLESS				0x02	/* "Bless" a tuple descriptor with
 											 * BlessTupleDesc(). */
-extern void InitMaterializedSRF(FunctionCallInfo fcinfo, bits32 flags);
+extern void InitMaterializedSRF(FunctionCallInfo fcinfo, uint32 flags);
 
 extern FuncCallContext *init_MultiFuncCall(PG_FUNCTION_ARGS);
 extern FuncCallContext *per_MultiFuncCall(PG_FUNCTION_ARGS);
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index f16f35659b9..04f29748be7 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -504,7 +504,7 @@ extern void InitializeMaxBackends(void);
 extern void InitializeFastPathLocks(void);
 extern void InitPostgres(const char *in_dbname, Oid dboid,
 						 const char *username, Oid useroid,
-						 bits32 flags,
+						 uint32 flags,
 						 char *out_dbname);
 extern void BaseInit(void);
 extern void StoreConnectionWarning(char *msg, char *detail);
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index df431220ac5..a501cdfb249 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -793,7 +793,7 @@ typedef struct TableLikeClause
 {
 	NodeTag		type;
 	RangeVar   *relation;
-	bits32		options;		/* OR of TableLikeOption flags */
+	uint32		options;		/* OR of TableLikeOption flags */
 	Oid			relationOid;	/* If table has been looked up, its OID */
 } TableLikeClause;
 
diff --git a/src/include/port/pg_bitutils.h b/src/include/port/pg_bitutils.h
index 0bca559caaa..7a00d197013 100644
--- a/src/include/port/pg_bitutils.h
+++ b/src/include/port/pg_bitutils.h
@@ -277,7 +277,7 @@ pg_ceil_log2_64(uint64 num)
 }
 
 extern uint64 pg_popcount_portable(const char *buf, int bytes);
-extern uint64 pg_popcount_masked_portable(const char *buf, int bytes, bits8 mask);
+extern uint64 pg_popcount_masked_portable(const char *buf, int bytes, uint8 mask);
 
 #if defined(HAVE_X86_64_POPCNTQ) || defined(USE_SVE_POPCNT_WITH_RUNTIME_CHECK)
 /*
@@ -285,12 +285,12 @@ extern uint64 pg_popcount_masked_portable(const char *buf, int bytes, bits8 mask
  * first.
  */
 extern PGDLLIMPORT uint64 (*pg_popcount_optimized) (const char *buf, int bytes);
-extern PGDLLIMPORT uint64 (*pg_popcount_masked_optimized) (const char *buf, int bytes, bits8 mask);
+extern PGDLLIMPORT uint64 (*pg_popcount_masked_optimized) (const char *buf, int bytes, uint8 mask);
 
 #else
 /* Use a portable implementation -- no need for a function pointer. */
 extern uint64 pg_popcount_optimized(const char *buf, int bytes);
-extern uint64 pg_popcount_masked_optimized(const char *buf, int bytes, bits8 mask);
+extern uint64 pg_popcount_masked_optimized(const char *buf, int bytes, uint8 mask);
 
 #endif
 
@@ -369,7 +369,7 @@ pg_popcount(const char *buf, int bytes)
  * it's likely to be faster.
  */
 static inline uint64
-pg_popcount_masked(const char *buf, int bytes, bits8 mask)
+pg_popcount_masked(const char *buf, int bytes, uint8 mask)
 {
 	/*
 	 * We set the threshold to the point at which we'll first use special
diff --git a/src/include/postmaster/syslogger.h b/src/include/postmaster/syslogger.h
index 9000a45cd13..30c4b2daf3f 100644
--- a/src/include/postmaster/syslogger.h
+++ b/src/include/postmaster/syslogger.h
@@ -46,7 +46,7 @@ typedef struct
 	char		nuls[2];		/* always \0\0 */
 	uint16		len;			/* size of this chunk (counts data only) */
 	int32		pid;			/* writer's pid */
-	bits8		flags;			/* bitmask of PIPE_PROTO_* */
+	uint8		flags;			/* bitmask of PIPE_PROTO_* */
 	char		data[FLEXIBLE_ARRAY_MEMBER];	/* data payload starts here */
 } PipeProtoHeader;
 
diff --git a/src/include/replication/reorderbuffer.h b/src/include/replication/reorderbuffer.h
index 2d717a9e152..ff825e4b7b2 100644
--- a/src/include/replication/reorderbuffer.h
+++ b/src/include/replication/reorderbuffer.h
@@ -293,7 +293,7 @@ typedef struct ReorderBufferChange
 typedef struct ReorderBufferTXN
 {
 	/* See above */
-	bits32		txn_flags;
+	uint32		txn_flags;
 
 	/* The transaction's transaction id, can be a toplevel or sub xid. */
 	TransactionId xid;
diff --git a/src/include/replication/walsender_private.h b/src/include/replication/walsender_private.h
index 5de674d5410..b0c80deeb24 100644
--- a/src/include/replication/walsender_private.h
+++ b/src/include/replication/walsender_private.h
@@ -100,7 +100,7 @@ typedef struct
 	 * can't reload the config file safely, so checkpointer updates this value
 	 * as needed. Protected by SyncRepLock.
 	 */
-	bits8		sync_standbys_status;
+	uint8		sync_standbys_status;
 
 	/* used as a registry of physical / logical walsenders to wake */
 	ConditionVariable wal_flush_cv;
diff --git a/src/include/utils/array.h b/src/include/utils/array.h
index d0b6d8786a3..88e4f4d70d8 100644
--- a/src/include/utils/array.h
+++ b/src/include/utils/array.h
@@ -206,7 +206,7 @@ typedef struct ArrayBuildStateArr
 {
 	MemoryContext mcontext;		/* where all the temp stuff is kept */
 	char	   *data;			/* accumulated data */
-	bits8	   *nullbitmap;		/* bitmap of is-null flags, or NULL if none */
+	uint8	   *nullbitmap;		/* bitmap of is-null flags, or NULL if none */
 	int			abytes;			/* allocated length of "data" */
 	int			nbytes;			/* number of bytes used so far */
 	int			aitems;			/* allocated length of bitmap (in elements) */
@@ -299,9 +299,9 @@ typedef struct ArrayIteratorData *ArrayIterator;
 
 #define ARR_NULLBITMAP(a) \
 		(ARR_HASNULL(a) ? \
-		 (bits8 *) (((char *) (a)) + sizeof(ArrayType) + \
+		 (uint8 *) (((char *) (a)) + sizeof(ArrayType) + \
 					2 * sizeof(int) * ARR_NDIM(a)) \
-		 : (bits8 *) NULL)
+		 : (uint8 *) NULL)
 
 /*
  * The total array header size (in bytes) for an array with the specified
@@ -387,8 +387,8 @@ extern Datum array_map(Datum arrayd,
 					   ExprState *exprstate, ExprContext *econtext,
 					   Oid retType, ArrayMapState *amstate);
 
-extern void array_bitmap_copy(bits8 *destbitmap, int destoffset,
-							  const bits8 *srcbitmap, int srcoffset,
+extern void array_bitmap_copy(uint8 *destbitmap, int destoffset,
+							  const uint8 *srcbitmap, int srcoffset,
 							  int nitems);
 
 extern ArrayType *construct_array(Datum *elems, int nelems,
diff --git a/src/include/utils/arrayaccess.h b/src/include/utils/arrayaccess.h
index a325ae52574..b983014ab0f 100644
--- a/src/include/utils/arrayaccess.h
+++ b/src/include/utils/arrayaccess.h
@@ -40,7 +40,7 @@ typedef struct array_iter
 
 	/* Fields used when we have a flat array */
 	char	   *dataptr;		/* Current spot in the data area */
-	bits8	   *bitmapptr;		/* Current byte of the nulls bitmap, or NULL */
+	uint8	   *bitmapptr;		/* Current byte of the nulls bitmap, or NULL */
 	int			bitmask;		/* mask for current bit in nulls bitmap */
 
 	/* Fields used in both cases: data about array's element type */
diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h
index 5dcd788ff80..b6a11bfa288 100644
--- a/src/include/utils/builtins.h
+++ b/src/include/utils/builtins.h
@@ -126,7 +126,7 @@ extern Datum numeric_float8_no_overflow(PG_FUNCTION_ARGS);
 #define FORMAT_TYPE_ALLOW_INVALID	0x02	/* allow invalid types */
 #define FORMAT_TYPE_FORCE_QUALIFY	0x04	/* force qualification of type */
 #define FORMAT_TYPE_INVALID_AS_NULL	0x08	/* NULL if undefined */
-extern char *format_type_extended(Oid type_oid, int32 typemod, bits16 flags);
+extern char *format_type_extended(Oid type_oid, int32 typemod, uint16 flags);
 
 extern char *format_type_be(Oid type_oid);
 extern char *format_type_be_qualified(Oid type_oid);
diff --git a/src/include/utils/pgstat_internal.h b/src/include/utils/pgstat_internal.h
index 97704421a92..eed4c6b359c 100644
--- a/src/include/utils/pgstat_internal.h
+++ b/src/include/utils/pgstat_internal.h
@@ -709,7 +709,7 @@ extern void pgstat_archiver_snapshot_cb(void);
 #define PGSTAT_BACKEND_FLUSH_WAL   (1 << 1) /* Flush WAL statistics */
 #define PGSTAT_BACKEND_FLUSH_ALL   (PGSTAT_BACKEND_FLUSH_IO | PGSTAT_BACKEND_FLUSH_WAL)
 
-extern bool pgstat_flush_backend(bool nowait, bits32 flags);
+extern bool pgstat_flush_backend(bool nowait, uint32 flags);
 extern bool pgstat_backend_flush_cb(bool nowait);
 extern void pgstat_backend_reset_timestamp_cb(PgStatShared_Common *header,
 											  TimestampTz ts);
diff --git a/src/include/utils/regproc.h b/src/include/utils/regproc.h
index 10681896a81..fd7e391519e 100644
--- a/src/include/utils/regproc.h
+++ b/src/include/utils/regproc.h
@@ -18,12 +18,12 @@
 /* Control flags for format_procedure_extended */
 #define FORMAT_PROC_INVALID_AS_NULL	0x01	/* NULL if undefined */
 #define FORMAT_PROC_FORCE_QUALIFY	0x02	/* force qualification */
-extern char *format_procedure_extended(Oid procedure_oid, bits16 flags);
+extern char *format_procedure_extended(Oid procedure_oid, uint16 flags);
 
 /* Control flags for format_operator_extended */
 #define FORMAT_OPERATOR_INVALID_AS_NULL	0x01	/* NULL if undefined */
 #define FORMAT_OPERATOR_FORCE_QUALIFY	0x02	/* force qualification */
-extern char *format_operator_extended(Oid operator_oid, bits16 flags);
+extern char *format_operator_extended(Oid operator_oid, uint16 flags);
 
 extern List *stringToQualifiedNameList(const char *string, Node *escontext);
 extern char *format_procedure(Oid procedure_oid);
diff --git a/src/include/utils/ruleutils.h b/src/include/utils/ruleutils.h
index 908b2708ed4..059e6474f3b 100644
--- a/src/include/utils/ruleutils.h
+++ b/src/include/utils/ruleutils.h
@@ -27,7 +27,7 @@ typedef struct PlannedStmt PlannedStmt;
 extern char *pg_get_indexdef_string(Oid indexrelid);
 extern char *pg_get_indexdef_columns(Oid indexrelid, bool pretty);
 extern char *pg_get_indexdef_columns_extended(Oid indexrelid,
-											  bits16 flags);
+											  uint16 flags);
 extern char *pg_get_querydef(Query *query, bool pretty);
 
 extern char *pg_get_partkeydef_columns(Oid relid, bool pretty);
diff --git a/src/include/utils/varbit.h b/src/include/utils/varbit.h
index 20cb14d75b0..8e2b981e1f6 100644
--- a/src/include/utils/varbit.h
+++ b/src/include/utils/varbit.h
@@ -20,7 +20,7 @@
 #include "fmgr.h"
 
 /*
- * Modeled on varlena from c.h, but data type is bits8.
+ * Modeled on varlena from c.h, but data type is uint8.
  *
  * Caution: if bit_len is not a multiple of BITS_PER_BYTE, the low-order
  * bits of the last byte of bit_dat[] are unused and MUST be zeroes.
@@ -31,7 +31,7 @@ typedef struct
 {
 	int32		vl_len_;		/* varlena header (do not touch directly!) */
 	int32		bit_len;		/* number of valid bits */
-	bits8		bit_dat[FLEXIBLE_ARRAY_MEMBER]; /* bit string, most sig. byte
+	uint8		bit_dat[FLEXIBLE_ARRAY_MEMBER]; /* bit string, most sig. byte
 												 * first */
 } VarBit;
 
@@ -82,7 +82,7 @@ VarBitPGetDatum(const VarBit *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))
+#define VARBITEND(PTR)		(((uint8 *) (PTR)) + VARSIZE(PTR))
 /* Mask that will cover exactly one byte, i.e. BITS_PER_BYTE bits */
 #define BITMASK 0xFF
 
diff --git a/src/pl/plpython/plpy_typeio.c b/src/pl/plpython/plpy_typeio.c
index 44055de6aeb..92d55bf9f42 100644
--- a/src/pl/plpython/plpy_typeio.c
+++ b/src/pl/plpython/plpy_typeio.c
@@ -35,7 +35,7 @@ static PyObject *PLyUnicode_FromScalar(PLyDatumToOb *arg, Datum d);
 static PyObject *PLyObject_FromTransform(PLyDatumToOb *arg, Datum d);
 static PyObject *PLyList_FromArray(PLyDatumToOb *arg, Datum d);
 static PyObject *PLyList_FromArray_recurse(PLyDatumToOb *elm, int *dims, int ndim, int dim,
-										   char **dataptr_p, bits8 **bitmap_p, int *bitmask_p);
+										   char **dataptr_p, uint8 **bitmap_p, int *bitmask_p);
 static PyObject *PLyDict_FromComposite(PLyDatumToOb *arg, Datum d);
 static PyObject *PLyDict_FromTuple(PLyDatumToOb *arg, HeapTuple tuple, TupleDesc desc, bool include_generated);
 
@@ -671,7 +671,7 @@ PLyList_FromArray(PLyDatumToOb *arg, Datum d)
 	int			ndim;
 	int		   *dims;
 	char	   *dataptr;
-	bits8	   *bitmap;
+	uint8	   *bitmap;
 	int			bitmask;
 
 	if (ARR_NDIM(array) == 0)
@@ -705,7 +705,7 @@ PLyList_FromArray(PLyDatumToOb *arg, Datum d)
 
 static PyObject *
 PLyList_FromArray_recurse(PLyDatumToOb *elm, int *dims, int ndim, int dim,
-						  char **dataptr_p, bits8 **bitmap_p, int *bitmask_p)
+						  char **dataptr_p, uint8 **bitmap_p, int *bitmask_p)
 {
 	int			i;
 	PyObject   *list;
@@ -733,7 +733,7 @@ PLyList_FromArray_recurse(PLyDatumToOb *elm, int *dims, int ndim, int dim,
 		 * for this slice.
 		 */
 		char	   *dataptr = *dataptr_p;
-		bits8	   *bitmap = *bitmap_p;
+		uint8	   *bitmap = *bitmap_p;
 		int			bitmask = *bitmask_p;
 		uint8		typalignby = typalign_to_alignby(elm->typalign);
 
diff --git a/src/port/pg_bitutils.c b/src/port/pg_bitutils.c
index 49b130f1306..7b11c38c417 100644
--- a/src/port/pg_bitutils.c
+++ b/src/port/pg_bitutils.c
@@ -133,7 +133,7 @@ pg_popcount_portable(const char *buf, int bytes)
  *		Returns the number of 1-bits in buf after applying the mask to each byte
  */
 uint64
-pg_popcount_masked_portable(const char *buf, int bytes, bits8 mask)
+pg_popcount_masked_portable(const char *buf, int bytes, uint8 mask)
 {
 	uint64		popcnt = 0;
 
@@ -186,7 +186,7 @@ pg_popcount_optimized(const char *buf, int bytes)
  *		Returns the number of 1-bits in buf after applying the mask to each byte
  */
 uint64
-pg_popcount_masked_optimized(const char *buf, int bytes, bits8 mask)
+pg_popcount_masked_optimized(const char *buf, int bytes, uint8 mask)
 {
 	return pg_popcount_masked_portable(buf, bytes, mask);
 }
diff --git a/src/port/pg_popcount_aarch64.c b/src/port/pg_popcount_aarch64.c
index b0f10ae07a4..3969a42523c 100644
--- a/src/port/pg_popcount_aarch64.c
+++ b/src/port/pg_popcount_aarch64.c
@@ -35,7 +35,7 @@
  * versions.
  */
 static uint64 pg_popcount_neon(const char *buf, int bytes);
-static uint64 pg_popcount_masked_neon(const char *buf, int bytes, bits8 mask);
+static uint64 pg_popcount_masked_neon(const char *buf, int bytes, uint8 mask);
 
 #ifdef USE_SVE_POPCNT_WITH_RUNTIME_CHECK
 
@@ -43,7 +43,7 @@ static uint64 pg_popcount_masked_neon(const char *buf, int bytes, bits8 mask);
  * These are the SVE implementations of the popcount functions.
  */
 static uint64 pg_popcount_sve(const char *buf, int bytes);
-static uint64 pg_popcount_masked_sve(const char *buf, int bytes, bits8 mask);
+static uint64 pg_popcount_masked_sve(const char *buf, int bytes, uint8 mask);
 
 /*
  * The function pointers are initially set to "choose" functions.  These
@@ -52,9 +52,9 @@ static uint64 pg_popcount_masked_sve(const char *buf, int bytes, bits8 mask);
  * caller's request.
  */
 static uint64 pg_popcount_choose(const char *buf, int bytes);
-static uint64 pg_popcount_masked_choose(const char *buf, int bytes, bits8 mask);
+static uint64 pg_popcount_masked_choose(const char *buf, int bytes, uint8 mask);
 uint64		(*pg_popcount_optimized) (const char *buf, int bytes) = pg_popcount_choose;
-uint64		(*pg_popcount_masked_optimized) (const char *buf, int bytes, bits8 mask) = pg_popcount_masked_choose;
+uint64		(*pg_popcount_masked_optimized) (const char *buf, int bytes, uint8 mask) = pg_popcount_masked_choose;
 
 static inline bool
 pg_popcount_sve_available(void)
@@ -94,7 +94,7 @@ pg_popcount_choose(const char *buf, int bytes)
 }
 
 static uint64
-pg_popcount_masked_choose(const char *buf, int bytes, bits8 mask)
+pg_popcount_masked_choose(const char *buf, int bytes, uint8 mask)
 {
 	choose_popcount_functions();
 	return pg_popcount_masked_optimized(buf, bytes, mask);
@@ -190,7 +190,7 @@ pg_popcount_sve(const char *buf, int bytes)
  */
 pg_attribute_target("arch=armv8-a+sve")
 static uint64
-pg_popcount_masked_sve(const char *buf, int bytes, bits8 mask)
+pg_popcount_masked_sve(const char *buf, int bytes, uint8 mask)
 {
 	svbool_t	pred = svptrue_b64();
 	svuint64_t	accum1 = svdup_u64(0),
@@ -284,7 +284,7 @@ pg_popcount_optimized(const char *buf, int bytes)
 }
 
 uint64
-pg_popcount_masked_optimized(const char *buf, int bytes, bits8 mask)
+pg_popcount_masked_optimized(const char *buf, int bytes, uint8 mask)
 {
 	return pg_popcount_masked_neon(buf, bytes, mask);
 }
@@ -386,7 +386,7 @@ pg_popcount_neon(const char *buf, int bytes)
  *		Returns number of 1 bits in buf after applying the mask to each byte
  */
 static uint64
-pg_popcount_masked_neon(const char *buf, int bytes, bits8 mask)
+pg_popcount_masked_neon(const char *buf, int bytes, uint8 mask)
 {
 	uint8x16_t	vec,
 				maskv = vdupq_n_u8(mask);
diff --git a/src/port/pg_popcount_x86.c b/src/port/pg_popcount_x86.c
index a99613f1818..91579e6b569 100644
--- a/src/port/pg_popcount_x86.c
+++ b/src/port/pg_popcount_x86.c
@@ -30,14 +30,14 @@
  * follow than "popcnt" for these names.
  */
 static uint64 pg_popcount_sse42(const char *buf, int bytes);
-static uint64 pg_popcount_masked_sse42(const char *buf, int bytes, bits8 mask);
+static uint64 pg_popcount_masked_sse42(const char *buf, int bytes, uint8 mask);
 
 /*
  * These are the AVX-512 implementations of the popcount functions.
  */
 #ifdef USE_AVX512_POPCNT_WITH_RUNTIME_CHECK
 static uint64 pg_popcount_avx512(const char *buf, int bytes);
-static uint64 pg_popcount_masked_avx512(const char *buf, int bytes, bits8 mask);
+static uint64 pg_popcount_masked_avx512(const char *buf, int bytes, uint8 mask);
 #endif							/* USE_AVX512_POPCNT_WITH_RUNTIME_CHECK */
 
 /*
@@ -47,9 +47,9 @@ static uint64 pg_popcount_masked_avx512(const char *buf, int bytes, bits8 mask);
  * caller's request.
  */
 static uint64 pg_popcount_choose(const char *buf, int bytes);
-static uint64 pg_popcount_masked_choose(const char *buf, int bytes, bits8 mask);
+static uint64 pg_popcount_masked_choose(const char *buf, int bytes, uint8 mask);
 uint64		(*pg_popcount_optimized) (const char *buf, int bytes) = pg_popcount_choose;
-uint64		(*pg_popcount_masked_optimized) (const char *buf, int bytes, bits8 mask) = pg_popcount_masked_choose;
+uint64		(*pg_popcount_masked_optimized) (const char *buf, int bytes, uint8 mask) = pg_popcount_masked_choose;

 #ifdef USE_AVX512_POPCNT_WITH_RUNTIME_CHECK
@@ -104,7 +104,7 @@ pg_popcount_choose(const char *buf, int bytes)
 }
 
 static uint64
-pg_popcount_masked_choose(const char *buf, int bytes, bits8 mask)
+pg_popcount_masked_choose(const char *buf, int bytes, uint8 mask)
 {
 	choose_popcount_functions();
 	return pg_popcount_masked(buf, bytes, mask);
@@ -174,7 +174,7 @@ pg_popcount_avx512(const char *buf, int bytes)
  */
 pg_attribute_target("avx512vpopcntdq,avx512bw")
 static uint64
-pg_popcount_masked_avx512(const char *buf, int bytes, bits8 mask)
+pg_popcount_masked_avx512(const char *buf, int bytes, uint8 mask)
 {
 	__m512i		val,
 				vmasked,
@@ -280,7 +280,7 @@ pg_popcount_sse42(const char *buf, int bytes)
  */
 pg_attribute_no_sanitize_alignment()
 static uint64
-pg_popcount_masked_sse42(const char *buf, int bytes, bits8 mask)
+pg_popcount_masked_sse42(const char *buf, int bytes, uint8 mask)
 {
 	uint64		popcnt = 0;
 	uint64		maskv = ~UINT64CONST(0) / 0xFF * mask;
diff --git a/src/test/modules/worker_spi/worker_spi.c b/src/test/modules/worker_spi/worker_spi.c
index b89954279c0..f65f3e98600 100644
--- a/src/test/modules/worker_spi/worker_spi.c
+++ b/src/test/modules/worker_spi/worker_spi.c
@@ -141,7 +141,7 @@ worker_spi_main(Datum main_arg)
 	Oid			dboid;
 	Oid			roleoid;
 	char	   *p;
-	bits32		flags = 0;
+	uint32		flags = 0;
 
 	table = palloc_object(worktable);
 	sprintf(name, "schema%d", index);
@@ -154,7 +154,7 @@ worker_spi_main(Datum main_arg)
 	p += sizeof(Oid);
 	memcpy(&roleoid, p, sizeof(Oid));
 	p += sizeof(Oid);
-	memcpy(&flags, p, sizeof(bits32));
+	memcpy(&flags, p, sizeof(uint32));
 
 	/* Establish signal handlers before unblocking signals. */
 	pqsignal(SIGHUP, SignalHandlerForConfigReload);
@@ -400,7 +400,7 @@ worker_spi_launch(PG_FUNCTION_ARGS)
 	BgwHandleStatus status;
 	pid_t		pid;
 	char	   *p;
-	bits32		flags = 0;
+	uint32		flags = 0;
 	ArrayType  *arr = PG_GETARG_ARRAYTYPE_P(3);
 	Size		ndim;
 	int			nelems;
@@ -472,7 +472,7 @@ worker_spi_launch(PG_FUNCTION_ARGS)
 	p += sizeof(Oid);
 	memcpy(p, &roleoid, sizeof(Oid));
 	p += sizeof(Oid);
-	memcpy(p, &flags, sizeof(bits32));
+	memcpy(p, &flags, sizeof(uint32));
 
 	if (!RegisterDynamicBackgroundWorker(&worker, &handle))
 		PG_RETURN_NULL();
diff --git a/src/tools/pgindent/typedefs.list b/src/tools/pgindent/typedefs.list
index e3c1007abdf..f1fa94c1397 100644
--- a/src/tools/pgindent/typedefs.list
+++ b/src/tools/pgindent/typedefs.list
@@ -3591,9 +3591,6 @@ bh_node_type
 binaryheap
 binaryheap_comparator
 bitmapword
-bits16
-bits32
-bits8
 blockreftable_hash
 blockreftable_iterator
 bloom_filter
-- 
2.50.1 (Apple Git-155)

--cfse7IKQXBjlvwxb--

---

From: Michael Paquier <[email-masked]>
Date: Sat, 21 Mar 2026 14:41:29 +0900

On Thu, Mar 19, 2026 at 12:22:10PM -0400, Tom Lane wrote:
> I'm content with the status quo personally, but perhaps it'd be
> worth adding some info to the comment for the bitsNN typedefs
> to make it clearer what they are intended for.  I'm imagining
> something along the lines of

Not sure why we absolutely need to be aggressive with a removal here,
so I'm +/-0 on that.  And there is always the argument of breaking the
compilation of out-of-core code.  That would be easily fixable, still
always slightly annoying.
--
Michael