summaryrefslogtreecommitdiffstats
path: root/mysql-test/suite/encryption/t/innodb-spatial-index.test
blob: 2caffb141e108dc9fb8238344f31516b3f0d2f4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
--source include/have_innodb.inc
--source include/have_file_key_management_plugin.inc
--source include/innodb_checksum_algorithm.inc

#
# MDEV-11974: MariaDB 10.2 encryption does not support spatial indexes
#

#
#
#
let $checksum_algorithm = `SELECT @@innodb_checksum_algorithm`;
let $error_code = ER_CANT_CREATE_TABLE, ER_ILLEGAL_HA_CREATE_OPTION;
if ($checksum_algorithm == "full_crc32")
{
  let $error_code = 0;
}
if ($checksum_algorithm == "strict_full_crc32")
{
  let $error_code = 0;
}

--error $error_code
CREATE TABLE t1 (pk INT PRIMARY KEY AUTO_INCREMENT,
c VARCHAR(256), coordinate POINT NOT NULL, SPATIAL index(coordinate)) ENGINE=INNODB
ENCRYPTED=YES;

if (!$error_code) {
INSERT INTO t1(c, coordinate) values('mysql', ST_GeomFromText('POINT(903994614 180726515)'));
--source include/restart_mysqld.inc
INSERT INTO t1(c, coordinate) values('mariadb', ST_GeomFromText('POINT(903994614 180726515)'));
DROP TABLE t1;
}

#
# (2) Alter table
#
CREATE TABLE t1 (pk INT PRIMARY KEY AUTO_INCREMENT,
c VARCHAR(256), coordinate POINT NOT NULL, SPATIAL index(coordinate)) ENGINE=INNODB;
--error $error_code
ALTER TABLE t1 ENCRYPTED=YES;
DROP TABLE t1;

#
# Index creation
#
CREATE TABLE t1 (pk INT PRIMARY KEY AUTO_INCREMENT,
c VARCHAR(256), coordinate POINT NOT NULL)
PAGE_COMPRESSED=YES, ENCRYPTED=YES ENGINE=INNODB;
# FIXME: MDEV-13851 Encrypted table refuses some form of ALGORITHM=COPY,
# but allows rebuild by FORCE
--error $error_code
ALTER TABLE t1 ADD SPATIAL INDEX b1(coordinate), ALGORITHM=COPY;
--error $error_code
ALTER TABLE t1 ADD SPATIAL INDEX b2(coordinate), FORCE, ALGORITHM=INPLACE;
--error $error_code
ALTER TABLE t1 ADD SPATIAL INDEX(coordinate);
--error $error_code
CREATE SPATIAL INDEX b3 on t1(coordinate);
DROP TABLE t1;

CREATE TABLE t1 (pk INT PRIMARY KEY AUTO_INCREMENT,
c VARCHAR(256), coordinate POINT NOT NULL) ENCRYPTED=DEFAULT ENGINE=INNODB;
CREATE SPATIAL INDEX b on t1(coordinate);
INSERT INTO t1 values(1, 'secret', ST_GeomFromText('POINT(903994614 180726515)'));
ALTER TABLE t1 DROP INDEX b;
INSERT INTO t1 values(2, 'secret', ST_GeomFromText('POINT(903994614 180726515)'));
ALTER TABLE t1 ADD SPATIAL INDEX b(coordinate);
INSERT INTO t1 values(3, 'secret', ST_GeomFromText('POINT(903994614 180726515)'));
DROP TABLE t1;
#
# (3) Default encryption should still work
#

CREATE TABLE t1 (pk INT PRIMARY KEY AUTO_INCREMENT,
c VARCHAR(256), coordinate POINT NOT NULL, SPATIAL index(coordinate)) ENGINE=INNODB;
CREATE TABLE t2 (pk INT PRIMARY KEY AUTO_INCREMENT,
c VARCHAR(256), coordinate POINT NOT NULL, SPATIAL index(coordinate)) ENGINE=INNODB PAGE_COMPRESSED=YES;

INSERT INTO t1 values(1, 'secret', ST_GeomFromText('POINT(903994614 180726515)'));
INSERT INTO t2 values(1, 'secret', ST_GeomFromText('POINT(903994614 180726515)'));

--let $wait_timeout=600
--let $wait_condition=SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0;
--source include/wait_condition.inc

--echo # Success!

--sorted_result
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION > 0;
--sorted_result
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0;

DROP TABLE t1, t2;