[MDEV-12586] ALTER TABLE…ALGORITHM=INPLACE fails with non-constant DEFAULT values Created: 2017-04-25 Updated: 2017-08-16 Resolved: 2017-05-08 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - InnoDB |
| Affects Version/s: | 10.2, 10.3 |
| Fix Version/s: | 10.2.6, 10.3.1 |
| Type: | Bug | Priority: | Major |
| Reporter: | Sergey Vojtovich | Assignee: | Marko Mäkelä |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | 10.2-ga | ||
| Issue Links: |
|
||||||||||||||||
| Description |
|
Apparently InnoDB doesn't copy blob data during online ALTER TABLE. In a meanwhile it calls innobase_rec_reset(), which may reallocate memory for blobs. It wasn't a problem before column compression was introduced, since in most (if not all) cases memory reallocation was not needed. With compressed columns reallocation is always there. Grep for Test not involving column compression:
|
| Comments |
| Comment by Marko Mäkelä [ 2017-04-27 ] | ||||||||||||||||||
|
For the record: | ||||||||||||||||||
| Comment by Michael Widenius [ 2017-05-06 ] | ||||||||||||||||||
|
The issue is not only with compressed fields, but with any fields that has a default that is not constant Here is an example for this: create or replace table t1 (a int auto_increment primary key, b int) engine=myisam; Innodb result is:
--
-- While MYISAM gives the right result:
--
-- The problem is that InnoDB only calls set_default() only once, when it should call it for every row for fields with "field->default_value" set. | ||||||||||||||||||
| Comment by Marko Mäkelä [ 2017-05-06 ] | ||||||||||||||||||
|
I think that we need a quick solution before the 10.2 GA release: simply refuse ALGORITHM=INPLACE if there are any non-constant DEFAULT values for added columns. Fixing this is somewhat tricky, because InnoDB would need to convert each row to MySQL format for evaluating the non-constant default values. Currently InnoDB uses a ‘default record’ of constant values that it will substitute for added columns. | ||||||||||||||||||
| Comment by Sergey Vojtovich [ 2017-05-06 ] | ||||||||||||||||||
|
I believe there're 2 different issues:
| ||||||||||||||||||
| Comment by Marko Mäkelä [ 2017-05-08 ] | ||||||||||||||||||
|
The fix to In ADD COLUMN as well as when changing a NULL column to NOT NULL, we must currently reject ALGORITHM=INPLACE when the DEFAULT expression is not a constant. | ||||||||||||||||||
| Comment by Marko Mäkelä [ 2017-05-08 ] | ||||||||||||||||||
| Comment by Jan Lindström (Inactive) [ 2017-05-08 ] | ||||||||||||||||||
|
ok to push after test is repeatable. | ||||||||||||||||||
| Comment by Sergey Vojtovich [ 2017-05-08 ] | ||||||||||||||||||
|
marko, I appreciate your effort fixing this bug. But this task was created to reference issue found during column compression implementation, which I worked around by disabling INPLACE for compressed columns. Original goal of this task was to support INPLACE for compressed columns. I understand that it revealed another more serious issue, which was also worked around by disabling INPLACE for non-const DEFAULT. But now we have no open task neither for compressed columns nor for non-const DEFAULT to support INPLACE. I think it is not fair. |