1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

PS and SP made compatible in mechanism used for preparing query for rexecutions (Bug #2266)

mysql-test/r/sp.result:
  test suite for Bug #2266
mysql-test/t/sp.test:
  test suite for Bug #2266
sql/item_subselect.cc:
  made ancestor for Statement (Item_arena)
sql/item_subselect.h:
  made ancestor for Statement (Item_arena)
sql/item_sum.cc:
  made ancestor for Statement (Item_arena)
sql/item_sum.h:
  made ancestor for Statement (Item_arena)
sql/mysql_priv.h:
  reset_stmt_for_execute use PS and SP
sql/sp_head.cc:
  sp_head use Item_arena as ancestor to be PS cleunup compatible
  SP use PS storing/restoring/cleanup mechanisms
  cleanup() of SP Items added
  Items created in temporary memory pool during SP execution saved for normal freeing after SP execution
sql/sp_head.h:
  sp_head use Item_arena
sql/sql_base.cc:
  made ancestor for Statement (Item_arena)
  results of wild_setup made permanent
  setup_conds make natural joins expanding only once and store results in PS/SP memory
sql/sql_class.cc:
  made ancestor for Statement (Item_arena)
sql/sql_class.h:
  made ancestor for Statement (Item_arena)
  method to detect PS preparation added
sql/sql_delete.cc:
  storing where for DELETE and mark first execution
sql/sql_derived.cc:
  use method
sql/sql_insert.cc:
  mark first execution for INSERT
sql/sql_lex.cc:
  flags to correctly make transformations of query and storing them in memory of PS/SP
  made ancestor for Statement (Item_arena)
sql/sql_lex.h:
  reved variable od SP ol saving data
  flags to correctly make transformations of query and storing them in memory of PS/SP
sql/sql_parse.cc:
  cleunup unit for any query
sql/sql_prepare.cc:
  made ancestor for Statement (Item_arena)
  storing where moved to preparation
  changed interface of reset_stmt_for_execute to use it is SP
  do not restore where/order by/group by before first execution (but tables and unit can be chenged without execution and should be prepared (subqueries executes on demand))
sql/sql_select.cc:
  storing where for SELECT/multi-DELETE/... and mark first execution
sql/sql_union.cc:
  made ancestor for Statement (Item_arena)
sql/sql_update.cc:
  storing where for UPDATE and mark first execution
This commit is contained in:
unknown
2004-05-20 02:02:49 +03:00
parent 8d18ae3986
commit 16227c28e6
22 changed files with 306 additions and 275 deletions

View File

@ -86,7 +86,7 @@ extern "C" void free_user_var(user_var_entry *entry)
** Thread specific functions
****************************************************************************/
THD::THD():user_time(0), current_statement(0), is_fatal_error(0),
THD::THD():user_time(0), current_arena(0), is_fatal_error(0),
last_insert_id_used(0),
insert_id_used(0), rand_used(0), in_lock_tables(0),
global_read_lock(0), bootstrap(0), spcont(NULL)
@ -1210,24 +1210,48 @@ int select_dumpvar::prepare(List<Item> &list, SELECT_LEX_UNIT *u)
}
/*
Statement functions
*/
Statement::Statement(THD *thd)
:id(++thd->statement_id_counter),
set_query_id(1),
allow_sum_func(0),
lex(&main_lex),
query(0),
query_length(0),
free_list(0)
Item_arena::Item_arena(THD* thd)
:free_list(0)
{
init_sql_alloc(&mem_root,
thd->variables.query_alloc_block_size,
thd->variables.query_prealloc_size);
}
Item_arena::Item_arena()
:free_list(0)
{
bzero((char *) &mem_root, sizeof(mem_root));
}
Item_arena::Item_arena(bool init_mem_root)
:free_list(0)
{
if (init_mem_root)
bzero((char *) &mem_root, sizeof(mem_root));
}
Item_arena::~Item_arena()
{}
/*
Statement functions
*/
Statement::Statement(THD *thd)
:Item_arena(thd),
id(++thd->statement_id_counter),
set_query_id(1),
allow_sum_func(0),
lex(&main_lex),
query(0),
query_length(0)
{}
/*
This constructor is called when statement is a subobject of THD:
Some variables are initialized in THD::init due to locking problems
@ -1235,15 +1259,14 @@ Statement::Statement(THD *thd)
*/
Statement::Statement()
:id(0),
:Item_arena(),
id(0),
set_query_id(1),
allow_sum_func(0), /* initialized later */
lex(&main_lex),
query(0), /* these two are set */
query_length(0), /* in alloc_query() */
free_list(0)
query_length(0) /* in alloc_query() */
{
bzero((char *) &mem_root, sizeof(mem_root));
}
@ -1264,14 +1287,14 @@ void Statement::set_statement(Statement *stmt)
}
void Statement::set_n_backup_item_arena(Statement *set, Statement *backup)
void Item_arena::set_n_backup_item_arena(Item_arena *set, Item_arena *backup)
{
backup->set_item_arena(this);
set_item_arena(set);
}
void Statement::restore_backup_item_arena(Statement *set, Statement *backup)
void Item_arena::restore_backup_item_arena(Item_arena *set, Item_arena *backup)
{
set->set_item_arena(this);
set_item_arena(backup);
@ -1279,7 +1302,7 @@ void Statement::restore_backup_item_arena(Statement *set, Statement *backup)
init_alloc_root(&backup->mem_root, 0, 0);
}
void Statement::set_item_arena(Statement *set)
void Item_arena::set_item_arena(Item_arena *set)
{
mem_root= set->mem_root;
free_list= set->free_list;