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

"Data truncated for column '%s' at row %d" #52672

Closed
aytrack opened this issue Apr 17, 2024 · 4 comments · Fixed by #53045
Closed

"Data truncated for column '%s' at row %d" #52672

aytrack opened this issue Apr 17, 2024 · 4 comments · Fixed by #53045
Labels
affects-5.3 This bug affects 5.3.x versions. 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. fuzz/comp Issues found by comp fuzz test. severity/major sig/execution SIG execution type/bug The issue is confirmed as a bug. type/regression

Comments

@aytrack
Copy link
Contributor

aytrack commented Apr 17, 2024

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

drop table if exists PK_PRECISION10063;
CREATE TABLE `PK_PRECISION10063` (
  `COL1` decimal(55,0) NOT NULL,
  `COL2` varchar(20) DEFAULT NULL,
  `COL4` datetime DEFAULT NULL,
  `COL3` bigint(20) DEFAULT NULL,
  `COL5` float DEFAULT NULL,
  PRIMARY KEY (`COL1`) /*T![clustered_index] CLUSTERED */
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
insert into `PK_PRECISION10063` (`COL1`) values (8320145330174776428);

select col1, tan(col1) from PK_PRECISION10063 where tan(col1) < tan(9021874879467600608071521900001091070693729763119983979);

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

[16:55:05]MySQL root:test> select col1, tan(col1) from PK_PRECISION10063 where tan(col1) < tan(9021874879467600608071521900001091070693729763119983979);
+---------------------+---------------------+
| col1                | tan(col1)           |
+---------------------+---------------------+
| 8320145330174776428 | 0.06084016242886609 |
+---------------------+---------------------+

3. What did you see instead (Required)

[16:54:19]TiDB root:test> select col1, tan(col1) from PK_PRECISION10063 where tan(col1) < tan(9021874879467600608071521900001091070693729763119983979);
(1265, "Data truncated for column '%s' at row %d")

4. What is your TiDB version? (Required)

v8.1.0

@aytrack aytrack added type/bug The issue is confirmed as a bug. sig/execution SIG execution type/regression severity/major labels Apr 17, 2024
@aytrack aytrack added affects-8.1 This bug affects the 8.1.x(LTS) versions. and removed may-affects-8.1 labels Apr 17, 2024
@aytrack
Copy link
Contributor Author

aytrack commented Apr 18, 2024

It's a bit strange, I can execute it fine on one clustered environment, but not on another!

[10:03:11]TiDB root:coms> select col1, tan(col1) from PK_PRECISION10063 where tan(col1) < tan(9021874879467600608071521900001091070693729763119983979);
+---------------------+---------------------+
| col1                | tan(col1)           |
+---------------------+---------------------+
| 8320145330174776428 | 0.06084016242886609 |
+---------------------+---------------------+
1 row in set
Time: 0.064s
[10:03:18]TiDB root:coms> explain select col1, tan(col1) from PK_PRECISION10063 where tan(col1) < tan(9021874879467600608071521900001091070693729763119983979);
+-----------------------+---------+-----------+-------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
| id                    | estRows | task      | access object           | operator info                                                                                                                                |
+-----------------------+---------+-----------+-------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
| Projection_4          | 0.80    | root      |                         | coms.pk_precision10063.col1, tan(cast(coms.pk_precision10063.col1, double BINARY))->Column#6                                                 |
| └─Selection_5         | 0.80    | root      |                         | lt(tan(cast(coms.pk_precision10063.col1, double BINARY)), tan(cast(9021874879467600608071521900001091070693729763119983979, double BINARY))) |
|   └─TableReader_7     | 1.00    | root      |                         | data:TableFullScan_6                                                                                                                         |
|     └─TableFullScan_6 | 1.00    | cop[tikv] | table:PK_PRECISION10063 | keep order:false, stats:pseudo                                                                                                               |
+-----------------------+---------+-----------+-------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
4 rows in set
Time: 0.046s
[10:03:29]TiDB root:coms> select tidb_version();
+-----------------------------------------------------------+
| tidb_version()                                            |
+-----------------------------------------------------------+
| Release Version: v8.0.0                                   |
| Edition: Community                                        |
| Git Commit Hash: 8ba1fa452b1ccdbfb85879ea94b9254aabba2916 |
| 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                                               |
+-----------------------------------------------------------+
1 row in set
Time: 0.058s

another same version cluster

mysql> select col1, tan(col1) from PK_PRECISION10063 where tan(col1) < tan(9021874879467600608071521900001091070693729763119983979);
ERROR 1265 (01000): Data truncated for column '%s' at row %d
mysql> explain select col1, tan(col1) from PK_PRECISION10063 where tan(col1) < tan(9021874879467600608071521900001091070693729763119983979);
+---------------------------+----------+-----------+-------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
| id                        | estRows  | task      | access object           | operator info                                                                                                                                |
+---------------------------+----------+-----------+-------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
| Projection_4              | 8000.00  | root      |                         | test.pk_precision10063.col1, tan(cast(test.pk_precision10063.col1, double BINARY))->Column#6                                                 |
| └─Selection_5             | 8000.00  | root      |                         | lt(tan(cast(test.pk_precision10063.col1, double BINARY)), tan(cast(9021874879467600608071521900001091070693729763119983979, double BINARY))) |
|   └─TableReader_7         | 10000.00 | root      |                         | data:TableFullScan_6                                                                                                                         |
|     └─TableFullScan_6     | 10000.00 | cop[tikv] | table:PK_PRECISION10063 | keep order:false, stats:pseudo                                                                                                               |
+---------------------------+----------+-----------+-------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
4 rows in set, 1 warning (0.00 sec)

mysql> select tidb_version();
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()                                                                                                                                                                                                                               |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v8.0.0
Edition: Community
Git Commit Hash: 8ba1fa452b1ccdbfb85879ea94b9254aabba2916
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 |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)

@yibin87
Copy link
Contributor

yibin87 commented Apr 28, 2024

It seems tidb doesn't try to handle truncate error inside builtinCastDecimalAsRealSig::evalReal:

val, isNull, err := b.args[0].EvalDecimal(ctx, row)

@windtalker windtalker added affects-5.3 This bug affects 5.3.x versions. 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. and removed may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 may-affects-6.5 may-affects-7.1 may-affects-7.5 labels May 7, 2024
@VivekGupta137
Copy link

Facing this issue as well.

@apollodafoni
Copy link

/label fuzz/comp

@ti-chi-bot ti-chi-bot bot added the fuzz/comp Issues found by comp fuzz test. label Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-5.3 This bug affects 5.3.x versions. 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. fuzz/comp Issues found by comp fuzz test. severity/major sig/execution SIG execution type/bug The issue is confirmed as a bug. type/regression
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants