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

[Draft] Inconsistent result with implicit cast upon comparison strings and numbers

    XMLWordPrintable

    Details

      Description

      CREATE TABLE t (f char(8));
      INSERT INTO t VALUES (''),('');
      SELECT * FROM t WHERE f BETWEEN 'a' AND 3;
      SELECT * FROM t WHERE f >= 'a';
       
      # Cleanup
      DROP TABLE t;
      

      BETWEEN query returns a result set (with warnings), while less restrictive >= returns an empty result set.

      SELECT * FROM t WHERE f BETWEEN 'a' AND 3;
      f
       
       
      Warnings:
      Warning	1292	Truncated incorrect DOUBLE value: '        '
      Warning	1292	Truncated incorrect DOUBLE value: 'a'
      Warning	1292	Truncated incorrect DOUBLE value: '        '
      Warning	1292	Truncated incorrect DOUBLE value: 'a'
      SELECT * FROM t WHERE f >= 'a';
      f
      DROP TABLE t;
      

      It may be not a bug at all, if 'a' is first cast to a number, and then both numbers are cast back to strings; but this is certainly weird behavior at the end.

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:

                Git Integration

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