1--source include/have_innodb.inc
2--source include/have_file_key_management_plugin.inc
3--source include/innodb_checksum_algorithm.inc
4
5#
6# MDEV-11974: MariaDB 10.2 encryption does not support spatial indexes
7#
8
9#
10#
11#
12let $checksum_algorithm = `SELECT @@innodb_checksum_algorithm`;
13let $error_code = ER_CANT_CREATE_TABLE, ER_ILLEGAL_HA_CREATE_OPTION;
14if ($checksum_algorithm == "full_crc32")
15{
16  let $error_code = 0;
17}
18if ($checksum_algorithm == "strict_full_crc32")
19{
20  let $error_code = 0;
21}
22
23--error $error_code
24CREATE TABLE t1 (pk INT PRIMARY KEY AUTO_INCREMENT,
25c VARCHAR(256), coordinate POINT NOT NULL, SPATIAL index(coordinate)) ENGINE=INNODB
26ENCRYPTED=YES;
27
28if (!$error_code) {
29INSERT INTO t1(c, coordinate) values('mysql', ST_GeomFromText('POINT(903994614 180726515)'));
30--source include/restart_mysqld.inc
31INSERT INTO t1(c, coordinate) values('mariadb', ST_GeomFromText('POINT(903994614 180726515)'));
32DROP TABLE t1;
33}
34
35#
36# (2) Alter table
37#
38CREATE TABLE t1 (pk INT PRIMARY KEY AUTO_INCREMENT,
39c VARCHAR(256), coordinate POINT NOT NULL, SPATIAL index(coordinate)) ENGINE=INNODB;
40--error $error_code
41ALTER TABLE t1 ENCRYPTED=YES;
42DROP TABLE t1;
43
44#
45# Index creation
46#
47CREATE TABLE t1 (pk INT PRIMARY KEY AUTO_INCREMENT,
48c VARCHAR(256), coordinate POINT NOT NULL)
49PAGE_COMPRESSED=YES, ENCRYPTED=YES ENGINE=INNODB;
50# FIXME: MDEV-13851 Encrypted table refuses some form of ALGORITHM=COPY,
51# but allows rebuild by FORCE
52--error $error_code
53ALTER TABLE t1 ADD SPATIAL INDEX b1(coordinate), ALGORITHM=COPY;
54--error $error_code
55ALTER TABLE t1 ADD SPATIAL INDEX b2(coordinate), FORCE, ALGORITHM=INPLACE;
56--error $error_code
57ALTER TABLE t1 ADD SPATIAL INDEX(coordinate);
58--error $error_code
59CREATE SPATIAL INDEX b3 on t1(coordinate);
60DROP TABLE t1;
61
62CREATE TABLE t1 (pk INT PRIMARY KEY AUTO_INCREMENT,
63c VARCHAR(256), coordinate POINT NOT NULL) ENCRYPTED=DEFAULT ENGINE=INNODB;
64CREATE SPATIAL INDEX b on t1(coordinate);
65INSERT INTO t1 values(1, 'secret', ST_GeomFromText('POINT(903994614 180726515)'));
66ALTER TABLE t1 DROP INDEX b;
67INSERT INTO t1 values(2, 'secret', ST_GeomFromText('POINT(903994614 180726515)'));
68ALTER TABLE t1 ADD SPATIAL INDEX b(coordinate);
69INSERT INTO t1 values(3, 'secret', ST_GeomFromText('POINT(903994614 180726515)'));
70DROP TABLE t1;
71#
72# (3) Default encryption should still work
73#
74
75CREATE TABLE t1 (pk INT PRIMARY KEY AUTO_INCREMENT,
76c VARCHAR(256), coordinate POINT NOT NULL, SPATIAL index(coordinate)) ENGINE=INNODB;
77CREATE TABLE t2 (pk INT PRIMARY KEY AUTO_INCREMENT,
78c VARCHAR(256), coordinate POINT NOT NULL, SPATIAL index(coordinate)) ENGINE=INNODB PAGE_COMPRESSED=YES;
79
80INSERT INTO t1 values(1, 'secret', ST_GeomFromText('POINT(903994614 180726515)'));
81INSERT INTO t2 values(1, 'secret', ST_GeomFromText('POINT(903994614 180726515)'));
82
83--let $wait_timeout=600
84--let $wait_condition=SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0;
85--source include/wait_condition.inc
86
87--echo # Success!
88
89--sorted_result
90SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION > 0;
91--sorted_result
92SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0;
93
94DROP TABLE t1, t2;
95