~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/function/func.cc

fixed build warnings

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems
 
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
25
25
#include <drizzled/function/math/int.h>
26
26
#include <drizzled/field/int32.h>
27
27
#include <drizzled/field/int64.h>
 
28
#include <drizzled/field/decimal.h>
28
29
#include <drizzled/field/double.h>
29
 
#include <drizzled/field/decimal.h>
 
30
#include <drizzled/field/size.h>
30
31
#include <drizzled/session.h>
31
32
#include <drizzled/error.h>
32
33
#include <drizzled/check_stack_overrun.h>
61
62
 
62
63
Item_func::Item_func(List<Item> &list) :
63
64
  _session(*current_session),
64
 
  allowed_arg_cols(1)
 
65
  allowed_arg_cols(1),
 
66
  const_item_cache(false)
65
67
{
66
68
  collation.set(DERIVATION_SYSCONST);
67
69
  set_arguments(list);
133
135
  unsigned char buff[STACK_BUFF_ALLOC];      // Max argument in function
134
136
  session->session_marker= 0;
135
137
  used_tables_cache= not_null_tables_cache= 0;
136
 
  const_item_cache=1;
 
138
  const_item_cache= true;
137
139
 
138
140
  if (check_stack_overrun(session, STACK_MIN_SIZE, buff))
139
141
    return true;        // Fatal error if flag is set!
188
190
  Item **arg,**arg_end;
189
191
 
190
192
  used_tables_cache= not_null_tables_cache= 0;
191
 
  const_item_cache=1;
 
193
  const_item_cache= false;
192
194
 
193
195
  if (arg_count)
194
196
  {
353
355
void Item_func::update_used_tables()
354
356
{
355
357
  used_tables_cache=0;
356
 
  const_item_cache=1;
 
358
  const_item_cache= true;
357
359
  for (uint32_t i=0 ; i < arg_count ; i++)
358
360
  {
359
361
    args[i]->update_used_tables();
433
435
}
434
436
 
435
437
 
436
 
bool Item_func::get_arg0_date(DRIZZLE_TIME *ltime, uint32_t fuzzy_date)
 
438
bool Item_func::get_arg0_date(type::Time *ltime, uint32_t fuzzy_date)
437
439
{
438
440
  return (null_value=args[0]->get_date(ltime, fuzzy_date));
439
441
}
440
442
 
441
443
 
442
 
bool Item_func::get_arg0_time(DRIZZLE_TIME *ltime)
 
444
bool Item_func::get_arg0_time(type::Time *ltime)
443
445
{
444
 
  return (null_value=args[0]->get_time(ltime));
 
446
  return (null_value= args[0]->get_time(ltime));
445
447
}
446
448
 
447
449
 
458
460
 
459
461
  switch (result_type()) {
460
462
  case INT_RESULT:
461
 
    if (max_length > MY_INT32_NUM_DECIMAL_DIGITS)
462
 
      field= new field::Int64(max_length, maybe_null, name, unsigned_flag);
 
463
    if (unsigned_flag)
 
464
    {
 
465
      field= new field::Size(max_length, maybe_null, name, true);
 
466
    } 
 
467
    else if (max_length > MY_INT32_NUM_DECIMAL_DIGITS)
 
468
    {
 
469
      field= new field::Int64(max_length, maybe_null, name, false);
 
470
    }
463
471
    else
464
 
      field= new field::Int32(max_length, maybe_null, name, unsigned_flag);
 
472
    {
 
473
      field= new field::Int32(max_length, maybe_null, name, false);
 
474
    }
 
475
 
465
476
    break;
466
477
 
467
478
  case REAL_RESULT:
472
483
    return make_string_field(table);
473
484
 
474
485
  case DECIMAL_RESULT:
475
 
    field= new Field_decimal(my_decimal_precision_to_length(decimal_precision(),
 
486
    field= new Field_decimal(class_decimal_precision_to_length(decimal_precision(),
476
487
                                                            decimals,
477
488
                                                            unsigned_flag),
478
489
                             maybe_null,
493
504
}
494
505
 
495
506
 
496
 
my_decimal *Item_func::val_decimal(my_decimal *decimal_value)
 
507
type::Decimal *Item_func::val_decimal(type::Decimal *decimal_value)
497
508
{
498
509
  assert(fixed);
499
 
  int2my_decimal(E_DEC_FATAL_ERROR, val_int(), unsigned_flag, decimal_value);
 
510
  int2_class_decimal(E_DEC_FATAL_ERROR, val_int(), unsigned_flag, decimal_value);
500
511
  return decimal_value;
501
512
}
502
513
 
570
581
    set_if_smaller(unsigned_flag, args[i]->unsigned_flag);
571
582
  }
572
583
  int precision= min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
573
 
  max_length= my_decimal_precision_to_length(precision, decimals,
 
584
  max_length= class_decimal_precision_to_length(precision, decimals,
574
585
                                             unsigned_flag);
575
586
}
576
587