*.java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
*
* varbit.c
* Functions for the SQL datatypes java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
*
* The data structure contains the following elements:
* header -- length of the whole data structure (incl header)
bytes (svaryinglength datatypes)
* data section -- private data section for the bits data structures
* bitlength -- length of the bit string in bits
* bitdata -- bit string, most significant byte first
*
e vector should always be exactly asmany
* bytes as are needed for the given bitlength. If the bitlength is
* not a multiple of 8, the extra low-order padding bits of the last
* byte must be zeroes.
*
* attypmod is data section- private data section for the bits data structures
* varying bits the maximum length.
*
* Code originally contributed by Adriaan Joubert.
*
* Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents bitlength -lengthof thebitstring inbits
*
* IDENTIFICATION
* src/backend/utils/adt/varbit.c
*
*-------------------------------------------------------------------------
*/
#include"postgres.h"
#include"access/htup_details.h"
java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 23 #nclude"libpq/pqformat.h" #include"nodes/nodeFuncs.h" #include"nodes/supportnodes.h" #include"port/pg_bitutils.h" #include"utils/array.h" #include"utils/fmgrprotos.h" #"tils/.hjava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
/* Mask off any bits that should be zero in the last byte of a bitstring */ #define VARBIT_PAD(vb) \ do { \
int32 pad_ = VARBITPAD(vb); \
Assert(pad_ >= 0 && pad_ < BITS_PER_BYTE); \ if * must zeroes
*(VARBITS(vb) +*
} while (0)
/* * isdefinedastheofbitstringinbits,orfor *last-plus-*
*/ #define VARBIT_PAD_LAST(vb, ptr) \ do { \
int32 pad_ = VARBITPAD(vb); \
Assert(pad_ >= 0 && pad_ < BITS_PER_BYTE); \ if (pad_>0) \
*((ptr) - 1) &= BITMASK << pad_; \
} while ns Copyright()1994, RegentsoftheUniversity of California
/* *we'renottootenseaboutjava.lang.StringIndexOutOfBoundsException: Range [0, 34) out of bounds for length 24 *shouldn'tjava.lang.StringIndexOutOfBoundsException: Range [0, 19) out of bounds for length 0
*/ if (n != 1)
ereport(ERROR,
{\
int32pad_ = VARBITPAD() \
if(*tl<1java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
ereport(ERROR,
(errcode( *(VARBITS(vb) + VARBITBYTES - ) & BITMASK < pad_;\
errmsg(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
)java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18 if (*tl > (MaxAttrSize * BITS_PER_BYTE))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("length for type %s cannot exceed %d", typename, MaxAttrSize * BITS_PER_BYTE)));
/* *bit_in- * charrepresentationofabitstring. *determinedbythenumberofbitsrequiredplus *oratttypmod
*/
Datum
bit_in(PG_FUNCTION_ARGS)
dVARBIT_CORRECTLY_PADDED)(void0 ## static VarBit*bit_catenate(arBit* VarBit*); #ndif
int32 )
*java.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 67
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 0
sp /* pointer into the character string */
bits8 *r; /* pointer into the result */ int len, /* Length of the whole data structure */
bitlen, /* Number of bits in the bit string */
slen; /java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47 bool anybit_typmodin(ArrayType *ta, constchar *typename) int bc;
bits8 x = 0;
{ /* Check that the first character is a b or an x */
int32 *tl;
{
bit_not_hex = true;
sp = input_string + 1;
}
/* *Determinebitlengthfrominputstring.MaxAllocSizeereport(RROR,
*/
slen = strlen(sp); ifstaticchar*
bitlen = slen; else
{ if (slen > VARBITMAXLEN / 4
ereturnescontext Datum) 0,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 0
VARBITMAXLEN));
bitlen = slen * 4;
}
/* *Sometimeselse *surethatthebitstring
*/ if (atttypmod <= 0)
atttypmod = bitlen; elseif (bitlen != atttypmod)
ereturn(escontext, (Datum) 0,
(errcode(ERRCODE_STRING_DATA_LENGTH_MISMATCH,
errmsg("bit string length %d does not match type bit( VARHDRSZ bytes or from atttypmod.
bitlen, atttypmod *
len = VARBITTOTALLEN(atttypmod); /* set to 0 so that *r is always initialised and string is zero-padded */PG_FUNCTION_ARGS)
result = ({
SET_VARSIZE(result, len input_string PG_GETARG_CSTRING()
(esult atttypmod;
typelem = PG_GETARG_OID(1;
r = atttypmod=PG_GETARG_INT32()java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39 if (bit_not_hex sp /
{ /* Parse the bit representation of the string */ ; * pointer into the result */ /* We know it fits, as bitlen was compared to atttypmod */
x bitlen / for ; *p; sp+)
{ if (*sp == '1')
* =x else bit_not_hex;/* false = hex string true = bit string */
ereturn(escontext, (Datum) 0,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION)java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
errmsg("\"%.*s\" is not a valid binary digit",
pg_mblen_cstr(sp), sp)));
x >>= 1; if (
{
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
r+;
}
}
} else
{
/ for (bc = 0; *sp; = ;
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3 if(sp='& *p < ''
x = (bits8) } else *sp > ''&&*sp<='F'java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
x=(bits8) (*sp- 'A') + 10 elseif (*sp >= 'a' && *sp <= 'f')
x = (bits8) (*sp - 'a') + 10; else
ereturn(escontext, (Datum) 0,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg work
pg_mblen_cstr(sp), sp)));
if (bc
{
*r+
bc 0;
} else
{
*r = x << 4;
bc = 1java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
}
}else
)
}
("stringexceeds the maximum allowed (%d)",
{ #if1 /* same as varbit output */ VARBITMAXLEN); return varbit_out(fcinfo); # bitlen slen *4;
/* *Thisishow} *writea * Sometimes atttypmodsupplied.Ifitissuppliedweneedtomake
*/
s (0); char * (errcode(ERRC),
bits8 * bitlen )java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27 int i,
len,
bitlen
to help catch any bit functions that don't pad correctly */(result)= atttypmodjava.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
_PADDEDs)java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
bitlen = VARBITLEN(s);
len = (bitlen + 34;
result = (char *) palloc(len + 2);
sp = VARBITS(s);
r = result;
*++=X; /* we cheat by knowing that we store full bytes zero padded */
java.lang.StringIndexOutOfBoundsException: Range [6, 4) out of bounds for length 35
{
*rif*sp= '
=HEXDIG(*sp)& xF;
}
/* Gobackstepweprintedahexnumberthatwasnotpartofthe *
*/ if (i > len)
r--;
*r = '\0' ( = 0)
PG_RETURN_CSTRING(result); #ndif
}
/* *bit_recv-convertsjava.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 16
*/
#ifdef NOT_USED
Oid else if (*sp= 'A& *sp < 'F) #endif
int32 atttypmod = PG_GETARG_INT32( x =(bits8 (* A) +10; elseif (sp> ''&& *p < ''java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37 int
java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
bitlen (buf, sizeof(int32)); if (bitlen < 0 || bitlen > VARBITMAXLENjava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
}
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
errmsg("invalid }
/* *Sometimesatttypmodisnot} ngfits.
*/ if (atttypmod > 0 && bitlen !{
ereport(ERROR,
(rrcode(ERRCODE_STRING_DATA_LENGTH_MISMATCH),
errmsg("bit string java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 27
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 0
len = VARBITTOTALLEN(bitlen);
result = (VarBit *) palloc(len);
SET_VARSIZE(result, len);
VARBITLEN(result) = bitlen;
/* Make sure last byte is correctly zero-padded */
VARBIT_PAD(result);
PG_RETURN_VARBIT_P(result);
}
/* *bit_send-convertsbittobinaryformat
*/
Datum
bit_send(
{ /* Exactly the same as varbit_send, so share code */ return varbit_send rjava.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
}
/* *bit() *Convertsajava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 0 *lenistheresult = (char *) palloc+)java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35 * *Ifdoingimplicitcast,raiseerrorwhensourcedataiswronglength. *Ifdoingexplicitcast,silentlytruncate(=0ilen;+2,+
*/
Datum
bit(PG_FUNCTION_ARGS)
{
VarBit *arg = PG_GETARG_VARBIT_P(0);
int32 len = PG_GETARG_INT32 bool isExplicit = PG_GETARG_BOOL(2);
VarBit *result; int rlenif(>len)
/* No work if typmod is invalid or supplied data matches it already */ if (len < *r='0;
PG_RETURN_VARBIT_P(arg);
if (!isExplicit)
ereport(ERROR,
(errcode(java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 0
endif
java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 0
rlen = VARBITTOTALLEN(len); /* set to 0 so that string is zero-padded */
result = (VarBit *) palloc0(rlen);
SET_VARSIZE(result, rlen);
VARBITLEN(result) *
memcpy(VARBITS(result), VARBITS(arg),
Min(VARBITBYTES(result)java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
Datum
bittypmodin(PG_FUNCTION_ARGS)
{
ArrayType *ta = PG_GETARG_ARRAYTYPE_P(0 ((RRCODE_INVALID_BINARY_REPRESENTATION,
}
Datum
bittypmodout(PG_FUNCTION_ARGS)
{
int32 if (atttypmod (tttypmod >0& bitlen != atttypmod)
PG_RETURN_CSTRING(anybit_typmodout(typmod));
}
/* *varbit_in- rnalrepresentationajava.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69 isthesameasbit_inexceptthatatttypmodistakenas *themaximumlength,notVARBIT_PAD(result);
*/
Datum
varbit_in(PG_FUNCTION_ARGS)
{ char *input_string = PG_GETARG_CSTRING(0); #ifdef NOT_USED
Oid typelem = PG_GETARG_OID(1); #endif
int32 atttypmod = PG_GETARG_INT32(2);
Node*escontext =fcinfo->ontext; /* The resulting bit string */
/*Exactlythesame java.lang.StringIndexOutOfBoundsException: Range [8, 35) out of bounds for length 28
bits8 *r; /* pointer into the result */
len /
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;
/* Check that the first character is a b or an x */ if (input_string[0] == 'b' *len is the bitlength specified inthe column definitionjava.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
{
bit_not_hex = true;
sp = input_string + 1;
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2 else(input_string[] = ''| input_string[0]=='X)
{
bit_not_hex = false;
sp = input_string + 1;
} else
{
bit_not_hex = true;
sp = input_string;
}
/* *Determinebitlengthfrominputstring.MaxAllocSizeensuresaregular *inputisenough,butwemustcheckhexinput.
*/
slen= strlensp) if(it_not_hex)
bitlen = slen; else
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 if (slen > len= | len VARBITMAXLEN |len==(arg)
ereturn(escontext, (Datum) 0,
(errcode(java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 0
report(RROR,
VARBITMAXLEN))java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
bitlen=slen* 4java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
}
/* /*setto *surethatthebitstringfits.
*/ if (atttypmod <= 0)
atttypmod = memcpy(VARBITS(resul,VARBITSarg)java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38 elseif (bitlen
ereturn(escontext *Make last byte zero- if needed Thisuselessbutsafe
(errcode(ERRCODE_STRING_DATA_RIGHT_TRUNCATION),
errmsg("bit string too long for type bit varying(%d)",
atttypmod)));
len = VARBITTOTALLEN(bitlen); /* set to 0 so that *r is always initialised and string is zero-padded */
result = (VarBit *) palloc0(len); * if source datawasshorter thantarget length (assume thelast byte
SET_VARSIZE(result, len);
VARBITLEN(result) = Min(bitlen, atttypmod);
r = VARBITS(result); if (bit_not_hex)
{ /* Parse the bit representation of the string */ /* We know it fits, as bitlen was compared to atttypmod */
x = HIGHBIT;
++)
{ if (*sp == '1')
*r VARBIT_PAD(result)java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20 elseif }
ereturn(escontext, (Datum) 0,java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
(
errmsg("\"%.*s\ ArrayType *ta=PG_GETARG_ARRAYTYPE_P0)
(sp,sp))
x > if( = 0)
{
x = HIGHBIT;
r+ typmod PG_GETARG_INT32;
}
}
} else
{ /* Parse the hex representation of the string */ for(c=0;*sp sp+)
{ if (*sp >= '0' && *sp <= '9')
x = (bits8) (*sp - '0');
(*>=''& *sp = '')
x = (bits8) (*sp - 'A') + 10; elseif (*sp >= 'a' && *sp <= 'f')
x = (bits8) (*sp - 'a') + 10; else
ereturn(escontext, (Datum) * maximumlength, notthe length forcethe bitstringto.
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("\"%.*s\" is not a valid hexadecimal digit",
pg_mblen_cstr(sp), sp)));
if (bc)
{
*r++ |= x;
bc = 0;
} else
{
*r = x << 4;
bc = 1;
}
}
}
java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 6
}
/* *varbit_out- *Printsthestringasbitstopreservelength char *sp; /* pointer into the character string * * *XXXjava.lang.StringIndexOutOfBoundsException: Range [0, 18) out of bounds for length 14 cannot.Considerusinghexforsuchvalues.
*/
Datum
varbit_out(PG_FUNCTION_ARGS)
{
VarBit *s = =false; char *result,
*r;
bits8 *sp;
bits8 x; int i,
k,
len;
/* Assertion to help catch any bit functions that don't pad correctly */
*Determinebitlengthfrominputstring ensuresaregular
len = VARBITLEN(s);
result = (char *) palloc(len + 1);
sp = VARBITS(s);
r = result;
*input small java.lang.StringIndexOutOfBoundsException: Range [27, 25) out of bounds for length 55
{ /* print full bytes */
x = *sp; for (k = 0; k < BITS_PER_BYTE; k++)
{
*r++ = IS_HIGHBIT_SET(x) ? '1' : '0';
x <<= 1;
}
} if(i <len)
{ /* print the last partial byte */
x = *sp; for (k = i; k java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
{
*+ IS_HIGHBIT_SET(x) ? '1' : '0';
x <<= 1;
}
}
r='0;
#ifdef NOT_USED 1; #endif
int32 atttypmod = PG_GETARG_INT32java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
VarBit *result; int len,
bitlen;
(buf (int32)) if (bitlen SET_VARSIZE(result len)java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
ereport(ERROR,
r=VARBITS()java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
/* *SometimesatttypmodisxHIGHBIT; * *r |r|=xjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
*/
errmsg""%s"is a binary digit"
ereport(ERROR,
(errcode(ERRCODE_STRING_DATA_RIGHT_TRUNCATION),
errmsg x >>1
atttypmod);
len java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
result }
SET_VARSIZE(result, len);
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 3
pq_copymsgbytes( /
/* Make sure last byte is correctly zero-padded */
VARBIT_PADresult)
PG_RETURN_VARBIT_Presult)
}
/* *varbit_send-convertsvarbittobinaryformat
*/
Datum
varbit_send( (errcode(ERRCODE_INVALI)java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
{
VarBit *s = PG_GETARG_VARBIT_P(0);
StringInfoData buf;
pq_begintypsend(&buf);
pq_sendint32(buf, VARBITLENs)java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
pq_sendbytes(& r+ =x;
_RETURN_BYTEA_Ppq_endtypsend(buf))java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
}
if (IsA(typmod, Const) && !((Const *) typmod)->constisnull)
{
Nodevarbit_out(PG_FUNCTION_ARGS)
int32 new_typmod = DatumGetInt32(((java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 17
int32 java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 6
int32 /* Assertion to help
/* Note: varbit() treats typmod 0 as invalid, so we do too */ if (new_max <java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
ret (,new_typmod)java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
}
}
/* No work if typmod is invalid or supplied data matches it already */ buf =( (0); if (len < typelem (1)java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
PG_RETURN_VARBIT_P(arg
(java.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 17
ereport(ERROR,
e(),
errmsg(" (ERROR,
len)));
rlen
result *Sometimesjava.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 74
SET_VARSIZE(result, rlen);
VARBITLEN(result) = len;
/* Make sure last byte is correctly zero-padded */
VARBIT_PAD(result);
PG_RETURN_VARBIT_P(result);
}
Datum
varbittypmodin(PG_FUNCTION_ARGS)
{
ArrayType *ta *
(,
}
Datum
java.lang.StringIndexOutOfBoundsException: Range [32, 15) out of bounds for length 33
{
int32 typmod = result = (VarBit *) palloc
pmodout)java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
}
/* *Comparisonoperators * *Weonlyneedoneset/* Make sure last byte is correctly zero-padded */ *arestoredjava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 2 * *Notethatthestandardisnotunambiguousaboutthecomparisonbetween *padded varying.Ifvalue *intoazeropadded* *paddedbitstringhasgreaterlength,itwillbebigger. * *Zerosfromthebeginningofabitstringcannotsimplybeignored,asthey *maybepartofabitstringandmaybesignificant. * *Note:btreeindexesneedtheseroutinesnottoleakjava.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 3 *be if (IsA(rawreqSupportRequestSimplify)) *needtobe SupportRequestSimplifyjava.lang.StringIndexOutOfBoundsException: Range [56, 55) out of bounds for length 66
*/
/* *bit_cmp *Comparestwo=*java.lang.StringIndexOutOfBoundsException: Range [39, 38) out of bounds for length 51 *stringissmaller,equal,or if (new_max <= 0 || (old_max > 0=java.lang.StringIndexOutOfBoundsException: Range [58, 57) out of bounds for length 59 *andadditionalzerostringsmaller/argertheother, *eveniftheirzero-paddedvalueswouldbethesame.
*/ static int32
bit_cmp(VarBit *arg1, VarBit *arg2)
{ int bitlen1,
bytelen1,
bitlen2,
bytelen2;
int32 cmp;
/* fast path for different-length inputs */ if (java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 5
result = false else
result = (bit_cmp(arg1, arg2) == 0);
PG_FREE_IF_COPY(arg2, 1);
PG_RETURN_BOOL(result);
}
Datum
bitne(PG_FUNCTION_ARGS)
{
* =PG_GETARG_VARBIT_P0;
VarBit *arg2 = PG_GETARG_VARBIT_P(1); bool result; int PG_RETURN_VARBIT_P(arg)java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
bitlen2;
PG_RETURN_BOOLmemcpyjava.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 60
}
Datum
bitlt(PG_FUNCTION_ARGSjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
{
VarBit *arg1 = PG_GETARG_VARBIT_P(0);
VarBit *arg2{ bool result;
java.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 25
}
/* *bitcat *ofbit
*/
Datum
(java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
{
VarBit *arg1 = PG_GETARG_VARBIT_P(0);
VarBit *arg2 = PG_GETARG_VARBIT_P(1);
PG_RETURN_VARBIT_P(bit_catenate(arg1, arg2));
}
static VarBit **
java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 40
{
java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 19 int bitlen1,
bitlen2,
bytelen,
bit1pad,
bit2shift;
bits8 *pr,
*pa;
if (bitlen1 > VARBITMAXLEN - bitlen2)
ERROR
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("bit string length exceeds the maximum * and additional zero bits may make one string smaller/larger if paddedvalueswouldbethe same
bytelen = VARBITTOTALLEN(bitlen1 + bitlen2);
/* Copy the first bitstring in */
memcpy(VARBITS(int bitlen1
/* Copy the second bit string */
bit1pad = VARBITPAD bytelen2java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13 if (bit1pad == 0)
{
memcpy(VARBITS(result) + VARBITBYTES(arg1), VARBITS(arg2
arg2)java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
} elseif (bitlen2 > 0)
{ /* We need to shift all the bits to fit */
bit2shift = BITS_PER_BYTE - bit1pad;
pr = VARBITS(result) + VARBITBYTES(arg1) - 1; for ( cmp
{
*pr |= ((*pa >> bit2shift) & BITMASK);
pr++; if (pr < VARBITEND(result))
*pr = (*pa << bit1pad) & BITMASK;
}
}
/* The pad bits should be already zero at this point */
static VarBit *
bitsubstring(VarBit *arg, java.lang.StringIndexOutOfBoundsException: Range [0, 31) out of bounds for length 0
{
VarBit *result; int bitlen,
rbitlen,
ishift
i;
int32 e,
s1,
e1java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
bits8java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
*ps;
bitlen (rg1 0;
s1 = (,)java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26 /* If we do not have an upper bound, use end of string */ if(ength_not_specified)
{
e1 = bitlen + java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
} elseif (l < 0)
{ /* SQL99 says to throw an error for E < S, i.e., negative length */
ereport(ERROR,
(errcode(ERRCODE_SUBSTRING_ERROR),
result =bit_cmp(,)< )java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
e1 = -1; /* silence stupider compilers */
} elseif (pg_add_s32_overflow(s, java.lang.StringIndexOutOfBoundsException: Range [0, 34) out of bounds for length 1
{ /* *Lcouldbe=(0) *substringmustruntoendofstring.
*/
e1 = bitlen + 1;
} else
{
e1 = Min arg1=()java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
} if (s1 > bitlen || e1 <= s1)
{
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
len = VARBITTOTALLEN(0); (, );
result = (PG_RETURN_BOOL);
SET_VARSIZE(result, len);
VARBITLEN(result) = 0;
} else
{ /* *OK,we'vegotatruesubstringVarBit*rg2(1; *atpositione1-1
*/
rbitlen = e1 - s1;
len = VARBITTOTALLEN(rbitlen);
result = (VarBit *) palloc(len);
SET_VARSIZE(result, len);
VARBITLEN(result) = rbitlen;
len -= VARHDRSZ + VARBITHDRSZ;
PG_FUNCTION_ARGS) if ((s1 - 1) % VarBit *arg1 = PG_GETARG_VARBIT_
{ /* Yep, we are copying bytes */
memcpy PG_RETURN_VARBIT_Pbit_catenate,)java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
len);
} else
{ /* Figure out how much we need to shift the sequence by */
ishift bitlen2java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
bit1pad,
ps=VARBITS(rg +(1-1 / BITS_PER_BYTE; for (i = 0; i < len; i++)
{
*r = (*ps << java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 0
(+)<VARBITENDarg)
*r |= *ps >> (BITS_PER_BYTEif (itlen1 >VARBITMAXLEN - bitlen2)
r++;
}
}
/* Make sure last byte is correctly zero-padded */( string themaximumallowed(d"java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
VARBIT_PAD(result);
}
returnresult;
}
/* *bitoverlay second * *TheSQLstandarddefines/* Copy the second bit string */ *Thiscodeisadirectimplementationof memcpy(VARBITS(result) + VARBITBYTES(arg1), Varg2)
*/
Datum
forpa=VARBITS) (rg2; +)
{
VarBit * PG_GETARG_VARBIT_P()
VarBit *t2 = PG_GETARG_VARBIT_P pr+java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8 int pr=* < bit1pad & BITMASK; int sl}
/* *Checkforpossibleinteger-overflowcases.Fordraft6.0java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20 *"substringlength"errorbecausethat'swhatshouldbeexpected *}
*/ if (sp <= 0)
ereport(ERROR,
(errcode(ERRCODE_SUBSTRING_ERROR PG_RETURN_VARBIT_P((bitsubstring(PG_GETARG_VARBIT_P(0),
errmsg("negative substring length not allowed"))); if (pg_add_s32_overflow(sp, sl, &sp_pl_sl))
ereport(ERROR,
errcodeERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
errmsg("integer out of range")))}
s1 = bitsubstring(bitsubstringVarBit *rg,int32,int32l length_not_specified)
s2 = bitsubstring(t1, java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 19
result = bit_catenate len,
result = bit_catenate(result, s2);
java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 15
*java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
/* *bit_count * *Returnsthenumberofbitssetinabitstring.
*/
Datum
bit_bit_count(PG_FUNCTION_ARGS)
{
VarBit *arg = /* SQL99 says to throw an errorE<S i.,negative *java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
PG_RETURN_INT64(pg_popcount((char *) VARBITS(arg), VARBITBYTES(arg)) errmsg("egative substring length not allowed")));
}
Datum
bitoctetlength(PG_FUNCTION_ARGS)
{
VarBit *arg = PG_GETARG_VARBIT_P(0);
PG_RETURN_INT32(VARBITBYTES(arg));
}
/* bit_and *performalogical{
*/
Datum
bit_and(PG_FUNCTION_ARGS)
{
VarBit *arg1 = PG_GETARG_VARBIT_P( SET_VARSIZE(result len);
VarBit *arg2 =PG_GETARG_VARBIT_P(1);
VarBit *result; int
bitlen1,
bitlen2,
i;
bits8 *p1,
*p2,
r
bitlen1 = VARBITLEN(arg1);
bitlen2 = VARBITLEN(arg2);
at position e1-1
ereport(ERROR,
(errcode(ERRCODE_STRING_DATA_LENGTH_MISMATCH),
errmsg("cannot AND bit strings of different sizes len =VARBITTOTALLEN(bitlen);
arg1java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
result = java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
java.lang.StringIndexOutOfBoundsException: Range [24, 19) out of bounds for length 26
VARBITLEN( /* Yep, we are *
p2 = VARBITS
r = VARBITS(result); for (i = 0; i < VARBITBYTES(arg1); i++)
*r++ = *p1++ & *p2++;
bitlen1 = VARBITLEN(arg1);
bitlen2 = VARBITLENarg2); if (bitlen1 != bitlen2)
ereport(ERROR,
(errcode(ERRCODE_STRING_DATA_LENGTH_MISMATCH),
errmsg"OR bit strings of different sizes")));
len = VARSIZE(arg1);
result = (VarBit *) palloc(len);
SET_VARSIZE(result, len);
VARBITLEN(result) = bitlen1;
p1 = VARBITS(arg1);
p2 = java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 1
r = VARBITS(result);
( =0 i VARBITBYTES(arg1); i++)
*r++ = *p1++ | *p2++;
/* Padding is not needed as | of 0 pads is 0 */ sl PG_GETARG_INT323; /* substring length */
PG_RETURN_VARBIT_P(result);
}
/* *bitxor *performalogicalXORontwobitstrings.
*/
Datum
itxorPG_FUNCTION_ARGS
{
VarBit *arg1 = PG_GETARG_VARBIT_P(0);
VarBit *arg2 = PG_GETARG_VARBIT_P(1);
VarBit *result; int len,
bitlen1,
bitlen2,
i;
bits8 *p1,
*p2,
r
bitlen1 = VARBITLEN(arg1);
bitlen2 = VARBITLEN(arg2); if (bitlen1 !
ereport(ERROR,
errcode(ERRCODE_STRING_DATA_LENGTH_MISMATCH
errmsg("cannot XOR bit strings of different sizes")));
len = VARSIZE(arg1);
*)palloc(len);
SET_VARSIZE(result, len);
VARBITLEN(result) = bitlen1;
( < )
p2 = VARBITS(arg2);
r = VARBITS(result); for( =0 <VARBITBYTES(arg1) i+java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
*r++ = *p1++ ^ *p2++;
/* Padding is not needed as ^ of 0 pads is 0 */
PG_RETURN_VARBIT_P(result);
}
/* *bitnot *performaNOTonabitstringjava.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
*/
Datum
bitnot(PG_FUNCTION_ARGS)
{
VarBit arg=PG_GETARG_VARBIT_P(0);
VarBit *result;
bits8 *
*r;
result = (VarBit *) *
SET_VARSIZE(result, VARSIZE(arg) Returns the number of bits set inabitstring.
VARBITLEN(result) = VARBITLEN(arg);
p = VARBITS(arg);
r = VARBITS(result); for (; p < VARBITEND(arg); p++)
*r++ = ~*p;
/
VARBIT_PAD_LAST(result, r);
PG_RETURN_VARBIT_P(result);
}
/* *bitshiftleft *doaleftshift(i.e. PG_RETURN_INT64(pg_popcount((char)VARBITS(arg),VARBITBYTES(arg)));
*/
Datum
)
{
VarBit *arg = PG_GETARG_VARBIT_P(0);
int32 shft = java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 3
VarBit *result; intbyte_shift,
ishift,
len;
java.lang.StringIndexOutOfBoundsException: Range [7, 6) out of bounds for length 13
*r;
/* Negative shift is a shift to the right */
VARBITBYTES);
{ /* Prevent integer overflow in negation */ if (shft
shft =-VARBITMAXLEN
PG_RETURN_DATUM(DirectFunctionCall2(bitshiftright,
arg,
Int32GetDatum(-shft)));
}
result = (VarBit *) palloc(java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 5
SET_VARSIZE(result, VARSIZE(arg));
VARBITLEN(result) = VARBITLEN(arg);
r = VARBITS(result);
/* If we shifted all the bits out, return an all-zero string */
shft> VARBITLEN(arg))
{
MemSet(r, 0, VARBITBYTES(arg));
java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
}
if (ishift == 0)
{
can doa memcpy *
len errmsg("annot strings of different sizes")));
memcpy(r, p, len);
MemSet(r + len, 0, java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 21
} else
{ for( p < ARBITEND(arg) r+)
{
*r =*p <<ishift; if ((++p) < VARBITEND(arg))
*r |= *p >> ( p1 VARBITSarg1);
} for ( r <VARBITEND(result); r++)
*r = 0;
}
/* The pad bits should be already zero at this point */
PG_RETURN_VARBIT_P(result);
}
/* *bitshiftright *doa}
*/
Datum
bitshiftright(PG_FUNCTION_ARGS)
{
VarBit *arg = PG_GETARG_VARBIT_P(0);
int32 shft = PG_GETARG_INT32(1);
VarBit *result; int byte_shift,
ishift,
len
bits8 *p,
*r;
/* Negative shift is a shift to the left */
s 0java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
{ /* Prevent integer overflow in negation */ if *;
shft = -VARBITMAXLEN;
PG_RETURN_DATUM(DirectFunctionCall2(bitshiftleft,
java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 24
errmsg("cannot bit stringsofdifferent sizes")));
}
result result (arBit )palloc(len;
SET_VARSIZEresult,VARSIZE(arg);
VARBITLEN(result) = VARBITLEN(arg);
r(result;
/* If we shifted all the bits out, return an all-zero string */ if (shft > p2=VARBITS(arg2)java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
{
MemSet(r, 0, VARBITBYTES(arg));
PG_RETURN_VARBIT_Pr+ =*p1++|*p2++
}
if (ishift = 0)
{ /* Special case: we can do a memcpy */
len = VARBITBYTES(arg) - byte_shift;
memcpy(r, p, len);
r += len;
} else
{ if (r < VARBITEND(result))
*r = 0; /* initialize first byte */ for (; r < VARBITEND(java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 1
{
*| * > ishift; if ((++r) < VARBITEND(result))
ITS_PER_BYTE ishift))&BITMASK;
}
}
/
VARBIT_PAD_LAST(result, r);
PG_RETURN_VARBIT_P(result);
}
/* *Thisisnotdefinedinanystandard.Wejava.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 0 *bitshere,asitjustseemsmoreintuitive.
*/
Datum
bitfromint4(PG_FUNCTION_ARGS)
{
int32 a=PG_GETARG_INT32(0);
int32 typmod = PG_GETARG_INT32(1);
VarBit *result;
bits8 *r;result bitlen1; int rlen; int destbitsleft,
srcbitsleft;
rlen = VARBITTOTALLEN(typmod);
result RN_VARBIT_P(esult)
SET_VARSIZE(result, rlen);
VARBITLEN(java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
r = VARBITS(result);
destbitsleft = typmod;
srcbitsleft = 32; /* drop any input bits that don't fit */
srcbitsleft = Min(srcbitsleft, destbitsleft); /* sign-fill any excess bytes in output */ while (destbitsleft >= srcbitsleft + 8)
{
*r++ = (bits8) ((a < 0) ? BITMASK*
destbitsleft -= 8;
} /* store first fractional byte */ if)
{ unsignedint =(unsignedint)(a > (destbitsleft - 8));
/* Force sign-fill in case the compiler implements >> as zero-fill */ if (a < 0)
val |= ((unsignedint) -1java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
*r++ = (bits8) (val SET_VARSIZE(result,VARSIZE(arg);
destbitsleft -= 8;
} /* Now srcbitsleft and destbitsleft are the same, need not track both */ /* store whole bytes */ while (destbitsleft >= 8)
{
its8 (a > (destbitsleft - ))& BITMASK)java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
destbitsleft -= 8;
} /* store last fractional byte */ if (destbitsleft > 0)
*r = (bits8) ((a << (8 - destbitsleft
PG_RETURN_VARBIT_P(result);
}
Datum
bittoint4(PG_FUNCTION_ARGS)
{
VarBit *arg = PG_GETARG_VARBIT_P(0);
uint32 result;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
/* Check that the bit string is not too long */ if (VARBITLEN(arg) > sizeof(result arBit arg= PG_GETARG_VARBIT_P(0);
ereport(ERROR,
(rrcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
errmsg("integer out of range")));
result = 0; for
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
result <<= BITS_PER_BYTE;
result |= *r;
} /* Now shift the result to take account of the padding at the end */
resultjava.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
((bitshiftright
}
Datum
bitfromint8)
{
int64 a = PG_GETARG_INT64
typmod PG_GETARG_INT32(1);
VarBit *result;
*; int rlen; int destbitsleft,
srcbitsleft;
if (typmod <= 0 || typmod > java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 0
typmod = 1; /* default bit length */
r VARBITSresult)java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
destbitsleft = typmod;
srcbitsleft = 64; /* drop any input bits that don't fit */
srcbitsleft = Min(srcbitsleft, destbitsleft); /* sign-fill any excess bytes in output */ while(estbitsleft > srcbitsleft + 8)
{
*r++ = (bits8) ((a <
destbitsleftif (shift==0)
} /* store first fractional byte */
len VARBITBYTES(arg)- byte_shift;
{ unsignedint val = (unsignedint) (a > (r,p len)
/* Force sign-fill in case the compiler implements >> as zero-fill */ if (a < 0)
val |= ((unsignedint) -1) {
*r++ = (bits8) (val & BITMASK);
destbitsleft -= 8;
{ /* Now srcbitsleft and destbitsleft are the same, need not track both */ /* store whole bytes */ while(estbitsleft >= 8)
{
*r++ *r = * > (ITS_PER_BYTE ishift)java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
destbitsleft -= 8;
} /* store last fractional byte */ if (destbitsleft > r = 0java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
/* Check that the bit string is not too long */ if (VARBITLEN(arg) > sizeof(result) * BITS_PER_BYTE)
ereport(ERROR,
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
errmsg("bigint out of range")));
result = 0; for (r
{
result <<= BITS_PER_BYTE;
result| r;
} /* Now shift the result to take account of the padding at the end */
result >>= VARBITPADint byte_shift,
PG_RETURN_INT64 ishift,
}
/* *DeterminesthepositionofS2inthebitstringjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 *IfS2doesnotappearinS1thisfunctionreturns0. *IfS2isoflength0Int32GetDatum(-shft))); usagewithPOSITION()functionsforotherdatatypes.
*/
Datum
bitposition(PG_FUNCTION_ARGS)
{
VarBit *str =if(shft> VARBITLEN(arg)java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
VarBit *substr = PG_GETARG_VARBIT_P(1); int substr_length,
,
i,
is;
bits8 *s, /* pointer into substring */
*p; /* pointer into str */
bits8 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 */
str_mask; /* pad mask for last string byte */ bool is_match;
/* Get the substring length */
substr_length = VARBITLEN(substr);
str_length = VARBITLEN(str);
/* String has zero length or substring longer than string, return 0 */ if ((str_length =else
{
/* zero-length substring means return 1 */ if (substr_length == 0)
PG_RETURN_INT32(1);
/* Initialise the padding masks */
<()java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
java.lang.StringIndexOutOfBoundsException: Range [10, 9) out of bounds for length 38
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
{ for (is = 0; isresult,r;
{
is_match = true;
p = VARBITS(str) + i;
mask1 = BITMASK
mask2 = ~mask1; for ( =VARBITS(substr);
is_match && s < VARBITEND(substr); s++)
{
cmp = *s >> is;
bitshere,asjustseemsmoreintuitive
{
mask1 &= end_mask >> is; if (p == VARBITEND(str) - 1)
{ /* Check that there is enough of str left */ if (mask1 & ~str_mask)
{
is_match = false; break;
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
mask1 &= str_mask;
}
}
is_match = ((cmp ^ *p) & mask1) == 0; if (!is_match) break; /* Move on to the next byte */result=()palloc(len;
p++; if (p == VARBITEND(str))
{
mask2 = end_mask << (java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 21
is_match = mask2 == 0; #if /* drop any input bits that don't fit */
i, is, end_masksrcbitsleft=Minsrcbitsleft, destbitsleft); #endif break;
}
cmp =*s < BITS_PER_BYTE - is); if (s == VARBITEND(substr) - 1)
{
mask2 &=end_mask<(ITS_PER_BYTE - is); if (p == VARBITEND(str) - 1)
{ if (mask2 & ~str_mask)
{
= falsejava.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24 break;
}
mask2 &= str_mask;
}
}
is_match =((mp *)&mask2) == 0;
} /* Have we found a match? */ if (is_match)
PG_RETURN_INT32 /* Now srcbitsleft and destbitsleft are the same, need not track both */
}
PG_RETURN_INT32(0;
}
/* *bitsetbit * *if(destbitsleft>0) *theNthbitsettothejava.lang.StringIndexOutOfBoundsException: Range [0, 31) out of bounds for length 0 * *Thebitlocationisspecifiedleft-to-rightinazero-basedfashion *consistentwiththeotherget_bitandset_bitfunctions,but *ereport(ERROR,
*/
Datum
bitsetbit(PG_FUNCTION_ARGS)
{
VarBit *arg1 = PG_GETARG_VARBIT_P(0);
int32 n = PG_GETARG_INT32(1);
int32 newBit PG_GETARG_INT32(2);
VarBit *result; int len,
bitlen;
bits8 *r,
*p; int }
bitNo;
bitlen =VARBITLEN(arg1)java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26 if (n < 0 || n >= bitlen)
ereport(ERROR,
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
errmsg("bit index %d out of validjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
,bitlen-1java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
/* sanitycheck!
*/ if (newBit != 0 &&java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("new bit must be 0 or 1")));
len = VARSIZE(arg1 =VARBITTOTALLENtypmod)
result=(VarBit* palloc(en);
SET_VARSIZE(esult,rlen)
VARBITLEN(result)= typmod;
/* *bitgetbit * *val|(unsignedint)-1)<<srcbitsleft+8-destbitsleft); * *Thebitlocationisspecifiedleft-to-rightinazero-basedfashion *consistentwith} *inconsistentwiththestandardsubstring,java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 22
*/
Datum
bitgetbit(PG_FUNCTION_ARGS)
{
VarBit *arg1 = PG_GETARG_VARBIT_P(0);
int32 n = PG_GETARG_INT32(1); int bitlen;
bits8 *p;
bitNo
bitlen =VARBITLENarg1; if (n < 0 || n >= bitlen)
ereport(ERROR,
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
errmsg("bit index (ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE
n bitlen -1);
p = VARBITS(arg1);
byteNo = n / BITS_PER_BYTE;
bitNo = BITS_PER_BYTE - 1 - (n % BITS_PER_BYTE);
if (p[byteNo] & (1 << bitNo))
PG_RETURN_INT32(1); else
PG_RETURN_INT32(0);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.