Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
N/A
-
None
Description
MariaDB [test]> SELECT @@default_week_format; |
+-----------------------+ |
| @@default_week_format |
|
+-----------------------+ |
| 0 |
|
+-----------------------+ |
1 row in set (0.00 sec) |
|
MariaDB [test]> SELECT WEEK('2000-01-01'); |
+--------------------+ |
| WEEK('2000-01-01') | |
+--------------------+ |
| 0 |
|
+--------------------+ |
1 row in set (0.00 sec) |
|
MariaDB [test]> SELECT WEEK('2000-01-01',2); |
+----------------------+ |
| WEEK('2000-01-01',2) | |
+----------------------+ |
| 52 |
|
+----------------------+ |
1 row in set (0.00 sec) |
MariaDB [test]> SET STATEMENT default_week_format = 2 FOR SELECT WEEK('2000-01-01'); |
+--------------------+ |
| WEEK('2000-01-01') | |
+--------------------+ |
| 0 |
|
+--------------------+ |
1 row in set (0.01 sec) |
|
MariaDB [test]> SET default_week_format = 2; |
Query OK, 0 rows affected (0.00 sec) |
|
MariaDB [test]> SELECT WEEK('2000-01-01'); |
+--------------------+ |
| WEEK('2000-01-01') | |
+--------------------+ |
| 52 |
|
+--------------------+ |
1 row in set (0.00 sec) |
All the same in Percona server.
The problem is that week format put as an constant argument during parsing:
Item *i1= new (thd->mem_root) Item_int((char*) "0",
thd->variables.default_week_format,
1);
if (i1 == NULL)
MYSQL_YYABORT;
$$= new (thd->mem_root) Item_func_week($3, i1);
if ($$ == NULL)
MYSQL_YYABORT;