mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-08-23 14:10:41 +02:00
here is an updated version of the bit type with a bugfix and all the necessa ry SQL functions defined. This should replace what is currently in contrib. I'd appreciate any comments on what is there. Kind regards, Adriaan
30 lines
790 B
SQL
30 lines
790 B
SQL
create table bit_example (a bits, b bits);
|
|
copy bit_example from stdin;
|
|
X0F X10
|
|
X1F X11
|
|
X2F X12
|
|
X3F X13
|
|
X8F X04
|
|
X000F X0010
|
|
X0123 XFFFF
|
|
X2468 X2468
|
|
XFA50 X05AF
|
|
X12345 XFFF
|
|
\.
|
|
|
|
select a,b,a||b as "a||b", bitsubstr(a,4,4) as "sub(a,4,4)",
|
|
bitsubstr(b,2,4) as "sub(b,2,4)",
|
|
bitsubstr(b,5,5) as "sub(b,5,5)"
|
|
from bit_example;
|
|
select a,b,~a as "~ a",~b as "~ b",a & b as "a & b",
|
|
a|b as "a | b", a^b as "a ^ b" from bit_example;
|
|
select a,b,a<b as "a<b",a<=b as "a<=b",a=b as "a=b",
|
|
a>=b as "a>=b",a>b as "a>b",a<=>b as "a<=>b" from bit_example;
|
|
select a,a<<4 as "a<<4",b,b>>2 as "b>>2" from bit_example;
|
|
select a,b,a||b as "a||b", bitsubstr(a,4,4) as "sub(a,4,4)",
|
|
bitsubstr(b,2,4) as "sub(b,2,4)",
|
|
bitsubstr(b,5,5) as "sub(b,5,5)"
|
|
from bit_example;
|
|
|
|
drop table bit_example;
|