Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong ERROR returned when POW value is out of range #18493

Open
zhangysh1995 opened this issue Jul 12, 2020 · 2 comments
Open

Wrong ERROR returned when POW value is out of range #18493

zhangysh1995 opened this issue Jul 12, 2020 · 2 comments
Assignees
Labels
component/expression severity/minor sig/execution SIG execution type/bug The issue is confirmed as a bug.

Comments

@zhangysh1995
Copy link

Bug Report

1. Minimal reproduce step (Required)

drop table if exists t2;

create  table t2 (col0 TINYINT NOT NULL, col1 TEXT, col2 SMALLINT UNIQUE);
insert into t2 values ('-128', 't', '-0');
insert into t2 values ('0', 'x', '32767');
insert into t2 values ('1', 't', '-32768');

SELECT `col2` FROM ( SELECT `col2` FROM t2 WHERE ( ATAN( `col2`, ( TAN( ( BINARY ( `col2` / '02:43:36' ) ) ) ) ) ) DIV ( ( CONVERT( ( POW( `col2`, `col2` ) ) USING latin1 ) ) NOT IN ( `col2`, `col2` ) )  HAVING DEGREES( ( - 3981378005 ) )) t;

drop table t2;

2. What did you expect to see? (Required)

mysql> SELECT `col2` FROM ( SELECT `col2` FROM t2 WHERE ( ATAN( `col2`, ( TAN( ( BINARY ( `col2` / '02:43:36' ) ) ) ) ) ) DIV ( ( CONVERT( ( POW( `col2`, `col2` ) ) USING latin1 ) ) NOT IN ( `col2`, `col2` ) )  HAVING DEGREES( ( - 3981378005 ) )) t;
ERROR 1690 (22003): DOUBLE value is out of range in 'pow(`test`.`t2`.`col2`,`test`.`t2`.`col2`)'

3. What did you see instead (Required)

mysql> SELECT `col2` FROM ( SELECT `col2` FROM t2 WHERE ( ATAN( `col2`, ( TAN( ( BINARY ( `col2` / '02:43:36' ) ) ) ) ) ) DIV ( ( CONVERT( ( POW( `col2`, `col2` ) ) USING latin1 ) ) NOT IN ( `col2`, `col2` ) )  HAVING DEGREES( ( - 3981378005 ) )) t;
ERROR 1105 (HY000): should ensure all columns have the same length
 

4. Affected version (Required)

commit a9177fe846bf2638261f64514ab4ebd0155cc60c (HEAD -> master, origin/master, origin/HEAD)
Author: Boqin Qin <bobbqqin@bupt.edu.cn>
Date:   Mon Jul 6 19:28:12 2020 +0800

5. Root Cause Analysis

@zhangysh1995 zhangysh1995 added the type/bug The issue is confirmed as a bug. label Jul 12, 2020
@ghost
Copy link

ghost commented Jul 12, 2020

Thank you for the bug report. Confirming that I can reproduce this against master (I've simplified the expression to trigger it slightly):

DROP TABLE IF EXISTS t2;
CREATE TABLE t2 (col0 TINYINT NOT NULL, col1 TEXT, col2 SMALLINT UNIQUE);
INSERT INTO t2 VALUES ('-128', 't', '-0');
INSERT INTO t2 VALUES ('0', 'x', '32767');
INSERT INTO t2 VALUES ('1', 't', '-32768');

SELECT
 `col2`
FROM t2
WHERE
 col2 DIV(POW(`col2`, `col2`));

..

tidb> SELECT
    ->  `col2`
    -> FROM t2
    -> WHERE
    ->  col2 DIV(POW(`col2`, `col2`));
ERROR 1105 (HY000): should ensure all columns have the same length
tidb> SELECT tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v4.0.0-beta.2-745-g2b0b34b88
Edition: Community
Git Commit Hash: 2b0b34b88e43ad20f4e5ab1a0b5daf7ae6ff6046
Git Branch: master
UTC Build Time: 2020-07-09 10:12:32
GoVersion: go1.13
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
1 row in set (0.00 sec)

@XuHuaiyu
Copy link
Contributor

Tested in master ce5ce53
The bug has been fixed

tidb> SELECT
    ->  `col2`
    -> FROM t2
    -> WHERE
    ->  col2 DIV(POW(`col2`, `col2`));
ERROR 1690 (22003): DOUBLE value is out of range in 'pow(32767, 32767)'

The error message is not compatible with MySQL now. According to the rule Error message or error code does not match MySQL, I'll change the label to severity/minor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/expression severity/minor sig/execution SIG execution type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

4 participants