Commit 33721d91 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-16134 Wrong I_S.COLUMNS.CHARACTER_XXX_LENGTH value for compressed columns

parent fc63c1e1
...@@ -1403,3 +1403,19 @@ SELECT CHAR_LENGTH(a), CHAR_LENGTH(b), LEFT(a, 10), LEFT(b, 10) FROM t1; ...@@ -1403,3 +1403,19 @@ SELECT CHAR_LENGTH(a), CHAR_LENGTH(b), LEFT(a, 10), LEFT(b, 10) FROM t1;
CHAR_LENGTH(a) CHAR_LENGTH(b) LEFT(a, 10) LEFT(b, 10) CHAR_LENGTH(a) CHAR_LENGTH(b) LEFT(a, 10) LEFT(b, 10)
254 254 aaaaaaaaaa aaaaaaaaaa 254 254 aaaaaaaaaa aaaaaaaaaa
DROP TABLE t1; DROP TABLE t1;
#
# MDEV-16134 Wrong I_S.COLUMNS.CHARACTER_XXX_LENGTH value for compressed columns
#
CREATE TABLE t1
(
a VARCHAR(10) CHARACTER SET latin1 COMPRESSED,
b VARCHAR(10) CHARACTER SET utf8 COMPRESSED
);
SELECT COLUMN_NAME, CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1' AND COLUMN_NAME IN ('a','b')
ORDER BY COLUMN_NAME;
COLUMN_NAME CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH
a 10 10
b 10 30
DROP TABLE t1;
...@@ -120,3 +120,19 @@ CREATE TABLE t1(a TINYTEXT COMPRESSED, b TINYTEXT) CHARACTER SET utf8; ...@@ -120,3 +120,19 @@ CREATE TABLE t1(a TINYTEXT COMPRESSED, b TINYTEXT) CHARACTER SET utf8;
INSERT INTO t1 VALUES (REPEAT(_latin1'a', 254), REPEAT(_latin1'a', 254)); INSERT INTO t1 VALUES (REPEAT(_latin1'a', 254), REPEAT(_latin1'a', 254));
SELECT CHAR_LENGTH(a), CHAR_LENGTH(b), LEFT(a, 10), LEFT(b, 10) FROM t1; SELECT CHAR_LENGTH(a), CHAR_LENGTH(b), LEFT(a, 10), LEFT(b, 10) FROM t1;
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # MDEV-16134 Wrong I_S.COLUMNS.CHARACTER_XXX_LENGTH value for compressed columns
--echo #
CREATE TABLE t1
(
a VARCHAR(10) CHARACTER SET latin1 COMPRESSED,
b VARCHAR(10) CHARACTER SET utf8 COMPRESSED
);
SELECT COLUMN_NAME, CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1' AND COLUMN_NAME IN ('a','b')
ORDER BY COLUMN_NAME;
DROP TABLE t1;
...@@ -1737,7 +1737,7 @@ class Field_str :public Field { ...@@ -1737,7 +1737,7 @@ class Field_str :public Field {
Information_schema_character_attributes Information_schema_character_attributes
information_schema_character_attributes() const information_schema_character_attributes() const
{ {
return Information_schema_character_attributes(field_length, return Information_schema_character_attributes(max_display_length(),
char_length()); char_length());
} }
friend class Create_field; friend class Create_field;
...@@ -3448,6 +3448,10 @@ class Field_varstring_compressed: public Field_varstring { ...@@ -3448,6 +3448,10 @@ class Field_varstring_compressed: public Field_varstring {
str.append(STRING_WITH_LEN(" /*!100301 COMPRESSED*/")); str.append(STRING_WITH_LEN(" /*!100301 COMPRESSED*/"));
} }
uint32 max_display_length() const { return field_length - 1; } uint32 max_display_length() const { return field_length - 1; }
uint32 char_length() const
{
return (field_length - 1) / field_charset->mbmaxlen;
}
int cmp_max(const uchar *a_ptr, const uchar *b_ptr, uint max_len); int cmp_max(const uchar *a_ptr, const uchar *b_ptr, uint max_len);
/* /*
......
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