00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifdef __GNUC__
00021 #pragma interface
00022 #endif
00023
00024 class Item_str_func :public Item_func
00025 {
00026 public:
00027 Item_str_func() :Item_func() { decimals=NOT_FIXED_DEC; }
00028 Item_str_func(Item *a) :Item_func(a) {decimals=NOT_FIXED_DEC; }
00029 Item_str_func(Item *a,Item *b) :Item_func(a,b) { decimals=NOT_FIXED_DEC; }
00030 Item_str_func(Item *a,Item *b,Item *c) :Item_func(a,b,c) { decimals=NOT_FIXED_DEC; }
00031 Item_str_func(Item *a,Item *b,Item *c,Item *d) :Item_func(a,b,c,d) {decimals=NOT_FIXED_DEC; }
00032 Item_str_func(Item *a,Item *b,Item *c,Item *d, Item* e) :Item_func(a,b,c,d,e) {decimals=NOT_FIXED_DEC; }
00033 Item_str_func(List<Item> &list) :Item_func(list) {decimals=NOT_FIXED_DEC; }
00034 longlong val_int();
00035 double val_real();
00036 enum Item_result result_type () const { return STRING_RESULT; }
00037 void left_right_max_length();
00038 };
00039
00040 class Item_func_md5 :public Item_str_func
00041 {
00042 String tmp_value;
00043 public:
00044 Item_func_md5(Item *a) :Item_str_func(a) {}
00045 String *val_str(String *);
00046 void fix_length_and_dec();
00047 const char *func_name() const { return "md5"; }
00048 };
00049
00050
00051 class Item_func_sha :public Item_str_func
00052 {
00053 public:
00054 Item_func_sha(Item *a) :Item_str_func(a) {}
00055 String *val_str(String *);
00056 void fix_length_and_dec();
00057 const char *func_name() const { return "sha"; }
00058 };
00059
00060 class Item_func_aes_encrypt :public Item_str_func
00061 {
00062 public:
00063 Item_func_aes_encrypt(Item *a, Item *b) :Item_str_func(a,b) {}
00064 String *val_str(String *);
00065 void fix_length_and_dec();
00066 const char *func_name() const { return "aes_encrypt"; }
00067 };
00068
00069 class Item_func_aes_decrypt :public Item_str_func
00070 {
00071 public:
00072 Item_func_aes_decrypt(Item *a, Item *b) :Item_str_func(a,b) {}
00073 String *val_str(String *);
00074 void fix_length_and_dec();
00075 const char *func_name() const { return "aes_decrypt"; }
00076 };
00077
00078
00079 class Item_func_concat :public Item_str_func
00080 {
00081 String tmp_value;
00082 public:
00083 Item_func_concat(List<Item> &list) :Item_str_func(list) {}
00084 Item_func_concat(Item *a,Item *b) :Item_str_func(a,b) {}
00085 String *val_str(String *);
00086 void fix_length_and_dec();
00087 const char *func_name() const { return "concat"; }
00088 };
00089
00090 class Item_func_concat_ws :public Item_str_func
00091 {
00092 String tmp_value;
00093 public:
00094 Item_func_concat_ws(List<Item> &list) :Item_str_func(list) {}
00095 String *val_str(String *);
00096 void fix_length_and_dec();
00097 const char *func_name() const { return "concat_ws"; }
00098 };
00099
00100 class Item_func_reverse :public Item_str_func
00101 {
00102 public:
00103 Item_func_reverse(Item *a) :Item_str_func(a) {}
00104 String *val_str(String *);
00105 void fix_length_and_dec();
00106 const char *func_name() const { return "reverse"; }
00107 };
00108
00109
00110 class Item_func_replace :public Item_str_func
00111 {
00112 String tmp_value,tmp_value2;
00113 public:
00114 Item_func_replace(Item *org,Item *find,Item *replace)
00115 :Item_str_func(org,find,replace) {}
00116 String *val_str(String *);
00117 void fix_length_and_dec();
00118 const char *func_name() const { return "replace"; }
00119 };
00120
00121
00122 class Item_func_insert :public Item_str_func
00123 {
00124 String tmp_value;
00125 public:
00126 Item_func_insert(Item *org,Item *start,Item *length,Item *new_str)
00127 :Item_str_func(org,start,length,new_str) {}
00128 String *val_str(String *);
00129 void fix_length_and_dec();
00130 const char *func_name() const { return "insert"; }
00131 };
00132
00133
00134 class Item_str_conv :public Item_str_func
00135 {
00136 public:
00137 Item_str_conv(Item *item) :Item_str_func(item) {}
00138 void fix_length_and_dec()
00139 {
00140 collation.set(args[0]->collation);
00141 max_length = args[0]->max_length;
00142 }
00143 };
00144
00145
00146 class Item_func_lcase :public Item_str_conv
00147 {
00148 public:
00149 Item_func_lcase(Item *item) :Item_str_conv(item) {}
00150 String *val_str(String *);
00151 const char *func_name() const { return "lcase"; }
00152 };
00153
00154 class Item_func_ucase :public Item_str_conv
00155 {
00156 public:
00157 Item_func_ucase(Item *item) :Item_str_conv(item) {}
00158 String *val_str(String *);
00159 const char *func_name() const { return "ucase"; }
00160 };
00161
00162
00163 class Item_func_left :public Item_str_func
00164 {
00165 public:
00166 Item_func_left(Item *a,Item *b) :Item_str_func(a,b) {}
00167 String *val_str(String *);
00168 void fix_length_and_dec();
00169 const char *func_name() const { return "left"; }
00170 };
00171
00172
00173 class Item_func_right :public Item_str_func
00174 {
00175 String tmp_value;
00176 public:
00177 Item_func_right(Item *a,Item *b) :Item_str_func(a,b) {}
00178 String *val_str(String *);
00179 void fix_length_and_dec();
00180 const char *func_name() const { return "right"; }
00181 };
00182
00183
00184 class Item_func_substr :public Item_str_func
00185 {
00186 String tmp_value;
00187 public:
00188 Item_func_substr(Item *a,Item *b) :Item_str_func(a,b) {}
00189 Item_func_substr(Item *a,Item *b,Item *c) :Item_str_func(a,b,c) {}
00190 String *val_str(String *);
00191 void fix_length_and_dec();
00192 const char *func_name() const { return "substr"; }
00193 };
00194
00195
00196 class Item_func_substr_index :public Item_str_func
00197 {
00198 String tmp_value;
00199 public:
00200 Item_func_substr_index(Item *a,Item *b,Item *c) :Item_str_func(a,b,c) {}
00201 String *val_str(String *);
00202 void fix_length_and_dec();
00203 const char *func_name() const { return "substring_index"; }
00204 };
00205
00206
00207 class Item_func_trim :public Item_str_func
00208 {
00209 protected:
00210 String tmp_value;
00211 String remove;
00212 public:
00213 Item_func_trim(Item *a,Item *b) :Item_str_func(a,b) {}
00214 Item_func_trim(Item *a) :Item_str_func(a) {}
00215 String *val_str(String *);
00216 void fix_length_and_dec();
00217 const char *func_name() const { return "trim"; }
00218 };
00219
00220
00221 class Item_func_ltrim :public Item_func_trim
00222 {
00223 public:
00224 Item_func_ltrim(Item *a,Item *b) :Item_func_trim(a,b) {}
00225 Item_func_ltrim(Item *a) :Item_func_trim(a) {}
00226 String *val_str(String *);
00227 const char *func_name() const { return "ltrim"; }
00228 };
00229
00230
00231 class Item_func_rtrim :public Item_func_trim
00232 {
00233 public:
00234 Item_func_rtrim(Item *a,Item *b) :Item_func_trim(a,b) {}
00235 Item_func_rtrim(Item *a) :Item_func_trim(a) {}
00236 String *val_str(String *);
00237 const char *func_name() const { return "rtrim"; }
00238 };
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249 class Item_func_password :public Item_str_func
00250 {
00251 char tmp_value[SCRAMBLED_PASSWORD_CHAR_LENGTH+1];
00252 public:
00253 Item_func_password(Item *a) :Item_str_func(a) {}
00254 String *val_str(String *str);
00255 void fix_length_and_dec() { max_length= SCRAMBLED_PASSWORD_CHAR_LENGTH; }
00256 const char *func_name() const { return "password"; }
00257 static char *alloc(THD *thd, const char *password);
00258 };
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268 class Item_func_old_password :public Item_str_func
00269 {
00270 char tmp_value[SCRAMBLED_PASSWORD_CHAR_LENGTH_323+1];
00271 public:
00272 Item_func_old_password(Item *a) :Item_str_func(a) {}
00273 String *val_str(String *str);
00274 void fix_length_and_dec() { max_length= SCRAMBLED_PASSWORD_CHAR_LENGTH_323; }
00275 const char *func_name() const { return "old_password"; }
00276 static char *alloc(THD *thd, const char *password);
00277 };
00278
00279
00280 class Item_func_des_encrypt :public Item_str_func
00281 {
00282 String tmp_value;
00283 public:
00284 Item_func_des_encrypt(Item *a) :Item_str_func(a) {}
00285 Item_func_des_encrypt(Item *a, Item *b): Item_str_func(a,b) {}
00286 String *val_str(String *);
00287 void fix_length_and_dec()
00288 { maybe_null=1; max_length = args[0]->max_length+8; }
00289 const char *func_name() const { return "des_encrypt"; }
00290 };
00291
00292 class Item_func_des_decrypt :public Item_str_func
00293 {
00294 String tmp_value;
00295 public:
00296 Item_func_des_decrypt(Item *a) :Item_str_func(a) {}
00297 Item_func_des_decrypt(Item *a, Item *b): Item_str_func(a,b) {}
00298 String *val_str(String *);
00299 void fix_length_and_dec() { maybe_null=1; max_length = args[0]->max_length; }
00300 const char *func_name() const { return "des_decrypt"; }
00301 };
00302
00303 class Item_func_encrypt :public Item_str_func
00304 {
00305 String tmp_value;
00306 public:
00307 Item_func_encrypt(Item *a) :Item_str_func(a) {}
00308 Item_func_encrypt(Item *a, Item *b): Item_str_func(a,b) {}
00309 String *val_str(String *);
00310 void fix_length_and_dec() { maybe_null=1; max_length = 13; }
00311 const char *func_name() const { return "ecrypt"; }
00312 };
00313
00314 #include "sql_crypt.h"
00315
00316
00317 class Item_func_encode :public Item_str_func
00318 {
00319 protected:
00320 SQL_CRYPT sql_crypt;
00321 public:
00322 Item_func_encode(Item *a, char *seed):
00323 Item_str_func(a),sql_crypt(seed) {}
00324 String *val_str(String *);
00325 void fix_length_and_dec();
00326 const char *func_name() const { return "encode"; }
00327 };
00328
00329
00330 class Item_func_decode :public Item_func_encode
00331 {
00332 public:
00333 Item_func_decode(Item *a, char *seed): Item_func_encode(a,seed) {}
00334 String *val_str(String *);
00335 const char *func_name() const { return "decode"; }
00336 };
00337
00338
00339 class Item_func_database :public Item_str_func
00340 {
00341 public:
00342 Item_func_database() { collation.set(system_charset_info,DERIVATION_IMPLICIT); }
00343 String *val_str(String *);
00344 void fix_length_and_dec()
00345 {
00346 max_length= MAX_FIELD_NAME * system_charset_info->mbmaxlen;
00347 maybe_null=1;
00348 }
00349 const char *func_name() const { return "database"; }
00350 };
00351
00352 class Item_func_user :public Item_str_func
00353 {
00354 public:
00355 Item_func_user() { collation.set(system_charset_info, DERIVATION_IMPLICIT); }
00356 String *val_str(String *);
00357 void fix_length_and_dec()
00358 {
00359 max_length= (USERNAME_LENGTH+HOSTNAME_LENGTH+1)*system_charset_info->mbmaxlen;
00360 }
00361 const char *func_name() const { return "user"; }
00362 };
00363
00364
00365 class Item_func_soundex :public Item_str_func
00366 {
00367 String tmp_value;
00368 public:
00369 Item_func_soundex(Item *a) :Item_str_func(a) {}
00370 String *val_str(String *);
00371 void fix_length_and_dec();
00372 const char *func_name() const { return "soundex"; }
00373 };
00374
00375
00376 class Item_func_elt :public Item_str_func
00377 {
00378 public:
00379 Item_func_elt(List<Item> &list) :Item_str_func(list) {}
00380 double val_real();
00381 longlong val_int();
00382 String *val_str(String *str);
00383 void fix_length_and_dec();
00384 const char *func_name() const { return "elt"; }
00385 };
00386
00387
00388 class Item_func_make_set :public Item_str_func
00389 {
00390 Item *item;
00391 String tmp_str;
00392
00393 public:
00394 Item_func_make_set(Item *a,List<Item> &list) :Item_str_func(list),item(a) {}
00395 String *val_str(String *str);
00396 bool fix_fields(THD *thd, TABLE_LIST *tlist, Item **ref)
00397 {
00398 DBUG_ASSERT(fixed == 0);
00399 return (item->fix_fields(thd, tlist, &item) ||
00400 item->check_cols(1) ||
00401 Item_func::fix_fields(thd, tlist, ref));
00402 }
00403 void split_sum_func(THD *thd, Item **ref_pointer_array, List<Item> &fields);
00404 void fix_length_and_dec();
00405 void update_used_tables();
00406 const char *func_name() const { return "make_set"; }
00407
00408 bool walk(Item_processor processor, byte *arg)
00409 {
00410 return item->walk(processor, arg) ||
00411 Item_str_func::walk(processor, arg);
00412 }
00413 Item *transform(Item_transformer transformer, byte *arg)
00414 {
00415 Item *new_item= item->transform(transformer, arg);
00416 if (!new_item)
00417 return 0;
00418 item= new_item;
00419 return Item_str_func::transform(transformer, arg);
00420 }
00421 void print(String *str);
00422 };
00423
00424
00425 class Item_func_format :public Item_str_func
00426 {
00427 String tmp_str;
00428 public:
00429 Item_func_format(Item *org,int dec);
00430 String *val_str(String *);
00431 void fix_length_and_dec()
00432 {
00433 collation.set(default_charset());
00434 max_length=args[0]->max_length+(args[0]->max_length-args[0]->decimals)/3;
00435 }
00436 const char *func_name() const { return "format"; }
00437 void print(String *);
00438 };
00439
00440
00441 class Item_func_char :public Item_str_func
00442 {
00443 public:
00444 Item_func_char(List<Item> &list) :Item_str_func(list) {}
00445 String *val_str(String *);
00446 void fix_length_and_dec()
00447 {
00448 collation.set(default_charset());
00449 maybe_null=0; max_length=arg_count;
00450 }
00451 const char *func_name() const { return "char"; }
00452 };
00453
00454
00455 class Item_func_repeat :public Item_str_func
00456 {
00457 String tmp_value;
00458 public:
00459 Item_func_repeat(Item *arg1,Item *arg2) :Item_str_func(arg1,arg2) {}
00460 String *val_str(String *);
00461 void fix_length_and_dec();
00462 const char *func_name() const { return "repeat"; }
00463 };
00464
00465
00466 class Item_func_rpad :public Item_str_func
00467 {
00468 String tmp_value, rpad_str;
00469 public:
00470 Item_func_rpad(Item *arg1,Item *arg2,Item *arg3)
00471 :Item_str_func(arg1,arg2,arg3) {}
00472 String *val_str(String *);
00473 void fix_length_and_dec();
00474 const char *func_name() const { return "rpad"; }
00475 };
00476
00477
00478 class Item_func_lpad :public Item_str_func
00479 {
00480 String tmp_value, lpad_str;
00481 public:
00482 Item_func_lpad(Item *arg1,Item *arg2,Item *arg3)
00483 :Item_str_func(arg1,arg2,arg3) {}
00484 String *val_str(String *);
00485 void fix_length_and_dec();
00486 const char *func_name() const { return "lpad"; }
00487 };
00488
00489
00490 class Item_func_conv :public Item_str_func
00491 {
00492 public:
00493 Item_func_conv(Item *a,Item *b,Item *c) :Item_str_func(a,b,c) {}
00494 const char *func_name() const { return "conv"; }
00495 String *val_str(String *);
00496 void fix_length_and_dec()
00497 {
00498 collation.set(default_charset());
00499 decimals=0; max_length=64;
00500 }
00501 };
00502
00503
00504 class Item_func_hex :public Item_str_func
00505 {
00506 String tmp_value;
00507 public:
00508 Item_func_hex(Item *a) :Item_str_func(a) {}
00509 const char *func_name() const { return "hex"; }
00510 String *val_str(String *);
00511 void fix_length_and_dec()
00512 {
00513 collation.set(default_charset());
00514 decimals=0;
00515 max_length=args[0]->max_length*2*collation.collation->mbmaxlen;
00516 }
00517 };
00518
00519 class Item_func_unhex :public Item_str_func
00520 {
00521 String tmp_value;
00522 public:
00523 Item_func_unhex(Item *a) :Item_str_func(a) {}
00524 const char *func_name() const { return "unhex"; }
00525 String *val_str(String *);
00526 void fix_length_and_dec()
00527 {
00528 collation.set(&my_charset_bin);
00529 decimals=0;
00530 max_length=(1+args[0]->max_length)/2;
00531 }
00532 };
00533
00534
00535 class Item_func_binary :public Item_str_func
00536 {
00537 public:
00538 Item_func_binary(Item *a) :Item_str_func(a) {}
00539 String *val_str(String *a)
00540 {
00541 DBUG_ASSERT(fixed == 1);
00542 String *tmp=args[0]->val_str(a);
00543 null_value=args[0]->null_value;
00544 if (tmp)
00545 tmp->set_charset(&my_charset_bin);
00546 return tmp;
00547 }
00548 void fix_length_and_dec()
00549 {
00550 collation.set(&my_charset_bin);
00551 max_length=args[0]->max_length;
00552 }
00553 void print(String *str);
00554 };
00555
00556
00557 class Item_load_file :public Item_str_func
00558 {
00559 String tmp_value;
00560 public:
00561 Item_load_file(Item *a) :Item_str_func(a) {}
00562 String *val_str(String *);
00563 const char *func_name() const { return "load_file"; }
00564 void fix_length_and_dec()
00565 {
00566 collation.set(&my_charset_bin, DERIVATION_COERCIBLE);
00567 maybe_null=1;
00568 max_length=MAX_BLOB_WIDTH;
00569 }
00570 };
00571
00572
00573 class Item_func_export_set: public Item_str_func
00574 {
00575 public:
00576 Item_func_export_set(Item *a,Item *b,Item* c) :Item_str_func(a,b,c) {}
00577 Item_func_export_set(Item *a,Item *b,Item* c,Item* d) :Item_str_func(a,b,c,d) {}
00578 Item_func_export_set(Item *a,Item *b,Item* c,Item* d,Item* e) :Item_str_func(a,b,c,d,e) {}
00579 String *val_str(String *str);
00580 void fix_length_and_dec();
00581 const char *func_name() const { return "export_set"; }
00582 };
00583
00584 class Item_func_inet_ntoa : public Item_str_func
00585 {
00586 public:
00587 Item_func_inet_ntoa(Item *a) :Item_str_func(a)
00588 {
00589 }
00590 String* val_str(String* str);
00591 const char *func_name() const { return "inet_ntoa"; }
00592 void fix_length_and_dec() { decimals = 0; max_length=3*8+7; }
00593 };
00594
00595 class Item_func_quote :public Item_str_func
00596 {
00597 public:
00598 Item_func_quote(Item *a) :Item_str_func(a) {}
00599 const char *func_name() const { return "quote"; }
00600 String *val_str(String *);
00601 void fix_length_and_dec()
00602 {
00603 collation.set(args[0]->collation);
00604 max_length= args[0]->max_length * 2 + 2;
00605 }
00606 };
00607
00608 class Item_func_conv_charset :public Item_str_func
00609 {
00610 CHARSET_INFO *conv_charset;
00611 public:
00612 Item_func_conv_charset(Item *a, CHARSET_INFO *cs) :Item_str_func(a)
00613 { conv_charset=cs; }
00614 String *val_str(String *);
00615 void fix_length_and_dec();
00616 const char *func_name() const { return "convert"; }
00617 void print(String *str);
00618 };
00619
00620 class Item_func_set_collation :public Item_str_func
00621 {
00622 public:
00623 Item_func_set_collation(Item *a, Item *b) :Item_str_func(a,b) {};
00624 String *val_str(String *);
00625 void fix_length_and_dec();
00626 bool eq(const Item *item, bool binary_cmp) const;
00627 const char *func_name() const { return "collate"; }
00628 void print(String *str);
00629 Item_field *filed_for_view_update()
00630 {
00631
00632 return args[0]->filed_for_view_update();
00633 }
00634 };
00635
00636 class Item_func_charset :public Item_str_func
00637 {
00638 public:
00639 Item_func_charset(Item *a) :Item_str_func(a) {}
00640 String *val_str(String *);
00641 const char *func_name() const { return "charset"; }
00642 void fix_length_and_dec()
00643 {
00644 collation.set(system_charset_info);
00645 max_length= 64 * collation.collation->mbmaxlen;
00646 };
00647 };
00648
00649 class Item_func_collation :public Item_str_func
00650 {
00651 public:
00652 Item_func_collation(Item *a) :Item_str_func(a) {}
00653 String *val_str(String *);
00654 const char *func_name() const { return "collation"; }
00655 void fix_length_and_dec()
00656 {
00657 collation.set(system_charset_info);
00658 max_length= 64 * collation.collation->mbmaxlen;
00659 };
00660 };
00661
00662 class Item_func_crc32 :public Item_int_func
00663 {
00664 String value;
00665 public:
00666 Item_func_crc32(Item *a) :Item_int_func(a) {}
00667 const char *func_name() const { return "crc32"; }
00668 void fix_length_and_dec() { max_length=10; }
00669 longlong val_int();
00670 };
00671
00672 class Item_func_uncompressed_length : public Item_int_func
00673 {
00674 String value;
00675 public:
00676 Item_func_uncompressed_length(Item *a):Item_int_func(a){}
00677 const char *func_name() const{return "uncompressed_length";}
00678 void fix_length_and_dec() { max_length=10; }
00679 longlong val_int();
00680 };
00681
00682 #ifdef HAVE_COMPRESS
00683 #define ZLIB_DEPENDED_FUNCTION ;
00684 #else
00685 #define ZLIB_DEPENDED_FUNCTION { null_value=1; return 0; }
00686 #endif
00687
00688 class Item_func_compress: public Item_str_func
00689 {
00690 String buffer;
00691 public:
00692 Item_func_compress(Item *a):Item_str_func(a){}
00693 void fix_length_and_dec(){max_length= (args[0]->max_length*120)/100+12;}
00694 const char *func_name() const{return "compress";}
00695 String *val_str(String *) ZLIB_DEPENDED_FUNCTION
00696 };
00697
00698 class Item_func_uncompress: public Item_str_func
00699 {
00700 String buffer;
00701 public:
00702 Item_func_uncompress(Item *a): Item_str_func(a){}
00703 void fix_length_and_dec(){max_length= MAX_BLOB_WIDTH;}
00704 const char *func_name() const{return "uncompress";}
00705 String *val_str(String *) ZLIB_DEPENDED_FUNCTION
00706 };
00707
00708 #define UUID_LENGTH (8+1+4+1+4+1+4+1+12)
00709 class Item_func_uuid: public Item_str_func
00710 {
00711 public:
00712 Item_func_uuid(): Item_str_func() {}
00713 void fix_length_and_dec() {
00714 collation.set(system_charset_info);
00715 max_length= UUID_LENGTH;
00716 }
00717 const char *func_name() const{ return "uuid"; }
00718 String *val_str(String *);
00719 };
00720