192
192
for (table_ptr= select_lex->leaf_tables;
194
194
table_ptr= table_ptr->next_leaf)
200
197
if (setup_wild(session, fields_list, &all_fields, wild_num) ||
201
198
select_lex->setup_ref_array(session, og_num) ||
596
593
if (const_tables && !(select_options & SELECT_NO_UNLOCK))
597
session->unlockSomeTables(table, const_tables);
594
mysql_unlock_some_tables(session, table, const_tables);
598
595
if (!conds && outer_join)
600
597
/* Handle the case where we have an OUTER JOIN without a WHERE */
1791
1788
is called after all rows are sent, but before EOF packet is sent.
1793
1790
For a simple SELECT with no subqueries this function performs a full
1794
cleanup of the Join and calls unlockReadTables to free used base
1791
cleanup of the Join and calls mysql_unlock_read_tables to free used base
1797
1794
If a Join is executed for a subquery or if it has a subquery, we can't
2465
2462
return NESTED_LOOP_ERROR;
2467
2464
return NESTED_LOOP_NO_MORE_ROWS;
2468
if (join->session->getKilled()) // Aborted by user
2465
if (join->session->killed) // Aborted by user
2470
2467
join->session->send_kill_message();
2471
2468
return NESTED_LOOP_KILLED;
2677
2674
info= &join_tab->read_record;
2680
if (join->session->getKilled())
2677
if (join->session->killed)
2682
2679
join->session->send_kill_message();
2683
2680
return NESTED_LOOP_KILLED;
2810
2807
Table *table= join->tmp_table;
2812
if (join->session->getKilled()) // Aborted by user
2809
if (join->session->killed) // Aborted by user
2814
2811
join->session->send_kill_message();
2815
2812
return NESTED_LOOP_KILLED;
2817
2814
if (!end_of_records)
2819
2816
copy_fields(&join->tmp_table_param);
2820
if (copy_funcs(join->tmp_table_param.items_to_copy, join->session))
2821
return NESTED_LOOP_ERROR;
2817
copy_funcs(join->tmp_table_param.items_to_copy);
2822
2818
if (!join->having || join->having->val_int())
2903
2899
memcpy(table->getInsertRecord()+key_part->offset, group->buff, 1);
2905
2901
init_tmptable_sum_functions(join->sum_funcs);
2906
if (copy_funcs(join->tmp_table_param.items_to_copy, join->session))
2907
return NESTED_LOOP_ERROR;
2902
copy_funcs(join->tmp_table_param.items_to_copy);
2908
2903
if ((error=table->cursor->insertRecord(table->getInsertRecord())))
2910
2905
my_error(ER_USE_SQL_BIG_RESULT, MYF(0));
2931
2926
init_tmptable_sum_functions(join->sum_funcs);
2932
2927
copy_fields(&join->tmp_table_param); // Groups are copied twice.
2933
if (copy_funcs(join->tmp_table_param.items_to_copy, join->session))
2934
return NESTED_LOOP_ERROR;
2928
copy_funcs(join->tmp_table_param.items_to_copy);
2936
2930
if (!(error= table->cursor->insertRecord(table->getInsertRecord())))
2937
2931
join->send_records++; // New group
3016
3010
case REAL_RESULT:
3017
3011
key_length+= sizeof(double);
3020
3013
case INT_RESULT:
3021
3014
key_length+= sizeof(int64_t);
3024
3016
case DECIMAL_RESULT:
3025
3017
key_length+= my_decimal_get_binary_size(group_item->max_length -
3026
3018
(group_item->decimals ? 1 : 0),
3027
3019
group_item->decimals);
3030
3021
case STRING_RESULT:
3032
enum enum_field_types type= group_item->field_type();
3023
enum enum_field_types type= group_item->field_type();
3025
As items represented as DATE/TIME fields in the group buffer
3026
have STRING_RESULT result type, we increase the length
3027
by 8 as maximum pack length of such fields.
3029
if (type == DRIZZLE_TYPE_DATE ||
3030
type == DRIZZLE_TYPE_DATETIME ||
3031
type == DRIZZLE_TYPE_TIMESTAMP)
3034
As items represented as DATE/TIME fields in the group buffer
3035
have STRING_RESULT result type, we increase the length
3036
by 8 as maximum pack length of such fields.
3038
Group strings are taken as varstrings and require an length field.
3039
A field is not yet created by create_tmp_field()
3040
and the sizes should match up.
3038
if (type == DRIZZLE_TYPE_DATE ||
3039
type == DRIZZLE_TYPE_DATETIME ||
3040
type == DRIZZLE_TYPE_TIMESTAMP)
3047
Group strings are taken as varstrings and require an length field.
3048
A field is not yet created by create_tmp_field()
3049
and the sizes should match up.
3051
key_length+= group_item->max_length + HA_KEY_BLOB_LENGTH;
3042
key_length+= group_item->max_length + HA_KEY_BLOB_LENGTH;
3057
3047
/* This case should never be choosen */
3059
3049
my_error(ER_OUT_OF_RESOURCES, MYF(ME_FATALERROR));
3065
3053
if (group_item->maybe_null)
3069
3056
join->tmp_table_param.group_length=key_length+null_parts;
3070
3057
join->tmp_table_param.group_parts=parts;
3071
3058
join->tmp_table_param.group_null_parts=null_parts;
5881
5868
if (join->const_tables != join->tables)
5883
5870
optimize_keyuse(join, keyuse_array);
5884
// @note c_str() is not likely to be valid here if dtrace expects it to
5885
// exist for any period of time.
5886
DRIZZLE_QUERY_OPT_CHOOSE_PLAN_START(join->session->getQueryString()->c_str(), join->session->thread_id);
5871
DRIZZLE_QUERY_OPT_CHOOSE_PLAN_START(join->session->query.c_str(), join->session->thread_id);
5887
5872
bool res= choose_plan(join, all_table_map & ~join->const_table_map);
5888
5873
DRIZZLE_QUERY_OPT_CHOOSE_PLAN_DONE(res ? 1 : 0);