mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-22441 SCOPE_VALUE macro for temporary values
- Needless engaged_ removed; - SCOPE_VALUE, SCOPE_SET, SCOPE_CLEAR macros for neater declaration; - IF_CLASS / IF_NOT_CLASS SFINAE checkers to pass arg by value or reference; - inline keyword; - couple of refactorings of temporary free_list.
This commit is contained in:
@ -2993,8 +2993,8 @@ void mysql_sql_stmt_execute_immediate(THD *thd)
|
||||
DBUG_VOID_RETURN; // out of memory
|
||||
|
||||
// See comments on thd->free_list in mysql_sql_stmt_execute()
|
||||
Item *free_list_backup= thd->free_list;
|
||||
thd->free_list= NULL;
|
||||
SCOPE_VALUE(thd->free_list, (Item *) NULL);
|
||||
SCOPE_EXIT([thd]() mutable { thd->free_items(); });
|
||||
/*
|
||||
Make sure we call Prepared_statement::execute_immediate()
|
||||
with an empty THD::change_list. It can be non empty as the above
|
||||
@ -3017,8 +3017,6 @@ void mysql_sql_stmt_execute_immediate(THD *thd)
|
||||
Item_change_list_savepoint change_list_savepoint(thd);
|
||||
(void) stmt->execute_immediate(query.str, (uint) query.length);
|
||||
change_list_savepoint.rollback(thd);
|
||||
thd->free_items();
|
||||
thd->free_list= free_list_backup;
|
||||
|
||||
/*
|
||||
stmt->execute_immediately() sets thd->query_string with the executed
|
||||
@ -3578,8 +3576,13 @@ void mysql_sql_stmt_execute(THD *thd)
|
||||
so they don't get freed in case of re-prepare.
|
||||
See MDEV-10702 Crash in SET STATEMENT FOR EXECUTE
|
||||
*/
|
||||
Item *free_list_backup= thd->free_list;
|
||||
thd->free_list= NULL; // Hide the external (e.g. "SET STATEMENT") Items
|
||||
/*
|
||||
Hide and restore at scope exit the "external" (e.g. "SET STATEMENT") Item list.
|
||||
It will be freed normaly in THD::cleanup_after_query().
|
||||
*/
|
||||
SCOPE_VALUE(thd->free_list, (Item *) NULL);
|
||||
// Free items created by execute_loop() at scope exit
|
||||
SCOPE_EXIT([thd]() mutable { thd->free_items(); });
|
||||
/*
|
||||
Make sure we call Prepared_statement::execute_loop() with an empty
|
||||
THD::change_list. It can be non-empty because the above
|
||||
@ -3603,12 +3606,6 @@ void mysql_sql_stmt_execute(THD *thd)
|
||||
|
||||
(void) stmt->execute_loop(&expanded_query, FALSE, NULL, NULL);
|
||||
change_list_savepoint.rollback(thd);
|
||||
thd->free_items(); // Free items created by execute_loop()
|
||||
/*
|
||||
Now restore the "external" (e.g. "SET STATEMENT") Item list.
|
||||
It will be freed normaly in THD::cleanup_after_query().
|
||||
*/
|
||||
thd->free_list= free_list_backup;
|
||||
|
||||
stmt->lex->restore_set_statement_var();
|
||||
DBUG_VOID_RETURN;
|
||||
|
Reference in New Issue
Block a user