Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
d70bf0dd
Commit
d70bf0dd
authored
Aug 26, 2000
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename BITSPERBYTE to BITS_PER_BYTE to avoid conflict with <values.h>
on some platforms.
parent
662f6a55
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
44 additions
and
44 deletions
+44
-44
src/backend/lib/bit.c
src/backend/lib/bit.c
+7
-7
src/backend/parser/gram.y
src/backend/parser/gram.y
+3
-3
src/backend/utils/adt/format_type.c
src/backend/utils/adt/format_type.c
+2
-2
src/backend/utils/adt/varbit.c
src/backend/utils/adt/varbit.c
+24
-24
src/include/config.h.in
src/include/config.h.in
+2
-2
src/include/utils/varbit.h
src/include/utils/varbit.h
+4
-4
src/interfaces/ecpg/preproc/preproc.y
src/interfaces/ecpg/preproc/preproc.y
+2
-2
No files found.
src/backend/lib/bit.c
View file @
d70bf0dd
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/lib/Attic/bit.c,v 1.1
0 2000/08/20 19:31:37
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/lib/Attic/bit.c,v 1.1
1 2000/08/26 21:53:42
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -21,21 +21,21 @@
void
BitArraySetBit
(
BitArray
bitArray
,
BitIndex
bitIndex
)
{
bitArray
[
bitIndex
/
BITS
PER
BYTE
]
|=
(
1
<<
(
BITS
PERBYTE
-
1
-
(
bitIndex
%
BITSPER
BYTE
)));
bitArray
[
bitIndex
/
BITS
_PER_
BYTE
]
|=
(
1
<<
(
BITS
_PER_BYTE
-
1
-
(
bitIndex
%
BITS_PER_
BYTE
)));
}
void
BitArrayClearBit
(
BitArray
bitArray
,
BitIndex
bitIndex
)
{
bitArray
[
bitIndex
/
BITS
PER
BYTE
]
&=
~
(
1
<<
(
BITS
PERBYTE
-
1
-
(
bitIndex
%
BITSPER
BYTE
)));
bitArray
[
bitIndex
/
BITS
_PER_
BYTE
]
&=
~
(
1
<<
(
BITS
_PER_BYTE
-
1
-
(
bitIndex
%
BITS_PER_
BYTE
)));
}
bool
BitArrayBitIsSet
(
BitArray
bitArray
,
BitIndex
bitIndex
)
{
return
((
bitArray
[
bitIndex
/
BITS
PER
BYTE
]
&
(
1
<<
(
BITS
PERBYTE
-
1
-
(
bitIndex
%
BITSPER
BYTE
)))
return
((
bitArray
[
bitIndex
/
BITS
_PER_
BYTE
]
&
(
1
<<
(
BITS
_PER_BYTE
-
1
-
(
bitIndex
%
BITS_PER_
BYTE
)))
)
!=
0
);
}
src/backend/parser/gram.y
View file @
d70bf0dd
...
...
@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.18
6 2000/08/12 05:15:21
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.18
7 2000/08/26 21:53:43
tgl Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
...
...
@@ -4163,9 +4163,9 @@ Bit: bit '(' Iconst ')'
if ($3 < 1)
elog(ERROR,"length for type '%s' must be at least 1",
$1);
else if ($3 > (MaxAttrSize * BITS
PER
BYTE))
else if ($3 > (MaxAttrSize * BITS
_PER_
BYTE))
elog(ERROR,"length for type '%s' cannot exceed %d",
$1, (MaxAttrSize * BITS
PER
BYTE));
$1, (MaxAttrSize * BITS
_PER_
BYTE));
$$->typmod = $3;
}
| bit
...
...
src/backend/utils/adt/format_type.c
View file @
d70bf0dd
...
...
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/format_type.c,v 1.
4 2000/08/25 18:05:54
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/format_type.c,v 1.
5 2000/08/26 21:53:41
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -254,7 +254,7 @@ type_maximum_size(Oid type_oid, int32 typemod)
case
VARBITOID
:
case
ZPBITOID
:
/* typemod is the (max) number of bits */
return
(
typemod
+
(
BITS
PERBYTE
-
1
))
/
BITSPER
BYTE
return
(
typemod
+
(
BITS
_PER_BYTE
-
1
))
/
BITS_PER_
BYTE
+
2
*
sizeof
(
int32
);
}
...
...
src/backend/utils/adt/varbit.c
View file @
d70bf0dd
...
...
@@ -9,7 +9,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varbit.c,v 1.
8 2000/08/21 04:48:50
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varbit.c,v 1.
9 2000/08/26 21:53:41
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -161,7 +161,7 @@ zpbit_in(PG_FUNCTION_ARGS)
* The bottom ipad bits of the byte pointed to by r need to be
* zero
*/
if
(((
*
r
<<
(
BITS
PER
BYTE
-
ipad
))
&
BITMASK
)
!=
0
)
if
(((
*
r
<<
(
BITS
_PER_
BYTE
-
ipad
))
&
BITMASK
)
!=
0
)
elog
(
ERROR
,
"zpbit_in: bit string too long for bit(%d)"
,
atttypmod
);
}
...
...
@@ -387,7 +387,7 @@ varbit_in(PG_FUNCTION_ARGS)
* The bottom ipad bits of the byte pointed to by r need to be
* zero
*/
if
(((
*
r
<<
(
BITS
PER
BYTE
-
ipad
))
&
BITMASK
)
!=
0
)
if
(((
*
r
<<
(
BITS
_PER_
BYTE
-
ipad
))
&
BITMASK
)
!=
0
)
elog
(
ERROR
,
"varbit_in: bit string too long for bit varying(%d)"
,
atttypmod
);
}
...
...
@@ -415,10 +415,10 @@ varbit_out(PG_FUNCTION_ARGS)
sp
=
VARBITS
(
s
);
r
=
result
;
*
r
++
=
'B'
;
for
(
i
=
0
;
i
<
len
-
BITS
PERBYTE
;
i
+=
BITSPER
BYTE
,
sp
++
)
for
(
i
=
0
;
i
<
len
-
BITS
_PER_BYTE
;
i
+=
BITS_PER_
BYTE
,
sp
++
)
{
x
=
*
sp
;
for
(
k
=
0
;
k
<
BITS
PER
BYTE
;
k
++
)
for
(
k
=
0
;
k
<
BITS
_PER_
BYTE
;
k
++
)
{
*
r
++
=
(
x
&
BITHIGH
)
?
'1'
:
'0'
;
x
<<=
1
;
...
...
@@ -704,7 +704,7 @@ bitcat(PG_FUNCTION_ARGS)
else
if
(
bitlen2
>
0
)
{
/* We need to shift all the bits to fit */
bit2shift
=
BITS
PER
BYTE
-
bit1pad
;
bit2shift
=
BITS
_PER_
BYTE
-
bit1pad
;
pr
=
VARBITS
(
result
)
+
VARBITBYTES
(
arg1
)
-
1
;
for
(
pa
=
VARBITS
(
arg2
);
pa
<
VARBITEND
(
arg2
);
pa
++
)
{
...
...
@@ -768,23 +768,23 @@ bitsubstr(PG_FUNCTION_ARGS)
VARBITLEN
(
result
)
=
rbitlen
;
len
-=
VARHDRSZ
+
VARBITHDRSZ
;
/* Are we copying from a byte boundary? */
if
((
s1
-
1
)
%
BITS
PER
BYTE
==
0
)
if
((
s1
-
1
)
%
BITS
_PER_
BYTE
==
0
)
{
/* Yep, we are copying bytes */
memcpy
(
VARBITS
(
result
),
VARBITS
(
arg
)
+
(
s1
-
1
)
/
BITS
PER
BYTE
,
memcpy
(
VARBITS
(
result
),
VARBITS
(
arg
)
+
(
s1
-
1
)
/
BITS
_PER_
BYTE
,
len
);
}
else
{
/* Figure out how much we need to shift the sequence by */
ishift
=
(
s1
-
1
)
%
BITS
PER
BYTE
;
ishift
=
(
s1
-
1
)
%
BITS
_PER_
BYTE
;
r
=
VARBITS
(
result
);
ps
=
VARBITS
(
arg
)
+
(
s1
-
1
)
/
BITS
PER
BYTE
;
ps
=
VARBITS
(
arg
)
+
(
s1
-
1
)
/
BITS
_PER_
BYTE
;
for
(
i
=
0
;
i
<
len
;
i
++
)
{
*
r
=
(
*
ps
<<
ishift
)
&
BITMASK
;
if
((
++
ps
)
<
VARBITEND
(
arg
))
*
r
|=
*
ps
>>
(
BITS
PER
BYTE
-
ishift
);
*
r
|=
*
ps
>>
(
BITS
_PER_
BYTE
-
ishift
);
r
++
;
}
}
...
...
@@ -1009,8 +1009,8 @@ bitshiftleft(PG_FUNCTION_ARGS)
PG_RETURN_VARBIT_P
(
result
);
}
byte_shift
=
shft
/
BITS
PER
BYTE
;
ishift
=
shft
%
BITS
PER
BYTE
;
byte_shift
=
shft
/
BITS
_PER_
BYTE
;
ishift
=
shft
%
BITS
_PER_
BYTE
;
p
=
VARBITS
(
arg
)
+
byte_shift
;
if
(
ishift
==
0
)
...
...
@@ -1026,7 +1026,7 @@ bitshiftleft(PG_FUNCTION_ARGS)
{
*
r
=
*
p
<<
ishift
;
if
((
++
p
)
<
VARBITEND
(
arg
))
*
r
|=
*
p
>>
(
BITS
PER
BYTE
-
ishift
);
*
r
|=
*
p
>>
(
BITS
_PER_
BYTE
-
ishift
);
}
for
(;
r
<
VARBITEND
(
result
);
r
++
)
*
r
=
0
;
...
...
@@ -1068,8 +1068,8 @@ bitshiftright(PG_FUNCTION_ARGS)
PG_RETURN_VARBIT_P
(
result
);
}
byte_shift
=
shft
/
BITS
PER
BYTE
;
ishift
=
shft
%
BITS
PER
BYTE
;
byte_shift
=
shft
/
BITS
_PER_
BYTE
;
ishift
=
shft
%
BITS
_PER_
BYTE
;
p
=
VARBITS
(
arg
);
/* Set the first part of the result to 0 */
...
...
@@ -1090,7 +1090,7 @@ bitshiftright(PG_FUNCTION_ARGS)
{
*
r
|=
*
p
>>
ishift
;
if
((
++
r
)
<
VARBITEND
(
result
))
*
r
=
(
*
p
<<
(
BITS
PER
BYTE
-
ishift
))
&
BITMASK
;
*
r
=
(
*
p
<<
(
BITS
_PER_
BYTE
-
ishift
))
&
BITMASK
;
}
}
...
...
@@ -1109,17 +1109,17 @@ bitfromint4(PG_FUNCTION_ARGS)
int
len
;
/* allocate enough space for the bits in an int4 */
len
=
VARBITTOTALLEN
(
sizeof
(
int4
)
*
BITS
PER
BYTE
);
len
=
VARBITTOTALLEN
(
sizeof
(
int4
)
*
BITS
_PER_
BYTE
);
result
=
(
VarBit
*
)
palloc
(
len
);
VARATT_SIZEP
(
result
)
=
len
;
VARBITLEN
(
result
)
=
sizeof
(
int4
)
*
BITS
PER
BYTE
;
VARBITLEN
(
result
)
=
sizeof
(
int4
)
*
BITS
_PER_
BYTE
;
/* masks and shifts here are just too painful and we know that an int4 has
* got 4 bytes
*/
r
=
VARBITS
(
result
);
r
[
0
]
=
(
bits8
)
((
a
>>
(
3
*
BITS
PER
BYTE
))
&
BITMASK
);
r
[
1
]
=
(
bits8
)
((
a
>>
(
2
*
BITS
PER
BYTE
))
&
BITMASK
);
r
[
2
]
=
(
bits8
)
((
a
>>
(
1
*
BITS
PER
BYTE
))
&
BITMASK
);
r
[
0
]
=
(
bits8
)
((
a
>>
(
3
*
BITS
_PER_
BYTE
))
&
BITMASK
);
r
[
1
]
=
(
bits8
)
((
a
>>
(
2
*
BITS
_PER_
BYTE
))
&
BITMASK
);
r
[
2
]
=
(
bits8
)
((
a
>>
(
1
*
BITS
_PER_
BYTE
))
&
BITMASK
);
r
[
3
]
=
(
bits8
)
(
a
&
BITMASK
);
PG_RETURN_VARBIT_P
(
result
);
...
...
@@ -1133,12 +1133,12 @@ bittoint4(PG_FUNCTION_ARGS)
bits8
*
r
;
/* Check that the bit string is not too long */
if
(
VARBITLEN
(
arg
)
>
sizeof
(
int4
)
*
BITS
PER
BYTE
)
if
(
VARBITLEN
(
arg
)
>
sizeof
(
int4
)
*
BITS
_PER_
BYTE
)
elog
(
ERROR
,
"Bit string is too large to fit in an int4"
);
result
=
0
;
for
(
r
=
VARBITS
(
arg
);
r
<
VARBITEND
(
arg
);
r
++
)
{
result
<<=
BITS
PER
BYTE
;
result
<<=
BITS
_PER_
BYTE
;
result
|=
*
r
;
}
/* Now shift the result to take account of the padding at the end */
...
...
src/include/config.h.in
View file @
d70bf0dd
...
...
@@ -8,7 +8,7 @@
* or in config.h afterwards. Of course, if you edit config.h, then your
* changes will be overwritten the next time you run configure.
*
* $Id: config.h.in,v 1.13
1 2000/08/20 10:55:34 petere
Exp $
* $Id: config.h.in,v 1.13
2 2000/08/26 21:53:40 tgl
Exp $
*/
#ifndef CONFIG_H
...
...
@@ -221,7 +221,7 @@
* You can try changing this if you have a machine with bytes of another
* size, but no guarantee...
*/
#define BITS
PER
BYTE 8
#define BITS
_PER_
BYTE 8
/*
* Define this is your operating system kernel supports AF_UNIX family
...
...
src/include/utils/varbit.h
View file @
d70bf0dd
...
...
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: varbit.h,v 1.
6 2000/08/21 04:48:54
tgl Exp $
* $Id: varbit.h,v 1.
7 2000/08/26 21:53:40
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -49,13 +49,13 @@ typedef struct
/* Number of bytes in the data section of a bit string */
#define VARBITBYTES(PTR) (VARSIZE(PTR) - VARHDRSZ - VARBITHDRSZ)
/* Padding of the bit string at the end (in bits) */
#define VARBITPAD(PTR) (VARBITBYTES(PTR)*BITS
PER
BYTE - VARBITLEN(PTR))
#define VARBITPAD(PTR) (VARBITBYTES(PTR)*BITS
_PER_
BYTE - VARBITLEN(PTR))
/* Number of bytes needed to store a bit string of a given length */
#define VARBITTOTALLEN(BITLEN) (((BITLEN) + BITS
PERBYTE-1)/BITSPER
BYTE + \
#define VARBITTOTALLEN(BITLEN) (((BITLEN) + BITS
_PER_BYTE-1)/BITS_PER_
BYTE + \
VARHDRSZ + VARBITHDRSZ)
/* pointer beyond the end of the bit string (like end() in STL containers) */
#define VARBITEND(PTR) (((bits8 *) (PTR)) + VARSIZE(PTR))
/* Mask that will cover exactly one byte, i.e. BITS
PER
BYTE bits */
/* Mask that will cover exactly one byte, i.e. BITS
_PER_
BYTE bits */
#define BITMASK 0xFF
#define BITHIGH 0x80
...
...
src/interfaces/ecpg/preproc/preproc.y
View file @
d70bf0dd
...
...
@@ -3116,10 +3116,10 @@ Bit: bit '(' Iconst ')'
sprintf(errortext,"length for type '%s' must be at least 1",$1);
mmerror(ET_ERROR, errortext);
}
else if (atol($3) > (MaxAttrSize * BITS
PER
BYTE))
else if (atol($3) > (MaxAttrSize * BITS
_PER_
BYTE))
{
sprintf(errortext, "length for type '%s' cannot exceed %d", $1,
(MaxAttrSize * BITS
PER
BYTE));
(MaxAttrSize * BITS
_PER_
BYTE));
mmerror(ET_ERROR, errortext);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment