diff options
author | Aleksey Midenkov <midenok@gmail.com> | 2017-09-29 17:51:10 +0300 |
---|---|---|
committer | Aleksey Midenkov <midenok@gmail.com> | 2017-09-29 17:52:07 +0300 |
commit | 9062385c20b62a7231b256f3f7af44ea9b1f5ad9 (patch) | |
tree | ef3dbec0b5543230b352955107fbb59ac4650396 | |
parent | 5e42511ce169d6883499d00072c309647f303aee (diff) | |
download | mariadb-git-9062385c20b62a7231b256f3f7af44ea9b1f5ad9.tar.gz |
SQL: invalidate current SP at archive substitution [closes #127]
Related to #125
-rw-r--r-- | sql/sp_cache.cc | 4 | ||||
-rw-r--r-- | sql/sp_cache.h | 1 | ||||
-rw-r--r-- | sql/sp_head.cc | 10 | ||||
-rw-r--r-- | sql/sp_rcontext.h | 5 | ||||
-rw-r--r-- | sql/sql_parse.cc | 5 | ||||
-rw-r--r-- | sql/sql_show.cc | 13 | ||||
-rw-r--r-- | sql/vtmd.cc | 9 |
7 files changed, 22 insertions, 25 deletions
diff --git a/sql/sp_cache.cc b/sql/sp_cache.cc index b80cde335db..634a084d1fb 100644 --- a/sql/sp_cache.cc +++ b/sql/sp_cache.cc @@ -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. diff --git a/sql/sp_cache.h b/sql/sp_cache.h index b21d4c4bf25..c776df263ce 100644 --- a/sql/sp_cache.h +++ b/sql/sp_cache.h @@ -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); diff --git a/sql/sp_head.cc b/sql/sp_head.cc index f470ca3f283..d3310578225 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -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) { diff --git a/sql/sp_rcontext.h b/sql/sp_rcontext.h index 98464518787..a5e5df407ca 100644 --- a/sql/sp_rcontext.h +++ b/sql/sp_rcontext.h @@ -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. diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 69938946678..2541ecb1c53 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -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; } diff --git a/sql/sql_show.cc b/sql/sql_show.cc index eb5bcc300bf..5f407e728e1 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -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)) diff --git a/sql/vtmd.cc b/sql/vtmd.cc index 1ed9014331c..2821b2226c7 100644 --- a/sql/vtmd.cc +++ b/sql/vtmd.cc @@ -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; } |