1- /* Copyright (c) 2000, 2012 , Oracle and/or its affiliates. All rights reserved.
1+ /* Copyright (c) 2000, 2013 , Oracle and/or its affiliates. All rights reserved.
22
33 This program is free software; you can redistribute it and/or modify
44 it under the terms of the GNU General Public License as published by
@@ -4366,7 +4366,7 @@ Item_cond::fix_fields(THD *thd, Item **ref)
43664366 const_item_cache= FALSE ;
43674367 }
43684368 with_sum_func= with_sum_func || item->with_sum_func ;
4369- with_subselect|= item->with_subselect ;
4369+ with_subselect|= item->has_subquery () ;
43704370 if (item->maybe_null )
43714371 maybe_null=1 ;
43724372 }
@@ -4691,7 +4691,7 @@ longlong Item_func_isnull::val_int()
46914691 Handle optimization if the argument can't be null
46924692 This has to be here because of the test in update_used_tables().
46934693 */
4694- if (!used_tables_cache && !with_subselect )
4694+ if (const_item_cache )
46954695 return cached_value;
46964696 return args[0 ]->is_null () ? 1 : 0 ;
46974697}
@@ -4700,7 +4700,7 @@ longlong Item_is_not_null_test::val_int()
47004700{
47014701 DBUG_ASSERT (fixed == 1 );
47024702 DBUG_ENTER (" Item_is_not_null_test::val_int" );
4703- if (!used_tables_cache && !with_subselect )
4703+ if (const_item_cache )
47044704 {
47054705 owner->was_null |= (!cached_value);
47064706 DBUG_PRINT (" info" , (" cached: %ld" , (long ) cached_value));
@@ -4721,10 +4721,12 @@ longlong Item_is_not_null_test::val_int()
47214721*/
47224722void Item_is_not_null_test::update_used_tables ()
47234723{
4724+ const_item_cache= false ;
47244725 if (!args[0 ]->maybe_null )
47254726 {
47264727 used_tables_cache= 0 ; /* is always true */
47274728 cached_value= (longlong) 1 ;
4729+ const_item_cache= true ;
47284730 }
47294731 else
47304732 {
@@ -4733,6 +4735,7 @@ void Item_is_not_null_test::update_used_tables()
47334735 {
47344736 /* Remember if the value is always NULL or never NULL */
47354737 cached_value= (longlong) !args[0 ]->is_null ();
4738+ const_item_cache= true ;
47364739 }
47374740 }
47384741}
@@ -4986,6 +4989,7 @@ Item_func_regex::fix_fields(THD *thd, Item **ref)
49864989 args[1 ]->fix_fields (thd, args + 1 )) || args[1 ]->check_cols (1 ))
49874990 return TRUE ; /* purecov: inspected */
49884991 with_sum_func=args[0 ]->with_sum_func || args[1 ]->with_sum_func ;
4992+ with_subselect= args[0 ]->has_subquery () || args[1 ]->has_subquery ();
49894993 max_length= 1 ;
49904994 decimals= 0 ;
49914995
0 commit comments