summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2020-04-15 09:56:03 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2020-04-15 09:56:03 +0300
commit84db10f27bdb4c8d9edf7f554afdcd2a24e3285a (patch)
tree5f9d5b22cdfee6f147274d85b279d98f8a1bb46b /sql
parent9aacda409db8606b985a93f675487943846cbc86 (diff)
parentccaec18b3934ee384296b4597bdf462fac66c5a4 (diff)
downloadmariadb-git-84db10f27bdb4c8d9edf7f554afdcd2a24e3285a.tar.gz
Merge 10.2 into 10.3
Diffstat (limited to 'sql')
-rw-r--r--sql/handler.cc34
-rw-r--r--sql/handler.h13
-rw-r--r--sql/log.cc6
-rw-r--r--sql/opt_range.cc23
-rw-r--r--sql/transaction.cc6
-rw-r--r--sql/wsrep_binlog.cc14
-rw-r--r--sql/wsrep_binlog.h2
-rw-r--r--sql/wsrep_hton.cc24
8 files changed, 61 insertions, 61 deletions
diff --git a/sql/handler.cc b/sql/handler.cc
index 4e2c6afda80..6bd8938fdca 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -1850,29 +1850,33 @@ int ha_commit_or_rollback_by_xid(XID *xid, bool commit)
#ifndef DBUG_OFF
-/**
- @note
- This does not need to be multi-byte safe or anything
-*/
-static char* xid_to_str(char *buf, XID *xid)
+/** Converts XID to string.
+
+@param[out] buf output buffer
+@param[in] xid XID to convert
+
+@return pointer to converted string
+
+@note This does not need to be multi-byte safe or anything */
+char *xid_to_str(char *buf, const XID &xid)
{
int i;
char *s=buf;
*s++='\'';
- for (i=0; i < xid->gtrid_length+xid->bqual_length; i++)
+ for (i= 0; i < xid.gtrid_length + xid.bqual_length; i++)
{
- uchar c=(uchar)xid->data[i];
+ uchar c= (uchar) xid.data[i];
/* is_next_dig is set if next character is a number */
bool is_next_dig= FALSE;
if (i < XIDDATASIZE)
{
- char ch= xid->data[i+1];
+ char ch= xid.data[i + 1];
is_next_dig= (ch >= '0' && ch <='9');
}
- if (i == xid->gtrid_length)
+ if (i == xid.gtrid_length)
{
*s++='\'';
- if (xid->bqual_length)
+ if (xid.bqual_length)
{
*s++='.';
*s++='\'';
@@ -1994,7 +1998,8 @@ static my_bool xarecover_handlerton(THD *unused, plugin_ref plugin,
{
#ifndef DBUG_OFF
char buf[XIDDATASIZE*4+6]; // see xid_to_str
- DBUG_PRINT("info", ("ignore xid %s", xid_to_str(buf, info->list+i)));
+ DBUG_PRINT("info",
+ ("ignore xid %s", xid_to_str(buf, info->list[i])));
#endif
xid_cache_insert(info->list+i, XA_PREPARED);
info->found_foreign_xids++;
@@ -2024,7 +2029,8 @@ static my_bool xarecover_handlerton(THD *unused, plugin_ref plugin,
if (rc == 0)
{
char buf[XIDDATASIZE*4+6]; // see xid_to_str
- DBUG_PRINT("info", ("commit xid %s", xid_to_str(buf, info->list+i)));
+ DBUG_PRINT("info",
+ ("commit xid %s", xid_to_str(buf, info->list[i])));
}
#endif
}
@@ -2038,8 +2044,8 @@ static my_bool xarecover_handlerton(THD *unused, plugin_ref plugin,
if (rc == 0)
{
char buf[XIDDATASIZE*4+6]; // see xid_to_str
- DBUG_PRINT("info", ("rollback xid %s",
- xid_to_str(buf, info->list+i)));
+ DBUG_PRINT("info",
+ ("rollback xid %s", xid_to_str(buf, info->list[i])));
}
#endif
}
diff --git a/sql/handler.h b/sql/handler.h
index e3bfcaa1ed2..94c652359d2 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -2,7 +2,7 @@
#define HANDLER_INCLUDED
/*
Copyright (c) 2000, 2019, Oracle and/or its affiliates.
- Copyright (c) 2009, 2019, MariaDB
+ Copyright (c) 2009, 2020, MariaDB
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@@ -4888,4 +4888,15 @@ void print_keydup_error(TABLE *table, KEY *key, myf errflag);
int del_global_index_stat(THD *thd, TABLE* table, KEY* key_info);
int del_global_table_stat(THD *thd, const LEX_CSTRING *db, const LEX_CSTRING *table);
+#ifndef DBUG_OFF
+/** Converts XID to string.
+
+@param[out] buf output buffer
+@param[in] xid XID to convert
+
+@return pointer to converted string
+
+@note This does not need to be multi-byte safe or anything */
+char *xid_to_str(char *buf, const XID &xid);
+#endif // !DBUG_OFF
#endif /* HANDLER_INCLUDED */
diff --git a/sql/log.cc b/sql/log.cc
index bde301452be..ae7468ede81 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -2251,9 +2251,6 @@ static int binlog_savepoint_set(handlerton *hton, THD *thd, void *sv)
int error= 1;
DBUG_ENTER("binlog_savepoint_set");
- if (wsrep_emulate_bin_log)
- DBUG_RETURN(0);
-
char buf[1024];
String log_query(buf, sizeof(buf), &my_charset_bin);
@@ -2286,9 +2283,6 @@ static int binlog_savepoint_rollback(handlerton *hton, THD *thd, void *sv)
{
DBUG_ENTER("binlog_savepoint_rollback");
- if (wsrep_emulate_bin_log)
- DBUG_RETURN(0);
-
/*
Write ROLLBACK TO SAVEPOINT to the binlog cache if we have updated some
non-transactional table. Otherwise, truncate the binlog cache starting
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 38b52f96704..0cf51415723 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -358,7 +358,8 @@ QUICK_RANGE_SELECT *get_quick_select(PARAM *param,uint index,
static TRP_RANGE *get_key_scans_params(PARAM *param, SEL_TREE *tree,
bool index_read_must_be_used,
bool update_tbl_stats,
- double read_time);
+ double read_time,
+ bool ror_scans_required);
static
TRP_INDEX_INTERSECT *get_best_index_intersect(PARAM *param, SEL_TREE *tree,
double read_time);
@@ -2606,7 +2607,7 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use,
/* Get best 'range' plan and prepare data for making other plans */
if ((range_trp= get_key_scans_params(&param, tree, FALSE, TRUE,
- best_read_time)))
+ best_read_time, FALSE)))
{
best_trp= range_trp;
best_read_time= best_trp->read_cost;
@@ -4732,7 +4733,8 @@ TABLE_READ_PLAN *get_best_disjunct_quick(PARAM *param, SEL_IMERGE *imerge,
{
DBUG_EXECUTE("info", print_sel_tree(param, *ptree, &(*ptree)->keys_map,
"tree in SEL_IMERGE"););
- if (!(*cur_child= get_key_scans_params(param, *ptree, TRUE, FALSE, read_time)))
+ if (!(*cur_child= get_key_scans_params(param, *ptree, TRUE, FALSE,
+ read_time, TRUE)))
{
/*
One of index scans in this index_merge is more expensive than entire
@@ -5054,7 +5056,7 @@ TABLE_READ_PLAN *merge_same_index_scans(PARAM *param, SEL_IMERGE *imerge,
index merge retrievals are not well calibrated
*/
trp= get_key_scans_params(param, *imerge->trees, FALSE, TRUE,
- read_time);
+ read_time, TRUE);
}
DBUG_RETURN(trp);
@@ -6782,6 +6784,7 @@ TRP_ROR_INTERSECT *get_best_covering_ror_intersect(PARAM *param,
index_read_must_be_used if TRUE, assume 'index only' option will be set
(except for clustered PK indexes)
read_time don't create read plans with cost > read_time.
+ ror_scans_required set to TRUE for index merge
RETURN
Best range read plan
NULL if no plan found or error occurred
@@ -6790,7 +6793,8 @@ TRP_ROR_INTERSECT *get_best_covering_ror_intersect(PARAM *param,
static TRP_RANGE *get_key_scans_params(PARAM *param, SEL_TREE *tree,
bool index_read_must_be_used,
bool update_tbl_stats,
- double read_time)
+ double read_time,
+ bool ror_scans_required)
{
uint idx, UNINIT_VAR(best_idx);
SEL_ARG *key_to_read= NULL;
@@ -6838,6 +6842,13 @@ static TRP_RANGE *get_key_scans_params(PARAM *param, SEL_TREE *tree,
update_tbl_stats, &mrr_flags,
&buf_size, &cost);
+ if (ror_scans_required && !param->is_ror_scan &&
+ !optimizer_flag(param->thd, OPTIMIZER_SWITCH_INDEX_MERGE_SORT_UNION))
+ {
+ /* The scan is not a ROR-scan, just skip it */
+ continue;
+ }
+
if (found_records != HA_POS_ERROR && tree->index_scans &&
(index_scan= (INDEX_SCAN_INFO *)alloc_root(param->mem_root,
sizeof(INDEX_SCAN_INFO))))
@@ -9108,7 +9119,7 @@ key_and(RANGE_OPT_PARAM *param, SEL_ARG *key1, SEL_ARG *key2, uint clone_flag)
if (key2->next_key_part)
{
key1->use_count--; // Incremented in and_all_keys
- return and_all_keys(param, key1, key2, clone_flag);
+ return and_all_keys(param, key1, key2->next_key_part, clone_flag);
}
key2->use_count--; // Key2 doesn't have a tree
}
diff --git a/sql/transaction.cc b/sql/transaction.cc
index 8c28543a0e7..e2c120ffebb 100644
--- a/sql/transaction.cc
+++ b/sql/transaction.cc
@@ -619,6 +619,9 @@ bool trans_savepoint(THD *thd, LEX_CSTRING name)
if (thd->transaction.xid_state.check_has_uncommitted_xa())
DBUG_RETURN(TRUE);
+ if (WSREP_ON)
+ wsrep_register_hton(thd, thd->in_multi_stmt_transaction_mode());
+
sv= find_savepoint(thd, name);
if (*sv) /* old savepoint of the same name exists */
@@ -695,6 +698,9 @@ bool trans_rollback_to_savepoint(THD *thd, LEX_CSTRING name)
if (thd->transaction.xid_state.check_has_uncommitted_xa())
DBUG_RETURN(TRUE);
+ if (WSREP_ON)
+ wsrep_register_hton(thd, thd->in_multi_stmt_transaction_mode());
+
/**
Checking whether it is safe to release metadata locks acquired after
savepoint, if rollback to savepoint is successful.
diff --git a/sql/wsrep_binlog.cc b/sql/wsrep_binlog.cc
index 412af259d98..85c1deb0d71 100644
--- a/sql/wsrep_binlog.cc
+++ b/sql/wsrep_binlog.cc
@@ -380,20 +380,6 @@ int wsrep_binlog_close_connection(THD* thd)
DBUG_RETURN(0);
}
-int wsrep_binlog_savepoint_set(THD *thd, void *sv)
-{
- if (!wsrep_emulate_bin_log) return 0;
- int rcode = binlog_hton->savepoint_set(binlog_hton, thd, sv);
- return rcode;
-}
-
-int wsrep_binlog_savepoint_rollback(THD *thd, void *sv)
-{
- if (!wsrep_emulate_bin_log) return 0;
- int rcode = binlog_hton->savepoint_rollback(binlog_hton, thd, sv);
- return rcode;
-}
-
#if 0
void wsrep_dump_rbr_direct(THD* thd, IO_CACHE* cache)
{
diff --git a/sql/wsrep_binlog.h b/sql/wsrep_binlog.h
index c2ccacdc180..ed8e19ed651 100644
--- a/sql/wsrep_binlog.h
+++ b/sql/wsrep_binlog.h
@@ -54,7 +54,5 @@ void wsrep_dump_rbr_buf_with_header(THD *thd, const void *rbr_buf,
size_t buf_len);
int wsrep_binlog_close_connection(THD* thd);
-int wsrep_binlog_savepoint_set(THD *thd, void *sv);
-int wsrep_binlog_savepoint_rollback(THD *thd, void *sv);
#endif /* WSREP_BINLOG_H */
diff --git a/sql/wsrep_hton.cc b/sql/wsrep_hton.cc
index acd648de892..16870372627 100644
--- a/sql/wsrep_hton.cc
+++ b/sql/wsrep_hton.cc
@@ -221,32 +221,20 @@ static int wsrep_prepare(handlerton *hton, THD *thd, bool all)
DBUG_RETURN(0);
}
+/*
+ Empty callbacks to support SAVEPOINT callbacks.
+*/
+
static int wsrep_savepoint_set(handlerton *hton, THD *thd, void *sv)
{
DBUG_ENTER("wsrep_savepoint_set");
-
- if (thd->wsrep_exec_mode == REPL_RECV)
- {
- DBUG_RETURN(0);
- }
-
- if (!wsrep_emulate_bin_log) DBUG_RETURN(0);
- int rcode = wsrep_binlog_savepoint_set(thd, sv);
- DBUG_RETURN(rcode);
+ DBUG_RETURN(0);
}
static int wsrep_savepoint_rollback(handlerton *hton, THD *thd, void *sv)
{
DBUG_ENTER("wsrep_savepoint_rollback");
-
- if (thd->wsrep_exec_mode == REPL_RECV)
- {
- DBUG_RETURN(0);
- }
-
- if (!wsrep_emulate_bin_log) DBUG_RETURN(0);
- int rcode = wsrep_binlog_savepoint_rollback(thd, sv);
- DBUG_RETURN(rcode);
+ DBUG_RETURN(0);
}
static int wsrep_rollback(handlerton *hton, THD *thd, bool all)