[MDEV-453] Microseconds precision is allowed to contain a decimal point Created: 2012-08-15  Updated: 2013-05-08  Resolved: 2013-05-08

Status: Closed
Project: MariaDB Server
Component/s: None
Affects Version/s: 5.5.25
Fix Version/s: 5.5.31

Type: Bug Priority: Trivial
Reporter: Elena Stepanova Assignee: Sergei Golubchik
Resolution: Won't Fix Votes: 0
Labels: None


 Description   

I presume it affects 5.3 too, but I didn't check. In any case, I am not sure it's worth changing, since no harm is done, but it differs from the doc (https://kb.askmonty.org/en/microseconds-in-mariadb/) which says that the precision is an INTEGER number, so I thought it makes sense to check.

Normally the syntax for microseconds precision doesn't allow anything but digits, but it makes an exception for a decimal points. A precision value with a fractional part is truncated.

create table t1 (f time(5.8));
# Query OK, 0 rows affected (0.14 sec)
 
show create table t1;
# +-------+---------------------------------------------------------------------------------------+
# | Table | Create Table                                                                          |
# +-------+---------------------------------------------------------------------------------------+
# | t1    | CREATE TABLE `t1` (
#   `f` time(5) DEFAULT NULL
# ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
# +-------+---------------------------------------------------------------------------------------+
 
select cast('12:12:12.12' as time(0.5));
# +----------------------------------+
# | cast('12:12:12.12' as time(0.5)) |
# +----------------------------------+
# | 12:12:12                         |
# +----------------------------------+



 Comments   
Comment by Sergei Golubchik [ 2012-08-29 ]

I'm not sure what to choose.
A complex 100% correct solution is not worth the troubles.
Out of easy ones, we can either allow decimal dot in the field's precision: CREATE TABLE t1 (a TIME(1.5));
Or prohibit huge precisions like CREATE TABLE t1 (a TIME(99999999999999999999999999999999999));

Neither syntax makes a lot of sense, and probably neither is used by anyone. The second is always an error (too large precision). In the first - precision is always rounded down.

Generated at Thu Feb 08 06:28:51 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.