SQL: invalidate current SP at archive substitution [closes #127]
Related to #125
This commit is contained in:
parent
5e42511ce1
commit
9062385c20
@ -238,6 +238,10 @@ void sp_cache_flush_obsolete(sp_cache **cp, sp_head **sp)
|
||||
}
|
||||
}
|
||||
|
||||
void sp_cache_flush(sp_cache *cp, sp_head *sp)
|
||||
{
|
||||
cp->remove(sp);
|
||||
}
|
||||
|
||||
/**
|
||||
Return the current global version of the cache.
|
||||
|
@ -62,6 +62,7 @@ void sp_cache_insert(sp_cache **cp, sp_head *sp);
|
||||
sp_head *sp_cache_lookup(sp_cache **cp, sp_name *name);
|
||||
void sp_cache_invalidate();
|
||||
void sp_cache_flush_obsolete(sp_cache **cp, sp_head **sp);
|
||||
void sp_cache_flush(sp_cache *cp, sp_head *sp);
|
||||
ulong sp_cache_version();
|
||||
void sp_cache_enforce_limit(sp_cache *cp, ulong upper_limit_for_elements);
|
||||
|
||||
|
@ -1589,10 +1589,7 @@ sp_head::execute_trigger(THD *thd,
|
||||
goto err_with_cleanup;
|
||||
}
|
||||
|
||||
#ifndef DBUG_OFF
|
||||
nctx->sp= this;
|
||||
#endif
|
||||
|
||||
thd->spcont= nctx;
|
||||
|
||||
err_status= execute(thd, FALSE);
|
||||
@ -1713,9 +1710,7 @@ sp_head::execute_function(THD *thd, Item **argp, uint argcount,
|
||||
*/
|
||||
thd->restore_active_arena(&call_arena, &backup_arena);
|
||||
|
||||
#ifndef DBUG_OFF
|
||||
nctx->sp= this;
|
||||
#endif
|
||||
|
||||
/* Pass arguments. */
|
||||
for (arg_no= 0; arg_no < argcount; arg_no++)
|
||||
@ -1919,9 +1914,7 @@ sp_head::execute_procedure(THD *thd, List<Item> *args)
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
|
||||
#ifndef DBUG_OFF
|
||||
octx->sp= 0;
|
||||
#endif
|
||||
thd->spcont= octx;
|
||||
|
||||
/* set callers_arena to thd, for upper-level function to work */
|
||||
@ -1934,9 +1927,8 @@ sp_head::execute_procedure(THD *thd, List<Item> *args)
|
||||
thd->spcont= save_spcont;
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
#ifndef DBUG_OFF
|
||||
|
||||
nctx->sp= this;
|
||||
#endif
|
||||
|
||||
if (params > 0)
|
||||
{
|
||||
|
@ -176,11 +176,8 @@ public:
|
||||
/// of the client/server protocol.
|
||||
bool end_partial_result_set;
|
||||
|
||||
#ifndef DBUG_OFF
|
||||
/// The stored program for which this runtime context is created. Used for
|
||||
/// checking if correct runtime context is used for variable handling.
|
||||
/// The stored program for which this runtime context is created.
|
||||
sp_head *sp;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// SP-variables.
|
||||
|
@ -5810,6 +5810,11 @@ end_with_restore_list:
|
||||
|
||||
if (do_execute_sp(thd, sp))
|
||||
goto error;
|
||||
|
||||
if (sp->sp_cache_version() == ULONG_MAX)
|
||||
{
|
||||
sp_cache_flush(thd->sp_proc_cache, sp);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1274,21 +1274,10 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
|
||||
bool versioned= table_list->vers_conditions;
|
||||
if (versioned)
|
||||
{
|
||||
String archive_name;
|
||||
DBUG_ASSERT(table_list->vers_conditions == FOR_SYSTEM_TIME_AS_OF);
|
||||
VTMD_table vtmd(*table_list);
|
||||
if (vtmd.find_archive_name(thd, archive_name))
|
||||
if (vtmd.setup_select(thd))
|
||||
goto exit;
|
||||
|
||||
if (archive_name.length() > 0)
|
||||
{
|
||||
archive.init_one_table(table_list->db, table_list->db_length, archive_name.ptr(),
|
||||
archive_name.length(), archive_name.ptr(), TL_READ);
|
||||
|
||||
archive.alias= table_list->table_name;
|
||||
archive.vers_force_alias= true;
|
||||
table_list= &archive;
|
||||
}
|
||||
}
|
||||
|
||||
if (mysqld_show_create_get_fields(thd, table_list, &field_list, &buffer))
|
||||
|
@ -9,6 +9,8 @@
|
||||
#include "sql_show.h"
|
||||
#include "sql_parse.h"
|
||||
#include "sql_lex.h"
|
||||
#include "sp_head.h"
|
||||
#include "sp_rcontext.h"
|
||||
|
||||
LString VERS_VTMD_TEMPLATE(C_STRING_WITH_LEN("vtmd_template"));
|
||||
|
||||
@ -659,5 +661,12 @@ bool VTMD_table::setup_select(THD* thd)
|
||||
DBUG_ASSERT(!about.mdl_request.ticket);
|
||||
about.mdl_request.init(MDL_key::TABLE, about.db, about.table_name,
|
||||
about.mdl_request.type, about.mdl_request.duration);
|
||||
about.vers_force_alias= true;
|
||||
// Since we modified SELECT_LEX::table_list, we need to invalidate current SP
|
||||
if (thd->spcont)
|
||||
{
|
||||
DBUG_ASSERT(thd->spcont->sp);
|
||||
thd->spcont->sp->set_sp_cache_version(ULONG_MAX);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user