Skip to content

Commit 4155d09

Browse files
author
Alexander Barkov
committed
MDEV-8402 Bug #77473 Truncated data with subquery & UTF8
1 parent df14488 commit 4155d09

File tree

5 files changed

+119
-4
lines changed

5 files changed

+119
-4
lines changed

mysql-test/r/ctype_utf8.result

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5830,5 +5830,44 @@ OCTET_LENGTH(a) a
58305830
255 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
58315831
DROP TABLE t1;
58325832
#
5833+
# MDEV-8402 Bug#77473 Bug#21317406 TRUNCATED DATA WITH SUBQUERY & UTF8
5834+
#
5835+
#
5836+
SET NAMES utf8;
5837+
SELECT length(rpad(_utf8 0xD0B1, 65536, _utf8 0xD0B2)) AS data;
5838+
data
5839+
131072
5840+
SELECT length(data) AS len FROM (
5841+
SELECT rpad(_utf8 0xD0B1, 65536, _utf8 0xD0B2) AS data
5842+
) AS sub;
5843+
len
5844+
131072
5845+
SELECT length(rpad(_utf8 0xD0B1, 65535, _utf8 0xD0B2)) AS data;
5846+
data
5847+
131070
5848+
SELECT length(data) AS len FROM (
5849+
SELECT rpad(_utf8 0xD0B1, 65535, _utf8 0xD0B2) AS data
5850+
) AS sub;
5851+
len
5852+
131070
5853+
SELECT length(data) AS len FROM (SELECT REPEAT('ä', 36766) AS data) AS sub;
5854+
len
5855+
73532
5856+
SELECT length(data) AS len FROM (SELECT REPEAT('ä', 36767) AS data) AS sub;
5857+
len
5858+
73534
5859+
SELECT length(data) AS len FROM (SELECT REPEAT('ä', 36778) AS data) AS sub;
5860+
len
5861+
73556
5862+
SELECT length(data) AS len FROM (SELECT REPEAT('ä', 65535) AS data) AS sub;
5863+
len
5864+
131070
5865+
SELECT length(data) AS len FROM (SELECT REPEAT('ä', 65536) AS data) AS sub;
5866+
len
5867+
131072
5868+
SELECT length(data) AS len FROM (SELECT REPEAT('ä', 65537) AS data) AS sub;
5869+
len
5870+
131074
5871+
#
58335872
# End of 5.5 tests
58345873
#

mysql-test/r/ctype_utf8mb4.result

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2622,6 +2622,40 @@ OCTET_LENGTH(a) a
26222622
252 😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎
26232623
DROP TABLE t1;
26242624
#
2625+
# MDEV-8402 Bug#77473 Bug#21317406 TRUNCATED DATA WITH SUBQUERY & UTF8
2626+
#
2627+
#
2628+
SET NAMES utf8mb4;
2629+
SELECT length(repeat(_utf8mb4 0xE29883, 21844)) AS data;
2630+
data
2631+
65532
2632+
SELECT length(data) AS len
2633+
FROM ( SELECT repeat(_utf8mb4 0xE29883, 21844) AS data ) AS sub;
2634+
len
2635+
65532
2636+
SELECT length(repeat(_utf8mb4 0xE29883, 21846)) AS data;
2637+
data
2638+
65538
2639+
SELECT length(data) AS len
2640+
FROM ( SELECT repeat(_utf8mb4 0xE29883, 21846) AS data ) AS sub;
2641+
len
2642+
65538
2643+
SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 21844) AS data ) AS sub;
2644+
len
2645+
65532
2646+
SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 21845) AS data ) AS sub;
2647+
len
2648+
65535
2649+
SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 21846) AS data ) AS sub;
2650+
len
2651+
65538
2652+
SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 65535) AS data ) AS sub;
2653+
len
2654+
196605
2655+
SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 65536) AS data ) AS sub;
2656+
len
2657+
196608
2658+
#
26252659
# End of 5.5 tests
26262660
#
26272661
#

