summaryrefslogtreecommitdiff
path: root/sql/sql_select.cc
diff options
context:
space:
mode:
authorOle John Aske <ole.john.aske@oracle.com>2011-01-13 11:42:48 +0100
committerOle John Aske <ole.john.aske@oracle.com>2011-01-13 11:42:48 +0100
commit970c3fb244d07e019fb86dc660fcdd94e2174c82 (patch)
tree04aa93fbce94e18bce64607f774873b2e0da1536 /sql/sql_select.cc
parente17c9279ee1ecb2d9e120a5fb8af521c8f3f9fc8 (diff)
downloadmariadb-git-970c3fb244d07e019fb86dc660fcdd94e2174c82.tar.gz
Fix for #58422: Incorrect result when OUTER JOIN'ing with an empty table.
Fixed incorrect checks in join_read_const_table() for when to accept a non-existing, or empty const-row as a part of the const'ified set of tables. Intention of this test is to only accept NULL-rows if this table is outer joined into the resultset. (In case of an inner-join we can conclude at this point that resultset will be empty, end we want to return 'error' to signal this.) Initially 'maybe_null' is set to the same value as 'outer_join' in setup_table_map(), mysql_priv.h ~line 2424. Later simplify_joins() will attemp to replace outer joins by inner join whenever possible. This will cause 'outer_join' to be updated. However, 'maybe_null' is *not* updated to reflect this rewrite as this field is used to currectly set the 'nullability' property for the columns in the resultset. We should therefore change join_read_const_table() to check the 'outer_join' property instead of 'maybe_null', as this correctly reflect the nullability of the *execution plan* (not *resultset*).
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r--sql/sql_select.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 26216225c3f..fdce2510df4 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -12040,7 +12040,7 @@ join_read_const_table(JOIN_TAB *tab, POSITION *pos)
/* Mark for EXPLAIN that the row was not found */
pos->records_read=0.0;
pos->ref_depend_map= 0;
- if (!table->maybe_null || error > 0)
+ if (!table->pos_in_table_list->outer_join || error > 0)
DBUG_RETURN(error);
}
}
@@ -12061,7 +12061,7 @@ join_read_const_table(JOIN_TAB *tab, POSITION *pos)
/* Mark for EXPLAIN that the row was not found */
pos->records_read=0.0;
pos->ref_depend_map= 0;
- if (!table->maybe_null || error > 0)
+ if (!table->pos_in_table_list->outer_join || error > 0)
DBUG_RETURN(error);
}
}