<?xml version="1.0" encoding="utf-8"?>
<launchpad-bug id="787299">
  <date_last_updated>2011-12-13 15:42:31.732066+00:00</date_last_updated>
  <api_links>
    <bug_api_link>https://api.launchpad.net/1.0/bugs/787299</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.3</milestone_link>
    <linked_branches_collection_link>https://api.launchpad.net/1.0/bugs/787299/linked_branches</linked_branches_collection_link>
    <activity_link>https://api.launchpad.net/1.0/bugs/787299/activity</activity_link>
  </api_links>
  <bug_web_link>https://bugs.launchpad.net/bugs/787299</bug_web_link>
  <owner>Igor Babaev</owner>
  <assignee>Sergey Petrunia</assignee>
  <milestone_title>Maria 5.3</milestone_title>
  <duplicate_link></duplicate_link>
  <duplicate_bug_id></duplicate_bug_id>
  <title>Valgrind complains on a join query with two IN subqueries</title>
  <status>Fix Released</status>
  <importance>Critical</importance>
  <created>2011-05-24 02:14:09.017954+00:00</created>
  <description>
<![CDATA[The following test case makes Valgrind complain on the 5.3 tree:

create table t1 (a int);
insert into t1 values (1), (2), (3);
create table t2 as select * from t1;
select * from t1 A, t1 B 
 where A.a = B.a and A.a in (select a from t2 C) and B.a in (select a from t2 D);
explain
select * from t1 A, t1 B 
 where A.a = B.a and A.a in (select a from t2 C) and B.a in (select a from t2 D);
drop table t1, t2;


igor@sophia:~/maria/maria-5.3/mysql-test> ./mysql-test-run --valgrind test_1
Logging: ./mysql-test-run  --valgrind view_1
MariaDB Version 5.3.0
Turning on valgrind for all executables
Running valgrind with options " --show-reachable=yes --quiet "
vardir: /home/igor/maria/maria-5.3/mysql-test/var
Checking leftover processes...
Removing old var directory...
Creating var directory '/home/igor/maria/maria-5.3/mysql-test/var'...
Installing system database...
Checking supported features...
 - skipping ndbcluster
 - SSL connections supported
 - binaries are debug compiled
Using "../libtool" when running valgrind, strace or debugger
Collecting tests...
Using server port 42383

==============================================================================

TEST                                      RESULT   TIME (ms)
------------------------------------------------------------

worker[1] Using MTR_BUILD_THREAD 300, with reserved ports 16000..16019
main.view_1                              [ fail ]  Found warnings/errors in server log file!
        Test ended at 2011-05-23 19:06:07
line
==15939== Thread 4:
==15939== Conditional jump or move depends on uninitialised value(s)
==15939==    at 0x769684: best_extension_by_limited_search(JOIN*, unsigned long long, unsigned int, double, double, unsigned int, unsigned int) (sql_select.cc:6064)
==15939==    by 0x769976: best_extension_by_limited_search(JOIN*, unsigned long long, unsigned int, double, double, unsigned int, unsigned int) (sql_select.cc:6116)
==15939==    by 0x769976: best_extension_by_limited_search(JOIN*, unsigned long long, unsigned int, double, double, unsigned int, unsigned int) (sql_select.cc:6116)
==15939==    by 0x768E10: greedy_search(JOIN*, unsigned long long, unsigned int, unsigned int) (sql_select.cc:5771)
==15939==    by 0x76864F: choose_plan(JOIN*, unsigned long long) (sql_select.cc:5433)
==15939==    by 0x762ECC: make_join_statistics(JOIN*, TABLE_LIST*, Item*, st_dynamic_array*) (sql_select.cc:3353)
==15939==    by 0x75AA0B: JOIN::optimize() (sql_select.cc:1016)
==15939==    by 0x76106F: mysql_select(THD*, Item***, TABLE_LIST*, unsigned int, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*) (sql_select.cc:2768)
==15939==    by 0x758644: handle_select(THD*, st_lex*, select_result*, unsigned long) (sql_select.cc:281)
==15939==    by 0x6E88E6: execute_sqlcom_select(THD*, TABLE_LIST*) (sql_parse.cc:5097)
==15939==    by 0x6DF9F5: mysql_execute_command(THD*) (sql_parse.cc:2242)
==15939==    by 0x6EB227: mysql_parse(THD*, char*, unsigned int, char const**) (sql_parse.cc:6097)
==15939==    by 0x6DD301: dispatch_command(enum_server_command, THD*, char*, unsigned int) (sql_parse.cc:1218)
==15939==    by 0x6DC65D: do_command(THD*) (sql_parse.cc:904)
==15939==    by 0x6D91A5: handle_one_connection (sql_connect.cc:1177)
==15939==    by 0x58B6A4E: start_thread (in /lib64/libpthread-2.11.2.so)
...]]>  </description>
  <activities>
    <activity datechanged="2011-05-24T02:14:09.017954+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[]]>      </newvalue>
      <whatchanged>bug</whatchanged>
      <person>Igor Babaev</person>
      <message>added bug</message>
    </activity>
    <activity datechanged="2011-05-24T02:15:32.786098+00:00">
      <oldvalue>
<![CDATA[New]]>      </oldvalue>
      <newvalue>
<![CDATA[Confirmed]]>      </newvalue>
      <whatchanged>maria: status</whatchanged>
      <person>Igor Babaev</person>
      <message></message>
    </activity>
    <activity datechanged="2011-05-24T02:15:37.521761+00:00">
      <oldvalue>
<![CDATA[Undecided]]>      </oldvalue>
      <newvalue>
