Skip to content

Commit

Permalink
Merge branch '10.1' into 10.2
Browse files Browse the repository at this point in the history
# Conflicts:
#	sql/sp_head.cc
#	sql/sql_select.cc
#	sql/sql_trigger.cc
  • Loading branch information
spetrunia committed Jan 16, 2020
2 parents bb8226d + bde7e0b commit b044294
Show file tree
Hide file tree
Showing 14 changed files with 63 additions and 63 deletions.
3 changes: 2 additions & 1 deletion sql/item_func.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ Item_args::Item_args(THD *thd, const Item_args *other)
arg_count= 0;
return;
}
memcpy(args, other->args, sizeof(Item*) * arg_count);
if (arg_count)
memcpy(args, other->args, sizeof(Item*) * arg_count);
}


Expand Down
2 changes: 1 addition & 1 deletion sql/sp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ static sp_head *sp_compile(THD *thd, String *defstr, sql_mode_t sql_mode,
if (parse_sql(thd, & parser_state, creation_ctx) || thd->lex == NULL)
{
sp= thd->lex->sphead;
delete sp;
sp_head::destroy(sp);
sp= 0;
}
else
Expand Down
2 changes: 1 addition & 1 deletion sql/sp_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ uchar *hash_get_key_for_sp_head(const uchar *ptr, size_t *plen,
void hash_free_sp_head(void *p)
{
sp_head *sp= (sp_head *)p;
delete sp;
sp_head::destroy(sp);
}


Expand Down
63 changes: 27 additions & 36 deletions sql/sp_head.cc
Original file line number Diff line number Diff line change
Expand Up @@ -532,51 +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;
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),
Expand All @@ -585,6 +574,8 @@ sp_head::sp_head()
m_next_cached_sp(0),
m_cont_level(0)
{
mem_root= &main_mem_root;

m_first_instance= this;
m_first_free_instance= this;
m_last_cached_sp= this;
Expand Down Expand Up @@ -831,7 +822,7 @@ sp_head::~sp_head()
my_hash_free(&m_sptabs);
my_hash_free(&m_sroutines);

delete m_next_cached_sp;
sp_head::destroy(m_next_cached_sp);

DBUG_VOID_RETURN;
}
Expand Down
17 changes: 9 additions & 8 deletions sql/sp_head.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class sp_name : public Sql_alloc
bool
check_routine_name(LEX_STRING *ident);

class sp_head :private Query_arena
class sp_head :private Query_arena, public Sql_alloc
{
sp_head(const sp_head &); /**< Prevent use of these */
void operator=(sp_head &);
Expand Down Expand Up @@ -298,14 +298,16 @@ class sp_head :private Query_arena
being opened is probably enough).
*/
SQL_I_List<Item_trigger_field> m_trg_table_fields;
private:
// users must use sp= sp_head::create()
sp_head(MEM_ROOT *mem_root_arg);

static void *
operator new(size_t size) throw ();

static void
operator delete(void *ptr, size_t size) throw ();
// users must use sp_head::destroy(sp)
virtual ~sp_head();

sp_head();
public:
static sp_head* create();
static void destroy(sp_head *sp);

/// Initialize after we have reset mem_root
void
Expand All @@ -323,7 +325,6 @@ class sp_head :private Query_arena
void
set_stmt_end(THD *thd);

virtual ~sp_head();

bool
execute_trigger(THD *thd,
Expand Down
4 changes: 2 additions & 2 deletions sql/sql_lex.cc
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ void lex_end_stage1(LEX *lex)
}
else
{
delete lex->sphead;
sp_head::destroy(lex->sphead);
lex->sphead= NULL;
}

Expand Down Expand Up @@ -2843,7 +2843,7 @@ void LEX::cleanup_lex_after_parse_error(THD *thd)
if (thd->lex->sphead)
{
thd->lex->sphead->restore_thd_mem_root(thd);
delete thd->lex->sphead;
sp_head::destroy(thd->lex->sphead);
thd->lex->sphead= NULL;
}
}
Expand Down
2 changes: 1 addition & 1 deletion sql/sql_parse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4862,7 +4862,7 @@ mysql_execute_command(THD *thd)
/* Don't do it, if we are inside a SP */
if (!thd->spcont)
{
delete lex->sphead;
sp_head::destroy(lex->sphead);
lex->sphead= NULL;
}
/* lex->unit.cleanup() is called outside, no need to call it here */
Expand Down
2 changes: 1 addition & 1 deletion sql/sql_prepare.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3877,7 +3877,7 @@ Prepared_statement::~Prepared_statement()
free_items();
if (lex)
{
delete lex->sphead;
sp_head::destroy(lex->sphead);
delete lex->result;
delete (st_lex_local *) lex;
}
Expand Down
13 changes: 8 additions & 5 deletions sql/sql_select.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13863,15 +13863,18 @@ static int compare_fields_by_table_order(Item *field1,
{
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() || 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 (f1->used_tables() & OUTER_REF_TABLE_BIT)
{
outer_ref= 1;
outer_ref= -1;
cmp= -1;
}
if (f2->used_tables() & OUTER_REF_TABLE_BIT)
Expand Down
6 changes: 3 additions & 3 deletions sql/sql_show.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5994,7 +5994,7 @@ bool store_schema_params(THD *thd, TABLE *table, TABLE *proc_table,
{
free_table_share(&share);
if (free_sp_head)
delete sp;
sp_head::destroy(sp);
DBUG_RETURN(1);
}
}
Expand Down Expand Up @@ -6045,7 +6045,7 @@ bool store_schema_params(THD *thd, TABLE *table, TABLE *proc_table,
}
}
if (free_sp_head)
delete sp;
sp_head::destroy(sp);
}
free_table_share(&share);
DBUG_RETURN(error);
Expand Down Expand Up @@ -6131,7 +6131,7 @@ bool store_schema_proc(THD *thd, TABLE *table, TABLE *proc_table,
store_column_type(table, field, cs, 5);
free_table_share(&share);
if (free_sp_head)
delete sp;
sp_head::destroy(sp);
}
}

