| 29867 | */ |
| 29868 | |
| 29869 | bool JOIN::alloc_func_list() |
| 29870 | { |
| 29871 | uint func_count, group_parts; |
| 29872 | DBUG_ENTER("alloc_func_list"); |
| 29873 | |
| 29874 | func_count= tmp_table_param.sum_func_count; |
| 29875 | /* |
| 29876 | If we are using rollup, we need a copy of the summary functions for |
| 29877 | each level |
| 29878 | */ |
| 29879 | if (rollup.state != ROLLUP::STATE_NONE) |
| 29880 | func_count*= (send_group_parts+1); |
| 29881 | |
| 29882 | group_parts= send_group_parts; |
| 29883 | /* |
| 29884 | If distinct, reserve memory for possible |
| 29885 | distinct->group_by optimization |
| 29886 | */ |
| 29887 | if (select_distinct) |
| 29888 | { |
| 29889 | group_parts+= fields_list.elements; |
| 29890 | /* |
| 29891 | If the ORDER clause is specified then it's possible that |
| 29892 | it also will be optimized, so reserve space for it too |
| 29893 | */ |
| 29894 | if (order) |
| 29895 | { |
| 29896 | ORDER *ord; |
| 29897 | for (ord= order; ord; ord= ord->next) |
| 29898 | group_parts++; |
| 29899 | } |
| 29900 | } |
| 29901 | |
| 29902 | /* This must use calloc() as rollup_make_fields depends on this */ |
| 29903 | sum_funcs= (Item_sum**) thd->calloc(sizeof(Item_sum**) * (func_count+1) + |
| 29904 | sizeof(Item_sum***) * (group_parts+1)); |
| 29905 | sum_funcs_end= (Item_sum***) (sum_funcs+func_count+1); |
| 29906 | DBUG_RETURN(sum_funcs == 0); |
| 29907 | } |
| 29908 | |
| 29909 | |
| 29910 | /** |