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
bd9d9621
Commit
bd9d9621
authored
Nov 18, 2000
by
Peter Eisentraut
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modify input and output routines to print plain binary strings without any
'b' prefixes.
parent
0f3720ed
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
17 deletions
+32
-17
src/backend/utils/adt/varbit.c
src/backend/utils/adt/varbit.c
+32
-17
No files found.
src/backend/utils/adt/varbit.c
View file @
bd9d9621
...
...
@@ -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.1
2 2000/11/16 21:43:28
petere Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varbit.c,v 1.1
3 2000/11/18 16:18:41
petere Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -50,7 +50,7 @@
Datum
zpbit_in
(
PG_FUNCTION_ARGS
)
{
char
*
s
=
PG_GETARG_CSTRING
(
0
);
char
*
input_string
=
PG_GETARG_CSTRING
(
0
);
#ifdef NOT_USED
Oid
typelem
=
PG_GETARG_OID
(
1
);
#endif
...
...
@@ -67,17 +67,27 @@ zpbit_in(PG_FUNCTION_ARGS)
bits8
x
=
0
;
/* Check that the first character is a b or an x */
if
(
s
[
0
]
==
'b'
||
s
[
0
]
==
'B'
)
if
(
input_string
[
0
]
==
'b'
||
input_string
[
0
]
==
'B'
)
{
bit_not_hex
=
true
;
else
if
(
s
[
0
]
==
'x'
||
s
[
0
]
==
'X'
)
sp
=
input_string
+
1
;
}
else
if
(
input_string
[
0
]
==
'x'
||
input_string
[
0
]
==
'X'
)
{
bit_not_hex
=
false
;
sp
=
input_string
+
1
;
}
else
{
elog
(
ERROR
,
"zpbit_in: %s is not a valid bitstring"
,
s
);
bit_not_hex
=
false
;
/* keep compiler quiet */
/*
* Otherwise it's binary. This allows things like cast('1001'
* as bit) to work transparently.
*/
bit_not_hex
=
true
;
sp
=
input_string
;
}
slen
=
strlen
(
s
)
-
1
;
slen
=
strlen
(
s
p
)
;
/* Determine bitlength from input string */
if
(
bit_not_hex
)
bitlen
=
slen
;
...
...
@@ -104,7 +114,6 @@ zpbit_in(PG_FUNCTION_ARGS)
VARATT_SIZEP
(
result
)
=
len
;
VARBITLEN
(
result
)
=
atttypmod
;
sp
=
s
+
1
;
r
=
VARBITS
(
result
);
if
(
bit_not_hex
)
{
...
...
@@ -283,7 +292,7 @@ _zpbit(PG_FUNCTION_ARGS)
Datum
varbit_in
(
PG_FUNCTION_ARGS
)
{
char
*
s
=
PG_GETARG_CSTRING
(
0
);
char
*
input_string
=
PG_GETARG_CSTRING
(
0
);
#ifdef NOT_USED
Oid
typelem
=
PG_GETARG_OID
(
1
);
#endif
...
...
@@ -300,17 +309,23 @@ varbit_in(PG_FUNCTION_ARGS)
bits8
x
=
0
;
/* Check that the first character is a b or an x */
if
(
s
[
0
]
==
'b'
||
s
[
0
]
==
'B'
)
if
(
input_string
[
0
]
==
'b'
||
input_string
[
0
]
==
'B'
)
{
bit_not_hex
=
true
;
else
if
(
s
[
0
]
==
'x'
||
s
[
0
]
==
'X'
)
sp
=
input_string
+
1
;
}
else
if
(
input_string
[
0
]
==
'x'
||
input_string
[
0
]
==
'X'
)
{
bit_not_hex
=
false
;
sp
=
input_string
+
1
;
}
else
{
elog
(
ERROR
,
"varbit_in: %s is not a valid bitstring"
,
s
)
;
bit_not_hex
=
false
;
/* keep compiler quiet */
bit_not_hex
=
true
;
sp
=
input_string
;
}
slen
=
strlen
(
s
)
-
1
;
slen
=
strlen
(
s
p
)
;
/* Determine bitlength from input string */
if
(
bit_not_hex
)
bitlen
=
slen
;
...
...
@@ -337,7 +352,6 @@ varbit_in(PG_FUNCTION_ARGS)
VARATT_SIZEP
(
result
)
=
len
;
VARBITLEN
(
result
)
=
Min
(
bitlen
,
atttypmod
);
sp
=
s
+
1
;
r
=
VARBITS
(
result
);
if
(
bit_not_hex
)
{
...
...
@@ -418,10 +432,9 @@ varbit_out(PG_FUNCTION_ARGS)
len
;
len
=
VARBITLEN
(
s
);
result
=
(
char
*
)
palloc
(
len
+
2
);
result
=
(
char
*
)
palloc
(
len
+
1
);
sp
=
VARBITS
(
s
);
r
=
result
;
*
r
++
=
'B'
;
for
(
i
=
0
;
i
<
len
-
BITS_PER_BYTE
;
i
+=
BITS_PER_BYTE
,
sp
++
)
{
x
=
*
sp
;
...
...
@@ -1224,8 +1237,10 @@ bitposition(PG_FUNCTION_ARGS)
if
(
p
==
VARBITEND
(
arg
))
{
mask2
=
end_mask
<<
(
BITS_PER_BYTE
-
is
);
is_match
=
mask2
==
0
;
#if 0
elog(NOTICE,"S. %d %d em=%2x sm=%2x r=%d",
i,is,end_mask,mask2,is_match);
#endif
break
;
}
cmp
=
*
s
<<
(
BITS_PER_BYTE
-
is
);
...
...
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