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

Sorting behavior changed from 10.1 to 10.3

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Not a Bug
    • Affects Version/s: 10.2, 10.3, 10.4, 10.5, 10.3.25
    • Fix Version/s: N/A
    • Component/s: Character Sets
    • Labels:
      None
    • Environment:
      Ubuntu 20.04

      Description

      The sorting behavior for columns with CRLF (\n\r) values seem to have changed from MariaDB 10.1 to 10.3

      Simple example table

      CREATE TABLE `test` (
        `a` int(11) NOT NULL AUTO_INCREMENT,
        `b` varchar(255) NOT NULL,
        `c` text NOT NULL,
        `d` varchar(255) NOT NULL,
        PRIMARY KEY (`a`)
      ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;
       
      INSERT INTO `test` VALUES (1,'A','\r\n','CRLF'),(2,'A','',''),(3,'A','',''),(4,'A','\r\n','CRLF'),(5,'A','','');
      

      Results on MariaDB 10.1 (Ubuntu 18.04 LTS)

      SELECT * FROM test ORDER BY b ASC, c ASC, a ASC;
       
      +---+---+----+------+
      | a | b | c  | d    |
      +---+---+----+------+
      | 2 | A |    |      |
      | 3 | A |    |      |
      | 5 | A |    |      |
      | 1 | A |    | CRLF |
      | 4 | A |    | CRLF |
      +---+---+----+------+
      

      Results on MariaDB 10.3 (Ubuntu 20.04 LTS)

      SELECT * FROM test ORDER BY b ASC, c ASC, a ASC;
       
      +---+---+----+------+
      | a | b | c  | d    |
      +---+---+----+------+
      | 1 | A |    | CRLF |
      | 4 | A |    | CRLF |
      | 2 | A |    |      |
      | 3 | A |    |      |
      | 5 | A |    |      |
      +---+---+----+------+
      

      The ordering for column c has obviously changed, since rows with a CRLF value are now shown before rows with an empty value.

      I did not find any documentation describing this change in sorting behavior. Is this a bug or can this behavior be changed "back" by a setting?

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              serg Sergei Golubchik
              Reporter:
              derhansen Torben Hansen
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: