Skip to content

Commit bab2f27

Browse files
Remove bits* typedefs.
In addition to removing the bits8, bits16, and bits32 typedefs, this commit replaces all uses with uint8, uint16, or uint32. bits* provided little benefit beyond establishing the intent of the variable, and they were inconsistently used for that purpose. Third-party code should instead use the corresponding uint* typedef. Suggested-by: Andres Freund <andres@anarazel.de> Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Reviewed-by: Robert Haas <robertmhaas@gmail.com> Reviewed-by: Michael Paquier <michael@paquier.xyz> Reviewed-by: Peter Eisentraut <peter@eisentraut.org> Reviewed-by: Melanie Plageman <melanieplageman@gmail.com> Reviewed-by: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org> Discussion: https://postgr.es/m/absbX33E4eaA0Ity%40nathan
1 parent 40c41dc commit bab2f27

73 files changed

Lines changed: 261 additions & 273 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

contrib/dblink/dblink.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2077,7 +2077,7 @@ get_text_array_contents(ArrayType *array, int *numitems)
20772077
uint8 typalignby;
20782078
char **values;
20792079
char *ptr;
2080-
bits8 *bitmap;
2080+
uint8 *bitmap;
20812081
int bitmask;
20822082
int i;
20832083

contrib/pageinspect/gistfuncs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ gist_page_items(PG_FUNCTION_ARGS)
203203
TupleDesc tupdesc;
204204
Page page;
205205
uint16 flagbits;
206-
bits16 printflags = 0;
206+
uint16 printflags = 0;
207207
OffsetNumber offset;
208208
OffsetNumber maxoff = InvalidOffsetNumber;
209209
char *index_columns;

