stoneatom / stonedb

StoneDB is an Open-Source MySQL HTAP and MySQL-Native DataBase for OLTP, Real-Time Analytics, a counterpart of MySQLHeatWave. (https://stonedb.io)
https://stonedb.io/
GNU General Public License v2.0
865 stars 141 forks source link

bug:insert into t1 values (" "),The query result becomes null #221

Closed shangyanwen closed 2 years ago

shangyanwen commented 2 years ago

Describe the problem

1、create table t1 (b char(0)) ENGINE=STONEDB;
2、insert into t1 values (" "),(null);
3、select * from t1; 
+------+
| b    |
+------+
| NULL |
| NULL |
+------+

Expected behavior

select * from t1; 
+------+
| b    |
+------+
|  |                     #注此处应是插入的空格
| NULL |
+------+

How To Reproduce

1、create table t1 (b char(0)) ENGINE=STONEDB;
2、insert into t1 values (" "),(null);
3、select * from t1; 

Environment

  1. StoneDB for mysql5.7
  2. Ubuntu 20.04.4

Are you interested in submitting a PR to solve the problem?

lylth commented 2 years ago

Oracle treats NULL and spaces as the same, and the same is true for the stonedb of the column-stored database, so this is not a problem


mysql> select * from t2;
+------+
| b    |
+------+
|      |
|      |
|      |
|      |
+------+
4 rows in set (0.00 sec)

mysql> insert into t2 values( );
Query OK, 1 row affected (0.00 sec)

mysql> select * from t2;
+------+
| b    |
+------+
| NULL |
| NULL |
| NULL |
| NULL |
| NULL |
+------+
5 rows in set (0.00 sec)

mysql> insert into t2 values(' ');
Query OK, 1 row affected (0.00 sec)

mysql> select * from t2;
+------+
| b    |
+------+
|      |
|      |
|      |
|      |
|      |
|      |
+------+
6 rows in set (0.00 sec)

mysql> insert into t2 values(NULL);
Query OK, 1 row affected (0.00 sec)

mysql> select * from t2;
+------+
| b    |
+------+
| NULL |
| NULL |
| NULL |
| NULL |
| NULL |
| NULL |
| NULL |
+------+
7 rows in set (0.00 sec)