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

Never SELECT the first row when using RAND function

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Confirmed (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 10.2, 10.3, 10.4, 10.5, 10.6, 10.7, 10.7.3
    • Fix Version/s: 10.2, 10.3, 10.4, 10.5, 10.6, 10.7
    • Component/s: Optimizer
    • Labels:
    • Environment:
      OS: Ubuntu-20.04

      Description

      The function RAND() with a string type argument is TRUE in WHERE clause, but the SELECT statements with this WHERE clause never select the first row.

      /* init */ DROP TABLE IF EXISTS t;
      /* init */ CREATE TABLE t(c1 INT);
      /* init */ INSERT INTO t(c1) VALUES (3), (2), (1);
       
      mariadb> SELECT RAND('t');
      +---------------------+
      | RAND('t')           |
      +---------------------+
      | 0.15522042769493574 |
      +---------------------+
      1 row in set, 1 warning (0.00 sec)
       
      mariadb> SELECT * FROM t WHERE RAND('t');
      +------+
      | c1   |
      +------+
      |    2 |
      |    1 |
      +------+
      2 rows in set, 1 warning (0.00 sec)
      

        Attachments

          Activity

            People

            Assignee:
            serg Sergei Golubchik
            Reporter:
            John Jove John Jove
            Votes:
            0 Vote for this issue
            Watchers:
            3 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.