contrib/pageinspect/heapfuncs.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ HeapTupleHeaderGetOidOld(const HeapTupleHeaderData *tup)
5656
/*
5757
* bits_to_text
5858
*
59-
* Converts a bits8-array of 'len' bits to a human-readable
59+
* Converts a uint8-array of 'len' bits to a human-readable
6060
* c-string representation.
6161
*/
6262
static char *
63-
bits_to_text(bits8 *bits, int len)
63+
bits_to_text(uint8 *bits, int len)
6464
{
6565
int i;
6666
char *str;
@@ -79,13 +79,13 @@ bits_to_text(bits8 *bits, int len)
7979
/*
8080
* text_to_bits
8181
*
82-
* Converts a c-string representation of bits into a bits8-array. This is
82+
* Converts a c-string representation of bits into a uint8-array. This is
8383
* the reverse operation of previous routine.
8484
*/
85-
static bits8 *
85+
static uint8 *
8686
text_to_bits(char *str, int len)
8787
{
88-
bits8 *bits;
88+
uint8 *bits;
8989
int off = 0;
9090
char byte = 0;
9191

@@ -305,7 +305,7 @@ heap_page_items(PG_FUNCTION_ARGS)
305305
static Datum
306306
tuple_data_split_internal(Oid relid, char *tupdata,
307307
uint16 tupdata_len, uint16 t_infomask,
308-
uint16 t_infomask2, bits8 *t_bits,
308+
uint16 t_infomask2, uint8 *t_bits,
309309
bool do_detoast)
310310
{
311311
ArrayBuildState *raw_attrs;
@@ -434,7 +434,7 @@ tuple_data_split(PG_FUNCTION_ARGS)
434434
uint16 t_infomask2;
435435
char *t_bits_str;
436436
bool do_detoast = false;
437-
bits8 *t_bits = NULL;
437+
uint8 *t_bits = NULL;
438438
Datum res;
439439

440440
relid = PG_GETARG_OID(0);
@@ -456,7 +456,7 @@ tuple_data_split(PG_FUNCTION_ARGS)
456456
PG_RETURN_NULL();
457457

458458
/*
459-
* Convert t_bits string back to the bits8 array as represented in the
459+
* Convert t_bits string back to the uint8 array as represented in the
460460
* tuple header.
461461
*/
462462
if (t_infomask & HEAP_HASNULL)

contrib/postgres_fdw/deparse.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1189,7 +1189,7 @@ is_foreign_pathkey(PlannerInfo *root,
11891189
static char *
11901190
deparse_type_name(Oid type_oid, int32 typemod)
11911191
{
1192-
bits16 flags = FORMAT_TYPE_TYPEMOD_GIVEN;
1192+
uint16 flags = FORMAT_TYPE_TYPEMOD_GIVEN;
11931193

11941194
if (!is_builtin(type_oid))
11951195
flags |= FORMAT_TYPE_FORCE_QUALIFY;

doc/src/sgml/fdwhandler.sgml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1702,7 +1702,7 @@ ReparameterizeForeignPathByChild(PlannerInfo *root, List *fdw_private,
17021702
<para>
17031703
<programlisting>
17041704
ForeignDataWrapper *
1705-
GetForeignDataWrapperExtended(Oid fdwid, bits16 flags);
1705+
GetForeignDataWrapperExtended(Oid fdwid, uint16 flags);
17061706
</programlisting>
17071707

17081708
This function returns a <structname>ForeignDataWrapper</structname>
@@ -1731,7 +1731,7 @@ GetForeignDataWrapper(Oid fdwid);
17311731
<para>
17321732
<programlisting>
17331733
ForeignServer *
1734-
GetForeignServerExtended(Oid serverid, bits16 flags);
1734+
GetForeignServerExtended(Oid serverid, uint16 flags);
17351735
</programlisting>
17361736

17371737
This function returns a <structname>ForeignServer</structname> object

src/backend/access/brin/brin_tuple.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050

5151

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

5656

@@ -107,7 +107,7 @@ brin_form_tuple(BrinDesc *brdesc, BlockNumber blkno, BrinMemTuple *tuple,
107107
int keyno;
108108
int idxattno;
109109
uint16 phony_infomask = 0;
110-
bits8 *phony_nullbitmap;
110+
uint8 *phony_nullbitmap;
111111
Size len,
112112
hoff,
113113
data_len;
@@ -122,7 +122,7 @@ brin_form_tuple(BrinDesc *brdesc, BlockNumber blkno, BrinMemTuple *tuple,
122122

123123
values = palloc_array(Datum, brdesc->bd_totalstored);
124124
nulls = palloc0_array(bool, brdesc->bd_totalstored);
125-
phony_nullbitmap = palloc_array(bits8, BITMAPLEN(brdesc->bd_totalstored));
125+
phony_nullbitmap = palloc_array(uint8, BITMAPLEN(brdesc->bd_totalstored));
126126

127127
#ifdef TOAST_INDEX_HACK
128128
untoasted_values = palloc_array(Datum, brdesc->bd_totalstored);
@@ -322,7 +322,7 @@ brin_form_tuple(BrinDesc *brdesc, BlockNumber blkno, BrinMemTuple *tuple,
322322
*/
323323
if (anynulls)
324324
{
325-
bits8 *bitP;
325+
uint8 *bitP;
326326
int bitmask;
327327

328328
rettuple->bt_info |= BRIN_NULLS_MASK;
@@ -332,7 +332,7 @@ brin_form_tuple(BrinDesc *brdesc, BlockNumber blkno, BrinMemTuple *tuple,
332332
* store a 1 for a null attribute rather than a 0. So we must reverse
333333
* the sense of the att_isnull test in brin_deconstruct_tuple as well.
334334
*/
335-
bitP = ((bits8 *) ((char *) rettuple + SizeOfBrinTuple)) - 1;
335+
bitP = ((uint8 *) ((char *) rettuple + SizeOfBrinTuple)) - 1;
336336
bitmask = HIGHBIT;
337337
for (keyno = 0; keyno < brdesc->bd_tupdesc->natts; keyno++)
338338
{
@@ -391,7 +391,7 @@ brin_form_placeholder_tuple(BrinDesc *brdesc, BlockNumber blkno, Size *size)
391391
Size hoff;
392392
BrinTuple *rettuple;
393393
int keyno;
394-
bits8 *bitP;
394+
uint8 *bitP;
395395
int bitmask;
396396

397397
/* compute total space needed: always add nulls */
@@ -404,7 +404,7 @@ brin_form_placeholder_tuple(BrinDesc *brdesc, BlockNumber blkno, Size *size)
404404
rettuple->bt_info = hoff;
405405
rettuple->bt_info |= BRIN_NULLS_MASK | BRIN_PLACEHOLDER_MASK | BRIN_EMPTY_RANGE_MASK;
406406

407-
bitP = ((bits8 *) ((char *) rettuple + SizeOfBrinTuple)) - 1;
407+
bitP = ((uint8 *) ((char *) rettuple + SizeOfBrinTuple)) - 1;
408408
bitmask = HIGHBIT;
409409
/* set allnulls true for all attributes */
410410
for (keyno = 0; keyno < brdesc->bd_tupdesc->natts; keyno++)
@@ -557,7 +557,7 @@ brin_deform_tuple(BrinDesc *brdesc, BrinTuple *tuple, BrinMemTuple *dMemtuple)
557557
bool *allnulls;
558558
bool *hasnulls;
559559
char *tp;
560-
bits8 *nullbits;
560+
uint8 *nullbits;
561561
int keyno;
562562
int valueno;
563563
MemoryContext oldcxt;
@@ -581,7 +581,7 @@ brin_deform_tuple(BrinDesc *brdesc, BrinTuple *tuple, BrinMemTuple *dMemtuple)
581581
tp = (char *) tuple + BrinTupleDataOffset(tuple);
582582

583583
if (BrinTupleHasNulls(tuple))
584-
nullbits = (bits8 *) ((char *) tuple + SizeOfBrinTuple);
584+
nullbits = (uint8 *) ((char *) tuple + SizeOfBrinTuple);
585585
else
586586
nullbits = NULL;
587587
brin_deconstruct_tuple(brdesc,
@@ -643,7 +643,7 @@ brin_deform_tuple(BrinDesc *brdesc, BrinTuple *tuple, BrinMemTuple *dMemtuple)
643643
*/
644644
static inline void
645645
brin_deconstruct_tuple(BrinDesc *brdesc,
646-
char *tp, bits8 *nullbits, bool nulls,
646+
char *tp, uint8 *nullbits, bool nulls,
647647
Datum *values, bool *allnulls, bool *hasnulls)
648648
{
649649
int attnum;

src/backend/access/common/heaptuple.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ heap_compute_data_size(TupleDesc tupleDesc,
273273
*/
274274
static inline void
275275
fill_val(CompactAttribute *att,
276-
bits8 **bit,
276+
uint8 **bit,
277277
int *bitmask,
278278
char **dataP,
279279
uint16 *infomask,
@@ -401,9 +401,9 @@ void
401401
heap_fill_tuple(TupleDesc tupleDesc,
402402
const Datum *values, const bool *isnull,
403403
char *data, Size data_size,
404-
uint16 *infomask, bits8 *bit)
404+
uint16 *infomask, uint8 *bit)
405405
{
406-
bits8 *bitP;
406+
uint8 *bitP;
407407
int bitmask;
408408
int i;
409409
int numberOfAttributes = tupleDesc->natts;
@@ -513,7 +513,7 @@ nocachegetattr(HeapTuple tup,
513513
CompactAttribute *cattr;
514514
HeapTupleHeader td = tup->t_data;
515515
char *tp; /* ptr to data part of tuple */
516-
bits8 *bp = td->t_bits; /* ptr to null bitmap in tuple */
516+
uint8 *bp = td->t_bits; /* ptr to null bitmap in tuple */
517517
int off; /* current offset within data */
518518
int startAttr;
519519
int firstNullAttr;
@@ -766,7 +766,7 @@ expand_tuple(HeapTuple *targetHeapTuple,
766766
Size targetDataLen;
767767
Size len;
768768
int hoff;
769-
bits8 *nullBits = NULL;
769+
uint8 *nullBits = NULL;
770770
int bitMask = 0;
771771
char *targetData;
772772
uint16 *infoMask;
@@ -878,7 +878,7 @@ expand_tuple(HeapTuple *targetHeapTuple,
878878
/* We also make sure that t_ctid is invalid unless explicitly set */
879879
ItemPointerSetInvalid(&(targetTHeader->t_ctid));
880880
if (targetNullLen > 0)
881-
nullBits = (bits8 *) ((char *) (*targetHeapTuple)->t_data
881+
nullBits = (uint8 *) ((char *) (*targetHeapTuple)->t_data
882882
+ offsetof(HeapTupleHeaderData, t_bits));
883883
targetData = (char *) (*targetHeapTuple)->t_data + hoff;
884884
infoMask = &(targetTHeader->t_infomask);
@@ -896,7 +896,7 @@ expand_tuple(HeapTuple *targetHeapTuple,
896896
/* Same macro works for MinimalTuples */
897897
HeapTupleHeaderSetNatts(*targetMinimalTuple, natts);
898898
if (targetNullLen > 0)
899-
nullBits = (bits8 *) ((char *) *targetMinimalTuple
899+
nullBits = (uint8 *) ((char *) *targetMinimalTuple
900900
+ offsetof(MinimalTupleData, t_bits));
901901
targetData = (char *) *targetMinimalTuple + hoff;
902902
infoMask = &((*targetMinimalTuple)->t_infomask);
@@ -1274,7 +1274,7 @@ heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc,
12741274
int attnum;
12751275
char *tp; /* ptr to tuple data */
12761276
uint32 off; /* offset in tuple data */
1277-
bits8 *bp = tup->t_bits; /* ptr to null bitmap in tuple */
1277+
uint8 *bp = tup->t_bits; /* ptr to null bitmap in tuple */
12781278
int firstNonCacheOffsetAttr;
12791279
int firstNullAttr;
12801280

src/backend/access/common/indextuple.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ index_form_tuple_context(TupleDesc tupleDescriptor,
175175
tp + hoff,
176176
data_size,
177177
&tupmask,
178-
(hasnull ? (bits8 *) tp + sizeof(IndexTupleData) : NULL));
178+
(hasnull ? (uint8 *) tp + sizeof(IndexTupleData) : NULL));
179179

180180
#ifdef TOAST_INDEX_HACK
181181
for (i = 0; i < numberOfAttributes; i++)
@@ -232,7 +232,7 @@ nocache_index_getattr(IndexTuple tup,
232232
{
233233
CompactAttribute *cattr;
234234
char *tp; /* ptr to data part of tuple */
235-
bits8 *bp = NULL; /* ptr to null bitmap in tuple */
235+
uint8 *bp = NULL; /* ptr to null bitmap in tuple */
236236
int data_off; /* tuple data offset */
237237
int off; /* current offset within data */
238238
int startAttr;
@@ -255,7 +255,7 @@ nocache_index_getattr(IndexTuple tup,
255255
*/
256256
if (hasnulls)
257257
{
258-
bp = (bits8 *) ((char *) tup + sizeof(IndexTupleData));
258+
bp = (uint8 *) ((char *) tup + sizeof(IndexTupleData));
259259
firstNullAttr = first_null_attr(bp, attnum);
260260
}
261261
else
@@ -365,10 +365,10 @@ index_deform_tuple(IndexTuple tup, TupleDesc tupleDescriptor,
365365
Datum *values, bool *isnull)
366366
{
367367
char *tp; /* ptr to tuple data */
368-
bits8 *bp; /* ptr to null bitmap in tuple */
368+
uint8 *bp; /* ptr to null bitmap in tuple */
369369

370370
/* XXX "knows" t_bits are just after fixed tuple header! */
371-
bp = (bits8 *) ((char *) tup + sizeof(IndexTupleData));
371+
bp = (uint8 *) ((char *) tup + sizeof(IndexTupleData));
372372

373373
tp = (char *) tup + IndexInfoFindDataOffset(tup->t_info);
374374

@@ -386,7 +386,7 @@ index_deform_tuple(IndexTuple tup, TupleDesc tupleDescriptor,
386386
void
387387
index_deform_tuple_internal(TupleDesc tupleDescriptor,
388388
Datum *values, bool *isnull,
389-
char *tp, bits8 *bp, int hasnulls)
389+
char *tp, uint8 *bp, int hasnulls)
390390
{
391391
CompactAttribute *cattr;
392392
int natts = tupleDescriptor->natts; /* number of atts to extract */

0 commit comments

Comments
 (0)