diff options
author | Oleksandr Byelkin <sanja@mariadb.com> | 2015-11-10 12:41:26 +0100 |
---|---|---|
committer | Oleksandr Byelkin <sanja@mariadb.com> | 2016-09-02 18:34:37 +0200 |
commit | b9631e310b7cadf8711eef643e432d7e816680b4 (patch) | |
tree | 8fe1ca98f6dc70622d6b29f699511e94ec608111 /sql/item.cc | |
parent | ee97274ca7d9ea8d8f00e40476a039c35399ee15 (diff) | |
download | mariadb-git-b9631e310b7cadf8711eef643e432d7e816680b4.tar.gz |
MDEV-8833 Crash of server on prepared statement with conversion to semi-join
Correct context chain made to allow outer fields pullout.
Diffstat (limited to 'sql/item.cc')
-rw-r--r-- | sql/item.cc | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/sql/item.cc b/sql/item.cc index 5861766371c..abcf48fc270 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -2778,9 +2778,28 @@ void Item_field::fix_after_pullout(st_select_lex *new_parent, Item **ref) if (context) { Name_resolution_context *ctx= new Name_resolution_context(); - ctx->outer_context= NULL; // We don't build a complete name resolver - ctx->table_list= NULL; // We rely on first_name_resolution_table instead + if (context->select_lex == new_parent) + { + /* + This field was pushed in then pulled out + (for example left part of IN) + */ + ctx->outer_context= context->outer_context; + } + else if (context->outer_context) + { + /* just pull to the upper context */ + ctx->outer_context= context->outer_context->outer_context; + } + else + { + /* No upper context (merging Derived/VIEW where context chain ends) */ + ctx->outer_context= NULL; + } + ctx->table_list= context->first_name_resolution_table; ctx->select_lex= new_parent; + if (context->select_lex == NULL) + ctx->select_lex= NULL; ctx->first_name_resolution_table= context->first_name_resolution_table; ctx->last_name_resolution_table= context->last_name_resolution_table; ctx->error_processor= context->error_processor; |