367
365
if (select_lex->linkage != DERIVED_TABLE_TYPE ||
368
(select_options & SELECT_DESCRIBE))
366
(select_options & SELECT_DESCRIBE))
370
368
if (select_lex->linkage != GLOBAL_OPTIONS_TYPE)
372
//here is EXPLAIN of subselect or derived table
373
if (join->change_result(result))
370
//here is EXPLAIN of subselect or derived table
371
if (join->change_result(result))
380
378
if ((err= join->prepare(rref_pointer_array, tables, wild_num,
381
379
conds, og_num, order, group, having, select_lex, unit)))
920
918
The result of this is that we're missing some 'ref' accesses.
921
919
TODO: OptimizerTeam: Fix this
923
if (!new_fields->val->const_item())
926
If the value matches, we can use the key reference.
927
If not, we keep it until we have examined all new values
929
if (old->val->eq(new_fields->val, old->field->binary()))
931
old->level= and_level;
932
old->optimize= ((old->optimize & new_fields->optimize &
933
KEY_OPTIMIZE_EXISTS) |
934
((old->optimize | new_fields->optimize) &
935
KEY_OPTIMIZE_REF_OR_NULL));
936
old->null_rejecting= (old->null_rejecting &&
937
new_fields->null_rejecting);
940
else if (old->eq_func && new_fields->eq_func &&
941
old->val->eq_by_collation(new_fields->val,
942
old->field->binary(),
943
old->field->charset()))
921
if (!new_fields->val->const_item())
924
If the value matches, we can use the key reference.
925
If not, we keep it until we have examined all new values
927
if (old->val->eq(new_fields->val, old->field->binary()))
929
old->level= and_level;
930
old->optimize= ((old->optimize & new_fields->optimize &
931
KEY_OPTIMIZE_EXISTS) |
932
((old->optimize | new_fields->optimize) &
933
KEY_OPTIMIZE_REF_OR_NULL));
934
old->null_rejecting= (old->null_rejecting &&
935
new_fields->null_rejecting);
938
else if (old->eq_func && new_fields->eq_func &&
939
old->val->eq_by_collation(new_fields->val,
940
old->field->binary(),
941
old->field->charset()))
946
old->level= and_level;
947
old->optimize= ((old->optimize & new_fields->optimize &
948
KEY_OPTIMIZE_EXISTS) |
949
((old->optimize | new_fields->optimize) &
950
KEY_OPTIMIZE_REF_OR_NULL));
951
old->null_rejecting= (old->null_rejecting &&
952
new_fields->null_rejecting);
954
else if (old->eq_func && new_fields->eq_func &&
955
((old->val->const_item() && old->val->is_null()) ||
956
new_fields->val->is_null()))
958
/* field = expression OR field IS NULL */
959
old->level= and_level;
960
old->optimize= KEY_OPTIMIZE_REF_OR_NULL;
962
Remember the NOT NULL value unless the value does not depend
944
old->level= and_level;
945
old->optimize= ((old->optimize & new_fields->optimize &
946
KEY_OPTIMIZE_EXISTS) |
947
((old->optimize | new_fields->optimize) &
948
KEY_OPTIMIZE_REF_OR_NULL));
949
old->null_rejecting= (old->null_rejecting &&
950
new_fields->null_rejecting);
952
else if (old->eq_func && new_fields->eq_func &&
953
((old->val->const_item() && old->val->is_null()) ||
954
new_fields->val->is_null()))
956
/* field = expression OR field IS NULL */
957
old->level= and_level;
958
old->optimize= KEY_OPTIMIZE_REF_OR_NULL;
960
Remember the NOT NULL value unless the value does not depend
963
if (!old->val->used_tables() && old->val->is_null())
964
old->val= new_fields->val;
965
/* The referred expression can be NULL: */
966
old->null_rejecting= 0;
971
We are comparing two different const. In this case we can't
972
use a key-lookup on this so it's better to remove the value
973
and let the range optimzier handle it
965
if (!old->val->used_tables() && old->val->is_null())
966
old->val= new_fields->val;
967
/* The referred expression can be NULL: */
968
old->null_rejecting= 0;
973
We are comparing two different const. In this case we can't
974
use a key-lookup on this so it's better to remove the value
975
and let the range optimzier handle it
977
if (old == --first_free) // If last item
979
*old= *first_free; // Remove old value
980
old--; // Retry this value
975
if (old == --first_free) // If last item
977
*old= *first_free; // Remove old value
978
old--; // Retry this value
1018
1015
*key_fields is incremented if we stored a key in the array
1022
add_key_field(KEY_FIELD **key_fields,uint32_t and_level, Item_func *cond,
1023
Field *field, bool eq_func, Item **value, uint32_t num_values,
1024
table_map usable_tables, SARGABLE_PARAM **sargables)
1017
static void add_key_field(KEY_FIELD **key_fields,
1023
uint32_t num_values,
1024
table_map usable_tables,
1025
SARGABLE_PARAM **sargables)
1026
1027
uint32_t exists_optimize= 0;
1027
1028
if (!(field->flags & PART_KEY_FLAG))
1190
1191
*key_fields is incremented if we stored a key in the array
1194
add_key_equal_fields(KEY_FIELD **key_fields, uint32_t and_level,
1195
Item_func *cond, Item_field *field_item,
1196
bool eq_func, Item **val,
1197
uint32_t num_values, table_map usable_tables,
1198
SARGABLE_PARAM **sargables)
1193
static void add_key_equal_fields(KEY_FIELD **key_fields,
1196
Item_field *field_item,
1199
uint32_t num_values,
1200
table_map usable_tables,
1201
SARGABLE_PARAM **sargables)
1200
1203
Field *field= field_item->field;
1201
1204
add_key_field(key_fields, and_level, cond, field,
1249
1254
while ((item=li++))
1251
KEY_FIELD *start_key_fields= *key_fields;
1253
add_key_fields(join, key_fields, and_level, item, usable_tables,
1255
*key_fields=merge_key_fields(org_key_fields,start_key_fields,
1256
*key_fields,++(*and_level));
1256
KEY_FIELD *start_key_fields= *key_fields;
1258
add_key_fields(join, key_fields, and_level, item, usable_tables,
1260
*key_fields=merge_key_fields(org_key_fields,start_key_fields,
1261
*key_fields,++(*and_level));
1348
1353
if (cond_func->arguments()[1]->real_item()->type() == Item::FIELD_ITEM &&
1349
cond_func->functype() != Item_func::LIKE_FUNC &&
1350
!(cond_func->arguments()[1]->used_tables() & OUTER_REF_TABLE_BIT))
1354
cond_func->functype() != Item_func::LIKE_FUNC &&
1355
!(cond_func->arguments()[1]->used_tables() & OUTER_REF_TABLE_BIT))
1352
1357
add_key_equal_fields(key_fields, *and_level, cond_func,
1353
(Item_field*) (cond_func->arguments()[1])->real_item(),
1358
(Item_field*) (cond_func->arguments()[1])->real_item(), equal_func,
1355
1359
cond_func->arguments(),1,usable_tables,
1360
1364
case Item_func::OPTIMIZE_NULL:
1361
1365
/* column_name IS [NOT] NULL */
1362
1366
if (cond_func->arguments()[0]->real_item()->type() == Item::FIELD_ITEM &&
1363
!(cond_func->used_tables() & OUTER_REF_TABLE_BIT))
1367
!(cond_func->used_tables() & OUTER_REF_TABLE_BIT))
1365
1369
Item *tmp=new Item_null;
1366
1370
if (unlikely(!tmp)) // Should never be true
1368
1372
add_key_equal_fields(key_fields, *and_level, cond_func,
1369
1373
(Item_field*) (cond_func->arguments()[0])->real_item(),
1370
1374
cond_func->functype() == Item_func::ISNULL_FUNC,
1441
1444
for (uint32_t key= 0 ; key < form->sizeKeys() ; key++)
1443
1446
if (!(form->keys_in_use_for_query.test(key)))
1446
1449
uint32_t key_parts= (uint32_t) form->key_info[key].key_parts;
1447
1450
for (uint32_t part=0 ; part < key_parts ; part++)
1449
if (field->eq(form->key_info[key].key_part[part].field))
1451
keyuse.table= field->table;
1452
keyuse.val = key_field->val;
1454
keyuse.keypart=part;
1455
keyuse.keypart_map= (key_part_map) 1 << part;
1456
keyuse.used_tables=key_field->val->used_tables();
1457
keyuse.optimize= key_field->optimize & KEY_OPTIMIZE_REF_OR_NULL;
1458
keyuse.null_rejecting= key_field->null_rejecting;
1459
keyuse.cond_guard= key_field->cond_guard;
1460
keyuse.sj_pred_no= key_field->sj_pred_no;
1461
insert_dynamic(keyuse_array,(unsigned char*) &keyuse);
1452
if (field->eq(form->key_info[key].key_part[part].field))
1454
keyuse.table= field->table;
1455
keyuse.val = key_field->val;
1457
keyuse.keypart=part;
1458
keyuse.keypart_map= (key_part_map) 1 << part;
1459
keyuse.used_tables=key_field->val->used_tables();
1460
keyuse.optimize= key_field->optimize & KEY_OPTIMIZE_REF_OR_NULL;
1461
keyuse.null_rejecting= key_field->null_rejecting;
1462
keyuse.cond_guard= key_field->cond_guard;
1463
keyuse.sj_pred_no= key_field->sj_pred_no;
1464
insert_dynamic(keyuse_array,(unsigned char*) &keyuse);
1469
sort_keyuse(KEYUSE *a,KEYUSE *b)
1471
static int sort_keyuse(KEYUSE *a,KEYUSE *b)
1472
1474
if (a->table->tablenr != b->table->tablenr)
1697
1698
for (i=0 ; i < keyuse->elements-1 ; i++,use++)
1699
1700
if (!use->used_tables && use->optimize != KEY_OPTIMIZE_REF_OR_NULL)
1700
use->table->const_key_parts[use->key]|= use->keypart_map;
1701
use->table->const_key_parts[use->key]|= use->keypart_map;
1702
if (use->key == prev->key && use->table == prev->table)
1702
if (use->key == prev->key && use->table == prev->table)
1704
if (prev->keypart+1 < use->keypart || ((prev->keypart == use->keypart) && found_eq_constant))
1705
continue; /* remove */
1707
else if (use->keypart != 0) // First found must be 0
1704
if (prev->keypart+1 < use->keypart || ((prev->keypart == use->keypart) && found_eq_constant))
1705
continue; /* remove */
1707
else if (use->keypart != 0) // First found must be 0
1711
1710
#ifdef HAVE_purify
1712
1711
/* Valgrind complains about overlapped memcpy when save_pos==use. */
1747
1746
To avoid bad matches, we don't make ref_table_rows less than 100.
1749
1748
keyuse->ref_table_rows= ~(ha_rows) 0; // If no ref
1750
if (keyuse->used_tables &
1751
(map= (keyuse->used_tables & ~join->const_table_map &
1752
~OUTER_REF_TABLE_BIT)))
1749
if (keyuse->used_tables & (map= (keyuse->used_tables & ~join->const_table_map & ~OUTER_REF_TABLE_BIT)))
1754
1751
uint32_t tablenr;
1755
1752
for (tablenr=0 ; ! (map & 1) ; map>>=1, tablenr++) ;
1756
1753
if (map == 1) // Only one table
1758
Table *tmp_table=join->all_tables[tablenr];
1759
keyuse->ref_table_rows= cmax(tmp_table->file->stats.records, (ha_rows)100);
1755
Table *tmp_table=join->all_tables[tablenr];
1756
keyuse->ref_table_rows= cmax(tmp_table->file->stats.records, (ha_rows)100);
2423
2410
Item_cond_and *new_cond=new Item_cond_and;
2426
2413
List_iterator<Item> li(*((Item_cond*) cond)->argument_list());
2428
2415
while ((item=li++))
2430
Item *fix= make_cond_for_index(item, table, keyno, other_tbls_ok);
2432
new_cond->argument_list()->push_back(fix);
2417
Item *fix= make_cond_for_index(item, table, keyno, other_tbls_ok);
2419
new_cond->argument_list()->push_back(fix);
2433
2420
n_marked += test(item->marker == ICP_COND_USES_INDEX_ONLY);
2435
2422
if (n_marked ==((Item_cond*)cond)->argument_list()->elements)
2436
2423
cond->marker= ICP_COND_USES_INDEX_ONLY;
2437
2424
switch (new_cond->argument_list()->elements) {
2441
return new_cond->argument_list()->head();
2428
return new_cond->argument_list()->head();
2443
new_cond->quick_fix_field();
2430
new_cond->quick_fix_field();
2447
2434
else /* It's OR */
2449
2436
Item_cond_or *new_cond=new Item_cond_or;
2452
2439
List_iterator<Item> li(*((Item_cond*) cond)->argument_list());
2454
2441
while ((item=li++))
2456
Item *fix= make_cond_for_index(item, table, keyno, other_tbls_ok);
2459
new_cond->argument_list()->push_back(fix);
2443
Item *fix= make_cond_for_index(item, table, keyno, other_tbls_ok);
2446
new_cond->argument_list()->push_back(fix);
2460
2447
n_marked += test(item->marker == ICP_COND_USES_INDEX_ONLY);
2462
2449
if (n_marked ==((Item_cond*)cond)->argument_list()->elements)
2487
2474
/* Create new top level AND item */
2488
2475
Item_cond_and *new_cond=new Item_cond_and;
2491
2478
List_iterator<Item> li(*((Item_cond*) cond)->argument_list());
2493
2480
while ((item=li++))
2495
Item *fix= make_cond_remainder(item, exclude_index);
2482
Item *fix= make_cond_remainder(item, exclude_index);
2498
new_cond->argument_list()->push_back(fix);
2485
new_cond->argument_list()->push_back(fix);
2499
2486
tbl_map |= fix->used_tables();
2502
2489
switch (new_cond->argument_list()->elements) {
2506
return new_cond->argument_list()->head();
2493
return new_cond->argument_list()->head();
2508
new_cond->quick_fix_field();
2495
new_cond->quick_fix_field();
2509
2496
((Item_cond*)new_cond)->used_tables_cache= tbl_map;
2513
2500
else /* It's OR */
2515
2502
Item_cond_or *new_cond=new Item_cond_or;
2518
2505
List_iterator<Item> li(*((Item_cond*) cond)->argument_list());
2520
2507
while ((item=li++))
2522
Item *fix= make_cond_remainder(item, false);
2525
new_cond->argument_list()->push_back(fix);
2509
Item *fix= make_cond_remainder(item, false);
2512
new_cond->argument_list()->push_back(fix);
2526
2513
tbl_map |= fix->used_tables();
2528
2515
new_cond->quick_fix_field();
3090
3072
or, if the equality is neither a simple one nor a row equality,
3091
3073
or, if the procedure fails by a fatal error.
3094
static bool check_equality(Session *session, Item *item, COND_EQUAL *cond_equal,
3095
List<Item> *eq_list)
3075
static bool check_equality(Session *session, Item *item, COND_EQUAL *cond_equal, List<Item> *eq_list)
3097
3077
if (item->type() == Item::FUNC_ITEM &&
3098
3078
((Item_func*) item)->functype() == Item_func::EQ_FUNC)
3806
3772
session->change_item_tree(args + 1, tmp);
3807
3773
func->update_used_tables();
3808
if ((functype == Item_func::EQ_FUNC || functype == Item_func::EQUAL_FUNC)
3809
&& and_father != cond && !left_item->const_item())
3774
if ((functype == Item_func::EQ_FUNC || functype == Item_func::EQUAL_FUNC) &&
3775
and_father != cond &&
3776
! left_item->const_item())
3813
if ((tmp2=new COND_CMP(and_father,func)))
3814
save_list->push_back(tmp2);
3780
if ((tmp2=new COND_CMP(and_father,func)))
3781
save_list->push_back(tmp2);
3816
3783
func->set_cmp_func();
3830
3797
session->change_item_tree(args, tmp);
3832
3799
func->update_used_tables();
3833
if ((functype == Item_func::EQ_FUNC || functype == Item_func::EQUAL_FUNC)
3834
&& and_father != cond && !right_item->const_item())
3800
if ((functype == Item_func::EQ_FUNC || functype == Item_func::EQUAL_FUNC) &&
3801
and_father != cond &&
3802
! right_item->const_item())
3836
3804
args[0]= args[1]; // For easy check
3837
3805
session->change_item_tree(args + 1, value);
3840
if ((tmp2=new COND_CMP(and_father,func)))
3841
save_list->push_back(tmp2);
3808
if ((tmp2=new COND_CMP(and_father,func)))
3809
save_list->push_back(tmp2);
3843
3811
func->set_cmp_func();
3917
3886
if (!(left_const && right_const) &&
3918
3887
args[0]->result_type() == args[1]->result_type())
3922
resolve_const_item(session, &args[1], args[0]);
3923
func->update_used_tables();
3924
change_cond_ref_to_const(session, save_list, and_father, and_father,
3927
else if (left_const)
3929
resolve_const_item(session, &args[0], args[1]);
3930
func->update_used_tables();
3931
change_cond_ref_to_const(session, save_list, and_father, and_father,
3891
resolve_const_item(session, &args[1], args[0]);
3892
func->update_used_tables();
3893
change_cond_ref_to_const(session, save_list, and_father, and_father,
3896
else if (left_const)
3898
resolve_const_item(session, &args[0], args[1]);
3899
func->update_used_tables();
3900
change_cond_ref_to_const(session, save_list, and_father, and_father,
4383
4348
if (test_if_equality_guarantees_uniqueness (left_item, right_item))
4386
return right_item->eq(*const_item, 1);
4387
*const_item=right_item;
4351
return right_item->eq(*const_item, 1);
4352
*const_item=right_item;
4391
4356
else if (right_item->eq(comp_item,1))
4393
4358
if (test_if_equality_guarantees_uniqueness (right_item, left_item))
4396
return left_item->eq(*const_item, 1);
4397
*const_item=left_item;
4361
return left_item->eq(*const_item, 1);
4362
*const_item=left_item;
4408
4372
Rows produced by a join sweep may end up in a temporary table or be sent
5564
5526
COND *make_cond_for_table(COND *cond, table_map tables, table_map used_table, bool exclude_expensive_cond)
5566
5528
if (used_table && !(cond->used_tables() & used_table) &&
5568
Exclude constant conditions not checked at optimization time if
5569
the table we are pushing conditions to is the first one.
5570
As a result, such conditions are not considered as already checked
5571
and will be checked at execution time, attached to the first table.
5573
!((used_table & 1) && cond->is_expensive()))
5530
Exclude constant conditions not checked at optimization time if
5531
the table we are pushing conditions to is the first one.
5532
As a result, such conditions are not considered as already checked
5533
and will be checked at execution time, attached to the first table.
5535
!((used_table & 1) && cond->is_expensive()))
5574
5536
return (COND*) 0; // Already checked
5575
5537
if (cond->type() == Item::COND_ITEM)
5579
5541
/* Create new top level AND item */
5580
5542
Item_cond_and *new_cond=new Item_cond_and;
5582
return (COND*) 0; // OOM /* purecov: inspected */
5544
return (COND*) 0; // OOM /* purecov: inspected */
5583
5545
List_iterator<Item> li(*((Item_cond*) cond)->argument_list());
5585
5547
while ((item=li++))
5587
Item *fix= make_cond_for_table(item,tables,used_table,
5588
exclude_expensive_cond);
5590
new_cond->argument_list()->push_back(fix);
5549
Item *fix= make_cond_for_table(item,tables,used_table,
5550
exclude_expensive_cond);
5552
new_cond->argument_list()->push_back(fix);
5592
switch (new_cond->argument_list()->elements) {
5594
return (COND*) 0; // Always true
5596
return new_cond->argument_list()->head();
5599
Item_cond_and do not need fix_fields for execution, its parameters
5600
are fixed or do not need fix_fields, too
5602
new_cond->quick_fix_field();
5603
new_cond->used_tables_cache=
5604
((Item_cond_and*) cond)->used_tables_cache &
5554
switch (new_cond->argument_list()->elements)
5557
return (COND*) 0; // Always true
5559
return new_cond->argument_list()->head();
5562
Item_cond_and do not need fix_fields for execution, its parameters
5563
are fixed or do not need fix_fields, too
5565
new_cond->quick_fix_field();
5566
new_cond->used_tables_cache= ((Item_cond_and*) cond)->used_tables_cache & tables;
5611
5572
Item_cond_or *new_cond=new Item_cond_or;
5613
return (COND*) 0; // OOM /* purecov: inspected */
5574
return (COND*) 0; // OOM /* purecov: inspected */
5614
5575
List_iterator<Item> li(*((Item_cond*) cond)->argument_list());
5616
5577
while ((item=li++))
5618
Item *fix= make_cond_for_table(item,tables,0L, exclude_expensive_cond);
5620
return (COND*) 0; // Always true
5621
new_cond->argument_list()->push_back(fix);
5579
Item *fix= make_cond_for_table(item,tables,0L, exclude_expensive_cond);
5581
return (COND*) 0; // Always true
5582
new_cond->argument_list()->push_back(fix);
5624
Item_cond_and do not need fix_fields for execution, its parameters
5625
are fixed or do not need fix_fields, too
5585
Item_cond_and do not need fix_fields for execution, its parameters
5586
are fixed or do not need fix_fields, too
5627
5588
new_cond->quick_fix_field();
5628
5589
new_cond->used_tables_cache= ((Item_cond_or*) cond)->used_tables_cache;
6067
6020
if (! usable_keys.test(ref_key))
6070
We come here when ref_key is not among usable_keys
6023
We come here when ref_key is not among usable_keys
6072
6025
uint32_t new_ref_key;
6074
If using index only read, only consider other possible index only
6027
If using index only read, only consider other possible index only
6077
6030
if (table->covering_keys.test(ref_key))
6078
usable_keys&= table->covering_keys;
6031
usable_keys&= table->covering_keys;
6079
6032
if (tab->pre_idx_push_select_cond)
6080
6033
tab->select_cond= tab->select->cond= tab->pre_idx_push_select_cond;
6081
6034
if ((new_ref_key= test_if_subkey(order, table, ref_key, ref_key_parts,
6082
6035
&usable_keys)) < MAX_KEY)
6084
/* Found key that can be used to retrieve data in sorted order */
6085
if (tab->ref.key >= 0)
6037
/* Found key that can be used to retrieve data in sorted order */
6038
if (tab->ref.key >= 0)
6088
6041
We'll use ref access method on key new_ref_key. In general case
6089
6042
the index search tuple for new_ref_key will be different (e.g.
6386
6339
/* order_st BY range_key DESC */
6387
tmp= new QUICK_SELECT_DESC((QUICK_RANGE_SELECT*)(select->quick),
6388
used_key_parts, &error);
6392
select->quick= save_quick;
6394
return(0); // Reverse sort not supported
6340
tmp= new QUICK_SELECT_DESC((QUICK_RANGE_SELECT*)(select->quick),
6341
used_key_parts, &error);
6345
select->quick= save_quick;
6347
return(0); // Reverse sort not supported
6399
6352
else if (tab->type != JT_NEXT &&
6400
6353
tab->ref.key >= 0 && tab->ref.key_parts <= used_key_parts)
6403
SELECT * FROM t1 WHERE a=1 order_st BY a DESC,b DESC
6356
SELECT * FROM t1 WHERE a=1 order_st BY a DESC,b DESC
6405
Use a traversal function that starts by reading the last row
6406
with key part (A) and then traverse the index backwards.
6358
Use a traversal function that starts by reading the last row
6359
with key part (A) and then traverse the index backwards.
6408
6361
tab->read_first_record= join_read_last_key;
6409
6362
tab->read_record.read_record= join_read_prev_same;
7049
6999
Change order to point at item in select list.
7051
7001
If item isn't a number and doesn't exits in the select list, add it the
7052
7002
the field list.
7055
int setup_order(Session *session, Item **ref_pointer_array, TableList *tables,
7056
List<Item> &fields, List<Item> &all_fields, order_st *order)
7004
int setup_order(Session *session,
7005
Item **ref_pointer_array,
7008
List<Item> &all_fields,
7058
7011
session->where="order clause";
7059
7012
for (; order; order=order->next)
7092
7044
1 error (probably out of memory)
7096
setup_group(Session *session, Item **ref_pointer_array, TableList *tables,
7097
List<Item> &fields, List<Item> &all_fields, order_st *order,
7098
bool *hidden_group_fields)
7046
int setup_group(Session *session,
7047
Item **ref_pointer_array,
7050
List<Item> &all_fields,
7052
bool *hidden_group_fields)
7100
7054
*hidden_group_fields=0;
7550
7504
if (item->type() == Item::FIELD_ITEM)
7552
item_field= item->get_tmp_table_item(session);
7506
item_field= item->get_tmp_table_item(session);
7554
7508
else if ((field= item->get_tmp_table_field()))
7556
if (item->type() == Item::SUM_FUNC_ITEM && field->table->group)
7557
item_field= ((Item_sum*) item)->result_item(field);
7559
item_field= (Item*) new Item_field(field);
7561
return(true); // Fatal error
7510
if (item->type() == Item::SUM_FUNC_ITEM && field->table->group)
7511
item_field= ((Item_sum*) item)->result_item(field);
7513
item_field= (Item*) new Item_field(field);
7515
return(true); // Fatal error
7563
7517
if (item->real_item()->type() != Item::FIELD_ITEM)
7564
7518
field->orig_table= 0;
7565
item_field->name= item->name;
7519
item_field->name= item->name;
7566
7520
if (item->type() == Item::REF_ITEM)
7568
7522
Item_field *ifield= (Item_field *) item_field;