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

IN with a mixture of TIME and DATETIME returns a wrong result

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 5.5(EOL), 10.0(EOL), 10.1(EOL), 10.2(EOL), 10.3(EOL)
    • 10.3.0
    • Temporal Types

    Description

      This query correctly returns TRUE:

      SELECT TIME'10:20:30' IN (102030,TIME'10:20:31');
      

      +-------------------------------------------+
      | TIME'10:20:30' IN (102030,TIME'10:20:31') |
      +-------------------------------------------+
      |                                         1 |
      +-------------------------------------------+
      

      If I add more values into the IN list, it returns FALSE with a warning:

      SELECT TIME'10:20:30' IN (102030,TIME'10:20:31',TIMESTAMP'2001-01-01 10:20:32');
      SHOW WARNINGS;
      

      +--------------------------------------------------------------------------+
      | TIME'10:20:30' IN (102030,TIME'10:20:31',TIMESTAMP'2001-01-01 10:20:32') |
      +--------------------------------------------------------------------------+
      |                                                                        0 |
      +--------------------------------------------------------------------------+
      +---------+------+------------------------------------+
      | Level   | Code | Message                            |
      +---------+------+------------------------------------+
      | Warning | 1292 | Incorrect datetime value: '102030' |
      +---------+------+------------------------------------+
      

      CASE demonstrates the same problem. See MDEV-11555.

      Attachments

        Issue Links

          Activity

            bar Alexander Barkov created issue -
            bar Alexander Barkov made changes -
            Field Original Value New Value
            bar Alexander Barkov made changes -
            Description This query correctly returns {{TRUE}}:
            {code:sql}
            SELECT TIME'10:20:30' IN (102030,TIME'10:20:31');
            {code}
            {noformat}
            +-------------------------------------------+
            | TIME'10:20:30' IN (102030,TIME'10:20:31') |
            +-------------------------------------------+
            | 1 |
            +-------------------------------------------+
            {noformat}

            If I add more value into the {{IN}} list, it returns {{FALSE}} with a warning:
            {code:sql}
            SELECT TIME'10:20:30' IN (102030,TIME'10:20:31',TIMESTAMP'2001-01-01 10:20:32');
            SHOW WARNINGS;
            {code}
            {noformat}
            +--------------------------------------------------------------------------+
            | TIME'10:20:30' IN (102030,TIME'10:20:31',TIMESTAMP'2001-01-01 10:20:32') |
            +--------------------------------------------------------------------------+
            | 0 |
            +--------------------------------------------------------------------------+
            +---------+------+------------------------------------+
            | Level | Code | Message |
            +---------+------+------------------------------------+
            | Warning | 1292 | Incorrect datetime value: '102030' |
            +---------+------+------------------------------------+
            {noformat}

            This query correctly returns {{TRUE}}:
            {code:sql}
            SELECT TIME'10:20:30' IN (102030,TIME'10:20:31');
            {code}
            {noformat}
            +-------------------------------------------+
            | TIME'10:20:30' IN (102030,TIME'10:20:31') |
            +-------------------------------------------+
            | 1 |
            +-------------------------------------------+
            {noformat}

            If I add more values into the {{IN}} list, it returns {{FALSE}} with a warning:
            {code:sql}
            SELECT TIME'10:20:30' IN (102030,TIME'10:20:31',TIMESTAMP'2001-01-01 10:20:32');
            SHOW WARNINGS;
            {code}
            {noformat}
            +--------------------------------------------------------------------------+
            | TIME'10:20:30' IN (102030,TIME'10:20:31',TIMESTAMP'2001-01-01 10:20:32') |
            +--------------------------------------------------------------------------+
            | 0 |
            +--------------------------------------------------------------------------+
            +---------+------+------------------------------------+
            | Level | Code | Message |
            +---------+------+------------------------------------+
            | Warning | 1292 | Incorrect datetime value: '102030' |
            +---------+------+------------------------------------+
            {noformat}

            bar Alexander Barkov made changes -
            bar Alexander Barkov made changes -
            Description This query correctly returns {{TRUE}}:
            {code:sql}
            SELECT TIME'10:20:30' IN (102030,TIME'10:20:31');
            {code}
            {noformat}
            +-------------------------------------------+
            | TIME'10:20:30' IN (102030,TIME'10:20:31') |
            +-------------------------------------------+
            | 1 |
            +-------------------------------------------+
            {noformat}

            If I add more values into the {{IN}} list, it returns {{FALSE}} with a warning:
            {code:sql}
            SELECT TIME'10:20:30' IN (102030,TIME'10:20:31',TIMESTAMP'2001-01-01 10:20:32');
            SHOW WARNINGS;
            {code}
            {noformat}
            +--------------------------------------------------------------------------+
            | TIME'10:20:30' IN (102030,TIME'10:20:31',TIMESTAMP'2001-01-01 10:20:32') |
            +--------------------------------------------------------------------------+
            | 0 |
            +--------------------------------------------------------------------------+
            +---------+------+------------------------------------+
            | Level | Code | Message |
            +---------+------+------------------------------------+
            | Warning | 1292 | Incorrect datetime value: '102030' |
            +---------+------+------------------------------------+
            {noformat}

            This query correctly returns {{TRUE}}:
            {code:sql}
            SELECT TIME'10:20:30' IN (102030,TIME'10:20:31');
            {code}
            {noformat}
            +-------------------------------------------+
            | TIME'10:20:30' IN (102030,TIME'10:20:31') |
            +-------------------------------------------+
            | 1 |
            +-------------------------------------------+
            {noformat}

            If I add more values into the {{IN}} list, it returns {{FALSE}} with a warning:
            {code:sql}
            SELECT TIME'10:20:30' IN (102030,TIME'10:20:31',TIMESTAMP'2001-01-01 10:20:32');
            SHOW WARNINGS;
            {code}
            {noformat}
            +--------------------------------------------------------------------------+
            | TIME'10:20:30' IN (102030,TIME'10:20:31',TIMESTAMP'2001-01-01 10:20:32') |
            +--------------------------------------------------------------------------+
            | 0 |
            +--------------------------------------------------------------------------+
            +---------+------+------------------------------------+
            | Level | Code | Message |
            +---------+------+------------------------------------+
            | Warning | 1292 | Incorrect datetime value: '102030' |
            +---------+------+------------------------------------+
            {noformat}

            {{CASE}} demonstrates the same problem:
            {code:sql}
            SELECT
              CASE TIME'10:20:30'
                WHEN 102030 THEN 'one'
                WHEN TIME'10:20:31' THEN 'two'
              END AS good,
              CASE TIME'10:20:30'
                WHEN 102030 THEN 'one'
                WHEN TIME'10:20:31' THEN 'two'
                WHEN TIMESTAMP'2001-01-01 10:20:32' THEN 'three'
              END AS bad;
            SHOW WARNINGS;
            {code}
            {noformat}

            {noformat}
            bar Alexander Barkov made changes -
            Description This query correctly returns {{TRUE}}:
            {code:sql}
            SELECT TIME'10:20:30' IN (102030,TIME'10:20:31');
            {code}
            {noformat}
            +-------------------------------------------+
            | TIME'10:20:30' IN (102030,TIME'10:20:31') |
            +-------------------------------------------+
            | 1 |
            +-------------------------------------------+
            {noformat}

            If I add more values into the {{IN}} list, it returns {{FALSE}} with a warning:
            {code:sql}
            SELECT TIME'10:20:30' IN (102030,TIME'10:20:31',TIMESTAMP'2001-01-01 10:20:32');
            SHOW WARNINGS;
            {code}
            {noformat}
            +--------------------------------------------------------------------------+
            | TIME'10:20:30' IN (102030,TIME'10:20:31',TIMESTAMP'2001-01-01 10:20:32') |
            +--------------------------------------------------------------------------+
            | 0 |
            +--------------------------------------------------------------------------+
            +---------+------+------------------------------------+
            | Level | Code | Message |
            +---------+------+------------------------------------+
            | Warning | 1292 | Incorrect datetime value: '102030' |
            +---------+------+------------------------------------+
            {noformat}

            {{CASE}} demonstrates the same problem:
            {code:sql}
            SELECT
              CASE TIME'10:20:30'
                WHEN 102030 THEN 'one'
                WHEN TIME'10:20:31' THEN 'two'
              END AS good,
              CASE TIME'10:20:30'
                WHEN 102030 THEN 'one'
                WHEN TIME'10:20:31' THEN 'two'
                WHEN TIMESTAMP'2001-01-01 10:20:32' THEN 'three'
              END AS bad;
            SHOW WARNINGS;
            {code}
            {noformat}

            {noformat}
            This query correctly returns {{TRUE}}:
            {code:sql}
            SELECT TIME'10:20:30' IN (102030,TIME'10:20:31');
            {code}
            {noformat}
            +-------------------------------------------+
            | TIME'10:20:30' IN (102030,TIME'10:20:31') |
            +-------------------------------------------+
            | 1 |
            +-------------------------------------------+
            {noformat}

            If I add more values into the {{IN}} list, it returns {{FALSE}} with a warning:
            {code:sql}
            SELECT TIME'10:20:30' IN (102030,TIME'10:20:31',TIMESTAMP'2001-01-01 10:20:32');
            SHOW WARNINGS;
            {code}
            {noformat}
            +--------------------------------------------------------------------------+
            | TIME'10:20:30' IN (102030,TIME'10:20:31',TIMESTAMP'2001-01-01 10:20:32') |
            +--------------------------------------------------------------------------+
            | 0 |
            +--------------------------------------------------------------------------+
            +---------+------+------------------------------------+
            | Level | Code | Message |
            +---------+------+------------------------------------+
            | Warning | 1292 | Incorrect datetime value: '102030' |
            +---------+------+------------------------------------+
            {noformat}

            {{CASE}} demonstrates the same problem:
            {code:sql}
            SELECT
              CASE TIME'10:20:30'
                WHEN 102030 THEN 'one'
                WHEN TIME'10:20:31' THEN 'two'
              END AS good,
              CASE TIME'10:20:30'
                WHEN 102030 THEN 'one'
                WHEN TIME'10:20:31' THEN 'two'
                WHEN TIMESTAMP'2001-01-01 10:20:32' THEN 'three'
              END AS bad;
            SHOW WARNINGS;
            {code}
            {noformat}
            +------+------+
            | good | bad |
            +------+------+
            | one | NULL |
            +------+------+
            {noformat}
            {noformat}
            +---------+------+------------------------------------+
            | Level | Code | Message |
            +---------+------+------------------------------------+
            | Warning | 1292 | Incorrect datetime value: '102030' |
            +---------+------+------------------------------------+
            {noformat}
            bar Alexander Barkov made changes -
            bar Alexander Barkov made changes -
            Description This query correctly returns {{TRUE}}:
            {code:sql}
            SELECT TIME'10:20:30' IN (102030,TIME'10:20:31');
            {code}
            {noformat}
            +-------------------------------------------+
            | TIME'10:20:30' IN (102030,TIME'10:20:31') |
            +-------------------------------------------+
            | 1 |
            +-------------------------------------------+
            {noformat}

            If I add more values into the {{IN}} list, it returns {{FALSE}} with a warning:
            {code:sql}
            SELECT TIME'10:20:30' IN (102030,TIME'10:20:31',TIMESTAMP'2001-01-01 10:20:32');
            SHOW WARNINGS;
            {code}
            {noformat}
            +--------------------------------------------------------------------------+
            | TIME'10:20:30' IN (102030,TIME'10:20:31',TIMESTAMP'2001-01-01 10:20:32') |
            +--------------------------------------------------------------------------+
            | 0 |
            +--------------------------------------------------------------------------+
            +---------+------+------------------------------------+
            | Level | Code | Message |
            +---------+------+------------------------------------+
            | Warning | 1292 | Incorrect datetime value: '102030' |
            +---------+------+------------------------------------+
            {noformat}

            {{CASE}} demonstrates the same problem:
            {code:sql}
            SELECT
              CASE TIME'10:20:30'
                WHEN 102030 THEN 'one'
                WHEN TIME'10:20:31' THEN 'two'
              END AS good,
              CASE TIME'10:20:30'
                WHEN 102030 THEN 'one'
                WHEN TIME'10:20:31' THEN 'two'
                WHEN TIMESTAMP'2001-01-01 10:20:32' THEN 'three'
              END AS bad;
            SHOW WARNINGS;
            {code}
            {noformat}
            +------+------+
            | good | bad |
            +------+------+
            | one | NULL |
            +------+------+
            {noformat}
            {noformat}
            +---------+------+------------------------------------+
            | Level | Code | Message |
            +---------+------+------------------------------------+
            | Warning | 1292 | Incorrect datetime value: '102030' |
            +---------+------+------------------------------------+
            {noformat}
            This query correctly returns {{TRUE}}:
            {code:sql}
            SELECT TIME'10:20:30' IN (102030,TIME'10:20:31');
            {code}
            {noformat}
            +-------------------------------------------+
            | TIME'10:20:30' IN (102030,TIME'10:20:31') |
            +-------------------------------------------+
            | 1 |
            +-------------------------------------------+
            {noformat}

            If I add more values into the {{IN}} list, it returns {{FALSE}} with a warning:
            {code:sql}
            SELECT TIME'10:20:30' IN (102030,TIME'10:20:31',TIMESTAMP'2001-01-01 10:20:32');
            SHOW WARNINGS;
            {code}
            {noformat}
            +--------------------------------------------------------------------------+
            | TIME'10:20:30' IN (102030,TIME'10:20:31',TIMESTAMP'2001-01-01 10:20:32') |
            +--------------------------------------------------------------------------+
            | 0 |
            +--------------------------------------------------------------------------+
            +---------+------+------------------------------------+
            | Level | Code | Message |
            +---------+------+------------------------------------+
            | Warning | 1292 | Incorrect datetime value: '102030' |
            +---------+------+------------------------------------+
            {noformat}

            {{CASE}} demonstrates the same problem. See MDEV-11555.
            bar Alexander Barkov made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            bar Alexander Barkov made changes -
            Assignee Alexander Barkov [ bar ] Oleksandr Byelkin [ sanja ]
            Status In Progress [ 3 ] In Review [ 10002 ]
            sanja Oleksandr Byelkin made changes -
            Status In Review [ 10002 ] Stalled [ 10000 ]
            sanja Oleksandr Byelkin made changes -
            Assignee Oleksandr Byelkin [ sanja ] Alexander Barkov [ bar ]

            Pushed into bb-10.2-ext

            bar Alexander Barkov added a comment - Pushed into bb-10.2-ext
            bar Alexander Barkov made changes -
            Fix Version/s 10.3.0 [ 22127 ]
            Fix Version/s 10.3 [ 22126 ]
            Resolution Fixed [ 1 ]
            Status Stalled [ 10000 ] Closed [ 6 ]
            bar Alexander Barkov made changes -
            Labels datatype
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 78691 ] MariaDB v4 [ 151339 ]

            People

              bar Alexander Barkov
              bar Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              1 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.