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

Regression select @var := behavior from MySQL 5.5

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.5.37
    • Fix Version/s: 10.0.6
    • Component/s: OTHER
    • Labels:
      None
    • Environment:
      OSX, CentOS

      Description

      There is a difference between MariaDB's behavior and MySQL 5.5 when a query is doing select @var := count(*). MySQL would return the number of rows matched while Maria returns 0.. Its unclear to me which behavior is actually correct.

      While I personally wouldn't have used the := syntax here, someone else did and it broke our application a little bit..

      ------------------------------------------------------

      Minimal Example:

      drop database if exists `test_example`;
      
      create database test_example;
      
      use test_example;
      
      CREATE TABLE `blarg` (
        `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
        `v` varchar(10),
        PRIMARY KEY (`id`)
      ) ENGINE=InnoDB;
      
      
      insert into blarg (`v`) values ('AAA');
      insert into blarg (`v`) values ('AAA');
      insert into blarg (`v`) values ('AAA');
      insert into blarg (`v`) values ('BBB');
      insert into blarg (`v`) values ('BBB');
      insert into blarg (`v`) values ('CCC');
      
      MariaDB [test_example]> select count(*), @a := count(*), v from blarg group by v;
      +----------+----------------+------+
      | count(*) | @a := count(*) | v    |
      +----------+----------------+------+
      |        3 |              0 | AAA  |
      |        2 |              0 | BBB  |
      |        1 |              0 | CCC  |
      +----------+----------------+------+
      3 rows in set (0.00 sec)
      
      
      
      mysql> select count(*), @a := count(*), v from blarg group by v;
      +----------+----------------+------+
      | count(*) | @a := count(*) | v    |
      +----------+----------------+------+
      |        3 |              3 | AAA  |
      |        2 |              2 | BBB  |
      |        1 |              1 | CCC  |
      +----------+----------------+------+
      3 rows in set (0.00 sec)
      
      mysql>
      
      

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            elenst Elena Stepanova added a comment - - edited

            It was fixed in 10.0.5. I can't point at the particular revision, as it was fixed by a big merge of 10.0-base (revno 3817 on 10.0 tree).

            It doesn't look critical enough to backport the fix to 5.5; please comment if you disagree.

            (I've set 'Fix Version' to 10.0.6 because 10.0.5 is not on the list).

            Show
            elenst Elena Stepanova added a comment - - edited It was fixed in 10.0.5. I can't point at the particular revision, as it was fixed by a big merge of 10.0-base (revno 3817 on 10.0 tree). It doesn't look critical enough to backport the fix to 5.5; please comment if you disagree. (I've set 'Fix Version' to 10.0.6 because 10.0.5 is not on the list).

              People

              • Assignee:
                elenst Elena Stepanova
                Reporter:
                steveb3210 Stephen Blackstone
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: