summaryrefslogtreecommitdiff
path: root/sql/thr_malloc.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/thr_malloc.cc')
-rw-r--r--sql/thr_malloc.cc32
1 files changed, 31 insertions, 1 deletions
diff --git a/sql/thr_malloc.cc b/sql/thr_malloc.cc
index 8b9baa6f045..fa678ec7de2 100644
--- a/sql/thr_malloc.cc
+++ b/sql/thr_malloc.cc
@@ -24,7 +24,7 @@ extern "C" {
{
THD *thd=current_thd;
if (thd) // QQ; To be removed
- thd->fatal_error=1; /* purecov: inspected */
+ thd->fatal_error(); /* purecov: inspected */
sql_print_error(ER(ER_OUT_OF_RESOURCES));
}
}
@@ -85,3 +85,33 @@ gptr sql_memdup(const void *ptr,uint len)
void sql_element_free(void *ptr __attribute__((unused)))
{} /* purecov: deadcode */
+
+
+
+char *sql_strmake_with_convert(const char *str, uint32 arg_length,
+ CHARSET_INFO *from_cs,
+ uint32 max_res_length,
+ CHARSET_INFO *to_cs, uint32 *result_length)
+{
+ char *pos;
+ uint32 new_length= to_cs->mbmaxlen*arg_length;
+ max_res_length--; // Reserve place for end null
+
+ set_if_smaller(new_length, max_res_length);
+ if (!(pos= sql_alloc(new_length+1)))
+ return pos; // Error
+
+ if ((from_cs == &my_charset_bin) || (to_cs == &my_charset_bin))
+ {
+ // Safety if to_cs->mbmaxlen > 0
+ new_length= min(arg_length, max_res_length);
+ memcpy(pos, str, new_length);
+ }
+ else
+ new_length= copy_and_convert((char*) pos, new_length, to_cs, str,
+ arg_length, from_cs);
+ pos[new_length]= 0;
+ *result_length= new_length;
+ return pos;
+}
+