mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-35326: Memory Leak in init_io_cache_ext upon SHUTDOWN
The problems were that: 1) resources was freed "asimetric" normal execution in send_eof, in case of error in destructor. 2) destructor was not called in case of SP for result objects. (so if the last SP execution ended with error resorces was not freeded on reinit before execution (cleanup() called before next execution) and destructor also was not called due to lack of delete call for the object) Result cleanup() renamed to reset_for_next_ps_execution() to better reflect function(). All result method revised and freeing resources made "symetric". Destructor of result object called for SP. Added skipped invalidation in case of error in insert. Removed misleading naming of reset(thd) (could be mixed with with reset()).
This commit is contained in:
@ -5585,7 +5585,8 @@ public:
|
||||
*/
|
||||
virtual int send_data(List<Item> &items)=0;
|
||||
virtual ~select_result_sink() = default;
|
||||
void reset(THD *thd_arg) { thd= thd_arg; }
|
||||
// Used in cursors to initialize and reset
|
||||
void reinit(THD *thd_arg) { thd= thd_arg; }
|
||||
};
|
||||
|
||||
class select_result_interceptor;
|
||||
@ -5659,15 +5660,11 @@ public:
|
||||
*/
|
||||
virtual bool check_simple_select() const;
|
||||
virtual void abort_result_set() {}
|
||||
/*
|
||||
Cleanup instance of this class for next execution of a prepared
|
||||
statement/stored procedure.
|
||||
*/
|
||||
virtual void cleanup();
|
||||
virtual void reset_for_next_ps_execution();
|
||||
void set_thd(THD *thd_arg) { thd= thd_arg; }
|
||||
void reset(THD *thd_arg)
|
||||
void reinit(THD *thd_arg)
|
||||
{
|
||||
select_result_sink::reset(thd_arg);
|
||||
select_result_sink::reinit(thd_arg);
|
||||
unit= NULL;
|
||||
}
|
||||
#ifdef EMBEDDED_LIBRARY
|
||||
@ -5773,9 +5770,9 @@ public:
|
||||
elsewhere. (this is used by ANALYZE $stmt feature).
|
||||
*/
|
||||
void disable_my_ok_calls() { suppress_my_ok= true; }
|
||||
void reset(THD *thd_arg)
|
||||
void reinit(THD *thd_arg)
|
||||
{
|
||||
select_result::reset(thd_arg);
|
||||
select_result::reinit(thd_arg);
|
||||
suppress_my_ok= false;
|
||||
}
|
||||
protected:
|
||||
@ -5827,7 +5824,7 @@ private:
|
||||
{}
|
||||
void reset(THD *thd_arg)
|
||||
{
|
||||
select_result_interceptor::reset(thd_arg);
|
||||
select_result_interceptor::reinit(thd_arg);
|
||||
spvar_list= NULL;
|
||||
field_count= 0;
|
||||
}
|
||||
@ -5871,7 +5868,7 @@ public:
|
||||
void reset(THD *thd_arg, sp_lex_keeper *lex_keeper)
|
||||
{
|
||||
sp_cursor_statistics::reset();
|
||||
result.reset(thd_arg);
|
||||
result.reinit(thd_arg);
|
||||
m_lex_keeper= lex_keeper;
|
||||
server_side_cursor= NULL;
|
||||
}
|
||||
@ -5899,7 +5896,7 @@ public:
|
||||
bool send_eof() override;
|
||||
bool check_simple_select() const override { return FALSE; }
|
||||
void abort_result_set() override;
|
||||
void cleanup() override;
|
||||
void reset_for_next_ps_execution() override;
|
||||
select_result_interceptor *result_interceptor() override { return NULL; }
|
||||
};
|
||||
|
||||
@ -5934,7 +5931,9 @@ public:
|
||||
{ path[0]=0; }
|
||||
~select_to_file();
|
||||
bool send_eof() override;
|
||||
void cleanup() override;
|
||||
void abort_result_set() override;
|
||||
void reset_for_next_ps_execution() override;
|
||||
bool free_recources();
|
||||
};
|
||||
|
||||
|
||||
@ -6011,7 +6010,7 @@ class select_insert :public select_result_interceptor {
|
||||
bool send_eof() override;
|
||||
void abort_result_set() override;
|
||||
/* not implemented: select_insert is never re-used in prepared statements */
|
||||
void cleanup() override;
|
||||
void reset_for_next_ps_execution() override;
|
||||
};
|
||||
|
||||
|
||||
@ -6231,7 +6230,7 @@ public:
|
||||
int delete_record();
|
||||
bool send_eof() override;
|
||||
virtual bool flush();
|
||||
void cleanup() override;
|
||||
void reset_for_next_ps_execution() override;
|
||||
virtual bool create_result_table(THD *thd, List<Item> *column_types,
|
||||
bool is_distinct, ulonglong options,
|
||||
const LEX_CSTRING *alias,
|
||||
@ -6406,9 +6405,10 @@ class select_union_recursive :public select_unit
|
||||
*/
|
||||
List<TABLE_LIST> rec_table_refs;
|
||||
/*
|
||||
The count of how many times cleanup() was called with cleaned==false
|
||||
for the unit specifying the recursive CTE for which this object was created
|
||||
or for the unit specifying a CTE that mutually recursive with this CTE.
|
||||
The count of how many times reset_for_next_ps_execution() was called with
|
||||
cleaned==false for the unit specifying the recursive CTE for which this
|
||||
object was created or for the unit specifying a CTE that mutually
|
||||
recursive with this CTE.
|
||||
*/
|
||||
uint cleanup_count;
|
||||
long row_counter;
|
||||
@ -6427,7 +6427,7 @@ class select_union_recursive :public select_unit
|
||||
bool create_table,
|
||||
bool keep_row_order,
|
||||
uint hidden) override;
|
||||
void cleanup() override;
|
||||
void reset_for_next_ps_execution() override;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -6497,7 +6497,7 @@ public:
|
||||
{
|
||||
result->abort_result_set(); /* purecov: inspected */
|
||||
}
|
||||
void cleanup() override
|
||||
void reset_for_next_ps_execution() override
|
||||
{
|
||||
send_records= 0;
|
||||
}
|
||||
@ -6600,7 +6600,7 @@ public:
|
||||
uint hidden) override;
|
||||
bool init_result_table(ulonglong select_options);
|
||||
int send_data(List<Item> &items) override;
|
||||
void cleanup() override;
|
||||
void reset_for_next_ps_execution() override;
|
||||
ha_rows get_null_count_of_col(uint idx)
|
||||
{
|
||||
DBUG_ASSERT(idx < table->s->fields);
|
||||
@ -6633,7 +6633,7 @@ public:
|
||||
bool mx, bool all):
|
||||
select_subselect(thd_arg, item_arg), cache(0), fmax(mx), is_all(all)
|
||||
{}
|
||||
void cleanup() override;
|
||||
void reset_for_next_ps_execution() override;
|
||||
int send_data(List<Item> &items) override;
|
||||
bool cmp_real();
|
||||
bool cmp_int();
|
||||
@ -7049,7 +7049,7 @@ public:
|
||||
int send_data(List<Item> &items) override;
|
||||
bool send_eof() override;
|
||||
bool check_simple_select() const override;
|
||||
void cleanup() override;
|
||||
void reset_for_next_ps_execution() override;
|
||||
};
|
||||
|
||||
/* Bits in sql_command_flags */
|
||||
|
Reference in New Issue
Block a user