diff options
author | Monty <monty@mariadb.org> | 2020-09-03 20:27:12 +0300 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2021-05-19 22:54:11 +0200 |
commit | 949d10bea27050970bf04aeaac4217e24997ce95 (patch) | |
tree | 4b1278de9d03ef2f858e4d12551d430c94eceaff /sql/procedure.h | |
parent | a206658b985fe5e18fb5692fdb3698dad5aca70a (diff) | |
download | mariadb-git-949d10bea27050970bf04aeaac4217e24997ce95.tar.gz |
Don't reset StringBuffers in loops when not needed
- Moved out creating StringBuffers in loops and instead create them
outside and just reset the buffer if it was not allocated (to avoid
a possible malloc/free for every entry)
Other things related to set_buffer_if_not_allocated()
- Changed Valuebuffer to not call set_buffer_if_not_allocated() when
it is created.
- Fixed geometry functions to reset string length before calling
String::reserve(). This is because one should not access length()
of an undefined.
- Added Item_func_conv_charset::save_in_field() as the item is using
str_value to store cached values, which conflicts with
Item::save_str_in_field().
- Changed Item_proc_string to not store the string value in sql_string
as this clashes with Item::save_str_in_field().
- Locally store value of full_name_cstring() in analyse::end_of_records()
as Item::save_str_in_field() may overwrite it.
- Marked some strings as set_thread_specific()
- Added String::free_buffer() to be used internally in String functions
to just free the buffer but not reset other String values.
- Fixed uses_buffer_owned_by() to check for allocated length instead of
strlength, which could be marked MEM_UNDEFINED().
Diffstat (limited to 'sql/procedure.h')
-rw-r--r-- | sql/procedure.h | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/sql/procedure.h b/sql/procedure.h index c83a52ff19c..c59b766d2b9 100644 --- a/sql/procedure.h +++ b/sql/procedure.h @@ -130,34 +130,40 @@ public: class Item_proc_string :public Item_proc { + String value; public: Item_proc_string(THD *thd, const char *name_par, uint length): - Item_proc(thd, name_par) { this->max_length=length; } + Item_proc(thd, name_par) + { + this->max_length=length; + value.set_thread_specific(); + } const Type_handler *type_handler() const override { return &type_handler_varchar; } - void set(double nr) override { str_value.set_real(nr, 2, default_charset()); } - void set(longlong nr) override { str_value.set(nr, default_charset()); } + void set(double nr) override { value.set_real(nr, 2, default_charset()); } + void set(longlong nr) override { value.set(nr, default_charset()); } void set(const char *str, uint length, CHARSET_INFO *cs) override - { str_value.copy(str,length,cs); } + { value.copy(str,length,cs); } double val_real() override { int err_not_used; char *end_not_used; - CHARSET_INFO *cs= str_value.charset(); - return cs->strntod((char*) str_value.ptr(), str_value.length(), + CHARSET_INFO *cs= value.charset(); + return cs->strntod((char*) value.ptr(), value.length(), &end_not_used, &err_not_used); } longlong val_int() override { int err; - CHARSET_INFO *cs=str_value.charset(); - return cs->strntoll(str_value.ptr(),str_value.length(),10,NULL,&err); + CHARSET_INFO *cs=value.charset(); + return cs->strntoll(value.ptr(), value.length(), 10, NULL, &err); } String *val_str(String*) override { - return null_value ? (String*) 0 : (String*) &str_value; + return null_value ? (String*) 0 : &value; } my_decimal *val_decimal(my_decimal *) override; + void cleanup() override { value.free(); } unsigned int size_of() { return sizeof(*this);} }; |