<?xml version="1.0" encoding="utf-8"?>
<launchpad-bug id="1002546">
  <date_last_updated>2012-05-21 22:16:42.690757+00:00</date_last_updated>
  <api_links>
    <bug_api_link>https://api.launchpad.net/1.0/bugs/1002546</bug_api_link>
    <bug_owner_link>https://api.launchpad.net/1.0/~igorb-seattle</bug_owner_link>
    <milestone_link>https://api.launchpad.net/1.0/maria/+milestone/5.2</milestone_link>
    <linked_branches_collection_link>https://api.launchpad.net/1.0/bugs/1002546/linked_branches</linked_branches_collection_link>
    <activity_link>https://api.launchpad.net/1.0/bugs/1002546/activity</activity_link>
  </api_links>
  <bug_web_link>https://bugs.launchpad.net/bugs/1002546</bug_web_link>
  <owner>Igor Babaev</owner>
  <assignee>Oleksandr &quot;Sanja&quot; Byelkin</assignee>
  <milestone_title>Maria 5.2</milestone_title>
  <duplicate_link></duplicate_link>
  <duplicate_bug_id></duplicate_bug_id>
  <title>Wrong result from a query with an empty derived table </title>
  <status>Confirmed</status>
  <importance>High</importance>
  <created>2012-05-21 22:16:03.907139+00:00</created>
  <description>
<![CDATA[The following test case gives us a wrong result in MariaDB 5.2/5.5

CREATE TABLE t1 (
  pk int NOT NULL,
  col_int_nokey int NOT NULL,
  col_int_key int NOT NULL,
  col_time_key time NOT NULL,
  col_varchar_key varchar(1) NOT NULL,
  col_varchar_nokey varchar(1) NOT NULL,
  PRIMARY KEY (pk),
  KEY col_int_key (col_int_key),
  KEY col_time_key (col_time_key),
  KEY col_varchar_key (col_varchar_key,col_int_key)
) ENGINE=MyISAM;

CREATE TABLE t2 (
  pk int NOT NULL AUTO_INCREMENT,
  col_int_nokey int NOT NULL,
  col_int_key int NOT NULL,
  col_time_key time NOT NULL,
  col_varchar_key varchar(1) NOT NULL,
  col_varchar_nokey varchar(1) NOT NULL,
  PRIMARY KEY (pk),
  KEY col_int_key (col_int_key),
  KEY col_time_key (col_time_key),
  KEY col_varchar_key (col_varchar_key,col_int_key)
) ENGINE=MyISAM;

INSERT INTO t2 VALUES (1,4,4,'00:00:00','b','b');

SET @var2:=4, @var3:=8;

MariaDB [test]> SELECT * FROM ( SELECT @var3:=12, sq4_alias1.* FROM t1 AS sq4_alias1 WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR       sq4_alias1.col_varchar_key = @var3 )  AS alias3;
+-----------+----+---------------+-------------+--------------+-----------------+-------------------+
| @var3:=12 | pk | col_int_nokey | col_int_key | col_time_key | col_varchar_key | col_varchar_nokey |
+-----------+----+---------------+-------------+--------------+-----------------+-------------------+
|        12 |  0 |             0 |           0 | 00:00:00     |                 |                   |
+-----------+----+---------------+-------------+--------------+-----------------+-------------------+

No rows are expected in the result here.

(see also bug #13651000 from mysql-trunk)]]>  </description>
  <activities>
    <activity datechanged="2012-05-21T22:16:03.907139+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[]]>      </newvalue>
      <whatchanged>bug</whatchanged>
      <person>Igor Babaev</person>
      <message>added bug</message>
    </activity>
    <activity datechanged="2012-05-21T22:16:14.052488+00:00">
      <oldvalue>
<![CDATA[New]]>      </oldvalue>
      <newvalue>
<![CDATA[Confirmed]]>      </newvalue>
      <whatchanged>maria: status</whatchanged>
      <person>Igor Babaev</person>
      <message></message>
    </activity>
    <activity datechanged="2012-05-21T22:16:19.441862+00:00">
      <oldvalue>
<![CDATA[Undecided]]>      </oldvalue>
      <newvalue>
<![CDATA[High]]>      </newvalue>
      <whatchanged>maria: importance</whatchanged>
      <person>Igor Babaev</person>
      <message></message>
    </activity>
    <activity datechanged="2012-05-21T22:16:36.108204+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[Oleksandr "Sanja" Byelkin (sanja-byelkin)]]>      </newvalue>
      <whatchanged>maria: assignee</whatchanged>
      <person>Igor Babaev</person>
      <message></message>
    </activity>
    <activity datechanged="2012-05-21T22:16:41.817283+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[5.2]]>      </newvalue>
      <whatchanged>maria: milestone</whatchanged>
      <person>Igor Babaev</person>
      <message></message>
    </activity>
  </activities>
</launchpad-bug>
