You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Note 1008 Can't drop database 'test_bit'; database doesn't exist
create database test_bit;
drop table if exists bittypes, t;
Warnings:
Note 1051 Unknown table 'test.bittypes'
Note 1051 Unknown table 'test.t'
CREATE TABLE t (b BIT(8));
INSERT INTO t SET b = b'11111111';
INSERT INTO t SET b = B'1010';
INSERT INTO t SET b = 0b0101;
INSERT INTO t values(b'1'), (B'1010'), (0b0101);
SELECT b+0, BIN(b), OCT(b), HEX(b) FROM t;
b+0 BIN(b) OCT(b) HEX(b)
255 11111111 377 FF
10 1010 12 A
5 101 5 5
1 1 1 1
10 1010 12 A
5 101 5 5
INSERT INTO t values(b'111111111');
ERROR 22001: Data too long for column 'b' at row 1
insert into t values(b'2');
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'b'2')' at line 1
insert into t values(0B111);
ERROR 42S22: Unknown column '0B111' in 'field list'
drop table t;
CREATE TABLE t (b BIT(8));
insert into t values('');
insert into t values(' ');
insert into t values('1');
insert into t values('2');
insert into t values('9');
SELECT b+0, BIN(b), OCT(b), HEX(b) FROM t;
b+0 BIN(b) OCT(b) HEX(b)
0 0 0 0
32 100000 40 20
49 110001 61 31
50 110010 62 32
57 111001 71 39
insert into t values('10');
ERROR 22001: Data too long for column 'b' at row 1
insert into t values(' ');
ERROR 22001: Data too long for column 'b' at row 1
insert into t values("22");
ERROR 22001: Data too long for column 'b' at row 1
drop table t;
CREATE TABLE t (b BIT);
insert into t values(b'0');
insert into t values(b'1');
insert into t values(b'');
SELECT b+0, BIN(b), OCT(b), HEX(b) FROM t;
b+0 BIN(b) OCT(b) HEX(b)
0 0 0 0
1 1 1 1
0 0 0 0
insert into t values(' ');
ERROR 22001: Data too long for column 'b' at row 1
drop table t;
create table bit2(a bit(8), b bit(11)) engine=tianmu DEFAULT CHARSET=utf8mb4;
SELECT DATE_ADD('2018-05-01',INTERVAL a DAY) from bit2;
DATE_ADD('2018-05-01',INTERVAL a DAY)
2018-05-24
2018-11-08
select a like "10111", b not like "1011" from bit2;
a like "10111" b not like "1011"
0 1
0 1
select strcmp(a,b), strcmp(b,a),strcmp(a,a) from bit2;
strcmp(a,b) strcmp(b,a) strcmp(a,a)
1 -1 0
-1 1 0
select charset(binary a), collation(binary b) from bit2;
charset(binary a) collation(binary b)
binary binary
binary binary
SELECT _latin1 b'1000001' from bit2;
_latin1 b'1000001'
A
A
SELECT _utf8mb4 0b1000001 COLLATE utf8mb4_danish_ci from bit2;
_utf8mb4 0b1000001 COLLATE utf8mb4_danish_ci
A
A
SELECT _utf8mb4 0B1000001 COLLATE utf8mb4_danish_ci from bit_test;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '0B1000001 COLLATE utf8mb4_danish_ci from bit_test' at line 1
SELECT BIT_AND(a), BIT_OR(a), BIT_XOR(a), BIT_COUNT(a), bin(a >> 1), bin(a << 1), bin(~a), bin(a & b'1111'), a ^ b, a | b, a & b from bit2 group by a,b;
BIT_AND(a) BIT_OR(a) BIT_XOR(a) BIT_COUNT(a) bin(a >> 1) bin(a << 1) bin(~a) bin(a & b'1111') a ^ b a | b a & b
ERROR 22003: BIGINT UNSIGNED value is out of range in '(`test`.`bit2`.`a` * 1234567891011121312)'
select a * 12345678910111213123 from bit2;
ERROR 22003: BIGINT UNSIGNED value is out of range in '(`test`.`bit2`.`a` * 12345678910111213123)'
select a * 12345678910111213123456 from bit2;
ERROR HY000: Numeric result of an expression is too large and cannot be handled by tianmu. Please use an explicit cast to a data type handled by tianmu, e.g. CAST(<expr> AS DECIMAL(18,6)).
drop table bit2;
CREATE TABLE `bit_test` (
`bit1` bit(1) DEFAULT NULL,
`bit2` bit(2) DEFAULT NULL,
`bit8` bit(8) DEFAULT NULL,
`bit16` bit(16) DEFAULT NULL,
`bit32` bit(32) DEFAULT NULL,
`bit63` bit(63) DEFAULT NULL
) ENGINE=TIANMU DEFAULT CHARSET=utf8mb4;
LOAD DATA local INFILE 'MYSQL_TEST_DIR/suite/tianmu/std_data/bit_test.txt' INTO TABLE bit_test fields TERMINATED BY ',' (@var1, @var2, @var3, @var4, @var5, @var6)
SET bit1 = CAST(CONV(MID(@var1, 3, LENGTH(@var1)-3), 2, 10) AS UNSIGNED),
bit2 = CAST(CONV(MID(@var2, 3, LENGTH(@var2)-3), 2, 10) AS UNSIGNED),
bit8 = CAST(CONV(MID(@var3, 3, LENGTH(@var3)-3), 2, 10) AS UNSIGNED),
bit16 = CAST(CONV(MID(@var4, 3, LENGTH(@var4)-3), 2, 10) AS UNSIGNED),
bit32 = CAST(CONV(MID(@var5, 3, LENGTH(@var5)-3), 2, 10) AS UNSIGNED),
bit63 = CAST(CONV(MID(@var6, 3, LENGTH(@var6)-3), 2, 10) AS UNSIGNED);
Warnings:
Warning 1406 Data too long for column 'bit1' at row 3
select bit1+0, bit2+0, bit8+0, bit16+0, bit32+0, bit63+0 from bit_test;
bit1+0 bit2+0 bit8+0 bit16+0 bit32+0 bit63+0
NULL NULL NULL NULL NULL NULL
0 0 0 0 0 0
1 2 7 47 3071 268435455
drop table bit_test;
CREATE TABLE `bit_test` (
`bit1` bit(1) DEFAULT NULL,
`bit2` bit(2) DEFAULT NULL,
`bit8` bit(8) DEFAULT NULL,
`bit16` bit(16) DEFAULT NULL,
`bit32` bit(32) DEFAULT NULL,
`bit63` bit(63) DEFAULT NULL
) ENGINE=TIANMU DEFAULT CHARSET=utf8mb4;
insert into bit_test values(b'1', b'11',b'111',b'1111',b'11',b'111');
insert into bit_test values(b'11', b'11',b'111',b'1111',b'11',b'111');
ERROR 22001: Data too long for column 'bit1' at row 1
insert into bit_test values(b'1', b'111',b'111',b'1111',b'11',b'111');
ERROR 22001: Data too long for column 'bit2' at row 1
insert into bit_test values(b'1', b'1',b'111111111',b'1111',b'11',b'111');
ERROR 22001: Data too long for column 'bit8' at row 1
insert into bit_test values(b'1', b'1',b'1',b'11111111111111111',b'11',b'111');
ERROR 22001: Data too long for column 'bit16' at row 1
insert into bit_test values(b'1', b'1',b'1',b'1', b'111111111111111111111111111111111',b'111');
ERROR 22001: Data too long for column 'bit32' at row 1
insert into bit_test values(b'1', b'1',b'1', b'1', b'1', b'11111111111111111111111111111111111111111111111111111111111111111');
ERROR 22001: Data too long for column 'bit63' at row 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(tianmu): impl bit type, add support to create/desc table with bit type #919 #1132
feat(tianmu): impl bit type, add support to create/desc table with bit type #919 #1132
Changes from all commits
8e90f3d
55b518d
118937a
54a39f3
8300075
8dd5c0b
5246253
1775e53
b46effe
9fd645a
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing