[MDEV-13238] Dynamic columns are corrupted by COLUMN_ADD when value goes out of bounds Created: 2017-07-03 Updated: 2018-03-29 Resolved: 2017-07-04 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Dynamic Columns |
| Affects Version/s: | 10.0, 10.1, 10.2 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Major |
| Reporter: | Elena Stepanova | Assignee: | Oleksandr Byelkin |
| Resolution: | Not a Bug | Votes: | 0 |
| Labels: | None | ||
| Description |
|
All contents of a blob containing dynamic columns can be easily corrupted by simply adding a value, when the field length is exceeded.
Here in the test case the maximum length of the blob is 255 symbols.
The last UPDATE should just fail, but not touch the existing value. Note: the same result can be achieved by 2 columns, I intentionally made it 3-step to show that the current logic is capable of truncating a value in some circumstances but not other. |
| Comments |
| Comment by Oleksandr Byelkin [ 2017-07-04 ] | ||||
|
It would be a bug is there was no warning, otherwise it is expected behaviour. | ||||
| Comment by Elena Stepanova [ 2017-07-04 ] | ||||
|
I disagree. Warning is meant to warn people from causing harm. This warning comes too late, the value is already corrupt, and there is no way to get it back. I mean the whole value, all previously existed dynamic columns, not just the one that you tried to add. It's like, for example, if you try to insert a row with a too long value into a table, it would throw a warning "the value is truncated", but after that the whole table would go corrupt and not readable anymore. It cannot possibly be expected behavior. | ||||
| Comment by Oleksandr Byelkin [ 2017-07-04 ] | ||||
|
When a string written to the field which can not fit it also (HURROR!!!) first damaged/corrupted (truncated) then written in this malformed state, then warning issued. What is the difference? Why dynamic column function should behave differently from concat or repeat? | ||||
| Comment by Oleksandr Byelkin [ 2017-07-04 ] | ||||
|
BTW field have no idea which function result is the string it store, and it is better to keep it so. | ||||
| Comment by Oleksandr Byelkin [ 2017-07-04 ] | ||||
|
set sql_mode=''; | ||||
| Comment by Clark Merchant [ 2018-03-28 ] | ||||
|
I am the author of the closed issue The default method for creating a Dynamic Column as per the documentation is to use a blob, which as far as I know has a 65535 byte max size. From the documentation:
While we need to investigate further to see if Is the recommended point of action in this case to simply change the dynamic columns to be MEDIUMBLOB or LARGEBLOB when they are created, to ensure we don't hit this limit? Are there drawbacks to this? And a related question, the limitations of dynamic columns are stated in the documentation to be "Max number of columns"=65535. Is that related at all to the fact that the documentation example is using a blob (which has a max size of 65535), or is this 65535 limit unrelated? My guess is that it's unrelated, but it's worthwhile to ask. If it indeed is prudent for us to update all dynamic columns to MEDIUMBLOB or larger, we will definitely do so. | ||||
| Comment by Oleksandr Byelkin [ 2018-03-29 ] | ||||
|
Please check warnings and you will see that data was truncated. |