drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
set_user_var.h
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, Inc.
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
20#pragma once
21
22#include <drizzled/function/func.h>
23
24namespace drizzled {
25
26/* Handling of user definable variables */
27
28class Item_func_set_user_var : public Item_func
29{
30 enum Item_result cached_result_type;
31 user_var_entry *entry;
32 char buffer[MAX_FIELD_WIDTH];
33 String value;
34 type::Decimal decimal_buff;
35 bool null_item;
36 union
37 {
38 int64_t vint;
39 double vreal;
40 String *vstr;
41 type::Decimal *vdec;
42 } save_result;
43
44public:
45 str_ref name; // keep it public
46 Item_func_set_user_var(str_ref a,Item *b) :
47 Item_func(b), cached_result_type(INT_RESULT), name(a)
48 {}
49 Functype functype() const { return SUSERVAR_FUNC; }
50 double val_real();
51 int64_t val_int();
52 String *val_str(String *str);
54 double val_result();
55 int64_t val_int_result();
56 String *str_result(String *str);
57 type::Decimal *val_decimal_result(type::Decimal *);
58 void update_hash(data_ref, Item_result type, const charset_info_st* cs, Derivation dv, bool unsigned_arg);
59 void send(plugin::Client *client, String *str_arg);
60 void make_field(SendField *tmp_field);
61 bool check(bool use_result_field);
62 void update();
63 Item_result result_type () const { return cached_result_type; }
64 bool fix_fields(Session *session, Item **ref);
65 void fix_length_and_dec();
66 virtual void print(String *str);
67
68 const char *func_name() const { return "set_user_var"; }
69 int save_in_field(Field *field, bool no_conversions,
70 bool can_use_result_field);
71 int save_in_field(Field *field, bool no_conversions)
72 {
73 return save_in_field(field, no_conversions, 1);
74 }
75 void save_org_in_field(Field *field) { (void)save_in_field(field, 1, 0); }
76 bool register_field_in_read_map(unsigned char *arg);
77};
78
79} /* namespace drizzled */
80
String * val_str(String *str)
virtual void print(String *str)
type::Decimal * val_decimal(type::Decimal *)
bool check(bool use_result_field)
void send(plugin::Client *client, String *str_arg)
const char * name
Definition item.h:112
TODO: Rename this file - func.h is stupid.
Derivation
Definition enum.h:39