Merge 10.2 into 10.3

FIXME: Properly resolve conflicts between MDEV-18883
and MDEV-7742/MDEV-8305, and record the correct result for
main.log_slow
This commit is contained in:
Marko Mäkelä 2019-03-05 12:56:05 +02:00
commit 446b3ebdfc
38 changed files with 833 additions and 240 deletions

View File

@ -581,6 +581,56 @@ HEX(a)
C3A4 C3A4
DROP TABLE t1; DROP TABLE t1;
# #
# MDEV-15744: Assertion `derived->table' failed in mysql_derived_merge_for_insert
#
create table t1 (a int, b int);
CREATE OR REPLACE VIEW t2 AS SELECT * FROM t1;
CREATE VIEW v2 AS SELECT * FROM t2;
LOAD DATA INFILE '../../std_data/loaddata7.dat' INTO TABLE v2
FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n';
select * from v2;
a b
2 2
3 3
4 4
5 5
6 6
select * from t2;
a b
2 2
3 3
4 4
5 5
6 6
DROP VIEW IF EXISTS v2,t2;
DROP TABLE IF EXISTS t1;
#
# MDEV-15950: LOAD DATA INTO compex_view crashed
#
create table t1 (a int, b int);
create table t0 (x int, y int);
CREATE OR REPLACE VIEW v1 AS SELECT * FROM t1,t0;
CREATE VIEW v2 AS SELECT * FROM v1;
LOAD DATA INFILE '../../std_data/loaddata7.dat' INTO TABLE v1
FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n';
ERROR HY000: Incorrect usage of Multi-table VIEW and LOAD
LOAD DATA INFILE '../../std_data/loaddata7.dat' INTO TABLE v2
FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n';
ERROR HY000: Incorrect usage of Multi-table VIEW and LOAD
DROP VIEW IF EXISTS v2,v1;
DROP TABLE IF EXISTS t1,t0;
CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a), UNIQUE(b));
INSERT INTO t1 VALUES (1,1);
CREATE TABLE t2 (c INT);
CREATE VIEW v AS SELECT t1.* FROM t1 JOIN t2;
SELECT a, b FROM t1 INTO OUTFILE '15645.data';
LOAD DATA INFILE '15645.data' IGNORE INTO TABLE v (a,b);
ERROR HY000: Incorrect usage of Multi-table VIEW and LOAD
LOAD DATA INFILE '15645.data' REPLACE INTO TABLE v (a,b);
ERROR HY000: Incorrect usage of Multi-table VIEW and LOAD
drop table t1,t2;
drop view v;
#
# MDEV-15497 Wrong empty value in a GEOMETRY column on LOAD DATA # MDEV-15497 Wrong empty value in a GEOMETRY column on LOAD DATA
# #
SET sql_mode=''; SET sql_mode='';

View File

@ -677,6 +677,51 @@ LOAD DATA INFILE '../../std_data/loaddata/mdev-11631.txt' INTO TABLE t1 CHARACTE
SELECT HEX(a) FROM t1; SELECT HEX(a) FROM t1;
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # MDEV-15744: Assertion `derived->table' failed in mysql_derived_merge_for_insert
--echo #
create table t1 (a int, b int);
CREATE OR REPLACE VIEW t2 AS SELECT * FROM t1;
CREATE VIEW v2 AS SELECT * FROM t2;
LOAD DATA INFILE '../../std_data/loaddata7.dat' INTO TABLE v2
FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n';
select * from v2;
select * from t2;
DROP VIEW IF EXISTS v2,t2;
DROP TABLE IF EXISTS t1;
--echo #
--echo # MDEV-15950: LOAD DATA INTO compex_view crashed
--echo #
create table t1 (a int, b int);
create table t0 (x int, y int);
CREATE OR REPLACE VIEW v1 AS SELECT * FROM t1,t0;
CREATE VIEW v2 AS SELECT * FROM v1;
--error ER_WRONG_USAGE
LOAD DATA INFILE '../../std_data/loaddata7.dat' INTO TABLE v1
FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n';
--error ER_WRONG_USAGE
LOAD DATA INFILE '../../std_data/loaddata7.dat' INTO TABLE v2
FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n';
DROP VIEW IF EXISTS v2,v1;
DROP TABLE IF EXISTS t1,t0;
CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a), UNIQUE(b));
INSERT INTO t1 VALUES (1,1);
CREATE TABLE t2 (c INT);
CREATE VIEW v AS SELECT t1.* FROM t1 JOIN t2;
SELECT a, b FROM t1 INTO OUTFILE '15645.data';
--error ER_WRONG_USAGE
LOAD DATA INFILE '15645.data' IGNORE INTO TABLE v (a,b);
--error ER_WRONG_USAGE
LOAD DATA INFILE '15645.data' REPLACE INTO TABLE v (a,b);
drop table t1,t2;
drop view v;
--echo # --echo #
--echo # MDEV-15497 Wrong empty value in a GEOMETRY column on LOAD DATA --echo # MDEV-15497 Wrong empty value in a GEOMETRY column on LOAD DATA

View File

@ -77,3 +77,40 @@ set @@log_slow_filter=default;
set @@log_slow_verbosity=default; set @@log_slow_verbosity=default;
set global log_output= default; set global log_output= default;
truncate mysql.slow_log; truncate mysql.slow_log;
#
# MDEV-18333 Slow_queries count doesn't increase when slow_query_log is turned off
#
SET SESSION slow_query_log=OFF;
SET GLOBAL slow_query_log=OFF;
SET long_query_time=0.1;
# Although this query is disallowed by slow_query_log, it should still increment Slow_queries
SELECT VARIABLE_VALUE INTO @global_slow_queries
FROM INFORMATION_SCHEMA.GLOBAL_STATUS
WHERE VARIABLE_NAME='SLOW_QUERIES';
SELECT sleep(0.2) INTO @tmp FROM DUAL;
SELECT
CAST(VARIABLE_VALUE AS UNSIGNED)-@global_slow_queries AS Slow_queries_increment
FROM
INFORMATION_SCHEMA.GLOBAL_STATUS
WHERE
VARIABLE_NAME='SLOW_QUERIES';
Slow_queries_increment
0
# Although this query is disallowed by log_slow_filter, it should still increment Slow_queries
SET log_slow_filter=filesort;
SELECT sleep(0.2) INTO @tmp FROM DUAL;
SELECT VARIABLE_VALUE INTO @global_slow_queries
FROM INFORMATION_SCHEMA.GLOBAL_STATUS
WHERE VARIABLE_NAME='SLOW_QUERIES';
SELECT sleep(0.2) INTO @tmp FROM DUAL;
SELECT
CAST(VARIABLE_VALUE AS UNSIGNED)-@global_slow_queries AS Slow_queries_increment
FROM
INFORMATION_SCHEMA.GLOBAL_STATUS
WHERE
VARIABLE_NAME='SLOW_QUERIES';
Slow_queries_increment
0
SET log_slow_filter=DEFAULT;
SET @@long_query_time=default;
SET GLOBAL slow_query_log= @org_slow_query_log;

View File

@ -58,3 +58,43 @@ set @@log_slow_filter=default;
set @@log_slow_verbosity=default; set @@log_slow_verbosity=default;
set global log_output= default; set global log_output= default;
truncate mysql.slow_log; truncate mysql.slow_log;
--echo #
--echo # MDEV-18333 Slow_queries count doesn't increase when slow_query_log is turned off
--echo #
SET SESSION slow_query_log=OFF;
SET GLOBAL slow_query_log=OFF;
SET long_query_time=0.1;
--echo # Although this query is disallowed by slow_query_log, it should still increment Slow_queries
SELECT VARIABLE_VALUE INTO @global_slow_queries
FROM INFORMATION_SCHEMA.GLOBAL_STATUS
WHERE VARIABLE_NAME='SLOW_QUERIES';
SELECT sleep(0.2) INTO @tmp FROM DUAL;
SELECT
CAST(VARIABLE_VALUE AS UNSIGNED)-@global_slow_queries AS Slow_queries_increment
FROM
INFORMATION_SCHEMA.GLOBAL_STATUS
WHERE
VARIABLE_NAME='SLOW_QUERIES';
--echo # Although this query is disallowed by log_slow_filter, it should still increment Slow_queries
SET log_slow_filter=filesort;
SELECT sleep(0.2) INTO @tmp FROM DUAL;
SELECT VARIABLE_VALUE INTO @global_slow_queries
FROM INFORMATION_SCHEMA.GLOBAL_STATUS
WHERE VARIABLE_NAME='SLOW_QUERIES';
SELECT sleep(0.2) INTO @tmp FROM DUAL;
SELECT
CAST(VARIABLE_VALUE AS UNSIGNED)-@global_slow_queries AS Slow_queries_increment
FROM
INFORMATION_SCHEMA.GLOBAL_STATUS
WHERE
VARIABLE_NAME='SLOW_QUERIES';
SET log_slow_filter=DEFAULT;
SET @@long_query_time=default;
SET GLOBAL slow_query_log= @org_slow_query_log;

View File

@ -7927,6 +7927,39 @@ CALL sp;
c a b a b c a b a b
DROP PROCEDURE sp; DROP PROCEDURE sp;
DROP TABLE t1; DROP TABLE t1;
#
# MDEV-17055: Server crashes in find_order_in_list upon
# 2nd (3rd) execution of SP with UPDATE
#
CREATE TABLE t1 (a INT);
CREATE VIEW v1 AS SELECT * FROM t1;
CREATE TABLE t2 (c INT);
CREATE PROCEDURE sp() UPDATE v1 SET a = 1 ORDER BY a, b LIMIT 1;
LOCK TABLE t2 READ;
CALL sp;
ERROR HY000: Table 'v1' was not locked with LOCK TABLES
UNLOCK TABLES;
CALL sp;
ERROR 42S22: Unknown column 'b' in 'order clause'
CALL sp;
ERROR 42S22: Unknown column 'b' in 'order clause'
CALL sp;
ERROR 42S22: Unknown column 'b' in 'order clause'
DROP PROCEDURE sp;
CREATE PROCEDURE sp() UPDATE v1 SET a = 1 WHERE a=1 and b=2;
LOCK TABLE t2 READ;
CALL sp;
ERROR HY000: Table 'v1' was not locked with LOCK TABLES
UNLOCK TABLES;
CALL sp;
ERROR 42S22: Unknown column 'b' in 'where clause'
CALL sp;
ERROR 42S22: Unknown column 'b' in 'where clause'
CALL sp;
ERROR 42S22: Unknown column 'b' in 'where clause'
DROP PROCEDURE sp;
DROP VIEW v1;
DROP TABLE t1, t2;
# End of 5.5 test # End of 5.5 test
# #
# MDEV-7040: Crash in field_conv, memcpy_field_possible, part#2 # MDEV-7040: Crash in field_conv, memcpy_field_possible, part#2

View File

@ -9364,6 +9364,47 @@ CALL sp;
DROP PROCEDURE sp; DROP PROCEDURE sp;
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # MDEV-17055: Server crashes in find_order_in_list upon
--echo # 2nd (3rd) execution of SP with UPDATE
--echo #
CREATE TABLE t1 (a INT);
CREATE VIEW v1 AS SELECT * FROM t1;
CREATE TABLE t2 (c INT);
CREATE PROCEDURE sp() UPDATE v1 SET a = 1 ORDER BY a, b LIMIT 1;
LOCK TABLE t2 READ;
--error ER_TABLE_NOT_LOCKED
CALL sp;
UNLOCK TABLES;
--error ER_BAD_FIELD_ERROR
CALL sp;
--error ER_BAD_FIELD_ERROR
CALL sp;
--error ER_BAD_FIELD_ERROR
CALL sp;
# Cleanup
DROP PROCEDURE sp;
CREATE PROCEDURE sp() UPDATE v1 SET a = 1 WHERE a=1 and b=2;
LOCK TABLE t2 READ;
--error ER_TABLE_NOT_LOCKED
CALL sp;
UNLOCK TABLES;
--error ER_BAD_FIELD_ERROR
CALL sp;
--error ER_BAD_FIELD_ERROR
CALL sp;
--error ER_BAD_FIELD_ERROR
CALL sp;
# Cleanup
DROP PROCEDURE sp;
DROP VIEW v1;
DROP TABLE t1, t2;
--echo # End of 5.5 test --echo # End of 5.5 test

