diff options
Diffstat (limited to 'sql/sql_derived.cc')
-rw-r--r-- | sql/sql_derived.cc | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index d9dd538f96d..9f507df3767 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -620,6 +620,15 @@ bool mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *derived) sl->context.outer_context= 0; // Prepare underlying views/DT first. sl->handle_derived(lex, DT_PREPARE); + + if (derived->outer_join) + { + /* Mark that table is part of OUTER JOIN and fields may be NULL */ + for (TABLE_LIST *cursor= (TABLE_LIST*) sl->table_list.first; + cursor; + cursor= cursor->next_local) + cursor->outer_join|= JOIN_TYPE_OUTER; + } } unit->derived= derived; @@ -714,6 +723,10 @@ exit: /* Add new temporary table to list of open derived tables */ table->next= thd->derived_tables; thd->derived_tables= table; + + /* If table is used by a left join, mark that any column may be null */ + if (derived->outer_join) + table->maybe_null= 1; } if (arena) thd->restore_active_arena(arena, &backup); |