Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

并行查询特性mtr失败用例query_rewrite_plugins.joins修改 #87

Merged
merged 1 commit into from
Jun 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sql/item.h
Original file line number Diff line number Diff line change
Expand Up @@ -3408,6 +3408,7 @@ class Item_ident : public Item {
cached_table should be replaced by table_ref ASAP.
*/
TABLE_LIST *cached_table;
uint m_tableno{0};
SELECT_LEX *depended_from;

Item_ident(Name_resolution_context *context_arg, const char *db_name_arg,
Expand Down Expand Up @@ -3692,6 +3693,7 @@ class Item_field : public Item_ident {
bool itemize(Parse_context *pc, Item **res) override;

Item *pq_clone(THD *thd, SELECT_LEX *select) override;
bool pq_copy_from(THD *thd, SELECT_LEX *select, Item *item) override;
enum Type type() const override { return FIELD_ITEM; }
bool eq(const Item *item, bool binary_cmp) const override;
double val_real() override;
Expand Down
15 changes: 15 additions & 0 deletions sql/pq_clone_item.cc
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,21 @@ PQ_COPY_FROM_DEF(Item_ident, Item) {
DBUG_EXECUTE_IF("simulate_item_clone_attr_copy_error", return true;);

context = &select->context;

if (orig_item->cached_table == nullptr) {
m_tableno = orig_item->m_tableno;
} else {
m_tableno = orig_item->cached_table->m_tableno;
}
}
PQ_COPY_FROM_RETURN

PQ_COPY_FROM_DEF(Item_field, Item_ident) {
DBUG_EXECUTE_IF("simulate_item_field_copy_error", return true;);

if (orig_item->table_ref != nullptr) {
m_tableno = orig_item->table_ref->m_tableno;
}
}
PQ_COPY_FROM_RETURN

Expand Down
8 changes: 7 additions & 1 deletion sql/sql_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7740,10 +7740,16 @@ Field *find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *first_table,
auto cur_table = first_table;
for (; cur_table != last_table && cur_table != last_table2;
cur_table = cur_table->next_name_resolution_table) {
Field *cur_field = find_field_in_table_ref(
Field *cur_field = nullptr;
if (thd->parallel_exec && item->m_tableno != cur_table->m_tableno) {
continue;
} else {
cur_field = find_field_in_table_ref(
thd, cur_table, name, length, item->item_name.ptr(), db, table_name,
ref, want_privilege, allow_rowid, &(item->cached_field_index),
register_tree_change, &actual_table);
}

if ((cur_field == nullptr && thd->is_error()) || cur_field == WRONG_GRANT)
return nullptr;

Expand Down
3 changes: 2 additions & 1 deletion sql/table.h
Original file line number Diff line number Diff line change
Expand Up @@ -3162,13 +3162,14 @@ struct TABLE_LIST {

const Lock_descriptor &lock_descriptor() const { return m_lock_descriptor; }

private:
public:
/**
The members below must be kept aligned so that (1 << m_tableno) == m_map.
A table that takes part in a join operation must be assigned a unique
table number.
*/
uint m_tableno{0}; ///< Table number within query block
private:
table_map m_map{0}; ///< Table map, derived from m_tableno
/**
If this table or join nest is the Y in "X [LEFT] JOIN Y ON C", this
Expand Down