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
1
/* Copyright (C) 2000-2003 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
21
17
/* This file defines all string functions */
19
#ifdef USE_PRAGMA_INTERFACE
20
#pragma interface /* gcc class implementation */
24
23
class Item_str_func :public Item_func
36
35
my_decimal *val_decimal(my_decimal *);
37
36
enum Item_result result_type () const { return STRING_RESULT; }
38
37
void left_right_max_length();
39
bool fix_fields(Session *session, Item **ref);
38
bool fix_fields(THD *thd, Item **ref);
256
253
assert(fixed == 1);
257
254
return (null_value ? 0 : &str_value);
259
bool fix_fields(Session *session, Item **ref);
256
bool fix_fields(THD *thd, Item **ref);
260
257
void fix_length_and_dec()
262
259
max_length= (USERNAME_CHAR_LENGTH + HOSTNAME_LENGTH + 1) *
280
277
Item_func_current_user(Name_resolution_context *context_arg)
281
278
: context(context_arg) {}
282
bool fix_fields(Session *session, Item **ref);
279
bool fix_fields(THD *thd, Item **ref);
283
280
const char *func_name() const { return "current_user"; }
284
281
const char *fully_qualified_func_name() const { return "current_user()"; }
317
314
Item_func_make_set(Item *a,List<Item> &list) :Item_str_func(list),item(a) {}
318
315
String *val_str(String *str);
319
bool fix_fields(Session *session, Item **ref)
316
bool fix_fields(THD *thd, Item **ref)
321
318
assert(fixed == 0);
322
return ((!item->fixed && item->fix_fields(session, &item)) ||
319
return ((!item->fixed && item->fix_fields(thd, &item)) ||
323
320
item->check_cols(1) ||
324
Item_func::fix_fields(session, ref));
321
Item_func::fix_fields(thd, ref));
326
void split_sum_func(Session *session, Item **ref_pointer_array, List<Item> &fields);
323
void split_sum_func(THD *thd, Item **ref_pointer_array, List<Item> &fields);
327
324
void fix_length_and_dec();
328
325
void update_used_tables();
329
326
const char *func_name() const { return "make_set"; }
331
bool walk(Item_processor processor, bool walk_subquery, unsigned char *arg)
328
bool walk(Item_processor processor, bool walk_subquery, uchar *arg)
333
330
return item->walk(processor, walk_subquery, arg) ||
334
331
Item_str_func::walk(processor, walk_subquery, arg);
336
Item *transform(Item_transformer transformer, unsigned char *arg);
333
Item *transform(Item_transformer transformer, uchar *arg);
337
334
virtual void print(String *str, enum_query_type query_type);
532
527
conv_charset= cs;
533
528
if (cache_if_const && args[0]->const_item())
536
531
String tmp, *str= args[0]->val_str(&tmp);
537
532
if (!str || str_value.copy(str->ptr(), str->length(),
538
533
str->charset(), conv_charset, &errors))
611
606
class Item_func_weight_string :public Item_str_func
613
608
String tmp_value;
617
Item_func_weight_string(Item *a, uint32_t nweights_arg, uint32_t flags_arg)
612
Item_func_weight_string(Item *a, uint nweights_arg, uint flags_arg)
618
613
:Item_str_func(a) { nweights= nweights_arg; flags= flags_arg; }
619
614
const char *func_name() const { return "weight_string"; }
620
615
String *val_str(String *);
621
616
void fix_length_and_dec();
623
TODO: Currently this Item is not allowed for virtual columns
624
only due to a bug in generating virtual column value.
626
bool check_vcol_func_processor(unsigned char *int_arg __attribute__((unused)))
619
class Item_func_uncompressed_length : public Item_int_func
623
Item_func_uncompressed_length(Item *a):Item_int_func(a){}
624
const char *func_name() const{return "uncompressed_length";}
625
void fix_length_and_dec() { max_length=10; }
630
#define ZLIB_DEPENDED_FUNCTION ;
632
#define ZLIB_DEPENDED_FUNCTION { null_value=1; return 0; }
635
class Item_func_compress: public Item_str_func
639
Item_func_compress(Item *a):Item_str_func(a){}
640
void fix_length_and_dec(){max_length= (args[0]->max_length*120)/100+12;}
641
const char *func_name() const{return "compress";}
642
String *val_str(String *) ZLIB_DEPENDED_FUNCTION
645
class Item_func_uncompress: public Item_str_func
649
Item_func_uncompress(Item *a): Item_str_func(a){}
650
void fix_length_and_dec(){ maybe_null= 1; max_length= MAX_BLOB_WIDTH; }
651
const char *func_name() const{return "uncompress";}
652
String *val_str(String *) ZLIB_DEPENDED_FUNCTION
630
655
#define UUID_LENGTH (8+1+4+1+4+1+4+1+12)