diff options
author | bell@sanja.is.com.ua <> | 2003-01-29 20:44:47 +0200 |
---|---|---|
committer | bell@sanja.is.com.ua <> | 2003-01-29 20:44:47 +0200 |
commit | a662f7e105ff9f0fe5b2fb7ac193d8f5a72370d1 (patch) | |
tree | 0388d71e4d05deefde23bc90c8ba8779cfaad936 /sql/item_row.cc | |
parent | 9525a58132be10ccf3baae3ac010974aaa92acf9 (diff) | |
download | mariadb-git-a662f7e105ff9f0fe5b2fb7ac193d8f5a72370d1.tar.gz |
fixed row items with group functions
fixed layout
Diffstat (limited to 'sql/item_row.cc')
-rw-r--r-- | sql/item_row.cc | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/sql/item_row.cc b/sql/item_row.cc index 0c060b6d8db..dbab041aae5 100644 --- a/sql/item_row.cc +++ b/sql/item_row.cc @@ -48,26 +48,45 @@ bool Item_row::fix_fields(THD *thd, TABLE_LIST *tabl, Item **ref) { null_value= 0; maybe_null= 0; - for (uint i= 0; i < arg_count; i++) + Item **arg, **arg_end; + for (arg= items, arg_end= items+arg_count; arg != arg_end ; arg++) { - if (items[i]->fix_fields(thd, tabl, items+i)) + if ((*arg)->fix_fields(thd, tabl, arg)) return 1; - used_tables_cache |= items[i]->used_tables(); - if (const_item_cache&= items[i]->const_item() && !with_null) + used_tables_cache |= (*arg)->used_tables(); + if (const_item_cache&= (*arg)->const_item() && !with_null) { - if (items[i]->cols() > 1) - with_null|= items[i]->null_inside(); + if ((*arg)->cols() > 1) + with_null|= (*arg)->null_inside(); else { - items[i]->val_int(); - with_null|= items[i]->null_value; + (*arg)->val_int(); + with_null|= (*arg)->null_value; } } - maybe_null|= items[i]->maybe_null; + maybe_null|= (*arg)->maybe_null; + with_sum_func= with_sum_func || (*arg)->with_sum_func; } return 0; } +void Item_row::split_sum_func(Item **ref_pointer_array, List<Item> &fields) +{ + Item **arg, **arg_end; + for (arg= items, arg_end= items+arg_count; arg != arg_end ; arg++) + { + if ((*arg)->with_sum_func && (*arg)->type() != SUM_FUNC_ITEM) + (*arg)->split_sum_func(ref_pointer_array, fields); + else if ((*arg)->used_tables() || (*arg)->type() == SUM_FUNC_ITEM) + { + uint el= fields.elements; + fields.push_front(*arg); + ref_pointer_array[el]= *arg; + *arg= new Item_ref(ref_pointer_array + el, 0, (*arg)->name); + } + } +} + void Item_row::update_used_tables() { used_tables_cache= 0; |