diff options
author | Sergei Golubchik <serg@mariadb.org> | 2019-10-07 22:17:05 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2019-10-13 20:03:08 +0200 |
commit | f2b27cbf966d715f0b4213703bf99f29f0d16038 (patch) | |
tree | 375007819529a440e36a945d80b8a324fd919f80 | |
parent | 6f472598075c0736768796966e84b479e219b3a0 (diff) | |
download | mariadb-git-f2b27cbf966d715f0b4213703bf99f29f0d16038.tar.gz |
cleanup: formatting
comments, whitespaces
-rw-r--r-- | sql/item.cc | 38 | ||||
-rw-r--r-- | sql/sql_class.h | 2 | ||||
-rw-r--r-- | sql/sql_delete.cc | 2 | ||||
-rw-r--r-- | sql/sql_insert.cc | 49 | ||||
-rw-r--r-- | sql/sql_lex.h | 4 | ||||
-rw-r--r-- | sql/sql_parse.cc | 14 | ||||
-rw-r--r-- | sql/sql_select.cc | 5 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 3 |
8 files changed, 53 insertions, 64 deletions
diff --git a/sql/item.cc b/sql/item.cc index bf59f4d8b85..9c0fa56329b 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -5006,8 +5006,7 @@ static bool mark_as_dependent(THD *thd, SELECT_LEX *last, SELECT_LEX *current, resolved identifier. */ -void mark_select_range_as_dependent(THD *thd, - SELECT_LEX *last_select, +void mark_select_range_as_dependent(THD *thd, SELECT_LEX *last_select, SELECT_LEX *current_sel, Field *found_field, Item *found_item, Item_ident *resolved_item) @@ -5027,26 +5026,25 @@ void mark_select_range_as_dependent(THD *thd, prev_subselect_item->used_tables_cache|= OUTER_REF_TABLE_BIT; prev_subselect_item->const_item_cache= 0; } + + Item_subselect *prev_subselect_item= + previous_select->master_unit()->item; + Item_ident *dependent= resolved_item; + if (found_field == view_ref_found) { - Item_subselect *prev_subselect_item= - previous_select->master_unit()->item; - Item_ident *dependent= resolved_item; - if (found_field == view_ref_found) - { - Item::Type type= found_item->type(); - prev_subselect_item->used_tables_cache|= - found_item->used_tables(); - dependent= ((type == Item::REF_ITEM || type == Item::FIELD_ITEM) ? - (Item_ident*) found_item : - 0); - } - else - prev_subselect_item->used_tables_cache|= - found_field->table->map; - prev_subselect_item->const_item_cache= 0; - mark_as_dependent(thd, last_select, current_sel, resolved_item, - dependent); + Item::Type type= found_item->type(); + prev_subselect_item->used_tables_cache|= + found_item->used_tables(); + dependent= ((type == Item::REF_ITEM || type == Item::FIELD_ITEM) ? + (Item_ident*) found_item : + 0); } + else + prev_subselect_item->used_tables_cache|= + found_field->table->map; + prev_subselect_item->const_item_cache= 0; + mark_as_dependent(thd, last_select, current_sel, resolved_item, + dependent); } diff --git a/sql/sql_class.h b/sql/sql_class.h index 65b6595ed83..34bafea8784 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -5142,7 +5142,7 @@ protected: /* Something used only by the parser: */ public: ha_rows est_records; /* estimated number of records in the result */ - select_result(THD *thd_arg): select_result_sink(thd_arg), est_records(0) {} + select_result(THD *thd_arg): select_result_sink(thd_arg), est_records(0) {} void set_unit(SELECT_LEX_UNIT *unit_arg) { unit= unit_arg; } virtual ~select_result() {}; /** diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index d39bcaea299..d0c9167a484 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -1087,7 +1087,7 @@ int mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, fix_inner_refs(thd, all_fields, select_lex, select_lex->ref_pointer_array)) DBUG_RETURN(TRUE); - select_lex->fix_prepare_information(thd, conds, &fake_conds); + select_lex->fix_prepare_information(thd, conds, &fake_conds); DBUG_RETURN(FALSE); } diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 266aed3c866..ddbdc45f3d7 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -744,8 +744,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, this will lead to a deadlock, since the delayed thread will never be able to get a lock on the table. */ - if (table_list->lock_type == TL_WRITE_DELAYED && - thd->locked_tables_mode && + if (table_list->lock_type == TL_WRITE_DELAYED && thd->locked_tables_mode && find_locked_table(thd->open_tables, table_list->db.str, table_list->table_name.str)) { @@ -774,8 +773,8 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, value_count= values->elements; if (mysql_prepare_insert(thd, table_list, table, fields, values, - update_fields, update_values, duplic, &unused_conds, - FALSE)) + update_fields, update_values, duplic, + &unused_conds, FALSE)) goto abort; /* mysql_prepare_insert sets table_list->table if it was not set */ @@ -1073,7 +1072,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, } else #endif - error=write_record(thd, table ,&info); + error=write_record(thd, table ,&info); if (unlikely(error)) break; thd->get_stmt_da()->inc_current_row_for_warning(); @@ -1087,7 +1086,7 @@ values_loop_end: joins_freed= TRUE; /* - Now all rows are inserted. Time to update logs and sends response to + Now all rows are inserted. Time to update logs and sends response to user */ #ifndef EMBEDDED_LIBRARY @@ -1234,19 +1233,20 @@ values_loop_end: retval= thd->lex->explain->send_explain(thd); goto abort; } + if ((iteration * values_list.elements) == 1 && (!(thd->variables.option_bits & OPTION_WARNINGS) || !thd->cuted_fields)) { my_ok(thd, info.copied + info.deleted + ((thd->client_capabilities & CLIENT_FOUND_ROWS) ? - info.touched : info.updated), - id); + info.touched : info.updated), id); } else { char buff[160]; ha_rows updated=((thd->client_capabilities & CLIENT_FOUND_ROWS) ? info.touched : info.updated); + if (ignore) sprintf(buff, ER_THD(thd, ER_INSERT_INFO), (ulong) info.records, (lock_type == TL_WRITE_DELAYED) ? (ulong) 0 : @@ -1264,7 +1264,7 @@ values_loop_end: thd->lex->current_select->save_leaf_tables(thd); thd->lex->current_select->first_cond_optimization= 0; } - + DBUG_RETURN(FALSE); abort: @@ -1465,12 +1465,13 @@ static void prepare_for_positional_update(TABLE *table, TABLE_LIST *tables) SYNOPSIS mysql_prepare_insert() - thd Thread handler - table_list Global/local table list - table Table to insert into (can be NULL if table should - be taken from table_list->table) - where Where clause (for insert ... select) - select_insert TRUE if INSERT ... SELECT statement + thd Thread handler + table_list Global/local table list + table Table to insert into + (can be NULL if table should + be taken from table_list->table) + where Where clause (for insert ... select) + select_insert TRUE if INSERT ... SELECT statement TODO (in far future) In cases of: @@ -1481,7 +1482,7 @@ static void prepare_for_positional_update(TABLE *table, TABLE_LIST *tables) WARNING You MUST set table->insert_values to 0 after calling this function before releasing the table object. - + RETURN VALUE FALSE OK TRUE error @@ -1664,8 +1665,8 @@ int vers_insert_history_row(TABLE *table) then both on update triggers will work instead. Similarly both on delete triggers will be invoked if we will delete conflicting records. - Sets thd->transaction.stmt.modified_non_trans_table to TRUE if table which is updated didn't have - transactions. + Sets thd->transaction.stmt.modified_non_trans_table to TRUE if table which + is updated didn't have transactions. RETURN VALUE 0 - success @@ -1684,7 +1685,7 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info) DBUG_ENTER("write_record"); info->records++; - save_read_set= table->read_set; + save_read_set= table->read_set; save_write_set= table->write_set; if (info->handle_duplicates == DUP_REPLACE || @@ -1706,7 +1707,7 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info) table->file->insert_id_for_cur_row= insert_id_for_cur_row; bool is_duplicate_key_error; if (table->file->is_fatal_error(error, HA_CHECK_ALL)) - goto err; + goto err; is_duplicate_key_error= table->file->is_fatal_error(error, HA_CHECK_ALL & ~HA_CHECK_DUP); if (!is_duplicate_key_error) @@ -3544,12 +3545,11 @@ bool mysql_insert_select_prepare(THD *thd) SELECT_LEX *select_lex= lex->first_select_lex(); DBUG_ENTER("mysql_insert_select_prepare"); - /* SELECT_LEX do not belong to INSERT statement, so we can't add WHERE clause if table is VIEW */ - + if (mysql_prepare_insert(thd, lex->query_tables, lex->query_tables->table, lex->field_list, 0, lex->update_list, lex->value_list, lex->duplicates, @@ -3794,7 +3794,7 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u) If the result table is the same as one of the source tables (INSERT SELECT), the result table is not finally prepared at the join prepair phase. Do the final preparation now. - + RETURN 0 OK */ @@ -3864,7 +3864,7 @@ int select_insert::send_data(List<Item> &values) error= write_record(thd, table, &info); table->vers_write= table->versioned(); table->auto_increment_field_not_null= FALSE; - + if (likely(!error)) { if (table->triggers || info.handle_duplicates == DUP_UPDATE) @@ -3995,7 +3995,6 @@ bool select_insert::send_ok_packet() { char message[160]; /* status message */ ulonglong row_count; /* rows affected */ ulonglong id; /* last insert-id */ - DBUG_ENTER("select_insert::send_ok_packet"); if (info.ignore) diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 5a0a180c4c8..1a8d5ececde 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -3105,14 +3105,14 @@ struct LEX: public Query_tables_list private: SELECT_LEX builtin_select; - /* current SELECT_LEX in parsing */ public: + /* current SELECT_LEX in parsing */ SELECT_LEX *current_select; /* list of all SELECT_LEX */ SELECT_LEX *all_selects_list; /* current with clause in parsing if any, otherwise 0*/ - With_clause *curr_with_clause; + With_clause *curr_with_clause; /* pointer to the first with clause in the current statement */ With_clause *with_clauses_list; /* diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 0adba6f64e0..bbf00e591e3 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4488,12 +4488,8 @@ mysql_execute_command(THD *thd) #ifdef ENABLED_DEBUG_SYNC DBUG_EXECUTE_IF("after_mysql_insert", { - const char act1[]= - "now " - "wait_for signal.continue"; - const char act2[]= - "now " - "signal signal.continued"; + const char act1[]= "now wait_for signal.continue"; + const char act2[]= "now signal signal.continued"; DBUG_ASSERT(debug_sync_service); DBUG_ASSERT(!debug_sync_set_action(thd, STRING_WITH_LEN(act1))); @@ -4646,8 +4642,7 @@ mysql_execute_command(THD *thd) unit->set_limit(select_lex); MYSQL_DELETE_START(thd->query()); - Protocol * UNINIT_VAR(save_protocol); - bool replaced_protocol= false; + Protocol *save_protocol= NULL; if (!select_lex->item_list.is_empty()) { @@ -4659,7 +4654,6 @@ mysql_execute_command(THD *thd) output and then discard it. */ sel_result= new (thd->mem_root) select_send_analyze(thd); - replaced_protocol= true; save_protocol= thd->protocol; thd->protocol= new Protocol_discard(thd); } @@ -4675,7 +4669,7 @@ mysql_execute_command(THD *thd) unit->lim.get_select_limit(), select_lex->options, lex->result ? lex->result : sel_result); - if (replaced_protocol) + if (save_protocol) { delete thd->protocol; thd->protocol= save_protocol; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index ee9c84e44fd..c68ee97c179 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -4107,9 +4107,8 @@ bool JOIN::save_explain_data(Explain_query *output, bool can_overwrite, If there is SELECT in this statement with the same number it must be the same SELECT */ - DBUG_SLOW_ASSERT(select_lex->select_number == UINT_MAX || - select_lex->select_number == INT_MAX || - !output || + DBUG_ASSERT(select_lex->select_number == UINT_MAX || + select_lex->select_number == INT_MAX || !output || !output->get_select(select_lex->select_number) || output->get_select(select_lex->select_number)->select_lex == select_lex); diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index d679b92a4a3..5477d1f50bf 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -9267,8 +9267,7 @@ query_specification_start: { SELECT_LEX *sel; LEX *lex= Lex; - if (!(sel= lex->alloc_select(TRUE)) || - lex->push_select(sel)) + if (!(sel= lex->alloc_select(TRUE)) || lex->push_select(sel)) MYSQL_YYABORT; sel->init_select(); sel->braces= FALSE; |