diff options
author | Oleksandr Byelkin <sanja@mariadb.com> | 2019-07-28 13:43:26 +0200 |
---|---|---|
committer | Oleksandr Byelkin <sanja@mariadb.com> | 2019-07-28 13:43:26 +0200 |
commit | 2792c6e7b057b18c19b506f37c35716529f80979 (patch) | |
tree | cead6068286ee469dbfe33a28d4585742eb26cbb /sql/item_subselect.cc | |
parent | c0743e4b0056eba0b19a19458c85e52a83cef676 (diff) | |
parent | 4b5a14d0fe3d6945a0a9516261f563dcfd1f2c9c (diff) | |
download | mariadb-git-2792c6e7b057b18c19b506f37c35716529f80979.tar.gz |
Merge branch '10.3' into 10.4
Diffstat (limited to 'sql/item_subselect.cc')
-rw-r--r-- | sql/item_subselect.cc | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 1d950a7dad3..2d29005cc35 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -1548,16 +1548,23 @@ bool Item_exists_subselect::fix_length_and_dec() { DBUG_ENTER("Item_exists_subselect::fix_length_and_dec"); init_length_and_dec(); - /* - We need only 1 row to determine existence (i.e. any EXISTS that is not - an IN always requires LIMIT 1) - */ - Item *item= new (thd->mem_root) Item_int(thd, (int32) 1); - if (!item) - DBUG_RETURN(TRUE); - thd->change_item_tree(&unit->global_parameters()->select_limit, - item); - DBUG_PRINT("info", ("Set limit to 1")); + // If limit is not set or it is constant more than 1 + if (!unit->global_parameters()->select_limit || + (unit->global_parameters()->select_limit->basic_const_item() && + unit->global_parameters()->select_limit->val_int() > 1)) + { + /* + We need only 1 row to determine existence (i.e. any EXISTS that is not + an IN always requires LIMIT 1) + */ + Item *item= new (thd->mem_root) Item_int(thd, (int32) 1); + if (!item) + DBUG_RETURN(TRUE); + thd->change_item_tree(&unit->global_parameters()->select_limit, + item); + unit->global_parameters()->explicit_limit= 1; // we set the limit + DBUG_PRINT("info", ("Set limit to 1")); + } DBUG_RETURN(FALSE); } |