1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems
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.
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.
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
20
#include <drizzled/server_includes.h>
22
#include <drizzled/functions/update_hash.h>
25
Set value to user variable.
27
@param entry pointer to structure representing variable
28
@param set_null should we set NULL value ?
29
@param ptr pointer to buffer with new value
30
@param length length of new value
31
@param type type of new value
32
@param cs charset info for new value
33
@param dv derivation for new value
34
@param unsigned_arg indiates if a value of type INT_RESULT is unsigned
36
@note Sets error and fatal error if allocation fails.
44
#define extra_size sizeof(double)
47
update_hash(user_var_entry *entry, bool set_null, void *ptr, uint32_t length,
48
Item_result type, const CHARSET_INFO * const cs, Derivation dv,
53
char *pos= (char*) entry+ ALIGN_SIZE(sizeof(user_var_entry));
54
if (entry->value && entry->value != pos)
61
if (type == STRING_RESULT)
62
length++; // Store strings with end \0
63
if (length <= extra_size)
65
/* Save value in value struct */
66
char *pos= (char*) entry+ ALIGN_SIZE(sizeof(user_var_entry));
67
if (entry->value != pos)
76
/* Allocate variable */
77
if (entry->length != length)
79
char *pos= (char*) entry+ ALIGN_SIZE(sizeof(user_var_entry));
80
if (entry->value == pos)
82
entry->value= (char*) my_realloc(entry->value, length,
83
MYF(MY_ALLOW_ZERO_PTR | MY_WME |
89
if (type == STRING_RESULT)
91
length--; // Fix length change above
92
entry->value[length]= 0; // Store end \0
94
memcpy(entry->value,ptr,length);
95
if (type == DECIMAL_RESULT)
96
((my_decimal*)entry->value)->fix_buffer_pointer();
97
entry->length= length;
98
entry->collation.set(cs, dv);
99
entry->unsigned_flag= unsigned_arg;