Skip to content

Commit 84fc571

Browse files
committed
Rename the C functions bitand(), bitor() to bit_and(), bit_or().
This is to avoid use of the C++ keywords "bitand" and "bitor" in the header file utils/varbit.h. Note the functions' SQL-level names are not changed, only their C-level names. In passing, make some comments in varbit.c conform to project-standard layout.
1 parent 8c61f81 commit 84fc571

File tree

4 files changed

+46
-25
lines changed

4 files changed

+46
-25
lines changed

src/backend/utils/adt/varbit.c

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ static VarBit *bitsubstring(VarBit *arg, int32 s, int32 l,
2929
static VarBit *bit_overlay(VarBit *t1, VarBit *t2, int sp, int sl);
3030

3131

32-
/* common code for bittypmodin and varbittypmodin */
32+
/*
33+
* common code for bittypmodin and varbittypmodin
34+
*/
3335
static int32
3436
anybit_typmodin(ArrayType *ta, const char *typename)
3537
{
@@ -64,7 +66,9 @@ anybit_typmodin(ArrayType *ta, const char *typename)
6466
return typmod;
6567
}
6668

67-
/* common code for bittypmodout and varbittypmodout */
69+
/*
70+
* common code for bittypmodout and varbittypmodout
71+
*/
6872
static char *
6973
anybit_typmodout(int32 typmod)
7074
{
@@ -233,8 +237,10 @@ bit_out(PG_FUNCTION_ARGS)
233237
/* same as varbit output */
234238
return varbit_out(fcinfo);
235239
#else
236-
/* This is how one would print a hex string, in case someone wants to
237-
write a formatting function. */
240+
/*
241+
* This is how one would print a hex string, in case someone wants to
242+
* write a formatting function.
243+
*/
238244
VarBit *s = PG_GETARG_VARBIT_P(0);
239245
char *result,
240246
*r;
@@ -330,7 +336,8 @@ bit_send(PG_FUNCTION_ARGS)
330336
return varbit_send(fcinfo);
331337
}
332338

333-
/* bit()
339+
/*
340+
* bit()
334341
* Converts a bit() type to a specific internal length.
335342
* len is the bitlength specified in the column definition.
336343
*
@@ -523,7 +530,8 @@ varbit_in(PG_FUNCTION_ARGS)
523530
PG_RETURN_VARBIT_P(result);
524531
}
525532

526-
/* varbit_out -
533+
/*
534+
* varbit_out -
527535
* Prints the string as bits to preserve length accurately
528536
*/
529537
Datum
@@ -636,7 +644,8 @@ varbit_send(PG_FUNCTION_ARGS)
636644
PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
637645
}
638646

639-
/* varbit()
647+
/*
648+
* varbit()
640649
* Converts a varbit() type to a specific internal length.
641650
* len is the maximum bitlength specified in the column definition.
642651
*
@@ -718,7 +727,8 @@ varbittypmodout(PG_FUNCTION_ARGS)
718727
* need to be so careful.
719728
*/
720729

721-
/* bit_cmp
730+
/*
731+
* bit_cmp
722732
*
723733
* Compares two bitstrings and returns <0, 0, >0 depending on whether the first
724734
* string is smaller, equal, or bigger than the second. All bits are considered
@@ -871,7 +881,8 @@ bitcmp(PG_FUNCTION_ARGS)
871881
PG_RETURN_INT32(result);
872882
}
873883

874-
/* bitcat
884+
/*
885+
* bitcat
875886
* Concatenation of bit strings
876887
*/
877888
Datum
@@ -931,7 +942,8 @@ bit_catenate(VarBit *arg1, VarBit *arg2)
931942
return result;
932943
}
933944

934-
/* bitsubstr
945+
/*
946+
* bitsubstr
935947
* retrieve a substring from the bit string.
936948
* Note, s is 1-based.
937949
* SQL draft 6.10 9)
@@ -1105,7 +1117,8 @@ bit_overlay(VarBit *t1, VarBit *t2, int sp, int sl)
11051117
return result;
11061118
}
11071119

1108-
/* bitlength, bitoctetlength
1120+
/*
1121+
* bitlength, bitoctetlength
11091122
* Return the length of a bit string
11101123
*/
11111124
Datum
@@ -1124,11 +1137,12 @@ bitoctetlength(PG_FUNCTION_ARGS)
11241137
PG_RETURN_INT32(VARBITBYTES(arg));
11251138
}
11261139

1127-
/* bitand
1140+
/*
1141+
* bit_and
11281142
* perform a logical AND on two bit strings.
11291143
*/
11301144
Datum
1131-
bitand(PG_FUNCTION_ARGS)
1145+
bit_and(PG_FUNCTION_ARGS)
11321146
{
11331147
VarBit *arg1 = PG_GETARG_VARBIT_P(0);
11341148
VarBit *arg2 = PG_GETARG_VARBIT_P(1);
@@ -1164,11 +1178,12 @@ bitand(PG_FUNCTION_ARGS)
11641178
PG_RETURN_VARBIT_P(result);
11651179
}
11661180