Expand Down
2 changes: 1 addition & 1 deletion sql/sql_trigger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ class Deprecated_trigger_syntax_handler : public Internal_error_handler

Trigger::~Trigger()
{
delete body;
sp_head::destroy(body);
}


Expand Down
2 changes: 1 addition & 1 deletion sql/sql_yacc.yy
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ static sp_head *make_sp_head(THD *thd, sp_name *name,
sp_head *sp;

/* Order is important here: new - reset - init */
if ((sp= new sp_head()))
if ((sp= sp_head::create()))
{
sp->reset_thd_mem_root(thd);
sp->init(lex);
Expand Down
4 changes: 3 additions & 1 deletion storage/innobase/buf/buf0dblwr.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*****************************************************************************

Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2013, 2019, MariaDB Corporation.
Copyright (c) 2013, 2020, MariaDB Corporation.

This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Expand Down Expand Up @@ -992,6 +992,7 @@ buf_dblwr_flush_buffered_writes()
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;
}
Expand Down Expand Up @@ -1121,6 +1122,7 @@ buf_dblwr_add_to_batch(
checkpoint. */
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;
Expand Down
4 changes: 3 additions & 1 deletion storage/xtradb/buf/buf0dblwr.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*****************************************************************************

Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2013, 2019, MariaDB Corporation.
Copyright (c) 2013, 2020, MariaDB Corporation.

This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Expand Down Expand Up @@ -963,6 +963,7 @@ buf_dblwr_flush_buffered_writes(void)
ib_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;
}
Expand Down Expand Up @@ -1112,6 +1113,7 @@ buf_dblwr_add_to_batch(
checkpoint. */
ib_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;
Expand Down

0 comments on commit b044294

Please sign in to comment.