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

incorrect result order when reusing aliases

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Not a Bug
    • 5.5, 10.0, 10.1
    • N/A
    • Parser
    • 10.1.24

    Description

      DROP TABLE IF EXISTS `foobar`;
      CREATE  TABLE IF NOT EXISTS `foobar` (
        `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
        `name` VARCHAR(45) NULL )
      ENGINE = InnoDB;
       
      INSERT INTO `foobar` (`name`) VALUES ('A');
      INSERT INTO `foobar` (`name`) VALUES ('B');
      INSERT INTO `foobar` (`name`) VALUES ('C');
      INSERT INTO `foobar` (`name`) VALUES ('D');
      INSERT INTO `foobar` (`name`) VALUES ('E');
       
      SELECT
        `SubQuery`.`Static` AS `Random`,
        `SubQuery`.`Name`
      FROM (
        SELECT
          RAND() AS `Random`,
          1 AS `Static`,
          `Name`
        FROM `foobar`
        ) AS `SubQuery`
      ORDER BY
      `SubQuery`.`Random`,
      `SubQuery`.`Name`;

      When executing in MySQL the result is sorted correctly at random. In MariaDB the result is incorrectly sorted alphabetically by name. When renaming the first alias (`SubQuery`.`Static` AS `Random`) to `Random2`, the sorting is correct in MariaDB, too.

      Attachments

        Issue Links

          Activity

            People

              sanja Oleksandr Byelkin
              hanswurst Hans Wurst
              Votes:
              0 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.