~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item_strfunc.h

  • Committer: Mark Atwood
  • Date: 2008-10-16 11:33:16 UTC
  • mto: (520.1.13 drizzle)
  • mto: This revision was merged to the branch mainline in revision 530.
  • Revision ID: mark@fallenpegasus.com-20081016113316-ff6jdt31ck90sjdh
an implemention of the errmsg plugin

Show diffs side-by-side

added added

removed removed

Lines of Context:
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 */
 
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
 */
15
19
 
16
20
 
17
21
/* This file defines all string functions */
18
22
 
19
 
#ifdef USE_PRAGMA_INTERFACE
20
 
#pragma interface                       /* gcc class implementation */
21
 
#endif
22
23
 
23
24
class Item_str_func :public Item_func
24
25
{
99
100
class Item_str_conv :public Item_str_func
100
101
{
101
102
protected:
102
 
  uint multiply;
 
103
  uint32_t multiply;
103
104
  my_charset_conv_case converter;
104
105
  String tmp_value;
105
106
public:
220
221
    call
221
222
  */
222
223
  virtual const char *fully_qualified_func_name() const = 0;
 
224
  bool check_vcol_func_processor(unsigned char *int_arg __attribute__((unused)))
 
225
  { return true; }
223
226
};
224
227
 
225
228
 
325
328
  void update_used_tables();
326
329
  const char *func_name() const { return "make_set"; }
327
330
 
328
 
  bool walk(Item_processor processor, bool walk_subquery, uchar *arg)
 
331
  bool walk(Item_processor processor, bool walk_subquery, unsigned char *arg)
329
332
  {
330
333
    return item->walk(processor, walk_subquery, arg) ||
331
334
      Item_str_func::walk(processor, walk_subquery, arg);
332
335
  }
333
 
  Item *transform(Item_transformer transformer, uchar *arg);
 
336
  Item *transform(Item_transformer transformer, unsigned char *arg);
334
337
  virtual void print(String *str, enum_query_type query_type);
335
338
};
336
339
 
484
487
    maybe_null=1;
485
488
    max_length=MAX_BLOB_WIDTH;
486
489
  }
 
490
  bool check_vcol_func_processor(unsigned char *int_arg __attribute__((unused)))
 
491
  { return true; }
487
492
};
488
493
 
489
494
 
527
532
    conv_charset= cs;
528
533
    if (cache_if_const && args[0]->const_item())
529
534
    {
530
 
      uint errors= 0;
 
535
      uint32_t errors= 0;
531
536
      String tmp, *str= args[0]->val_str(&tmp);
532
537
      if (!str || str_value.copy(str->ptr(), str->length(),
533
538
                                 str->charset(), conv_charset, &errors))
606
611
class Item_func_weight_string :public Item_str_func
607
612
{
608
613
  String tmp_value;
609
 
  uint flags;
610
 
  uint nweights;
 
614
  uint32_t flags;
 
615
  uint32_t nweights;
611
616
public:
612
 
  Item_func_weight_string(Item *a, uint nweights_arg, uint flags_arg)
 
617
  Item_func_weight_string(Item *a, uint32_t nweights_arg, uint32_t flags_arg)
613
618
  :Item_str_func(a) { nweights= nweights_arg; flags= flags_arg; }
614
619
  const char *func_name() const { return "weight_string"; }
615
620
  String *val_str(String *);
616
621
  void fix_length_and_dec();
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
 
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; }
653
628
};
654
629
 
655
630
#define UUID_LENGTH (8+1+4+1+4+1+4+1+12)
668
643
  }
669
644
  const char *func_name() const{ return "uuid"; }
670
645
  String *val_str(String *);
 
646
  bool check_vcol_func_processor(unsigned char *int_arg __attribute__((unused)))
 
647
  { return true; }
671
648
};
672
649