1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

MDEV-35416 CONV(1<<63, 10, -2) fails with --view-protocol

Item_func_conv::fix_length_and_dec() incorrectly set maximum
length as 64 character. But for negative numbers it can
return up to 65 charcters (including the sign).
This commit is contained in:
Alexander Barkov
2024-11-14 17:05:31 +04:00
parent 3b20045071
commit c4843c10a3
3 changed files with 23 additions and 5 deletions

View File

@@ -745,9 +745,9 @@ encode('abcd','ab')
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`bin(130)` varchar(64) DEFAULT NULL, `bin(130)` varchar(65) DEFAULT NULL,
`oct(130)` varchar(64) DEFAULT NULL, `oct(130)` varchar(65) DEFAULT NULL,
`conv(130,16,10)` varchar(64) DEFAULT NULL, `conv(130,16,10)` varchar(65) DEFAULT NULL,
`hex(130)` varchar(16) DEFAULT NULL, `hex(130)` varchar(16) DEFAULT NULL,
`char(130)` varbinary(4) DEFAULT NULL, `char(130)` varbinary(4) DEFAULT NULL,
`format(130,10)` varchar(25) DEFAULT NULL, `format(130,10)` varchar(25) DEFAULT NULL,
@@ -5260,7 +5260,7 @@ conv(i,16,2)
SHOW CREATE TABLE t2; SHOW CREATE TABLE t2;
Table Create Table Table Create Table
t2 CREATE TABLE `t2` ( t2 CREATE TABLE `t2` (
`conv(i,16,2)` varchar(64) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL `conv(i,16,2)` varchar(65) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
DROP TABLE t1,t2; DROP TABLE t1,t2;
# #
@@ -5397,5 +5397,15 @@ SELECT CONV(1<<63, 10, -2);
CONV(1<<63, 10, -2) CONV(1<<63, 10, -2)
-1000000000000000000000000000000000000000000000000000000000000000 -1000000000000000000000000000000000000000000000000000000000000000
# #
# MDEV-35416 CONV(1<<63, 10, -2) fails with --view-protocol
#
CREATE TABLE t1 AS SELECT CONV(1<<63, 10, -2) AS c1;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` varchar(65) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
DROP TABLE t1;
#
# End of 10.6 tests # End of 10.6 tests
# #

View File

@@ -2439,6 +2439,14 @@ DROP TABLE t0;
SELECT CONV(-29223372036854775809, -10, 18446744073709551614); SELECT CONV(-29223372036854775809, -10, 18446744073709551614);
SELECT CONV(1<<63, 10, -2); SELECT CONV(1<<63, 10, -2);
--echo #
--echo # MDEV-35416 CONV(1<<63, 10, -2) fails with --view-protocol
--echo #
CREATE TABLE t1 AS SELECT CONV(1<<63, 10, -2) AS c1;
SHOW CREATE TABLE t1;
DROP TABLE t1;
--echo # --echo #
--echo # End of 10.6 tests --echo # End of 10.6 tests
--echo # --echo #

View File

@@ -1547,7 +1547,7 @@ public:
bool fix_length_and_dec() override bool fix_length_and_dec() override
{ {
collation.set(default_charset()); collation.set(default_charset());
fix_char_length(64); fix_char_length(65);
set_maybe_null(); set_maybe_null();
return FALSE; return FALSE;
} }