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/str/export_set.h>
24
String* Item_func_export_set::val_str(String* str)
27
uint64_t the_set = (uint64_t) args[0]->val_int();
29
yes = args[1]->val_str(&yes_buf);
31
no = args[2]->val_str(&no_buf);
32
String *sep = NULL, sep_buf ;
34
uint32_t num_set_values = 64;
37
str->set_charset(collation.collation);
39
/* Check if some argument is a NULL value */
40
if (args[0]->null_value || args[1]->null_value || args[2]->null_value)
46
Arg count can only be 3, 4 or 5 here. This is guaranteed from the
47
grammar for EXPORT_SET()
51
num_set_values = (uint) args[4]->val_int();
52
if (num_set_values > 64)
54
if (args[4]->null_value)
61
if (!(sep = args[3]->val_str(&sep_buf))) // Only true if NULL
69
/* errors is not checked - assume "," can always be converted */
71
sep_buf.copy(STRING_WITH_LEN(","), &my_charset_bin, collation.collation, &errors);
76
assert(0); // cannot happen
80
for (uint32_t i = 0; i < num_set_values; i++, mask = (mask << 1))
86
if (i != num_set_values - 1)
92
void Item_func_export_set::fix_length_and_dec()
94
uint32_t length=cmax(args[1]->max_length,args[2]->max_length);
95
uint32_t sep_length=(arg_count > 3 ? args[3]->max_length : 1);
96
max_length=length*64+sep_length*63;
98
if (agg_arg_charsets(collation, args+1, cmin((uint)4,arg_count)-1,
99
MY_COLL_ALLOW_CONV, 1))