The world's most popular open source database
#include <item_strfunc.h>
Inheritance diagram for Item_func_quote:


Public Member Functions | |
| Item_func_quote (Item *a) | |
| const char * | func_name () const |
| String * | val_str (String *) |
| void | fix_length_and_dec () |
| bool | check_partition_func_processor (byte *bool_arg) |
Private Attributes | |
| String | tmp_value |
Definition at line 682 of file item_strfunc.h.
| Item_func_quote::Item_func_quote | ( | Item * | a | ) | [inline] |
| void Item_func_quote::fix_length_and_dec | ( | ) | [inline, virtual] |
Implements Item_result_field.
Definition at line 689 of file item_strfunc.h.
References Item_func::args, Item::collation, Item::max_length, and DTCollation::set().
00690 { 00691 collation.set(args[0]->collation); 00692 max_length= args[0]->max_length * 2 + 2; 00693 }
Here is the call graph for this function:

| const char* Item_func_quote::func_name | ( | ) | const [inline, virtual] |
Implements Item.
Definition at line 2796 of file item_strfunc.cc.
References String::alloc(), Item_func::args, DTCollation::collation, Item::collation, String::copy(), DBUG_ASSERT, Item::fixed, from, get_esc_bit, String::length(), Item::null_value, String::ptr(), String::set_charset(), start(), STRING_WITH_LEN, tmp_value, to, and Item::val_str().
02797 { 02798 DBUG_ASSERT(fixed == 1); 02799 /* 02800 Bit mask that has 1 for set for the position of the following characters: 02801 0, \, ' and ^Z 02802 */ 02803 02804 static uchar escmask[32]= 02805 { 02806 0x01, 0x00, 0x00, 0x04, 0x80, 0x00, 0x00, 0x00, 02807 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 02808 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 02809 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 02810 }; 02811 02812 char *from, *to, *end, *start; 02813 String *arg= args[0]->val_str(str); 02814 uint arg_length, new_length; 02815 if (!arg) // Null argument 02816 { 02817 /* Return the string 'NULL' */ 02818 str->copy(STRING_WITH_LEN("NULL"), collation.collation); 02819 null_value= 0; 02820 return str; 02821 } 02822 02823 arg_length= arg->length(); 02824 new_length= arg_length+2; /* for beginning and ending ' signs */ 02825 02826 for (from= (char*) arg->ptr(), end= from + arg_length; from < end; from++) 02827 new_length+= get_esc_bit(escmask, (uchar) *from); 02828 02829 if (tmp_value.alloc(new_length)) 02830 goto null; 02831 02832 /* 02833 We replace characters from the end to the beginning 02834 */ 02835 to= (char*) tmp_value.ptr() + new_length - 1; 02836 *to--= '\''; 02837 for (start= (char*) arg->ptr(),end= start + arg_length; end-- != start; to--) 02838 { 02839 /* 02840 We can't use the bitmask here as we want to replace \O and ^Z with 0 02841 and Z 02842 */ 02843 switch (*end) { 02844 case 0: 02845 *to--= '0'; 02846 *to= '\\'; 02847 break; 02848 case '\032': 02849 *to--= 'Z'; 02850 *to= '\\'; 02851 break; 02852 case '\'': 02853 case '\\': 02854 *to--= *end; 02855 *to= '\\'; 02856 break; 02857 default: 02858 *to= *end; 02859 break; 02860 } 02861 } 02862 *to= '\''; 02863 tmp_value.length(new_length); 02864 tmp_value.set_charset(collation.collation); 02865 null_value= 0; 02866 return &tmp_value; 02867 02868 null: 02869 null_value= 1; 02870 return 0; 02871 }
Here is the call graph for this function:

String Item_func_quote::tmp_value [private] |
1.4.7