1167-
/* bitor
1181+
/*
1182+
* bit_or
11681183
* perform a logical OR on two bit strings.
11691184
*/
11701185
Datum
1171-
bitor(PG_FUNCTION_ARGS)
1186+
bit_or(PG_FUNCTION_ARGS)
11721187
{
11731188
VarBit *arg1 = PG_GETARG_VARBIT_P(0);
11741189
VarBit *arg2 = PG_GETARG_VARBIT_P(1);
@@ -1210,7 +1225,8 @@ bitor(PG_FUNCTION_ARGS)
12101225
PG_RETURN_VARBIT_P(result);
12111226
}
12121227

1213-
/* bitxor
1228+
/*
1229+
* bitxor
12141230
* perform a logical XOR on two bit strings.
12151231
*/
12161232
Datum
@@ -1257,7 +1273,8 @@ bitxor(PG_FUNCTION_ARGS)
12571273
PG_RETURN_VARBIT_P(result);
12581274
}
12591275

1260-
/* bitnot
1276+
/*
1277+
* bitnot
12611278
* perform a logical NOT on a bit string.
12621279
*/
12631280
Datum
@@ -1289,7 +1306,8 @@ bitnot(PG_FUNCTION_ARGS)
12891306
PG_RETURN_VARBIT_P(result);
12901307
}
12911308

1292-
/* bitshiftleft
1309+
/*
1310+
* bitshiftleft
12931311
* do a left shift (i.e. towards the beginning of the string)
12941312
*/
12951313
Datum
@@ -1348,7 +1366,8 @@ bitshiftleft(PG_FUNCTION_ARGS)
13481366
PG_RETURN_VARBIT_P(result);
13491367
}
13501368

1351-
/* bitshiftright
1369+
/*
1370+
* bitshiftright
13521371
* do a right shift (i.e. towards the end of the string)
13531372
*/
13541373
Datum
@@ -1575,7 +1594,8 @@ bittoint8(PG_FUNCTION_ARGS)
15751594
}
15761595

15771596

1578-
/* Determines the position of S2 in the bitstring S1 (1-based string).
1597+
/*
1598+
* Determines the position of S2 in the bitstring S1 (1-based string).
15791599
* If S2 does not appear in S1 this function returns 0.
15801600
* If S2 is of length 0 this function returns 1.
15811601
* Compatible in usage with POSITION() functions for other data types.

src/include/catalog/catversion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/* yyyymmddN */
56-
#define CATALOG_VERSION_NO 201012161
56+
#define CATALOG_VERSION_NO 201012271
5757

5858
#endif

src/include/catalog/pg_proc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2396,9 +2396,9 @@ DESCR("less than");
23962396
DATA(insert OID = 1672 ( varbitcmp PGNSP PGUID 12 1 0 0 f f f t f i 2 0 23 "1562 1562" _null_ _null_ _null_ _null_ bitcmp _null_ _null_ _null_ ));
23972397
DESCR("compare");
23982398

2399-
DATA(insert OID = 1673 ( bitand PGNSP PGUID 12 1 0 0 f f f t f i 2 0 1560 "1560 1560" _null_ _null_ _null_ _null_ bitand _null_ _null_ _null_ ));
2399+
DATA(insert OID = 1673 ( bitand PGNSP PGUID 12 1 0 0 f f f t f i 2 0 1560 "1560 1560" _null_ _null_ _null_ _null_ bit_and _null_ _null_ _null_ ));
24002400
DESCR("bitwise and");
2401-
DATA(insert OID = 1674 ( bitor PGNSP PGUID 12 1 0 0 f f f t f i 2 0 1560 "1560 1560" _null_ _null_ _null_ _null_ bitor _null_ _null_ _null_ ));
2401+
DATA(insert OID = 1674 ( bitor PGNSP PGUID 12 1 0 0 f f f t f i 2 0 1560 "1560 1560" _null_ _null_ _null_ _null_ bit_or _null_ _null_ _null_ ));
24022402
DESCR("bitwise or");
24032403
DATA(insert OID = 1675 ( bitxor PGNSP PGUID 12 1 0 0 f f f t f i 2 0 1560 "1560 1560" _null_ _null_ _null_ _null_ bitxor _null_ _null_ _null_ ));
24042404
DESCR("bitwise exclusive or");

src/include/utils/varbit.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,9 @@ extern Datum bitle(PG_FUNCTION_ARGS);
8080
extern Datum bitgt(PG_FUNCTION_ARGS);
8181
extern Datum bitge(PG_FUNCTION_ARGS);
8282
extern Datum bitcmp(PG_FUNCTION_ARGS);
83-
extern Datum bitand(PG_FUNCTION_ARGS);
84-
extern Datum bitor(PG_FUNCTION_ARGS);
83+
/* avoid the names bitand and bitor, since they are C++ keywords */
84+
extern Datum bit_and(PG_FUNCTION_ARGS);
85+
extern Datum bit_or(PG_FUNCTION_ARGS);
8586
extern Datum bitxor(PG_FUNCTION_ARGS);
8687
extern Datum bitnot(PG_FUNCTION_ARGS);
8788
extern Datum bitshiftleft(PG_FUNCTION_ARGS);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy