revision-id: b04429434ad1ee7f49d263762a560f4ff31dd111 (mariadb-10.2.30-58-gb04429434ad) parent(s): bb8226deabd177d70151d5e0729bf08533954ffd bde7e0ba6e94d576c4563022f38e8d81b1f6d54a author: Sergei Petrunia committer: Sergei Petrunia timestamp: 2020-01-17 00:24:17 +0300 message: Merge branch '10.1' into 10.2 # Conflicts: # sql/sp_head.cc # sql/sql_select.cc # sql/sql_trigger.cc sql/item_func.cc | 3 +- sql/sp.cc | 2 +- sql/sp_cache.cc | 2 +- sql/sp_head.cc | 63 +++++++++++++++++---------------------- sql/sp_head.h | 17 ++++++----- sql/sql_lex.cc | 4 +-- sql/sql_parse.cc | 2 +- sql/sql_prepare.cc | 2 +- sql/sql_select.cc | 13 ++++---- sql/sql_show.cc | 6 ++-- sql/sql_trigger.cc | 2 +- sql/sql_yacc.yy | 2 +- storage/innobase/buf/buf0dblwr.cc | 4 ++- storage/xtradb/buf/buf0dblwr.cc | 4 ++- 14 files changed, 63 insertions(+), 63 deletions(-) diff --cc sql/sp_head.cc index 0179214e508,f940040b480..1f5c6e96906 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@@ -532,51 -550,41 +532,40 @@@ check_routine_name(LEX_STRING *ident } - /* - * - * sp_head - * - */ - - void * - sp_head::operator new(size_t size) throw() + sp_head* sp_head::create() { - DBUG_ENTER("sp_head::operator new"); MEM_ROOT own_root; + init_sql_alloc(&own_root, MEM_ROOT_BLOCK_SIZE, MEM_ROOT_PREALLOC, MYF(0)); sp_head *sp; + if (!(sp= new (&own_root) sp_head(&own_root))) + free_root(&own_root, MYF(0)); - init_sql_alloc(&own_root, MEM_ROOT_BLOCK_SIZE, MEM_ROOT_PREALLOC, MYF(0)); - sp= (sp_head *) alloc_root(&own_root, size); - if (sp == NULL) - DBUG_RETURN(NULL); - sp->main_mem_root= own_root; - DBUG_PRINT("info", ("mem_root %p", &sp->mem_root)); - DBUG_RETURN(sp); + return sp; } - void - sp_head::operator delete(void *ptr, size_t size) throw() - { - DBUG_ENTER("sp_head::operator delete"); - MEM_ROOT own_root; - - if (ptr == NULL) - DBUG_VOID_RETURN; - - sp_head *sp= (sp_head *) ptr; - /* Make a copy of main_mem_root as free_root will free the sp */ - own_root= sp->main_mem_root; - DBUG_PRINT("info", ("mem_root %p moved to %p", - &sp->mem_root, &own_root)); - free_root(&own_root, MYF(0)); - - DBUG_VOID_RETURN; + void sp_head::destroy(sp_head *sp) + { + if (sp) + { + /* Make a copy of main_mem_root as free_root will free the sp */ + MEM_ROOT own_root= sp->main_mem_root; ++ DBUG_PRINT("info", ("mem_root %p moved to %p", ++ &sp->main_mem_root, &own_root)); + delete sp; - - DBUG_PRINT("info", ("mem_root 0x%lx moved to 0x%lx", - (ulong) &sp->mem_root, (ulong) &own_root)); + free_root(&own_root, MYF(0)); + } } + /* + * + * sp_head + * + */ - sp_head::sp_head() - :Query_arena(&main_mem_root, STMT_INITIALIZED_FOR_SP), + sp_head::sp_head(MEM_ROOT *mem_root_arg) + :Query_arena(NULL, STMT_INITIALIZED_FOR_SP), + main_mem_root(*mem_root_arg), // todo: std::move operator. m_flags(0), m_sp_cache_version(0), m_creation_ctx(0), diff --cc sql/sql_select.cc index 72c1e876359,2358615affc..44ac1056a8a --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@@ -13863,19 -13669,23 +13863,22 @@@ static int compare_fields_by_table_orde { int cmp= 0; bool outer_ref= 0; - Item_field *f1= (Item_field *) (field1->real_item()); - Item_field *f2= (Item_field *) (field2->real_item()); - if (field1->const_item() || f1->const_item()) + Item *field1_real= field1->real_item(); + Item *field2_real= field2->real_item(); + + if (field1->const_item() || field1_real->const_item()) - return 1; - if (field2->const_item() || field2_real->const_item()) return -1; - if (field2->const_item() || f2->const_item()) - ++ if (field2->const_item() || field2_real->const_item()) + return 1; + Item_field *f1= (Item_field *) field1_real; + Item_field *f2= (Item_field *) field2_real; - if (f2->used_tables() & OUTER_REF_TABLE_BIT) - { - outer_ref= 1; - cmp= -1; - } if (f1->used_tables() & OUTER_REF_TABLE_BIT) { - outer_ref= 1; ++ outer_ref= -1; + cmp= -1; + } + if (f2->used_tables() & OUTER_REF_TABLE_BIT) + { outer_ref= 1; cmp++; } diff --cc sql/sql_trigger.cc index daea60c26bc,c4d348ce400..2d1c3e1cafb --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@@ -335,38 -356,6 +335,38 @@@ public }; +Trigger::~Trigger() +{ - delete body; ++ sp_head::destroy(body); +} + + +/** + Call a Table_triggers_list function for all triggers + + @return 0 ok + @return # Something went wrong. Pointer to the trigger that mailfuncted + returned +*/ + +Trigger* Table_triggers_list::for_all_triggers(Triggers_processor func, + void *arg) +{ + for (uint i= 0; i < (uint)TRG_EVENT_MAX; i++) + { + for (uint j= 0; j < (uint)TRG_ACTION_MAX; j++) + { + for (Trigger *trigger= get_trigger(i,j) ; + trigger ; + trigger= trigger->next) + if ((trigger->*func)(arg)) + return trigger; + } + } + return 0; +} + + /** Create or drop trigger for table. diff --cc storage/innobase/buf/buf0dblwr.cc index 93201c3793f,32b4399b41d..d44bfbf2b9e --- a/storage/innobase/buf/buf0dblwr.cc +++ b/storage/innobase/buf/buf0dblwr.cc @@@ -989,9 -960,10 +989,10 @@@ try_again if (buf_dblwr->batch_running) { /* Another thread is running the batch right now. Wait for it to finish. */ - ib_int64_t sig_count = os_event_reset(buf_dblwr->b_event); + int64_t sig_count = os_event_reset(buf_dblwr->b_event); mutex_exit(&buf_dblwr->mutex); + os_aio_simulated_wake_handler_threads(); os_event_wait_low(buf_dblwr->b_event, sig_count); goto try_again; } @@@ -1119,8 -1095,9 +1120,9 @@@ try_again point. The only exception is when a user thread is forced to do a flush batch because of a sync checkpoint. */ - ib_int64_t sig_count = os_event_reset(buf_dblwr->b_event); + int64_t sig_count = os_event_reset(buf_dblwr->b_event); mutex_exit(&buf_dblwr->mutex); + os_aio_simulated_wake_handler_threads(); os_event_wait_low(buf_dblwr->b_event, sig_count); goto try_again;