View File

@ -1,5 +1,5 @@
--- suite/encryption/r/innodb-checksum-algorithm.result --- suite/encryption/r/innodb-checksum-algorithm.result
+++ suite/encryption/r/innodb-checksum-algorithm,32k.reject +++ suite/encryption/r/innodb-checksum-algorithm.result
@@ -13,9 +13,9 @@ @@ -13,9 +13,9 @@
SET GLOBAL innodb_default_encryption_key_id=4; SET GLOBAL innodb_default_encryption_key_id=4;
SET GLOBAL innodb_checksum_algorithm=crc32; SET GLOBAL innodb_checksum_algorithm=crc32;
@ -9,10 +9,10 @@
create table tc_crc32(a serial, b blob, index(b(10))) engine=innodb create table tc_crc32(a serial, b blob, index(b(10))) engine=innodb
-ROW_FORMAT=COMPRESSED encrypted=no; -ROW_FORMAT=COMPRESSED encrypted=no;
+ROW_FORMAT=DYNAMIC encrypted=no; +ROW_FORMAT=DYNAMIC encrypted=no;
Warnings:
Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1
create table te_crc32(a serial, b blob, index(b(10))) engine=innodb create table te_crc32(a serial, b blob, index(b(10))) engine=innodb
encrypted=yes; @@ -153,9 +153,9 @@
create table t_crc32(a serial, b blob, index(b(10))) engine=innodb
@@ -222,9 +222,9 @@
t_crc32, tpe_crc32, tp_crc32; t_crc32, tpe_crc32, tp_crc32;
SET GLOBAL innodb_checksum_algorithm=innodb; SET GLOBAL innodb_checksum_algorithm=innodb;
create table tce_innodb(a serial, b blob, index(b(10))) engine=innodb create table tce_innodb(a serial, b blob, index(b(10))) engine=innodb
@ -21,10 +21,10 @@
create table tc_innodb(a serial, b blob, index(b(10))) engine=innodb create table tc_innodb(a serial, b blob, index(b(10))) engine=innodb
-ROW_FORMAT=COMPRESSED encrypted=no; -ROW_FORMAT=COMPRESSED encrypted=no;
+ROW_FORMAT=DYNAMIC encrypted=no; +ROW_FORMAT=DYNAMIC encrypted=no;
Warnings:
Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1
create table te_innodb(a serial, b blob, index(b(10))) engine=innodb create table te_innodb(a serial, b blob, index(b(10))) engine=innodb
encrypted=yes; @@ -293,9 +293,9 @@
create table t_innodb(a serial, b blob, index(b(10))) engine=innodb
@@ -431,9 +431,9 @@
t_innodb, tpe_innodb, tp_innodb; t_innodb, tpe_innodb, tp_innodb;
SET GLOBAL innodb_checksum_algorithm=none; SET GLOBAL innodb_checksum_algorithm=none;
create table tce_none(a serial, b blob, index(b(10))) engine=innodb create table tce_none(a serial, b blob, index(b(10))) engine=innodb
@ -33,6 +33,6 @@
create table tc_none(a serial, b blob, index(b(10))) engine=innodb create table tc_none(a serial, b blob, index(b(10))) engine=innodb
-ROW_FORMAT=COMPRESSED encrypted=no; -ROW_FORMAT=COMPRESSED encrypted=no;
+ROW_FORMAT=DYNAMIC encrypted=no; +ROW_FORMAT=DYNAMIC encrypted=no;
Warnings:
Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1
create table te_none(a serial, b blob, index(b(10))) engine=innodb create table te_none(a serial, b blob, index(b(10))) engine=innodb
encrypted=yes;
create table t_none(a serial, b blob, index(b(10))) engine=innodb

View File

@ -1,5 +1,5 @@
--- suite/encryption/r/innodb-checksum-algorithm.result --- suite/encryption/r/innodb-checksum-algorithm.result
+++ suite/encryption/r/innodb-checksum-algorithm,64k.reject +++ suite/encryption/r/innodb-checksum-algorithm.result
@@ -13,9 +13,9 @@ @@ -13,9 +13,9 @@
SET GLOBAL innodb_default_encryption_key_id=4; SET GLOBAL innodb_default_encryption_key_id=4;
SET GLOBAL innodb_checksum_algorithm=crc32; SET GLOBAL innodb_checksum_algorithm=crc32;
@ -9,10 +9,10 @@
create table tc_crc32(a serial, b blob, index(b(10))) engine=innodb create table tc_crc32(a serial, b blob, index(b(10))) engine=innodb
-ROW_FORMAT=COMPRESSED encrypted=no; -ROW_FORMAT=COMPRESSED encrypted=no;
+ROW_FORMAT=DYNAMIC encrypted=no; +ROW_FORMAT=DYNAMIC encrypted=no;
Warnings:
Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1
create table te_crc32(a serial, b blob, index(b(10))) engine=innodb create table te_crc32(a serial, b blob, index(b(10))) engine=innodb
encrypted=yes; @@ -153,9 +153,9 @@
create table t_crc32(a serial, b blob, index(b(10))) engine=innodb
@@ -222,9 +222,9 @@
t_crc32, tpe_crc32, tp_crc32; t_crc32, tpe_crc32, tp_crc32;
SET GLOBAL innodb_checksum_algorithm=innodb; SET GLOBAL innodb_checksum_algorithm=innodb;
create table tce_innodb(a serial, b blob, index(b(10))) engine=innodb create table tce_innodb(a serial, b blob, index(b(10))) engine=innodb
@ -21,10 +21,10 @@
create table tc_innodb(a serial, b blob, index(b(10))) engine=innodb create table tc_innodb(a serial, b blob, index(b(10))) engine=innodb
-ROW_FORMAT=COMPRESSED encrypted=no; -ROW_FORMAT=COMPRESSED encrypted=no;
+ROW_FORMAT=DYNAMIC encrypted=no; +ROW_FORMAT=DYNAMIC encrypted=no;
Warnings:
Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1
create table te_innodb(a serial, b blob, index(b(10))) engine=innodb create table te_innodb(a serial, b blob, index(b(10))) engine=innodb
encrypted=yes; @@ -293,9 +293,9 @@
create table t_innodb(a serial, b blob, index(b(10))) engine=innodb
@@ -431,9 +431,9 @@
t_innodb, tpe_innodb, tp_innodb; t_innodb, tpe_innodb, tp_innodb;
SET GLOBAL innodb_checksum_algorithm=none; SET GLOBAL innodb_checksum_algorithm=none;
create table tce_none(a serial, b blob, index(b(10))) engine=innodb create table tce_none(a serial, b blob, index(b(10))) engine=innodb
@ -33,6 +33,6 @@
create table tc_none(a serial, b blob, index(b(10))) engine=innodb create table tc_none(a serial, b blob, index(b(10))) engine=innodb
-ROW_FORMAT=COMPRESSED encrypted=no; -ROW_FORMAT=COMPRESSED encrypted=no;
+ROW_FORMAT=DYNAMIC encrypted=no; +ROW_FORMAT=DYNAMIC encrypted=no;
Warnings:
Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1
create table te_none(a serial, b blob, index(b(10))) engine=innodb create table te_none(a serial, b blob, index(b(10))) engine=innodb
encrypted=yes;
create table t_none(a serial, b blob, index(b(10))) engine=innodb

View File

@ -14,14 +14,20 @@ create table tce_crc32(a serial, b blob, index(b(10))) engine=innodb
ROW_FORMAT=COMPRESSED encrypted=yes; ROW_FORMAT=COMPRESSED encrypted=yes;
create table tc_crc32(a serial, b blob, index(b(10))) engine=innodb create table tc_crc32(a serial, b blob, index(b(10))) engine=innodb
ROW_FORMAT=COMPRESSED encrypted=no; ROW_FORMAT=COMPRESSED encrypted=no;
Warnings:
Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1
create table te_crc32(a serial, b blob, index(b(10))) engine=innodb create table te_crc32(a serial, b blob, index(b(10))) engine=innodb
encrypted=yes; encrypted=yes;
create table t_crc32(a serial, b blob, index(b(10))) engine=innodb create table t_crc32(a serial, b blob, index(b(10))) engine=innodb
encrypted=no; encrypted=no;
Warnings:
Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1
create table tpe_crc32(a serial, b blob, index(b(10))) engine=innodb create table tpe_crc32(a serial, b blob, index(b(10))) engine=innodb
page_compressed=yes encrypted=yes; page_compressed=yes encrypted=yes;
create table tp_crc32(a serial, b blob, index(b(10))) engine=innodb create table tp_crc32(a serial, b blob, index(b(10))) engine=innodb
page_compressed=yes encrypted=no; page_compressed=yes encrypted=no;
Warnings:
Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1
begin; begin;
insert into tce_crc32(b) values (repeat('secret',20)); insert into tce_crc32(b) values (repeat('secret',20));
insert into tc_crc32(b) values (repeat('secret',20)); insert into tc_crc32(b) values (repeat('secret',20));
@ -149,14 +155,20 @@ create table tce_innodb(a serial, b blob, index(b(10))) engine=innodb
ROW_FORMAT=COMPRESSED encrypted=yes; ROW_FORMAT=COMPRESSED encrypted=yes;
create table tc_innodb(a serial, b blob, index(b(10))) engine=innodb create table tc_innodb(a serial, b blob, index(b(10))) engine=innodb
ROW_FORMAT=COMPRESSED encrypted=no; ROW_FORMAT=COMPRESSED encrypted=no;
Warnings:
Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1
create table te_innodb(a serial, b blob, index(b(10))) engine=innodb create table te_innodb(a serial, b blob, index(b(10))) engine=innodb
encrypted=yes; encrypted=yes;
create table t_innodb(a serial, b blob, index(b(10))) engine=innodb create table t_innodb(a serial, b blob, index(b(10))) engine=innodb
encrypted=no; encrypted=no;
Warnings:
Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1
create table tpe_innodb(a serial, b blob, index(b(10))) engine=innodb create table tpe_innodb(a serial, b blob, index(b(10))) engine=innodb
page_compressed=yes encrypted=yes; page_compressed=yes encrypted=yes;
create table tp_innodb(a serial, b blob, index(b(10))) engine=innodb create table tp_innodb(a serial, b blob, index(b(10))) engine=innodb
page_compressed=yes encrypted=no; page_compressed=yes encrypted=no;
Warnings:
Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1
begin; begin;
insert into tce_innodb(b) values (repeat('secret',20)); insert into tce_innodb(b) values (repeat('secret',20));
insert into tc_innodb(b) values (repeat('secret',20)); insert into tc_innodb(b) values (repeat('secret',20));
@ -284,14 +296,20 @@ create table tce_none(a serial, b blob, index(b(10))) engine=innodb
ROW_FORMAT=COMPRESSED encrypted=yes; ROW_FORMAT=COMPRESSED encrypted=yes;
create table tc_none(a serial, b blob, index(b(10))) engine=innodb create table tc_none(a serial, b blob, index(b(10))) engine=innodb
ROW_FORMAT=COMPRESSED encrypted=no; ROW_FORMAT=COMPRESSED encrypted=no;
Warnings:
Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1
create table te_none(a serial, b blob, index(b(10))) engine=innodb create table te_none(a serial, b blob, index(b(10))) engine=innodb
encrypted=yes; encrypted=yes;
create table t_none(a serial, b blob, index(b(10))) engine=innodb create table t_none(a serial, b blob, index(b(10))) engine=innodb
encrypted=no; encrypted=no;
Warnings:
Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1
create table tpe_none(a serial, b blob, index(b(10))) engine=innodb create table tpe_none(a serial, b blob, index(b(10))) engine=innodb
page_compressed=yes encrypted=yes; page_compressed=yes encrypted=yes;
create table tp_none(a serial, b blob, index(b(10))) engine=innodb create table tp_none(a serial, b blob, index(b(10))) engine=innodb
page_compressed=yes encrypted=no; page_compressed=yes encrypted=no;
Warnings:
Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1
begin; begin;
insert into tce_none(b) values (repeat('secret',20)); insert into tce_none(b) values (repeat('secret',20));
insert into tc_none(b) values (repeat('secret',20)); insert into tc_none(b) values (repeat('secret',20));

