@@ -302,7 +302,13 @@ class st_select_lex;
302
302
We assume that the nesting level of subquries does not exceed 127.
303
303
TODO: to catch queries where the limit is exceeded to make the
304
304
code clean here.
305
-
305
+
306
+ @note
307
+ The implementation takes into account the used strategy:
308
+ - Items resolved at optimization phase return 0 from Item_sum::used_tables().
309
+ - Items that depend on the number of join output records, but not columns of
310
+ any particular table (like COUNT(*)), returm 0 from Item_sum::used_tables(),
311
+ but still return false from Item_sum::const_item().
306
312
*/
307
313
308
314
class Item_sum :public Item_func_or_sum
@@ -368,32 +374,25 @@ class Item_sum :public Item_func_or_sum
368
374
the current argument list can be altered by usage of temporary tables.
369
375
*/
370
376
Item **orig_args, *tmp_orig_args[2 ];
371
- table_map used_tables_cache;
372
377
373
- /*
374
- TRUE <=> We've managed to calculate the value of this Item in
375
- opt_sum_query(), hence it can be considered constant at all subsequent
376
- steps.
377
- */
378
- bool forced_const;
379
378
static ulonglong ram_limitation (THD *thd);
380
379
381
380
public:
382
381
383
382
void mark_as_sum_func ();
384
- Item_sum (THD *thd): Item_func_or_sum(thd), quick_group(1 ), forced_const( FALSE )
383
+ Item_sum (THD *thd): Item_func_or_sum(thd), quick_group(1 )
385
384
{
386
385
mark_as_sum_func ();
387
386
init_aggregator ();
388
387
}
389
388
Item_sum (THD *thd, Item *a): Item_func_or_sum(thd, a), quick_group(1 ),
390
- orig_args (tmp_orig_args), forced_const( FALSE )
389
+ orig_args (tmp_orig_args)
391
390
{
392
391
mark_as_sum_func ();
393
392
init_aggregator ();
394
393
}
395
394
Item_sum (THD *thd, Item *a, Item *b): Item_func_or_sum(thd, a, b),
396
- quick_group(1 ), orig_args(tmp_orig_args), forced_const( FALSE )
395
+ quick_group(1 ), orig_args(tmp_orig_args)
397
396
{
398
397
mark_as_sum_func ();
399
398
init_aggregator ();
@@ -433,16 +432,6 @@ class Item_sum :public Item_func_or_sum
433
432
virtual void fix_length_and_dec () { maybe_null=1 ; null_value=1 ; }
434
433
virtual Item *result_item (THD *thd, Field *field);
435
434
436
- /*
437
- Return bitmap of tables that are needed to evaluate the item.
438
-
439
- The implementation takes into account the used strategy: items resolved
440
- at optimization phase will report 0.
441
- Items that depend on the number of join output records, but not columns
442
- of any particular table (like COUNT(*)) will report 0 from used_tables(),
443
- but will still return false from const_item().
444
- */
445
- table_map used_tables () const { return used_tables_cache; }
446
435
void update_used_tables ();
447
436
COND *build_equal_items (THD *thd, COND_EQUAL *inherited,
448
437
bool link_item_fields,
@@ -458,12 +447,17 @@ class Item_sum :public Item_func_or_sum
458
447
cond_equal_ref);
459
448
}
460
449
bool is_null () { return null_value; }
450
+ /* *
451
+ make_const()
452
+ Called if we've managed to calculate the value of this Item in
453
+ opt_sum_query(), hence it can be considered constant at all subsequent
454
+ steps.
455
+ */
461
456
void make_const ()
462
457
{
463
458
used_tables_cache= 0 ;
464
- forced_const= TRUE ;
459
+ const_item_cache= true ;
465
460
}
466
- virtual bool const_item () const { return forced_const; }
467
461
virtual bool const_during_execution () const { return false ; }
468
462
virtual void print (String *str, enum_query_type query_type);
469
463
void fix_num_length_and_dec ();
0 commit comments