~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item_sum.cc

Merged build changes from Antony.

Show diffs side-by-side

added added

removed removed

Lines of Context:
481
481
}
482
482
 
483
483
 
484
 
Field *Item_sum::create_tmp_field(bool group __attribute__((__unused__)),
 
484
Field *Item_sum::create_tmp_field(bool group __attribute__((unused)),
485
485
                                  TABLE *table,
486
486
                                  uint convert_blob_length)
487
487
{
696
696
    fields creations separately.
697
697
  */
698
698
  switch (args[0]->field_type()) {
699
 
  case MYSQL_TYPE_NEWDATE:
 
699
  case DRIZZLE_TYPE_NEWDATE:
700
700
    field= new Field_newdate(maybe_null, name, collation.collation);
701
701
    break;
702
 
  case MYSQL_TYPE_TIME:
 
702
  case DRIZZLE_TYPE_TIME:
703
703
    field= new Field_time(maybe_null, name, collation.collation);
704
704
    break;
705
 
  case MYSQL_TYPE_TIMESTAMP:
706
 
  case MYSQL_TYPE_DATETIME:
 
705
  case DRIZZLE_TYPE_TIMESTAMP:
 
706
  case DRIZZLE_TYPE_DATETIME:
707
707
    field= new Field_datetime(maybe_null, name, collation.collation);
708
708
    break;
709
709
  default:
861
861
 
862
862
 
863
863
static int item_sum_distinct_walk(void *element,
864
 
                                  element_count num_of_dups __attribute__((__unused__)),
 
864
                                  element_count num_of_dups __attribute__((unused)),
865
865
                                  void *item)
866
866
{
867
867
  return ((Item_sum_distinct*) (item))->unique_walk_function(element);
936
936
  case STRING_RESULT:
937
937
  case REAL_RESULT:
938
938
    val.traits= Hybrid_type_traits::instance();
939
 
    table_field_type= MYSQL_TYPE_DOUBLE;
 
939
    table_field_type= DRIZZLE_TYPE_DOUBLE;
940
940
    break;
941
941
  case INT_RESULT:
942
942
  /*
946
946
    calculations. The range of int64 is enough to hold sum 2^32 distinct
947
947
    integers each <= 2^32.
948
948
  */
949
 
  if (table_field_type >= MYSQL_TYPE_TINY && table_field_type <= MYSQL_TYPE_LONG)
 
949
  if (table_field_type >= DRIZZLE_TYPE_TINY && table_field_type <= DRIZZLE_TYPE_LONG)
950
950
  {
951
951
    val.traits= Hybrid_type_traits_fast_decimal::instance();
952
952
    break;
953
953
  }
954
 
  table_field_type= MYSQL_TYPE_LONGLONG;
 
954
  table_field_type= DRIZZLE_TYPE_LONGLONG;
955
955
  /* fallthrough */
956
956
  case DECIMAL_RESULT:
957
957
    val.traits= Hybrid_type_traits_decimal::instance();
958
 
    if (table_field_type != MYSQL_TYPE_LONGLONG)
959
 
      table_field_type= MYSQL_TYPE_NEWDECIMAL;
 
958
    if (table_field_type != DRIZZLE_TYPE_LONGLONG)
 
959
      table_field_type= DRIZZLE_TYPE_NEWDECIMAL;
960
960
    break;
961
961
  case ROW_RESULT:
962
962
  default:
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
                                      uint 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
                                           uint convert_blob_len __attribute__((unused)))
1428
1428
{
1429
1429
  Field *field;
1430
1430
  if (group)
1504
1504
  nr= args[0]->val_real();              /* sets null_value as side-effect */
1505
1505
 
1506
1506
  if (args[0]->null_value)
1507
 
    bzero(res,sizeof(double)*2+sizeof(int64_t));
 
1507
    memset(res, 0, sizeof(double)*2+sizeof(int64_t));
1508
1508
  else
1509
1509
  {
1510
1510
    /* Serialize format is (double)m, (double)s, (int64_t)count */
2039
2039
    double nr= args[0]->val_real();
2040
2040
 
2041
2041
    if (args[0]->null_value)
2042
 
      bzero(res,sizeof(double)+sizeof(int64_t));
 
2042
      memset(res, 0, sizeof(double)+sizeof(int64_t));
2043
2043
    else
2044
2044
    {
2045
2045
      int64_t tmp= 1;
2447
2447
  Item_sum_count_distinct* item = (Item_sum_count_distinct*)arg;
2448
2448
  Field **field    = item->table->field;
2449
2449
  Field **field_end= field + item->table->s->fields;
2450
 
  uint32 *lengths=item->field_lengths;
 
2450
  uint32_t *lengths=item->field_lengths;
2451
2451
  for (; field < field_end; ++field)
2452
2452
  {
2453
2453
    Field* f = *field;
2464
2464
 
2465
2465
C_MODE_START
2466
2466
 
2467
 
static int count_distinct_walk(void *elem __attribute__((__unused__)),
2468
 
                               element_count count __attribute__((__unused__)),
 
2467
static int count_distinct_walk(void *elem __attribute__((unused)),
 
2468
                               element_count count __attribute__((unused)),
2469
2469
                               void *arg)
2470
2470
{
2471
2471
  (*((uint64_t*)arg))++;
2582
2582
      Field *f= *field;
2583
2583
      enum enum_field_types f_type= f->type();
2584
2584
      tree_key_length+= f->pack_length();
2585
 
      if ((f_type == MYSQL_TYPE_VARCHAR) || (!f->binary() && (f_type == MYSQL_TYPE_STRING)))
 
2585
      if ((f_type == DRIZZLE_TYPE_VARCHAR) || (!f->binary() && (f_type == DRIZZLE_TYPE_STRING)))
2586
2586
      {
2587
2587
        all_binary= false;
2588
2588
        break;
2609
2609
      }
2610
2610
      else
2611
2611
      {
2612
 
        uint32 *length;
 
2612
        uint32_t *length;
2613
2613
        compare_key= (qsort_cmp2) composite_key_cmp;
2614
2614
        cmp_arg= (void*) this;
2615
 
        field_lengths= (uint32*) thd->alloc(table->s->fields * sizeof(uint32));
 
2615
        field_lengths= (uint32_t*) thd->alloc(table->s->fields * sizeof(uint32_t));
2616
2616
        for (tree_key_length= 0, length= field_lengths, field= table->field;
2617
2617
             field < field_end; ++field, ++length)
2618
2618
        {
3288
3288
  null_value= 1;
3289
3289
  max_length= thd->variables.group_concat_max_len;
3290
3290
 
3291
 
  uint32 offset;
 
3291
  uint32_t offset;
3292
3292
  if (separator->needs_conversion(separator->length(), separator->charset(),
3293
3293
                                  collation.collation, &offset))
3294
3294
  {
3295
 
    uint32 buflen= collation.collation->mbmaxlen * separator->length();
 
3295
    uint32_t buflen= collation.collation->mbmaxlen * separator->length();
3296
3296
    uint errors, conv_length;
3297
3297
    char *buf;
3298
3298
    String *new_separator;
3436
3436
}
3437
3437
 
3438
3438
 
3439
 
String* Item_func_group_concat::val_str(String* str __attribute__((__unused__)))
 
3439
String* Item_func_group_concat::val_str(String* str __attribute__((unused)))
3440
3440
{
3441
3441
  assert(fixed == 1);
3442
3442
  if (null_value)