~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item_strfunc.h

  • Committer: Brian Aker
  • Date: 2008-09-04 19:31:00 UTC
  • Revision ID: brian@tangent.org-20080904193100-l849hgghfy4urj43
Changing default character set from this point on.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
 */
 
1
/* Copyright (C) 2000-2003 MySQL AB
 
2
 
 
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.
 
6
 
 
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.
 
11
 
 
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 */
19
15
 
20
16
 
21
17
/* This file defines all string functions */
22
18
 
 
19
#ifdef USE_PRAGMA_INTERFACE
 
20
#pragma interface                       /* gcc class implementation */
 
21
#endif
23
22
 
24
23
class Item_str_func :public Item_func
25
24
{
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);
40
39
};
41
40
 
42
41
 
100
99
class Item_str_conv :public Item_str_func
101
100
{
102
101
protected:
103
 
  uint32_t multiply;
 
102
  uint multiply;
104
103
  my_charset_conv_case converter;
105
104
  String tmp_value;
106
105
public:
221
220
    call
222
221
  */
223
222
  virtual const char *fully_qualified_func_name() const = 0;
224
 
  bool check_vcol_func_processor(unsigned char *int_arg __attribute__((unused)))
225
 
  { return true; }
226
223
};
227
224
 
228
225
 
256
253
    assert(fixed == 1);
257
254
    return (null_value ? 0 : &str_value);
258
255
  }
259
 
  bool fix_fields(Session *session, Item **ref);
 
256
  bool fix_fields(THD *thd, Item **ref);
260
257
  void fix_length_and_dec()
261
258
  {
262
259
    max_length= (USERNAME_CHAR_LENGTH + HOSTNAME_LENGTH + 1) *
279
276
public:
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()"; }
285
282
};
316
313
public:
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)
320
317
  {
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));
325
322
  }
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"; }
330
327
 
331
 
  bool walk(Item_processor processor, bool walk_subquery, unsigned char *arg)
 
328
  bool walk(Item_processor processor, bool walk_subquery, uchar *arg)
332
329
  {
333
330
    return item->walk(processor, walk_subquery, arg) ||
334
331
      Item_str_func::walk(processor, walk_subquery, arg);
335
332
  }
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);
338
335
};
339
336
 
487
484
    maybe_null=1;
488
485
    max_length=MAX_BLOB_WIDTH;
489
486
  }
490
 
  bool check_vcol_func_processor(unsigned char *int_arg __attribute__((unused)))
491
 
  { return true; }
492
487
};
493
488
 
494
489
 
532
527
    conv_charset= cs;
533
528
    if (cache_if_const && args[0]->const_item())
534
529
    {
535
 
      uint32_t errors= 0;
 
530
      uint errors= 0;
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
612
607
{
613
608
  String tmp_value;
614
 
  uint32_t flags;
615
 
  uint32_t nweights;
 
609
  uint flags;
 
610
  uint nweights;
616
611
public:
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();
622
 
  /*
623
 
    TODO: Currently this Item is not allowed for virtual columns
624
 
    only due to a bug in generating virtual column value.
625
 
  */
626
 
  bool check_vcol_func_processor(unsigned char *int_arg __attribute__((unused)))
627
 
  { return true; }
 
617
};
 
618
 
 
619
class Item_func_uncompressed_length : public Item_int_func
 
620
{
 
621
  String value;
 
622
public:
 
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; }
 
626
  int64_t val_int();
 
627
};
 
628
 
 
629
#ifdef HAVE_COMPRESS
 
630
#define ZLIB_DEPENDED_FUNCTION ;
 
631
#else
 
632
#define ZLIB_DEPENDED_FUNCTION { null_value=1; return 0; }
 
633
#endif
 
634
 
 
635
class Item_func_compress: public Item_str_func
 
636
{
 
637
  String buffer;
 
638
public:
 
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
 
643
};
 
644
 
 
645
class Item_func_uncompress: public Item_str_func
 
646
{
 
647
  String buffer;
 
648
public:
 
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
628
653
};
629
654
 
630
655
#define UUID_LENGTH (8+1+4+1+4+1+4+1+12)
643
668
  }
644
669
  const char *func_name() const{ return "uuid"; }
645
670
  String *val_str(String *);
646
 
  bool check_vcol_func_processor(unsigned char *int_arg __attribute__((unused)))
647
 
  { return true; }
648
671
};
649
672