mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
Allow bit string constants without fully-specified length declaration.
Implement conversion between 8-byte integers and bit strings. Similar to what is done for 4-byte integers.
This commit is contained in:
@ -6,12 +6,12 @@
|
||||
--
|
||||
CREATE TABLE BIT_TABLE(b BIT(11));
|
||||
INSERT INTO BIT_TABLE VALUES (B'10'); -- too short
|
||||
ERROR: bit string length does not match type bit(11)
|
||||
ERROR: Bit string length 2 does not match type BIT(11)
|
||||
INSERT INTO BIT_TABLE VALUES (B'00000000000');
|
||||
INSERT INTO BIT_TABLE VALUES (B'11011000000');
|
||||
INSERT INTO BIT_TABLE VALUES (B'01010101010');
|
||||
INSERT INTO BIT_TABLE VALUES (B'101011111010'); -- too long
|
||||
ERROR: bit string length does not match type bit(11)
|
||||
ERROR: Bit string length 12 does not match type BIT(11)
|
||||
--INSERT INTO BIT_TABLE VALUES ('X554');
|
||||
--INSERT INTO BIT_TABLE VALUES ('X555');
|
||||
SELECT * FROM BIT_TABLE;
|
||||
@ -28,7 +28,7 @@ INSERT INTO VARBIT_TABLE VALUES (B'0');
|
||||
INSERT INTO VARBIT_TABLE VALUES (B'010101');
|
||||
INSERT INTO VARBIT_TABLE VALUES (B'01010101010');
|
||||
INSERT INTO VARBIT_TABLE VALUES (B'101011111010'); -- too long
|
||||
ERROR: bit string too long for type bit varying(11)
|
||||
ERROR: Bit string too long for type BIT VARYING(11)
|
||||
--INSERT INTO VARBIT_TABLE VALUES ('X554');
|
||||
--INSERT INTO VARBIT_TABLE VALUES ('X555');
|
||||
SELECT * FROM VARBIT_TABLE;
|
||||
@ -212,11 +212,11 @@ SELECT a,a<<4 AS "a<<4",b,b>>2 AS "b>>2" FROM bit_table;
|
||||
DROP TABLE bit_table;
|
||||
-- The following should fail
|
||||
select B'001' & B'10';
|
||||
ERROR: cannot AND bit strings of different sizes
|
||||
ERROR: Cannot AND bit strings of different sizes
|
||||
select B'0111' | B'011';
|
||||
ERROR: cannot OR bit strings of different sizes
|
||||
ERROR: Cannot OR bit strings of different sizes
|
||||
select B'0010' # B'011101';
|
||||
ERROR: cannot XOR bit strings of different sizes
|
||||
ERROR: Cannot XOR bit strings of different sizes
|
||||
-- More position tests, checking all the boundary cases
|
||||
SELECT POSITION(B'1010' IN B'0000101'); -- 0
|
||||
position
|
||||
|
Reference in New Issue
Block a user