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

insert truncated decimal value with sql_mode='' should succeed #49369

Closed
tiancaiamao opened this issue Dec 12, 2023 · 3 comments · Fixed by #49383
Closed

insert truncated decimal value with sql_mode='' should succeed #49369

tiancaiamao opened this issue Dec 12, 2023 · 3 comments · Fixed by #49383
Assignees
Labels
affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. affects-5.4 This bug affects the 5.4.x(LTS) versions. affects-6.0 affects-6.1 This bug affects the 6.1.x(LTS) versions. affects-6.2 affects-6.3 affects-6.4 affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-6.6 affects-7.0 affects-7.1 This bug affects the 7.1.x(LTS) versions. affects-7.2 affects-7.3 affects-7.4 affects-7.5 This bug affects the 7.5.x(LTS) versions. fixes-7.1.3 report/customer Customers have encountered this bug. severity/minor sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug. type/compatibility

Comments

@tiancaiamao
Copy link
Contributor

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

mysql> set sql_mode = '';
Query OK, 0 rows affected (0.00 sec)

mysql> show create table t;
+-------+-----------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                      |
+-------+-----------------------------------------------------------------------------------------------------------------------------------+
| t     | CREATE TABLE `t` (
  `x` varchar(32) COLLATE utf8mb4_bin DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
+-------+-----------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql>  insert into t   select round(cast('88888899999999999888888888888888888888888888888888888.11111111111111111111' as decimal(18,12)) * cast('88888899999999999888888888888888888888888888888888888.11111111111111111111' as decimal(42,18)) );
Query OK, 1 row affected, 2 warnings (0.01 sec)
Records: 1  Duplicates: 0  Warnings: 2

mysql> show warnings;
+---------+------+-------------------------------------------------+
| Level   | Code | Message                                         |
+---------+------+-------------------------------------------------+
| Warning | 1264 | Out of range value for column '(null)' at row 1 |
| Warning | 1264 | Out of range value for column '(null)' at row 1 |
+---------+------+-------------------------------------------------+
2 rows in set (0.00 sec)

mysql> select * from t;
+--------------------------------+
| x                              |
+--------------------------------+
| 999999999999999999000000000000 |
+--------------------------------+
5 rows in set (0.00 sec)

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

This SQL should succeed with warning.

 insert into t   select ...

3. What did you see instead (Required)

mysql> set @@sql_mode ='';
Query OK, 0 rows affected (0.00 sec)

mysql>  show create table t;
+-------+---------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                  |
+-------+---------------------------------------------------------------------------------------------------------------+
| t     | CREATE TABLE `t` (
  `x` varchar(32) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
+-------+---------------------------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)

mysql> insert into t   select round(cast('88888899999999999888888888888888888888888888888888888.11111111111111111111' as decimal(18,12)) * cast('88888899999999999888888888888888888888888888888888888.11111111111111111111' as decimal(42,18)) );
ERROR 1690 (22003): DECIMAL value is out of range in '(18, 12)'
mysql> select * from t;
Empty set (0.00 sec)

4. What is your TiDB version? (Required)

mysql> select tidb_version();
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()                                                                                                                                                                                                                                                                      |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v7.6.0-alpha-387-gc3982c4e74-dirty
Edition: Community
Git Commit Hash: c3982c4e74116dade00d6eb12bef81ce38d77eaa
Git Branch: resultset-close
UTC Build Time: 2023-12-08 01:47:08
GoVersion: go1.21.0
Race Enabled: false
Check Table Before Drop: false
Store: tikv |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
@tiancaiamao tiancaiamao added type/bug The issue is confirmed as a bug. compatibility-mysql8 This is a compatibility issue with MySQL 8.0(but NOT 5.7) sig/sql-infra SIG: SQL Infra labels Dec 12, 2023
@tiancaiamao tiancaiamao self-assigned this Dec 12, 2023
@tiancaiamao tiancaiamao added affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. affects-6.0 affects-6.1 This bug affects the 6.1.x(LTS) versions. affects-6.2 affects-6.3 affects-6.4 affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-6.6 affects-7.0 affects-7.1 This bug affects the 7.1.x(LTS) versions. affects-7.2 affects-7.3 affects-7.4 affects-7.5 This bug affects the 7.5.x(LTS) versions. labels Dec 12, 2023
@tiancaiamao tiancaiamao changed the title insert truncated decimal with sql_mode='' should succeed insert truncated decimal value with sql_mode='' should succeed Dec 12, 2023
@ti-chi-bot ti-chi-bot bot added the may-affects-5.4 This bug maybe affects 5.4.x versions. label Dec 13, 2023
@bb7133
Copy link
Member

bb7133 commented Dec 13, 2023

@jebter I don't think this is a major bug, it is in an edge case for a specific sql mode.

@bb7133
Copy link
Member

bb7133 commented Dec 13, 2023

@tiancaiamao It's not about MySQL 8 compatibility: behavior is the same for MySQL 5.7 so I will remove 'compatibility-mysql8'.

@bb7133 bb7133 added type/compatibility and removed compatibility-mysql8 This is a compatibility issue with MySQL 8.0(but NOT 5.7) labels Dec 13, 2023
@tiancaiamao tiancaiamao removed the may-affects-5.4 This bug maybe affects 5.4.x versions. label Dec 14, 2023
@tiancaiamao tiancaiamao added the affects-5.4 This bug affects the 5.4.x(LTS) versions. label Dec 14, 2023
@seiya-annie
Copy link

/found customer

@ti-chi-bot ti-chi-bot bot added the report/customer Customers have encountered this bug. label Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. affects-5.4 This bug affects the 5.4.x(LTS) versions. affects-6.0 affects-6.1 This bug affects the 6.1.x(LTS) versions. affects-6.2 affects-6.3 affects-6.4 affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-6.6 affects-7.0 affects-7.1 This bug affects the 7.1.x(LTS) versions. affects-7.2 affects-7.3 affects-7.4 affects-7.5 This bug affects the 7.5.x(LTS) versions. fixes-7.1.3 report/customer Customers have encountered this bug. severity/minor sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug. type/compatibility
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants