mirror of
https://github.com/MariaDB/server.git
synced 2025-01-20 14:02:32 +01:00
fdc4779235
Storage engine independent support for column compression. TINYBLOB, BLOB, MEDIUMBLOB, LONGBLOB, TINYTEXT, TEXT, MEDIUMTEXT, LONGTEXT, VARCHAR and VARBINARY columns can be compressed. New COMPRESSED column attribute added: COMPRESSED[=<compression_method>] System variables added: column_compression_threshold column_compression_zlib_level column_compression_zlib_strategy column_compression_zlib_wrap Status variables added: Column_compressions Column_decompressions Limitations: - the only supported method currently is zlib - CSV storage engine stores data uncompressed on-disk even if COMPRESSED attribute is present - it is not possible to create indexes over compressed columns.
81 lines
2.2 KiB
Text
81 lines
2.2 KiB
Text
--source include/have_innodb.inc
|
|
--source include/have_csv.inc
|
|
|
|
let $MYSQLD_DATADIR= `select @@datadir`;
|
|
|
|
SET column_compression_zlib_wrap=true;
|
|
let $typec= BLOB COMPRESSED;
|
|
let $typeu= BLOB;
|
|
--source column_compression.inc
|
|
|
|
let $typec= TEXT COMPRESSED;
|
|
let $typeu= TEXT;
|
|
--source column_compression.inc
|
|
|
|
let $typec= VARBINARY(10000) COMPRESSED;
|
|
let $typeu= VARBINARY(10000);
|
|
--source column_compression.inc
|
|
|
|
let $typec= VARCHAR(10000) COMPRESSED;
|
|
let $typeu= VARCHAR(10000);
|
|
--source column_compression.inc
|
|
|
|
let $typec= TEXT CHARSET ucs2 COMPRESSED;
|
|
let $typeu= TEXT;
|
|
--source column_compression.inc
|
|
|
|
SET column_compression_zlib_wrap=DEFAULT;
|
|
let $typec= BLOB COMPRESSED;
|
|
let $typeu= BLOB;
|
|
--source column_compression.inc
|
|
|
|
--error ER_WRONG_FIELD_SPEC
|
|
CREATE TABLE t1(a CHAR(100) COMPRESSED);
|
|
--error ER_WRONG_FIELD_SPEC
|
|
CREATE TABLE t1(a INT COMPRESSED);
|
|
--error ER_UNKNOWN_COMPRESSION_METHOD
|
|
CREATE TABLE t1(a BLOB COMPRESSED=unknown);
|
|
CREATE TABLE t1(a BLOB COMPRESSED COMPRESSED);
|
|
DROP TABLE t1;
|
|
CREATE TABLE t1(a INT);
|
|
--error ER_WRONG_FIELD_SPEC
|
|
ALTER TABLE t1 MODIFY a INT COMPRESSED;
|
|
DROP TABLE t1;
|
|
|
|
--echo # Test CSV
|
|
CREATE TABLE t1(a BLOB NOT NULL COMPRESSED) ENGINE=CSV;
|
|
INSERT INTO t1 VALUES(REPEAT('a', 110));
|
|
SELECT LENGTH(a) FROM t1;
|
|
ALTER TABLE t1 ENGINE=MyISAM;
|
|
SELECT LENGTH(a) FROM t1;
|
|
ALTER TABLE t1 ENGINE=CSV;
|
|
SELECT LENGTH(a) FROM t1;
|
|
SHOW CREATE TABLE t1;
|
|
--cat_file $MYSQLD_DATADIR/test/t1.CSV
|
|
DROP TABLE t1;
|
|
|
|
--echo # Test fields that don't fit data
|
|
CREATE TABLE t1(a VARCHAR(9) COMPRESSED);
|
|
--error ER_DATA_TOO_LONG
|
|
INSERT INTO t1 VALUES(REPEAT('a', 10));
|
|
INSERT INTO t1 VALUES(REPEAT(' ', 10));
|
|
SELECT a, LENGTH(a) FROM t1;
|
|
DROP TABLE t1;
|
|
|
|
CREATE TABLE t1(a TINYTEXT COMPRESSED);
|
|
SET column_compression_threshold=300;
|
|
--error ER_DATA_TOO_LONG
|
|
INSERT INTO t1 VALUES(REPEAT('a', 255));
|
|
INSERT INTO t1 VALUES(REPEAT(' ', 255));
|
|
SET column_compression_threshold=DEFAULT;
|
|
SELECT a, LENGTH(a) FROM t1;
|
|
DROP TABLE t1;
|
|
|
|
--echo # Corner case: VARCHAR(255) COMPRESSED must have 2 bytes pack length
|
|
CREATE TABLE t1(a VARCHAR(255) COMPRESSED);
|
|
SHOW CREATE TABLE t1;
|
|
SET column_compression_threshold=300;
|
|
INSERT INTO t1 VALUES(REPEAT('a', 255));
|
|
SET column_compression_threshold=DEFAULT;
|
|
SELECT a, LENGTH(a) FROM t1;
|
|
DROP TABLE t1;
|