~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item_sum.cc

  • Committer: Brian Aker
  • Date: 2008-10-06 06:47:29 UTC
  • Revision ID: brian@tangent.org-20081006064729-2i9mhjkzyvow9xsm
RemoveĀ uint.

Show diffs side-by-side

added added

removed removed

Lines of Context:
356
356
{
357
357
  if ((args=(Item**) sql_alloc(sizeof(Item*)*arg_count)))
358
358
  {
359
 
    uint i=0;
 
359
    uint32_t i=0;
360
360
    List_iterator_fast<Item> li(list);
361
361
    Item *item;
362
362
 
422
422
void Item_sum::print(String *str, enum_query_type query_type)
423
423
{
424
424
  str->append(func_name());
425
 
  for (uint i=0 ; i < arg_count ; i++)
 
425
  for (uint32_t i=0 ; i < arg_count ; i++)
426
426
  {
427
427
    if (i)
428
428
      str->append(',');
434
434
void Item_sum::fix_num_length_and_dec()
435
435
{
436
436
  decimals=0;
437
 
  for (uint i=0 ; i < arg_count ; i++)
 
437
  for (uint32_t i=0 ; i < arg_count ; i++)
438
438
    set_if_bigger(decimals,args[i]->decimals);
439
439
  max_length=float_length(decimals);
440
440
}
445
445
  if (sum_item && sum_item->result_field)          // If not a const sum func
446
446
  {
447
447
    Field *result_field_tmp= sum_item->result_field;
448
 
    for (uint i=0 ; i < sum_item->arg_count ; i++)
 
448
    for (uint32_t i=0 ; i < sum_item->arg_count ; i++)
449
449
    {
450
450
      Item *arg= sum_item->args[i];
451
451
      if (!arg->const_item())
479
479
 
480
480
Field *Item_sum::create_tmp_field(bool group __attribute__((unused)),
481
481
                                  Table *table,
482
 
                                  uint convert_blob_length)
 
482
                                  uint32_t convert_blob_length)
483
483
{
484
484
  Field *field;
485
485
  switch (result_type()) {
518
518
  if (!forced_const)
519
519
  {
520
520
    used_tables_cache= 0;
521
 
    for (uint i=0 ; i < arg_count ; i++)
 
521
    for (uint32_t i=0 ; i < arg_count ; i++)
522
522
    {
523
523
      args[i]->update_used_tables();
524
524
      used_tables_cache|= args[i]->used_tables();
568
568
 
569
569
  decimals=0;
570
570
  maybe_null=0;
571
 
  for (uint i=0 ; i < arg_count ; i++)
 
571
  for (uint32_t i=0 ; i < arg_count ; i++)
572
572
  {
573
573
    if (args[i]->fix_fields(thd, args + i) || args[i]->check_cols(1))
574
574
      return true;
674
674
}
675
675
 
676
676
Field *Item_sum_hybrid::create_tmp_field(bool group, Table *table,
677
 
                                         uint convert_blob_length)
 
677
                                         uint32_t convert_blob_length)
678
678
{
679
679
  Field *field;
680
680
  if (args[0]->type() == Item::FIELD_ITEM)
854
854
 
855
855
static int simple_raw_key_cmp(void* arg, const void* key1, const void* key2)
856
856
{
857
 
    return memcmp(key1, key2, *(uint *) arg);
 
857
    return memcmp(key1, key2, *(uint32_t *) arg);
858
858
}
859
859
 
860
860
 
1214
1214
 
1215
1215
 
1216
1216
Field *Item_sum_avg::create_tmp_field(bool group, Table *table,
1217
 
                                      uint convert_blob_len __attribute__((unused)))
 
1217
                                      uint32_t convert_blob_len __attribute__((unused)))
1218
1218
{
1219
1219
  Field *field;
1220
1220
  if (group)
1424
1424
  pass around.
1425
1425
*/
1426
1426
Field *Item_sum_variance::create_tmp_field(bool group, Table *table,
1427
 
                                           uint convert_blob_len __attribute__((unused)))
 
1427
                                           uint32_t convert_blob_len __attribute__((unused)))
1428
1428
{
1429
1429
  Field *field;
1430
1430
  if (group)
2547
2547
    return true;
2548
2548
 
2549
2549
  /* Create a table with an unique key over all parameters */
2550
 
  for (uint i=0; i < arg_count ; i++)
 
2550
  for (uint32_t i=0; i < arg_count ; i++)
2551
2551
  {
2552
2552
    Item *item=args[i];
2553
2553
    if (list.push_back(item))
2758
2758
  Item_func_group_concat *item_func= (Item_func_group_concat*)arg;
2759
2759
  Table *table= item_func->table;
2760
2760
 
2761
 
  for (uint i= 0; i < item_func->arg_count_field; i++)
 
2761
  for (uint32_t i= 0; i < item_func->arg_count_field; i++)
2762
2762
  {
2763
2763
    Item *item= item_func->args[i];
2764
2764
    /* 
2774
2774
    */
2775
2775
    Field *field= item->get_tmp_table_field();
2776
2776
    int res;
2777
 
    uint offset= field->offset(field->table->record[0])-table->s->null_bytes;
 
2777
    uint32_t offset= field->offset(field->table->record[0])-table->s->null_bytes;
2778
2778
    if((res= field->cmp((unsigned char*)key1 + offset, (unsigned char*)key2 + offset)))
2779
2779
      return res;
2780
2780
  }
2811
2811
    if (field && !item->const_item())
2812
2812
    {
2813
2813
      int res;
2814
 
      uint offset= (field->offset(field->table->record[0]) -
 
2814
      uint32_t offset= (field->offset(field->table->record[0]) -
2815
2815
                    table->s->null_bytes);
2816
2816
      if ((res= field->cmp((unsigned char*)key1 + offset, (unsigned char*)key2 + offset)))
2817
2817
        return (*order_item)->asc ? res : -res;
2839
2839
  String tmp2;
2840
2840
  String *result= &item->result;
2841
2841
  Item **arg= item->args, **arg_end= item->args + item->arg_count_field;
2842
 
  uint old_length= result->length();
 
2842
  uint32_t old_length= result->length();
2843
2843
 
2844
2844
  if (item->no_appended)
2845
2845
    item->no_appended= false;
2861
2861
        because it contains both order and arg list fields.
2862
2862
      */
2863
2863
      Field *field= (*arg)->get_tmp_table_field();
2864
 
      uint offset= (field->offset(field->table->record[0]) -
 
2864
      uint32_t offset= (field->offset(field->table->record[0]) -
2865
2865
                    table->s->null_bytes);
2866
2866
      assert(offset < table->s->reclength);
2867
2867
      res= field->val_str(&tmp, key + offset);
2878
2878
    int well_formed_error;
2879
2879
    const CHARSET_INFO * const cs= item->collation.collation;
2880
2880
    const char *ptr= result->ptr();
2881
 
    uint add_length;
 
2881
    uint32_t add_length;
2882
2882
    /*
2883
2883
      It's ok to use item->result.length() as the fourth argument
2884
2884
      as this is never used to limit the length of the data.
3064
3064
  copy_fields(tmp_table_param);
3065
3065
  copy_funcs(tmp_table_param->items_to_copy);
3066
3066
 
3067
 
  for (uint i= 0; i < arg_count_field; i++)
 
3067
  for (uint32_t i= 0; i < arg_count_field; i++)
3068
3068
  {
3069
3069
    Item *show_item= args[i];
3070
3070
    if (!show_item->const_item())
3081
3081
  if (distinct) 
3082
3082
  {
3083
3083
    /* Filter out duplicate rows. */
3084
 
    uint count= unique_filter->elements_in_tree();
 
3084
    uint32_t count= unique_filter->elements_in_tree();
3085
3085
    unique_filter->unique_add(table->record[0] + table->s->null_bytes);
3086
3086
    if (count == unique_filter->elements_in_tree())
3087
3087
      row_eligible= false;
3107
3107
bool
3108
3108
Item_func_group_concat::fix_fields(THD *thd, Item **ref)
3109
3109
{
3110
 
  uint i;                       /* for loop variable */
 
3110
  uint32_t i;                       /* for loop variable */
3111
3111
  assert(fixed == 0);
3112
3112
 
3113
3113
  if (init_sum_func_check(thd))
3144
3144
                                  collation.collation, &offset))
3145
3145
  {
3146
3146
    uint32_t buflen= collation.collation->mbmaxlen * separator->length();
3147
 
    uint errors, conv_length;
 
3147
    uint32_t errors, conv_length;
3148
3148
    char *buf;
3149
3149
    String *new_separator;
3150
3150
 
3188
3188
                                        collation.collation->mbmaxlen;
3189
3189
  /* Push all not constant fields to the list and create a temp table */
3190
3190
  always_null= 0;
3191
 
  for (uint i= 0; i < arg_count_field; i++)
 
3191
  for (uint32_t i= 0; i < arg_count_field; i++)
3192
3192
  {
3193
3193
    Item *item= args[i];
3194
3194
    if (list.push_back(item))
3249
3249
     Don't reserve space for NULLs: if any of gconcat arguments is NULL,
3250
3250
     the row is not added to the result.
3251
3251
  */
3252
 
  uint tree_key_length= table->s->reclength - table->s->null_bytes;
 
3252
  uint32_t tree_key_length= table->s->reclength - table->s->null_bytes;
3253
3253
 
3254
3254
  if (arg_count_order)
3255
3255
  {
3316
3316
  str->append(STRING_WITH_LEN("group_concat("));
3317
3317
  if (distinct)
3318
3318
    str->append(STRING_WITH_LEN("distinct "));
3319
 
  for (uint i= 0; i < arg_count_field; i++)
 
3319
  for (uint32_t i= 0; i < arg_count_field; i++)
3320
3320
  {
3321
3321
    if (i)
3322
3322
      str->append(',');
3325
3325
  if (arg_count_order)
3326
3326
  {
3327
3327
    str->append(STRING_WITH_LEN(" order by "));
3328
 
    for (uint i= 0 ; i < arg_count_order ; i++)
 
3328
    for (uint32_t i= 0 ; i < arg_count_order ; i++)
3329
3329
    {
3330
3330
      if (i)
3331
3331
        str->append(',');