1
0
mirror of https://github.com/MariaDB/server.git synced 2025-06-04 18:03:14 +03:00
mariadb/mysql-test/suite/compat/oracle/t/column_compression.test
Alexander Barkov 5352e9687a MDEV-17363 - Compressed columns cannot be restored from dump
In collaboration with Sergey Vojtovich <svoj@mariadb.org>

The COMPRESSED clause is now a part of the data type and goes immediately
after the data type and length, but before the CHARACTER SET clause,
and before column attributes such as DEFAULT, COLLATE, ON UPDATE,
SYSTEM VERSIONING, engine specific column attributes.

In the old reduction, the COMPRESSED clause was a column attribute.

New syntax:
  <varchar or text data type> <length> <compression> <character set> <column attributes>
  <varbinary or blob data type> <length> <compression> <column attributes>

New syntax examples:
  VARCHAR(1000) COMPRESSED CHARACTER SET latin1 DEFAULT ''
  BLOB COMPRESSED DEFAULT ''

Deprecate syntax examples:
  VARCHAR(1000) CHARACTER SET latin1 COMPRESSED DEFAULT ''
  TEXT          CHARACTER SET latin1 DEFAULT '' COMPRESSED
  VARBINARY(1000) DEFAULT '' COMPRESSED

As a side effect:
- COMPRESSED is not valid as an SP label name in SQL/PSM routines any more
  (but it's still valid as an SP label name in sql_mode=ORACLE)

- COMPRESSED is now allowed in combination with GENERATED ALWAYS AS:

  TEXT COMPRESSED GENERATED ALWAYS AS REPEAT('a',1000)
2019-06-18 07:48:08 +04:00

85 lines
1.9 KiB
Plaintext

--source include/have_innodb.inc
--source include/have_csv.inc
SET sql_mode=ORACLE;
SET column_compression_zlib_wrap=true;
CREATE TABLE t1 (a BLOB COMPRESSED);
INSERT INTO t1 VALUES (REPEAT('a',10000));
SELECT DATA_LENGTH<100 AS c FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='test';
DROP TABLE t1;
--echo #
--echo # MDEV-17363 - Compressed columns cannot be restored from dump
--echo #
--error ER_WRONG_FIELD_SPEC
CREATE TABLE t1(a INT NOT NULL COMPRESSED);
SHOW WARNINGS;
CREATE TABLE t1(
a JSON COMPRESSED,
b VARCHAR(1000) COMPRESSED BINARY,
c NVARCHAR(1000) COMPRESSED BINARY,
d TINYTEXT COMPRESSED BINARY
);
SHOW CREATE TABLE t1;
DROP TABLE t1;
--echo #
--echo # VARCHAR and TEXT variants
--echo #
--let type=VARCHAR(10)
--source include/column_compression_syntax_varchar.inc
--let type=VARCHAR2(10)
--source include/column_compression_syntax_varchar.inc
--let type=TINYTEXT
--source include/column_compression_syntax_varchar.inc
--let type=TEXT
--source include/column_compression_syntax_varchar.inc
--let type=MEDIUMTEXT
--source include/column_compression_syntax_varchar.inc
--let type=LONGTEXT
--source include/column_compression_syntax_varchar.inc
--echo #
--echo # VARBINARY and BLOB variables
--echo #
--let type=VARCHAR(10)
--source include/column_compression_syntax_varbinary.inc
--let type=TINYBLOB
--source include/column_compression_syntax_varbinary.inc
--let type=BLOB
--source include/column_compression_syntax_varbinary.inc
--let type=MEDIUMBLOB
--source include/column_compression_syntax_varbinary.inc
--let type=LONGBLOB
--source include/column_compression_syntax_varbinary.inc
--echo #
--echo # NVARCHAR
--echo #
CREATE TABLE t1 (a NVARCHAR(10) COMPRESSED);
SHOW CREATE TABLE t1;
DROP TABLE t1;
--error ER_PARSE_ERROR
CREATE TABLE t1 (a NVARCHAR(10) COMPRESSED BINARY COMPRESSED);
--error ER_PARSE_ERROR
CREATE TABLE t1 (a NVARCHAR(10) COMPRESSED DEFAULT '' COMPRESSED);