Uploaded image for project: 'MariaDB Connector/C'
  1. MariaDB Connector/C
  2. CONC-372

Fix str_to_TIME() parsing wrt performance.

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • None
    • 3.0.8
    • None
    • None

    Description

      currently, parsing str_to_TIME() is too complicated, and even embarassing in terms of performance

      https://github.com/MariaDB/mariadb-connector-c/blob/6545b1d194d5fd037844f7a0d93604fb4757cf41/libmariadb/ma_stmt_codec.c#L199

      Following calls inside it can and should be removed.
      alloca, memcpy, memset, strchr (x4), sscanf

      Attachments

        Issue Links

          Activity

            wlad Vladislav Vaintroub created issue -
            wlad Vladislav Vaintroub added a comment - - edited

            while testing , found additional bugs in current str_to_TIME()

            Major :

            • "0000-00-00" after parsing becomes year 1970, should be 0
            • "0069-12-31" parses as year 1969, should be 69 (YYYY format)
              the above 2 make it impossible to parse anything from years 1 AD - 70 AD (and the fake MySQLish year 0)
            • "69-12-31" parses as year 1969, should be 2069

            Minor /debatable , differences with server

            • fails to parse "10:15:01." as TIME (note the trailing dot)
            • parses "10000-01-01", which server dismisses as incorrect date ( year > 9999)
            • parses time >= 839:00:00 and time <= -839:00:00, which server does not do
            • parses incorrect datetime "1999-12-31 834:59:59.999999" is parses as datetime, with hour = 834
            • server allows trailing spaces after values, but nothing else, str_to_TIME() allows anything ,except trailing dot e.g "2000-01-01a"
            • does not parse some formats that server can, e.g "YYYYMMDD"

            Server testing is done with SELECT TIME 'string' , SELECT DATE 'string', SELECT TIMESTAMP 'string' e.g

            select DATETIME '1999-12-31 834:59:59.999999';
            

            wlad Vladislav Vaintroub added a comment - - edited while testing , found additional bugs in current str_to_TIME() Major : "0000-00-00" after parsing becomes year 1970, should be 0 "0069-12-31" parses as year 1969, should be 69 (YYYY format) the above 2 make it impossible to parse anything from years 1 AD - 70 AD (and the fake MySQLish year 0) "69-12-31" parses as year 1969, should be 2069 Minor /debatable , differences with server fails to parse "10:15:01." as TIME (note the trailing dot) parses "10000-01-01", which server dismisses as incorrect date ( year > 9999) parses time >= 839:00:00 and time <= -839:00:00, which server does not do parses incorrect datetime "1999-12-31 834:59:59.999999" is parses as datetime, with hour = 834 server allows trailing spaces after values, but nothing else, str_to_TIME() allows anything ,except trailing dot e.g "2000-01-01a" does not parse some formats that server can, e.g "YYYYMMDD" Server testing is done with SELECT TIME 'string' , SELECT DATE 'string', SELECT TIMESTAMP 'string' e.g select DATETIME '1999-12-31 834:59:59.999999' ;
            wlad Vladislav Vaintroub made changes -
            Field Original Value New Value
            Status Open [ 1 ] In Progress [ 3 ]
            wlad Vladislav Vaintroub made changes -
            Fix Version/s 3.1 [ 23223 ]
            Resolution Fixed [ 1 ]
            Status In Progress [ 3 ] Closed [ 6 ]
            wlad Vladislav Vaintroub made changes -
            diego dupin Diego Dupin made changes -
            Fix Version/s 3.0.8 [ 23233 ]
            Fix Version/s 3.1 [ 23223 ]
            julien.fritsch Julien Fritsch made changes -
            Workflow MariaDB connectors [ 90501 ] MariaDB v4 [ 161147 ]

            People

              wlad Vladislav Vaintroub
              wlad Vladislav Vaintroub
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.