Skip to content

Commit

Permalink
MDEV-15746 ASAN heap-use-after-free in Item_change_list::rollback_ite…
Browse files Browse the repository at this point in the history
…m_tree_changes on ALTER executed as PS

10.3+ fix

On ALTER TABLE, if a non-changed column default
might need a charset conversion, it must
be a blob. Because blob's defaults ar stored
as expressions, and for any other type
a basic_const_item() will be in the record,
so it'll have correct charset and won't need
converting. For the same reason it makes no
sense to convert blob defaults (and it's
unsafe, see MDEV-15746).

test case is already in main/ps.test
  • Loading branch information
vuvova committed May 11, 2018
1 parent c9717dc commit e19915d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion sql/sql_table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3191,8 +3191,10 @@ bool Column_definition::prepare_stage1_string(THD *thd,
Convert the default value from client character
set into the column character set if necessary.
We can only do this for constants as we have not yet run fix_fields.
But not for blobs, as they will be stored as SQL expressions, not
written down into the record image.
*/
if (default_value &&
if (!(flags & BLOB_FLAG) && default_value &&
default_value->expr->basic_const_item() &&
charset != default_value->expr->collation.collation)
{
Expand Down

0 comments on commit e19915d

Please sign in to comment.