Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-453

Microseconds precision is allowed to contain a decimal point

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Trivial
    • Resolution: Won't Fix
    • Affects Version/s: 5.5.25
    • Fix Version/s: 5.5.31
    • Component/s: None
    • 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                         |
      # +----------------------------------+
      

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            serg Sergei Golubchik added a comment - - edited

            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.

            Show
            serg Sergei Golubchik added a comment - - edited 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.

              People

              • Assignee:
                serg Sergei Golubchik
                Reporter:
                elenst Elena Stepanova
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - Not Specified
                  Not Specified
                  Logged:
                  Time Spent - 20 minutes
                  20m