~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item_sum.cc

  • Committer: Brian Aker
  • Date: 2008-08-18 20:57:01 UTC
  • mto: This revision was merged to the branch mainline in revision 352.
  • Revision ID: brian@tangent.org-20080818205701-rzeyd4qw4xj7wx7l
Refactoring of class Table

Show diffs side-by-side

added added

removed removed

Lines of Context:
2553
2553
  tmp_table_param->force_copy_fields= force_copy_fields;
2554
2554
  assert(table == 0);
2555
2555
 
2556
 
  if (!(table= create_tmp_table(thd, tmp_table_param, list, (ORDER*) 0, 1,
 
2556
  if (!(table= create_tmp_table(thd, tmp_table_param, list, (order_st*) 0, 1,
2557
2557
                                0,
2558
2558
                                (select_lex->options | thd->options),
2559
2559
                                HA_POS_ERROR, (char*)"")))
2872
2872
 GROUP_CONCAT function
2873
2873
 
2874
2874
 SQL SYNTAX:
2875
 
  GROUP_CONCAT([DISTINCT] expr,... [ORDER BY col [ASC|DESC],...]
 
2875
  GROUP_CONCAT([DISTINCT] expr,... [order_st BY col [ASC|DESC],...]
2876
2876
    [SEPARATOR str_const])
2877
2877
 
2878
2878
 concat of values from "group by" operation
2879
2879
 
2880
2880
 BUGS
2881
 
   Blobs doesn't work with DISTINCT or ORDER BY
 
2881
   Blobs doesn't work with DISTINCT or order_st BY
2882
2882
*****************************************************************************/
2883
2883
 
2884
2884
 
2887
2887
  @note
2888
2888
       
2889
2889
     GROUP_CONCAT([DISTINCT] expr [,expr ...]
2890
 
              [ORDER BY {unsigned_integer | col_name | expr}
 
2890
              [order_st BY {unsigned_integer | col_name | expr}
2891
2891
                  [ASC | DESC] [,col_name ...]]
2892
2892
              [SEPARATOR str_val])
2893
2893
 
2928
2928
 
2929
2929
 
2930
2930
/**
2931
 
  function of sort for syntax: GROUP_CONCAT(expr,... ORDER BY col,... )
 
2931
  function of sort for syntax: GROUP_CONCAT(expr,... order_st BY col,... )
2932
2932
*/
2933
2933
 
2934
2934
int group_concat_key_cmp_with_order(void* arg, const void* key1, 
2935
2935
                                    const void* key2)
2936
2936
{
2937
2937
  Item_func_group_concat* grp_item= (Item_func_group_concat*) arg;
2938
 
  ORDER **order_item, **end;
 
2938
  order_st **order_item, **end;
2939
2939
  Table *table= grp_item->table;
2940
2940
 
2941
2941
  for (order_item= grp_item->order, end=order_item+ grp_item->arg_count_order;
3079
3079
    order - arg_count_order
3080
3080
  */
3081
3081
  if (!(args= (Item**) sql_alloc(sizeof(Item*) * arg_count +
3082
 
                                 sizeof(ORDER*)*arg_count_order)))
 
3082
                                 sizeof(order_st*)*arg_count_order)))
3083
3083
    return;
3084
3084
 
3085
 
  order= (ORDER**)(args + arg_count);
 
3085
  order= (order_st**)(args + arg_count);
3086
3086
 
3087
3087
  /* fill args items of show and sort */
3088
3088
  List_iterator_fast<Item> li(*select_list);
3092
3092
 
3093
3093
  if (arg_count_order)
3094
3094
  {
3095
 
    ORDER **order_ptr= order;
3096
 
    for (ORDER *order_item= (ORDER*) order_list->first;
 
3095
    order_st **order_ptr= order;
 
3096
    for (order_st *order_item= (order_st*) order_list->first;
3097
3097
         order_item != NULL;
3098
3098
         order_item= order_item->next)
3099
3099
    {
3261
3261
  maybe_null= 1;
3262
3262
 
3263
3263
  /*
3264
 
    Fix fields for select list and ORDER clause
 
3264
    Fix fields for select list and order_st clause
3265
3265
  */
3266
3266
 
3267
3267
  for (i=0 ; i < arg_count ; i++)
3350
3350
 
3351
3351
  List<Item> all_fields(list);
3352
3352
  /*
3353
 
    Try to find every ORDER expression in the list of GROUP_CONCAT
 
3353
    Try to find every order_st expression in the list of GROUP_CONCAT
3354
3354
    arguments. If an expression is not found, prepend it to
3355
3355
    "all_fields". The resulting field list is used as input to create
3356
3356
    tmp table columns.
3366
3366
  {
3367
3367
    /*
3368
3368
      Currently we have to force conversion of BLOB values to VARCHAR's
3369
 
      if we are to store them in TREE objects used for ORDER BY and
 
3369
      if we are to store them in TREE objects used for order_st BY and
3370
3370
      DISTINCT. This leads to truncation if the BLOB's size exceeds
3371
3371
      Field_varstring::MAX_SIZE.
3372
3372
    */
3378
3378
    We have to create a temporary table to get descriptions of fields
3379
3379
    (types, sizes and so on).
3380
3380
 
3381
 
    Note that in the table, we first have the ORDER BY fields, then the
 
3381
    Note that in the table, we first have the order_st BY fields, then the
3382
3382
    field list.
3383
3383
  */
3384
3384
  if (!(table= create_tmp_table(thd, tmp_table_param, all_fields,
3385
 
                                (ORDER*) 0, 0, true,
 
3385
                                (order_st*) 0, 0, true,
3386
3386
                                (select_lex->options | thd->options),
3387
3387
                                HA_POS_ERROR, (char*) "")))
3388
3388
    return(true);
3401
3401
    tree= &tree_base;
3402
3402
    /*
3403
3403
      Create a tree for sorting. The tree is used to sort (according to the
3404
 
      syntax of this function). If there is no ORDER BY clause, we don't
 
3404
      syntax of this function). If there is no order_st BY clause, we don't
3405
3405
      create this tree.
3406
3406
    */
3407
3407
    init_tree(tree, (uint) min(thd->variables.max_heap_table_size,