summaryrefslogtreecommitdiff
path: root/sql/sql_class.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_class.cc')
-rw-r--r--sql/sql_class.cc26
1 files changed, 25 insertions, 1 deletions
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 59f82de7013..8672180b66a 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -1497,7 +1497,13 @@ int select_dumpvar::prepare(List<Item> &list, SELECT_LEX_UNIT *u)
{
my_var *mv= gl++;
if (mv->local)
- (void)local_vars.push_back(new Item_splocal(mv->s, mv->offset));
+ {
+ Item_splocal *var;
+ (void)local_vars.push_back(var= new Item_splocal(mv->s, mv->offset));
+#ifndef DBUG_OFF
+ var->owner= mv->owner;
+#endif
+ }
else
{
Item_func_set_user_var *var= new Item_func_set_user_var(mv->s, item);
@@ -1918,6 +1924,7 @@ void THD::restore_backup_open_tables_state(Open_tables_state *backup)
- Value for found_rows() is reset and restored
- examined_row_count is added to the total
- cuted_fields is added to the total
+ - new savepoint level is created and destroyed
NOTES:
Seed for random() is saved for the first! usage of RAND()
@@ -1941,6 +1948,7 @@ void THD::reset_sub_statement_state(Sub_statement_state *backup,
backup->sent_row_count= sent_row_count;
backup->cuted_fields= cuted_fields;
backup->client_capabilities= client_capabilities;
+ backup->savepoints= transaction.savepoints;
if (!lex->requires_prelocking() || is_update_query(lex->sql_command))
options&= ~OPTION_BIN_LOG;
@@ -1953,6 +1961,7 @@ void THD::reset_sub_statement_state(Sub_statement_state *backup,
examined_row_count= 0;
sent_row_count= 0;
cuted_fields= 0;
+ transaction.savepoints= 0;
#ifndef EMBEDDED_LIBRARY
/* Surpress OK packets in case if we will execute statements */
@@ -1963,6 +1972,21 @@ void THD::reset_sub_statement_state(Sub_statement_state *backup,
void THD::restore_sub_statement_state(Sub_statement_state *backup)
{
+ /*
+ To save resources we want to release savepoints which were created
+ during execution of function or trigger before leaving their savepoint
+ level. It is enough to release first savepoint set on this level since
+ all later savepoints will be released automatically.
+ */
+ if (transaction.savepoints)
+ {
+ SAVEPOINT *sv;
+ for (sv= transaction.savepoints; sv->prev; sv= sv->prev)
+ {}
+ /* ha_release_savepoint() never returns error. */
+ (void)ha_release_savepoint(this, sv);
+ }
+ transaction.savepoints= backup->savepoints;
options= backup->options;
in_sub_stmt= backup->in_sub_stmt;
net.no_send_ok= backup->no_send_ok;