diff options
author | unknown <bell@sanja.is.com.ua> | 2002-11-11 00:15:38 +0200 |
---|---|---|
committer | unknown <bell@sanja.is.com.ua> | 2002-11-11 00:15:38 +0200 |
commit | 828c0e9ac197f92d4b6d11aa58c312aef2c12c20 (patch) | |
tree | abe203666ad8275454b7b63843ab9041499bead1 | |
parent | 446a5b0ad584bca06a83f96acc15a2e085d93f75 (diff) | |
download | mariadb-git-828c0e9ac197f92d4b6d11aa58c312aef2c12c20.tar.gz |
fix of yet another join_free bug
decreased number of check of "!join->select_lex->dependent"
mysql-test/r/subselect.result:
test of yet another join_free bug
mysql-test/t/subselect.test:
test of yet another join_free bug
-rw-r--r-- | mysql-test/r/subselect.result | 21 | ||||
-rw-r--r-- | mysql-test/t/subselect.test | 26 | ||||
-rw-r--r-- | sql/sql_select.cc | 46 |
3 files changed, 77 insertions, 16 deletions
diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 5674bf3c473..4eaacfe66f7 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -220,3 +220,24 @@ id select_type table type possible_keys key key_len ref rows Extra 2 SUBSELECT No tables used 3 UNION No tables used drop table searchconthardwarefr3; +drop table if exists forumconthardwarefr7, searchconthardwarefr7; +CREATE TABLE `forumconthardwarefr7` ( +`numeropost` mediumint(8) unsigned NOT NULL auto_increment, +`maxnumrep` int(10) unsigned NOT NULL default '0', +PRIMARY KEY (`numeropost`), +UNIQUE KEY `maxnumrep` (`maxnumrep`) +) TYPE=MyISAM ROW_FORMAT=FIXED; +INSERT INTO forumconthardwarefr7 (numeropost,maxnumrep) VALUES (40143,1),(43506,2); +CREATE TABLE `searchconthardwarefr7` ( +`mot` varchar(30) NOT NULL default '', +`topic` mediumint(8) unsigned NOT NULL default '0', +`date` date NOT NULL default '0000-00-00', +`pseudo` varchar(35) NOT NULL default '', +PRIMARY KEY (`mot`,`pseudo`,`date`,`topic`) +) TYPE=MyISAM ROW_FORMAT=DYNAMIC; +INSERT INTO searchconthardwarefr7 (mot,topic,date,pseudo) VALUES ('joce','40143','2002-10-22','joce'), ('joce','43506','2002-10-22','joce'); +SELECT numeropost,maxnumrep FROM forumconthardwarefr7 WHERE exists (SELECT 1 FROM searchconthardwarefr7 WHERE (mot='joce') AND date >= '2002-10-21' AND forumconthardwarefr7.numeropost = searchconthardwarefr7.topic) ORDER BY maxnumrep DESC LIMIT 0, 20; +numeropost maxnumrep +43506 2 +40143 1 +drop table forumconthardwarefr7, searchconthardwarefr7; diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index 841e98dd96c..12df155bc7f 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -114,4 +114,28 @@ SELECT 1 FROM searchconthardwarefr3 WHERE 1=(SELECT 1 UNION SELECT 1) UNION ALL -- error 1240 SELECT 1 FROM searchconthardwarefr3 WHERE 1=(SELECT 1 UNION ALL SELECT 1) UNION SELECT 1; EXPLAIN SELECT 1 FROM searchconthardwarefr3 WHERE 1=(SELECT 1 UNION SELECT 1); -drop table searchconthardwarefr3;
\ No newline at end of file +drop table searchconthardwarefr3; + +drop table if exists forumconthardwarefr7, searchconthardwarefr7; +CREATE TABLE `forumconthardwarefr7` ( + `numeropost` mediumint(8) unsigned NOT NULL auto_increment, + `maxnumrep` int(10) unsigned NOT NULL default '0', + PRIMARY KEY (`numeropost`), + UNIQUE KEY `maxnumrep` (`maxnumrep`) +) TYPE=MyISAM ROW_FORMAT=FIXED; + +INSERT INTO forumconthardwarefr7 (numeropost,maxnumrep) VALUES (40143,1),(43506,2); + +CREATE TABLE `searchconthardwarefr7` ( + `mot` varchar(30) NOT NULL default '', + `topic` mediumint(8) unsigned NOT NULL default '0', + `date` date NOT NULL default '0000-00-00', + `pseudo` varchar(35) NOT NULL default '', + PRIMARY KEY (`mot`,`pseudo`,`date`,`topic`) + ) TYPE=MyISAM ROW_FORMAT=DYNAMIC; + +INSERT INTO searchconthardwarefr7 (mot,topic,date,pseudo) VALUES ('joce','40143','2002-10-22','joce'), ('joce','43506','2002-10-22','joce'); + +SELECT numeropost,maxnumrep FROM forumconthardwarefr7 WHERE exists (SELECT 1 FROM searchconthardwarefr7 WHERE (mot='joce') AND date >= '2002-10-21' AND forumconthardwarefr7.numeropost = searchconthardwarefr7.topic) ORDER BY maxnumrep DESC LIMIT 0, 20; + +drop table forumconthardwarefr7, searchconthardwarefr7;
\ No newline at end of file diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 674caed0cd0..ecf06f0971a 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2911,27 +2911,43 @@ join_free(JOIN *join) */ if (join->tables > join->const_tables) // Test for not-const tables free_io_cache(join->table[join->const_tables]); - for (tab=join->join_tab,end=tab+join->tables ; tab != end ; tab++) + if (join->select_lex->dependent) + for (tab=join->join_tab,end=tab+join->tables ; tab != end ; tab++) + { + if (tab->table) + { + if (tab->table->key_read) + { + tab->table->key_read= 0; + tab->table->file->extra(HA_EXTRA_NO_KEYREAD); + } + /* Don't free index if we are using read_record */ + if (!tab->read_record.table) + tab->table->file->index_end(); + } + } + else { - delete tab->select; - delete tab->quick; - x_free(tab->cache.buff); - if (tab->table) + for (tab=join->join_tab,end=tab+join->tables ; tab != end ; tab++) { - if (tab->table->key_read) + delete tab->select; + delete tab->quick; + x_free(tab->cache.buff); + if (tab->table) { - tab->table->key_read=0; - tab->table->file->extra(HA_EXTRA_NO_KEYREAD); + if (tab->table->key_read) + { + tab->table->key_read= 0; + tab->table->file->extra(HA_EXTRA_NO_KEYREAD); + } + /* Don't free index if we are using read_record */ + if (!tab->read_record.table) + tab->table->file->index_end(); } - /* Don't free index if we are using read_record */ - if (!tab->read_record.table) - tab->table->file->index_end(); + end_read_record(&tab->read_record); } - end_read_record(&tab->read_record); + join->table= 0; } - //TODO: is enough join_free at the end of mysql_select? - if (!join->select_lex->dependent) - join->table=0; } /* We are not using tables anymore |