summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmake/plugin.cmake9
-rw-r--r--mysql-test/r/view.result37
-rw-r--r--mysql-test/suite/innodb/r/innodb-alter-debug.result61
-rw-r--r--mysql-test/suite/innodb/r/innodb-alter-nullable.result59
-rw-r--r--mysql-test/suite/innodb/r/innodb_defragment.result1
-rw-r--r--mysql-test/suite/innodb/r/innodb_defragment_small.result29
-rw-r--r--mysql-test/suite/innodb/t/innodb-alter-debug.test79
-rw-r--r--mysql-test/suite/innodb/t/innodb-alter-nullable.test76
-rw-r--r--mysql-test/suite/innodb/t/innodb_defragment-master.opt2
-rw-r--r--mysql-test/suite/innodb/t/innodb_defragment.opt1
-rw-r--r--mysql-test/suite/innodb/t/innodb_defragment.test19
-rw-r--r--mysql-test/suite/innodb/t/innodb_defragment_small.test32
-rw-r--r--mysql-test/t/view.test38
-rw-r--r--sql/CMakeLists.txt83
-rw-r--r--sql/item.cc12
-rw-r--r--sql/wsrep_binlog.cc6
-rw-r--r--storage/innobase/fil/fil0crypt.cc2
-rw-r--r--storage/innobase/handler/ha_innodb.cc19
-rw-r--r--storage/innobase/handler/handler0alter.cc1
-rw-r--r--storage/xtradb/btr/btr0cur.cc10
-rw-r--r--storage/xtradb/fil/fil0crypt.cc2
-rw-r--r--storage/xtradb/handler/ha_innodb.cc11
-rw-r--r--storage/xtradb/handler/handler0alter.cc1
-rw-r--r--win/create_def_file.js46
24 files changed, 566 insertions, 70 deletions
diff --git a/cmake/plugin.cmake b/cmake/plugin.cmake
index edbd2065f82..16da44311b6 100644
--- a/cmake/plugin.cmake
+++ b/cmake/plugin.cmake
@@ -201,9 +201,16 @@ MACRO(MYSQL_ADD_PLUGIN)
# executable to the linker command line (it would result into link error).
# Thus we skip TARGET_LINK_LIBRARIES on Linux, as it would only generate
# an additional dependency.
- IF(NOT CMAKE_SYSTEM_NAME STREQUAL "Linux" AND NOT ARG_CLIENT)
+ IF(MSVC)
+ ADD_DEPENDENCIES(${target} gen_mysqld_lib)
+ TARGET_LINK_LIBRARIES(${target} mysqld_import_lib)
+ ELSEIF(NOT CMAKE_SYSTEM_NAME STREQUAL "Linux")
TARGET_LINK_LIBRARIES (${target} mysqld)
ENDIF()
+
+ IF(ARG_LINK_LIBRARIES)
+ TARGET_LINK_LIBRARIES (${target} ${ARG_LINK_LIBRARIES})
+ ENDIF()
ADD_DEPENDENCIES(${target} GenError ${ARG_DEPENDENCIES})
SET_TARGET_PROPERTIES(${target} PROPERTIES
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result
index b3f1468a2aa..4119c11c67b 100644
--- a/mysql-test/r/view.result
+++ b/mysql-test/r/view.result
@@ -5954,6 +5954,43 @@ a
2
DROP VIEW v1;
DROP TABLE t1;
+#
+# MDEV-8642: WHERE Clause not applied on View - Empty result set returned
+#
+CREATE TABLE `t1` (
+`id` int(20) NOT NULL AUTO_INCREMENT,
+`use_case` int(11) DEFAULT NULL,
+`current_deadline` date DEFAULT NULL,
+`ts_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+PRIMARY KEY (`id`),
+UNIQUE KEY `id_UNIQUE` (`id`)
+) ENGINE=MyISAM AUTO_INCREMENT=13976 DEFAULT CHARSET=latin1;
+INSERT INTO `t1` VALUES (1,10,'2015-12-18','2015-08-18 08:38:16');
+INSERT INTO `t1` VALUES (2,20,'2015-10-18','2015-08-18 08:43:30');
+CREATE VIEW v1 AS SELECT
+use_case as use_case_id,
+(
+SELECT
+deadline_sub.current_deadline
+FROM
+t1 deadline_sub
+WHERE
+deadline_sub.use_case = use_case_id
+AND ts_create = (SELECT
+MIN(ts_create)
+FROM
+t1 startdate_sub
+WHERE
+startdate_sub.use_case = use_case_id
+)
+) AS InitialDeadline
+FROM
+t1;
+SELECT * FROM v1 where use_case_id = 10;
+use_case_id InitialDeadline
+10 2015-12-18
+drop view v1;
+drop table t1;
# -----------------------------------------------------------------
# -- End of 10.0 tests.
# -----------------------------------------------------------------
diff --git a/mysql-test/suite/innodb/r/innodb-alter-debug.result b/mysql-test/suite/innodb/r/innodb-alter-debug.result
new file mode 100644
index 00000000000..d580a641d81
--- /dev/null
+++ b/mysql-test/suite/innodb/r/innodb-alter-debug.result
@@ -0,0 +1,61 @@
+SET NAMES utf8;
+CREATE TABLE ① (
+c1 INT PRIMARY KEY, c2 INT DEFAULT 1, ct TEXT, INDEX(c2))
+ENGINE = InnoDB;
+CREATE TABLE t1ć (c1 INT PRIMARY KEY, c2 INT, INDEX(c2),
+CONSTRAINT t1c2 FOREIGN KEY (c2) REFERENCES ①(c2))
+ENGINE=InnoDB;
+INSERT INTO ① SET c1 = 1;
+SET @saved_debug_dbug = @@SESSION.debug_dbug;
+SET DEBUG_DBUG = '+d,ib_drop_foreign_error';
+ALTER TABLE t1ć DROP FOREIGN KEY t1c2, RENAME TO ②;
+ERROR HY000: The table 't1ć' is full
+SET DEBUG_DBUG = @saved_debug_dbug;
+SET DEBUG_DBUG = '+d,ib_rename_column_error';
+ALTER TABLE ① CHANGE c2 š INT;
+ERROR HY000: The table '①' is full
+SET DEBUG_DBUG = @saved_debug_dbug;
+SHOW CREATE TABLE t1ć;
+Table Create Table
+t1ć CREATE TABLE `t1ć` (
+ `c1` int(11) NOT NULL,
+ `c2` int(11) DEFAULT NULL,
+ PRIMARY KEY (`c1`),
+ KEY `c2` (`c2`),
+ CONSTRAINT `t1c2` FOREIGN KEY (`c2`) REFERENCES `①` (`c2`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+DROP TABLE t1ć, ①;
+#
+# Bug #21364096 THE BOGUS DUPLICATE KEY ERROR IN ONLINE DDL
+# WITH INCORRECT KEY NAME
+create table t1 (id int auto_increment primary key, a int, unique key uk(a))
+engine = innodb;
+insert into t1 select 1, 1;
+insert into t1 select 2, 2;
+SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL s1 WAIT_FOR s2';
+alter table t1 add b int, ALGORITHM=inplace;
+/* connection con1 */
+connect con1,localhost,root,,;
+SET DEBUG_SYNC = 'now WAIT_FOR s1';
+insert into t1 select NULL, 1;
+ERROR 23000: Duplicate entry '1' for key 'uk'
+SET DEBUG_SYNC = 'now SIGNAL s2';
+/* connection default */
+connection default;
+/* reap */ alter table t1 add b int, ALGORITHM=inplace;
+ERROR 23000: Duplicate entry '1' for key 'uk'
+SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL s1 WAIT_FOR s2';
+alter table t1 add b int, ALGORITHM=inplace;;
+/* connection con1 */
+connection con1;
+set DEBUG_SYNC = 'now WAIT_FOR s1';
+update t1 set a=1 where id=2;
+ERROR 23000: Duplicate entry '1' for key 'uk'
+SET DEBUG_SYNC = 'now SIGNAL s2';
+disconnect con1;
+/* connection default */
+connection default;
+/* reap */ alter table t1 add b int, ALGORITHM=inplace;
+ERROR 23000: Duplicate entry '1' for key 'uk'
+SET DEBUG_SYNC = 'RESET';
+drop table t1;
diff --git a/mysql-test/suite/innodb/r/innodb-alter-nullable.result b/mysql-test/suite/innodb/r/innodb-alter-nullable.result
new file mode 100644
index 00000000000..7048f49f4a2
--- /dev/null
+++ b/mysql-test/suite/innodb/r/innodb-alter-nullable.result
@@ -0,0 +1,59 @@
+CREATE TABLE t (c1 INT PRIMARY KEY, c2 INT NOT NULL, c3 INT) ENGINE=InnoDB;
+INSERT INTO t VALUES (1,2,3),(4,5,6),(7,8,9);
+ALTER TABLE t CHANGE c1 c1 INT NULL FIRST, ALGORITHM=INPLACE;
+affected rows: 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;
+affected rows: 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;
+ERROR 42S22: Unknown column 'c2' in 't'
+ALTER TABLE t MODIFY c2 INT, MODIFY c2 INT NOT NULL;
+ERROR 42S22: Unknown column 'c2' in 't'
+ALTER TABLE t MODIFY c2 INT UNSIGNED, MODIFY c2 INT;
+ERROR 42S22: Unknown column 'c2' in 't'
+ALTER TABLE t MODIFY c2 CHAR(1) NOT NULL, MODIFY c2 INT NOT NULL;
+ERROR 42S22: Unknown column 'c2' in 't'
+ALTER TABLE t CHANGE c2 c2 INT NOT NULL;
+affected rows: 0
+info: Records: 0 Duplicates: 0 Warnings: 0
+ALTER TABLE t MODIFY c2 INT NOT NULL;
+affected rows: 0
+info: Records: 0 Duplicates: 0 Warnings: 0
+connect con1,localhost,root,,;
+connection con1;
+SET SQL_MODE='STRICT_ALL_TABLES';
+UPDATE t SET c2=NULL;
+ERROR 23000: Column 'c2' cannot be null
+SELECT * FROM t;
+c1 c2 c3
+1 2 3
+4 5 6
+7 8 9
+connection default;
+ALTER TABLE t MODIFY c2 INT, ALGORITHM=INPLACE;
+connection con1;
+BEGIN;
+UPDATE t SET c2=NULL;
+SELECT * FROM t;
+c1 c2 c3
+1 NULL 3
+4 NULL 6
+7 NULL 9
+ROLLBACK;
+SELECT * FROM t;
+c1 c2 c3
+1 2 3
+4 5 6
+7 8 9
+disconnect con1;
+connection default;
+ALTER TABLE t MODIFY c2 INT NULL, ALGORITHM=INPLACE;
+SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES
+WHERE NAME='test/t';
+TABLE_ID NAME FLAG N_COLS SPACE FILE_FORMAT ROW_FORMAT ZIP_PAGE_SIZE SPACE_TYPE
+# test/t 33 6 # Barracuda Dynamic 0 Single
+DROP TABLE t;
diff --git a/mysql-test/suite/innodb/r/innodb_defragment.result b/mysql-test/suite/innodb/r/innodb_defragment.result
index c42cbd972f8..989d3ef3397 100644
--- a/mysql-test/suite/innodb/r/innodb_defragment.result
+++ b/mysql-test/suite/innodb/r/innodb_defragment.result
@@ -1,4 +1,3 @@
-DROP TABLE if exists t1;
set global innodb_defragment_stats_accuracy = 80;
CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b VARCHAR(256), KEY SECOND(a, b)) ENGINE=INNODB;
optimize table t1;
diff --git a/mysql-test/suite/innodb/r/innodb_defragment_small.result b/mysql-test/suite/innodb/r/innodb_defragment_small.result
new file mode 100644
index 00000000000..7471c84bb44
--- /dev/null
+++ b/mysql-test/suite/innodb/r/innodb_defragment_small.result
@@ -0,0 +1,29 @@
+SET @innodb_defragment_orig=@@GLOBAL.innodb_defragment;
+SET GLOBAL innodb_defragment = 1;
+CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(256), KEY(a, b)) ENGINE=INNODB;
+OPTIMIZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 optimize status OK
+INSERT INTO t1 VALUES (100000, REPEAT('A', 256));
+INSERT INTO t1 VALUES (200000, REPEAT('A', 256));
+INSERT INTO t1 VALUES (300000, REPEAT('A', 256));
+INSERT INTO t1 VALUES (400000, REPEAT('A', 256));
+OPTIMIZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 optimize status OK
+DROP TABLE t1;
+#
+# MDEV-12198 innodb_defragment=1 crashes server on
+# OPTIMIZE TABLE when FULLTEXT index exists
+#
+CREATE TABLE t1 (c TEXT, FULLTEXT KEY (c)) ENGINE=InnoDB;
+OPTIMIZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 optimize status OK
+DROP TABLE t1;
+CREATE TABLE t1 (c POINT PRIMARY KEY, SPATIAL INDEX(c)) ENGINE=InnoDB;
+OPTIMIZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 optimize status OK
+DROP TABLE t1;
+SET GLOBAL innodb_defragment = @innodb_defragment_orig;
diff --git a/mysql-test/suite/innodb/t/innodb-alter-debug.test b/mysql-test/suite/innodb/t/innodb-alter-debug.test
new file mode 100644
index 00000000000..70017ffba35
--- /dev/null
+++ b/mysql-test/suite/innodb/t/innodb-alter-debug.test
@@ -0,0 +1,79 @@
+--source include/have_innodb.inc
+--source include/have_debug.inc
+--source include/have_debug_sync.inc
+
+--source include/count_sessions.inc
+
+SET NAMES utf8;
+
+CREATE TABLE ① (
+ c1 INT PRIMARY KEY, c2 INT DEFAULT 1, ct TEXT, INDEX(c2))
+ENGINE = InnoDB;
+
+CREATE TABLE t1ć (c1 INT PRIMARY KEY, c2 INT, INDEX(c2),
+ CONSTRAINT t1c2 FOREIGN KEY (c2) REFERENCES ①(c2))
+ENGINE=InnoDB;
+
+INSERT INTO ① SET c1 = 1;
+
+SET @saved_debug_dbug = @@SESSION.debug_dbug;
+SET DEBUG_DBUG = '+d,ib_drop_foreign_error';
+--error ER_RECORD_FILE_FULL
+ALTER TABLE t1ć DROP FOREIGN KEY t1c2, RENAME TO ②;
+SET DEBUG_DBUG = @saved_debug_dbug;
+
+SET DEBUG_DBUG = '+d,ib_rename_column_error';
+--error ER_RECORD_FILE_FULL
+ALTER TABLE ① CHANGE c2 š INT;
+SET DEBUG_DBUG = @saved_debug_dbug;
+
+SHOW CREATE TABLE t1ć;
+
+DROP TABLE t1ć, ①;
+
+--echo #
+--echo # Bug #21364096 THE BOGUS DUPLICATE KEY ERROR IN ONLINE DDL
+--echo # WITH INCORRECT KEY NAME
+
+create table t1 (id int auto_increment primary key, a int, unique key uk(a))
+engine = innodb;
+insert into t1 select 1, 1;
+insert into t1 select 2, 2;
+SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL s1 WAIT_FOR s2';
+--send alter table t1 add b int, ALGORITHM=inplace
+
+--echo /* connection con1 */
+connect (con1,localhost,root,,);
+SET DEBUG_SYNC = 'now WAIT_FOR s1';
+--error ER_DUP_ENTRY
+insert into t1 select NULL, 1;
+SET DEBUG_SYNC = 'now SIGNAL s2';
+
+--echo /* connection default */
+connection default;
+--echo /* reap */ alter table t1 add b int, ALGORITHM=inplace;
+--error ER_DUP_ENTRY
+--reap
+
+SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL s1 WAIT_FOR s2';
+--send alter table t1 add b int, ALGORITHM=inplace;
+
+--echo /* connection con1 */
+connection con1;
+set DEBUG_SYNC = 'now WAIT_FOR s1';
+--error ER_DUP_ENTRY
+update t1 set a=1 where id=2;
+SET DEBUG_SYNC = 'now SIGNAL s2';
+disconnect con1;
+
+--echo /* connection default */
+connection default;
+--echo /* reap */ alter table t1 add b int, ALGORITHM=inplace;
+--error ER_DUP_ENTRY
+--reap
+SET DEBUG_SYNC = 'RESET';
+
+drop table t1;
+
+# Wait till all disconnects are completed
+--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/suite/innodb/t/innodb-alter-nullable.test b/mysql-test/suite/innodb/t/innodb-alter-nullable.test
new file mode 100644
index 00000000000..3f1e82b3183
--- /dev/null
+++ b/mysql-test/suite/innodb/t/innodb-alter-nullable.test
@@ -0,0 +1,76 @@
+--source include/have_innodb.inc
+
+# Save the initial number of concurrent sessions.
+--source include/count_sessions.inc
+
+CREATE TABLE t (c1 INT PRIMARY KEY, c2 INT NOT NULL, c3 INT) ENGINE=InnoDB;
+INSERT INTO t VALUES (1,2,3),(4,5,6),(7,8,9);
+
+--enable_info
+# This one will be a no-op.
+# MySQL should perhaps issue an error, because it refuses to modify
+# the PRIMARY KEY column c1 from NOT NULL to NULL.
+ALTER TABLE t CHANGE c1 c1 INT NULL FIRST, ALGORITHM=INPLACE;
+
+# 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;
+--disable_info
+set @@sql_mode = @old_sql_mode;
+--enable_info
+
+# Request some conflicting changes for a single column.
+--error ER_BAD_FIELD_ERROR
+ALTER TABLE t CHANGE c2 c2 INT, CHANGE c2 c2 INT NOT NULL;
+--error ER_BAD_FIELD_ERROR
+ALTER TABLE t MODIFY c2 INT, MODIFY c2 INT NOT NULL;
+--error ER_BAD_FIELD_ERROR
+ALTER TABLE t MODIFY c2 INT UNSIGNED, MODIFY c2 INT;
+--error ER_BAD_FIELD_ERROR
+ALTER TABLE t MODIFY c2 CHAR(1) NOT NULL, MODIFY c2 INT NOT NULL;
+
+# No-ops.
+ALTER TABLE t CHANGE c2 c2 INT NOT NULL;
+ALTER TABLE t MODIFY c2 INT NOT NULL;
+--disable_info
+
+connect (con1,localhost,root,,);
+connection con1;
+
+SET SQL_MODE='STRICT_ALL_TABLES';
+
+--error ER_BAD_NULL_ERROR
+UPDATE t SET c2=NULL;
+
+SELECT * FROM t;
+
+connection default;
+
+# This should change the column to NULL.
+ALTER TABLE t MODIFY c2 INT, ALGORITHM=INPLACE;
+
+connection con1;
+BEGIN;
+UPDATE t SET c2=NULL;
+SELECT * FROM t;
+ROLLBACK;
+SELECT * FROM t;
+
+disconnect con1;
+connection default;
+
+# This should be no-op.
+ALTER TABLE t MODIFY c2 INT NULL, ALGORITHM=INPLACE;
+
+--replace_column 1 # 5 #
+SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES
+WHERE NAME='test/t';
+
+DROP TABLE t;
+
+# 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.
+--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/suite/innodb/t/innodb_defragment-master.opt b/mysql-test/suite/innodb/t/innodb_defragment-master.opt
deleted file mode 100644
index 6fc7f343b24..00000000000
--- a/mysql-test/suite/innodb/t/innodb_defragment-master.opt
+++ /dev/null
@@ -1,2 +0,0 @@
---innodb_file_per_table
---innodb-defragment=1 \ No newline at end of file
diff --git a/mysql-test/suite/innodb/t/innodb_defragment.opt b/mysql-test/suite/innodb/t/innodb_defragment.opt
index 6426bac41a0..aea3d480c24 100644
--- a/mysql-test/suite/innodb/t/innodb_defragment.opt
+++ b/mysql-test/suite/innodb/t/innodb_defragment.opt
@@ -1,4 +1,5 @@
--loose-innodb-buffer-pool-stats
--loose-innodb-buffer-page
--loose-innodb-buffer-page-lru
+--innodb-file-per-table
--innodb-defragment=1 \ No newline at end of file
diff --git a/mysql-test/suite/innodb/t/innodb_defragment.test b/mysql-test/suite/innodb/t/innodb_defragment.test
index 22b72a4aa6b..d9f5f56316e 100644
--- a/mysql-test/suite/innodb/t/innodb_defragment.test
+++ b/mysql-test/suite/innodb/t/innodb_defragment.test
@@ -1,17 +1,7 @@
--source include/have_innodb.inc
--source include/big_test.inc
---source include/not_valgrind.inc
--source include/not_embedded.inc
---disable_warnings
-DROP TABLE if exists t1;
---enable_warnings
-
---disable_query_log
-let $innodb_defragment_n_pages_orig=`select @@innodb_defragment_n_pages`;
-let $innodb_defragment_stats_accuracy_orig=`select @@innodb_defragment_stats_accuracy`;
---enable_query_log
-
set global innodb_defragment_stats_accuracy = 80;
# Create table.
@@ -47,12 +37,14 @@ delimiter ;//
# Populate table.
let $i = $data_size;
--disable_query_log
+BEGIN;
while ($i)
{
eval
INSERT INTO t1 VALUES ($data_size + 1 - $i, REPEAT('A', 256));
dec $i;
}
+COMMIT;
--enable_query_log
select count(stat_value) from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_pages_freed');
@@ -161,10 +153,3 @@ select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like
DROP PROCEDURE defragment;
DROP TABLE t1;
-
-# reset system
---disable_query_log
-EVAL SET GLOBAL innodb_defragment_n_pages = $innodb_defragment_n_pages_orig;
-EVAL SET GLOBAL innodb_defragment_stats_accuracy = $innodb_defragment_stats_accuracy_orig;
---enable_query_log
-
diff --git a/mysql-test/suite/innodb/t/innodb_defragment_small.test b/mysql-test/suite/innodb/t/innodb_defragment_small.test
new file mode 100644
index 00000000000..8500c173af7
--- /dev/null
+++ b/mysql-test/suite/innodb/t/innodb_defragment_small.test
@@ -0,0 +1,32 @@
+--source include/have_innodb.inc
+
+SET @innodb_defragment_orig=@@GLOBAL.innodb_defragment;
+SET GLOBAL innodb_defragment = 1;
+
+# Small tests copied from innodb.innodb_defragment
+CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(256), KEY(a, b)) ENGINE=INNODB;
+OPTIMIZE TABLE t1;
+
+INSERT INTO t1 VALUES (100000, REPEAT('A', 256));
+INSERT INTO t1 VALUES (200000, REPEAT('A', 256));
+INSERT INTO t1 VALUES (300000, REPEAT('A', 256));
+INSERT INTO t1 VALUES (400000, REPEAT('A', 256));
+
+OPTIMIZE TABLE t1;
+DROP TABLE t1;
+
+--echo #
+--echo # MDEV-12198 innodb_defragment=1 crashes server on
+--echo # OPTIMIZE TABLE when FULLTEXT index exists
+--echo #
+
+CREATE TABLE t1 (c TEXT, FULLTEXT KEY (c)) ENGINE=InnoDB;
+
+OPTIMIZE TABLE t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (c POINT PRIMARY KEY, SPATIAL INDEX(c)) ENGINE=InnoDB;
+OPTIMIZE TABLE t1;
+DROP TABLE t1;
+
+SET GLOBAL innodb_defragment = @innodb_defragment_orig;
diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test
index df5c7d3495d..cb658b5146f 100644
--- a/mysql-test/t/view.test
+++ b/mysql-test/t/view.test
@@ -5779,6 +5779,44 @@ DROP VIEW v1;
DROP TABLE t1;
+--echo #
+--echo # MDEV-8642: WHERE Clause not applied on View - Empty result set returned
+--echo #
+
+CREATE TABLE `t1` (
+ `id` int(20) NOT NULL AUTO_INCREMENT,
+ `use_case` int(11) DEFAULT NULL,
+ `current_deadline` date DEFAULT NULL,
+ `ts_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `id_UNIQUE` (`id`)
+) ENGINE=MyISAM AUTO_INCREMENT=13976 DEFAULT CHARSET=latin1;
+INSERT INTO `t1` VALUES (1,10,'2015-12-18','2015-08-18 08:38:16');
+INSERT INTO `t1` VALUES (2,20,'2015-10-18','2015-08-18 08:43:30');
+CREATE VIEW v1 AS SELECT
+ use_case as use_case_id,
+ (
+ SELECT
+ deadline_sub.current_deadline
+ FROM
+ t1 deadline_sub
+ WHERE
+ deadline_sub.use_case = use_case_id
+ AND ts_create = (SELECT
+ MIN(ts_create)
+ FROM
+ t1 startdate_sub
+ WHERE
+ startdate_sub.use_case = use_case_id
+ )
+ ) AS InitialDeadline
+FROM
+ t1;
+
+SELECT * FROM v1 where use_case_id = 10;
+
+drop view v1;
+drop table t1;
--echo # -----------------------------------------------------------------
--echo # -- End of 10.0 tests.
diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt
index fc41a31c3c4..f46d8e4ee83 100644
--- a/sql/CMakeLists.txt
+++ b/sql/CMakeLists.txt
@@ -68,7 +68,6 @@ ENDIF()
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lex_token.h
COMMAND gen_lex_token > lex_token.h
- DEPENDS gen_lex_token
)
ADD_DEFINITIONS(-DMYSQL_SERVER -DHAVE_EVENT_SCHEDULER)
@@ -183,6 +182,63 @@ ELSE()
SET(MYSQLD_SOURCE main.cc ${DTRACE_PROBES_ALL})
ENDIF()
+
+IF(MSVC AND NOT WITHOUT_DYNAMIC_PLUGINS)
+
+ # mysqld.exe must to export symbols from some specific libs.
+ # These symbols are used by dynamic plugins, that "link" to mysqld.
+ #
+ # To do that, we
+ #
+ # 1. Generate mysqld_lib.def text file with all symbols from static
+ # libraries mysys, dbug, strings, sql.
+ # 2. Then we call
+ # lib.exe /DEF:mysqld_lib.def ...
+ # to create import library mysqld_lib.lib and export library mysqld_lib.exp
+ # 3. mysqld.exe links with mysqld_lib.exp (exporting symbols)
+ # 4. plugins link with mysqld_lib.lib (importing symbols)
+ #
+ # We do not not regenerate .def, .lib and .exp
+ # without necessity.E.g source modifications, that do not
+ # change list of exported symbols, will not result in a relink for plugins.
+
+ SET(MYSQLD_DEF ${CMAKE_CURRENT_BINARY_DIR}/mysqld_lib.def)
+ SET(MYSQLD_EXP ${CMAKE_CURRENT_BINARY_DIR}/mysqld_lib.exp)
+ SET(MYSQLD_LIB ${CMAKE_CURRENT_BINARY_DIR}/mysqld_lib.lib)
+ SET(MYSQLD_CORELIBS sql mysys mysys_ssl dbug strings)
+ FOREACH (CORELIB ${MYSQLD_CORELIBS})
+ GET_TARGET_PROPERTY(LOC ${CORELIB} LOCATION)
+ FILE(TO_NATIVE_PATH ${LOC} LOC)
+ SET (LIB_LOCATIONS ${LIB_LOCATIONS} ${LOC})
+ ENDFOREACH (CORELIB)
+
+ SET(_PLATFORM x86)
+ IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ SET(_PLATFORM x64)
+ ENDIF()
+
+ ADD_CUSTOM_COMMAND(
+ OUTPUT ${MYSQLD_DEF}
+ COMMAND cscript ARGS //nologo ${PROJECT_SOURCE_DIR}/win/create_def_file.js
+ ${_PLATFORM} /forLib ${LIB_LOCATIONS} > mysqld_lib.def.tmp
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different mysqld_lib.def.tmp mysqld_lib.def
+ COMMAND ${CMAKE_COMMAND} -E remove mysqld_lib.def.tmp
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ DEPENDS ${MYSQLD_CORELIBS}
+ )
+
+ ADD_CUSTOM_COMMAND(
+ OUTPUT ${MYSQLD_LIB}
+ COMMAND lib
+ ARGS /NAME:mysqld.exe "/DEF:${MYSQLD_DEF}" "/MACHINE:${_PLATFORM}"
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ DEPENDS ${MYSQLD_DEF}
+ )
+ ADD_CUSTOM_TARGET(gen_mysqld_lib DEPENDS ${MYSQLD_LIB})
+ ADD_LIBRARY(mysqld_import_lib UNKNOWN IMPORTED GLOBAL)
+ SET_TARGET_PROPERTIES(mysqld_import_lib PROPERTIES IMPORTED_LOCATION ${MYSQLD_LIB})
+ENDIF()
+
MYSQL_ADD_EXECUTABLE(mysqld ${MYSQLD_SOURCE} DESTINATION ${INSTALL_SBINDIR} COMPONENT Server)
IF(APPLE)
@@ -203,25 +259,9 @@ IF(NOT WITHOUT_DYNAMIC_PLUGINS)
SET_TARGET_PROPERTIES(mysqld PROPERTIES LINK_FLAGS "${mysqld_link_flags} -Wl,--export-all-symbols")
ENDIF()
IF(MSVC)
- # Set module definition file. Also use non-incremental linker,
- # incremental appears to crash from time to time,if used with /DEF option
- SET_TARGET_PROPERTIES(mysqld PROPERTIES LINK_FLAGS "${mysqld_link_flags} /DEF:mysqld.def /INCREMENTAL:NO")
-
- FOREACH (CORELIB sql mysys mysys_ssl dbug strings)
- GET_TARGET_PROPERTY(LOC ${CORELIB} LOCATION)
- FILE(TO_NATIVE_PATH ${LOC} LOC)
- SET (LIB_LOCATIONS ${LIB_LOCATIONS} ${LOC})
- ENDFOREACH (CORELIB ${MYSQLD_CORE_LIBS})
- SET(_PLATFORM x86)
- IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
- SET(_PLATFORM x64)
- ENDIF()
- ADD_CUSTOM_COMMAND(TARGET mysqld PRE_LINK
- COMMAND echo ${_PLATFORM} && cscript ARGS //nologo ${PROJECT_SOURCE_DIR}/win/create_def_file.js
- ${_PLATFORM} ${LIB_LOCATIONS} > mysqld.def
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
- ADD_DEPENDENCIES(sql GenError)
- ENDIF(MSVC)
+ SET_TARGET_PROPERTIES(mysqld PROPERTIES LINK_FLAGS "${mysqld_link_flags} \"${MYSQLD_EXP}\"")
+ ADD_DEPENDENCIES(mysqld gen_mysqld_lib)
+ ENDIF()
ENDIF(NOT WITHOUT_DYNAMIC_PLUGINS)
SET_TARGET_PROPERTIES(mysqld PROPERTIES ENABLE_EXPORTS TRUE)
@@ -287,7 +327,6 @@ ENDIF()
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lex_hash.h
COMMAND gen_lex_hash > lex_hash.h
- DEPENDS gen_lex_hash
)
MYSQL_ADD_EXECUTABLE(mysql_tzinfo_to_sql tztime.cc COMPONENT Server)
@@ -405,7 +444,7 @@ IF(WIN32)
${CMAKE_CURRENT_BINARY_DIR}/my_bootstrap.sql
mysql_bootstrap_sql.c
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
- DEPENDS comp_sql ${my_bootstrap_sql}
+ DEPENDS ${my_bootstrap_sql}
)
MYSQL_ADD_EXECUTABLE(mysql_install_db
diff --git a/sql/item.cc b/sql/item.cc
index 2ff9d4e4a44..08316d95276 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -7583,18 +7583,6 @@ bool Item_ref::fix_fields(THD *thd, Item **reference)
last_checked_context->select_lex->nest_level);
}
}
- else if (ref_type() != VIEW_REF)
- {
- /*
- It could be that we're referring to something that's in ancestor selects.
- We must make an appropriate mark_as_dependent() call for each such
- outside reference.
- */
- Dependency_marker dep_marker;
- dep_marker.current_select= current_sel;
- dep_marker.thd= thd;
- (*ref)->walk(&Item::enumerate_field_refs_processor, FALSE, &dep_marker);
- }
DBUG_ASSERT(*ref);
/*
diff --git a/sql/wsrep_binlog.cc b/sql/wsrep_binlog.cc
index 08b7e3f1e3d..d538383ebc4 100644
--- a/sql/wsrep_binlog.cc
+++ b/sql/wsrep_binlog.cc
@@ -329,9 +329,13 @@ void wsrep_dump_rbr_buf(THD *thd, const void* rbr_buf, size_t buf_len)
}
FILE *of= fopen(filename, "wb");
+
if (of)
{
- fwrite (rbr_buf, buf_len, 1, of);
+ if (fwrite(rbr_buf, buf_len, 1, of) == 0)
+ WSREP_ERROR("Failed to write buffer of length %llu to '%s'",
+ (unsigned long long)buf_len, filename);
+
fclose(of);
}
else
diff --git a/storage/innobase/fil/fil0crypt.cc b/storage/innobase/fil/fil0crypt.cc
index a61d7439e2c..db7efe89d37 100644
--- a/storage/innobase/fil/fil0crypt.cc
+++ b/storage/innobase/fil/fil0crypt.cc
@@ -1767,7 +1767,7 @@ fil_crypt_rotate_page(
return;
}
- if (space == TRX_SYS_SPACE && offset == TRX_SYS_PAGE_NO) {
+ if (space_id == TRX_SYS_SPACE && offset == TRX_SYS_PAGE_NO) {
/* don't encrypt this as it contains address to dblwr buffer */
return;
}
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 6aacdd48ad8..6f219bb5d20 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -15267,6 +15267,25 @@ ha_innobase::defragment_table(
for (index = dict_table_get_first_index(table); index;
index = dict_table_get_next_index(index)) {
+ if (dict_index_is_corrupted(index)) {
+ continue;
+ }
+
+ if (dict_index_is_spatial(index)) {
+ /* Do not try to defragment spatial indexes,
+ because doing it properly would require
+ appropriate logic around the SSN (split
+ sequence number). */
+ continue;
+ }
+
+ if (index->page == FIL_NULL) {
+ /* Do not defragment auxiliary tables related
+ to FULLTEXT INDEX. */
+ ut_ad(index->type & DICT_FTS);
+ continue;
+ }
+
if (one_index && strcasecmp(index_name, index->name) != 0) {
continue;
}
diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
index 27fa7e84aa3..a5b919b424d 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -300,7 +300,6 @@ my_error_innodb(
break;
case DB_OUT_OF_FILE_SPACE:
my_error(ER_RECORD_FILE_FULL, MYF(0), table);
- ut_error;
break;
case DB_TEMP_FILE_WRITE_FAIL:
my_error(ER_TEMP_FILE_WRITE_FAILURE, MYF(0));
diff --git a/storage/xtradb/btr/btr0cur.cc b/storage/xtradb/btr/btr0cur.cc
index 454b085862c..78683f35028 100644
--- a/storage/xtradb/btr/btr0cur.cc
+++ b/storage/xtradb/btr/btr0cur.cc
@@ -3948,7 +3948,7 @@ static const unsigned rows_in_range_max_retries = 4;
/** We pretend that a range has that many records if the tree keeps changing
for rows_in_range_max_retries retries while we try to estimate the records
in a given range. */
-static const int64_t rows_in_range_arbitrary_ret_val = 10;
+static const ib_int64_t rows_in_range_arbitrary_ret_val = 10;
/** Estimates the number of rows in a given index range.
@param[in] index index
@@ -3966,7 +3966,7 @@ rows_in_range_arbitrary_ret_val as a result (if
nth_attempt >= rows_in_range_max_retries and the tree is modified between
the two dives). */
static
-int64_t
+ib_int64_t
btr_estimate_n_rows_in_range_low(
dict_index_t* index,
const dtuple_t* tuple1,
@@ -4102,7 +4102,7 @@ btr_estimate_n_rows_in_range_low(
return(rows_in_range_arbitrary_ret_val);
}
- const int64_t ret =
+ const ib_int64_t ret =
btr_estimate_n_rows_in_range_low(
index, tuple1, mode1,
tuple2, mode2, trx,
@@ -4168,7 +4168,7 @@ btr_estimate_n_rows_in_range_low(
@param[in] mode2 search mode for range end
@param[in] trx trx
@return estimated number of rows */
-int64_t
+ib_int64_t
btr_estimate_n_rows_in_range(
dict_index_t* index,
const dtuple_t* tuple1,
@@ -4177,7 +4177,7 @@ btr_estimate_n_rows_in_range(
ulint mode2,
trx_t* trx)
{
- const int64_t ret = btr_estimate_n_rows_in_range_low(
+ const ib_int64_t ret = btr_estimate_n_rows_in_range_low(
index, tuple1, mode1, tuple2, mode2, trx,
1 /* first attempt */);
diff --git a/storage/xtradb/fil/fil0crypt.cc b/storage/xtradb/fil/fil0crypt.cc
index 60ab067d105..aa95de7efea 100644
--- a/storage/xtradb/fil/fil0crypt.cc
+++ b/storage/xtradb/fil/fil0crypt.cc
@@ -1951,7 +1951,7 @@ fil_crypt_rotate_page(
return;
}
- if (space == TRX_SYS_SPACE && offset == TRX_SYS_PAGE_NO) {
+ if (space_id == TRX_SYS_SPACE && offset == TRX_SYS_PAGE_NO) {
/* don't encrypt this as it contains address to dblwr buffer */
return;
}
diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc
index 742c03b5404..11779a66e7c 100644
--- a/storage/xtradb/handler/ha_innodb.cc
+++ b/storage/xtradb/handler/ha_innodb.cc
@@ -13277,6 +13277,17 @@ ha_innobase::defragment_table(
for (index = dict_table_get_first_index(table); index;
index = dict_table_get_next_index(index)) {
+ if (dict_index_is_corrupted(index)) {
+ continue;
+ }
+
+ if (index->page == FIL_NULL) {
+ /* Do not defragment auxiliary tables related
+ to FULLTEXT INDEX. */
+ ut_ad(index->type & DICT_FTS);
+ continue;
+ }
+
if (one_index && strcasecmp(index_name, index->name) != 0) {
continue;
}
diff --git a/storage/xtradb/handler/handler0alter.cc b/storage/xtradb/handler/handler0alter.cc
index 8aaf5cd83bc..a521db3ce25 100644
--- a/storage/xtradb/handler/handler0alter.cc
+++ b/storage/xtradb/handler/handler0alter.cc
@@ -134,7 +134,6 @@ my_error_innodb(
break;
case DB_OUT_OF_FILE_SPACE:
my_error(ER_RECORD_FILE_FULL, MYF(0), table);
- ut_error;
break;
case DB_TEMP_FILE_WRITE_FAILURE:
my_error(ER_GET_ERRMSG, MYF(0),
diff --git a/win/create_def_file.js b/win/create_def_file.js
index 5fb28ef0bee..25bbbb4eb3d 100644
--- a/win/create_def_file.js
+++ b/win/create_def_file.js
@@ -54,6 +54,22 @@ var is64 = args.Item(0).toLowerCase() == "x64";
var shell = new ActiveXObject("WScript.Shell");
var fso = new ActiveXObject("Scripting.FileSystemObject");
+/*
+ If .def file is used with together with lib.exe
+ the name mangling for stdcall is slightly different.
+
+ Undescore prefix for stdcall function name must be removed for
+ lib.exe but not link.exe (see ScrubSymbol())
+
+ This difference is not documented anywhere and could
+ be a bug in compiler tools.
+
+ We use a parameter /forLib, if the resulting .def file is used
+ with lib.exe .
+*/
+var forLib = false;
+
+
OutputSymbols(CollectSymbols());
@@ -62,8 +78,8 @@ function OutputSymbols(symbols)
{
var out = WScript.StdOut;
out.WriteLine("EXPORTS");
- for (var sym in symbols)
- out.WriteLine(sym);
+ for (var i= 0; i < symbols.length; i++)
+ out.WriteLine(symbols[i]);
}
function echo(message)
@@ -72,9 +88,10 @@ function echo(message)
}
// Extract global symbol names and type from objects
+// Returns string array with symbol names
function CollectSymbols()
{
- var uniqueSymbols = new Array();
+ var uniqueSymbols = new Object();
try
{
@@ -146,7 +163,19 @@ function CollectSymbols()
uniqueSymbols[symbol] = 1;
}
fso.DeleteFile(rspfilename);
- return uniqueSymbols;
+ // Sort symbols names
+ var keys=[];
+ var sorted = {};
+ for (key in uniqueSymbols)
+ {
+ if (uniqueSymbols.hasOwnProperty(key))
+ {
+ keys.push(key);
+ }
+ }
+ keys.sort();
+
+ return keys;
}
// performs necessary cleanup on the symbol name
@@ -156,6 +185,9 @@ function ScrubSymbol(symbol)
if (symbol.charAt(0) != "_")
return symbol;
+ if (forLib)
+ return symbol.substring(1, symbol.length);
+
var atSign = symbol.indexOf("@");
if (atSign != -1)
{
@@ -189,7 +221,11 @@ function CreateResponseFile(filename)
var index = 1;
for (; index < args.length; index++)
{
- addToResponseFile(args.Item(index),responseFile);
+ var param = args.Item(index);
+ if (param == "/forLib")
+ forLib = true;
+ else
+ addToResponseFile(args.Item(index),responseFile);
}
responseFile.Close();
}