Inconsistent result for WEEKOFYEAR()
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Bug Report
Please answer these questions before submitting your issue. Thanks!
Is this the same bug as the #64386 and #64382?
### 1. Minimal reproduce step (Required)
CREATE TABLE t1307 ( c2 TEXT);
INSERT t1307 () VALUES ('4e0ZqL');
SELECT CONVERT(t1307.c2, DECIMAL(1, 1)) FROM t1307;
-- 0.9
SELECT WEEKOFYEAR(0.9) IS NULL;
-- 1
SELECT * FROM t1307 WHERE (((WEEKOFYEAR((CONVERT(t1307.c2, DECIMAL(1, 1))))) IS NULL));
-- empty set expected 1 rows
### 2. What did you expect to see? (Required)
mysql> SELECT * FROM t1307 WHERE (((WEEKOFYEAR(0.9)) IS NULL));
+--------+
| c2 |
+--------+
| 4e0ZqL |
+--------+
1 row in set, 1 warning (0.00 sec)
### 3. What did you see instead (Required)
mysql> SELECT * FROM t1307 WHERE (((WEEKOFYEAR((CONVERT(t1307.c2, DECIMAL(1, 1))))) IS NULL));
Empty set, 2 warnings (0.00 sec)
mysql> show warnings;
+---------+------+-------------------------------------------+
| Level | Code | Message |
+---------+------+-------------------------------------------+
| Warning | 1105 | Data truncated for column '%s' at row %d |
| Warning | 1690 | DECIMAL value is out of range in '(1, 1)' |
+---------+------+-------------------------------------------+
2 rows in set (0.00 sec)
### 4. What is your TiDB version? (Required)
Release Version: v8.5.0-20251010-ec6b882
Edition: Community
Git Commit Hash: https://github.com/pingcap/tidb/commit/ec6b882d188f77c199907ba26843a872b8c5fd6d
Git Branch: heads/refs/tags/v8.5.0-20251010-ec6b882
UTC Build Time: 2025-10-10 10:21:51
GoVersion: go1.23.3
Race Enabled: false
Check Table Before Drop: false
Store: unistore
Contributor guide
Research direction
Start by running the supplied CREATE, INSERT, CONVERT, and WEEKOFYEAR statements and compare the direct and converted expressions. Trace the WEEKOFYEAR and DECIMAL conversion entry points, then verify completion by reproducing the expected row and warning behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100