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

Import into ... from select does not comply with the current SQL mode #58443

Closed
gengliqi opened this issue Dec 20, 2024 · 2 comments · Fixed by #58606
Closed

Import into ... from select does not comply with the current SQL mode #58443

gengliqi opened this issue Dec 20, 2024 · 2 comments · Fixed by #58606
Labels
affects-8.1 This bug affects the 8.1.x(LTS) versions. affects-8.5 This bug affects the 8.5.x(LTS) versions. component/ddl This issue is related to DDL of TiDB. severity/major type/bug The issue is confirmed as a bug.

Comments

@gengliqi
Copy link
Contributor

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

mysql> create table t(a double);
Query OK, 0 rows affected (0.08 sec)

mysql> create table s(x varchar(20));
Query OK, 0 rows affected (0.08 sec)

mysql> insert into s values('1e309abc');
Query OK, 1 row affected (0.01 sec)

mysql> alter table s set tiflash replica 1;
Query OK, 0 rows affected (0.11 sec)

mysql> set tidb_enforce_mpp=1;
Query OK, 0 rows affected (0.00 sec)

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

mysql> insert into t select cast(x as double) from s;
Query OK, 1 row affected (0.09 sec)
Records: 1  Duplicates: 0  Warnings: 0

mysql> truncate t;
Query OK, 0 rows affected (0.08 sec)

mysql> import into t from select cast(x as double) from s;
ERROR 1105 (HY000): other error for mpp stream: Code: 0, e.displayText() = DB::TiFlashException: Overflow error: Truncated incorrect DOUBLE value, e.what() = DB::TiFlashException,
mysql> explain import into t from select cast(x as double) from s;
+------------------------------+----------+--------------+---------------+-----------------------------------------+
| id                           | estRows  | task         | access object | operator info                           |
+------------------------------+----------+--------------+---------------+-----------------------------------------+
| ImportInto_2                 | N/A      | root         |               | N/A                                     |
| └─TableReader_14             | 10000.00 | root         |               | MppVersion: 2, data:ExchangeSender_13   |
|   └─ExchangeSender_13        | 10000.00 | mpp[tiflash] |               | ExchangeType: PassThrough               |
|     └─Projection_6           | 10000.00 | mpp[tiflash] |               | cast(test.s.x, double BINARY)->Column#4 |
|       └─TableFullScan_12     | 10000.00 | mpp[tiflash] | table:s       | keep order:false, stats:pseudo          |
+------------------------------+----------+--------------+---------------+-----------------------------------------+
5 rows in set (0.00 sec)

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

The sql import into ... from select should use non-strict sql mode and run successfully.

3. What did you see instead (Required)

Run failed

4. What is your TiDB version? (Required)

v8.1.1

@gengliqi gengliqi added the type/bug The issue is confirmed as a bug. label Dec 20, 2024
@gengliqi gengliqi changed the title Import into ... from select does not respect sql_mode in current session Import into ... from select does not comply with the current SQL mode Dec 20, 2024
@jebter jebter added severity/major component/ddl This issue is related to DDL of TiDB. labels Dec 24, 2024
@D3Hunter
Copy link
Contributor

D3Hunter commented Dec 30, 2024

there are some difference in MPP flags, but the flag for import into(0b110000001) in DAGRequest already contains FlagIgnoreTruncate uint64 = 1.

if we run import into with TiKV(without run the tiflash replica statement), it works, it seems tiflash doesn't honor FlagIgnoreTruncate as tikv does. created a tiflash issue pingcap/tiflash#9752

@D3Hunter D3Hunter added affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-8.1 This bug affects the 8.1.x(LTS) versions. affects-8.5 This bug affects the 8.5.x(LTS) versions. and removed may-affects-6.1 may-affects-6.5 may-affects-7.1 may-affects-7.5 may-affects-8.1 may-affects-8.5 affects-7.5 This bug affects the 7.5.x(LTS) versions. labels Dec 30, 2024
@windtalker
Copy link
Contributor

The root cause is TiFlash's error handling logic is the same earlier version of TiDB, which treat overflow and truncate as different error, but after #49122, there is actually no overflow error, the OVERFLOW_AS_WARNING flag is useless, but TiFlash still use this to handle the overflow error.

@D3Hunter D3Hunter removed the may-affects-5.4 This bug maybe affects 5.4.x versions. label Dec 30, 2024
@ti-chi-bot ti-chi-bot bot closed this as completed in 284a3ee Dec 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-8.1 This bug affects the 8.1.x(LTS) versions. affects-8.5 This bug affects the 8.5.x(LTS) versions. component/ddl This issue is related to DDL of TiDB. severity/major type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants