diff options
author | Alexander Barkov <bar@mariadb.com> | 2020-08-09 14:25:22 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.com> | 2020-08-10 07:47:59 +0400 |
commit | 9b2fe4bd12e72fbb4235ec01f5013e331d87e9c3 (patch) | |
tree | 4bf0859aa31db6de7d31a59e8403afe3f5871626 /sql/protocol.cc | |
parent | 2b6dd87b2c137229863f5eb0128a869b12785cdb (diff) | |
download | mariadb-git-9b2fe4bd12e72fbb4235ec01f5013e331d87e9c3.tar.gz |
MDEV-23435 Functions do not convert numbers to character_set_results
Diffstat (limited to 'sql/protocol.cc')
-rw-r--r-- | sql/protocol.cc | 45 |
1 files changed, 27 insertions, 18 deletions
diff --git a/sql/protocol.cc b/sql/protocol.cc index c6e2339c0d0..369ef27877d 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -1200,6 +1200,16 @@ bool Protocol::store_string_aux(const char *from, size_t length, } +bool Protocol_text::store_numeric_string_aux(const char *from, size_t length) +{ + CHARSET_INFO *tocs= thd->variables.character_set_results; + // 'tocs' is NULL when the client issues SET character_set_results=NULL + if (tocs && (tocs->state & MY_CS_NONASCII)) // Conversion needed + return net_store_data_cs((uchar*) from, length, &my_charset_latin1, tocs); + return net_store_data((uchar*) from, length); // No conversion +} + + bool Protocol::store_warning(const char *from, size_t length) { BinaryStringBuffer<MYSQL_ERRMSG_SIZE> tmp; @@ -1235,8 +1245,8 @@ bool Protocol_text::store_tiny(longlong from) field_pos++; #endif char buff[22]; - return net_store_data((uchar*) buff, - (size_t) (int10_to_str((int) from, buff, -10) - buff)); + size_t length= (size_t) (int10_to_str((int) from, buff, -10) - buff); + return store_numeric_string_aux(buff, length); } @@ -1247,9 +1257,8 @@ bool Protocol_text::store_short(longlong from) field_pos++; #endif char buff[22]; - return net_store_data((uchar*) buff, - (size_t) (int10_to_str((int) from, buff, -10) - - buff)); + size_t length= (size_t) (int10_to_str((int) from, buff, -10) - buff); + return store_numeric_string_aux(buff, length); } @@ -1260,9 +1269,9 @@ bool Protocol_text::store_long(longlong from) field_pos++; #endif char buff[22]; - return net_store_data((uchar*) buff, - (size_t) (int10_to_str((long int)from, buff, - (from <0)?-10:10)-buff)); + size_t length= (size_t) (int10_to_str((long int)from, buff, + (from < 0) ? - 10 : 10) - buff); + return store_numeric_string_aux(buff, length); } @@ -1273,10 +1282,10 @@ bool Protocol_text::store_longlong(longlong from, bool unsigned_flag) field_pos++; #endif char buff[22]; - return net_store_data((uchar*) buff, - (size_t) (longlong10_to_str(from,buff, - unsigned_flag ? 10 : -10)- - buff)); + size_t length= (size_t) (longlong10_to_str(from, buff, + unsigned_flag ? 10 : -10) - + buff); + return store_numeric_string_aux(buff, length); } @@ -1288,7 +1297,7 @@ bool Protocol_text::store_decimal(const my_decimal *d) #endif StringBuffer<DECIMAL_MAX_STR_LENGTH> str; (void) d->to_string(&str); - return net_store_data((uchar*) str.ptr(), str.length()); + return store_numeric_string_aux(str.ptr(), str.length()); } @@ -1299,7 +1308,7 @@ bool Protocol_text::store(float from, uint32 decimals, String *buffer) field_pos++; #endif Float(from).to_string(buffer, decimals); - return net_store_data((uchar*) buffer->ptr(), buffer->length()); + return store_numeric_string_aux(buffer->ptr(), buffer->length()); } @@ -1310,7 +1319,7 @@ bool Protocol_text::store(double from, uint32 decimals, String *buffer) field_pos++; #endif buffer->set_real(from, decimals, thd->charset()); - return net_store_data((uchar*) buffer->ptr(), buffer->length()); + return store_numeric_string_aux(buffer->ptr(), buffer->length()); } @@ -1350,7 +1359,7 @@ bool Protocol_text::store(MYSQL_TIME *tm, int decimals) #endif char buff[MAX_DATE_STRING_REP_LENGTH]; uint length= my_datetime_to_str(tm, buff, decimals); - return net_store_data((uchar*) buff, length); + return store_numeric_string_aux(buff, length); } @@ -1362,7 +1371,7 @@ bool Protocol_text::store_date(MYSQL_TIME *tm) #endif char buff[MAX_DATE_STRING_REP_LENGTH]; size_t length= my_date_to_str(tm, buff); - return net_store_data((uchar*) buff, length); + return store_numeric_string_aux(buff, length); } @@ -1374,7 +1383,7 @@ bool Protocol_text::store_time(MYSQL_TIME *tm, int decimals) #endif char buff[MAX_DATE_STRING_REP_LENGTH]; uint length= my_time_to_str(tm, buff, decimals); - return net_store_data((uchar*) buff, length); + return store_numeric_string_aux(buff, length); } /** |