matrixone icon indicating copy to clipboard operation
matrixone copied to clipboard

[Bug]: panic info occurs when I use LIMIT 'a'

Open goodMan-code opened this issue 3 years ago • 1 comments

Is there an existing issue for the same bug?

  • [X] I have checked the existing issues.

Environment

- Version or commit-id (e.g. v0.1.0 or 8b23a93):
- Hardware parameters:
- OS type:
- Others:

Actual Behavior

Table Structure : CREATE TABLE t1( id INT, str blob, PRIMARY KEY (id) );

DML : INSERT INTO t1 VALUES(1, '123456'), (2, 'shanghai'), (3, BIN(123456)), (4, HEX(123456)), (6, NULL),(5,'china');

The SQL stmt is : SELECT MAX(id), MIN(str) FROM t1 LIMIT 'a';

Result on MO is : ERROR 20101 (HY000): internal error: panic interface conversion: interface {} is []types.Varlena, not []int64: runtime.panicdottypeE /usr/local/go/src/runtime/iface.go:262 github.com/matrixorigin/matrixone/pkg/sql/compile.constructLimit /home/mo/matrixone/pkg/sql/compile/operator.go:514 github.com/matrixorigin/matrixone/pkg/sql/compile.(*Compile).compileLimit /home/mo/matrixone/pkg/sql/compile/compile.go:828 github.com/matrixorigin/matrixone/pkg/sql/compile.(*Compile).compileSort /home/mo/matrixone/pkg/sql/compile/compile

Expected Behavior

No response

Steps to Reproduce

No response

Additional information

No response

goodMan-code avatar Oct 09 '22 08:10 goodMan-code

the non-numeric value for LIMIT should be treated as a SQL syntax error. but it passed into compiler and the compiler tried to cast it into numeric so we got a panic.

dongdongyang33 avatar Oct 11 '22 07:10 dongdongyang33

I will add a error check for that.

m-schen avatar Oct 19 '22 12:10 m-schen

Attention : SELECT MAX(id), MIN(str) FROM t1 LIMIT 'a'; This scene has been fixed, thx.

goodMan-code avatar Nov 01 '22 09:11 goodMan-code

But another problem has occured, execute this SQL stmt, DDL and DML as usual, : SELECT MAX(id), MIN(str) FROM t1 LIMIT NULL; on my machine, this stmt got the result is : ERROR 20101 (HY000): internal error: panic interface conversion: interface {} is nil, not []int64: runtime.panicdottypeE /usr/local/go/src/runtime/iface.go:262 github.com/matrixorigin/matrixone/pkg/sql/compile.constructLimit /home/zxg/matrixone/pkg/sql/compile/operator.go:574 github.com/matrixorigin/matrixone/pkg/sql/compile.(*Compile).compileLimit /home/zxg/matrixone/pkg/sql/compile/compile.go:923 github.com/matrixorigin/matrixone/pkg/sql/compile.(*Compile).compileSort /home/zxg/matrixone/pkg/sql/compile/compile.go:840 g

at this time, MO commit id is : commit ccfcd648ea670d1bbb62c6cf8967e16fb7cc2a4d fix it pls.

goodMan-code avatar Nov 01 '22 09:11 goodMan-code

I have Recheck it, can be closed on commit 45c43c065b169c8dc00c9f8ed6964dac3e0a6ef8

goodMan-code avatar Nov 07 '22 03:11 goodMan-code