summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2021-12-02 17:59:45 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2021-12-02 17:59:45 +0200
commite384299ec28cd90666638fe2740134395ee4c607 (patch)
tree2194a4d09e2680685aa803a31ab16677ec5e3666
parent02de93d158bc866166ea7aa94e804447203e9930 (diff)
parent1e54a9716d2d41a059cd6f91a2f7bf6d46e48090 (diff)
downloadmariadb-git-e384299ec28cd90666638fe2740134395ee4c607.tar.gz
Merge 10.7 into 10.8
-rw-r--r--mysql-test/main/opt_trace,ps.rdiff92
-rw-r--r--mysql-test/main/opt_trace.test1
-rw-r--r--sql/opt_subselect.cc9
-rw-r--r--storage/innobase/fil/fil0fil.cc3
-rw-r--r--storage/innobase/fsp/fsp0file.cc30
-rw-r--r--storage/innobase/include/fsp0file.h3
6 files changed, 34 insertions, 104 deletions
diff --git a/mysql-test/main/opt_trace,ps.rdiff b/mysql-test/main/opt_trace,ps.rdiff
deleted file mode 100644
index 3e2218de673..00000000000
--- a/mysql-test/main/opt_trace,ps.rdiff
+++ /dev/null
@@ -1,92 +0,0 @@
---- /Users/shulga/projects/mariadb/server-10.6/mysql-test/main/opt_trace.result 2021-07-21 19:17:11.000000000 +0700
-+++ /Users/shulga/projects/mariadb/server-10.6/mysql-test/main/opt_trace.reject 2021-07-21 19:17:48.000000000 +0700
-@@ -2829,14 +2829,6 @@
- }
- },
- {
-- "transformation": {
-- "select_id": 2,
-- "from": "IN (SELECT)",
-- "to": "semijoin",
-- "chosen": true
-- }
-- },
-- {
- "expanded_query": "/* select#2 */ select t10.pk from t10"
- }
- ]
-@@ -4402,14 +4394,6 @@
- }
- },
- {
-- "transformation": {
-- "select_id": 2,
-- "from": "IN (SELECT)",
-- "to": "semijoin",
-- "chosen": true
-- }
-- },
-- {
- "expanded_query": "/* select#2 */ select t_inner_1.a from t1 t_inner_1 join t1 t_inner_2"
- }
- ]
-@@ -4852,14 +4836,6 @@
- }
- },
- {
-- "transformation": {
-- "select_id": 2,
-- "from": "IN (SELECT)",
-- "to": "semijoin",
-- "chosen": true
-- }
-- },
-- {
- "expanded_query": "/* select#2 */ select t_inner_1.a from t2 t_inner_2 join t1 t_inner_1"
- }
- ]
-@@ -4879,14 +4855,6 @@
- }
- },
- {
-- "transformation": {
-- "select_id": 3,
-- "from": "IN (SELECT)",
-- "to": "semijoin",
-- "chosen": true
-- }
-- },
-- {
- "expanded_query": "/* select#3 */ select t_inner_3.a from t2 t_inner_3 join t1 t_inner_4"
- }
- ]
-@@ -6432,14 +6400,6 @@
- }
- },
- {
-- "transformation": {
-- "select_id": 2,
-- "from": "IN (SELECT)",
-- "to": "semijoin",
-- "chosen": true
-- }
-- },
-- {
- "expanded_query": "/* select#2 */ select t_inner_1.a from t2 t_inner_2 join t1 t_inner_1"
- }
- ]
-@@ -6459,14 +6419,6 @@
- }
- },
- {
-- "transformation": {
-- "select_id": 3,
-- "from": "IN (SELECT)",
-- "to": "semijoin",
-- "chosen": true
-- }
-- },
-- {
- "expanded_query": "/* select#3 */ select t_inner_3.a from t2 t_inner_3 join t1 t_inner_4"
- }
- ]
diff --git a/mysql-test/main/opt_trace.test b/mysql-test/main/opt_trace.test
index 70223560187..402caf2a165 100644
--- a/mysql-test/main/opt_trace.test
+++ b/mysql-test/main/opt_trace.test
@@ -1,6 +1,5 @@
--source include/not_embedded.inc
--source include/have_sequence.inc
---source include/protocol.inc
SELECT table_name, column_name FROM information_schema.columns where table_name="OPTIMIZER_TRACE";
set optimizer_trace="enabled=on";
show variables like 'optimizer_trace';
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc
index 725b8b054ba..596b5169659 100644
--- a/sql/opt_subselect.cc
+++ b/sql/opt_subselect.cc
@@ -717,6 +717,15 @@ int check_and_do_in_subquery_rewrites(JOIN *join)
if (arena)
thd->restore_active_arena(arena, &backup);
in_subs->is_registered_semijoin= TRUE;
+ }
+
+ /*
+ Print the transformation into trace. Do it when we've just set
+ is_registered_semijoin=TRUE above, and also do it when we've already
+ had it set.
+ */
+ if (in_subs->is_registered_semijoin)
+ {
OPT_TRACE_TRANSFORM(thd, trace_wrapper, trace_transform,
select_lex->select_number,
"IN (SELECT)", "semijoin");
diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc
index 0007fde5f43..5a4d5df378e 100644
--- a/storage/innobase/fil/fil0fil.cc
+++ b/storage/innobase/fil/fil0fil.cc
@@ -2544,7 +2544,8 @@ fil_ibd_load(uint32_t space_id, const char *filename, fil_space_t *&space)
/* Read and validate the first page of the tablespace.
Assign a tablespace name based on the tablespace type. */
- switch (file.validate_for_recovery()) {
+ switch (file.validate_for_recovery(
+ static_cast<uint32_t>(space_id))) {
os_offset_t minimum_size;
case DB_SUCCESS:
deferred_space = file.m_defer;
diff --git a/storage/innobase/fsp/fsp0file.cc b/storage/innobase/fsp/fsp0file.cc
index 95eb9007944..a45d4eb95dc 100644
--- a/storage/innobase/fsp/fsp0file.cc
+++ b/storage/innobase/fsp/fsp0file.cc
@@ -386,10 +386,11 @@ exist and be successfully opened. We initially open it in read-only mode
because we just want to read the SpaceID. However, if the first page is
corrupt and needs to be restored from the doublewrite buffer, we will
reopen it in write mode and ry to restore that page.
+@param space_id space id to validate for recovery
@retval DB_SUCCESS if tablespace is valid, DB_ERROR if not.
m_is_valid is also set true on success, else false. */
dberr_t
-Datafile::validate_for_recovery()
+Datafile::validate_for_recovery(uint32_t space_id)
{
dberr_t err;
@@ -432,15 +433,23 @@ Datafile::validate_for_recovery()
}
}
- if (m_space_id == UINT32_MAX) {
- return DB_SUCCESS; /* empty file */
+ const bool empty_tablespace = (m_space_id == UINT32_MAX);
+ if (empty_tablespace && space_id) {
+ /* Set space id to find out whether
+ the page exist in double write buffer */
+ m_space_id = space_id;
}
if (restore_from_doublewrite()) {
- if (m_defer) {
+ if (!m_defer) {
+ return DB_CORRUPTION;
+ }
+ if (!empty_tablespace) {
return err;
}
- return(DB_CORRUPTION);
+ /* InnoDB may rebuild the file from redo log */
+ m_space_id = UINT32_MAX;
+ return DB_SUCCESS; /* empty file */
}
/* Free the previously read first page and then re-validate. */
@@ -768,10 +777,13 @@ Datafile::restore_from_doublewrite()
in the doublewrite buffer, then the recovery is going to fail
now. Hence this is treated as an error. */
- ib::error()
- << "Corrupted page " << page_id
- << " of datafile '" << m_filepath
- << "' could not be found in the doublewrite buffer.";
+ if (!m_defer) {
+ ib::error()
+ << "Corrupted page " << page_id
+ << " of datafile '" << m_filepath
+ << "' could not be found in the "
+ << "doublewrite buffer.";
+ }
return(true);
}
diff --git a/storage/innobase/include/fsp0file.h b/storage/innobase/include/fsp0file.h
index 9dfb3cc7561..fae7d6ea4d4 100644
--- a/storage/innobase/include/fsp0file.h
+++ b/storage/innobase/include/fsp0file.h
@@ -207,9 +207,10 @@ public:
However, if the first page is corrupt and needs to be restored
from the doublewrite buffer, we will reopen it in write mode and
ry to restore that page.
+ @param space_id space id to validate for recovery
@retval DB_SUCCESS if tablespace is valid, DB_ERROR if not.
m_is_valid is also set true on success, else false. */
- dberr_t validate_for_recovery()
+ dberr_t validate_for_recovery(uint32_t space_id=0)
MY_ATTRIBUTE((warn_unused_result));
/** Checks the consistency of the first page of a datafile when the