diff options
author | Alexander Barkov <bar@mariadb.org> | 2016-06-10 17:06:38 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.org> | 2016-06-10 17:06:38 +0400 |
commit | 4155d0937b98e57a93adbe5b5dc20d06ceda59e7 (patch) | |
tree | 165bc57c43c4db2ca7dad2b95a275c3386dca5dc | |
parent | df1448801ceba4d8d8a02db83ba022fea9e6755d (diff) | |
download | mariadb-git-4155d0937b98e57a93adbe5b5dc20d06ceda59e7.tar.gz |
MDEV-8402 Bug #77473 Truncated data with subquery & UTF8
-rw-r--r-- | mysql-test/r/ctype_utf8.result | 39 | ||||
-rw-r--r-- | mysql-test/r/ctype_utf8mb4.result | 34 | ||||
-rw-r--r-- | mysql-test/t/ctype_utf8.test | 23 | ||||
-rw-r--r-- | mysql-test/t/ctype_utf8mb4.test | 20 | ||||
-rw-r--r-- | sql/field.h | 7 |
5 files changed, 119 insertions, 4 deletions
diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result index 217d3ca26d8..121168c2a2a 100644 --- a/mysql-test/r/ctype_utf8.result +++ b/mysql-test/r/ctype_utf8.result @@ -5830,5 +5830,44 @@ OCTET_LENGTH(a) a 255 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA DROP TABLE t1; # +# MDEV-8402 Bug#77473 Bug#21317406 TRUNCATED DATA WITH SUBQUERY & UTF8 +# +# +SET NAMES utf8; +SELECT length(rpad(_utf8 0xD0B1, 65536, _utf8 0xD0B2)) AS data; +data +131072 +SELECT length(data) AS len FROM ( +SELECT rpad(_utf8 0xD0B1, 65536, _utf8 0xD0B2) AS data +) AS sub; +len +131072 +SELECT length(rpad(_utf8 0xD0B1, 65535, _utf8 0xD0B2)) AS data; +data +131070 +SELECT length(data) AS len FROM ( +SELECT rpad(_utf8 0xD0B1, 65535, _utf8 0xD0B2) AS data +) AS sub; +len +131070 +SELECT length(data) AS len FROM (SELECT REPEAT('ä', 36766) AS data) AS sub; +len +73532 +SELECT length(data) AS len FROM (SELECT REPEAT('ä', 36767) AS data) AS sub; +len +73534 +SELECT length(data) AS len FROM (SELECT REPEAT('ä', 36778) AS data) AS sub; +len +73556 +SELECT length(data) AS len FROM (SELECT REPEAT('ä', 65535) AS data) AS sub; +len +131070 +SELECT length(data) AS len FROM (SELECT REPEAT('ä', 65536) AS data) AS sub; +len +131072 +SELECT length(data) AS len FROM (SELECT REPEAT('ä', 65537) AS data) AS sub; +len +131074 +# # End of 5.5 tests # diff --git a/mysql-test/r/ctype_utf8mb4.result b/mysql-test/r/ctype_utf8mb4.result index 448645ebbae..17a1a2f787e 100644 --- a/mysql-test/r/ctype_utf8mb4.result +++ b/mysql-test/r/ctype_utf8mb4.result @@ -2622,6 +2622,40 @@ OCTET_LENGTH(a) a 252 😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎 DROP TABLE t1; # +# MDEV-8402 Bug#77473 Bug#21317406 TRUNCATED DATA WITH SUBQUERY & UTF8 +# +# +SET NAMES utf8mb4; +SELECT length(repeat(_utf8mb4 0xE29883, 21844)) AS data; +data +65532 +SELECT length(data) AS len +FROM ( SELECT repeat(_utf8mb4 0xE29883, 21844) AS data ) AS sub; +len +65532 +SELECT length(repeat(_utf8mb4 0xE29883, 21846)) AS data; +data +65538 +SELECT length(data) AS len +FROM ( SELECT repeat(_utf8mb4 0xE29883, 21846) AS data ) AS sub; +len +65538 +SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 21844) AS data ) AS sub; +len +65532 +SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 21845) AS data ) AS sub; +len +65535 +SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 21846) AS data ) AS sub; +len +65538 +SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 65535) AS data ) AS sub; +len +196605 +SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 65536) AS data ) AS sub; +len +196608 +# # End of 5.5 tests # # diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test index a9b5cee11ce..d6fdc6c6a2c 100644 --- a/mysql-test/t/ctype_utf8.test +++ b/mysql-test/t/ctype_utf8.test @@ -1659,5 +1659,28 @@ SELECT OCTET_LENGTH(a),a FROM t1; DROP TABLE t1; --echo # +--echo # MDEV-8402 Bug#77473 Bug#21317406 TRUNCATED DATA WITH SUBQUERY & UTF8 +--echo # +--echo # + +SET NAMES utf8; +SELECT length(rpad(_utf8 0xD0B1, 65536, _utf8 0xD0B2)) AS data; +SELECT length(data) AS len FROM ( + SELECT rpad(_utf8 0xD0B1, 65536, _utf8 0xD0B2) AS data +) AS sub; + +SELECT length(rpad(_utf8 0xD0B1, 65535, _utf8 0xD0B2)) AS data; +SELECT length(data) AS len FROM ( + SELECT rpad(_utf8 0xD0B1, 65535, _utf8 0xD0B2) AS data +) AS sub; + +SELECT length(data) AS len FROM (SELECT REPEAT('ä', 36766) AS data) AS sub; +SELECT length(data) AS len FROM (SELECT REPEAT('ä', 36767) AS data) AS sub; +SELECT length(data) AS len FROM (SELECT REPEAT('ä', 36778) AS data) AS sub; +SELECT length(data) AS len FROM (SELECT REPEAT('ä', 65535) AS data) AS sub; +SELECT length(data) AS len FROM (SELECT REPEAT('ä', 65536) AS data) AS sub; +SELECT length(data) AS len FROM (SELECT REPEAT('ä', 65537) AS data) AS sub; + +--echo # --echo # End of 5.5 tests --echo # diff --git a/mysql-test/t/ctype_utf8mb4.test b/mysql-test/t/ctype_utf8mb4.test index 66f5a3ba5ac..c240f261af4 100644 --- a/mysql-test/t/ctype_utf8mb4.test +++ b/mysql-test/t/ctype_utf8mb4.test @@ -1839,6 +1839,26 @@ DROP TABLE t1; --echo # +--echo # MDEV-8402 Bug#77473 Bug#21317406 TRUNCATED DATA WITH SUBQUERY & UTF8 +--echo # +--echo # + +SET NAMES utf8mb4; +SELECT length(repeat(_utf8mb4 0xE29883, 21844)) AS data; +SELECT length(data) AS len +FROM ( SELECT repeat(_utf8mb4 0xE29883, 21844) AS data ) AS sub; + +SELECT length(repeat(_utf8mb4 0xE29883, 21846)) AS data; +SELECT length(data) AS len +FROM ( SELECT repeat(_utf8mb4 0xE29883, 21846) AS data ) AS sub; + +SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 21844) AS data ) AS sub; +SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 21845) AS data ) AS sub; +SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 21846) AS data ) AS sub; +SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 65535) AS data ) AS sub; +SELECT LENGTH(data) AS len FROM (SELECT REPEAT('☃', 65536) AS data ) AS sub; + +--echo # --echo # End of 5.5 tests --echo # diff --git a/sql/field.h b/sql/field.h index fdf229edfbb..f8fc7427618 100644 --- a/sql/field.h +++ b/sql/field.h @@ -1854,10 +1854,9 @@ public: packlength= 4; if (set_packlength) { - uint32 l_char_length= len_arg/cs->mbmaxlen; - packlength= l_char_length <= 255 ? 1 : - l_char_length <= 65535 ? 2 : - l_char_length <= 16777215 ? 3 : 4; + packlength= len_arg <= 255 ? 1 : + len_arg <= 65535 ? 2 : + len_arg <= 16777215 ? 3 : 4; } } Field_blob(uint32 packlength_arg) |