=== modified file 'drizzled/item.h'
--- drizzled/item.h 2010-03-30 09:29:02 +0000
+++ drizzled/item.h 2010-07-19 02:40:58 +0000
@@ -732,6 +732,11 @@
* cost Item::execution_cost(),
* where 'cost' is either 'double' or some structure of various cost
* parameters.
+ *
+ *NOTE
+ * This function is now used to prevent evaluation of materialized IN
+ * subquery predicates before it is allowed. grep for
+ * DontEvaluateMaterializedSubqueryTooEarly to see the uses.
*/
virtual bool is_expensive();
=== modified file 'drizzled/join.cc'
--- drizzled/join.cc 2010-07-16 05:40:08 +0000
+++ drizzled/join.cc 2010-07-19 02:40:58 +0000
@@ -4040,6 +4040,15 @@
*/
join->setPosInPartialPlan(idx, best_pos);
+ /*
+ We need to make best_extension_by_limited_search aware of the fact
+ that it's not starting from top level, but from a rather specific
+ position in the list of nested joins.
+ */
+ check_interleaving_with_nj (best_table);
+
+
+
/* find the position of 'best_table' in 'join->best_ref' */
best_idx= idx;
JoinTable *pos= join->best_ref[best_idx];
@@ -4201,13 +4210,9 @@
for (JoinTable **pos= join->best_ref + idx ; (s= *pos) ; pos++)
{
table_map real_table_bit= s->table->map;
- if (idx)
- {
- partial_pos= join->getPosFromPartialPlan(idx - 1);
- }
if ((remaining_tables & real_table_bit) &&
! (remaining_tables & s->dependent) &&
- (! idx || ! check_interleaving_with_nj(partial_pos.getJoinTable(), s)))
+ (! idx || ! check_interleaving_with_nj(s)))
{
double current_record_count, current_read_time;
@@ -6014,35 +6019,75 @@
/**
Nested joins perspective: Remove the last table from the join order.
+ The algorithm is the reciprocal of check_interleaving_with_nj(), hence
+ parent join nest nodes are updated only when the last table in its child
+ node is removed. The ASCII graphic below will clarify.
+
+ %A table nesting such as t1 x [ ( t2 x t3 ) x ( t4 x t5 ) ] is
+ represented by the below join nest tree.
+
+ @verbatim
+ NJ1
+ _/ / \
+ _/ / NJ2
+ _/ / / \
+ / / / \
+ t1 x [ (t2 x t3) x (t4 x t5) ]
+ @endverbatim
+
+ At the point in time when check_interleaving_with_nj() adds the table t5 to
+ the query execution plan, QEP, it also directs the node named NJ2 to mark
+ the table as covered. NJ2 does so by incrementing its @c counter
+ member. Since all of NJ2's tables are now covered by the QEP, the algorithm
+ proceeds up the tree to NJ1, incrementing its counter as well. All join
+ nests are now completely covered by the QEP.
+
+ restore_prev_nj_state() does the above in reverse. As seen above, the node
+ NJ1 contains the nodes t2, t3, and NJ2. Its counter being equal to 3 means
+ that the plan covers t2, t3, and NJ2, @e and that the sub-plan (t4 x t5)
+ completely covers NJ2. The removal of t5 from the partial plan will first
+ decrement NJ2's counter to 1. It will then detect that NJ2 went from being
+ completely to partially covered, and hence the algorithm must continue
+ upwards to NJ1 and decrement its counter to 2. %A subsequent removal of t4
+ will however not influence NJ1 since it did not un-cover the last table in
+ NJ2.
+
+ SYNOPSIS
+ restore_prev_nj_state()
+ last join table to remove, it is assumed to be the last in current
+ partial join order.
+
+ DESCRIPTION
+
Remove the last table from the partial join order and update the nested
- joins counters and join->cur_embedding_map. It is ok to call this
- function for the first table in join order (for which
+ joins counters and join->cur_embedding_map. It is ok to call this
+ function for the first table in join order (for which
check_interleaving_with_nj has not been called)
@param last join table to remove, it is assumed to be the last in current
partial join order.
*/
+
static void restore_prev_nj_state(JoinTable *last)
{
TableList *last_emb= last->table->pos_in_table_list->getEmbedding();
Join *join= last->join;
- while (last_emb)
+ for (;last_emb != NULL; last_emb= last_emb->getEmbedding())
{
- if (last_emb->on_expr)
- {
- if (!(--last_emb->getNestedJoin()->counter_))
- join->cur_embedding_map&= ~last_emb->getNestedJoin()->nj_map;
- else if (last_emb->getNestedJoin()->join_list.elements-1 ==
- last_emb->getNestedJoin()->counter_)
- join->cur_embedding_map|= last_emb->getNestedJoin()->nj_map;
- else
- break;
- }
- last_emb= last_emb->getEmbedding();
+ nested_join_st *nest= last_emb->getNestedJoin();
+
+ bool was_fully_covered= nest->is_fully_covered();
+
+ if (--nest->counter_ == 0)
+ join->cur_embedding_map&= ~nest->nj_map;
+
+ if (!was_fully_covered)
+ break;
+
+ join->cur_embedding_map|= nest->nj_map;
}
}
-
/**
Create a condition for a const reference and add this to the
currenct select for the table.
=== modified file 'drizzled/nested_join.h'
--- drizzled/nested_join.h 2010-02-04 08:14:46 +0000
+++ drizzled/nested_join.h 2010-07-19 02:40:58 +0000
@@ -65,6 +65,16 @@
table_map sj_corr_tables;
List- sj_outer_expr_list;
+
+ /**
+ True if this join nest node is completely covered by the query execution
+ plan. This means two things.
+
+ 1. All tables on its @c join_list are covered by the plan.
+
+ 2. All child join nest nodes are fully covered.
+ */
+ bool is_fully_covered() const { return join_list.elements == counter_; }
};
} /* namespace drizzled */
=== modified file 'drizzled/optimizer/range.cc'
--- drizzled/optimizer/range.cc 2010-07-16 05:40:08 +0000
+++ drizzled/optimizer/range.cc 2010-07-19 02:40:58 +0000
@@ -2639,8 +2639,11 @@
}
return(tree);
}
- /* Here when simple cond */
- if (cond->const_item())
+ /* Here when simple cond
+ There are limits on what kinds of const items we can evaluate, grep for
+ DontEvaluateMaterializedSubqueryTooEarly.
+ */
+ if (cond->const_item() && !cond->is_expensive())
{
/*
During the cond->val_int() evaluation we can come across a subselect
=== modified file 'drizzled/sql_select.cc'
--- drizzled/sql_select.cc 2010-07-16 05:40:08 +0000
+++ drizzled/sql_select.cc 2010-07-19 02:40:58 +0000
@@ -2850,8 +2850,6 @@
@endverbatim
@param join Join being processed
- @param last_tab Last table in current partial join order (this function is
- not called for empty partial join orders)
@param next_tab Table we're going to extend the current partial join with
@retval
@@ -2860,10 +2858,10 @@
@retval
true Requested join order extension not allowed.
*/
-bool check_interleaving_with_nj(JoinTable *last_tab, JoinTable *next_tab)
+bool check_interleaving_with_nj(JoinTable *next_tab)
{
TableList *next_emb= next_tab->table->pos_in_table_list->getEmbedding();
- Join *join= last_tab->join;
+ Join *join= next_tab->join;
if ((join->cur_embedding_map & ~next_tab->embedding_map).any())
{
@@ -3085,12 +3083,12 @@
/*
TODO:
Excluding all expensive functions is too restritive we should exclude only
- materialized IN because it is created later than this phase, and cannot be
- evaluated at this point.
- The condition should be something as (need to fix member access):
- !(cond->type() == Item::FUNC_ITEM &&
- ((Item_func*)cond)->func_name() == "" &&
- ((Item_in_optimizer*)cond)->is_expensive()))
+ materialized IN subquery predicates because they can't yet be evaluated
+ here (they need additional initialization that is done later on).
+
+ The proper way to exclude the subqueries would be to walk the cond tree and
+ check for materialized subqueries there.
+
*/
{
*cond_value= eval_const_cond(cond) ? Item::COND_TRUE : Item::COND_FALSE;
=== modified file 'drizzled/sql_select.h'
--- drizzled/sql_select.h 2010-05-19 00:35:41 +0000
+++ drizzled/sql_select.h 2010-07-19 02:40:58 +0000
@@ -144,7 +144,7 @@
uint32_t elements,
List
- &all_fields);
bool change_group_ref(Session *session, Item_func *expr, order_st *group_list, bool *changed);
-bool check_interleaving_with_nj(JoinTable *last, JoinTable *next);
+bool check_interleaving_with_nj(JoinTable *next);
int join_read_const_table(JoinTable *tab, optimizer::Position *pos);
int join_read_system(JoinTable *tab);
=== modified file 'tests/r/optimizer.result'
--- tests/r/optimizer.result 2010-07-10 21:56:22 +0000
+++ tests/r/optimizer.result 2010-07-19 02:40:58 +0000
@@ -71,3 +71,144 @@
NULL
DROP TABLE `bb`, `cc`;
End Bug#600664 test
+Bug#595305
+- Assertion failed - exec_method != MATERIALIZATION || (exec_method == MATERIALIZATION && engine->engine_type() == subselect_engine::HASH_SJ_ENGINE)", file=, line=318, function=0x84fae0 "virtual bool drizzled::Item_in_subselect::exec()
+DROP TABLE IF EXISTS `bb`;
+CREATE TABLE `bb` (
+`pk` int NOT NULL AUTO_INCREMENT,
+`col_text_not_null` text NOT NULL,
+`col_bigint_key` bigint DEFAULT NULL,
+`col_int` int DEFAULT NULL,
+`col_char` varchar(1) DEFAULT NULL,
+`col_text` text,
+`col_text_not_null_key` text NOT NULL,
+`col_char_not_null` varchar(1) NOT NULL,
+PRIMARY KEY (`pk`),
+KEY `col_bigint_key` (`col_bigint_key`),
+KEY `col_text_not_null_key` (`col_text_not_null_key`(255))
+) ENGINE=InnoDB;
+ALTER TABLE `bb` DISABLE KEYS;
+Warnings:
+Note 1031 Table storage engine for 'bb' doesn't have this option
+INSERT INTO `bb` VALUES (1,'',NULL,NULL,'h',NULL,'','f'),(2,'',NULL,1756299264,'p',NULL,'','w'),(3,'',6,-1990000640,'w',NULL,'','w'),(4,'',NULL,NULL,'f',NULL,'','k'),(5,'',NULL,NULL,'k',NULL,'','t'),(6,'',9,NULL,'m',NULL,'','c'),(7,'',6451687941184946176,0,'z',NULL,'','f'),(8,'',8960474408607023104,1805844480,'h',NULL,'','k'),(9,'',8,7,'y',NULL,'','m'),(10,'',NULL,-415629312,'t',NULL,'','h');
+ALTER TABLE `bb` ENABLE KEYS;
+Warnings:
+Note 1031 Table storage engine for 'bb' doesn't have this option
+SELECT DISTINCT OUTR . `col_text` AS X FROM BB AS OUTR2 LEFT JOIN BB AS OUTR ON ( OUTR2 . `col_char` <> OUTR . `col_text` ) WHERE OUTR . `col_bigint_key` IN ( SELECT INNR . `pk` AS Y FROM BB AS INNR WHERE INNR . `col_bigint_key` > INNR . `col_int` AND INNR . `col_text_not_null_key` >= INNR . `col_char_not_null` ) AND OUTR . `col_bigint_key` = 9 ORDER BY OUTR . `col_text_not_null` , OUTR . `pk`;
+X
+DROP TABLE BB;
+End Bug#595305 test
+Bug#592444
+- Segfault - operator= (join=0x1fd0fd8, tables=, conds=, keyuse_array=) at ./drizzled/join_table.h:73
+DROP TABLE IF EXISTS `p`;
+CREATE TABLE `p` (
+`pk` int NOT NULL AUTO_INCREMENT,
+`col_int_key` int DEFAULT NULL,
+PRIMARY KEY (`pk`),
+KEY `col_int_key` (`col_int_key`)
+) ENGINE=InnoDB;
+ALTER TABLE `p` DISABLE KEYS;
+Warnings:
+Note 1031 Table storage engine for 'p' doesn't have this option
+INSERT INTO `p` VALUES (1,NULL),(2,261947392),(3,-1761017856),(4,NULL),(5,NULL),(6,NULL),(7,1941635072),(8,-610992128),(9,NULL),(10,-1486618624),(11,1047199744),(12,5),(13,2),(14,NULL),(15,NULL),(16,-828899328),(17,5),(18,NULL),(19,-1573322752),(20,NULL),(21,1),(22,1080360960),(23,NULL),(24,9),(25,243335168),(26,NULL),(27,2),(28,351469568),(29,NULL),(30,0),(31,1626865664),(32,NULL),(33,NULL),(34,6),(35,NULL),(36,6),(37,NULL),(38,838598656),(39,-1732706304),(40,-120061952),(41,NULL),(42,3),(43,2),(44,8),(45,-1234436096),(46,4),(47,-1542324224),(48,NULL),(49,1607073792),(50,0),(51,9),(52,NULL),(53,NULL),(54,-921174016),(55,-184877056),(56,NULL),(57,-1291059200),(58,0),(59,NULL),(60,565379072),(61,NULL),(62,506855424),(63,NULL),(64,NULL),(65,NULL),(66,5),(67,5),(68,5),(69,2),(70,6),(71,NULL),(72,9),(73,7),(74,-2108555264),(75,6),(76,1057095680),(77,8),(78,-409468928),(79,-438960128),(80,-939393024),(81,-927203328),(82,NULL),(83,-1834680320),(84,NULL),(85,1984561152),(86,8),(87,NULL),(88,8),(89,-326500352),(90,NULL),(91,4),(92,NULL),(93,NULL),(94,-1369833472),(95,NULL),(96,0),(97,31260672),(98,NULL),(99,NULL),(100,0);
+ALTER TABLE `p` ENABLE KEYS;
+Warnings:
+Note 1031 Table storage engine for 'p' doesn't have this option
+DROP TABLE IF EXISTS `n`;
+Warnings:
+Note 1051 Unknown table 'n'
+CREATE TABLE `n` (
+`pk` int NOT NULL AUTO_INCREMENT,
+`col_varchar_10_key` varchar(10) DEFAULT NULL,
+PRIMARY KEY (`pk`),
+KEY `col_varchar_10_key` (`col_varchar_10_key`)
+) ENGINE=InnoDB;
+ALTER TABLE `n` DISABLE KEYS;
+Warnings:
+Note 1031 Table storage engine for 'n' doesn't have this option
+INSERT INTO `n` VALUES (1,'rdtxodtcmi'),(2,'corrdtxodt'),(3,'v'),(4,'dcorrdtxod'),(5,'s'),(6,'my'),(7,'e'),(8,'qxszmrdcor'),(9,'bqxszmrdco'),(10,'wbqxszmrdc'),(11,'v'),(12,'kywbqxszmr'),(13,'v'),(14,'lngrakywbq'),(15,'umtlngraky'),(16,'could'),(17,'peiywumtln'),(18,'will'),(19,'tell'),(20,'w'),(21,'jenpeiywum'),(22,'cejenpeiyw'),(23,'x'),(24,'vxcejenpei');
+ALTER TABLE `n` ENABLE KEYS;
+Warnings:
+Note 1031 Table storage engine for 'n' doesn't have this option
+DROP TABLE IF EXISTS `d`;
+Warnings:
+Note 1051 Unknown table 'd'
+CREATE TABLE `d` (
+`pk` int NOT NULL AUTO_INCREMENT,
+`col_varchar_10` varchar(10) DEFAULT NULL,
+PRIMARY KEY (`pk`)
+) ENGINE=InnoDB;
+ALTER TABLE `d` DISABLE KEYS;
+Warnings:
+Note 1031 Table storage engine for 'd' doesn't have this option
+INSERT INTO `d` VALUES (1,'f'),(2,'zdvoleqxer'),(3,'i'),(4,'u'),(5,'q');
+ALTER TABLE `d` ENABLE KEYS;
+Warnings:
+Note 1031 Table storage engine for 'd' doesn't have this option
+DROP TABLE IF EXISTS `h`;
+Warnings:
+Note 1051 Unknown table 'h'
+CREATE TABLE `h` (
+`col_varchar_10` varchar(10) DEFAULT NULL,
+`pk` int NOT NULL AUTO_INCREMENT,
+`col_varchar_10_key` varchar(10) DEFAULT NULL,
+`col_int_key` int DEFAULT NULL,
+PRIMARY KEY (`pk`),
+KEY `col_varchar_10_key` (`col_varchar_10_key`),
+KEY `col_int_key` (`col_int_key`)
+) ENGINE=InnoDB;
+ALTER TABLE `h` DISABLE KEYS;
+Warnings:
+Note 1031 Table storage engine for 'h' doesn't have this option
+INSERT INTO `h` VALUES ('n',1,'rshrrbmsyd',4),('h',2,'okay',NULL),('ok',3,'i',-802095104),('just',4,'z',6),('hfnrshrrbm',5,'his',8),('f',6,'xhfnrshrrb',1),('h',7,'wxhfnrshrr',7),('wtwxhfnrsh',8,'v',7),('of',9,'cwtwxhfnrs',-1258487808);
+ALTER TABLE `h` ENABLE KEYS;
+Warnings:
+Note 1031 Table storage engine for 'h' doesn't have this option
+DROP TABLE IF EXISTS `a`;
+Warnings:
+Note 1051 Unknown table 'a'
+CREATE TABLE `a` (
+`pk` int NOT NULL AUTO_INCREMENT,
+PRIMARY KEY (`pk`)
+) ENGINE=InnoDB;
+DROP TABLE IF EXISTS `k`;
+Warnings:
+Note 1051 Unknown table 'k'
+CREATE TABLE `k` (
+`pk` int NOT NULL AUTO_INCREMENT,
+`col_varchar_10` varchar(10) DEFAULT NULL,
+`col_varchar_10_key` varchar(10) DEFAULT NULL,
+`col_int_key` int DEFAULT NULL,
+PRIMARY KEY (`pk`),
+KEY `col_varchar_10_key` (`col_varchar_10_key`),
+KEY `col_int_key` (`col_int_key`)
+) ENGINE=InnoDB;
+ALTER TABLE `k` DISABLE KEYS;
+Warnings:
+Note 1031 Table storage engine for 'k' doesn't have this option
+INSERT INTO `k` VALUES (1,'bwylrhande','hbwylrhand',-522452992),(2,'how','about',2098200576),(3,'ephbwylrha','pephbwylrh',904331264),(4,'okay','ipephbwylr',-1176633344),(5,'but','one',-1177288704),(6,'tnwkipephb','j',5),(7,'hqtnwkipep','a',9),(8,'with','wdhqtnwkip',NULL),(9,'eyxwdhqtnw','jeyxwdhqtn',2),(10,'right','something',3),(11,'z','ujeyxwdhqt',5),(12,'yyujeyxwdh','we',NULL),(13,'can','syyujeyxwd',0),(14,'s','oh',21037056),(15,'ngvsyyujey','something',1224867840),(16,'gngvsyyuje','qgngvsyyuj',1),(17,'this','really',4),(18,'p','bbuqgngvsy',1865023488),(19,'okay','from',1),(20,'dmbbuqgngv','but',9),(21,'one','rdmbbuqgng',0);
+ALTER TABLE `k` ENABLE KEYS;
+Warnings:
+Note 1031 Table storage engine for 'k' doesn't have this option
+SELECT
+table2 . `pk` AS field4
+FROM p AS table1 LEFT JOIN
+n AS table2 LEFT JOIN
+d AS table3
+ON table2 . `pk` = table3 . `pk`
+RIGHT OUTER JOIN h AS table4
+LEFT OUTER JOIN a AS table5
+ON table4 . `pk` = table5 . `pk`
+ON table2 . `col_varchar_10_key` = table4 . `col_varchar_10_key`
+ON table1 . `col_int_key` = table5 . `pk`
+LEFT JOIN h AS table6
+LEFT JOIN k AS table7
+ON table6 . `col_int_key` = table7 . `col_int_key`
+LEFT OUTER JOIN h AS table8
+ON table7 . `col_varchar_10_key` = table8 . `col_varchar_10`
+ON table3 . `col_varchar_10` = table7 . `col_varchar_10`
+WHERE (
+( table3 . `pk` IN (6) )
+OR table7 . `col_int_key` IN (1, 1, 1, 2) ) ;
+field4
+End Bug#592444 test
=== modified file 'tests/t/optimizer.test'
--- tests/t/optimizer.test 2010-07-10 21:56:22 +0000
+++ tests/t/optimizer.test 2010-07-19 02:40:58 +0000
@@ -86,3 +86,129 @@
DROP TABLE `bb`, `cc`;
--echo End Bug#600664 test
+
+--echo Bug#595305
+--echo - Assertion failed - exec_method != MATERIALIZATION || (exec_method == MATERIALIZATION && engine->engine_type() == subselect_engine::HASH_SJ_ENGINE)", file=, line=318, function=0x84fae0 "virtual bool drizzled::Item_in_subselect::exec()
+--disable_warnings
+DROP TABLE IF EXISTS `bb`;
+--enable_warnings
+
+CREATE TABLE `bb` (
+ `pk` int NOT NULL AUTO_INCREMENT,
+ `col_text_not_null` text NOT NULL,
+ `col_bigint_key` bigint DEFAULT NULL,
+ `col_int` int DEFAULT NULL,
+ `col_char` varchar(1) DEFAULT NULL,
+ `col_text` text,
+ `col_text_not_null_key` text NOT NULL,
+ `col_char_not_null` varchar(1) NOT NULL,
+ PRIMARY KEY (`pk`),
+ KEY `col_bigint_key` (`col_bigint_key`),
+ KEY `col_text_not_null_key` (`col_text_not_null_key`(255))
+) ENGINE=InnoDB;
+
+ALTER TABLE `bb` DISABLE KEYS;
+INSERT INTO `bb` VALUES (1,'',NULL,NULL,'h',NULL,'','f'),(2,'',NULL,1756299264,'p',NULL,'','w'),(3,'',6,-1990000640,'w',NULL,'','w'),(4,'',NULL,NULL,'f',NULL,'','k'),(5,'',NULL,NULL,'k',NULL,'','t'),(6,'',9,NULL,'m',NULL,'','c'),(7,'',6451687941184946176,0,'z',NULL,'','f'),(8,'',8960474408607023104,1805844480,'h',NULL,'','k'),(9,'',8,7,'y',NULL,'','m'),(10,'',NULL,-415629312,'t',NULL,'','h');
+ALTER TABLE `bb` ENABLE KEYS;
+
+SELECT DISTINCT OUTR . `col_text` AS X FROM BB AS OUTR2 LEFT JOIN BB AS OUTR ON ( OUTR2 . `col_char` <> OUTR . `col_text` ) WHERE OUTR . `col_bigint_key` IN ( SELECT INNR . `pk` AS Y FROM BB AS INNR WHERE INNR . `col_bigint_key` > INNR . `col_int` AND INNR . `col_text_not_null_key` >= INNR . `col_char_not_null` ) AND OUTR . `col_bigint_key` = 9 ORDER BY OUTR . `col_text_not_null` , OUTR . `pk`;
+
+DROP TABLE BB;
+--echo End Bug#595305 test
+
+--echo Bug#592444
+--echo - Segfault - operator= (join=0x1fd0fd8, tables=, conds=, keyuse_array=) at ./drizzled/join_table.h:73
+--disable_warnings
+DROP TABLE IF EXISTS `p`;
+--enable_warnings
+CREATE TABLE `p` (
+ `pk` int NOT NULL AUTO_INCREMENT,
+ `col_int_key` int DEFAULT NULL,
+ PRIMARY KEY (`pk`),
+ KEY `col_int_key` (`col_int_key`)
+) ENGINE=InnoDB;
+
+ALTER TABLE `p` DISABLE KEYS;
+INSERT INTO `p` VALUES (1,NULL),(2,261947392),(3,-1761017856),(4,NULL),(5,NULL),(6,NULL),(7,1941635072),(8,-610992128),(9,NULL),(10,-1486618624),(11,1047199744),(12,5),(13,2),(14,NULL),(15,NULL),(16,-828899328),(17,5),(18,NULL),(19,-1573322752),(20,NULL),(21,1),(22,1080360960),(23,NULL),(24,9),(25,243335168),(26,NULL),(27,2),(28,351469568),(29,NULL),(30,0),(31,1626865664),(32,NULL),(33,NULL),(34,6),(35,NULL),(36,6),(37,NULL),(38,838598656),(39,-1732706304),(40,-120061952),(41,NULL),(42,3),(43,2),(44,8),(45,-1234436096),(46,4),(47,-1542324224),(48,NULL),(49,1607073792),(50,0),(51,9),(52,NULL),(53,NULL),(54,-921174016),(55,-184877056),(56,NULL),(57,-1291059200),(58,0),(59,NULL),(60,565379072),(61,NULL),(62,506855424),(63,NULL),(64,NULL),(65,NULL),(66,5),(67,5),(68,5),(69,2),(70,6),(71,NULL),(72,9),(73,7),(74,-2108555264),(75,6),(76,1057095680),(77,8),(78,-409468928),(79,-438960128),(80,-939393024),(81,-927203328),(82,NULL),(83,-1834680320),(84,NULL),(85,1984561152),(86,8),(87,NULL),(88,8),(89,-326500352),(90,NULL),(91,4),(92,NULL),(93,NULL),(94,-1369833472),(95,NULL),(96,0),(97,31260672),(98,NULL),(99,NULL),(100,0);
+ALTER TABLE `p` ENABLE KEYS;
+
+DROP TABLE IF EXISTS `n`;
+CREATE TABLE `n` (
+ `pk` int NOT NULL AUTO_INCREMENT,
+ `col_varchar_10_key` varchar(10) DEFAULT NULL,
+ PRIMARY KEY (`pk`),
+ KEY `col_varchar_10_key` (`col_varchar_10_key`)
+) ENGINE=InnoDB;
+
+ALTER TABLE `n` DISABLE KEYS;
+INSERT INTO `n` VALUES (1,'rdtxodtcmi'),(2,'corrdtxodt'),(3,'v'),(4,'dcorrdtxod'),(5,'s'),(6,'my'),(7,'e'),(8,'qxszmrdcor'),(9,'bqxszmrdco'),(10,'wbqxszmrdc'),(11,'v'),(12,'kywbqxszmr'),(13,'v'),(14,'lngrakywbq'),(15,'umtlngraky'),(16,'could'),(17,'peiywumtln'),(18,'will'),(19,'tell'),(20,'w'),(21,'jenpeiywum'),(22,'cejenpeiyw'),(23,'x'),(24,'vxcejenpei');
+ALTER TABLE `n` ENABLE KEYS;
+
+DROP TABLE IF EXISTS `d`;
+CREATE TABLE `d` (
+ `pk` int NOT NULL AUTO_INCREMENT,
+ `col_varchar_10` varchar(10) DEFAULT NULL,
+ PRIMARY KEY (`pk`)
+) ENGINE=InnoDB;
+
+ALTER TABLE `d` DISABLE KEYS;
+INSERT INTO `d` VALUES (1,'f'),(2,'zdvoleqxer'),(3,'i'),(4,'u'),(5,'q');
+ALTER TABLE `d` ENABLE KEYS;
+
+DROP TABLE IF EXISTS `h`;
+CREATE TABLE `h` (
+ `col_varchar_10` varchar(10) DEFAULT NULL,
+ `pk` int NOT NULL AUTO_INCREMENT,
+ `col_varchar_10_key` varchar(10) DEFAULT NULL,
+ `col_int_key` int DEFAULT NULL,
+ PRIMARY KEY (`pk`),
+ KEY `col_varchar_10_key` (`col_varchar_10_key`),
+ KEY `col_int_key` (`col_int_key`)
+) ENGINE=InnoDB;
+
+ALTER TABLE `h` DISABLE KEYS;
+INSERT INTO `h` VALUES ('n',1,'rshrrbmsyd',4),('h',2,'okay',NULL),('ok',3,'i',-802095104),('just',4,'z',6),('hfnrshrrbm',5,'his',8),('f',6,'xhfnrshrrb',1),('h',7,'wxhfnrshrr',7),('wtwxhfnrsh',8,'v',7),('of',9,'cwtwxhfnrs',-1258487808);
+ALTER TABLE `h` ENABLE KEYS;
+
+DROP TABLE IF EXISTS `a`;
+CREATE TABLE `a` (
+ `pk` int NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (`pk`)
+) ENGINE=InnoDB;
+
+DROP TABLE IF EXISTS `k`;
+CREATE TABLE `k` (
+ `pk` int NOT NULL AUTO_INCREMENT,
+ `col_varchar_10` varchar(10) DEFAULT NULL,
+ `col_varchar_10_key` varchar(10) DEFAULT NULL,
+ `col_int_key` int DEFAULT NULL,
+ PRIMARY KEY (`pk`),
+ KEY `col_varchar_10_key` (`col_varchar_10_key`),
+ KEY `col_int_key` (`col_int_key`)
+) ENGINE=InnoDB;
+
+ALTER TABLE `k` DISABLE KEYS;
+INSERT INTO `k` VALUES (1,'bwylrhande','hbwylrhand',-522452992),(2,'how','about',2098200576),(3,'ephbwylrha','pephbwylrh',904331264),(4,'okay','ipephbwylr',-1176633344),(5,'but','one',-1177288704),(6,'tnwkipephb','j',5),(7,'hqtnwkipep','a',9),(8,'with','wdhqtnwkip',NULL),(9,'eyxwdhqtnw','jeyxwdhqtn',2),(10,'right','something',3),(11,'z','ujeyxwdhqt',5),(12,'yyujeyxwdh','we',NULL),(13,'can','syyujeyxwd',0),(14,'s','oh',21037056),(15,'ngvsyyujey','something',1224867840),(16,'gngvsyyuje','qgngvsyyuj',1),(17,'this','really',4),(18,'p','bbuqgngvsy',1865023488),(19,'okay','from',1),(20,'dmbbuqgngv','but',9),(21,'one','rdmbbuqgng',0);
+ALTER TABLE `k` ENABLE KEYS;
+
+SELECT
+table2 . `pk` AS field4
+FROM p AS table1 LEFT JOIN
+n AS table2 LEFT JOIN
+d AS table3
+ON table2 . `pk` = table3 . `pk`
+RIGHT OUTER JOIN h AS table4
+LEFT OUTER JOIN a AS table5
+ON table4 . `pk` = table5 . `pk`
+ON table2 . `col_varchar_10_key` = table4 . `col_varchar_10_key`
+ON table1 . `col_int_key` = table5 . `pk`
+LEFT JOIN h AS table6
+LEFT JOIN k AS table7
+ON table6 . `col_int_key` = table7 . `col_int_key`
+LEFT OUTER JOIN h AS table8
+ON table7 . `col_varchar_10_key` = table8 . `col_varchar_10`
+ON table3 . `col_varchar_10` = table7 . `col_varchar_10`
+WHERE (
+( table3 . `pk` IN (6) )
+OR table7 . `col_int_key` IN (1, 1, 1, 2) ) ;
+--echo End Bug#592444 test