forked from stoneatom/stonedb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(tianmu): bit operators and functions problems stoneatom#1173
Cause: The mysql original item will round when time convert to longlong, but tianmu won't. Solution: Do rounding use mysql funciton.
- Loading branch information
1 parent
1a7fe0f
commit 26619fd
Showing
3 changed files
with
105 additions
and
3 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,50 @@ | ||
DROP DATABASE IF EXISTS issue1173_test_db; | ||
CREATE DATABASE issue1173_test_db; | ||
USE issue1173_test_db; | ||
CREATE TABLE t1 (a TIME(1) NOT NULL)engine=tianmu; | ||
INSERT INTO t1 VALUES ('00:00:02.9'); | ||
INSERT INTO t1 VALUES ('00:00:02'); | ||
INSERT INTO t1 VALUES ('00:00:02.98'); | ||
INSERT INTO t1 VALUES ('00:00:02.5'); | ||
INSERT INTO t1 VALUES ('00:00:02.51'); | ||
INSERT INTO t1 VALUES ('00:00:02.49'); | ||
CREATE TABLE t1i (a TIME(1) NOT NULL)engine=innodb; | ||
INSERT INTO t1i VALUES ('00:00:02.9'); | ||
INSERT INTO t1i VALUES ('00:00:02'); | ||
INSERT INTO t1i VALUES ('00:00:02.98'); | ||
INSERT INTO t1i VALUES ('00:00:02.5'); | ||
INSERT INTO t1i VALUES ('00:00:02.51'); | ||
INSERT INTO t1i VALUES ('00:00:02.49'); | ||
select * from t1; | ||
a | ||
00:00:02.9 | ||
00:00:02.0 | ||
00:00:03.0 | ||
00:00:02.5 | ||
00:00:02.5 | ||
00:00:02.5 | ||
select * from t1i; | ||
00:00:02.9 | ||
00:00:02.0 | ||
00:00:03.0 | ||
00:00:02.5 | ||
00:00:02.5 | ||
00:00:02.5 | ||
SELECT a, a & a, a | a, a^0, a<<1, a<<0, a>>1, bit_count(a) FROM t1; | ||
a a & a a | a a^0 a<<1 a<<0 a>>1 bit_count(a) | ||
00:00:02.9 3 3 3 6 3 1 2 | ||
00:00:02.0 2 2 2 4 2 1 1 | ||
00:00:03.0 3 3 3 6 3 1 2 | ||
00:00:02.5 3 3 3 6 3 1 2 | ||
00:00:02.5 3 3 3 6 3 1 2 | ||
00:00:02.5 3 3 3 6 3 1 2 | ||
CREATE TABLE t2 (a DATETIME(1) NOT NULL); | ||
INSERT INTO t2 VALUES ('2001-01-01 00:00:02.9'); | ||
INSERT INTO t2 VALUES ('2001-01-01 23:59:59.9'); | ||
INSERT INTO t2 VALUES ('9999-12-31 23:59:59.9'); | ||
SELECT a, a & a, a | a, a^0, a<<1, a<<0, a>>1, bit_count(a) FROM t2; | ||
a a & a a | a a^0 a<<1 a<<0 a>>1 bit_count(a) | ||
2001-01-01 00:00:02.9 20010101000003 20010101000003 20010101000003 40020202000006 20010101000003 10005050500001 24 | ||
2001-01-01 23:59:59.9 20010102000000 20010102000000 20010102000000 40020204000000 20010102000000 10005051000000 18 | ||
9999-12-31 23:59:59.9 99991231000000 99991231000000 99991231000000 199982462000000 99991231000000 49995615500000 24 | ||
DROP DATABASE issue1173_test_db; |
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,38 @@ | ||
--source include/have_tianmu.inc | ||
|
||
--disable_warnings | ||
DROP DATABASE IF EXISTS issue1173_test_db; | ||
--enable_warnings | ||
CREATE DATABASE issue1173_test_db; | ||
USE issue1173_test_db; | ||
|
||
CREATE TABLE t1 (a TIME(1) NOT NULL)engine=tianmu; | ||
INSERT INTO t1 VALUES ('00:00:02.9'); | ||
INSERT INTO t1 VALUES ('00:00:02'); | ||
INSERT INTO t1 VALUES ('00:00:02.98'); | ||
INSERT INTO t1 VALUES ('00:00:02.5'); | ||
INSERT INTO t1 VALUES ('00:00:02.51'); | ||
INSERT INTO t1 VALUES ('00:00:02.49'); | ||
|
||
CREATE TABLE t1i (a TIME(1) NOT NULL)engine=innodb; | ||
INSERT INTO t1i VALUES ('00:00:02.9'); | ||
INSERT INTO t1i VALUES ('00:00:02'); | ||
INSERT INTO t1i VALUES ('00:00:02.98'); | ||
INSERT INTO t1i VALUES ('00:00:02.5'); | ||
INSERT INTO t1i VALUES ('00:00:02.51'); | ||
INSERT INTO t1i VALUES ('00:00:02.49'); | ||
|
||
select * from t1; | ||
|
||
select * from t1i; | ||
|
||
SELECT a, a & a, a | a, a^0, a<<1, a<<0, a>>1, bit_count(a) FROM t1; | ||
|
||
CREATE TABLE t2 (a DATETIME(1) NOT NULL); | ||
INSERT INTO t2 VALUES ('2001-01-01 00:00:02.9'); | ||
INSERT INTO t2 VALUES ('2001-01-01 23:59:59.9'); | ||
INSERT INTO t2 VALUES ('9999-12-31 23:59:59.9'); | ||
|
||
SELECT a, a & a, a | a, a^0, a<<1, a<<0, a>>1, bit_count(a) FROM t2; | ||
|
||
DROP DATABASE issue1173_test_db; |
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