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
862 stars 139 forks source link

bug: select * from t1 order by c1,(select c1 from t2 limit 2); Result set error #1326

Open shangyanwen opened 1 year ago

shangyanwen commented 1 year ago

Have you read the Contributing Guidelines on issues?

Please confirm if bug report does NOT exists already ?

Describe the problem

#Result set error
mysql> select * from t1 order by c1,(select c1 from t2 limit 2);
+----+------+------+
| c1 | c2   | c3   |
+----+------+------+
|  1 |    1 |    1 |
|  2 |    2 |    2 |
|  3 |    3 |    3 |
+----+------+------+
3 rows in set (0.00 sec)

Expected behavior

mysql> select * from t1 order by c1,(select c1 from t2 limit 2);
ERROR 1242 (21000): Subquery returns more than 1 row

How To Reproduce

CREATE TABLE t1 (
  c1 int primary key,
  c2 int, c3 int
)engine=tianmu;

INSERT INTO t1 VALUES (1,1,1);
INSERT INTO t1 VALUES (2,2,2);
INSERT INTO t1 VALUES (3,3,3);

create table t2 (
  c1 int primary key,
  c2 int, c3 int
)engine=tianmu;

INSERT INTO t2 VALUES (1,1,1);
INSERT INTO t2 VALUES (2,2,2);
INSERT INTO t2 VALUES (3,3,3);

----error 1242
select * from t1 order by c1,(select c1 from t2);
----error 1242
select * from t1 order by c1,(select c1 from t2 limit 2);
----error 1242
select * from t1 order by c1,(select c1 from t5 order by c1,(select c1 from t3));

Environment

5.7.36-StoneDB-v1.0.2

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

wisehead commented 1 year ago

@shangyanwen please use the latest build to double check.