Commit ca695888 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-14116 INET6_NTOA output is set as null to varchar(39) variable

parent 6a524fcf
...@@ -1407,3 +1407,17 @@ SELECT CONCAT(NAME_CONST('name',15),'오'); ...@@ -1407,3 +1407,17 @@ SELECT CONCAT(NAME_CONST('name',15),'오');
CONCAT(NAME_CONST('name',15),'오') CONCAT(NAME_CONST('name',15),'오')
15오 15오
SET NAMES latin1; SET NAMES latin1;
#
# MDEV-14116 INET6_NTOA output is set as null to varchar(39) variable
#
CREATE PROCEDURE p1()
BEGIN
DECLARE ip_full_addr varchar(39) DEFAULT "";
SELECT INET6_NTOA(UNHEX('20000000000000000000000000000000')) into ip_full_addr;
SELECT ip_full_addr;
END;
$$
CALL p1();
ip_full_addr
2000::
DROP PROCEDURE p1;
...@@ -1091,3 +1091,19 @@ SELECT COERCIBILITY(NAME_CONST('name',TIME'00:00:00')); ...@@ -1091,3 +1091,19 @@ SELECT COERCIBILITY(NAME_CONST('name',TIME'00:00:00'));
SELECT COERCIBILITY(NAME_CONST('name',15)); SELECT COERCIBILITY(NAME_CONST('name',15));
SELECT CONCAT(NAME_CONST('name',15),'오'); SELECT CONCAT(NAME_CONST('name',15),'오');
SET NAMES latin1; SET NAMES latin1;
--echo #
--echo # MDEV-14116 INET6_NTOA output is set as null to varchar(39) variable
--echo #
DELIMITER $$;
CREATE PROCEDURE p1()
BEGIN
DECLARE ip_full_addr varchar(39) DEFAULT "";
SELECT INET6_NTOA(UNHEX('20000000000000000000000000000000')) into ip_full_addr;
SELECT ip_full_addr;
END;
$$
DELIMITER ;$$
CALL p1();
DROP PROCEDURE p1;
...@@ -181,7 +181,8 @@ String *Item_func_inet_str_base::val_str_ascii(String *buffer) ...@@ -181,7 +181,8 @@ String *Item_func_inet_str_base::val_str_ascii(String *buffer)
return NULL; return NULL;
} }
String *arg_str= args[0]->val_str(buffer); StringBuffer<STRING_BUFFER_USUAL_SIZE> tmp;
String *arg_str= args[0]->val_str(&tmp);
if (!arg_str) // Out-of memory happened. The error has been reported. if (!arg_str) // Out-of memory happened. The error has been reported.
{ // Or: the underlying field is NULL { // Or: the underlying field is NULL
null_value= true; null_value= true;
...@@ -679,7 +680,7 @@ static void ipv6_to_str(const in6_addr *ipv6, char *str) ...@@ -679,7 +680,7 @@ static void ipv6_to_str(const in6_addr *ipv6, char *str)
@retval true The string has been converted sucessfully. @retval true The string has been converted sucessfully.
*/ */
bool Item_func_inet6_aton::calc_value(String *arg, String *buffer) bool Item_func_inet6_aton::calc_value(const String *arg, String *buffer)
{ {
// ipv4-string -> varbinary(4) // ipv4-string -> varbinary(4)
// ipv6-string -> varbinary(16) // ipv6-string -> varbinary(16)
...@@ -719,7 +720,7 @@ bool Item_func_inet6_aton::calc_value(String *arg, String *buffer) ...@@ -719,7 +720,7 @@ bool Item_func_inet6_aton::calc_value(String *arg, String *buffer)
@retval true The string has been converted sucessfully. @retval true The string has been converted sucessfully.
*/ */
bool Item_func_inet6_ntoa::calc_value(String *arg, String *buffer) bool Item_func_inet6_ntoa::calc_value(const String *arg, String *buffer)
{ {
if (arg->charset() != &my_charset_bin) if (arg->charset() != &my_charset_bin)
return false; return false;
......
...@@ -99,7 +99,7 @@ class Item_func_inet_str_base : public Item_str_ascii_func ...@@ -99,7 +99,7 @@ class Item_func_inet_str_base : public Item_str_ascii_func
virtual String *val_str_ascii(String *buffer); virtual String *val_str_ascii(String *buffer);
protected: protected:
virtual bool calc_value(String *arg, String *buffer) = 0; virtual bool calc_value(const String *arg, String *buffer) = 0;
}; };
...@@ -126,7 +126,7 @@ class Item_func_inet6_aton : public Item_func_inet_str_base ...@@ -126,7 +126,7 @@ class Item_func_inet6_aton : public Item_func_inet_str_base
} }
protected: protected:
virtual bool calc_value(String *arg, String *buffer); virtual bool calc_value(const String *arg, String *buffer);
}; };
...@@ -158,7 +158,7 @@ class Item_func_inet6_ntoa : public Item_func_inet_str_base ...@@ -158,7 +158,7 @@ class Item_func_inet6_ntoa : public Item_func_inet_str_base
} }
protected: protected:
virtual bool calc_value(String *arg, String *buffer); virtual bool calc_value(const String *arg, String *buffer);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment