diff --git a/sql/item.h b/sql/item.h index 22eb0c08e2d..31d501dc5c3 100644 --- a/sql/item.h +++ b/sql/item.h @@ -470,6 +470,13 @@ public: my_string name; /* Name from select */ /* Original item name (if it was renamed)*/ my_string orig_name; + /** + Intrusive list pointer for free list. If not null, points to the next + Item on some Query_arena's free list. For instance, stored procedures + have their own Query_arena's. + + @see Query_arena::free_list + */ Item *next; uint32 max_length; uint name_length; /* Length of name */ diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 807d6c09a46..d0a4fff442f 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1411,8 +1411,10 @@ end: } - /* This works because items are allocated with sql_alloc() */ - +/** + This works because items are allocated with sql_alloc(). + @note The function also handles null pointers (empty list). +*/ void cleanup_items(Item *item) { DBUG_ENTER("cleanup_items"); diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 35ae0febcec..8d666c771ec 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -908,8 +908,9 @@ reopen_tables: items from 'fields' list, so the cleanup above is necessary to. */ cleanup_items(thd->free_list); - + cleanup_items(thd->stmt_arena->free_list); close_tables_for_reopen(thd, &table_list); + goto reopen_tables; }