~drizzle-trunk/drizzle/development

492.3.35 by Lee
more changes to move functions from item_func.cc/h to the functions directory
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
4
 *  Copyright (C) 2008 Sun Microsystems
5
 *
6
 *  This program is free software; you can redistribute it and/or modify
7
 *  it under the terms of the GNU General Public License as published by
8
 *  the Free Software Foundation; version 2 of the License.
9
 *
10
 *  This program is distributed in the hope that it will be useful,
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 *  GNU General Public License for more details.
14
 *
15
 *  You should have received a copy of the GNU General Public License
16
 *  along with this program; if not, write to the Free Software
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 */
19
670.1.20 by Monty Taylor
Renamed functions to function... everything else is singular.
20
#ifndef DRIZZLED_FUNCTION_SET_USER_VAR_H
21
#define DRIZZLED_FUNCTION_SET_USER_VAR_H
492.3.35 by Lee
more changes to move functions from item_func.cc/h to the functions directory
22
670.1.20 by Monty Taylor
Renamed functions to function... everything else is singular.
23
#include <drizzled/function/func.h>
492.3.35 by Lee
more changes to move functions from item_func.cc/h to the functions directory
24
25
/* Handling of user definable variables */
26
27
class user_var_entry;
28
29
class Item_func_set_user_var :public Item_func
30
{
31
  enum Item_result cached_result_type;
32
  user_var_entry *entry;
33
  char buffer[MAX_FIELD_WIDTH];
34
  String value;
35
  my_decimal decimal_buff;
36
  bool null_item;
37
  union
38
  {
39
    int64_t vint;
40
    double vreal;
41
    String *vstr;
42
    my_decimal *vdec;
43
  } save_result;
44
45
public:
46
  LEX_STRING name; // keep it public
47
  Item_func_set_user_var(LEX_STRING a,Item *b)
48
    :Item_func(b), cached_result_type(INT_RESULT), name(a)
49
  {}
50
  enum Functype functype() const { return SUSERVAR_FUNC; }
51
  double val_real();
52
  int64_t val_int();
53
  String *val_str(String *str);
54
  my_decimal *val_decimal(my_decimal *);
55
  double val_result();
56
  int64_t val_int_result();
57
  String *str_result(String *str);
58
  my_decimal *val_decimal_result(my_decimal *);
59
  bool update_hash(void *ptr, uint32_t length, enum Item_result type,
60
  		   const CHARSET_INFO * const cs, Derivation dv, bool unsigned_arg);
61
  bool send(Protocol *protocol, String *str_arg);
62
  void make_field(Send_field *tmp_field);
63
  bool check(bool use_result_field);
64
  bool update();
65
  enum Item_result result_type () const { return cached_result_type; }
66
  bool fix_fields(Session *session, Item **ref);
67
  void fix_length_and_dec();
68
  virtual void print(String *str, enum_query_type query_type);
69
  void print_as_stmt(String *str, enum_query_type query_type);
70
  const char *func_name() const { return "set_user_var"; }
71
  int save_in_field(Field *field, bool no_conversions,
72
                    bool can_use_result_field);
73
  int save_in_field(Field *field, bool no_conversions)
74
  {
75
    return save_in_field(field, no_conversions, 1);
76
  }
77
  void save_org_in_field(Field *field) { (void)save_in_field(field, 1, 0); }
78
  bool register_field_in_read_map(unsigned char *arg);
79
};
80
670.1.20 by Monty Taylor
Renamed functions to function... everything else is singular.
81
#endif /* DRIZZLED_FUNCTION_SET_USER_VAR_H */