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 #pragma once 00021 00022 #include <drizzled/function/func.h> 00023 00024 00025 namespace drizzled 00026 { 00027 00028 /* 00029 Objects of this class are used for ROLLUP queries to wrap up 00030 each constant item referred to in GROUP BY list. 00031 */ 00032 00033 class Item_func_rollup_const :public Item_func 00034 { 00035 public: 00036 Item_func_rollup_const(Item *a) :Item_func(a) 00037 { 00038 name= a->name; 00039 name_length= a->name_length; 00040 } 00041 double val_real() { return args[0]->val_real(); } 00042 int64_t val_int() { return args[0]->val_int(); } 00043 String *val_str(String *str) { return args[0]->val_str(str); } 00044 type::Decimal *val_decimal(type::Decimal *dec) { return args[0]->val_decimal(dec); } 00045 const char *func_name() const { return "rollup_const"; } 00046 bool const_item() const { return 0; } 00047 Item_result result_type() const { return args[0]->result_type(); } 00048 void fix_length_and_dec() 00049 { 00050 collation= args[0]->collation; 00051 max_length= args[0]->max_length; 00052 decimals=args[0]->decimals; 00053 /* The item could be a NULL constant. */ 00054 null_value= args[0]->is_null(); 00055 } 00056 }; 00057 00058 } /* namespace drizzled */ 00059