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

Unexpected SQL exception returned #52472

Closed
sayJason opened this issue Apr 10, 2024 · 6 comments · Fixed by #52542
Closed

Unexpected SQL exception returned #52472

sayJason opened this issue Apr 10, 2024 · 6 comments · Fixed by #52542
Assignees
Labels
affects-5.4 This bug affects the 5.4.x(LTS) versions. affects-6.1 This bug affects the 6.1.x(LTS) versions. affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-7.1 This bug affects the 7.1.x(LTS) versions. affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-8.1 This bug affects the 8.1.x(LTS) versions. severity/major sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@sayJason
Copy link

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

I run the following statement through JDBC with version 8.3.0

CREATE TABLE t1 ( c1 int, c2 int);
CREATE TABLE t2 ( c1 int unsigned);
INSERT INTO t1 (c1,c2) VALUES (8,4);
INSERT INTO t2 (c1) VALUES (2454396638);
SELECT ca4 AS ca1 FROM (SELECT c2 AS ca4 FROM t1) AS ta2 CROSS JOIN (SELECT c1 FROM t2) AS ta3 UNION ALL SELECT c1 AS ca13 FROM t2; 

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

The JDBC should return {2454396638, 4}

3. What did you see instead (Required)

A SQLException is returned.

java.sql.SQLException: Out of range value for column 'ca1' : value 2454396638 is not in class java.lang.Integer range
	at org.mariadb.jdbc.internal.com.read.resultset.rowprotocol.RowProtocol.rangeCheck(RowProtocol.java:283)
	at org.mariadb.jdbc.internal.com.read.resultset.rowprotocol.TextRowProtocol.getInternalInt(TextRowProtocol.java:255)
	at org.mariadb.jdbc.internal.com.read.resultset.rowprotocol.TextRowProtocol.getInternalObject(TextRowProtocol.java:900)
	at org.mariadb.jdbc.internal.com.read.resultset.SelectResultSet.getObject(SelectResultSet.java:1159)
	in JdbcHelperImpl.getObject(JdbcHelperImpl.java:353)

4. What is your TiDB version? (Required)

Release Version: v8.0.0
Edition: Community
Git Commit Hash: 8ba1fa4
Git Branch: HEAD
UTC Build Time: 2024-03-28 14:22:15
GoVersion: go1.21.4
Race Enabled: false
Check Table Before Drop: false
Store: tikv

@sayJason sayJason added the type/bug The issue is confirmed as a bug. label Apr 10, 2024
@sayJason
Copy link
Author

Moreover, I can reproduce it with the client like DataGrip with JDBC version 8.2.0.

@aytrack
Copy link
Contributor

aytrack commented Apr 10, 2024

simple reproduce is select c2 from t1 union select c1 from t2;. It's about int uninion int unsigned
for tidb

mysql> select c2 from t1 union select c1 from t2;
Field   1:  `c2`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       LONG
Collation:  binary (63)
Length:     11
Max_length: 10
Decimals:   0
Flags:      BINARY NUM


+------------+
| c2         |
+------------+
|          4 |
| 2454396638 |
+------------+
2 rows in set (0.00 sec)

+------------------------------+---------+-----------+---------------+-------------------------------------------------------+
| id                           | estRows | task      | access object | operator info                                         |
+------------------------------+---------+-----------+---------------+-------------------------------------------------------+
| HashAgg_9                    | 2.00    | root      |               | group by:Column#6, funcs:firstrow(Column#6)->Column#6 |
| └─Union_10                   | 2.00    | root      |               |                                                       |
|   ├─TableReader_13           | 1.00    | root      |               | data:TableFullScan_12                                 |
|   │ └─TableFullScan_12       | 1.00    | cop[tikv] | table:t1      | keep order:false, stats:pseudo                        |
|   └─Projection_14            | 1.00    | root      |               | cast(test.t2.c1, int(11) BINARY)->Column#6            |
|     └─TableReader_16         | 1.00    | root      |               | data:TableFullScan_15                                 |
|       └─TableFullScan_15     | 1.00    | cop[tikv] | table:t2      | keep order:false, stats:pseudo                        |
+------------------------------+---------+-----------+---------------+-------------------------------------------------------+
7 rows in set (0.01 sec)

for mysql

mysql> select c2 from t1 union select c1 from t2;
Field   1:  `c2`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       LONGLONG
Collation:  binary (63)
Length:     11
Max_length: 10
Decimals:   0
Flags:      NUM


+------------+
| c2         |
+------------+
|          4 |
| 2454396638 |
+------------+
2 rows in set (0.00 sec)

@aytrack
Copy link
Contributor

aytrack commented Apr 11, 2024

for mysql , it return the bigint type
img_v3_029r_d3f60e86-78db-41c9-b195-f39f826af99g

for tidb, it return the int type and wrong result
img_v3_029r_35a774c7-b229-4d51-bb91-2f54f20d60cg
img_v3_029r_32f333e6-2057-441d-b65a-851b99d3ed8g

@YangKeao YangKeao self-assigned this Apr 12, 2024
@YangKeao YangKeao added affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-7.1 This bug affects the 7.1.x(LTS) versions. affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-8.1 This bug affects the 8.1.x(LTS) versions. and removed may-affects-8.1 labels Apr 12, 2024
@YangKeao YangKeao added affects-5.4 This bug affects the 5.4.x(LTS) versions. affects-6.1 This bug affects the 6.1.x(LTS) versions. and removed may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 labels Apr 12, 2024
@spihiker
Copy link

As versions are released, there are more and more problems. Can you put some effort into making the 6.5 version more stable?

@YangKeao
Copy link
Member

As versions are released, there are more and more problems. Can you put some effort into making the 6.5 version more stable?

Let's focus on concrete issues. Did you face any issue while using 6.5 and shows that the version 6.5 is unstable? If so, feel free to open a new issue and we'll try to locate and fix it 🍻.

Besides, I believe we are continuously working on making every (not EOL) versions more stable. For example, the fix of this issue will also be back-ported to 6.5 so that the next version of 6.5 will include the fix.

@spihiker
Copy link

Please deal with existing issues first. I encountered the non-functional bug mentioned by someone in 6.5.3 before, and I still encounter it in 6.5.7. It was not until 6.5.8 that it was found to be resolved. I just hope that a big version is stable enough, including current functional modules, sql standards, compatibility, etc. Like mysql-5.6, mysql-5.7. I also hope that tidb will develop better and better and become an eye-catching database product at home and abroad.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-5.4 This bug affects the 5.4.x(LTS) versions. affects-6.1 This bug affects the 6.1.x(LTS) versions. affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-7.1 This bug affects the 7.1.x(LTS) versions. affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-8.1 This bug affects the 8.1.x(LTS) versions. severity/major sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants