pingcap / tidb

TiDB is an open-source, cloud-native, distributed, MySQL-Compatible database for elastic scale and real-time analytics. Try AI-powered Chat2Query free at : https://www.pingcap.com/tidb-serverless/
https://pingcap.com
Apache License 2.0
36.94k stars 5.81k forks source link

Corrupt warnings and compatibility issues with FORMAT and CTE #56193

Open dveeden opened 2 hours ago

dveeden commented 2 hours ago

Bug Report

1. Minimal reproduce step (Required)

WITH RECURSIVE cte(n) AS (
  SELECT 1 n
  UNION ALL
  SELECT 100+n FROM cte WHERE n<1000
)
SELECT FORMAT(n+RAND(),3,'en_UK') FROM cte;

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

With MySQL 9.0.1:

mysql-9.0.1> WITH RECURSIVE cte(n) AS (SELECT 1 n UNION ALL SELECT 100+n FROM cte WHERE n<1000) SELECT FORMAT(n+RAND(),3,'en_UK') FROM cte;
+----------------------------+
| FORMAT(n+RAND(),3,'en_UK') |
+----------------------------+
| 1.207                      |
| 101.688                    |
| 201.819                    |
| 301.030                    |
| 401.691                    |
| 501.368                    |
| 601.767                    |
| 701.731                    |
| 801.355                    |
| 901.582                    |
| 1,001.845                  |
+----------------------------+
11 rows in set, 1 warning (0.00 sec)

Warning (Code 1649): Unknown locale: 'en_UK'
  1. Only one warning for the statement.
  2. Warning text is correct

3. What did you see instead (Required)

mysql-8.0.11-TiDB-v8.4.0-alpha-207-gfb9b8a194f> WITH RECURSIVE cte(n) AS (SELECT 1 n UNION ALL SELECT 100+n FROM cte WHERE n<1000) SELECT FORMAT(n+RAND(),3,'en_UK') FROM cte;
+----------------------------+
| FORMAT(n+RAND(),3,'en_UK') |
+----------------------------+
| 1.613                      |
| 101.927                    |
| 201.795                    |
| 301.193                    |
| 401.579                    |
| 501.318                    |
| 601.854                    |
| 701.313                    |
| 801.006                    |
| 901.092                    |
| 1,001.439                  |
+----------------------------+
11 rows in set, 11 warnings (0.00 sec)

Warning (Code 1649): Unknown locale: '
                                      .P��'
Warning (Code 1649): Unknown locale: 'en_UK'
Warning (Code 1649): Unknown locale: '
Warning (Code 1649): Unknown locale: '
                                      .P��'
Warning (Code 1649): Unknown locale: 'en_UK'
Warning (Code 1649): Unknown locale: '
Warning (Code 1649): Unknown locale: '
                                      .P��'
Warning (Code 1649): Unknown locale: 'en_UK'
Warning (Code 1649): Unknown locale: '
Warning (Code 1649): Unknown locale: '
                                      .P��'
Warning (Code 1649): Unknown locale: 'en_UK'
  1. Multiple warnings instead of one.
  2. Text is sometimes correct and sometimes corrupt

4. What is your TiDB version? (Required)

mysql-8.0.11-TiDB-v8.4.0-alpha-207-gfb9b8a194f> SELECT TIDB_VERSION()\G
*************************** 1. row ***************************
TIDB_VERSION(): Release Version: v8.4.0-alpha-207-gfb9b8a194f
Edition: Community
Git Commit Hash: fb9b8a194f8716beaee035cd0c285c30e29a9d64
Git Branch: master
UTC Build Time: 2024-09-20 09:07:51
GoVersion: go1.22.7
Race Enabled: false
Check Table Before Drop: false
Store: unistore
1 row in set (0.00 sec)

Also happens with v8.3.0

dveeden commented 2 hours ago

Found this while working on #56167 / #56168