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
857 stars 140 forks source link

crash: StoneDB crash: SUM #1953

Open ZhengLin-Li opened 11 months ago

ZhengLin-Li commented 11 months ago

Have you read the Contributing Guidelines on issues?

Please confirm if bug report does NOT exists already ?

Describe the problem

StoneDB V1.0.4 crash when running the following commands:

EXAMPLE 1:

image

EXAMPLE 2:

image

EXAMPLE 3:

image

(Have tried to reduce the statements as fewer as possible)

Expected behavior

EXAMPLE 1:

Return NULL as MySQL 5.7 does: image

EXAMPLE 2:

Return NULL as MySQL 5.7 does: image

EXAMPLE 3:

Return NULL as MySQL 5.7 does: image

How To Reproduce

EXAMPLE 1:

CREATE TABLE t0(c0 INT);
INSERT INTO t0(c0) VALUES (1);
ALTER TABLE t0 CHANGE COLUMN c0 c1 INT;
CREATE TABLE t1(c0 INT);

SELECT SUM(count1) FROM (SELECT CAST(t0.c1 AS UNSIGNED)  as count1 FROM t0, t1) as res;

EXAMPLE 2:

CREATE TABLE t0(c0 INT);
CREATE TABLE t1(c0 INT) ;
INSERT INTO t1(c0) VALUES (111);

SELECT SUM(count1) FROM (SELECT CAST(t1.c0 AS UNSIGNED)  as count1 FROM t1, t0) as res;

EXAMPLE 3:

CREATE TABLE t0(c1 INT );
CREATE TABLE t1(c0 INT );
INSERT INTO t0(c1) VALUES (1);

SELECT SUM(count1) FROM (SELECT CAST(t0.c1 AS UNSIGNED)  as count1 FROM t0, t1) as res;

Environment

Docker image V1.0.4

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

ZhengLin-Li commented 11 months ago

UPDATE: it seams that the CAST operation is not essential to reproduce this crash, but the SUM operation is essential. image