diff options
author | unknown <bell@sanja.is.com.ua> | 2003-10-30 12:57:26 +0200 |
---|---|---|
committer | unknown <bell@sanja.is.com.ua> | 2003-10-30 12:57:26 +0200 |
commit | 87e6c2ba77a514456f9f33e69984d67d0a588469 (patch) | |
tree | feb3d108a684e5356467c6eca482627ae8d30859 /sql | |
parent | 683dcaae6bfc101d352755f834ecda48f4ea4700 (diff) | |
download | mariadb-git-87e6c2ba77a514456f9f33e69984d67d0a588469.tar.gz |
added code covarage for functions convert(), nullif(), crc32(), is_used_lock(), char_lengtrh(), bit_xor()
added string length for more speed
made code covarage for print() method of Item
fixed printability of some items (SCRUM) (WL#1274)
mysql-test/r/auto_increment.result:
print() code coverage
mysql-test/r/bench_count_distinct.result:
print() code coverage
mysql-test/r/case.result:
print() code coverage
mysql-test/r/cast.result:
print() code coverage
mysql-test/r/ctype_collate.result:
print() code coverage
mysql-test/r/ctype_many.result:
convert with 3 arguments code covarage
print() code coverage
mysql-test/r/ctype_utf8.result:
char_length code coverage
mysql-test/r/date_formats.result:
print() code coverage
mysql-test/r/fulltext.result:
print() code coverage
mysql-test/r/func_compress.result:
print() code coverage
mysql-test/r/func_gconcat.result:
print() code coverage
mysql-test/r/func_group.result:
bit_xor() code coverage
print() code coverage
mysql-test/r/func_if.result:
nullif() code coverage
print() code coverage
mysql-test/r/func_in.result:
print() code coverage
mysql-test/r/func_math.result:
print() code coverage
mysql-test/r/func_op.result:
print() code coverage
mysql-test/r/func_regexp.result:
print() code coverage
mysql-test/r/func_set.result:
print() code coverage
mysql-test/r/func_str.result:
crc32() code coverage
print() code coverage
mysql-test/r/func_system.result:
print() code coverage
mysql-test/r/func_test.result:
print() code coverage
mysql-test/r/func_time.result:
print() code coverage
mysql-test/r/group_by.result:
print() code coverage
mysql-test/r/having.result:
print() code coverage
mysql-test/r/insert_update.result:
print() code coverage
mysql-test/r/null.result:
print() code coverage
mysql-test/r/olap.result:
print() code coverage
mysql-test/r/query_cache.result:
print() code coverage
mysql-test/r/row.result:
print() code coverage
mysql-test/r/rpl000001.result:
print() code coverage
mysql-test/r/rpl_get_lock.result:
print() code coverage
mysql-test/r/rpl_master_pos_wait.result:
print() code coverage
mysql-test/r/select.result:
print() code coverage
mysql-test/r/subselect.result:
print() code coverage
mysql-test/r/type_blob.result:
print() code coverage
mysql-test/r/varbinary.result:
print() code coverage
mysql-test/r/variables.result:
print() code coverage
mysql-test/t/auto_increment.test:
print() code coverage
mysql-test/t/bench_count_distinct.test:
print() code coverage
mysql-test/t/case.test:
print() code coverage
mysql-test/t/cast.test:
print() code coverage
mysql-test/t/ctype_collate.test:
print() code coverage
mysql-test/t/ctype_many.test:
convert with 3 arguments code covarage
print() code coverage
mysql-test/t/ctype_utf8.test:
char_length code coverage
mysql-test/t/date_formats.test:
print() code coverage
mysql-test/t/fulltext.test:
print() code coverage
mysql-test/t/func_compress.test:
print() code coverage
mysql-test/t/func_gconcat.test:
print() code coverage
mysql-test/t/func_group.test:
bit_xor() code coverage
print() code coverage
mysql-test/t/func_if.test:
nullif() code coverage
print() code coverage
mysql-test/t/func_in.test:
print() code coverage
mysql-test/t/func_math.test:
print() code coverage
mysql-test/t/func_op.test:
print() code coverage
mysql-test/t/func_regexp.test:
print() code coverage
mysql-test/t/func_set.test:
print() code coverage
mysql-test/t/func_str.test:
crc32() code covarage
print() code coverage
mysql-test/t/func_system.test:
print() code coverage
mysql-test/t/func_test.test:
print() code coverage
mysql-test/t/func_time.test:
print() code coverage
mysql-test/t/group_by.test:
print() code coverage
mysql-test/t/having.test:
print() code coverage
mysql-test/t/insert_update.test:
print() code coverage
mysql-test/t/null.test:
print() code coverage
mysql-test/t/olap.test:
print() code coverage
mysql-test/t/query_cache.test:
print() code coverage
mysql-test/t/row.test:
print() code coverage
mysql-test/t/rpl000001.test:
print() code coverage
mysql-test/t/rpl_get_lock.test:
print() code coverage
mysql-test/t/rpl_master_pos_wait.test:
print() code coverage
mysql-test/t/select.test:
print() code coverage
mysql-test/t/type_blob.test:
print() code coverage
mysql-test/t/varbinary.test:
print() code coverage
mysql-test/t/variables.test:
print() code coverage
sql/item.cc:
added string length for more speed
layout fix
fixed string printability
sql/item.h:
added string length for more speed
sql/item_cmpfunc.cc:
added string length for more speed
sql/item_cmpfunc.h:
fixed printability
sql/item_create.cc:
fixed printability
sql/item_func.cc:
fixed printability
added string length for more speed
sql/item_func.h:
fixed printability
sql/item_strfunc.cc:
fixed printability
added string length for more speed
sql/item_strfunc.h:
fixed printability
sql/item_subselect.cc:
added string length for more speed
sql/item_sum.cc:
added string length for more speed
sql/item_timefunc.cc:
added string length for more speed
sql/item_timefunc.h:
fixed printability
sql/item_uniq.h:
added string length for more speed
sql/key.cc:
added string length for more speed
sql/sql_lex.cc:
added string length for more speed
sql/sql_parse.cc:
after merge fix
sql/sql_repl.cc:
string changed with character for more speed
sql/sql_select.cc:
added string length for more speed
sql/sql_show.cc:
added string length for more speed
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item.cc | 61 | ||||
-rw-r--r-- | sql/item.h | 2 | ||||
-rw-r--r-- | sql/item_cmpfunc.cc | 22 | ||||
-rw-r--r-- | sql/item_cmpfunc.h | 3 | ||||
-rw-r--r-- | sql/item_create.cc | 2 | ||||
-rw-r--r-- | sql/item_func.cc | 62 | ||||
-rw-r--r-- | sql/item_func.h | 5 | ||||
-rw-r--r-- | sql/item_strfunc.cc | 50 | ||||
-rw-r--r-- | sql/item_strfunc.h | 11 | ||||
-rw-r--r-- | sql/item_subselect.cc | 44 | ||||
-rw-r--r-- | sql/item_sum.cc | 11 | ||||
-rw-r--r-- | sql/item_timefunc.cc | 33 | ||||
-rw-r--r-- | sql/item_timefunc.h | 2 | ||||
-rw-r--r-- | sql/item_uniq.h | 4 | ||||
-rw-r--r-- | sql/key.cc | 4 | ||||
-rw-r--r-- | sql/sql_lex.cc | 22 | ||||
-rw-r--r-- | sql/sql_parse.cc | 2 | ||||
-rw-r--r-- | sql/sql_repl.cc | 2 | ||||
-rw-r--r-- | sql/sql_select.cc | 44 | ||||
-rw-r--r-- | sql/sql_show.cc | 14 |
20 files changed, 267 insertions, 133 deletions
diff --git a/sql/item.cc b/sql/item.cc index 933d219d29d..735d67c6c3f 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -93,7 +93,7 @@ void Item::print_item_w_name(String *str) print(str); if (name) { - str->append(" AS `"); + str->append(" AS `", 5); str->append(name); str->append('`'); } @@ -435,6 +435,7 @@ bool Item_field::eq(const Item *item, bool binary_cmp) const db_name)))))); } + table_map Item_field::used_tables() const { if (field->table->const_table) @@ -442,6 +443,7 @@ table_map Item_field::used_tables() const return (depended_from ? OUTER_REF_TABLE_BIT : field->table->map); } + Item *Item_field::get_tmp_table_item(THD *thd) { Item_field *new_item= new Item_field(thd, *this); @@ -450,6 +452,7 @@ Item *Item_field::get_tmp_table_item(THD *thd) return new_item; } + String *Item_int::val_str(String *str) { str->set(value, default_charset()); @@ -458,18 +461,22 @@ String *Item_int::val_str(String *str) void Item_int::print(String *str) { - str_value.set(value, default_charset()); + // latin1 is good enough for numbers + str_value.set(value, &my_charset_latin1); str->append(str_value); } + String *Item_uint::val_str(String *str) { str->set((ulonglong) value, default_charset()); return str; } + void Item_uint::print(String *str) { + // latin1 is good enough for numbers str_value.set((ulonglong) value, default_charset()); str->append(str_value); } @@ -481,12 +488,46 @@ String *Item_real::val_str(String *str) return str; } + void Item_string::print(String *str) { str->append('_'); str->append(collation.collation->csname); str->append('\''); - str->append(str_value); + char *st= (char*)str_value.ptr(), *end= st+str_value.length(); + for(; st < end; st++) + { + uchar c= *st; + switch (c) + { + case '\\': + str->append("\\\\", 2); + break; + case '\0': + str->append("\\0", 2); + break; + case '\'': + str->append("\\'", 2); + break; + case '\n': + str->append("\\n", 2); + break; + case '\r': + str->append("\\r", 2); + break; + case '\t': + str->append("\\t", 2); + break; + case '\b': + str->append("\\b", 2); + break; + case 26: //Ctrl-Z + str->append("\\z", 2); + break; + default: + str->append(c); + } + } str->append('\''); } @@ -707,7 +748,7 @@ String *Item_param::query_val_str(String* str) make_datetime(str, <ime, is_time_only, 0, tmp_format->format, tmp_format->format_length, 0); } - str->append("'"); + str->append('\''); } return str; } @@ -1551,7 +1592,7 @@ void Item_ref::print(String *str) void Item_ref_null_helper::print(String *str) { - str->append("<ref_null_helper>("); + str->append("<ref_null_helper>(", 18); if (ref && *ref) (*ref)->print(str); else @@ -1562,7 +1603,7 @@ void Item_ref_null_helper::print(String *str) void Item_null_helper::print(String *str) { - str->append("<null_helper>("); + str->append("<null_helper>(", 14); store->print(str); str->append(')'); } @@ -1609,10 +1650,10 @@ void Item_default_value::print(String *str) { if (!arg) { - str->append("DEFAULT"); + str->append("default", 6); return; } - str->append("DEFAULT("); + str->append("default", 7); arg->print(str); str->append(')'); } @@ -1665,7 +1706,7 @@ bool Item_insert_value::fix_fields(THD *thd, struct st_table_list *table_list, I void Item_insert_value::print(String *str) { - str->append("VALUE("); + str->append("values(", 7); arg->print(str); str->append(')'); } @@ -1792,7 +1833,7 @@ Item_cache* Item_cache::get_cache(Item_result type) void Item_cache::print(String *str) { - str->append("<cache>("); + str->append("<cache>(", 8); if (example) example->print(str); else diff --git a/sql/item.h b/sql/item.h index 5f691c9e4e4..9751458b810 100644 --- a/sql/item.h +++ b/sql/item.h @@ -316,7 +316,7 @@ public: bool basic_const_item() const { return 1; } Item *new_item() { return new Item_null(name); } bool is_null() { return 1; } - void print(String *str) { str->append("NULL"); } + void print(String *str) { str->append("NULL", 4); } }; class Item_param :public Item diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index d183c81b230..1731f5859b3 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -717,9 +717,9 @@ void Item_func_between::print(String *str) { str->append('('); args[0]->print(str); - str->append(" between "); + str->append(" between ", 9); args[1]->print(str); - str->append(" and "); + str->append(" and ", 5); args[2]->print(str); str->append(')'); } @@ -880,7 +880,7 @@ Item_func_nullif::fix_length_and_dec() } /* - nullif () returns NULL if arguments are different, else it returns the + nullif () returns NULL if arguments are equal, else it returns the first argument. Note that we have to evaluate the first argument twice as the compare may have been done with a different type than return value @@ -1117,7 +1117,7 @@ void Item_func_case::fix_length_and_dec() void Item_func_case::print(String *str) { - str->append("(case "); + str->append("(case ", 6); if (first_expr_num != -1) { args[first_expr_num]->print(str); @@ -1125,19 +1125,19 @@ void Item_func_case::print(String *str) } for (uint i=0 ; i < ncases ; i+=2) { - str->append("when "); + str->append("when ", 5); args[i]->print(str); - str->append(" then "); + str->append(" then ", 6); args[i+1]->print(str); str->append(' '); } if (else_expr_num != -1) { - str->append("else "); + str->append("else ", 5); args[else_expr_num]->print(str); str->append(' '); } - str->append("end)"); + str->append("end)", 4); } /* @@ -1545,14 +1545,14 @@ void Item_func_in::print(String *str) { str->append('('); args[0]->print(str); - str->append(" IN ("); + str->append(" in (", 5); for (uint i=1 ; i < arg_count ; i++) { if (i > 1) str->append(','); args[i]->print(str); } - str->append("))"); + str->append("))", 2); } @@ -1924,7 +1924,7 @@ void Item_func_isnotnull::print(String *str) { str->append('('); args[0]->print(str); - str->append(" is not null)"); + str->append(" is not null)", 13); } diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index eb473a1a73d..36ed849a650 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -349,6 +349,7 @@ public: enum Item_result result_type () const { return cached_result_type; } void fix_length_and_dec(); const char *func_name() const { return "nullif"; } + void print(String *str) { Item_func::print(str); } table_map not_null_tables() const { return 0; } }; @@ -780,7 +781,7 @@ public: ~Item_func_regex(); longlong val_int(); bool fix_fields(THD *thd, struct st_table_list *tlist, Item **ref); - const char *func_name() const { return "regex"; } + const char *func_name() const { return "regexp"; } void print(String *str) { print_op(str); } }; diff --git a/sql/item_create.cc b/sql/item_create.cc index fce59d68c1f..0755a43a48e 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -292,7 +292,7 @@ Item *create_func_period_diff(Item* a, Item *b) Item *create_func_pi(void) { - return new Item_real(NullS,M_PI,6,8); + return new Item_real("Pi()",M_PI,6,8); } Item *create_func_pow(Item* a, Item *b) diff --git a/sql/item_func.cc b/sql/item_func.cc index bff7c9a6bf3..7bc8f2954da 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -287,13 +287,19 @@ void Item_func::print(String *str) { str->append(func_name()); str->append('('); + print_args(str); + str->append(')'); +} + + +void Item_func::print_args(String *str) +{ for (uint i=0 ; i < arg_count ; i++) { if (i) str->append(','); args[i]->print(str); } - str->append(')'); } @@ -464,18 +470,18 @@ String *Item_num_op::val_str(String *str) void Item_func_signed::print(String *str) { - str->append("cast("); + str->append("cast(", 5); args[0]->print(str); - str->append("as signed)"); + str->append(" as signed)", 11); } void Item_func_unsigned::print(String *str) { - str->append("cast("); + str->append("cast(", 5); args[0]->print(str); - str->append("as unsigned)"); + str->append(" as unsigned)", 13); } @@ -1202,6 +1208,21 @@ longlong Item_func_locate::val_int() } +void Item_func_locate::print(String *str) +{ + str->append("locate(", 7); + args[1]->print(str); + str->append(','); + args[0]->print(str); + if (arg_count == 3) + { + str->append(','); + args[2]->print(str); + } + str->append(')'); +} + + longlong Item_func_field::val_int() { if (cmp_type == STRING_RESULT) @@ -1782,7 +1803,7 @@ void item_user_lock_release(ULL *ull) String tmp(buf,sizeof(buf), system_charset_info); tmp.copy(command, strlen(command), tmp.charset()); tmp.append(ull->key,ull->key_length); - tmp.append("\")"); + tmp.append("\")", 2); Query_log_event qev(current_thd, tmp.ptr(), tmp.length(),1); qev.error_code=0; // this query is always safe to run on slave mysql_bin_log.write(&qev); @@ -2067,6 +2088,19 @@ longlong Item_func_benchmark::val_int() } +void Item_func_benchmark::print(String *str) +{ + str->append("benchmark(", 10); + char buffer[20]; + // latin1 is good enough for numbers + String st(buffer, sizeof(buffer), &my_charset_latin1); + st.set((ulonglong)loop_count, &my_charset_latin1); + str->append(st); + str->append(','); + args[0]->print(str); + str->append(')'); +} + #define extra_size sizeof(double) static user_var_entry *get_variable(HASH *hash, LEX_STRING &name, @@ -2405,9 +2439,9 @@ String *Item_func_set_user_var::val_str(String *str) void Item_func_set_user_var::print(String *str) { - str->append("(@@",3); - str->append(name.str,name.length); - str->append(":=",2); + str->append("(@", 2); + str->append(name.str, name.length); + str->append(":=", 2); args[0]->print(str); str->append(')'); } @@ -2553,7 +2587,7 @@ enum Item_result Item_func_get_user_var::result_type() const void Item_func_get_user_var::print(String *str) { - str->append('@'); + str->append("(@", 2); str->append(name.str,name.length); str->append(')'); } @@ -2840,7 +2874,7 @@ double Item_func_match::val() void Item_func_match::print(String *str) { - str->append("(match "); + str->append("(match ", 7); List_iterator_fast<Item> li(fields); Item *item; bool first= 1; @@ -2852,11 +2886,11 @@ void Item_func_match::print(String *str) str->append(','); item->print(str); } - str->append(" against ("); + str->append(" against (", 10); args[0]->print(str); if (mode == FT_BOOL) - str->append(" in boolean mode"); - str->append("))"); + str->append(" in boolean mode", 16); + str->append("))", 2); } longlong Item_func_bit_xor::val_int() diff --git a/sql/item_func.h b/sql/item_func.h index 541ced0f1ba..235b1ea18f2 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -124,6 +124,7 @@ public: virtual void split_sum_func(Item **ref_pointer_array, List<Item> &fields); void print(String *str); void print_op(String *str); + void print_args(String *str); void fix_num_length_and_dec(); inline bool get_arg0_date(TIME *ltime,bool fuzzy_date) { @@ -608,6 +609,7 @@ public: const char *func_name() const { return "locate"; } longlong val_int(); void fix_length_and_dec(); + void print(String *str); }; @@ -733,6 +735,7 @@ class Item_func_benchmark :public Item_int_func longlong val_int(); const char *func_name() const { return "benchmark"; } void fix_length_and_dec() { max_length=1; maybe_null=0; } + void print(String *str); }; @@ -1056,7 +1059,7 @@ class Item_func_is_free_lock :public Item_int_func public: Item_func_is_free_lock(Item *a) :Item_int_func(a) {} longlong val_int(); - const char *func_name() const { return "check_lock"; } + const char *func_name() const { return "is_free_lock"; } void fix_length_and_dec() { decimals=0; max_length=1; maybe_null=1;} }; diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 5afd52e3738..70f98783624 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -654,6 +654,17 @@ void Item_func_concat_ws::update_used_tables() const_item_cache&=separator->const_item(); } +void Item_func_concat_ws::print(String *str) +{ + str->append("concat_ws(", 10); + separator->print(str); + if (arg_count) + { + str->append(','); + print_args(str); + } + str->append(')'); +} String *Item_func_reverse::val_str(String *str) { @@ -1613,6 +1624,19 @@ String *Item_func_format::val_str(String *str) } +void Item_func_format::print(String *str) +{ + str->append("format(", 7); + args[0]->print(str); + str->append(','); + // latin1 is good enough for numbers + char buffer[20]; + String st(buffer, sizeof(buffer), &my_charset_latin1); + st.set((ulonglong)decimals, &my_charset_latin1); + str->append(st); + str->append(')'); +} + void Item_func_elt::fix_length_and_dec() { max_length=0; @@ -1764,6 +1788,19 @@ String *Item_func_make_set::val_str(String *str) } +void Item_func_make_set::print(String *str) +{ + str->append("make_set(", 9); + item->print(str); + if (arg_count) + { + str->append(','); + print_args(str); + } + str->append(')'); +} + + String *Item_func_char::val_str(String *str) { str->length(0); @@ -2077,7 +2114,14 @@ void Item_func_conv_charset::fix_length_and_dec() max_length = args[0]->max_length*conv_charset->mbmaxlen; } - +void Item_func_conv_charset::print(String *str) +{ + str->append("convert(", 8); + args[0]->print(str); + str->append(" using ", 7); + str->append(conv_charset->csname); + str->append(')'); +} String *Item_func_conv_charset3::val_str(String *str) { @@ -2273,9 +2317,9 @@ String *Item_func_hex::val_str(String *str) void Item_func_binary::print(String *str) { - str->append("cast("); + str->append("cast(", 5); args[0]->print(str); - str->append("as binary)"); + str->append(" as binary)", 11); } diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index 51dff0fbaf2..00b1ebb0732 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -112,6 +112,7 @@ public: return separator->walk(processor, arg) || Item_str_func::walk(processor, arg); } + void print(String *str); }; class Item_func_reverse :public Item_str_func @@ -426,6 +427,7 @@ public: return item->walk(processor, arg) || Item_str_func::walk(processor, arg); } + void print(String *str); }; @@ -441,6 +443,7 @@ public: max_length=args[0]->max_length+(args[0]->max_length-args[0]->decimals)/3; } const char *func_name() const { return "format"; } + void print(String *); }; @@ -602,7 +605,8 @@ public: { conv_charset=cs; } String *val_str(String *); void fix_length_and_dec(); - const char *func_name() const { return "conv_charset"; } + const char *func_name() const { return "convert"; } + void print(String *str); }; class Item_func_set_collation :public Item_str_func @@ -612,7 +616,8 @@ public: String *val_str(String *); void fix_length_and_dec(); bool eq(const Item *item, bool binary_cmp) const; - const char *func_name() const { return "set_collation"; } + const char *func_name() const { return "collate"; } + void print(String *str) { print_op(str); } }; class Item_func_conv_charset3 :public Item_str_func @@ -622,7 +627,7 @@ public: :Item_str_func(arg1,arg2,arg3) {} String *val_str(String *); void fix_length_and_dec(); - const char *func_name() const { return "conv_charset3"; } + const char *func_name() const { return "convert"; } }; class Item_func_charset :public Item_str_func diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 5105323be22..ae44647b11c 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -219,7 +219,7 @@ Item_maxmin_subselect::Item_maxmin_subselect(Item_subselect *parent, void Item_maxmin_subselect::print(String *str) { - str->append(max?"<max>":"<min>"); + str->append(max?"<max>":"<min>", 5); Item_singlerow_subselect::print(str); } @@ -403,7 +403,7 @@ Item_exists_subselect::Item_exists_subselect(st_select_lex *select_lex): void Item_exists_subselect::print(String *str) { - str->append("exists"); + str->append("exists", 6); Item_subselect::print(str); } @@ -841,11 +841,11 @@ Item_in_subselect::select_transformer(JOIN *join) void Item_in_subselect::print(String *str) { if (transformed) - str->append("<exists>"); + str->append("<exists>", 8); else { left_expr->print(str); - str->append(" in "); + str->append(" in ", 4); } Item_subselect::print(str); } @@ -864,7 +864,7 @@ Item_allany_subselect::select_transformer(JOIN *join) void Item_allany_subselect::print(String *str) { if (transformed) - str->append("<exists>"); + str->append("<exists>", 8); else { left_expr->print(str); @@ -872,22 +872,22 @@ void Item_allany_subselect::print(String *str) if (all) { if (func == &Item_bool_func2::lt_creator) - str->append(">="); + str->append(">=", 2); else if (func == &Item_bool_func2::gt_creator) - str->append("<="); + str->append("<=", 2); else if (func == &Item_bool_func2::le_creator) str->append('>'); else if (func == &Item_bool_func2::ge_creator) str->append('<'); else if (func == &Item_bool_func2::eq_creator) - str->append("<>"); + str->append("<>", 2); else if (func == &Item_bool_func2::ne_creator) str->append('='); else { DBUG_ASSERT(0); // Impossible } - str->append(" all "); + str->append(" all ", 5); } else { @@ -896,18 +896,18 @@ void Item_allany_subselect::print(String *str) else if (func == &Item_bool_func2::gt_creator) str->append('>'); else if (func == &Item_bool_func2::le_creator) - str->append("<="); + str->append("<=", 2); else if (func == &Item_bool_func2::ge_creator) - str->append(">="); + str->append(">=", 2); else if (func == &Item_bool_func2::eq_creator) str->append('='); else if (func == &Item_bool_func2::ne_creator) - str->append("<>"); + str->append("<>", 2); else { DBUG_ASSERT(0); // Impossible } - str->append(" any "); + str->append(" any ", 5); } } Item_subselect::print(str); @@ -1330,16 +1330,16 @@ void subselect_union_engine::print(String *str) void subselect_uniquesubquery_engine::print(String *str) { - str->append("<primary_index_lookup>("); + str->append("<primary_index_lookup>(", 23); tab->ref.items[0]->print(str); - str->append(" in "); + str->append(" in ", 4); str->append(tab->table->real_name); KEY *key_info= tab->table->key_info+ tab->ref.key; - str->append(" on "); + str->append(" on ", 4); str->append(key_info->name); if (cond) { - str->append(" where "); + str->append(" where ", 7); cond->print(str); } str->append(')'); @@ -1348,18 +1348,18 @@ void subselect_uniquesubquery_engine::print(String *str) void subselect_indexsubquery_engine::print(String *str) { - str->append("<index_lookup>("); + str->append("<index_lookup>(", 15); tab->ref.items[0]->print(str); - str->append(" in "); + str->append(" in ", 4); str->append(tab->table->real_name); KEY *key_info= tab->table->key_info+ tab->ref.key; - str->append(" on "); + str->append(" on ", 4); str->append(key_info->name); if (check_null) - str->append(" chicking NULL"); + str->append(" chicking NULL", 14); if (cond) { - str->append(" where "); + str->append(" where ", 7); cond->print(str); } str->append(')'); diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 1a5df9e8ccc..e5f88156c2d 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1369,7 +1369,7 @@ longlong Item_sum_count_distinct::val_int() void Item_sum_count_distinct::print(String *str) { - str->append("count(distinct "); + str->append("count(distinct ", 15); args[0]->print(str); str->append(')'); } @@ -1971,9 +1971,9 @@ String* Item_func_group_concat::val_str(String* str) void Item_func_group_concat::print(String *str) { - str->append("group concat("); + str->append("group_concat(", 13); if (distinct) - str->append(" distinct "); + str->append("distinct ", 9); for (uint i= 0; i < arg_count; i++) { if (i) @@ -1982,6 +1982,7 @@ void Item_func_group_concat::print(String *str) } if (arg_count_order) { + str->append(" order by ", 10); for (uint i= 0 ; i < arg_count_order ; i++) { if (i) @@ -1989,7 +1990,7 @@ void Item_func_group_concat::print(String *str) (*order[i]->item)->print(str); } } - str->append(" seperator \'"); + str->append(" seperator \'", 12); str->append(*separator); - str->append("\')"); + str->append("\')", 2); } diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index a8c8f9bcf7f..4f1d6c5d63e 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -433,7 +433,7 @@ String *make_datetime(String *str, TIME *l_time, length= int10_to_str(l_time->day, intbuff, 10) - intbuff; str->append_with_prefill(intbuff, length, 1, '0'); if (l_time->day >= 10 && l_time->day <= 19) - str->append("th"); + str->append("th", 2); else { switch (l_time->day %10) { @@ -531,7 +531,7 @@ String *make_datetime(String *str, TIME *l_time, str->append_with_prefill(intbuff, length, 2, '0'); if (add_second_frac) { - str->append(".", 1); + str->append('.'); length= int10_to_str(l_time->second_part, intbuff, 10) - intbuff; str->append_with_prefill(intbuff, length, 6, '0'); } @@ -1660,15 +1660,16 @@ void Item_date_add_interval::print(String *str) args[0]->print(str); str->append(date_sub_interval?" - interval ":" + interval "); args[1]->print(str); + str->append(' '); str->append(interval_names[int_type]); str->append(')'); } void Item_extract::print(String *str) { - str->append("extract("); + str->append("extract(", 8); str->append(interval_names[int_type]); - str->append(' '); + str->append(" from ", 6); args[0]->print(str); str->append(')'); } @@ -1780,29 +1781,31 @@ bool Item_extract::eq(const Item *item, bool binary_cmp) const void Item_typecast::print(String *str) { - str->append("cast("); + str->append("cast(", 5); args[0]->print(str); - str->append(" as "); + str->append(" as ", 4); str->append(cast_type()); str->append(')'); } void Item_char_typecast::print(String *str) { - str->append("cast("); + str->append("cast(", 5); args[0]->print(str); - str->append(" as char"); + str->append(" as char", 8); if (cast_length >= 0) { str->append('('); - char buff[10]; - snprintf(buff, 10, "%d", cast_length); - str->append(buff); + char buffer[20]; + // latin1 is good enough for numbers + String st(buffer, sizeof(buffer), &my_charset_latin1); + st.set((ulonglong)cast_length, &my_charset_latin1); + str->append(st); str->append(')'); } if (cast_cs) { - str->append(" charset "); + str->append(" charset ", 9); str->append(cast_cs->name); } str->append(')'); @@ -2095,14 +2098,14 @@ void Item_func_add_time::print(String *str) if (is_date) { DBUG_ASSERT(sign > 0); - str->append("timestamp("); + str->append("timestamp(", 10); } else { if (sign > 0) - str->append("addtime("); + str->append("addtime(", 8); else - str->append("subtime("); + str->append("subtime(", 8); } args[0]->print(str); str->append(','); diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index ea1e51614c7..af71322ff0c 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -285,7 +285,7 @@ public: Item_func_unix_timestamp() :Item_int_func() {} Item_func_unix_timestamp(Item *a) :Item_int_func(a) {} longlong val_int(); - const char *func_name() const { return "timestamp"; } + const char *func_name() const { return "unix_timestamp"; } void fix_length_and_dec() { decimals=0; diff --git a/sql/item_uniq.h b/sql/item_uniq.h index 2101fc4e45a..5c6f6eefb6b 100644 --- a/sql/item_uniq.h +++ b/sql/item_uniq.h @@ -29,7 +29,7 @@ public: :Item_real_func(list) {} double val() { return 0.0; } void fix_length_and_dec() { decimals=0; max_length=6; } - void print(String *str) { str->append("0.0"); } + void print(String *str) { str->append("0.0", 3); } }; @@ -55,5 +55,5 @@ public: { return new Item_sum_unique_users(thd, *this); } - void print(String *str) { str->append("0.0"); } + void print(String *str) { str->append("0.0", 3); } }; diff --git a/sql/key.cc b/sql/key.cc index 37ef6339f20..639b1e535a6 100644 --- a/sql/key.cc +++ b/sql/key.cc @@ -227,7 +227,7 @@ void key_unpack(String *to,TABLE *table,uint idx) { if (table->record[0][key_part->null_offset] & key_part->null_bit) { - to->append("NULL"); + to->append("NULL", 4); continue; } } @@ -239,7 +239,7 @@ void key_unpack(String *to,TABLE *table,uint idx) to->append(tmp); } else - to->append("???"); + to->append("???", 3); } DBUG_VOID_RETURN; } diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index ee0743d531e..d47bd2170a2 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1477,9 +1477,9 @@ void st_select_lex_unit::print(String *str) { if (sl != first_select()) { - str->append(" union "); + str->append(" union ", 7); if (union_option & UNION_ALL) - str->append("all "); + str->append("all ", 4); } if (sl->braces) str->append('('); @@ -1491,7 +1491,7 @@ void st_select_lex_unit::print(String *str) { if (fake_select_lex->order_list.elements) { - str->append(" order by "); + str->append(" order by ", 10); fake_select_lex->print_order(str, (ORDER *) fake_select_lex-> order_list.first); @@ -1507,7 +1507,7 @@ void st_select_lex::print_order(String *str, ORDER *order) { (*order->item)->print(str); if (!order->asc) - str->append(" desc"); + str->append(" desc", 5); if (order->next) str->append(','); } @@ -1522,15 +1522,17 @@ void st_select_lex::print_limit(THD *thd, String *str) select_limit != HA_POS_ERROR || offset_limit != 0L) { - str->append(" limit "); - char buff[21]; - snprintf(buff, 21, "%ld", select_limit); - str->append(buff); + str->append(" limit ", 7); + char buff[20]; + // latin1 is good enough for numbers + String st(buff, sizeof(buff), &my_charset_latin1); + st.set((ulonglong)select_limit, &my_charset_latin1); + str->append(st); if (offset_limit) { str->append(','); - snprintf(buff, 21, "%ld", offset_limit); - str->append(buff); + st.set((ulonglong)select_limit, &my_charset_latin1); + str->append(st); } } } diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 270a249073d..525df80bc71 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4741,7 +4741,7 @@ Item * all_any_subquery_creator(Item *left_expr, return new Item_func_not(new Item_in_subselect(left_expr, select_lex)); Item_allany_subselect *it= - new Item_allany_subselect(left_expr, (*cmp)(all), select_lex); + new Item_allany_subselect(left_expr, (*cmp)(all), select_lex, all); if (all) return it->upper_not= new Item_func_not_all(it); /* ALL */ diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 5db3be7599b..ecad84ba0cb 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -625,7 +625,7 @@ Increase max_allowed_packet on master"; goto err; } packet->length(0); - packet->append("\0",1); + packet->append('\0'); } } diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 278839442e3..cfc7b2824ee 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -8948,28 +8948,28 @@ void st_select_lex::print(THD *thd, String *str) if (!thd) thd= current_thd; - str->append("select "); + str->append("select ", 7); //options if (options & SELECT_STRAIGHT_JOIN) - str->append("straight_join "); + str->append("straight_join ", 14); if ((thd->lex.lock_option & TL_READ_HIGH_PRIORITY) && (this == &thd->lex.select_lex)) - str->append("high_priority "); + str->append("high_priority ", 14); if (options & SELECT_DISTINCT) - str->append("distinct "); + str->append("distinct ", 9); if (options & SELECT_SMALL_RESULT) - str->append("small_result "); + str->append("small_result ", 13); if (options & SELECT_BIG_RESULT) - str->append("big_result "); + str->append("big_result ", 11); if (options & OPTION_BUFFER_RESULT) - str->append("buffer_result "); + str->append("buffer_result ", 14); if (options & OPTION_FOUND_ROWS) - str->append("calc_found_rows "); + str->append("calc_found_rows ", 16); if (!thd->lex.safe_to_cache_query) - str->append("no_cache "); + str->append("no_cache ", 9); if (options & OPTION_TO_QUERY_CACHE) - str->append("cache "); + str->append("cache ", 6); //Item List bool first= 1; @@ -8990,7 +8990,7 @@ void st_select_lex::print(THD *thd, String *str) */ if (table_list.elements) { - str->append(" from "); + str->append(" from ", 6); Item *next_on= 0; for (TABLE_LIST *table= (TABLE_LIST *) table_list.first; table; @@ -9021,7 +9021,7 @@ void st_select_lex::print(THD *thd, String *str) if (next_on) { - str->append(" on("); + str->append(" on(", 4); next_on->print(str); str->append(')'); next_on= 0; @@ -9032,17 +9032,17 @@ void st_select_lex::print(THD *thd, String *str) { if (table->outer_join & JOIN_TYPE_RIGHT) { - str->append(" right join "); + str->append(" right join ", 12); if (!(table->outer_join & JOIN_TYPE_LEFT) && table->on_expr) next_on= table->on_expr; } else if (next->straight) - str->append(" straight_join "); + str->append(" straight_join ", 15); else if (next->outer_join & JOIN_TYPE_LEFT) - str->append(" left join "); + str->append(" left join ", 11); else - str->append(" join "); + str->append(" join ", 6); } } } @@ -9053,22 +9053,22 @@ void st_select_lex::print(THD *thd, String *str) where= join->conds; if (where) { - str->append(" where "); + str->append(" where ", 7); where->print(str); } //group by & olap if (group_list.elements) { - str->append(" group by "); + str->append(" group by ", 10); print_order(str, (ORDER *) group_list.first); switch (olap) { case CUBE_TYPE: - str->append(" with cube"); + str->append(" with cube", 10); break; case ROLLUP_TYPE: - str->append(" with rollup"); + str->append(" with rollup", 12); break; default: ; //satisfy compiler @@ -9082,13 +9082,13 @@ void st_select_lex::print(THD *thd, String *str) if (having) { - str->append(" having "); + str->append(" having ", 8); having->print(str); } if (order_list.elements) { - str->append(" order by "); + str->append(" order by ", 10); print_order(str, (ORDER *) order_list.first); } diff --git a/sql/sql_show.cc b/sql/sql_show.cc index c667824224e..f4826fafff4 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1111,12 +1111,12 @@ store_create_info(THD *thd, TABLE *table, String *packet) if (field->has_charset()) { if (field->charset() == &my_charset_bin) - packet->append(" binary"); + packet->append(" binary", 7); else if (!limited_mysql_mode && !foreign_db_mode) { if (field->charset() != table->table_charset) { - packet->append(" character set "); + packet->append(" character set ", 15); packet->append(field->charset()->csname); } /* @@ -1253,32 +1253,32 @@ store_create_info(THD *thd, TABLE *table, String *packet) !(thd->variables.sql_mode & MODE_MYSQL323) && !(thd->variables.sql_mode & MODE_MYSQL40)) { - packet->append(" CHARSET="); + packet->append(" CHARSET=", 9); packet->append(table->table_charset->csname); if (!(table->table_charset->state & MY_CS_PRIMARY)) { - packet->append(" COLLATE="); + packet->append(" COLLATE=", 9); packet->append(table->table_charset->name); } } if (table->min_rows) { - packet->append(" MIN_ROWS="); + packet->append(" MIN_ROWS=", 10); end= longlong10_to_str(table->min_rows, buff, 10); packet->append(buff, (uint) (end- buff)); } if (table->max_rows) { - packet->append(" MAX_ROWS="); + packet->append(" MAX_ROWS=", 10); end= longlong10_to_str(table->max_rows, buff, 10); packet->append(buff, (uint) (end - buff)); } if (table->avg_row_length) { - packet->append(" AVG_ROW_LENGTH="); + packet->append(" AVG_ROW_LENGTH=", 16); end= longlong10_to_str(table->avg_row_length, buff,10); packet->append(buff, (uint) (end - buff)); } |