mysql-test/t/ctype_utf8.test

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1658,6 +1658,29 @@ ALTER TABLE t1 MODIFY a TINYTEXT CHARACTER SET utf8;
16581658
SELECT OCTET_LENGTH(a),a FROM t1;
16591659
DROP TABLE t1;
16601660

1661+
--echo #
1662+
--echo # MDEV-8402 Bug#77473 Bug#21317406 TRUNCATED DATA WITH SUBQUERY & UTF8
1663+
--echo #
1664+
--echo #
1665+
1666+
SET NAMES utf8;
1667+
SELECT length(rpad(_utf8 0xD0B1, 65536, _utf8 0xD0B2)) AS data;
1668+
SELECT length(data) AS len FROM (
1669+
SELECT rpad(_utf8 0xD0B1, 65536, _utf8 0xD0B2) AS data
1670+
) AS sub;
1671+
1672+
SELECT length(rpad(_utf8 0xD0B1, 65535, _utf8 0xD0B2)) AS data;
1673+
SELECT length(data) AS len FROM (
1674+
SELECT rpad(_utf8 0xD0B1, 65535, _utf8 0xD0B2) AS data
1675+
) AS sub;
1676+
1677+
SELECT length(data) AS len FROM (SELECT REPEAT('ä', 36766) AS data) AS sub;
1678+
SELECT length(data) AS len FROM (SELECT REPEAT('ä', 36767) AS data) AS sub;
1679+
SELECT length(data) AS len FROM (SELECT REPEAT('ä', 36778) AS data) AS sub;
1680+
SELECT length(data) AS len FROM (SELECT REPEAT('ä', 65535) AS data) AS sub;
1681+
SELECT length(data) AS len FROM (SELECT REPEAT('ä', 65536) AS data) AS sub;
1682+
SELECT length(data) AS len FROM (SELECT REPEAT('ä', 65537) AS data) AS sub;
1683+
16611684
--echo #
16621685
--echo # End of 5.5 tests
16631686
--echo #

mysql-test/t/ctype_utf8mb4.test

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1838,6 +1838,26 @@ SELECT OCTET_LENGTH(a),a FROM t1;
18381838
DROP TABLE t1;
18391839

18401840

1841+
--echo #
1842+
--echo # MDEV-8402 Bug#77473 Bug#21317406 TRUNCATED DATA WITH SUBQUERY & UTF8
1843+
--echo #
1844+
--echo #
1845+
1846+
SET NAMES utf8mb4;
1847+
SELECT length(repeat(_utf8mb4 0xE29883, 21844)) AS data;
1848+
SELECT length(data) AS len
1849+
FROM ( SELECT repeat(_utf8mb4 0xE29883, 21844) AS data ) AS sub;
1850+
1851+
SELECT length(repeat(_utf8mb4 0xE29883, 21846)) AS data;
1852+
SELECT length(data) AS len
1853+
FROM ( SELECT repeat(_utf8mb4 0xE29883, 21846) AS data ) AS sub;
1854+
1855+
SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 21844) AS data ) AS sub;
1856+
SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 21845) AS data ) AS sub;
1857+
SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 21846) AS data ) AS sub;
1858+
SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 65535) AS data ) AS sub;
1859+
SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 65536) AS data ) AS sub;
1860+
18411861
--echo #
18421862
--echo # End of 5.5 tests
18431863
--echo #

sql/field.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1854,10 +1854,9 @@ class Field_blob :public Field_longstr {
18541854
packlength= 4;
18551855
if (set_packlength)
18561856
{
1857-
uint32 l_char_length= len_arg/cs->mbmaxlen;
1858-
packlength= l_char_length <= 255 ? 1 :
1859-
l_char_length <= 65535 ? 2 :
1860-
l_char_length <= 16777215 ? 3 : 4;
1857+
packlength= len_arg <= 255 ? 1 :
1858+
len_arg <= 65535 ? 2 :
1859+
len_arg <= 16777215 ? 3 : 4;
18611860
}
18621861
}
18631862
Field_blob(uint32 packlength_arg)

0 commit comments

Comments
 (0)