-
-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tianmu): impl bit type on tianmu engine #919
[summary] 1. impl insert with mode delayed=0/1 2. impl simple select bit data from table
- Loading branch information
1 parent
41ca5e4
commit 17cdb6c
Showing
15 changed files
with
164 additions
and
38 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
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; |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--source include/have_tianmu.inc | ||
|
||
drop table if exists bittypes, t; | ||
CREATE TABLE t (b BIT(8)); | ||
# insert values using literals: https://dev.mysql.com/doc/refman/8.0/en/bit-value-literals.html | ||
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; | ||
|
||
# data too long | ||
--error 1406 | ||
INSERT INTO t values(b'111111111'); | ||
|
||
# wrong SQL syntax | ||
--error 1064 | ||
insert into t values(b'2'); | ||
|
||
--error 1054 | ||
insert into t values(0B111); | ||
|
||
# insert values with string mode | ||
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; | ||
|
||
# ERROR 1406 (22001): Data too long for column 'b' at row 1 | ||
--error 1406 | ||
insert into t values('10'); | ||
--error 1406 | ||
insert into t values(' '); | ||
--error 1406 | ||
insert into t values("22"); | ||
drop table t; | ||
|
||
# test default M=1 | ||
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; | ||
|
||
# space will be parsed as num 32, so data too long error is returned | ||
--error 1406 | ||
insert into t values(' '); | ||
drop table t; |
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
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
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
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
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
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
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
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
Oops, something went wrong.