Commit 5352e968 authored by Alexander Barkov's avatar Alexander Barkov

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)
parent 3784ed7a
--echo #
--echo # The following statements run without warnings.
--echo #
--eval CREATE TABLE t1 (a $type COMPRESSED)
SHOW CREATE TABLE t1;
DROP TABLE t1;
--echo #
--echo # The following statements run without warnings.
--echo # They have extra column attributes (or GENERATED) after COMPRESSED.
--echo #
--eval CREATE TABLE t1 (a $type COMPRESSED DEFAULT '')
SHOW CREATE TABLE t1;
DROP TABLE t1;
--eval CREATE TABLE t1 (a $type COMPRESSED NULL)
SHOW CREATE TABLE t1;
DROP TABLE t1;
--eval CREATE TABLE t1 (a $type COMPRESSED GENERATED ALWAYS AS (REPEAT('a',10)))
SHOW CREATE TABLE t1;
DROP TABLE t1;
--echo #
--echo # The following statements return deprecated syntax warnings
--echo #
--eval CREATE TABLE t1 (a $type DEFAULT '' COMPRESSED)
SHOW CREATE TABLE t1;
DROP TABLE t1;
--eval CREATE TABLE t1 (a $type NULL COMPRESSED)
SHOW CREATE TABLE t1;
DROP TABLE t1;
--echo #
--echo # The following statements fail by the grammar,
--echo # because COMPRESSED immediately follows 'field_type'.
--echo #
--error ER_PARSE_ERROR
--eval CREATE TABLE t1 (a $type COMPRESSED COMPRESSED)
--echo #
--echo # The following statements are not prohibited by the *.yy grammar,
--echo # because the sequence `field_type attribute COMPRESSED` is allowed
--echo # (notice there is at least one attribute after `field_type`).
--echo # The first COMPRESSED is parsed inside `field_type`.
--echo # The second COMPRESSED passes through the parser but then is caught
--echo # inside Column_definition::set_compressed_deprecated_with_type_check()
--echo # and a syntax error is raised.
--echo #
--error ER_PARSE_ERROR
--eval CREATE TABLE t1 (a $type COMPRESSED DEFAULT '' COMPRESSED)
--error ER_PARSE_ERROR
--eval CREATE TABLE t1 (a $type COMPRESSED NULL COMPRESSED)
--error ER_PARSE_ERROR
--echo #
--echo # The following statements run without warnings.
--echo # The `compressed opt_binary` grammar sequence is covered.
--echo #
--eval CREATE TABLE t1 (a $type COMPRESSED)
SHOW CREATE TABLE t1;
DROP TABLE t1;
--eval CREATE TABLE t1 (a $type COMPRESSED BINARY)
SHOW CREATE TABLE t1;
DROP TABLE t1;
--eval CREATE TABLE t1 (a $type COMPRESSED BINARY ASCII)
SHOW CREATE TABLE t1;
DROP TABLE t1;
--eval CREATE TABLE t1 (a $type COMPRESSED BYTE)
SHOW CREATE TABLE t1;
DROP TABLE t1;
--eval CREATE TABLE t1 (a $type COMPRESSED ASCII)
SHOW CREATE TABLE t1;
DROP TABLE t1;
--eval CREATE TABLE t1 (a $type COMPRESSED UNICODE)
SHOW CREATE TABLE t1;
DROP TABLE t1;
--eval CREATE TABLE t1 (a $type COMPRESSED CHARACTER SET utf8)
SHOW CREATE TABLE t1;
DROP TABLE t1;
--echo #
--echo # The following statements run without warnings.
--echo # They have extra column attributes (or GENERATED) after COMPRESSED.
--echo #
--eval CREATE TABLE t1 (a $type COMPRESSED BYTE DEFAULT '')
SHOW CREATE TABLE t1;
DROP TABLE t1;
--eval CREATE TABLE t1 (a $type COMPRESSED BINARY DEFAULT '')
SHOW CREATE TABLE t1;
DROP TABLE t1;
--eval CREATE TABLE t1 (a $type COMPRESSED ASCII DEFAULT '')
SHOW CREATE TABLE t1;
DROP TABLE t1;
--eval CREATE TABLE t1 (a $type COMPRESSED CHARACTER SET utf8 DEFAULT '')
SHOW CREATE TABLE t1;
DROP TABLE t1;
--eval CREATE TABLE t1 (a $type COMPRESSED CHARACTER SET utf8 GENERATED ALWAYS AS (REPEAT('a',100)))
SHOW CREATE TABLE t1;
DROP TABLE t1;
--echo #
--echo # The following statements return deprecated syntax warnings
--echo #
--eval CREATE TABLE t1 (a $type BINARY COMPRESSED)
SHOW CREATE TABLE t1;
DROP TABLE t1;
--eval CREATE TABLE t1 (a $type ASCII COMPRESSED)
SHOW CREATE TABLE t1;
DROP TABLE t1;
--eval CREATE TABLE t1 (a $type BYTE COMPRESSED)
SHOW CREATE TABLE t1;
DROP TABLE t1;
--echo #
--echo # The following statements fail by the grammar,
--echo # because COMPRESSED immediately follows 'field_type'.
--echo #
--error ER_PARSE_ERROR
--eval CREATE TABLE t1 (a $type COMPRESSED BYTE COMPRESSED)
--error ER_PARSE_ERROR
--eval CREATE TABLE t1 (a $type COMPRESSED BINARY COMPRESSED)
--error ER_PARSE_ERROR
--eval CREATE TABLE t1 (a $type COMPRESSED ASCII COMPRESSED)
--error ER_PARSE_ERROR
--eval CREATE TABLE t1 (a $type COMPRESSED CHARACTER SET utf8 COMPRESSED)
--echo #
--echo # The following statements are not prohibited by the *.yy grammar,
--echo # because the sequence `field_type attribute COMPRESSED` is allowed
--echo # (notice there is at least one attribute after `field_type`).
--echo # The first COMPRESSED is parsed inside `field_type`.
--echo # The second COMPRESSED passes through the parser but then is caught
--echo # inside Column_definition::set_compressed_deprecated_with_type_check()
--echo # and a syntax error is raised.
--echo #
--error ER_PARSE_ERROR
--eval CREATE TABLE t1 (a $type COMPRESSED BYTE DEFAULT '' COMPRESSED)
--error ER_PARSE_ERROR
--eval CREATE TABLE t1 (a $type COMPRESSED BINARY DEFAULT '' COMPRESSED)
--error ER_PARSE_ERROR
--eval CREATE TABLE t1 (a $type COMPRESSED ASCII DEFAULT '' COMPRESSED)
--error ER_PARSE_ERROR
--eval CREATE TABLE t1 (a $type COMPRESSED CHARACTER SET utf8 DEFAULT '' COMPRESSED)
This diff is collapsed.
...@@ -20,7 +20,7 @@ let $typec= VARCHAR(10000) COMPRESSED; ...@@ -20,7 +20,7 @@ let $typec= VARCHAR(10000) COMPRESSED;
let $typeu= VARCHAR(10000); let $typeu= VARCHAR(10000);
--source column_compression.inc --source column_compression.inc
let $typec= TEXT CHARSET ucs2 COMPRESSED; let $typec= TEXT COMPRESSED CHARSET ucs2;
let $typeu= TEXT; let $typeu= TEXT;
--source column_compression.inc --source column_compression.inc
...@@ -29,21 +29,25 @@ let $typec= BLOB COMPRESSED; ...@@ -29,21 +29,25 @@ let $typec= BLOB COMPRESSED;
let $typeu= BLOB; let $typeu= BLOB;
--source column_compression.inc --source column_compression.inc
--error ER_WRONG_FIELD_SPEC --error ER_PARSE_ERROR
CREATE TABLE t1(a CHAR(100) COMPRESSED); CREATE TABLE t1(a CHAR(100) COMPRESSED);
--error ER_WRONG_FIELD_SPEC --error ER_WRONG_FIELD_SPEC
CREATE TABLE t1(a CHAR(100) NOT NULL COMPRESSED);
--error ER_PARSE_ERROR
CREATE TABLE t1(a INT COMPRESSED); CREATE TABLE t1(a INT COMPRESSED);
--error ER_UNKNOWN_COMPRESSION_METHOD --error ER_UNKNOWN_COMPRESSION_METHOD
CREATE TABLE t1(a BLOB COMPRESSED=unknown); CREATE TABLE t1(a BLOB COMPRESSED=unknown);
--error ER_PARSE_ERROR
CREATE TABLE t1(a BLOB COMPRESSED COMPRESSED); CREATE TABLE t1(a BLOB COMPRESSED COMPRESSED);
DROP TABLE t1;
CREATE TABLE t1(a INT); CREATE TABLE t1(a INT);
--error ER_WRONG_FIELD_SPEC --error ER_PARSE_ERROR
ALTER TABLE t1 MODIFY a INT COMPRESSED; ALTER TABLE t1 MODIFY a INT COMPRESSED;
--error ER_WRONG_FIELD_SPEC
ALTER TABLE t1 MODIFY a INT NOT NULL COMPRESSED;
DROP TABLE t1; DROP TABLE t1;
--echo # Test CSV --echo # Test CSV
CREATE TABLE t1(a BLOB NOT NULL COMPRESSED) ENGINE=CSV; CREATE TABLE t1(a BLOB COMPRESSED NOT NULL) ENGINE=CSV;
INSERT INTO t1 VALUES(REPEAT('a', 110)); INSERT INTO t1 VALUES(REPEAT('a', 110));
SELECT LENGTH(a) FROM t1; SELECT LENGTH(a) FROM t1;
ALTER TABLE t1 ENGINE=MyISAM; ALTER TABLE t1 ENGINE=MyISAM;
...@@ -153,8 +157,8 @@ DROP TABLE t1; ...@@ -153,8 +157,8 @@ DROP TABLE t1;
CREATE TABLE t1 CREATE TABLE t1
( (
a VARCHAR(10) CHARACTER SET latin1 COMPRESSED, a VARCHAR(10) COMPRESSED CHARACTER SET latin1,
b VARCHAR(10) CHARACTER SET utf8 COMPRESSED b VARCHAR(10) COMPRESSED CHARACTER SET utf8
); );
SELECT COLUMN_NAME, CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH SELECT COLUMN_NAME, CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH
FROM INFORMATION_SCHEMA.COLUMNS FROM INFORMATION_SCHEMA.COLUMNS
...@@ -176,8 +180,78 @@ DROP TABLE t1; ...@@ -176,8 +180,78 @@ DROP TABLE t1;
--echo # MDEV-16729 VARCHAR COMPRESSED is created with a wrong length for multi-byte character sets --echo # MDEV-16729 VARCHAR COMPRESSED is created with a wrong length for multi-byte character sets
--echo # --echo #
CREATE OR REPLACE TABLE t1 (a VARCHAR(1000) CHARACTER SET utf8 COMPRESSED); CREATE OR REPLACE TABLE t1 (a VARCHAR(1000) COMPRESSED CHARACTER SET utf8);
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1'; WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1';
DROP TABLE t1; 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=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);
...@@ -358,3 +358,36 @@ CREATE TABLE raise (raise int); ...@@ -358,3 +358,36 @@ CREATE TABLE raise (raise int);
DROP TABLE raise; DROP TABLE raise;
CREATE TABLE reuse (reuse int); CREATE TABLE reuse (reuse int);
DROP TABLE reuse; DROP TABLE reuse;
#
# MDEV-17363 Compressed columns cannot be restored from dump
# COMPRESSED is not valid as an SP label any more
# but is still valid as an SP variable name.
#
BEGIN NOT ATOMIC
compressed:
BEGIN
SELECT 1 AS a;
END;
END
$$
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'compressed:
BEGIN
SELECT 1 AS a;
END;
END' at line 2
BEGIN NOT ATOMIC
`compressed`:
BEGIN
SELECT 1 AS a;
END;
END
$$
a
1
BEGIN NOT ATOMIC
DECLARE compressed INT DEFAULT 1;
SELECT compressed;
END
$$
compressed
1
...@@ -259,3 +259,39 @@ DROP TABLE raise; ...@@ -259,3 +259,39 @@ DROP TABLE raise;
CREATE TABLE reuse (reuse int); CREATE TABLE reuse (reuse int);
DROP TABLE reuse; DROP TABLE reuse;
--echo #
--echo # MDEV-17363 Compressed columns cannot be restored from dump
--echo # COMPRESSED is not valid as an SP label any more
--echo # but is still valid as an SP variable name.
--echo #
DELIMITER $$;
--error ER_PARSE_ERROR
BEGIN NOT ATOMIC
compressed:
BEGIN
SELECT 1 AS a;
END;
END
$$
DELIMITER ;$$
DELIMITER $$;
BEGIN NOT ATOMIC
`compressed`:
BEGIN
SELECT 1 AS a;
END;
END
$$
DELIMITER ;$$
DELIMITER $$;
BEGIN NOT ATOMIC
DECLARE compressed INT DEFAULT 1;
SELECT compressed;
END
$$
DELIMITER ;$$
...@@ -103,7 +103,43 @@ ALTER TABLE test.t1 RENAME to test.t1_orig; ...@@ -103,7 +103,43 @@ ALTER TABLE test.t1 RENAME to test.t1_orig;
include/diff_tables.inc [test.t1, test.t1_orig] include/diff_tables.inc [test.t1, test.t1_orig]
# Cleanup # Cleanup
DROP TABLE test.t1, test.t1_orig; DROP TABLE test.t1, test.t1_orig;
# End tests #
# Start of 10.3 tests
#
#
# MDEV-17363 Compressed columns cannot be restored from dump
#
CREATE TABLE t1 (a VARCHAR(1000) COMPRESSED CHARACTER SET latin1 COLLATE latin1_bin DEFAULT NULL);
INSERT INTO `t1` VALUES (REPEAT('a', 256));
# Begin testing mysqldump output + restore
# Create 'original table name - <table>_orig
SET @orig_table_name = CONCAT('test.t1', '_orig');
# Rename original table
ALTER TABLE test.t1 RENAME to test.t1_orig;
# Recreate table from mysqldump output
# Compare original and recreated tables
# Recreated table: test.t1
# Original table: test.t1_orig
include/diff_tables.inc [test.t1, test.t1_orig]
# Cleanup
DROP TABLE test.t1, test.t1_orig;
CREATE TABLE t1 (a LONGTEXT COMPRESSED CHARACTER SET latin1 COLLATE latin1_bin DEFAULT NULL);
INSERT INTO `t1` VALUES (REPEAT('a', 256));
# Begin testing mysqldump output + restore
# Create 'original table name - <table>_orig
SET @orig_table_name = CONCAT('test.t1', '_orig');
# Rename original table
ALTER TABLE test.t1 RENAME to test.t1_orig;
# Recreate table from mysqldump output
# Compare original and recreated tables
# Recreated table: test.t1
# Original table: test.t1_orig
include/diff_tables.inc [test.t1, test.t1_orig]
# Cleanup
DROP TABLE test.t1, test.t1_orig;
#
# End of 10.3 tests
#
# Cleanup # Cleanup
# Reset concurrent_insert to its original value # Reset concurrent_insert to its original value
SET @@global.concurrent_insert = @old_concurrent_insert; SET @@global.concurrent_insert = @old_concurrent_insert;
......
...@@ -101,7 +101,29 @@ INSERT INTO `t1` VALUES (0x602010000280100005E71A); ...@@ -101,7 +101,29 @@ INSERT INTO `t1` VALUES (0x602010000280100005E71A);
let $table_name = test.t1; let $table_name = test.t1;
--source include/mysqldump.inc --source include/mysqldump.inc
--echo # End tests --echo #
--echo # Start of 10.3 tests
--echo #
--echo #
--echo # MDEV-17363 Compressed columns cannot be restored from dump
--echo #
CREATE TABLE t1 (a VARCHAR(1000) COMPRESSED CHARACTER SET latin1 COLLATE latin1_bin DEFAULT NULL);
INSERT INTO `t1` VALUES (REPEAT('a', 256));
--exec $MYSQL_DUMP --skip-extended-insert test --skip-comments t1 > $mysqldumpfile
let $table_name = test.t1;
--source include/mysqldump.inc
CREATE TABLE t1 (a LONGTEXT COMPRESSED CHARACTER SET latin1 COLLATE latin1_bin DEFAULT NULL);
INSERT INTO `t1` VALUES (REPEAT('a', 256));
--exec $MYSQL_DUMP --skip-extended-insert test --skip-comments t1 > $mysqldumpfile
let $table_name = test.t1;
--source include/mysqldump.inc
--echo #
--echo # End of 10.3 tests
--echo #
--echo # Cleanup --echo # Cleanup
--echo # Reset concurrent_insert to its original value --echo # Reset concurrent_insert to its original value
......
...@@ -8814,4 +8814,31 @@ Note 1050 Table 't1' already exists ...@@ -8814,4 +8814,31 @@ Note 1050 Table 't1' already exists
drop procedure p4; drop procedure p4;
drop table t1; drop table t1;
set @@sql_mode=@save_sql_mode; set @@sql_mode=@save_sql_mode;
#
# MDEV-17363 Compressed columns cannot be restored from dump
# COMPRESSED conflicted between data type and SP label,
# so it's not allowed as an SP label any more.
#
CREATE FUNCTION f1() RETURNS TEXT COMPRESSED
BEGIN
RETURN '';
END;
$$
SHOW CREATE FUNCTION f1;
Function sql_mode Create Function character_set_client collation_connection Database Collation
f1 STRICT_ALL_TABLES CREATE DEFINER=`root`@`localhost` FUNCTION `f1`() RETURNS text COMPRESSED CHARSET latin1
BEGIN
RETURN '';
END latin1 latin1_swedish_ci latin1_swedish_ci
DROP FUNCTION f1;
CREATE FUNCTION f1() RETURNS TEXT
COMPRESSED:
BEGIN
RETURN '';
END;
$$
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ':
BEGIN
RETURN '';
END' at line 2
# End of 10.3 tests # End of 10.3 tests
...@@ -10335,4 +10335,30 @@ drop procedure p4; ...@@ -10335,4 +10335,30 @@ drop procedure p4;
drop table t1; drop table t1;
set @@sql_mode=@save_sql_mode; set @@sql_mode=@save_sql_mode;
--echo #
--echo # MDEV-17363 Compressed columns cannot be restored from dump
--echo # COMPRESSED conflicted between data type and SP label,
--echo # so it's not allowed as an SP label any more.
--echo #
DELIMITER $$;
CREATE FUNCTION f1() RETURNS TEXT COMPRESSED
BEGIN
RETURN '';
END;
$$
DELIMITER ;$$
SHOW CREATE FUNCTION f1;
DROP FUNCTION f1;
DELIMITER $$;
--error ER_PARSE_ERROR
CREATE FUNCTION f1() RETURNS TEXT
COMPRESSED:
BEGIN
RETURN '';
END;
$$
DELIMITER ;$$
--echo # End of 10.3 tests --echo # End of 10.3 tests
SET sql_mode=ORACLE;
#
# MDEV-17363 Compressed columns cannot be restored from dump
# In sql_mode=ORACLE, COMPRESSED is still valid both as an SP label
# and an SP variable name.
#
BEGIN
IF TRUE THEN
GOTO compressed;
END IF;
SELECT 'This should not be reached' AS warn;
<<compressed>>
BEGIN
SELECT 1 AS a;
END;
END
$$
a
1
DECLARE compressed INT DEFAULT 1;
BEGIN
SELECT compressed;
END
$$
compressed
1
SET sql_mode=ORACLE;
#
# Start of 10.3 tests
#
#
# MDEV-17363 Compressed columns cannot be restored from dump
#
CREATE TABLE t1 (a VARCHAR(1000) COMPRESSED CHARACTER SET latin1 COLLATE latin1_bin DEFAULT NULL);
INSERT INTO `t1` VALUES (REPEAT('a', 256));
# Begin testing mysqldump output + restore
# Create 'original table name - <table>_orig
SET @orig_table_name = CONCAT('test.t1', '_orig');
# Rename original table
ALTER TABLE test.t1 RENAME to test.t1_orig;
# Recreate table from mysqldump output
# Compare original and recreated tables
# Recreated table: test.t1
# Original table: test.t1_orig
include/diff_tables.inc [test.t1, test.t1_orig]
# Cleanup
DROP TABLE test.t1, test.t1_orig;
CREATE TABLE t1 (a LONGTEXT COMPRESSED CHARACTER SET latin1 COLLATE latin1_bin DEFAULT NULL);
INSERT INTO `t1` VALUES (REPEAT('a', 256));
# Begin testing mysqldump output + restore
# Create 'original table name - <table>_orig
SET @orig_table_name = CONCAT('test.t1', '_orig');
# Rename original table
ALTER TABLE test.t1 RENAME to test.t1_orig;
# Recreate table from mysqldump output
# Compare original and recreated tables
# Recreated table: test.t1
# Original table: test.t1_orig
include/diff_tables.inc [test.t1, test.t1_orig]
# Cleanup
DROP TABLE test.t1, test.t1_orig;
#
# End of 10.3 tests
#
...@@ -9,3 +9,76 @@ INSERT INTO t1 VALUES (REPEAT('a',10000)); ...@@ -9,3 +9,76 @@ INSERT INTO t1 VALUES (REPEAT('a',10000));
SELECT DATA_LENGTH<100 AS c FROM INFORMATION_SCHEMA.TABLES SELECT DATA_LENGTH<100 AS c FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='test'; WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='test';
DROP TABLE t1; 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);
SET sql_mode=ORACLE;
--echo #
--echo # MDEV-17363 Compressed columns cannot be restored from dump
--echo # In sql_mode=ORACLE, COMPRESSED is still valid both as an SP label
--echo # and an SP variable name.
--echo #
DELIMITER $$;
BEGIN
IF TRUE THEN
GOTO compressed;
END IF;
SELECT 'This should not be reached' AS warn;
<<compressed>>
BEGIN
SELECT 1 AS a;
END;
END
$$
DELIMITER ;$$
DELIMITER $$;
DECLARE compressed INT DEFAULT 1;
BEGIN
SELECT compressed;
END
$$
DELIMITER ;$$
# See comments in mysql-test/main/mysqldump_restore.test
--source include/not_embedded.inc
SET sql_mode=ORACLE;
let $mysqldumpfile = $MYSQLTEST_VARDIR/tmp/mysqldumpfile.sql;
--echo #
--echo # Start of 10.3 tests
--echo #
--echo #
--echo # MDEV-17363 Compressed columns cannot be restored from dump
--echo #
CREATE TABLE t1 (a VARCHAR(1000) COMPRESSED CHARACTER SET latin1 COLLATE latin1_bin DEFAULT NULL);
INSERT INTO `t1` VALUES (REPEAT('a', 256));
--exec $MYSQL_DUMP --skip-extended-insert test --skip-comments t1 > $mysqldumpfile
let $table_name = test.t1;
--source include/mysqldump.inc
CREATE TABLE t1 (a LONGTEXT COMPRESSED CHARACTER SET latin1 COLLATE latin1_bin DEFAULT NULL);
INSERT INTO `t1` VALUES (REPEAT('a', 256));
--exec $MYSQL_DUMP --skip-extended-insert test --skip-comments t1 > $mysqldumpfile
let $table_name = test.t1;
--source include/mysqldump.inc
--echo #
--echo # End of 10.3 tests
--echo #
...@@ -11105,12 +11105,6 @@ bool Column_definition::has_default_expression() ...@@ -11105,12 +11105,6 @@ bool Column_definition::has_default_expression()
bool Column_definition::set_compressed(const char *method) bool Column_definition::set_compressed(const char *method)
{ {
enum enum_field_types sql_type= real_field_type();
/* We can't use f_is_blob here as pack_flag is not yet set */
if (sql_type == MYSQL_TYPE_VARCHAR || sql_type == MYSQL_TYPE_TINY_BLOB ||
sql_type == MYSQL_TYPE_BLOB || sql_type == MYSQL_TYPE_MEDIUM_BLOB ||
sql_type == MYSQL_TYPE_LONG_BLOB)
{
if (!method || !strcmp(method, zlib_compression_method->name)) if (!method || !strcmp(method, zlib_compression_method->name))
{ {
unireg_check= Field::TMYSQL_COMPRESSED; unireg_check= Field::TMYSQL_COMPRESSED;
...@@ -11118,7 +11112,41 @@ bool Column_definition::set_compressed(const char *method) ...@@ -11118,7 +11112,41 @@ bool Column_definition::set_compressed(const char *method)
return false; return false;
} }
my_error(ER_UNKNOWN_COMPRESSION_METHOD, MYF(0), method); my_error(ER_UNKNOWN_COMPRESSION_METHOD, MYF(0), method);
return true;
}
bool Column_definition::set_compressed_deprecated(THD *thd, const char *method)
{
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_WARN_DEPRECATED_SYNTAX,
ER_THD(thd, ER_WARN_DEPRECATED_SYNTAX),
"<data type> <character set clause> ... COMPRESSED...",
"'<data type> COMPRESSED... <character set clause> ...'");
return set_compressed(method);
}
bool
Column_definition::set_compressed_deprecated_column_attribute(THD *thd,
const char *pos,
const char *method)
{
if (compression_method_ptr)
{
/*
Compression method has already been set, e.g.:
a VARCHAR(10) COMPRESSED DEFAULT 10 COMPRESSED
*/
thd->parse_error(ER_SYNTAX_ERROR, pos);
return true;
} }
enum enum_field_types sql_type= real_field_type();
/* We can't use f_is_blob here as pack_flag is not yet set */
if (sql_type == MYSQL_TYPE_VARCHAR || sql_type == MYSQL_TYPE_TINY_BLOB ||
sql_type == MYSQL_TYPE_BLOB || sql_type == MYSQL_TYPE_MEDIUM_BLOB ||
sql_type == MYSQL_TYPE_LONG_BLOB)
return set_compressed_deprecated(thd, method);
else else
my_error(ER_WRONG_FIELD_SPEC, MYF(0), field_name.str); my_error(ER_WRONG_FIELD_SPEC, MYF(0), field_name.str);
return true; return true;
......
...@@ -4559,6 +4559,10 @@ class Column_definition: public Sql_alloc, ...@@ -4559,6 +4559,10 @@ class Column_definition: public Sql_alloc,
*this= *def; *this= *def;
} }
bool set_compressed(const char *method); bool set_compressed(const char *method);
bool set_compressed_deprecated(THD *thd, const char *method);
bool set_compressed_deprecated_column_attribute(THD *thd,
const char *pos,
const char *method);
void set_compression_method(Compression_method *compression_method_arg) void set_compression_method(Compression_method *compression_method_arg)
{ compression_method_ptr= compression_method_arg; } { compression_method_ptr= compression_method_arg; }
Compression_method *compression_method() const Compression_method *compression_method() const
......
...@@ -2092,7 +2092,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); ...@@ -2092,7 +2092,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
ref_list opt_match_clause opt_on_update_delete use ref_list opt_match_clause opt_on_update_delete use
opt_delete_options opt_delete_option varchar nchar nvarchar opt_delete_options opt_delete_option varchar nchar nvarchar
opt_outer table_list table_name table_alias_ref_list table_alias_ref opt_outer table_list table_name table_alias_ref_list table_alias_ref
opt_attribute opt_attribute_list attribute column_list column_list_id attribute attribute_list
compressed_deprecated_data_type_attribute
compressed_deprecated_column_attribute
column_list column_list_id
opt_column_list grant_privileges grant_ident grant_list grant_option opt_column_list grant_privileges grant_ident grant_list grant_option
object_privilege object_privilege_list user_list user_and_role_list object_privilege object_privilege_list user_list user_and_role_list
rename_list table_or_tables rename_list table_or_tables
...@@ -6779,7 +6782,10 @@ opt_asrow_attribute_list: ...@@ -6779,7 +6782,10 @@ opt_asrow_attribute_list:
; ;
field_def: field_def:
opt_attribute /* empty */ { }
| attribute_list
| attribute_list compressed_deprecated_column_attribute
| attribute_list compressed_deprecated_column_attribute attribute_list
| opt_generated_always AS virtual_column_func | opt_generated_always AS virtual_column_func
{ {
Lex->last_field->vcol_info= $3; Lex->last_field->vcol_info= $3;
...@@ -6965,6 +6971,13 @@ field_type_numeric: ...@@ -6965,6 +6971,13 @@ field_type_numeric:
; ;
opt_binary_and_compression:
/* empty */
| binary
| binary compressed_deprecated_data_type_attribute
| compressed opt_binary
;
field_type_string: field_type_string:
char opt_field_length_default_1 opt_binary char opt_field_length_default_1 opt_binary
{ {
...@@ -6980,25 +6993,25 @@ field_type_string: ...@@ -6980,25 +6993,25 @@ field_type_string:
Lex->charset=&my_charset_bin; Lex->charset=&my_charset_bin;
$$.set(&type_handler_string, $2); $$.set(&type_handler_string, $2);
} }
| varchar field_length opt_binary | varchar field_length opt_binary_and_compression
{ {
$$.set(&type_handler_varchar, $2); $$.set(&type_handler_varchar, $2);
} }
| VARCHAR2_ORACLE_SYM field_length opt_binary | VARCHAR2_ORACLE_SYM field_length opt_binary_and_compression
{ {
$$.set(&type_handler_varchar, $2); $$.set(&type_handler_varchar, $2);
} }
| nvarchar field_length opt_bin_mod | nvarchar field_length opt_compressed opt_bin_mod
{ {
$$.set(&type_handler_varchar, $2); $$.set(&type_handler_varchar, $2);
bincmp_collation(national_charset_info, $3); bincmp_collation(national_charset_info, $4);
} }
| VARBINARY field_length | VARBINARY field_length opt_compressed
{ {
Lex->charset=&my_charset_bin; Lex->charset=&my_charset_bin;
$$.set(&type_handler_varchar, $2); $$.set(&type_handler_varchar, $2);
} }
| RAW_ORACLE_SYM field_length | RAW_ORACLE_SYM field_length opt_compressed
{ {
Lex->charset= &my_charset_bin; Lex->charset= &my_charset_bin;
$$.set(&type_handler_varchar, $2); $$.set(&type_handler_varchar, $2);
...@@ -7064,17 +7077,17 @@ field_type_temporal: ...@@ -7064,17 +7077,17 @@ field_type_temporal:
field_type_lob: field_type_lob:
TINYBLOB TINYBLOB opt_compressed
{ {
Lex->charset=&my_charset_bin; Lex->charset=&my_charset_bin;
$$.set(&type_handler_tiny_blob); $$.set(&type_handler_tiny_blob);
} }
| BLOB_MARIADB_SYM opt_field_length | BLOB_MARIADB_SYM opt_field_length opt_compressed
{ {
Lex->charset=&my_charset_bin; Lex->charset=&my_charset_bin;
$$.set(&type_handler_blob, $2); $$.set(&type_handler_blob, $2);
} }
| BLOB_ORACLE_SYM opt_field_length | BLOB_ORACLE_SYM opt_field_length opt_compressed
{ {
Lex->charset=&my_charset_bin; Lex->charset=&my_charset_bin;
$$.set(&type_handler_long_blob); $$.set(&type_handler_long_blob);
...@@ -7090,36 +7103,36 @@ field_type_lob: ...@@ -7090,36 +7103,36 @@ field_type_lob:
sym_group_geom.needed_define)); sym_group_geom.needed_define));
#endif #endif
} }
| MEDIUMBLOB | MEDIUMBLOB opt_compressed
{ {
Lex->charset=&my_charset_bin; Lex->charset=&my_charset_bin;
$$.set(&type_handler_medium_blob); $$.set(&type_handler_medium_blob);
} }
| LONGBLOB | LONGBLOB opt_compressed
{ {
Lex->charset=&my_charset_bin; Lex->charset=&my_charset_bin;
$$.set(&type_handler_long_blob); $$.set(&type_handler_long_blob);
} }
| LONG_SYM VARBINARY | LONG_SYM VARBINARY opt_compressed
{ {
Lex->charset=&my_charset_bin; Lex->charset=&my_charset_bin;
$$.set(&type_handler_medium_blob); $$.set(&type_handler_medium_blob);
} }
| LONG_SYM varchar opt_binary | LONG_SYM varchar opt_binary_and_compression
{ $$.set(&type_handler_medium_blob); } { $$.set(&type_handler_medium_blob); }
| TINYTEXT opt_binary | TINYTEXT opt_binary_and_compression
{ $$.set(&type_handler_tiny_blob); } { $$.set(&type_handler_tiny_blob); }
| TEXT_SYM opt_field_length opt_binary | TEXT_SYM opt_field_length opt_binary_and_compression
{ $$.set(&type_handler_blob, $2); } { $$.set(&type_handler_blob, $2); }
| MEDIUMTEXT opt_binary | MEDIUMTEXT opt_binary_and_compression
{ $$.set(&type_handler_medium_blob); } { $$.set(&type_handler_medium_blob); }
| LONGTEXT opt_binary | LONGTEXT opt_binary_and_compression
{ $$.set(&type_handler_long_blob); } { $$.set(&type_handler_long_blob); }
| CLOB_ORACLE_SYM opt_binary | CLOB_ORACLE_SYM opt_binary_and_compression
{ $$.set(&type_handler_long_blob); } { $$.set(&type_handler_long_blob); }
| LONG_SYM opt_binary | LONG_SYM opt_binary_and_compression
{ $$.set(&type_handler_medium_blob); } { $$.set(&type_handler_medium_blob); }
| JSON_SYM | JSON_SYM opt_compressed
{ {
Lex->charset= &my_charset_utf8mb4_bin; Lex->charset= &my_charset_utf8mb4_bin;
$$.set(&type_handler_long_blob); $$.set(&type_handler_long_blob);
...@@ -7233,13 +7246,9 @@ opt_precision: ...@@ -7233,13 +7246,9 @@ opt_precision:
| precision { $$= $1; } | precision { $$= $1; }
; ;
opt_attribute:
/* empty */ {}
| opt_attribute_list {}
;
opt_attribute_list: attribute_list:
opt_attribute_list attribute {} attribute_list attribute {}
| attribute | attribute
; ;
...@@ -7267,11 +7276,6 @@ attribute: ...@@ -7267,11 +7276,6 @@ attribute:
$2->name,Lex->charset->csname)); $2->name,Lex->charset->csname));
Lex->last_field->charset= $2; Lex->last_field->charset= $2;
} }
| COMPRESSED_SYM opt_compression_method
{
if (unlikely(Lex->last_field->set_compressed($2)))
MYSQL_YYABORT;
}
| serial_attribute | serial_attribute
; ;
...@@ -7280,6 +7284,36 @@ opt_compression_method: ...@@ -7280,6 +7284,36 @@ opt_compression_method:
| equal ident { $$= $2.str; } | equal ident { $$= $2.str; }
; ;
opt_compressed:
/* empty */ {}
| compressed { }
;
compressed:
COMPRESSED_SYM opt_compression_method
{
if (unlikely(Lex->last_field->set_compressed($2)))
MYSQL_YYABORT;
}
;
compressed_deprecated_data_type_attribute:
COMPRESSED_SYM opt_compression_method
{
if (unlikely(Lex->last_field->set_compressed_deprecated(thd, $2)))
MYSQL_YYABORT;
}
;
compressed_deprecated_column_attribute:
COMPRESSED_SYM opt_compression_method
{
if (unlikely(Lex->last_field->
set_compressed_deprecated_column_attribute(thd, $1.pos(), $2)))
MYSQL_YYABORT;
}
;
asrow_attribute: asrow_attribute:
not NULL_SYM not NULL_SYM
{ {
...@@ -7438,7 +7472,11 @@ charset_or_alias: ...@@ -7438,7 +7472,11 @@ charset_or_alias:
opt_binary: opt_binary:
/* empty */ { bincmp_collation(NULL, false); } /* empty */ { bincmp_collation(NULL, false); }
| BYTE_SYM { bincmp_collation(&my_charset_bin, false); } | binary {}
;
binary:
BYTE_SYM { bincmp_collation(&my_charset_bin, false); }
| charset_or_alias opt_bin_mod { bincmp_collation($1, $2); } | charset_or_alias opt_bin_mod { bincmp_collation($1, $2); }
| BINARY { bincmp_collation(NULL, true); } | BINARY { bincmp_collation(NULL, true); }
| BINARY charset_or_alias { bincmp_collation($2, true); } | BINARY charset_or_alias { bincmp_collation($2, true); }
...@@ -15713,6 +15751,7 @@ keyword_sp_var_not_label: ...@@ -15713,6 +15751,7 @@ keyword_sp_var_not_label:
| COLUMN_DELETE_SYM | COLUMN_DELETE_SYM
| COLUMN_GET_SYM | COLUMN_GET_SYM
| COMMENT_SYM | COMMENT_SYM
| COMPRESSED_SYM
| DEALLOCATE_SYM | DEALLOCATE_SYM
| EXAMINED_SYM | EXAMINED_SYM
| EXCLUDE_SYM | EXCLUDE_SYM
...@@ -15925,7 +15964,6 @@ keyword_sp_var_and_label: ...@@ -15925,7 +15964,6 @@ keyword_sp_var_and_label:
| COMMITTED_SYM | COMMITTED_SYM
| COMPACT_SYM | COMPACT_SYM
| COMPLETION_SYM | COMPLETION_SYM
| COMPRESSED_SYM
| CONCURRENT | CONCURRENT
| CONNECTION_SYM | CONNECTION_SYM
| CONSISTENT_SYM | CONSISTENT_SYM
......
...@@ -278,10 +278,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); ...@@ -278,10 +278,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
%parse-param { THD *thd } %parse-param { THD *thd }
%lex-param { THD *thd } %lex-param { THD *thd }
/* /*
Currently there are 53 shift/reduce conflicts. Currently there are 55 shift/reduce conflicts.
We should not introduce new conflicts any more. We should not introduce new conflicts any more.
*/ */
%expect 53 %expect 55
/* /*
Comments for TOKENS. Comments for TOKENS.
...@@ -1495,7 +1495,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); ...@@ -1495,7 +1495,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
ref_list opt_match_clause opt_on_update_delete use ref_list opt_match_clause opt_on_update_delete use
opt_delete_options opt_delete_option varchar nchar nvarchar opt_delete_options opt_delete_option varchar nchar nvarchar
opt_outer table_list table_name table_alias_ref_list table_alias_ref opt_outer table_list table_name table_alias_ref_list table_alias_ref
opt_attribute opt_attribute_list attribute column_list column_list_id attribute attribute_list
compressed_deprecated_data_type_attribute
compressed_deprecated_column_attribute
column_list column_list_id
opt_column_list grant_privileges grant_ident grant_list grant_option opt_column_list grant_privileges grant_ident grant_list grant_option
object_privilege object_privilege_list user_list user_and_role_list object_privilege object_privilege_list user_list user_and_role_list
rename_list table_or_tables rename_list table_or_tables
...@@ -6625,7 +6628,10 @@ opt_asrow_attribute_list: ...@@ -6625,7 +6628,10 @@ opt_asrow_attribute_list:
; ;
field_def: field_def:
opt_attribute /* empty */ { }
| attribute_list
| attribute_list compressed_deprecated_column_attribute
| attribute_list compressed_deprecated_column_attribute attribute_list
| opt_generated_always AS virtual_column_func | opt_generated_always AS virtual_column_func
{ {
Lex->last_field->vcol_info= $3; Lex->last_field->vcol_info= $3;
...@@ -6821,6 +6827,13 @@ field_type_numeric: ...@@ -6821,6 +6827,13 @@ field_type_numeric:
; ;
opt_binary_and_compression:
/* empty */
| binary
| binary compressed_deprecated_data_type_attribute
| compressed opt_binary
;
field_type_string: field_type_string:
char opt_field_length_default_1 opt_binary char opt_field_length_default_1 opt_binary
{ {
...@@ -6836,25 +6849,25 @@ field_type_string: ...@@ -6836,25 +6849,25 @@ field_type_string:
Lex->charset=&my_charset_bin; Lex->charset=&my_charset_bin;
$$.set(&type_handler_string, $2); $$.set(&type_handler_string, $2);
} }
| varchar field_length opt_binary | varchar field_length opt_binary_and_compression
{ {
$$.set(&type_handler_varchar, $2); $$.set(&type_handler_varchar, $2);
} }
| VARCHAR2_ORACLE_SYM field_length opt_binary | VARCHAR2_ORACLE_SYM field_length opt_binary_and_compression
{ {
$$.set(&type_handler_varchar, $2); $$.set(&type_handler_varchar, $2);
} }
| nvarchar field_length opt_bin_mod | nvarchar field_length opt_compressed opt_bin_mod
{ {
$$.set(&type_handler_varchar, $2); $$.set(&type_handler_varchar, $2);
bincmp_collation(national_charset_info, $3); bincmp_collation(national_charset_info, $4);
} }
| VARBINARY field_length | VARBINARY field_length opt_compressed
{ {
Lex->charset=&my_charset_bin; Lex->charset=&my_charset_bin;
$$.set(&type_handler_varchar, $2); $$.set(&type_handler_varchar, $2);
} }
| RAW_ORACLE_SYM field_length | RAW_ORACLE_SYM field_length opt_compressed
{ {
Lex->charset= &my_charset_bin; Lex->charset= &my_charset_bin;
$$.set(&type_handler_varchar, $2); $$.set(&type_handler_varchar, $2);
...@@ -6962,17 +6975,17 @@ field_type_temporal: ...@@ -6962,17 +6975,17 @@ field_type_temporal:
field_type_lob: field_type_lob:
TINYBLOB TINYBLOB opt_compressed
{ {
Lex->charset=&my_charset_bin; Lex->charset=&my_charset_bin;
$$.set(&type_handler_tiny_blob); $$.set(&type_handler_tiny_blob);
} }
| BLOB_MARIADB_SYM opt_field_length | BLOB_MARIADB_SYM opt_field_length opt_compressed
{ {
Lex->charset=&my_charset_bin; Lex->charset=&my_charset_bin;
$$.set(&type_handler_blob, $2); $$.set(&type_handler_blob, $2);
} }
| BLOB_ORACLE_SYM opt_field_length | BLOB_ORACLE_SYM opt_field_length opt_compressed
{ {
Lex->charset=&my_charset_bin; Lex->charset=&my_charset_bin;
$$.set(&type_handler_long_blob); $$.set(&type_handler_long_blob);
...@@ -6988,36 +7001,36 @@ field_type_lob: ...@@ -6988,36 +7001,36 @@ field_type_lob:
sym_group_geom.needed_define)); sym_group_geom.needed_define));
#endif #endif
} }
| MEDIUMBLOB | MEDIUMBLOB opt_compressed
{ {
Lex->charset=&my_charset_bin; Lex->charset=&my_charset_bin;
$$.set(&type_handler_medium_blob); $$.set(&type_handler_medium_blob);
} }
| LONGBLOB | LONGBLOB opt_compressed
{ {
Lex->charset=&my_charset_bin; Lex->charset=&my_charset_bin;
$$.set(&type_handler_long_blob); $$.set(&type_handler_long_blob);
} }
| LONG_SYM VARBINARY | LONG_SYM VARBINARY opt_compressed
{ {
Lex->charset=&my_charset_bin; Lex->charset=&my_charset_bin;
$$.set(&type_handler_medium_blob); $$.set(&type_handler_medium_blob);
} }
| LONG_SYM varchar opt_binary | LONG_SYM varchar opt_binary_and_compression
{ $$.set(&type_handler_medium_blob); } { $$.set(&type_handler_medium_blob); }
| TINYTEXT opt_binary | TINYTEXT opt_binary_and_compression
{ $$.set(&type_handler_tiny_blob); } { $$.set(&type_handler_tiny_blob); }
| TEXT_SYM opt_field_length opt_binary | TEXT_SYM opt_field_length opt_binary_and_compression
{ $$.set(&type_handler_blob, $2); } { $$.set(&type_handler_blob, $2); }
| MEDIUMTEXT opt_binary | MEDIUMTEXT opt_binary_and_compression
{ $$.set(&type_handler_medium_blob); } { $$.set(&type_handler_medium_blob); }
| LONGTEXT opt_binary | LONGTEXT opt_binary_and_compression
{ $$.set(&type_handler_long_blob); } { $$.set(&type_handler_long_blob); }
| CLOB_ORACLE_SYM opt_binary | CLOB_ORACLE_SYM opt_binary_and_compression
{ $$.set(&type_handler_long_blob); } { $$.set(&type_handler_long_blob); }
| LONG_SYM opt_binary | LONG_SYM opt_binary_and_compression
{ $$.set(&type_handler_medium_blob); } { $$.set(&type_handler_medium_blob); }
| JSON_SYM | JSON_SYM opt_compressed
{ {
Lex->charset= &my_charset_utf8mb4_bin; Lex->charset= &my_charset_utf8mb4_bin;
$$.set(&type_handler_long_blob); $$.set(&type_handler_long_blob);
...@@ -7157,13 +7170,9 @@ opt_precision: ...@@ -7157,13 +7170,9 @@ opt_precision:
| precision { $$= $1; } | precision { $$= $1; }
; ;
opt_attribute:
/* empty */ {}
| opt_attribute_list {}
;
opt_attribute_list: attribute_list:
opt_attribute_list attribute {} attribute_list attribute {}
| attribute | attribute
; ;
...@@ -7191,11 +7200,6 @@ attribute: ...@@ -7191,11 +7200,6 @@ attribute:
$2->name,Lex->charset->csname)); $2->name,Lex->charset->csname));
Lex->last_field->charset= $2; Lex->last_field->charset= $2;
} }
| COMPRESSED_SYM opt_compression_method
{
if (unlikely(Lex->last_field->set_compressed($2)))
MYSQL_YYABORT;
}
| serial_attribute | serial_attribute
; ;
...@@ -7204,6 +7208,36 @@ opt_compression_method: ...@@ -7204,6 +7208,36 @@ opt_compression_method:
| equal ident { $$= $2.str; } | equal ident { $$= $2.str; }
; ;
opt_compressed:
/* empty */ {}
| compressed { }
;
compressed:
COMPRESSED_SYM opt_compression_method
{
if (unlikely(Lex->last_field->set_compressed($2)))
MYSQL_YYABORT;
}
;
compressed_deprecated_data_type_attribute:
COMPRESSED_SYM opt_compression_method
{
if (unlikely(Lex->last_field->set_compressed_deprecated(thd, $2)))
MYSQL_YYABORT;
}
;
compressed_deprecated_column_attribute:
COMPRESSED_SYM opt_compression_method
{
if (unlikely(Lex->last_field->
set_compressed_deprecated_column_attribute(thd, $1.pos(), $2)))
MYSQL_YYABORT;
}
;
asrow_attribute: asrow_attribute:
not NULL_SYM not NULL_SYM
{ {
...@@ -7375,7 +7409,11 @@ charset_or_alias: ...@@ -7375,7 +7409,11 @@ charset_or_alias:
opt_binary: opt_binary:
/* empty */ { bincmp_collation(NULL, false); } /* empty */ { bincmp_collation(NULL, false); }
| BYTE_SYM { bincmp_collation(&my_charset_bin, false); } | binary {}
;
binary:
BYTE_SYM { bincmp_collation(&my_charset_bin, false); }
| charset_or_alias opt_bin_mod { bincmp_collation($1, $2); } | charset_or_alias opt_bin_mod { bincmp_collation($1, $2); }
| BINARY { bincmp_collation(NULL, true); } | BINARY { bincmp_collation(NULL, true); }
| BINARY charset_or_alias { bincmp_collation($2, true); } | BINARY charset_or_alias { bincmp_collation($2, true); }
...@@ -15648,6 +15686,7 @@ keyword_label: ...@@ -15648,6 +15686,7 @@ keyword_label:
| keyword_sp_var_and_label | keyword_sp_var_and_label
| keyword_sysvar_type | keyword_sysvar_type
| FUNCTION_SYM | FUNCTION_SYM
| COMPRESSED_SYM
; ;
keyword_sysvar_name: keyword_sysvar_name:
...@@ -15717,6 +15756,7 @@ keyword_sp_var_not_label: ...@@ -15717,6 +15756,7 @@ keyword_sp_var_not_label:
| COLUMN_DELETE_SYM | COLUMN_DELETE_SYM
| COLUMN_GET_SYM | COLUMN_GET_SYM
| COMMENT_SYM | COMMENT_SYM
| COMPRESSED_SYM
| DEALLOCATE_SYM | DEALLOCATE_SYM
| EXAMINED_SYM | EXAMINED_SYM
| EXCLUDE_SYM | EXCLUDE_SYM
...@@ -15929,7 +15969,6 @@ keyword_sp_var_and_label: ...@@ -15929,7 +15969,6 @@ keyword_sp_var_and_label:
| COMMITTED_SYM | COMMITTED_SYM
| COMPACT_SYM | COMPACT_SYM
| COMPLETION_SYM | COMPLETION_SYM
| COMPRESSED_SYM
| CONCURRENT | CONCURRENT
| CONNECTION_SYM | CONNECTION_SYM
| CONSISTENT_SYM | CONSISTENT_SYM
......
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