Commit 84fc5713 authored by Tom Lane's avatar Tom Lane

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.
parent 8c61f81b
......@@ -29,7 +29,9 @@ static VarBit *bitsubstring(VarBit *arg, int32 s, int32 l,
static VarBit *bit_overlay(VarBit *t1, VarBit *t2, int sp, int sl);
/* common code for bittypmodin and varbittypmodin */
/*
* common code for bittypmodin and varbittypmodin
*/
static int32
anybit_typmodin(ArrayType *ta, const char *typename)
{
......@@ -64,7 +66,9 @@ anybit_typmodin(ArrayType *ta, const char *typename)
return typmod;
}
/* common code for bittypmodout and varbittypmodout */
/*
* common code for bittypmodout and varbittypmodout
*/
static char *
anybit_typmodout(int32 typmod)
{
......@@ -233,8 +237,10 @@ bit_out(PG_FUNCTION_ARGS)
/* same as varbit output */
return varbit_out(fcinfo);
#else
/* This is how one would print a hex string, in case someone wants to
write a formatting function. */
/*
* This is how one would print a hex string, in case someone wants to
* write a formatting function.
*/
VarBit *s = PG_GETARG_VARBIT_P(0);
char *result,
*r;
......@@ -330,7 +336,8 @@ bit_send(PG_FUNCTION_ARGS)
return varbit_send(fcinfo);
}
/* bit()
/*
* bit()
* Converts a bit() type to a specific internal length.
* len is the bitlength specified in the column definition.
*
......@@ -523,7 +530,8 @@ varbit_in(PG_FUNCTION_ARGS)
PG_RETURN_VARBIT_P(result);
}
/* varbit_out -
/*
* varbit_out -
* Prints the string as bits to preserve length accurately
*/
Datum
......@@ -636,7 +644,8 @@ varbit_send(PG_FUNCTION_ARGS)
PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
}
/* varbit()
/*
* varbit()
* Converts a varbit() type to a specific internal length.
* len is the maximum bitlength specified in the column definition.
*
......@@ -718,7 +727,8 @@ varbittypmodout(PG_FUNCTION_ARGS)
* need to be so careful.
*/
/* bit_cmp
/*
* bit_cmp
*
* Compares two bitstrings and returns <0, 0, >0 depending on whether the first
* string is smaller, equal, or bigger than the second. All bits are considered
......@@ -871,7 +881,8 @@ bitcmp(PG_FUNCTION_ARGS)
PG_RETURN_INT32(result);
}
/* bitcat
/*
* bitcat
* Concatenation of bit strings
*/
Datum
......@@ -931,7 +942,8 @@ bit_catenate(VarBit *arg1, VarBit *arg2)
return result;
}
/* bitsubstr
/*
* bitsubstr
* retrieve a substring from the bit string.
* Note, s is 1-based.
* SQL draft 6.10 9)
......@@ -1105,7 +1117,8 @@ bit_overlay(VarBit *t1, VarBit *t2, int sp, int sl)
return result;
}
/* bitlength, bitoctetlength
/*
* bitlength, bitoctetlength
* Return the length of a bit string
*/
Datum
......@@ -1124,11 +1137,12 @@ bitoctetlength(PG_FUNCTION_ARGS)
PG_RETURN_INT32(VARBITBYTES(arg));
}
/* bitand
/*
* bit_and
* perform a logical AND on two bit strings.
*/
Datum
bitand(PG_FUNCTION_ARGS)
bit_and(PG_FUNCTION_ARGS)
{
VarBit *arg1 = PG_GETARG_VARBIT_P(0);
VarBit *arg2 = PG_GETARG_VARBIT_P(1);
......@@ -1164,11 +1178,12 @@ bitand(PG_FUNCTION_ARGS)
PG_RETURN_VARBIT_P(result);
}
/* bitor
/*
* bit_or
* perform a logical OR on two bit strings.
*/
Datum
bitor(PG_FUNCTION_ARGS)
bit_or(PG_FUNCTION_ARGS)
{
VarBit *arg1 = PG_GETARG_VARBIT_P(0);
VarBit *arg2 = PG_GETARG_VARBIT_P(1);
......@@ -1210,7 +1225,8 @@ bitor(PG_FUNCTION_ARGS)
PG_RETURN_VARBIT_P(result);
}
/* bitxor
/*
* bitxor
* perform a logical XOR on two bit strings.
*/
Datum
......@@ -1257,7 +1273,8 @@ bitxor(PG_FUNCTION_ARGS)
PG_RETURN_VARBIT_P(result);
}
/* bitnot
/*
* bitnot
* perform a logical NOT on a bit string.
*/
Datum
......@@ -1289,7 +1306,8 @@ bitnot(PG_FUNCTION_ARGS)
PG_RETURN_VARBIT_P(result);
}
/* bitshiftleft
/*
* bitshiftleft
* do a left shift (i.e. towards the beginning of the string)
*/
Datum
......@@ -1348,7 +1366,8 @@ bitshiftleft(PG_FUNCTION_ARGS)
PG_RETURN_VARBIT_P(result);
}
/* bitshiftright
/*
* bitshiftright
* do a right shift (i.e. towards the end of the string)
*/
Datum
......@@ -1575,7 +1594,8 @@ bittoint8(PG_FUNCTION_ARGS)
}
/* Determines the position of S2 in the bitstring S1 (1-based string).
/*
* Determines the position of S2 in the bitstring S1 (1-based string).
* If S2 does not appear in S1 this function returns 0.
* If S2 is of length 0 this function returns 1.
* Compatible in usage with POSITION() functions for other data types.
......
......@@ -53,6 +53,6 @@
*/
/* yyyymmddN */
#define CATALOG_VERSION_NO 201012161
#define CATALOG_VERSION_NO 201012271
#endif
......@@ -2396,9 +2396,9 @@ DESCR("less than");
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_ ));
DESCR("compare");
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_ ));
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_ ));
DESCR("bitwise and");
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_ ));
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_ ));
DESCR("bitwise or");
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_ ));
DESCR("bitwise exclusive or");
......
......@@ -80,8 +80,9 @@ extern Datum bitle(PG_FUNCTION_ARGS);
extern Datum bitgt(PG_FUNCTION_ARGS);
extern Datum bitge(PG_FUNCTION_ARGS);
extern Datum bitcmp(PG_FUNCTION_ARGS);
extern Datum bitand(PG_FUNCTION_ARGS);
extern Datum bitor(PG_FUNCTION_ARGS);
/* avoid the names bitand and bitor, since they are C++ keywords */
extern Datum bit_and(PG_FUNCTION_ARGS);
extern Datum bit_or(PG_FUNCTION_ARGS);
extern Datum bitxor(PG_FUNCTION_ARGS);
extern Datum bitnot(PG_FUNCTION_ARGS);
extern Datum bitshiftleft(PG_FUNCTION_ARGS);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment