Bug #116307 handling of fsp > 255 is incorrect

Submitted: 7 Oct 2024 5:54 Modified: 14 Jul 14:43
Reporter: Daniël van Eeden Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Errors Severity:S2 (Serious)
Version:9.0.1 OS:Any
Assigned to: CPU Architecture:Any
Tags: fsp

[7 Oct 2024 5:54] Daniël van Eeden
Description:
The fsp as used in `NOW(fsp)` should be between 0 and 6.

For fsp values between 7 and 255 the correct error is shown.

For fsp values between 256 and 262 the values is incorrectly accepted and handled like values between 0 and 6.

For fsp values of 263 and up the error message contains an incorrect precision number.

How to repeat:
sql> SELECT NOW(255);
ERROR: 1426 (42000): Too-big precision 255 specified for 'now'. Maximum is 6.

sql> SELECT NOW(256);
+---------------------+
| NOW(256)            |
+---------------------+
| 2024-10-07 07:49:23 |
+---------------------+
1 row in set (0.0004 sec)

sql> SELECT NOW(262);
+----------------------------+
| NOW(262)                   |
+----------------------------+
| 2024-10-07 07:49:42.668660 |
+----------------------------+
1 row in set (0.0004 sec)

sql> SELECT NOW(263);
ERROR: 1426 (42000): Too-big precision 7 specified for 'now'. Maximum is 6.

sql> SELECT NOW(999);
ERROR: 1426 (42000): Too-big precision 231 specified for 'now'. Maximum is 6.

sql> SELECT VERSION();
+-----------+
| VERSION() |
+-----------+
| 9.0.1     |
+-----------+
1 row in set (0.0005 sec)

Suggested fix:
- Make sure to reject incorrect fsp numbers
- Make sure to use the correct precision for error messages for fsp numbers of >262
[7 Oct 2024 6:06] Daniël van Eeden
$ (for n in {1..1000}; do echo -en "$n: "; echo "SELECT NOW($n)" | mysql -Nu root 2>&1; done) | grep -v 'Too-big precision'
1: 2024-10-07 08:05:57.1
2: 2024-10-07 08:05:57.17
3: 2024-10-07 08:05:57.181
4: 2024-10-07 08:05:57.1864
5: 2024-10-07 08:05:57.19196
6: 2024-10-07 08:05:57.198036
256: 2024-10-07 08:05:58
257: 2024-10-07 08:05:58.4
258: 2024-10-07 08:05:58.48
259: 2024-10-07 08:05:58.487
260: 2024-10-07 08:05:58.4927
261: 2024-10-07 08:05:58.49918
262: 2024-10-07 08:05:58.505731
512: 2024-10-07 08:05:59
513: 2024-10-07 08:05:59.7
514: 2024-10-07 08:05:59.73
515: 2024-10-07 08:05:59.744
516: 2024-10-07 08:05:59.7498
517: 2024-10-07 08:05:59.75391
518: 2024-10-07 08:05:59.757951
768: 2024-10-07 08:06:01
769: 2024-10-07 08:06:01.0
770: 2024-10-07 08:06:01.01
771: 2024-10-07 08:06:01.024
772: 2024-10-07 08:06:01.0285
773: 2024-10-07 08:06:01.03447
774: 2024-10-07 08:06:01.039853
[7 Oct 2024 6:42] MySQL Verification Team
Hello Daniël,

Thank you for the report and feedback.

regards,
Umesh
[21 Apr 12:02] Dyre Tjeldvoll
Posted by developer:
 
Thank you for the bug report. Fix has been pushed to mysql-trunk, and is expected to be part of the 10.0 release.
[28 May 1:13] MySQL Admin
Posted by developer: Bug status updated to 'Documenting'
[14 Jul 14:43] Edward Gilmore
Posted by developer:
 
Added the following note to the MySQL Server 26.7.0 release notes:

NOW() accepted values outside the defined range (0-6) and did not return an error.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.055 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.