<![CDATA[Critical]]>      </newvalue>
      <whatchanged>maria: importance</whatchanged>
      <person>Igor Babaev</person>
      <message></message>
    </activity>
    <activity datechanged="2011-05-24T02:16:19.838004+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[Sergey Petrunia (sergefp)]]>      </newvalue>
      <whatchanged>maria: assignee</whatchanged>
      <person>Igor Babaev</person>
      <message></message>
    </activity>
    <activity datechanged="2011-05-24T02:16:25.472743+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[5.3]]>      </newvalue>
      <whatchanged>maria: milestone</whatchanged>
      <person>Igor Babaev</person>
      <message></message>
    </activity>
    <activity datechanged="2011-06-02T13:33:40.039114+00:00">
      <oldvalue>
<![CDATA[Confirmed]]>      </oldvalue>
      <newvalue>
<![CDATA[Fix Committed]]>      </newvalue>
      <whatchanged>maria: status</whatchanged>
      <person>Sergey Petrunia</person>
      <message></message>
    </activity>
    <activity datechanged="2011-12-13T15:42:30.940969+00:00">
      <oldvalue>
<![CDATA[Fix Committed]]>      </oldvalue>
      <newvalue>
<![CDATA[Fix Released]]>      </newvalue>
      <whatchanged>maria: status</whatchanged>
      <person>Daniel Bartholomew</person>
      <message></message>
    </activity>
  </activities>
  <comments>
    <comment commentlink="https://api.launchpad.net/1.0/maria/+bug/787299/comments/0" datecreated="2011-05-24T02:14:09.017954+00:00">
      <person>Igor Babaev</person>
      <subject>
<![CDATA[Valgrind complains on a join query with two IN subqueries]]>      </subject>
      <content>
<![CDATA[The following test case makes Valgrind complain on the 5.3 tree:

create table t1 (a int);
insert into t1 values (1), (2), (3);
create table t2 as select * from t1;
select * from t1 A, t1 B 
 where A.a = B.a and A.a in (select a from t2 C) and B.a in (select a from t2 D);
explain
select * from t1 A, t1 B 
 where A.a = B.a and A.a in (select a from t2 C) and B.a in (select a from t2 D);
drop table t1, t2;


igor@sophia:~/maria/maria-5.3/mysql-test> ./mysql-test-run --valgrind test_1
Logging: ./mysql-test-run  --valgrind view_1
MariaDB Version 5.3.0
Turning on valgrind for all executables
Running valgrind with options " --show-reachable=yes --quiet "
vardir: /home/igor/maria/maria-5.3/mysql-test/var
Checking leftover processes...
Removing old var directory...
Creating var directory '/home/igor/maria/maria-5.3/mysql-test/var'...
Installing system database...
Checking supported features...
 - skipping ndbcluster
 - SSL connections supported
 - binaries are debug compiled
Using "../libtool" when running valgrind, strace or debugger
Collecting tests...
Using server port 42383

==============================================================================

TEST                                      RESULT   TIME (ms)
------------------------------------------------------------

worker[1] Using MTR_BUILD_THREAD 300, with reserved ports 16000..16019
main.view_1                              [ fail ]  Found warnings/errors in server log file!
        Test ended at 2011-05-23 19:06:07
line
==15939== Thread 4:
==15939== Conditional jump or move depends on uninitialised value(s)
==15939==    at 0x769684: best_extension_by_limited_search(JOIN*, unsigned long long, unsigned int, double, double, unsigned int, unsigned int) (sql_select.cc:6064)
==15939==    by 0x769976: best_extension_by_limited_search(JOIN*, unsigned long long, unsigned int, double, double, unsigned int, unsigned int) (sql_select.cc:6116)
==15939==    by 0x769976: best_extension_by_limited_search(JOIN*, unsigned long long, unsigned int, double, double, unsigned int, unsigned int) (sql_select.cc:6116)
==15939==    by 0x768E10: greedy_search(JOIN*, unsigned long long, unsigned int, unsigned int) (sql_select.cc:5771)
==15939==    by 0x76864F: choose_plan(JOIN*, unsigned long long) (sql_select.cc:5433)
==15939==    by 0x762ECC: make_join_statistics(JOIN*, TABLE_LIST*, Item*, st_dynamic_array*) (sql_select.cc:3353)
==15939==    by 0x75AA0B: JOIN::optimize() (sql_select.cc:1016)
==15939==    by 0x76106F: mysql_select(THD*, Item***, TABLE_LIST*, unsigned int, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*) (sql_select.cc:2768)
==15939==    by 0x758644: handle_select(THD*, st_lex*, select_result*, unsigned long) (sql_select.cc:281)
==15939==    by 0x6E88E6: execute_sqlcom_select(THD*, TABLE_LIST*) (sql_parse.cc:5097)
==15939==    by 0x6DF9F5: mysql_execute_command(THD*) (sql_parse.cc:2242)
==15939==    by 0x6EB227: mysql_parse(THD*, char*, unsigned int, char const**) (sql_parse.cc:6097)
==15939==    by 0x6DD301: dispatch_command(enum_server_command, THD*, char*, unsigned int) (sql_parse.cc:1218)
==15939==    by 0x6DC65D: do_command(THD*) (sql_parse.cc:904)
==15939==    by 0x6D91A5: handle_one_connection (sql_connect.cc:1177)
==15939==    by 0x58B6A4E: start_thread (in /lib64/libpthread-2.11.2.so)
...]]>      </content>
    </comment>
  </comments>
</launchpad-bug>
