-
Igor Solodovnikov authored
Memory leak was caused by prepared statement fields metadata allocated on MYSQL's field_alloc. field_alloc is reset by free_old_query() function but only if mysql->fields is not NULL. In this case memory was allocated by mysql_stmt_prepare() and then free_old_query() was called from mysql_execute() while mysql->fields is NULL. Thus mysql->field_alloc was reset without freeing allocated memory. Fixed by extending cli_read_metadata() function to be able to accept MEM_ROOT pointer. Extended function is cli_read_metadat_ex(). cli_read_metadata() is now simple shell which uses &mysql->field_alloc as a parameter to cli_read_metadata_ex() . cli_read_prepare_result() now uses stmt->mem_root to allocate memory for fields metadata. By the way stmt->mem_root was used in this context before WL#7766 (commit 03149053bf7fb93e841fd68414109b69a4413018). Reviewed-by:
Rafal Somla <rafal.somla@oracle.com> Reviewed-by:
Praveen Hulakund <praveenkumar.hulakund@oracle.com> RB: 8156
Igor Solodovnikov authoredMemory leak was caused by prepared statement fields metadata allocated on MYSQL's field_alloc. field_alloc is reset by free_old_query() function but only if mysql->fields is not NULL. In this case memory was allocated by mysql_stmt_prepare() and then free_old_query() was called from mysql_execute() while mysql->fields is NULL. Thus mysql->field_alloc was reset without freeing allocated memory. Fixed by extending cli_read_metadata() function to be able to accept MEM_ROOT pointer. Extended function is cli_read_metadat_ex(). cli_read_metadata() is now simple shell which uses &mysql->field_alloc as a parameter to cli_read_metadata_ex() . cli_read_prepare_result() now uses stmt->mem_root to allocate memory for fields metadata. By the way stmt->mem_root was used in this context before WL#7766 (commit 03149053bf7fb93e841fd68414109b69a4413018). Reviewed-by:
Rafal Somla <rafal.somla@oracle.com> Reviewed-by:
Praveen Hulakund <praveenkumar.hulakund@oracle.com> RB: 8156
Loading