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

support for parallel queries #246

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 1 addition & 2 deletions include/sql_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,10 @@ extern PSI_memory_key key_memory_String_value;
Don't add new members or virual methods into this class!
*/
class Simple_cstring {
private:
public:
const char *m_str;
size_t m_length;

public:
/**
Initialize from a C string whose length is already known.
*/
Expand Down
5 changes: 2 additions & 3 deletions sql/item_func.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6851,7 +6851,7 @@ bool Item_func_get_user_var::set_value(THD *thd, sp_rcontext * /*ctx*/,

bool Item_func_get_user_var::pq_copy_from(THD *thd, Query_block *select,
Item *item) {
if (Item_var_func::pq_copy_from(thd, select, this)) {
if (Item_var_func::pq_copy_from(thd, select, item)) {
return true;
}
Item_func_get_user_var *orig_item =
Expand All @@ -6863,9 +6863,8 @@ bool Item_func_get_user_var::pq_copy_from(THD *thd, Query_block *select,
THD *entry_thd = thd->pq_leader;
assert(entry_thd);
mysql_mutex_lock(&entry_thd->LOCK_thd_data);
var_entry = get_variable(entry_thd, name, NULL);
var_entry = get_variable(entry_thd, name, nullptr);
mysql_mutex_unlock(&entry_thd->LOCK_thd_data);
assert(var_entry && orig_item->var_entry);
#endif
if (orig_item != nullptr) {
m_cached_result_type = orig_item->m_cached_result_type;
Expand Down
2 changes: 2 additions & 0 deletions sql/parse_tree_items.h
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,8 @@ class PTI_user_variable final : public Item_func_get_user_var {
PTI_user_variable(const POS &pos, const LEX_STRING &var) : super(pos, var) {}

bool itemize(Parse_context *pc, Item **res) override;

Item *pq_clone(THD *thd, Query_block *select) override;
};

/**
Expand Down
25 changes: 18 additions & 7 deletions sql/pq_clone_item.cc
Original file line number Diff line number Diff line change
Expand Up @@ -690,13 +690,19 @@ COPY_FUNC_ITEM(Item_func_lt, ARG0, ARG1)
COPY_FUNC_ITEM(Item_func_ne, ARG0, ARG1)

PQ_CLONE_DEF(Item_func_like) {
Item *arg0 = args[0]->pq_clone(thd, select);
if (arg0 == nullptr) return nullptr;

Item *arg1 = args[1]->pq_clone(thd, select);
if (arg1 == nullptr) return nullptr;

new_item = new (thd->pq_mem_root) Item_func_like(arg0, arg1);
Item *arg[3];
for (uint i = 0; i < arg_count; i++) {
arg[i] = args[i]->pq_clone(thd, select);
if (arg[i] == nullptr) return nullptr;
}

if (arg_count == 2) {
new_item = new (thd->pq_mem_root) Item_func_like(arg[0], arg[1]);
} else if (arg_count == 3) {
new_item = new (thd->pq_mem_root) Item_func_like(arg[0], arg[1], arg[2]);
} else {
sql_print_warning("arg_count is wrong!");
}
}
PQ_CLONE_RETURN

Expand Down Expand Up @@ -1894,6 +1900,11 @@ PQ_CLONE_DEF(PTI_text_literal_underscore_charset) {
}
PQ_CLONE_RETURN

PQ_CLONE_DEF(PTI_user_variable) {
new_item = new (thd->pq_mem_root) PTI_user_variable(POS(), {const_cast<char*>(name.m_str), name.m_length});
}
PQ_CLONE_RETURN

PQ_CLONE_DEF(Item_func_get_user_var) {
new_item = new (thd->pq_mem_root) Item_func_get_user_var(POS(), name);
}
Expand Down
16 changes: 8 additions & 8 deletions sql/pq_condition.cc
Original file line number Diff line number Diff line change
Expand Up @@ -418,17 +418,13 @@ bool pq_create_result_fields(THD *thd, Temp_table_param *param,

copy_func->reserve(copy_func_count);
for (Item *item : fields) {
Field *new_field = nullptr;
Item::Type type = item->type();
const bool is_sum_func =
type == Item::SUM_FUNC_ITEM && !item->m_is_window_function;

if (not_all_columns && item != nullptr) {
if (item->has_aggregation() && type != Item::SUM_FUNC_ITEM) {
if (item->used_tables() & OUTER_REF_TABLE_BIT) {
item->update_used_tables();
}

if (item->is_outer_reference()) item->update_used_tables();
if (type == Item::SUBSELECT_ITEM ||
(item->used_tables() & ~OUTER_REF_TABLE_BIT)) {
param->using_outer_summary_function = 1;
Expand All @@ -449,14 +445,14 @@ bool pq_create_result_fields(THD *thd, Temp_table_param *param,
goto update_hidden;
}
}
if (item->const_item() && (int)hidden_field_count <= 0) {
continue; // We don't have to store this
}

if (item->const_item()) continue;
}

if (is_sum_func && !save_sum_fields) {
/* Can't calc group yet */
} else {
Field *new_field = nullptr;
if (param->schema_table) {
new_field =
item ? create_tmp_field_for_schema(item, &table, root) : nullptr;
Expand All @@ -479,6 +475,8 @@ bool pq_create_result_fields(THD *thd, Temp_table_param *param,
if (not_all_columns && type == Item::SUM_FUNC_ITEM) {
((Item_sum *)item)->result_field = new_field;
}

s.fields++;
}

update_hidden:
Expand All @@ -487,6 +485,8 @@ bool pq_create_result_fields(THD *thd, Temp_table_param *param,
}
} // end of while ((item=li++)).

if (s.fields == 0) return true;

Field *result_field = nullptr;

for (Item *item : fields) {
Expand Down