View File

@ -7,6 +7,8 @@ set GLOBAL innodb_default_encryption_key_id=4;
create table t1(a int not null primary key, b blob, index(b(10))) engine=innodb row_format=compressed; create table t1(a int not null primary key, b blob, index(b(10))) engine=innodb row_format=compressed;
create table t2(a int not null primary key, b blob, index(b(10))) engine=innodb row_format=compressed encrypted=yes; create table t2(a int not null primary key, b blob, index(b(10))) engine=innodb row_format=compressed encrypted=yes;
create table t3(a int not null primary key, b blob, index(b(10))) engine=innodb row_format=compressed encrypted=no; create table t3(a int not null primary key, b blob, index(b(10))) engine=innodb row_format=compressed encrypted=no;
Warnings:
Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1
insert into t1 values (1, repeat('secret',6000)); insert into t1 values (1, repeat('secret',6000));
insert into t2 values (1, repeat('secret',6000)); insert into t2 values (1, repeat('secret',6000));
insert into t3 values (1, repeat('secret',6000)); insert into t3 values (1, repeat('secret',6000));

View File

@ -2,9 +2,16 @@ SET GLOBAL innodb_encrypt_tables = ON;
SET GLOBAL innodb_encryption_threads = 4; SET GLOBAL innodb_encryption_threads = 4;
CREATE TABLE t1 (pk INT PRIMARY KEY AUTO_INCREMENT, c VARCHAR(256)) ENGINE=INNODB ENCRYPTED=NO ENCRYPTION_KEY_ID=4; CREATE TABLE t1 (pk INT PRIMARY KEY AUTO_INCREMENT, c VARCHAR(256)) ENGINE=INNODB ENCRYPTED=NO ENCRYPTION_KEY_ID=4;
Warnings: Warnings:
Warning 140 InnoDB: Ignored ENCRYPTION_KEY_ID 4 when encryption is disabled Warning 140 InnoDB: ENCRYPTED=NO implies ENCRYPTION_KEY_ID=1
DROP TABLE t1; DROP TABLE t1;
set @save_global = @@GLOBAL.innodb_default_encryption_key_id;
set innodb_default_encryption_key_id = 99; set innodb_default_encryption_key_id = 99;
Warnings:
Warning 1210 innodb_default_encryption_key=99 is not available
set global innodb_default_encryption_key_id = 99;
Warnings:
Warning 1210 innodb_default_encryption_key=99 is not available
set global innodb_default_encryption_key_id = @save_global;
CREATE TABLE t1 (pk INT PRIMARY KEY AUTO_INCREMENT, c VARCHAR(256)) ENGINE=INNODB; CREATE TABLE t1 (pk INT PRIMARY KEY AUTO_INCREMENT, c VARCHAR(256)) ENGINE=INNODB;
ERROR HY000: Can't create table `test`.`t1` (errno: 140 "Wrong create options") ERROR HY000: Can't create table `test`.`t1` (errno: 140 "Wrong create options")
SHOW WARNINGS; SHOW WARNINGS;
@ -38,8 +45,6 @@ t1 CREATE TABLE `t1` (
PRIMARY KEY (`pk`) PRIMARY KEY (`pk`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 `ENCRYPTION_KEY_ID`=4 ) ENGINE=InnoDB DEFAULT CHARSET=latin1 `ENCRYPTION_KEY_ID`=4
CREATE TABLE t2 (pk INT PRIMARY KEY AUTO_INCREMENT, c VARCHAR(256)) ENGINE=INNODB ENCRYPTED=NO ENCRYPTION_KEY_ID=1; CREATE TABLE t2 (pk INT PRIMARY KEY AUTO_INCREMENT, c VARCHAR(256)) ENGINE=INNODB ENCRYPTED=NO ENCRYPTION_KEY_ID=1;
Warnings:
Warning 140 InnoDB: Ignored ENCRYPTION_KEY_ID 1 when encryption is disabled
ALTER TABLE t1 ENCRYPTION_KEY_ID=99; ALTER TABLE t1 ENCRYPTION_KEY_ID=99;
ERROR HY000: Table storage engine 'InnoDB' does not support the create option 'ENCRYPTION_KEY_ID' ERROR HY000: Table storage engine 'InnoDB' does not support the create option 'ENCRYPTION_KEY_ID'
SHOW WARNINGS; SHOW WARNINGS;
@ -51,38 +56,32 @@ drop table t1,t2;
SET GLOBAL innodb_encrypt_tables=OFF; SET GLOBAL innodb_encrypt_tables=OFF;
CREATE TABLE t1 (a int not null primary key) engine=innodb; CREATE TABLE t1 (a int not null primary key) engine=innodb;
ALTER TABLE t1 ENCRYPTION_KEY_ID=4; ALTER TABLE t1 ENCRYPTION_KEY_ID=4;
ERROR HY000: Table storage engine 'InnoDB' does not support the create option 'ENCRYPTION_KEY_ID'
SHOW WARNINGS;
Level Code Message
Warning 140 InnoDB: innodb_encrypt_tables=OFF only allows ENCRYPTION_KEY_ID=1
Error 1478 Table storage engine 'InnoDB' does not support the create option 'ENCRYPTION_KEY_ID'
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL, `a` int(11) NOT NULL,
PRIMARY KEY (`a`) PRIMARY KEY (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1 `ENCRYPTION_KEY_ID`=4
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t2 (a int not null primary key) engine=innodb; CREATE TABLE t2 (a int not null primary key) engine=innodb;
ALTER TABLE t2 ENCRYPTION_KEY_ID=4, ALGORITHM=COPY; ALTER TABLE t2 ENCRYPTION_KEY_ID=4, ALGORITHM=COPY;
ERROR HY000: Can't create table `test`.`t2` (errno: 140 "Wrong create options")
SHOW WARNINGS; SHOW WARNINGS;
Level Code Message Level Code Message
Warning 140 InnoDB: innodb_encrypt_tables=OFF only allows ENCRYPTION_KEY_ID=1
Error 1005 Can't create table `test`.`t2` (errno: 140 "Wrong create options")
Warning 1030 Got error 140 "Wrong create options" from storage engine InnoDB
SHOW CREATE TABLE t2; SHOW CREATE TABLE t2;
Table Create Table Table Create Table
t2 CREATE TABLE `t2` ( t2 CREATE TABLE `t2` (
`a` int(11) NOT NULL, `a` int(11) NOT NULL,
PRIMARY KEY (`a`) PRIMARY KEY (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1 `ENCRYPTION_KEY_ID`=4
CREATE TABLE t3 (a int not null primary key) engine=innodb ENCRYPTION_KEY_ID=4; CREATE TABLE t3 (a int not null primary key) engine=innodb ENCRYPTION_KEY_ID=4;
ERROR HY000: Can't create table `test`.`t3` (errno: 140 "Wrong create options") DROP TABLE t3;
SET GLOBAL innodb_encrypt_tables='FORCE';
CREATE TABLE t1 (a int primary key) engine=innodb encrypted=no;
ERROR HY000: Can't create table `test`.`t1` (errno: 140 "Wrong create options")
SHOW WARNINGS; SHOW WARNINGS;
Level Code Message Level Code Message
Warning 140 InnoDB: innodb_encrypt_tables=OFF only allows ENCRYPTION_KEY_ID=1 Warning 140 InnoDB: ENCRYPTED=NO cannot be used with innodb_encrypt_tables=FORCE
Error 1005 Can't create table `test`.`t3` (errno: 140 "Wrong create options") Error 1005 Can't create table `test`.`t1` (errno: 140 "Wrong create options")
Warning 1030 Got error 140 "Wrong create options" from storage engine InnoDB Warning 1030 Got error 140 "Wrong create options" from storage engine InnoDB
FLUSH TABLES; FLUSH TABLES;
create table t1(f1 int not null, f2 int not null)engine=innodb encrypted=yes; create table t1(f1 int not null, f2 int not null)engine=innodb encrypted=yes;

View File

@ -12,7 +12,10 @@ SET GLOBAL innodb_encryption_threads = 4;
CREATE TABLE t1 (pk INT PRIMARY KEY AUTO_INCREMENT, c VARCHAR(256)) ENGINE=INNODB ENCRYPTED=NO ENCRYPTION_KEY_ID=4; CREATE TABLE t1 (pk INT PRIMARY KEY AUTO_INCREMENT, c VARCHAR(256)) ENGINE=INNODB ENCRYPTED=NO ENCRYPTION_KEY_ID=4;
DROP TABLE t1; DROP TABLE t1;
set @save_global = @@GLOBAL.innodb_default_encryption_key_id;
set innodb_default_encryption_key_id = 99; set innodb_default_encryption_key_id = 99;
set global innodb_default_encryption_key_id = 99;
set global innodb_default_encryption_key_id = @save_global;
--error 1005 --error 1005
CREATE TABLE t1 (pk INT PRIMARY KEY AUTO_INCREMENT, c VARCHAR(256)) ENGINE=INNODB; CREATE TABLE t1 (pk INT PRIMARY KEY AUTO_INCREMENT, c VARCHAR(256)) ENGINE=INNODB;
SHOW WARNINGS; SHOW WARNINGS;
@ -83,22 +86,24 @@ drop table t1,t2;
# #
# MDEV-17230: encryption_key_id from alter is ignored by encryption threads # MDEV-17230: encryption_key_id from alter is ignored by encryption threads
# #
--enable_warnings
SET GLOBAL innodb_encrypt_tables=OFF; SET GLOBAL innodb_encrypt_tables=OFF;
CREATE TABLE t1 (a int not null primary key) engine=innodb; CREATE TABLE t1 (a int not null primary key) engine=innodb;
--error ER_ILLEGAL_HA_CREATE_OPTION
ALTER TABLE t1 ENCRYPTION_KEY_ID=4; ALTER TABLE t1 ENCRYPTION_KEY_ID=4;
SHOW WARNINGS;
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t2 (a int not null primary key) engine=innodb; CREATE TABLE t2 (a int not null primary key) engine=innodb;
--error ER_CANT_CREATE_TABLE
ALTER TABLE t2 ENCRYPTION_KEY_ID=4, ALGORITHM=COPY; ALTER TABLE t2 ENCRYPTION_KEY_ID=4, ALGORITHM=COPY;
SHOW WARNINGS; SHOW WARNINGS;
SHOW CREATE TABLE t2; SHOW CREATE TABLE t2;
--error ER_CANT_CREATE_TABLE
CREATE TABLE t3 (a int not null primary key) engine=innodb ENCRYPTION_KEY_ID=4; CREATE TABLE t3 (a int not null primary key) engine=innodb ENCRYPTION_KEY_ID=4;
DROP TABLE t3;
SET GLOBAL innodb_encrypt_tables='FORCE';
--error ER_CANT_CREATE_TABLE
CREATE TABLE t1 (a int primary key) engine=innodb encrypted=no;
SHOW WARNINGS; SHOW WARNINGS;
FLUSH TABLES; FLUSH TABLES;

View File

@ -3,12 +3,9 @@ INSERT INTO t VALUES (1,2,3),(4,5,6),(7,8,9);
ALTER TABLE t CHANGE c1 c1 INT NULL FIRST, ALGORITHM=INPLACE; ALTER TABLE t CHANGE c1 c1 INT NULL FIRST, ALGORITHM=INPLACE;
affected rows: 0 affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0 info: Records: 0 Duplicates: 0 Warnings: 0
set @old_sql_mode = @@sql_mode;
set @@sql_mode = 'STRICT_TRANS_TABLES';
ALTER TABLE t MODIFY c3 INT NOT NULL, ALGORITHM=INPLACE; ALTER TABLE t MODIFY c3 INT NOT NULL, ALGORITHM=INPLACE;
affected rows: 0 affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0 info: Records: 0 Duplicates: 0 Warnings: 0
set @@sql_mode = @old_sql_mode;
ALTER TABLE t CHANGE c2 c2 INT, CHANGE c2 c2 INT NOT NULL; ALTER TABLE t CHANGE c2 c2 INT, CHANGE c2 c2 INT NOT NULL;
ERROR 42S22: Unknown column 'c2' in 't' ERROR 42S22: Unknown column 'c2' in 't'
ALTER TABLE t MODIFY c2 INT, MODIFY c2 INT NOT NULL; ALTER TABLE t MODIFY c2 INT, MODIFY c2 INT NOT NULL;
@ -24,8 +21,6 @@ ALTER TABLE t MODIFY c2 INT NOT NULL;
affected rows: 0 affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0 info: Records: 0 Duplicates: 0 Warnings: 0
connect con1,localhost,root,,; connect con1,localhost,root,,;
connection con1;
SET SQL_MODE='STRICT_ALL_TABLES';
UPDATE t SET c2=NULL; UPDATE t SET c2=NULL;
ERROR 23000: Column 'c2' cannot be null ERROR 23000: Column 'c2' cannot be null
SELECT * FROM t; SELECT * FROM t;
@ -61,3 +56,152 @@ CREATE TABLE t1(c1 INT) ENGINE=InnoDB;
ALTER TABLE t1 ADD CONSTRAINT UNIQUE KEY i1(c1); ALTER TABLE t1 ADD CONSTRAINT UNIQUE KEY i1(c1);
ALTER TABLE t1 CHANGE c1 c1 INT NOT NULL,ADD KEY(c1); ALTER TABLE t1 CHANGE c1 c1 INT NOT NULL,ADD KEY(c1);
DROP TABLE t1; DROP TABLE t1;
#
# MDEV-18732 InnoDB: ALTER IGNORE returns error for NULL
#
CREATE TABLE t1(c INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (NULL);
ALTER IGNORE TABLE t1 MODIFY c INT NOT NULL;
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 1
Warnings:
Warning 1265 Data truncated for column 'c' at row 1
INSERT INTO t1 VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
SELECT * FROM t1;
c
0
DROP TABLE t1;
CREATE TABLE t1(c INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (NULL),(1),(1);
ALTER IGNORE TABLE t1 ADD UNIQUE(c);
affected rows: 3
info: Records: 3 Duplicates: 1 Warnings: 0
ALTER IGNORE TABLE t1 ADD PRIMARY KEY(c);
affected rows: 2
info: Records: 2 Duplicates: 0 Warnings: 1
Warnings:
Warning 1265 Data truncated for column 'c' at row 1
SELECT * FROM t1;
c
0
1
DROP TABLE t1;
CREATE TABLE t1(c INT, g INT AS (c) PERSISTENT) ENGINE=InnoDB;
CREATE TABLE t2(c INT, v INT AS (c) VIRTUAL) ENGINE=InnoDB;
CREATE TABLE t3(c INT, v INT AS (c) VIRTUAL, INDEX(v)) ENGINE=InnoDB;
INSERT INTO t1 SET c=NULL;
INSERT INTO t2 SET c=NULL;
INSERT INTO t3 SET c=NULL;
SET @old_sql_mode = @@sql_mode;
SET sql_mode = '';
ALTER TABLE t1 MODIFY c INT NOT NULL;
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 1
Warnings:
Warning 1265 Data truncated for column 'c' at row 1
ALTER TABLE t2 MODIFY c INT NOT NULL;
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 1
Warnings:
Warning 1265 Data truncated for column 'c' at row 1
ALTER TABLE t3 MODIFY c INT NOT NULL;
affected rows: 1
info: Records: 1 Duplicates: 0 Warnings: 1
Warnings:
Warning 1265 Data truncated for column 'c' at row 1
SET sql_mode = @old_sql_mode;
# MDEV-18819 FIXME: Wrong result g=NULL
SELECT * FROM t1;
c g
0 NULL
SELECT * FROM t2;
c v
0 0
SELECT * FROM t3;
c v
0 0
SELECT v FROM t3 FORCE INDEX(v);
v
0
CHECK TABLE t1,t2,t3;
Table Op Msg_type Msg_text
test.t1 check status OK
test.t2 check status OK
test.t3 check status OK
DROP TABLE t1,t2,t3;
CREATE TABLE t1(c INT, g INT AS (c) PERSISTENT) ENGINE=InnoDB;
CREATE TABLE t2(c INT, v INT AS (c) VIRTUAL) ENGINE=InnoDB;
CREATE TABLE t3(c INT, v INT AS (c) VIRTUAL, INDEX(v)) ENGINE=InnoDB;
INSERT INTO t1 SET c=NULL;
INSERT INTO t2 SET c=NULL;
INSERT INTO t3 SET c=NULL;
ALTER IGNORE TABLE t1 MODIFY c INT NOT NULL;
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 1
Warnings:
Warning 1265 Data truncated for column 'c' at row 1
ALTER IGNORE TABLE t2 MODIFY c INT NOT NULL;
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 1
Warnings:
Warning 1265 Data truncated for column 'c' at row 1
ALTER IGNORE TABLE t3 MODIFY c INT NOT NULL;
affected rows: 1
info: Records: 1 Duplicates: 0 Warnings: 1
Warnings:
Warning 1265 Data truncated for column 'c' at row 1
# MDEV-18819 FIXME: Wrong result g=NULL
SELECT * FROM t1;
c g
0 NULL
SELECT * FROM t2;
c v
0 0
SELECT * FROM t3;
c v
0 0
SELECT v FROM t3 FORCE INDEX(v);
v
0
CHECK TABLE t1,t2,t3;
Table Op Msg_type Msg_text
test.t1 check status OK
test.t2 check status OK
test.t3 check status OK
DROP TABLE t1,t2,t3;
CREATE TABLE t1(c INT, g INT AS (c) PERSISTENT) ENGINE=InnoDB;
CREATE TABLE t2(c INT, v INT AS (c) VIRTUAL) ENGINE=InnoDB;
CREATE TABLE t3(c INT, v INT AS (c) VIRTUAL, INDEX(v)) ENGINE=InnoDB;
INSERT INTO t1 SET c=NULL;
INSERT INTO t2 SET c=NULL;
INSERT INTO t3 SET c=NULL;
ALTER TABLE t1 MODIFY c INT NOT NULL;
ERROR 01000: Data truncated for column 'c' at row 1
ALTER TABLE t2 MODIFY c INT NOT NULL;
ERROR 01000: Data truncated for column 'c' at row 1
ALTER TABLE t3 MODIFY c INT NOT NULL;
ERROR 01000: Data truncated for column 'c' at row 1
UPDATE t1 SET c=0;
UPDATE t2 SET c=0;
UPDATE t3 SET c=0;
ALTER TABLE t1 MODIFY c INT NOT NULL;
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
ALTER TABLE t2 MODIFY c INT NOT NULL;
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
# MDEV-18819 FIXME: This should not require ALGORITHM=COPY.
ALTER TABLE t3 MODIFY c INT NOT NULL;
affected rows: 1
info: Records: 1 Duplicates: 0 Warnings: 0
SELECT * FROM t1;
c g
0 0
SELECT * FROM t2;
c v
0 0
SELECT * FROM t3;
c v
0 0
DROP TABLE t1,t2,t3;

View File

@ -10,10 +10,15 @@ ALTER TABLE t1 CHANGE i1 id INT UNSIGNED NOT NULL AUTO_INCREMENT,
ADD PRIMARY KEY(id), ALGORITHM=INPLACE; ADD PRIMARY KEY(id), ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Cannot change column type INPLACE. Try ALGORITHM=COPY ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Cannot change column type INPLACE. Try ALGORITHM=COPY
ALTER IGNORE TABLE t1 ADD PRIMARY KEY(i1), ALGORITHM=INPLACE; ALTER IGNORE TABLE t1 ADD PRIMARY KEY(i1), ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Creating unique indexes with IGNORE requires COPY algorithm to remove duplicate rows. Try ALGORITHM=COPY
SET @old_sql_mode = @@sql_mode;
SET sql_mode = '';
ALTER TABLE t1 ADD PRIMARY KEY(i1), ALGORITHM=INPLACE;
affected rows: 0 affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 1 info: Records: 0 Duplicates: 0 Warnings: 1
Warnings: Warnings:
Warning 1265 Data truncated for column 'i1' at row 1 Warning 1265 Data truncated for column 'i1' at row 1
SET sql_mode = @old_sql_mode;
ALTER TABLE t1 CHANGE i1 id INT UNSIGNED NOT NULL AUTO_INCREMENT; ALTER TABLE t1 CHANGE i1 id INT UNSIGNED NOT NULL AUTO_INCREMENT;
affected rows: 1 affected rows: 1
info: Records: 1 Duplicates: 0 Warnings: 0 info: Records: 1 Duplicates: 0 Warnings: 0

View File

@ -396,15 +396,11 @@ UPDATE t1 SET c3 = NULL WHERE c3 = '';
SET lock_wait_timeout = 1; SET lock_wait_timeout = 1;
ALTER TABLE t1 DROP COLUMN c22f, ADD PRIMARY KEY c3p5(c3(5)); ALTER TABLE t1 DROP COLUMN c22f, ADD PRIMARY KEY c3p5(c3(5));
ERROR 42000: Key column 'c22f' doesn't exist in table ERROR 42000: Key column 'c22f' doesn't exist in table
SET @old_sql_mode = @@sql_mode;
SET @@sql_mode = 'STRICT_TRANS_TABLES';
ALTER IGNORE TABLE t1 DROP COLUMN c22f, DROP PRIMARY KEY, ADD PRIMARY KEY c3p5(c3(5)), ALTER IGNORE TABLE t1 DROP COLUMN c22f, DROP PRIMARY KEY, ADD PRIMARY KEY c3p5(c3(5)),
ALGORITHM = INPLACE; ALGORITHM = INPLACE;
ERROR 23000: Duplicate entry '' for key 'PRIMARY' ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Creating unique indexes with IGNORE requires COPY algorithm to remove duplicate rows. Try ALGORITHM=COPY
SET @@sql_mode = @old_sql_mode;
UPDATE t1 SET c3=LEFT(CONCAT(c1,REPEAT('foo',c1)),255) WHERE c3 IS NULL; UPDATE t1 SET c3=LEFT(CONCAT(c1,REPEAT('foo',c1)),255) WHERE c3 IS NULL;
SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL c3p5_created0 WAIT_FOR ins_done0'; SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL c3p5_created0 WAIT_FOR ins_done0';
SET @@sql_mode = 'STRICT_TRANS_TABLES';
ALTER TABLE t1 MODIFY c3 CHAR(255) NOT NULL, DROP COLUMN c22f, ALTER TABLE t1 MODIFY c3 CHAR(255) NOT NULL, DROP COLUMN c22f,
DROP PRIMARY KEY, ADD PRIMARY KEY(c1,c4(5)), DROP PRIMARY KEY, ADD PRIMARY KEY(c1,c4(5)),
ADD COLUMN c5 CHAR(5) DEFAULT 'tired' FIRST; ADD COLUMN c5 CHAR(5) DEFAULT 'tired' FIRST;
@ -418,7 +414,6 @@ SET DEBUG_SYNC = 'now SIGNAL ins_done0';
# session con1 # session con1
connection con1; connection con1;
ERROR 01000: Data truncated for column 'c3' at row 323 ERROR 01000: Data truncated for column 'c3' at row 323
SET @@sql_mode = @old_sql_mode;
# session default # session default
connection default; connection default;
ROLLBACK; ROLLBACK;

View File

@ -219,7 +219,7 @@ ALTER TABLE t1 ADD COLUMN d INT, ALGORITHM=INSTANT;
UPDATE t1 SET d=1; UPDATE t1 SET d=1;
connection ddl; connection ddl;
SET DEBUG_SYNC='row_log_table_apply1_before SIGNAL copied WAIT_FOR logged'; SET DEBUG_SYNC='row_log_table_apply1_before SIGNAL copied WAIT_FOR logged';
ALTER IGNORE TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY (a,d); ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY (a,d);
connection default; connection default;
SET DEBUG_SYNC = 'now WAIT_FOR copied'; SET DEBUG_SYNC = 'now WAIT_FOR copied';
BEGIN; BEGIN;

View File

@ -13,14 +13,7 @@ INSERT INTO t VALUES (1,2,3),(4,5,6),(7,8,9);
ALTER TABLE t CHANGE c1 c1 INT NULL FIRST, ALGORITHM=INPLACE; ALTER TABLE t CHANGE c1 c1 INT NULL FIRST, ALGORITHM=INPLACE;
# NULL -> NOT NULL only allowed INPLACE if strict sql_mode is on. # NULL -> NOT NULL only allowed INPLACE if strict sql_mode is on.
--disable_info
set @old_sql_mode = @@sql_mode;
set @@sql_mode = 'STRICT_TRANS_TABLES';
--enable_info
ALTER TABLE t MODIFY c3 INT NOT NULL, ALGORITHM=INPLACE; ALTER TABLE t MODIFY c3 INT NOT NULL, ALGORITHM=INPLACE;
--disable_info
set @@sql_mode = @old_sql_mode;
--enable_info
# Request some conflicting changes for a single column. # Request some conflicting changes for a single column.
--error ER_BAD_FIELD_ERROR --error ER_BAD_FIELD_ERROR
@ -38,9 +31,6 @@ ALTER TABLE t MODIFY c2 INT NOT NULL;
--disable_info --disable_info
connect (con1,localhost,root,,); connect (con1,localhost,root,,);
connection con1;
SET SQL_MODE='STRICT_ALL_TABLES';
--error ER_BAD_NULL_ERROR --error ER_BAD_NULL_ERROR
UPDATE t SET c2=NULL; UPDATE t SET c2=NULL;
@ -76,6 +66,99 @@ ALTER TABLE t1 ADD CONSTRAINT UNIQUE KEY i1(c1);
ALTER TABLE t1 CHANGE c1 c1 INT NOT NULL,ADD KEY(c1); ALTER TABLE t1 CHANGE c1 c1 INT NOT NULL,ADD KEY(c1);
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # MDEV-18732 InnoDB: ALTER IGNORE returns error for NULL
--echo #
CREATE TABLE t1(c INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (NULL);
--enable_info
ALTER IGNORE TABLE t1 MODIFY c INT NOT NULL;
--disable_info
--error ER_BAD_NULL_ERROR
INSERT INTO t1 VALUES (NULL);
SELECT * FROM t1;
DROP TABLE t1;
CREATE TABLE t1(c INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (NULL),(1),(1);
--enable_info
ALTER IGNORE TABLE t1 ADD UNIQUE(c);
ALTER IGNORE TABLE t1 ADD PRIMARY KEY(c);
--disable_info
SELECT * FROM t1;
DROP TABLE t1;
CREATE TABLE t1(c INT, g INT AS (c) PERSISTENT) ENGINE=InnoDB;
CREATE TABLE t2(c INT, v INT AS (c) VIRTUAL) ENGINE=InnoDB;
CREATE TABLE t3(c INT, v INT AS (c) VIRTUAL, INDEX(v)) ENGINE=InnoDB;
INSERT INTO t1 SET c=NULL;
INSERT INTO t2 SET c=NULL;
INSERT INTO t3 SET c=NULL;
SET @old_sql_mode = @@sql_mode;
# Allow lossy conversions of data
SET sql_mode = '';
--enable_info
ALTER TABLE t1 MODIFY c INT NOT NULL;
ALTER TABLE t2 MODIFY c INT NOT NULL;
ALTER TABLE t3 MODIFY c INT NOT NULL;
--disable_info
SET sql_mode = @old_sql_mode;
--echo # MDEV-18819 FIXME: Wrong result g=NULL
SELECT * FROM t1;
SELECT * FROM t2;
SELECT * FROM t3;
SELECT v FROM t3 FORCE INDEX(v);
CHECK TABLE t1,t2,t3;
DROP TABLE t1,t2,t3;
CREATE TABLE t1(c INT, g INT AS (c) PERSISTENT) ENGINE=InnoDB;
CREATE TABLE t2(c INT, v INT AS (c) VIRTUAL) ENGINE=InnoDB;
CREATE TABLE t3(c INT, v INT AS (c) VIRTUAL, INDEX(v)) ENGINE=InnoDB;
INSERT INTO t1 SET c=NULL;
INSERT INTO t2 SET c=NULL;
INSERT INTO t3 SET c=NULL;
--enable_info
ALTER IGNORE TABLE t1 MODIFY c INT NOT NULL;
ALTER IGNORE TABLE t2 MODIFY c INT NOT NULL;
ALTER IGNORE TABLE t3 MODIFY c INT NOT NULL;
--disable_info
--echo # MDEV-18819 FIXME: Wrong result g=NULL
SELECT * FROM t1;
SELECT * FROM t2;
SELECT * FROM t3;
SELECT v FROM t3 FORCE INDEX(v);
CHECK TABLE t1,t2,t3;
DROP TABLE t1,t2,t3;
CREATE TABLE t1(c INT, g INT AS (c) PERSISTENT) ENGINE=InnoDB;
CREATE TABLE t2(c INT, v INT AS (c) VIRTUAL) ENGINE=InnoDB;
CREATE TABLE t3(c INT, v INT AS (c) VIRTUAL, INDEX(v)) ENGINE=InnoDB;
INSERT INTO t1 SET c=NULL;
INSERT INTO t2 SET c=NULL;
INSERT INTO t3 SET c=NULL;
--enable_info
--error WARN_DATA_TRUNCATED
ALTER TABLE t1 MODIFY c INT NOT NULL;
--error WARN_DATA_TRUNCATED
ALTER TABLE t2 MODIFY c INT NOT NULL;
--error WARN_DATA_TRUNCATED
ALTER TABLE t3 MODIFY c INT NOT NULL;
--disable_info
UPDATE t1 SET c=0;
UPDATE t2 SET c=0;
UPDATE t3 SET c=0;
--enable_info
ALTER TABLE t1 MODIFY c INT NOT NULL;
ALTER TABLE t2 MODIFY c INT NOT NULL;
--echo # MDEV-18819 FIXME: This should not require ALGORITHM=COPY.
ALTER TABLE t3 MODIFY c INT NOT NULL;
--disable_info
SELECT * FROM t1;
SELECT * FROM t2;
SELECT * FROM t3;
DROP TABLE t1,t2,t3;
# Check that all connections opened by test cases in this file are really # Check that all connections opened by test cases in this file are really
# gone so execution of other tests won't be affected by their presence. # gone so execution of other tests won't be affected by their presence.
--source include/wait_until_count_sessions.inc --source include/wait_until_count_sessions.inc

View File

@ -12,7 +12,19 @@ ALGORITHM=COPY;
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON --error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
ALTER TABLE t1 CHANGE i1 id INT UNSIGNED NOT NULL AUTO_INCREMENT, ALTER TABLE t1 CHANGE i1 id INT UNSIGNED NOT NULL AUTO_INCREMENT,
ADD PRIMARY KEY(id), ALGORITHM=INPLACE; ADD PRIMARY KEY(id), ALGORITHM=INPLACE;
# ALTER IGNORE cannot create unique or primary key with ALGORITHM=INPLACE.
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
ALTER IGNORE TABLE t1 ADD PRIMARY KEY(i1), ALGORITHM=INPLACE; ALTER IGNORE TABLE t1 ADD PRIMARY KEY(i1), ALGORITHM=INPLACE;
# Try the same with ALTER TABLE, using non-strict sql_mode.
--disable_info
SET @old_sql_mode = @@sql_mode;
SET sql_mode = '';
--enable_info
ALTER TABLE t1 ADD PRIMARY KEY(i1), ALGORITHM=INPLACE;
--disable_info
SET sql_mode = @old_sql_mode;
--enable_info
ALTER TABLE t1 CHANGE i1 id INT UNSIGNED NOT NULL AUTO_INCREMENT; ALTER TABLE t1 CHANGE i1 id INT UNSIGNED NOT NULL AUTO_INCREMENT;
--disable_info --disable_info
SELECT * FROM t1; SELECT * FROM t1;

View File

@ -350,20 +350,16 @@ UPDATE t1 SET c3 = NULL WHERE c3 = '';
SET lock_wait_timeout = 1; SET lock_wait_timeout = 1;
--error ER_KEY_COLUMN_DOES_NOT_EXITS --error ER_KEY_COLUMN_DOES_NOT_EXITS
ALTER TABLE t1 DROP COLUMN c22f, ADD PRIMARY KEY c3p5(c3(5)); ALTER TABLE t1 DROP COLUMN c22f, ADD PRIMARY KEY c3p5(c3(5));
SET @old_sql_mode = @@sql_mode; # NULL -> NOT NULL is only allowed INPLACE without IGNORE.
# NULL -> NOT NULL only allowed INPLACE if strict sql_mode is on. # Adding a PRIMARY KEY will add NOT NULL implicitly!
# And adding a PRIMARY KEY will also add NOT NULL implicitly! --error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
SET @@sql_mode = 'STRICT_TRANS_TABLES';
--error ER_DUP_ENTRY
ALTER IGNORE TABLE t1 DROP COLUMN c22f, DROP PRIMARY KEY, ADD PRIMARY KEY c3p5(c3(5)), ALTER IGNORE TABLE t1 DROP COLUMN c22f, DROP PRIMARY KEY, ADD PRIMARY KEY c3p5(c3(5)),
ALGORITHM = INPLACE; ALGORITHM = INPLACE;
SET @@sql_mode = @old_sql_mode;
UPDATE t1 SET c3=LEFT(CONCAT(c1,REPEAT('foo',c1)),255) WHERE c3 IS NULL; UPDATE t1 SET c3=LEFT(CONCAT(c1,REPEAT('foo',c1)),255) WHERE c3 IS NULL;
SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL c3p5_created0 WAIT_FOR ins_done0'; SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL c3p5_created0 WAIT_FOR ins_done0';
# NULL -> NOT NULL only allowed INPLACE if strict sql_mode is on. # NULL -> NOT NULL is allowed INPLACE.
SET @@sql_mode = 'STRICT_TRANS_TABLES';
--send --send
ALTER TABLE t1 MODIFY c3 CHAR(255) NOT NULL, DROP COLUMN c22f, ALTER TABLE t1 MODIFY c3 CHAR(255) NOT NULL, DROP COLUMN c22f,
DROP PRIMARY KEY, ADD PRIMARY KEY(c1,c4(5)), DROP PRIMARY KEY, ADD PRIMARY KEY(c1,c4(5)),
@ -382,7 +378,6 @@ SET DEBUG_SYNC = 'now SIGNAL ins_done0';
connection con1; connection con1;
--error WARN_DATA_TRUNCATED --error WARN_DATA_TRUNCATED
reap; reap;
SET @@sql_mode = @old_sql_mode;
--echo # session default --echo # session default
connection default; connection default;

View File

@ -248,7 +248,7 @@ UPDATE t1 SET d=1;
connection ddl; connection ddl;
SET DEBUG_SYNC='row_log_table_apply1_before SIGNAL copied WAIT_FOR logged'; SET DEBUG_SYNC='row_log_table_apply1_before SIGNAL copied WAIT_FOR logged';
send ALTER IGNORE TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY (a,d); send ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY (a,d);
connection default; connection default;
SET DEBUG_SYNC = 'now WAIT_FOR copied'; SET DEBUG_SYNC = 'now WAIT_FOR copied';

View File

@ -1,5 +1,5 @@
/* Copyright (c) 2010, 2015, Oracle and/or its affiliates. /* Copyright (c) 2010, 2015, Oracle and/or its affiliates.
Copyright (c) 2011, 2018, MariaDB Copyright (c) 2011, 2019, MariaDB
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -1398,8 +1398,6 @@ bool Sql_cmd_repair_table::execute(THD *thd)
if (check_table_access(thd, SELECT_ACL | INSERT_ACL, first_table, if (check_table_access(thd, SELECT_ACL | INSERT_ACL, first_table,
FALSE, UINT_MAX, FALSE)) FALSE, UINT_MAX, FALSE))
goto error; /* purecov: inspected */ goto error; /* purecov: inspected */
thd->enable_slow_log&= !MY_TEST(thd->variables.log_slow_disabled_statements &
LOG_SLOW_DISABLE_ADMIN);
WSREP_TO_ISOLATION_BEGIN_WRTCHK(NULL, NULL, first_table); WSREP_TO_ISOLATION_BEGIN_WRTCHK(NULL, NULL, first_table);
res= mysql_admin_table(thd, first_table, &m_lex->check_opt, "repair", res= mysql_admin_table(thd, first_table, &m_lex->check_opt, "repair",
TL_WRITE, 1, TL_WRITE, 1,

View File

@ -28,7 +28,7 @@ int reassign_keycache_tables(THD* thd, KEY_CACHE *src_cache,
/** /**
Sql_cmd_analyze_table represents the ANALYZE TABLE statement. Sql_cmd_analyze_table represents the ANALYZE TABLE statement.
*/ */
class Sql_cmd_analyze_table : public Sql_cmd class Sql_cmd_analyze_table : public Sql_cmd_admin
{ {
public: public:
/** /**
@ -53,7 +53,7 @@ public:
/** /**
Sql_cmd_check_table represents the CHECK TABLE statement. Sql_cmd_check_table represents the CHECK TABLE statement.
*/ */
class Sql_cmd_check_table : public Sql_cmd class Sql_cmd_check_table : public Sql_cmd_admin
{ {
public: public:
/** /**
@ -77,7 +77,7 @@ public:
/** /**
Sql_cmd_optimize_table represents the OPTIMIZE TABLE statement. Sql_cmd_optimize_table represents the OPTIMIZE TABLE statement.
*/ */
class Sql_cmd_optimize_table : public Sql_cmd class Sql_cmd_optimize_table : public Sql_cmd_admin
{ {
public: public:
/** /**
@ -102,7 +102,7 @@ public:
/** /**
Sql_cmd_repair_table represents the REPAIR TABLE statement. Sql_cmd_repair_table represents the REPAIR TABLE statement.
*/ */
class Sql_cmd_repair_table : public Sql_cmd class Sql_cmd_repair_table : public Sql_cmd_admin
{ {
public: public:
/** /**

View File

@ -333,7 +333,7 @@ private:
statements. statements.
@todo move Alter_info and other ALTER generic structures from Lex here. @todo move Alter_info and other ALTER generic structures from Lex here.
*/ */
class Sql_cmd_common_alter_table : public Sql_cmd class Sql_cmd_common_alter_table : public Sql_cmd_admin
{ {
protected: protected:
/** /**

View File

@ -160,6 +160,8 @@ public:
*/ */
virtual bool execute(THD *thd) = 0; virtual bool execute(THD *thd) = 0;
virtual bool log_slow_enabled_statement(const THD *thd) const;
protected: protected:
Sql_cmd() Sql_cmd()
{} {}
@ -177,6 +179,17 @@ protected:
}; };
class Sql_cmd_admin: public Sql_cmd
{
public:
Sql_cmd_admin()
{}
~Sql_cmd_admin()
{}
bool log_slow_enabled_statement(const THD *thd) const;
};
/** /**
Sql_cmd_call represents the CALL statement. Sql_cmd_call represents the CALL statement.
*/ */

View File

@ -1,6 +1,6 @@
/* /*
Copyright (c) 2000, 2010, Oracle and/or its affiliates. Copyright (c) 2000, 2010, Oracle and/or its affiliates.
Copyright (c) 2010, 2015, MariaDB Copyright (c) 2010, 2019, MariaDB
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -41,7 +41,7 @@
#include "records.h" // init_read_record, #include "records.h" // init_read_record,
#include "filesort.h" #include "filesort.h"
#include "uniques.h" #include "uniques.h"
#include "sql_derived.h" // mysql_handle_list_of_derived #include "sql_derived.h" // mysql_handle_derived
// end_read_record // end_read_record
#include "sql_partition.h" // make_used_partitions_str #include "sql_partition.h" // make_used_partitions_str
@ -335,9 +335,9 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
} }
} }
if (mysql_handle_list_of_derived(thd->lex, table_list, DT_MERGE_FOR_INSERT)) if (thd->lex->handle_list_of_derived(table_list, DT_MERGE_FOR_INSERT))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
if (mysql_handle_list_of_derived(thd->lex, table_list, DT_PREPARE)) if (thd->lex->handle_list_of_derived(table_list, DT_PREPARE))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
if (!table_list->single_table_updatable()) if (!table_list->single_table_updatable())

View File

@ -93,6 +93,7 @@ mysql_handle_derived(LEX *lex, uint phases)
sl= sl->next_select_in_list()) sl= sl->next_select_in_list())
{ {
TABLE_LIST *cursor= sl->get_table_list(); TABLE_LIST *cursor= sl->get_table_list();
sl->changed_elements|= TOUCHED_SEL_DERIVED;
/* /*
DT_MERGE_FOR_INSERT is not needed for views/derived tables inside DT_MERGE_FOR_INSERT is not needed for views/derived tables inside
subqueries. Views and derived tables of subqueries should be subqueries. Views and derived tables of subqueries should be
@ -202,36 +203,6 @@ mysql_handle_single_derived(LEX *lex, TABLE_LIST *derived, uint phases)
} }
/**
Run specified phases for derived tables/views in the given list
@param lex LEX for this thread
@param table_list list of derived tables/view to handle
@param phase_map phases to process tables/views through
@details
This function runs phases specified by the 'phases_map' on derived
tables/views found in the 'dt_list' with help of the
TABLE_LIST::handle_derived function.
'lex' is passed as an argument to the TABLE_LIST::handle_derived.
@return FALSE ok
@return TRUE error
*/
bool
mysql_handle_list_of_derived(LEX *lex, TABLE_LIST *table_list, uint phases)
{
for (TABLE_LIST *tl= table_list; tl; tl= tl->next_local)
{
if (tl->is_view_or_derived() &&
tl->handle_derived(lex, phases))
return TRUE;
}
return FALSE;
}
/** /**
Merge a derived table/view into the embedding select Merge a derived table/view into the embedding select

View File

@ -22,7 +22,6 @@ struct LEX;
bool mysql_handle_derived(LEX *lex, uint phases); bool mysql_handle_derived(LEX *lex, uint phases);
bool mysql_handle_single_derived(LEX *lex, TABLE_LIST *derived, uint phases); bool mysql_handle_single_derived(LEX *lex, TABLE_LIST *derived, uint phases);
bool mysql_handle_list_of_derived(LEX *lex, TABLE_LIST *dt_list, uint phases);
bool mysql_derived_reinit(THD *thd, LEX *lex, TABLE_LIST *derived); bool mysql_derived_reinit(THD *thd, LEX *lex, TABLE_LIST *derived);
/** /**

View File

@ -1491,7 +1491,7 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list,
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
if (table_list->handle_derived(thd->lex, DT_MERGE_FOR_INSERT)) if (table_list->handle_derived(thd->lex, DT_MERGE_FOR_INSERT))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
if (mysql_handle_list_of_derived(thd->lex, table_list, DT_PREPARE)) if (thd->lex->handle_list_of_derived(table_list, DT_PREPARE))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
/* /*
For subqueries in VALUES() we should not see the table in which we are For subqueries in VALUES() we should not see the table in which we are
@ -1584,7 +1584,6 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list,
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
select_lex->fix_prepare_information(thd, &fake_conds, &fake_conds); select_lex->fix_prepare_information(thd, &fake_conds, &fake_conds);
select_lex->first_execution= 0;
} }
/* /*
Only call prepare_for_posistion() if we are not performing a DELAYED Only call prepare_for_posistion() if we are not performing a DELAYED

View File

@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2014, Oracle and/or its affiliates. /* Copyright (c) 2000, 2014, Oracle and/or its affiliates.
Copyright (c) 2009, 2018, MariaDB Corporation Copyright (c) 2009, 2019, MariaDB Corporation
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -2317,7 +2317,7 @@ void st_select_lex::init_query()
hidden_bit_fields= 0; hidden_bit_fields= 0;
subquery_in_having= explicit_limit= 0; subquery_in_having= explicit_limit= 0;
is_item_list_lookup= 0; is_item_list_lookup= 0;
first_execution= 1; changed_elements= 0;
first_natural_join_processing= 1; first_natural_join_processing= 1;
first_cond_optimization= 1; first_cond_optimization= 1;
parsing_place= NO_MATTER; parsing_place= NO_MATTER;
@ -3843,10 +3843,11 @@ void st_select_lex::fix_prepare_information(THD *thd, Item **conds,
Item **having_conds) Item **having_conds)
{ {
DBUG_ENTER("st_select_lex::fix_prepare_information"); DBUG_ENTER("st_select_lex::fix_prepare_information");
if (!thd->stmt_arena->is_conventional() && first_execution) if (!thd->stmt_arena->is_conventional() &&
!(changed_elements & TOUCHED_SEL_COND))
{ {
Query_arena_stmt on_stmt_arena(thd); Query_arena_stmt on_stmt_arena(thd);
first_execution= 0; changed_elements|= TOUCHED_SEL_COND;
if (group_list.first) if (group_list.first)
{ {
if (!group_list_ptrs) if (!group_list_ptrs)
@ -4097,14 +4098,7 @@ bool st_select_lex::optimize_unflattened_subqueries(bool const_only)
bool st_select_lex::handle_derived(LEX *lex, uint phases) bool st_select_lex::handle_derived(LEX *lex, uint phases)
{ {
for (TABLE_LIST *cursor= (TABLE_LIST*) table_list.first; return lex->handle_list_of_derived(table_list.first, phases);
cursor;
cursor= cursor->next_local)
{
if (cursor->is_view_or_derived() && cursor->handle_derived(lex, phases))
return TRUE;
}
return FALSE;
} }
@ -5110,6 +5104,20 @@ bool LEX::is_partition_management() const
} }
bool Sql_cmd::log_slow_enabled_statement(const THD *thd) const
{
return global_system_variables.sql_log_slow && thd->variables.sql_log_slow;
}
bool Sql_cmd_admin::log_slow_enabled_statement(const THD *thd) const
{
return !MY_TEST(thd->variables.log_slow_disabled_statements &
LOG_SLOW_DISABLE_ADMIN) &&
Sql_cmd::log_slow_enabled_statement(thd);
}
/** /**
Exclude last added SELECT_LEX (current) in the UNIT and return pointer in it Exclude last added SELECT_LEX (current) in the UNIT and return pointer in it
(previous become currect) (previous become currect)

View File

@ -931,6 +931,10 @@ public:
:tmp_field(fld), producing_item(item) {} :tmp_field(fld), producing_item(item) {}
}; };
#define TOUCHED_SEL_COND 1/* WHERE/HAVING/ON should be reinited before use */
#define TOUCHED_SEL_DERIVED (1<<1)/* derived should be reinited before use */
/* /*
SELECT_LEX - store information of parsed SELECT statment SELECT_LEX - store information of parsed SELECT statment
*/ */
@ -1117,7 +1121,8 @@ public:
subquery. Prepared statements work OK in that regard, as in subquery. Prepared statements work OK in that regard, as in
case of an error during prepare the PS is not created. case of an error during prepare the PS is not created.
*/ */
bool first_execution; uint8 changed_elements; // see TOUCHED_SEL_*
/* TODO: add foloowing first_* to bitmap above */
bool first_natural_join_processing; bool first_natural_join_processing;
bool first_cond_optimization; bool first_cond_optimization;
/* do not wrap view fields with Item_ref */ /* do not wrap view fields with Item_ref */
@ -3949,6 +3954,31 @@ public:
bool tmp_table() const { return create_info.tmp_table(); } bool tmp_table() const { return create_info.tmp_table(); }
bool if_exists() const { return create_info.if_exists(); } bool if_exists() const { return create_info.if_exists(); }
/*
Run specified phases for derived tables/views in the given list
@param table_list - list of derived tables/view to handle
@param phase - phases to process tables/views through
@details
This method runs phases specified by the 'phases' on derived
tables/views found in the 'table_list' with help of the
TABLE_LIST::handle_derived function.
'this' is passed as an argument to the TABLE_LIST::handle_derived.
@return false - ok
@return true - error
*/
bool handle_list_of_derived(TABLE_LIST *table_list, uint phases)
{
for (TABLE_LIST *tl= table_list; tl; tl= tl->next_local)
{
if (tl->is_view_or_derived() && tl->handle_derived(this, phases))
return true;
}
return false;
}
SELECT_LEX *exclude_last_select(); SELECT_LEX *exclude_last_select();
bool add_unit_in_brackets(SELECT_LEX *nselect); bool add_unit_in_brackets(SELECT_LEX *nselect);
void check_automatic_up(enum sub_select_type type); void check_automatic_up(enum sub_select_type type);

View File

@ -387,8 +387,9 @@ int mysql_load(THD *thd, const sql_exchange *ex, TABLE_LIST *table_list,
if (open_and_lock_tables(thd, table_list, TRUE, 0)) if (open_and_lock_tables(thd, table_list, TRUE, 0))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
if (mysql_handle_single_derived(thd->lex, table_list, DT_MERGE_FOR_INSERT) || if (table_list->handle_derived(thd->lex, DT_MERGE_FOR_INSERT))
mysql_handle_single_derived(thd->lex, table_list, DT_PREPARE)) DBUG_RETURN(TRUE);
if (thd->lex->handle_list_of_derived(table_list, DT_PREPARE))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
if (setup_tables_and_check_access(thd, &thd->lex->select_lex.context, if (setup_tables_and_check_access(thd, &thd->lex->select_lex.context,
&thd->lex->select_lex.top_join_list, &thd->lex->select_lex.top_join_list,
@ -404,6 +405,11 @@ int mysql_load(THD *thd, const sql_exchange *ex, TABLE_LIST *table_list,
my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias.str, "LOAD"); my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias.str, "LOAD");
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
if (table_list->is_multitable())
{
my_error(ER_WRONG_USAGE, MYF(0), "Multi-table VIEW", "LOAD");
DBUG_RETURN(TRUE);
}
if (table_list->prepare_where(thd, 0, TRUE) || if (table_list->prepare_where(thd, 0, TRUE) ||
table_list->prepare_check_option(thd)) table_list->prepare_check_option(thd))
{ {

View File

@ -1642,7 +1642,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
thd->variables.log_slow_disabled_statements defines which statements thd->variables.log_slow_disabled_statements defines which statements
are logged to slow log are logged to slow log
*/ */
thd->enable_slow_log= thd->variables.sql_log_slow; thd->enable_slow_log= true;
thd->query_plan_flags= QPLAN_INIT; thd->query_plan_flags= QPLAN_INIT;
thd->lex->sql_command= SQLCOM_END; /* to avoid confusing VIEW detectors */ thd->lex->sql_command= SQLCOM_END; /* to avoid confusing VIEW detectors */
thd->reset_kill_query(); thd->reset_kill_query();
@ -2466,6 +2466,32 @@ com_multi_end:
} }
static bool log_slow_enabled_statement(const THD *thd)
{
/*
TODO-10.4: Add classes Sql_cmd_create_index and Sql_cmd_drop_index
for symmetry with other admin commands, so these statements can be
handled by this command:
*/
if (thd->lex->m_sql_cmd)
return thd->lex->m_sql_cmd->log_slow_enabled_statement(thd);
/*
Currently CREATE INDEX or DROP INDEX cause a full table rebuild
and thus classify as slow administrative statements just like
ALTER TABLE.
*/
if ((thd->lex->sql_command == SQLCOM_CREATE_INDEX ||
thd->lex->sql_command == SQLCOM_DROP_INDEX) &&
MY_TEST(thd->variables.log_slow_disabled_statements &
LOG_SLOW_DISABLE_ADMIN))
return true;
return global_system_variables.sql_log_slow &&
thd->variables.sql_log_slow;
}
/* /*
Log query to slow queries, if it passes filtering Log query to slow queries, if it passes filtering
@ -2484,8 +2510,17 @@ void log_slow_statement(THD *thd)
*/ */
if (unlikely(thd->in_sub_stmt)) if (unlikely(thd->in_sub_stmt))
goto end; // Don't set time for sub stmt goto end; // Don't set time for sub stmt
if (!thd->enable_slow_log || !global_system_variables.sql_log_slow) /*
goto end; Skip both long_query_count increment and logging if the current
statement forces slow log suppression (e.g. an SP statement).
Note, we don't check for global_system_variables.sql_log_slow here.
According to the manual, the "Slow_queries" status variable does not require
sql_log_slow to be ON. So even if sql_log_slow is OFF, we still need to
continue and increment long_query_count (and skip only logging, see below):
*/
if (!thd->enable_slow_log)
goto end; // E.g. SP statement
if ((thd->server_status & if ((thd->server_status &
(SERVER_QUERY_NO_INDEX_USED | SERVER_QUERY_NO_GOOD_INDEX_USED)) && (SERVER_QUERY_NO_INDEX_USED | SERVER_QUERY_NO_GOOD_INDEX_USED)) &&
@ -2498,15 +2533,14 @@ void log_slow_statement(THD *thd)
thd->server_status|= SERVER_QUERY_WAS_SLOW; thd->server_status|= SERVER_QUERY_WAS_SLOW;
} }
/* Follow the slow log filter configuration. */
if (thd->variables.log_slow_filter &&
!(thd->variables.log_slow_filter & thd->query_plan_flags))
goto end;
if ((thd->server_status & SERVER_QUERY_WAS_SLOW) && if ((thd->server_status & SERVER_QUERY_WAS_SLOW) &&
thd->get_examined_row_count() >= thd->variables.min_examined_row_limit) thd->get_examined_row_count() >= thd->variables.min_examined_row_limit)
{ {
thd->status_var.long_query_count++; thd->status_var.long_query_count++;
if (!log_slow_enabled_statement(thd))
goto end;
/* /*
If rate limiting of slow log writes is enabled, decide whether to log If rate limiting of slow log writes is enabled, decide whether to log
this query to the log or not. this query to the log or not.
@ -2515,6 +2549,14 @@ void log_slow_statement(THD *thd)
(global_query_id % thd->variables.log_slow_rate_limit) != 0) (global_query_id % thd->variables.log_slow_rate_limit) != 0)
goto end; goto end;
/*
Follow the slow log filter configuration:
skip logging if the current statement matches the filter.
*/
if (thd->variables.log_slow_filter &&
!(thd->variables.log_slow_filter & thd->query_plan_flags))
goto end;
THD_STAGE_INFO(thd, stage_logging_slow_query); THD_STAGE_INFO(thd, stage_logging_slow_query);
slow_log_print(thd, thd->query(), thd->query_length(), slow_log_print(thd, thd->query(), thd->query_length(),
thd->utime_after_query); thd->utime_after_query);

View File

@ -1,5 +1,5 @@
/* Copyright (c) 2002, 2015, Oracle and/or its affiliates. /* Copyright (c) 2002, 2015, Oracle and/or its affiliates.
Copyright (c) 2008, 2017, MariaDB Copyright (c) 2008, 2019, MariaDB
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -2930,7 +2930,7 @@ void reinit_stmt_before_use(THD *thd, LEX *lex)
} }
for (; sl; sl= sl->next_select_in_list()) for (; sl; sl= sl->next_select_in_list())
{ {
if (!sl->first_execution) if (sl->changed_elements & TOUCHED_SEL_COND)
{ {
/* remove option which was put by mysql_explain_union() */ /* remove option which was put by mysql_explain_union() */
sl->options&= ~SELECT_DESCRIBE; sl->options&= ~SELECT_DESCRIBE;
@ -2977,8 +2977,13 @@ void reinit_stmt_before_use(THD *thd, LEX *lex)
order->next= sl->group_list_ptrs->at(ix+1); order->next= sl->group_list_ptrs->at(ix+1);
} }
} }
}
{ // no harm to do it (item_ptr set on parsing)
ORDER *order;
for (order= sl->group_list.first; order; order= order->next) for (order= sl->group_list.first; order; order= order->next)
{
order->item= &order->item_ptr; order->item= &order->item_ptr;
}
/* Fix ORDER list */ /* Fix ORDER list */
for (order= sl->order_list.first; order; order= order->next) for (order= sl->order_list.first; order; order= order->next)
order->item= &order->item_ptr; order->item= &order->item_ptr;
@ -2992,7 +2997,8 @@ void reinit_stmt_before_use(THD *thd, LEX *lex)
for (order= win_spec->order_list->first; order; order= order->next) for (order= win_spec->order_list->first; order; order= order->next)
order->item= &order->item_ptr; order->item= &order->item_ptr;
} }
}
if (sl->changed_elements & TOUCHED_SEL_DERIVED)
{ {
#ifdef DBUG_ASSERT_EXISTS #ifdef DBUG_ASSERT_EXISTS
bool res= bool res=
@ -3000,7 +3006,7 @@ void reinit_stmt_before_use(THD *thd, LEX *lex)
sl->handle_derived(lex, DT_REINIT); sl->handle_derived(lex, DT_REINIT);
DBUG_ASSERT(res == 0); DBUG_ASSERT(res == 0);
} }
}
{ {
SELECT_LEX_UNIT *unit= sl->master_unit(); SELECT_LEX_UNIT *unit= sl->master_unit();
unit->unclean(); unit->unclean();

View File

@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2016 Oracle and/or its affiliates. /* Copyright (c) 2000, 2016 Oracle and/or its affiliates.
Copyright (c) 2009, 2018 MariaDB Corporation Copyright (c) 2009, 2019 MariaDB Corporation
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -1184,7 +1184,7 @@ JOIN::prepare(TABLE_LIST *tables_init,
select_lex->check_unrestricted_recursive( select_lex->check_unrestricted_recursive(
thd->variables.only_standard_compliant_cte)) thd->variables.only_standard_compliant_cte))
DBUG_RETURN(-1); DBUG_RETURN(-1);
if (select_lex->first_execution) if (!(select_lex->changed_elements & TOUCHED_SEL_COND))
select_lex->check_subqueries_with_recursive_references(); select_lex->check_subqueries_with_recursive_references();
int res= check_and_do_in_subquery_rewrites(this); int res= check_and_do_in_subquery_rewrites(this);

View File

@ -612,7 +612,8 @@ st_select_lex_unit::init_prepare_fake_select_lex(THD *thd_arg,
shows whether this is called at the first execution of the union that shows whether this is called at the first execution of the union that
may form just a subselect. may form just a subselect.
*/ */
if (!fake_select_lex->first_execution && first_execution) if ((fake_select_lex->changed_elements & TOUCHED_SEL_COND) &&
first_execution)
{ {
for (ORDER *order= global_parameters()->order_list.first; for (ORDER *order= global_parameters()->order_list.first;
order; order;

View File

@ -718,9 +718,25 @@ static MYSQL_THDVAR_BOOL(compression_default, PLUGIN_VAR_OPCMDARG,
"Is compression the default for new tables", "Is compression the default for new tables",
NULL, NULL, FALSE); NULL, NULL, FALSE);
/** Update callback for SET [SESSION] innodb_default_encryption_key_id */
static void
innodb_default_encryption_key_id_update(THD* thd, st_mysql_sys_var* var,
void* var_ptr, const void *save)
{
uint key_id = *static_cast<const uint*>(save);
if (key_id != FIL_DEFAULT_ENCRYPTION_KEY
&& !encryption_key_id_exists(key_id)) {
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_WRONG_ARGUMENTS,
"innodb_default_encryption_key=%u"
" is not available", key_id);
}
*static_cast<uint*>(var_ptr) = key_id;
}
static MYSQL_THDVAR_UINT(default_encryption_key_id, PLUGIN_VAR_RQCMDARG, static MYSQL_THDVAR_UINT(default_encryption_key_id, PLUGIN_VAR_RQCMDARG,
"Default encryption key id used for table encryption.", "Default encryption key id used for table encryption.",
NULL, NULL, NULL, innodb_default_encryption_key_id_update,
FIL_DEFAULT_ENCRYPTION_KEY, 1, UINT_MAX32, 0); FIL_DEFAULT_ENCRYPTION_KEY, 1, UINT_MAX32, 0);
/** /**
@ -11120,8 +11136,8 @@ err_col:
if (err == DB_SUCCESS) { if (err == DB_SUCCESS) {
err = row_create_table_for_mysql( err = row_create_table_for_mysql(
table, m_trx, table, m_trx,
(fil_encryption_t)options->encryption, fil_encryption_t(options->encryption),
(uint32_t)options->encryption_key_id); uint32_t(options->encryption_key_id));
m_drop_before_rollback = (err == DB_SUCCESS); m_drop_before_rollback = (err == DB_SUCCESS);
} }
@ -11541,25 +11557,62 @@ const char*
create_table_info_t::check_table_options() create_table_info_t::check_table_options()
{ {
enum row_type row_format = m_create_info->row_type; enum row_type row_format = m_create_info->row_type;
ha_table_option_struct *options= m_form->s->option_struct; const ha_table_option_struct *options= m_form->s->option_struct;
fil_encryption_t encrypt = (fil_encryption_t)options->encryption;
bool should_encrypt = (encrypt == FIL_ENCRYPTION_ON);
/* Currently we do not support encryption for switch (options->encryption) {
spatial indexes thus do not allow creating table with forced case FIL_ENCRYPTION_OFF:
encryption */ if (options->encryption_key_id != FIL_DEFAULT_ENCRYPTION_KEY) {
push_warning(
m_thd, Sql_condition::WARN_LEVEL_WARN,
HA_WRONG_CREATE_OPTION,
"InnoDB: ENCRYPTED=NO implies"
" ENCRYPTION_KEY_ID=1");
compile_time_assert(FIL_DEFAULT_ENCRYPTION_KEY == 1);
}
if (srv_encrypt_tables != 2) {
break;
}
push_warning(
m_thd, Sql_condition::WARN_LEVEL_WARN,
HA_WRONG_CREATE_OPTION,
"InnoDB: ENCRYPTED=NO cannot be used with"
" innodb_encrypt_tables=FORCE");
return "ENCRYPTED";
case FIL_ENCRYPTION_DEFAULT:
if (!srv_encrypt_tables) {
break;
}
/* fall through */
case FIL_ENCRYPTION_ON:
const uint32_t key_id = uint32_t(options->encryption_key_id);
if (!encryption_key_id_exists(key_id)) {
push_warning_printf(
m_thd, Sql_condition::WARN_LEVEL_WARN,
HA_WRONG_CREATE_OPTION,
"InnoDB: ENCRYPTION_KEY_ID %u not available",
key_id);
return "ENCRYPTION_KEY_ID";
}
/* Currently we do not support encryption for spatial indexes.
Do not allow ENCRYPTED=YES if any SPATIAL INDEX exists. */
if (options->encryption != FIL_ENCRYPTION_ON) {
break;
}
for (ulint i = 0; i < m_form->s->keys; i++) { for (ulint i = 0; i < m_form->s->keys; i++) {
const KEY* key = m_form->key_info + i; if (m_form->key_info[i].flags & HA_SPATIAL) {
if (key->flags & HA_SPATIAL && should_encrypt) { push_warning(m_thd,
push_warning_printf(m_thd, Sql_condition::WARN_LEVEL_WARN, Sql_condition::WARN_LEVEL_WARN,
HA_ERR_UNSUPPORTED, HA_ERR_UNSUPPORTED,
"InnoDB: ENCRYPTED=ON not supported for table because " "InnoDB: ENCRYPTED=YES is not"
"it contains spatial index."); " supported for SPATIAL INDEX");
return "ENCRYPTED"; return "ENCRYPTED";
} }
} }
}
if (encrypt != FIL_ENCRYPTION_DEFAULT && !m_allow_file_per_table) { if (!m_allow_file_per_table
&& options->encryption != FIL_ENCRYPTION_DEFAULT) {
push_warning( push_warning(
m_thd, Sql_condition::WARN_LEVEL_WARN, m_thd, Sql_condition::WARN_LEVEL_WARN,
HA_WRONG_CREATE_OPTION, HA_WRONG_CREATE_OPTION,
@ -11567,14 +11620,6 @@ create_table_info_t::check_table_options()
return "ENCRYPTED"; return "ENCRYPTED";
} }
if (encrypt == FIL_ENCRYPTION_OFF && srv_encrypt_tables == 2) {
push_warning(
m_thd, Sql_condition::WARN_LEVEL_WARN,
HA_WRONG_CREATE_OPTION,
"InnoDB: ENCRYPTED=OFF cannot be used when innodb_encrypt_tables=FORCE");
return "ENCRYPTED";
}
/* Check page compression requirements */ /* Check page compression requirements */
if (options->page_compressed) { if (options->page_compressed) {
@ -11647,46 +11692,6 @@ create_table_info_t::check_table_options()
} }
} }
/* If encryption is set up make sure that used key_id is found */
if (encrypt == FIL_ENCRYPTION_ON ||
(encrypt == FIL_ENCRYPTION_DEFAULT && srv_encrypt_tables)) {
if (!encryption_key_id_exists((unsigned int)options->encryption_key_id)) {
push_warning_printf(
m_thd, Sql_condition::WARN_LEVEL_WARN,
HA_WRONG_CREATE_OPTION,
"InnoDB: ENCRYPTION_KEY_ID %u not available",
(uint)options->encryption_key_id
);
return "ENCRYPTION_KEY_ID";
}
}
/* Ignore nondefault key_id if encryption is set off */
if (encrypt == FIL_ENCRYPTION_OFF &&
options->encryption_key_id != THDVAR(m_thd, default_encryption_key_id)) {
push_warning_printf(
m_thd, Sql_condition::WARN_LEVEL_WARN,
HA_WRONG_CREATE_OPTION,
"InnoDB: Ignored ENCRYPTION_KEY_ID %u when encryption is disabled",
(uint)options->encryption_key_id
);
options->encryption_key_id = FIL_DEFAULT_ENCRYPTION_KEY;
}
/* If default encryption is used and encryption is disabled, you may
not use nondefault encryption_key_id as it is not stored anywhere. */
if (encrypt == FIL_ENCRYPTION_DEFAULT
&& !srv_encrypt_tables
&& options->encryption_key_id != FIL_DEFAULT_ENCRYPTION_KEY) {
compile_time_assert(FIL_DEFAULT_ENCRYPTION_KEY == 1);
push_warning_printf(
m_thd, Sql_condition::WARN_LEVEL_WARN,
HA_WRONG_CREATE_OPTION,
"InnoDB: innodb_encrypt_tables=OFF only allows ENCRYPTION_KEY_ID=1"
);
return "ENCRYPTION_KEY_ID";
}
return NULL; return NULL;
} }

View File

@ -939,6 +939,17 @@ ha_innobase::check_if_supported_inplace_alter(
DBUG_RETURN(HA_ALTER_INPLACE_INSTANT); DBUG_RETURN(HA_ALTER_INPLACE_INSTANT);
} }
/* InnoDB cannot IGNORE when creating unique indexes. IGNORE
should silently delete some duplicate rows. Our inplace_alter
code will not delete anything from existing indexes. */
if (ha_alter_info->ignore
&& (ha_alter_info->handler_flags
& (ALTER_ADD_PK_INDEX | ALTER_ADD_UNIQUE_INDEX))) {
ha_alter_info->unsupported_reason = my_get_err_msg(
ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_IGNORE);
DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED);
}
/* DROP PRIMARY KEY is only allowed in combination with ADD /* DROP PRIMARY KEY is only allowed in combination with ADD
PRIMARY KEY. */ PRIMARY KEY. */
if ((ha_alter_info->handler_flags if ((ha_alter_info->handler_flags
@ -949,15 +960,16 @@ ha_innobase::check_if_supported_inplace_alter(
DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED); DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED);
} }
/* If a column change from NOT NULL to NULL, if (ha_alter_info->handler_flags & ALTER_COLUMN_NULLABLE) {
and there's a implict pk on this column. the /* If a NOT NULL attribute is going to be removed and
table should be rebuild. The change should a UNIQUE INDEX on the column had been promoted to an
only go through the "Copy" method. */ implicit PRIMARY KEY, the table should be rebuilt by
if ((ha_alter_info->handler_flags ALGORITHM=COPY. (Theoretically, we could support
& ALTER_COLUMN_NULLABLE)) { rebuilding by ALGORITHM=INPLACE if a PRIMARY KEY is
going to be added, either explicitly or by promoting
another UNIQUE KEY.) */
const uint my_primary_key = altered_table->s->primary_key; const uint my_primary_key = altered_table->s->primary_key;
/* See if MYSQL table has no pk but we do. */
if (UNIV_UNLIKELY(my_primary_key >= MAX_KEY) if (UNIV_UNLIKELY(my_primary_key >= MAX_KEY)
&& !dict_index_is_auto_gen_clust( && !dict_index_is_auto_gen_clust(
dict_table_get_first_index(m_prebuilt->table))) { dict_table_get_first_index(m_prebuilt->table))) {
@ -1234,8 +1246,15 @@ ha_innobase::check_if_supported_inplace_alter(
& ALTER_ADD_COLUMN)); & ALTER_ADD_COLUMN));
if (const Field* f = cf->field) { if (const Field* f = cf->field) {
/* This could be changing an existing column if (!f->real_maybe_null() || (*af)->real_maybe_null())
goto next_column;
/* We are changing an existing column
from NULL to NOT NULL. */ from NULL to NOT NULL. */
DBUG_ASSERT(ha_alter_info->handler_flags
& ALTER_COLUMN_NOT_NULLABLE);
/* Virtual columns are never NOT NULL. */
DBUG_ASSERT(f->stored_in_db());
switch ((*af)->type()) { switch ((*af)->type()) {
case MYSQL_TYPE_TIMESTAMP: case MYSQL_TYPE_TIMESTAMP:
case MYSQL_TYPE_TIMESTAMP2: case MYSQL_TYPE_TIMESTAMP2:
@ -1244,20 +1263,12 @@ ha_innobase::check_if_supported_inplace_alter(
replaced. Ensure that the DEFAULT replaced. Ensure that the DEFAULT
expression is not changing during expression is not changing during
ALTER TABLE. */ ALTER TABLE. */
if (!f->real_maybe_null()
|| (*af)->real_maybe_null()) {
/* The column was NOT NULL, or it
will allow NULL after ALTER TABLE. */
goto next_column;
}
if (!(*af)->default_value if (!(*af)->default_value
&& (*af)->is_real_null()) { && (*af)->is_real_null()) {
/* No DEFAULT value is /* No DEFAULT value is
specified. We can report specified. We can report
errors for any NULL values for errors for any NULL values for
the TIMESTAMP. */ the TIMESTAMP. */
goto next_column; goto next_column;
} }
break; break;
@ -1274,8 +1285,7 @@ ha_innobase::check_if_supported_inplace_alter(
goto next_column; goto next_column;
} }
ha_alter_info->unsupported_reason ha_alter_info->unsupported_reason = my_get_err_msg(
= my_get_err_msg(
ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_NOT_NULL); ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_NOT_NULL);
} else if (!is_non_const_value(*af)) { } else if (!is_non_const_value(*af)) {

View File

@ -362,9 +362,10 @@ IF("$ENV{EXTRA_LIGHT_ARGS}")
ENDIF() ENDIF()
FILE(REMOVE mysql_server.wixobj extra.wixobj) FILE(REMOVE mysql_server.wixobj extra.wixobj)
STRING(REPLACE " " ";" EXTRA_WIX_PREPROCESSOR_FLAGS_LIST ${EXTRA_WIX_PREPROCESSOR_FLAGS})
EXECUTE_PROCESS( EXECUTE_PROCESS(
COMMAND ${CANDLE_EXECUTABLE} COMMAND ${CANDLE_EXECUTABLE}
${EXTRA_WIX_PREPROCESSOR_FLAGS} ${EXTRA_WIX_PREPROCESSOR_FLAGS_LIST}
${CANDLE_ARCH} ${CANDLE_ARCH}
-ext WixUtilExtension -ext WixUtilExtension
-ext WixFirewallExtension -ext WixFirewallExtension
@ -374,7 +375,7 @@ EXECUTE_PROCESS(
EXECUTE_PROCESS( EXECUTE_PROCESS(
COMMAND ${CANDLE_EXECUTABLE} ${CANDLE_ARCH} COMMAND ${CANDLE_EXECUTABLE} ${CANDLE_ARCH}
${EXTRA_WIX_PREPROCESSOR_FLAGS} ${EXTRA_WIX_PREPROCESSOR_FLAGS_LIST}
-ext WixUtilExtension -ext WixUtilExtension
-ext WixFirewallExtension -ext WixFirewallExtension
${CMAKE_CURRENT_BINARY_DIR}/extra.wxs ${CMAKE_CURRENT_BINARY_DIR}/extra.wxs