[MDEV-24582] INSERT silently truncates too long value for a virtual column without warnings or errors Created: 2021-01-13 Updated: 2023-04-27 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | Data Manipulation - Insert, Virtual Columns |
| Affects Version/s: | 5.5, 10.1, 10.2, 10.3, 10.4, 10.5 |
| Fix Version/s: | 10.4, 10.5 |
| Type: | Bug | Priority: | Major |
| Reporter: | Elena Stepanova | Assignee: | Nikita Malyavin |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Description |
|
Reproducible on all of 5.5-10.6. The expected result would be a warning with non-strict SQL mode and an error with the strict mode. MySQL does exactly that:
|
| Comments |
| Comment by Elena Stepanova [ 2021-09-19 ] | ||||||||||||||||||||
|
A similar problem can be observed upon ALTER which, for example, adds a virtual column of a too short length. With certain ALTER algorithms it succeeds without warnings and truncates the values. Example:
With ALTER algorithm COPY it fails as expected:
| ||||||||||||||||||||
| Comment by Masashi Tomooka [ 2022-06-03 ] | ||||||||||||||||||||
|
Hi @Nikita Malyavin, I'm Masashi, a community contributor wannabe for MariaDB, and now trying to solve this issue with @nayuta-yanagisawa. Basically we want to compare 1. column maximal length defined in DDL and 2. computed value length of a virtual column, and if 2 exceeds 1, we raise error or warning according to strict mode. The question is, do you think the above approach reasonable? After this fix, we'll have additional computation overhead on every INSERT query. Is it acceptable? Thanks! | ||||||||||||||||||||
| Comment by Nayuta Yanagisawa (Inactive) [ 2022-06-06 ] | ||||||||||||||||||||