Drizzled Public API Documentation

num_op.cc

00001 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Copyright (C) 2008 Sun Microsystems, Inc.
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; version 2 of the License.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018  */
00019 
00020 #include <config.h>
00021 
00022 #include <cassert>
00023 
00024 #include <drizzled/function/num_op.h>
00025 
00026 namespace drizzled
00027 {
00028 
00034 void Item_num_op::find_num_type(void)
00035 {
00036   assert(arg_count == 2);
00037   Item_result r0= args[0]->result_type();
00038   Item_result r1= args[1]->result_type();
00039 
00040   if (r0 == REAL_RESULT || r1 == REAL_RESULT ||
00041       r0 == STRING_RESULT || r1 ==STRING_RESULT)
00042   {
00043     count_real_length();
00044     max_length= float_length(decimals);
00045     hybrid_type= REAL_RESULT;
00046   }
00047   else if (r0 == DECIMAL_RESULT || r1 == DECIMAL_RESULT)
00048   {
00049     hybrid_type= DECIMAL_RESULT;
00050     result_precision();
00051   }
00052   else
00053   {
00054     assert(r0 == INT_RESULT && r1 == INT_RESULT);
00055     decimals= 0;
00056     hybrid_type=INT_RESULT;
00057     result_precision();
00058   }
00059   return;
00060 }
00061 
00062 } /* namespace drizzled */