summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mysql/plugin_audit.h8
-rw-r--r--include/mysql/plugin_auth.h9
-rw-r--r--include/mysql/plugin_encryption.h8
-rw-r--r--include/mysql/plugin_ftparser.h8
-rw-r--r--include/mysql/plugin_password_validation.h9
-rw-r--r--mysql-test/r/derived_view.result6
-rw-r--r--mysql-test/r/subselect.result12
-rw-r--r--mysql-test/r/subselect_no_exists_to_in.result12
-rw-r--r--mysql-test/r/subselect_no_mat.result12
-rw-r--r--mysql-test/r/subselect_no_opts.result12
-rw-r--r--mysql-test/r/subselect_no_scache.result12
-rw-r--r--mysql-test/r/subselect_no_semijoin.result12
-rw-r--r--mysql-test/r/type_year.result1
-rw-r--r--mysql-test/t/subselect.test11
-rw-r--r--sql/encryption.cc16
-rw-r--r--sql/item_subselect.cc20
-rw-r--r--storage/innobase/dict/dict0load.cc19
-rw-r--r--storage/innobase/fil/fil0fil.cc57
-rw-r--r--storage/innobase/include/fsp0fsp.h12
-rw-r--r--storage/xtradb/dict/dict0load.cc19
-rw-r--r--storage/xtradb/fil/fil0fil.cc59
-rw-r--r--storage/xtradb/include/fsp0fsp.h12
22 files changed, 293 insertions, 53 deletions
diff --git a/include/mysql/plugin_audit.h b/include/mysql/plugin_audit.h
index 31589f071f0..cbdd6591b70 100644
--- a/include/mysql/plugin_audit.h
+++ b/include/mysql/plugin_audit.h
@@ -23,6 +23,10 @@
#include "plugin.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#define MYSQL_AUDIT_CLASS_MASK_SIZE 1
#define MYSQL_AUDIT_INTERFACE_VERSION 0x0302
@@ -175,4 +179,8 @@ struct st_mysql_audit
};
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/include/mysql/plugin_auth.h b/include/mysql/plugin_auth.h
index 156fb386aae..d776ed79a61 100644
--- a/include/mysql/plugin_auth.h
+++ b/include/mysql/plugin_auth.h
@@ -31,6 +31,10 @@
#include <mysql/plugin_auth_common.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* defines for MYSQL_SERVER_AUTH_INFO.password_used */
#define PASSWORD_USED_NO 0
@@ -122,5 +126,10 @@ struct st_mysql_auth
*/
int (*authenticate_user)(MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *info);
};
+
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/include/mysql/plugin_encryption.h b/include/mysql/plugin_encryption.h
index 3f35c2bcf80..5d08f6d3067 100644
--- a/include/mysql/plugin_encryption.h
+++ b/include/mysql/plugin_encryption.h
@@ -27,6 +27,10 @@
#include <mysql/plugin.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#define MariaDB_ENCRYPTION_INTERFACE_VERSION 0x0300
/**
@@ -114,5 +118,9 @@ struct st_mariadb_encryption
*/
unsigned int (*encrypted_length)(unsigned int slen, unsigned int key_id, unsigned int key_version);
};
+
+#ifdef __cplusplus
+}
+#endif
#endif
diff --git a/include/mysql/plugin_ftparser.h b/include/mysql/plugin_ftparser.h
index 324fce7ae86..4dace4ef3a6 100644
--- a/include/mysql/plugin_ftparser.h
+++ b/include/mysql/plugin_ftparser.h
@@ -18,6 +18,10 @@
#define _my_plugin_ftparser_h
#include "plugin.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/*************************************************************************
API for Full-text parser plugin. (MYSQL_FTPARSER_PLUGIN)
*/
@@ -208,5 +212,9 @@ struct st_mysql_ftparser
};
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/include/mysql/plugin_password_validation.h b/include/mysql/plugin_password_validation.h
index f3ca5c7e0cf..18c643e877b 100644
--- a/include/mysql/plugin_password_validation.h
+++ b/include/mysql/plugin_password_validation.h
@@ -26,6 +26,10 @@
#include <mysql/plugin.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#define MariaDB_PASSWORD_VALIDATION_INTERFACE_VERSION 0x0100
/**
@@ -41,5 +45,10 @@ struct st_mariadb_password_validation
int (*validate_password)(MYSQL_LEX_STRING *username,
MYSQL_LEX_STRING *password);
};
+
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/mysql-test/r/derived_view.result b/mysql-test/r/derived_view.result
index 639942f0da9..5783247b673 100644
--- a/mysql-test/r/derived_view.result
+++ b/mysql-test/r/derived_view.result
@@ -1101,7 +1101,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t3 system NULL NULL NULL NULL 1 100.00
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
-Note 1003 select 6 AS `a`,5 AS `b` from `test`.`t3` where (not(<expr_cache><6,5>(<in_optimizer>((6,5),<exists>(select 7,5 having (trigcond(((<cache>(6) = 7) or isnull(7))) and trigcond(((<cache>(5) = 5) or isnull(5))) and trigcond(<is_not_null_test>(7)) and trigcond(<is_not_null_test>(5))))))))
+Note 1003 select 6 AS `a`,5 AS `b` from `test`.`t3` where 1
SELECT t.a,t.b FROM t3 RIGHT JOIN ((SELECT * FROM t1) AS t, t2) ON t2.b != 0
WHERE (t.a,t.b) NOT IN (SELECT 7, 5);
a b
@@ -1115,7 +1115,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t3 system NULL NULL NULL NULL 1 100.00
3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
-Note 1003 select 6 AS `a`,5 AS `b` from `test`.`t3` where (not(<expr_cache><6,5>(<in_optimizer>((6,5),<exists>(select 7,5 having (trigcond(((<cache>(6) = 7) or isnull(7))) and trigcond(((<cache>(5) = 5) or isnull(5))) and trigcond(<is_not_null_test>(7)) and trigcond(<is_not_null_test>(5))))))))
+Note 1003 select 6 AS `a`,5 AS `b` from `test`.`t3` where 1
SELECT t.a,t.b FROM t3 RIGHT JOIN (v1 AS t, t2) ON t2.b != 0
WHERE (t.a,t.b) NOT IN (SELECT 7, 5);
a b
@@ -1129,7 +1129,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t3 system NULL NULL NULL NULL 1 100.00
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
-Note 1003 select 6 AS `a`,5 AS `b` from `test`.`t3` where (not(<expr_cache><6,5>(<in_optimizer>((6,5),<exists>(select 7,5 having (trigcond(((<cache>(6) = 7) or isnull(7))) and trigcond(((<cache>(5) = 5) or isnull(5))) and trigcond(<is_not_null_test>(7)) and trigcond(<is_not_null_test>(5))))))))
+Note 1003 select 6 AS `a`,5 AS `b` from `test`.`t3` where 1
DROP VIEW v1;
DROP TABLE t1,t2,t3;
#
diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result
index ac874f9943c..6a531997d79 100644
--- a/mysql-test/r/subselect.result
+++ b/mysql-test/r/subselect.result
@@ -7147,3 +7147,15 @@ sq
NULL
drop view v2;
drop table t1,t2;
+#
+# MDEV-9487: Server crashes in Time_and_counter_tracker::incr_loops
+# with UNION in ALL subquery
+#
+SET NAMES utf8;
+CREATE TABLE t1 (f VARCHAR(8)) ENGINE=MyISAM;
+INSERT INTO t1 VALUES ('foo');
+SELECT f FROM t1 WHERE f > ALL ( SELECT 'bar' UNION SELECT 'baz' );
+f
+foo
+drop table t1;
+SET NAMES default;
diff --git a/mysql-test/r/subselect_no_exists_to_in.result b/mysql-test/r/subselect_no_exists_to_in.result
index 6a5bec062c7..aa6843409c0 100644
--- a/mysql-test/r/subselect_no_exists_to_in.result
+++ b/mysql-test/r/subselect_no_exists_to_in.result
@@ -7147,6 +7147,18 @@ sq
NULL
drop view v2;
drop table t1,t2;
+#
+# MDEV-9487: Server crashes in Time_and_counter_tracker::incr_loops
+# with UNION in ALL subquery
+#
+SET NAMES utf8;
+CREATE TABLE t1 (f VARCHAR(8)) ENGINE=MyISAM;
+INSERT INTO t1 VALUES ('foo');
+SELECT f FROM t1 WHERE f > ALL ( SELECT 'bar' UNION SELECT 'baz' );
+f
+foo
+drop table t1;
+SET NAMES default;
set optimizer_switch=default;
select @@optimizer_switch like '%exists_to_in=off%';
@@optimizer_switch like '%exists_to_in=off%'
diff --git a/mysql-test/r/subselect_no_mat.result b/mysql-test/r/subselect_no_mat.result
index a574319b175..754aec1db20 100644
--- a/mysql-test/r/subselect_no_mat.result
+++ b/mysql-test/r/subselect_no_mat.result
@@ -7140,6 +7140,18 @@ sq
NULL
drop view v2;
drop table t1,t2;
+#
+# MDEV-9487: Server crashes in Time_and_counter_tracker::incr_loops
+# with UNION in ALL subquery
+#
+SET NAMES utf8;
+CREATE TABLE t1 (f VARCHAR(8)) ENGINE=MyISAM;
+INSERT INTO t1 VALUES ('foo');
+SELECT f FROM t1 WHERE f > ALL ( SELECT 'bar' UNION SELECT 'baz' );
+f
+foo
+drop table t1;
+SET NAMES default;
set optimizer_switch=default;
select @@optimizer_switch like '%materialization=on%';
@@optimizer_switch like '%materialization=on%'
diff --git a/mysql-test/r/subselect_no_opts.result b/mysql-test/r/subselect_no_opts.result
index 62eecd568f0..e05dd4d140d 100644
--- a/mysql-test/r/subselect_no_opts.result
+++ b/mysql-test/r/subselect_no_opts.result
@@ -7138,4 +7138,16 @@ sq
NULL
drop view v2;
drop table t1,t2;
+#
+# MDEV-9487: Server crashes in Time_and_counter_tracker::incr_loops
+# with UNION in ALL subquery
+#
+SET NAMES utf8;
+CREATE TABLE t1 (f VARCHAR(8)) ENGINE=MyISAM;
+INSERT INTO t1 VALUES ('foo');
+SELECT f FROM t1 WHERE f > ALL ( SELECT 'bar' UNION SELECT 'baz' );
+f
+foo
+drop table t1;
+SET NAMES default;
set @optimizer_switch_for_subselect_test=null;
diff --git a/mysql-test/r/subselect_no_scache.result b/mysql-test/r/subselect_no_scache.result
index 174c791489c..71ade62b423 100644
--- a/mysql-test/r/subselect_no_scache.result
+++ b/mysql-test/r/subselect_no_scache.result
@@ -7153,6 +7153,18 @@ sq
NULL
drop view v2;
drop table t1,t2;
+#
+# MDEV-9487: Server crashes in Time_and_counter_tracker::incr_loops
+# with UNION in ALL subquery
+#
+SET NAMES utf8;
+CREATE TABLE t1 (f VARCHAR(8)) ENGINE=MyISAM;
+INSERT INTO t1 VALUES ('foo');
+SELECT f FROM t1 WHERE f > ALL ( SELECT 'bar' UNION SELECT 'baz' );
+f
+foo
+drop table t1;
+SET NAMES default;
set optimizer_switch=default;
select @@optimizer_switch like '%subquery_cache=on%';
@@optimizer_switch like '%subquery_cache=on%'
diff --git a/mysql-test/r/subselect_no_semijoin.result b/mysql-test/r/subselect_no_semijoin.result
index e0d62ac6d14..43d191b1225 100644
--- a/mysql-test/r/subselect_no_semijoin.result
+++ b/mysql-test/r/subselect_no_semijoin.result
@@ -7138,5 +7138,17 @@ sq
NULL
drop view v2;
drop table t1,t2;
+#
+# MDEV-9487: Server crashes in Time_and_counter_tracker::incr_loops
+# with UNION in ALL subquery
+#
+SET NAMES utf8;
+CREATE TABLE t1 (f VARCHAR(8)) ENGINE=MyISAM;
+INSERT INTO t1 VALUES ('foo');
+SELECT f FROM t1 WHERE f > ALL ( SELECT 'bar' UNION SELECT 'baz' );
+f
+foo
+drop table t1;
+SET NAMES default;
set @optimizer_switch_for_subselect_test=null;
set @join_cache_level_for_subselect_test=NULL;
diff --git a/mysql-test/r/type_year.result b/mysql-test/r/type_year.result
index 842a16e3b4a..204cec2cc66 100644
--- a/mysql-test/r/type_year.result
+++ b/mysql-test/r/type_year.result
@@ -387,6 +387,7 @@ a
00
select a from t1 where a=(select 2000 from dual where 1);
a
+00
select a from t1 where a=y2k();
a
00
diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test
index 7a7c01e78bd..3599b523d91 100644
--- a/mysql-test/t/subselect.test
+++ b/mysql-test/t/subselect.test
@@ -6000,3 +6000,14 @@ SELECT ( SELECT MIN(v2.f2) FROM t1 ) AS sq FROM v2 GROUP BY sq;
drop view v2;
drop table t1,t2;
+
+--echo #
+--echo # MDEV-9487: Server crashes in Time_and_counter_tracker::incr_loops
+--echo # with UNION in ALL subquery
+--echo #
+SET NAMES utf8;
+CREATE TABLE t1 (f VARCHAR(8)) ENGINE=MyISAM;
+INSERT INTO t1 VALUES ('foo');
+SELECT f FROM t1 WHERE f > ALL ( SELECT 'bar' UNION SELECT 'baz' );
+drop table t1;
+SET NAMES default;
diff --git a/sql/encryption.cc b/sql/encryption.cc
index 209b092b0a4..52aaef896dd 100644
--- a/sql/encryption.cc
+++ b/sql/encryption.cc
@@ -23,6 +23,8 @@
static plugin_ref encryption_manager= 0;
struct encryption_service_st encryption_handler;
+extern "C" {
+
uint no_key(uint)
{
return ENCRYPTION_KEY_VERSION_INVALID;
@@ -41,6 +43,8 @@ static unsigned int get_length(unsigned int slen, unsigned int key_id,
return my_aes_get_size(MY_AES_CBC, slen);
}
+} /* extern "C" */
+
int initialize_encryption_plugin(st_plugin_int *plugin)
{
if (encryption_manager)
@@ -57,9 +61,15 @@ int initialize_encryption_plugin(st_plugin_int *plugin)
st_mariadb_encryption *handle=
(struct st_mariadb_encryption*) plugin->plugin->info;
- encryption_handler.encryption_ctx_size_func=
- handle->crypt_ctx_size ? handle->crypt_ctx_size :
- (uint (*)(unsigned int, unsigned int))my_aes_ctx_size;
+ /*
+ Copmiler on Spark doesn't like the '?' operator here as it
+ belives the (uint (*)...) implies the C++ call model.
+ */
+ if (handle->crypt_ctx_size)
+ encryption_handler.encryption_ctx_size_func= handle->crypt_ctx_size;
+ else
+ encryption_handler.encryption_ctx_size_func=
+ (uint (*)(unsigned int, unsigned int))my_aes_ctx_size;
encryption_handler.encryption_ctx_init_func=
handle->crypt_ctx_init ? handle->crypt_ctx_init : ctx_init;
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index dea58bf8e0c..1812110b1e6 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -561,22 +561,34 @@ bool Item_subselect::is_expensive()
for (SELECT_LEX *sl= unit->first_select(); sl; sl= sl->next_select())
{
JOIN *cur_join= sl->join;
+
+ /* not optimized subquery */
if (!cur_join)
- continue;
+ return true;
+
+ /* very simple subquery */
+ if (!cur_join->tables_list && !sl->first_inner_unit())
+ return false;
+
+ /*
+ If the subquery is not optimised or in the process of optimization
+ it supposed to be expensive
+ */
+ if (!cur_join->optimized)
+ return true;
/*
Subqueries whose result is known after optimization are not expensive.
Such subqueries have all tables optimized away, thus have no join plan.
*/
- if (cur_join->optimized &&
- (cur_join->zero_result_cause || !cur_join->tables_list))
+ if ((cur_join->zero_result_cause || !cur_join->tables_list))
return false;
/*
If a subquery is not optimized we cannot estimate its cost. A subquery is
considered optimized if it has a join plan.
*/
- if (!(cur_join->optimized && cur_join->join_tab))
+ if (!cur_join->join_tab)
return true;
if (sl->first_inner_unit())
diff --git a/storage/innobase/dict/dict0load.cc b/storage/innobase/dict/dict0load.cc
index d8bd0a66ade..ce5b10a623c 100644
--- a/storage/innobase/dict/dict0load.cc
+++ b/storage/innobase/dict/dict0load.cc
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2016, MariaDB Corporation.
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 the Free Software
@@ -2241,8 +2242,9 @@ dict_get_and_save_data_dir_path(
bool dict_mutex_own) /*!< in: true if dict_sys->mutex
is owned already */
{
- if (DICT_TF_HAS_DATA_DIR(table->flags)
- && (!table->data_dir_path)) {
+ bool is_temp = DICT_TF2_FLAG_IS_SET(table, DICT_TF2_TEMPORARY);
+
+ if (!is_temp && !table->data_dir_path && table->space) {
char* path = fil_space_get_first_path(table->space);
if (!dict_mutex_own) {
@@ -2254,6 +2256,7 @@ dict_get_and_save_data_dir_path(
}
if (path) {
+ table->flags |= (1 << DICT_TF_POS_DATA_DIR);
dict_save_data_dir_path(table, path);
mem_free(path);
}
@@ -2394,16 +2397,14 @@ err_exit:
}
/* Use the remote filepath if needed. */
- if (DICT_TF_HAS_DATA_DIR(table->flags)) {
- /* This needs to be added to the table
- from SYS_DATAFILES */
- dict_get_and_save_data_dir_path(table, true);
+ /* This needs to be added to the tablex1
+ from SYS_DATAFILES */
+ dict_get_and_save_data_dir_path(table, true);
- if (table->data_dir_path) {
- filepath = os_file_make_remote_pathname(
+ if (table->data_dir_path) {
+ filepath = os_file_make_remote_pathname(
table->data_dir_path,
table->name, "ibd");
- }
}
/* Try to open the tablespace. We set the
diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc
index bf7a53778f4..1bf15e7b639 100644
--- a/storage/innobase/fil/fil0fil.cc
+++ b/storage/innobase/fil/fil0fil.cc
@@ -717,16 +717,23 @@ fil_node_open_file(
}
if (UNIV_UNLIKELY(space->flags != flags)) {
- fprintf(stderr,
- "InnoDB: Error: table flags are 0x%lx"
- " in the data dictionary\n"
- "InnoDB: but the flags in file %s are 0x%lx!\n",
- space->flags, node->name, flags);
+ ulint sflags = (space->flags & ~FSP_FLAGS_MASK_DATA_DIR);
+ ulint fflags = (flags & ~FSP_FLAGS_MASK_DATA_DIR_ORACLE);
- ut_error;
- }
+ /* DATA_DIR option is on different place on MariaDB
+ compared to MySQL. If this is the difference. Fix
+ it. */
+
+ if (sflags == fflags) {
+ fprintf(stderr,
+ "InnoDB: Warning: Table flags 0x%lx"
+ " in the data dictionary but in file %s are 0x%lx!\n"
+ " Temporally corrected because DATA_DIR option to 0x%lx.\n",
+ space->flags, node->name, flags, space->flags);
+
+ flags = space->flags;
+ }
- if (UNIV_UNLIKELY(space->flags != flags)) {
if (!dict_tf_verify_flags(space->flags, flags)) {
fprintf(stderr,
"InnoDB: Error: table flags are 0x%lx"
@@ -3808,8 +3815,18 @@ fil_open_single_table_tablespace(
/* Validate this single-table-tablespace with SYS_TABLES,
but do not compare the DATA_DIR flag, in case the
tablespace was relocated. */
+
+ ulint newf = def.flags;
+ if (newf != mod_flags) {
+ if (FSP_FLAGS_HAS_DATA_DIR(newf)) {
+ newf = (newf & ~FSP_FLAGS_MASK_DATA_DIR);
+ } else if(FSP_FLAGS_HAS_DATA_DIR_ORACLE(newf)) {
+ newf = (newf & ~FSP_FLAGS_MASK_DATA_DIR_ORACLE);
+ }
+ }
+
if (def.valid && def.id == id
- && (def.flags & ~FSP_FLAGS_MASK_DATA_DIR) == mod_flags) {
+ && newf == mod_flags) {
valid_tablespaces_found++;
} else {
def.valid = false;
@@ -3837,8 +3854,17 @@ fil_open_single_table_tablespace(
/* Validate this single-table-tablespace with SYS_TABLES,
but do not compare the DATA_DIR flag, in case the
tablespace was relocated. */
+ ulint newf = remote.flags;
+ if (newf != mod_flags) {
+ if (FSP_FLAGS_HAS_DATA_DIR(newf)) {
+ newf = (newf & ~FSP_FLAGS_MASK_DATA_DIR);
+ } else if(FSP_FLAGS_HAS_DATA_DIR_ORACLE(newf)) {
+ newf = (newf & ~FSP_FLAGS_MASK_DATA_DIR_ORACLE);
+ }
+ }
+
if (remote.valid && remote.id == id
- && (remote.flags & ~FSP_FLAGS_MASK_DATA_DIR) == mod_flags) {
+ && newf == mod_flags) {
valid_tablespaces_found++;
} else {
remote.valid = false;
@@ -3867,8 +3893,17 @@ fil_open_single_table_tablespace(
/* Validate this single-table-tablespace with SYS_TABLES,
but do not compare the DATA_DIR flag, in case the
tablespace was relocated. */
+ ulint newf = dict.flags;
+ if (newf != mod_flags) {
+ if (FSP_FLAGS_HAS_DATA_DIR(newf)) {
+ newf = (newf & ~FSP_FLAGS_MASK_DATA_DIR);
+ } else if(FSP_FLAGS_HAS_DATA_DIR_ORACLE(newf)) {
+ newf = (newf & ~FSP_FLAGS_MASK_DATA_DIR_ORACLE);
+ }
+ }
+
if (dict.valid && dict.id == id
- && (dict.flags & ~FSP_FLAGS_MASK_DATA_DIR) == mod_flags) {
+ && newf == mod_flags) {
valid_tablespaces_found++;
} else {
dict.valid = false;
diff --git a/storage/innobase/include/fsp0fsp.h b/storage/innobase/include/fsp0fsp.h
index 2bac42eb081..296dfd8d841 100644
--- a/storage/innobase/include/fsp0fsp.h
+++ b/storage/innobase/include/fsp0fsp.h
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1995, 2012, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2013, SkySQL Ab. All Rights Reserved.
+Copyright (c) 2013, 2016, MariaDB Corporation. All Rights Reserved.
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 the Free Software
@@ -100,6 +100,9 @@ dictionary */
/** Zero relative shift position of the start of the UNUSED bits */
#define FSP_FLAGS_POS_DATA_DIR (FSP_FLAGS_POS_PAGE_SSIZE \
+ FSP_FLAGS_WIDTH_PAGE_SSIZE)
+#define FSP_FLAGS_POS_DATA_DIR_ORACLE (FSP_FLAGS_POS_ATOMIC_BLOBS \
+ + FSP_FLAGS_WIDTH_ATOMIC_BLOBS \
+ + FSP_FLAGS_WIDTH_PAGE_SSIZE)
/** Zero relative shift position of the start of the UNUSED bits */
#define FSP_FLAGS_POS_UNUSED (FSP_FLAGS_POS_DATA_DIR \
+ FSP_FLAGS_WIDTH_DATA_DIR)
@@ -124,6 +127,10 @@ dictionary */
#define FSP_FLAGS_MASK_DATA_DIR \
((~(~0 << FSP_FLAGS_WIDTH_DATA_DIR)) \
<< FSP_FLAGS_POS_DATA_DIR)
+/** Bit mask of the DATA_DIR field */
+#define FSP_FLAGS_MASK_DATA_DIR_ORACLE \
+ ((~(~0 << FSP_FLAGS_WIDTH_DATA_DIR)) \
+ << FSP_FLAGS_POS_DATA_DIR_ORACLE)
/** Bit mask of the PAGE_COMPRESSION field */
#define FSP_FLAGS_MASK_PAGE_COMPRESSION \
((~(~0 << FSP_FLAGS_WIDTH_PAGE_COMPRESSION)) \
@@ -156,6 +163,9 @@ dictionary */
#define FSP_FLAGS_HAS_DATA_DIR(flags) \
((flags & FSP_FLAGS_MASK_DATA_DIR) \
>> FSP_FLAGS_POS_DATA_DIR)
+#define FSP_FLAGS_HAS_DATA_DIR_ORACLE(flags) \
+ ((flags & FSP_FLAGS_MASK_DATA_DIR_ORACLE) \
+ >> FSP_FLAGS_POS_DATA_DIR_ORACLE)
/** Return the contents of the UNUSED bits */
#define FSP_FLAGS_GET_UNUSED(flags) \
(flags >> FSP_FLAGS_POS_UNUSED)
diff --git a/storage/xtradb/dict/dict0load.cc b/storage/xtradb/dict/dict0load.cc
index d6ed8acb39e..3d3a35e5c8e 100644
--- a/storage/xtradb/dict/dict0load.cc
+++ b/storage/xtradb/dict/dict0load.cc
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2016, MariaDB Corporation.
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 the Free Software
@@ -2242,8 +2243,9 @@ dict_get_and_save_data_dir_path(
bool dict_mutex_own) /*!< in: true if dict_sys->mutex
is owned already */
{
- if (DICT_TF_HAS_DATA_DIR(table->flags)
- && (!table->data_dir_path)) {
+ bool is_temp = DICT_TF2_FLAG_IS_SET(table, DICT_TF2_TEMPORARY);
+
+ if (!is_temp && !table->data_dir_path && table->space) {
char* path = fil_space_get_first_path(table->space);
if (!dict_mutex_own) {
@@ -2255,6 +2257,7 @@ dict_get_and_save_data_dir_path(
}
if (path) {
+ table->flags |= (1 << DICT_TF_POS_DATA_DIR);
dict_save_data_dir_path(table, path);
mem_free(path);
}
@@ -2395,16 +2398,14 @@ err_exit:
}
/* Use the remote filepath if needed. */
- if (DICT_TF_HAS_DATA_DIR(table->flags)) {
- /* This needs to be added to the table
- from SYS_DATAFILES */
- dict_get_and_save_data_dir_path(table, true);
+ /* This needs to be added to the table
+ from SYS_DATAFILES */
+ dict_get_and_save_data_dir_path(table, true);
- if (table->data_dir_path) {
- filepath = os_file_make_remote_pathname(
+ if (table->data_dir_path) {
+ filepath = os_file_make_remote_pathname(
table->data_dir_path,
table->name, "ibd");
- }
}
/* Try to open the tablespace. We set the
diff --git a/storage/xtradb/fil/fil0fil.cc b/storage/xtradb/fil/fil0fil.cc
index bc30211032b..e77c97ead5b 100644
--- a/storage/xtradb/fil/fil0fil.cc
+++ b/storage/xtradb/fil/fil0fil.cc
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2013, 2015, MariaDB Corporation. All Rights Reserved.
+Copyright (c) 2013, 2016, MariaDB Corporation. All Rights Reserved.
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 the Free Software
@@ -719,16 +719,23 @@ fil_node_open_file(
}
if (UNIV_UNLIKELY(space->flags != flags)) {
- fprintf(stderr,
- "InnoDB: Error: table flags are 0x%lx"
- " in the data dictionary\n"
- "InnoDB: but the flags in file %s are 0x%lx!\n",
- space->flags, node->name, flags);
+ ulint sflags = (space->flags & ~FSP_FLAGS_MASK_DATA_DIR);
+ ulint fflags = (flags & ~FSP_FLAGS_MASK_DATA_DIR_ORACLE);
- ut_error;
- }
+ /* DATA_DIR option is on different place on MariaDB
+ compared to MySQL. If this is the difference. Fix
+ it. */
+
+ if (sflags == fflags) {
+ fprintf(stderr,
+ "InnoDB: Warning: Table flags 0x%lx"
+ " in the data dictionary but in file %s are 0x%lx!\n"
+ " Temporally corrected because DATA_DIR option to 0x%lx.\n",
+ space->flags, node->name, flags, space->flags);
+
+ flags = space->flags;
+ }
- if (UNIV_UNLIKELY(space->flags != flags)) {
if (!dict_tf_verify_flags(space->flags, flags)) {
fprintf(stderr,
"InnoDB: Error: table flags are 0x%lx"
@@ -3829,8 +3836,18 @@ fil_open_single_table_tablespace(
/* Validate this single-table-tablespace with SYS_TABLES,
but do not compare the DATA_DIR flag, in case the
tablespace was relocated. */
+
+ ulint newf = def.flags;
+ if (newf != mod_flags) {
+ if (FSP_FLAGS_HAS_DATA_DIR(newf)) {
+ newf = (newf & ~FSP_FLAGS_MASK_DATA_DIR);
+ } else if(FSP_FLAGS_HAS_DATA_DIR_ORACLE(newf)) {
+ newf = (newf & ~FSP_FLAGS_MASK_DATA_DIR_ORACLE);
+ }
+ }
+
if (def.valid && def.id == id
- && (def.flags & ~FSP_FLAGS_MASK_DATA_DIR) == mod_flags) {
+ && newf == mod_flags) {
valid_tablespaces_found++;
} else {
def.valid = false;
@@ -3855,8 +3872,17 @@ fil_open_single_table_tablespace(
/* Validate this single-table-tablespace with SYS_TABLES,
but do not compare the DATA_DIR flag, in case the
tablespace was relocated. */
+ ulint newf = remote.flags;
+ if (newf != mod_flags) {
+ if (FSP_FLAGS_HAS_DATA_DIR(newf)) {
+ newf = (newf & ~FSP_FLAGS_MASK_DATA_DIR);
+ } else if(FSP_FLAGS_HAS_DATA_DIR_ORACLE(newf)) {
+ newf = (newf & ~FSP_FLAGS_MASK_DATA_DIR_ORACLE);
+ }
+ }
+
if (remote.valid && remote.id == id
- && (remote.flags & ~FSP_FLAGS_MASK_DATA_DIR) == mod_flags) {
+ && newf == mod_flags) {
valid_tablespaces_found++;
} else {
remote.valid = false;
@@ -3882,8 +3908,17 @@ fil_open_single_table_tablespace(
/* Validate this single-table-tablespace with SYS_TABLES,
but do not compare the DATA_DIR flag, in case the
tablespace was relocated. */
+ ulint newf = dict.flags;
+ if (newf != mod_flags) {
+ if (FSP_FLAGS_HAS_DATA_DIR(newf)) {
+ newf = (newf & ~FSP_FLAGS_MASK_DATA_DIR);
+ } else if(FSP_FLAGS_HAS_DATA_DIR_ORACLE(newf)) {
+ newf = (newf & ~FSP_FLAGS_MASK_DATA_DIR_ORACLE);
+ }
+ }
+
if (dict.valid && dict.id == id
- && (dict.flags & ~FSP_FLAGS_MASK_DATA_DIR) == mod_flags) {
+ && newf == mod_flags) {
valid_tablespaces_found++;
} else {
dict.valid = false;
diff --git a/storage/xtradb/include/fsp0fsp.h b/storage/xtradb/include/fsp0fsp.h
index 8fdacc51277..839aed80418 100644
--- a/storage/xtradb/include/fsp0fsp.h
+++ b/storage/xtradb/include/fsp0fsp.h
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1995, 2012, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2013, SkySQL Ab. All Rights Reserved.
+Copyright (c) 2013, 2016, MariaDB Corporation. All Rights Reserved.
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 the Free Software
@@ -99,6 +99,9 @@ dictionary */
/** Zero relative shift position of the start of the DATA DIR bits */
#define FSP_FLAGS_POS_DATA_DIR (FSP_FLAGS_POS_PAGE_SSIZE \
+ FSP_FLAGS_WIDTH_PAGE_SSIZE)
+#define FSP_FLAGS_POS_DATA_DIR_ORACLE (FSP_FLAGS_POS_ATOMIC_BLOBS \
+ + FSP_FLAGS_WIDTH_ATOMIC_BLOBS \
+ + FSP_FLAGS_WIDTH_PAGE_SSIZE)
/** Zero relative shift position of the start of the UNUSED bits */
#define FSP_FLAGS_POS_UNUSED (FSP_FLAGS_POS_DATA_DIR\
+ FSP_FLAGS_WIDTH_DATA_DIR)
@@ -123,6 +126,10 @@ dictionary */
#define FSP_FLAGS_MASK_DATA_DIR \
((~(~0 << FSP_FLAGS_WIDTH_DATA_DIR)) \
<< FSP_FLAGS_POS_DATA_DIR)
+/** Bit mask of the DATA_DIR field */
+#define FSP_FLAGS_MASK_DATA_DIR_ORACLE \
+ ((~(~0 << FSP_FLAGS_WIDTH_DATA_DIR)) \
+ << FSP_FLAGS_POS_DATA_DIR_ORACLE)
/** Bit mask of the PAGE_COMPRESSION field */
#define FSP_FLAGS_MASK_PAGE_COMPRESSION \
((~(~0 << FSP_FLAGS_WIDTH_PAGE_COMPRESSION)) \
@@ -156,6 +163,9 @@ dictionary */
#define FSP_FLAGS_HAS_DATA_DIR(flags) \
((flags & FSP_FLAGS_MASK_DATA_DIR) \
>> FSP_FLAGS_POS_DATA_DIR)
+#define FSP_FLAGS_HAS_DATA_DIR_ORACLE(flags) \
+ ((flags & FSP_FLAGS_MASK_DATA_DIR_ORACLE) \
+ >> FSP_FLAGS_POS_DATA_DIR_ORACLE)
/** Return the contents of the UNUSED bits */
#define FSP_FLAGS_GET_UNUSED(flags) \
(flags >> FSP_FLAGS_POS_UNUSED)