[MDEV-558] DNAMES: Adding a column with a too long name corrupts previously inserted data Created: 2012-09-27  Updated: 2012-09-28  Resolved: 2012-09-28

Status: Closed
Project: MariaDB Server
Component/s: None
Affects Version/s: None
Fix Version/s: 10.0.1

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Oleksandr Byelkin
Resolution: Not a Bug Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-377 Name support for dynamic columns Closed

 Description   

First, we insert a value into column col1 (and check that it's inserted correctly). Then we add a column with a long name, and expectedly get a warning about truncated data. But then we try to read the value of 'col1' again and find out that it's not the same as it used to be.

drop table if exists t1;
CREATE TABLE t1 (f1 tinyblob);
INSERT INTO t1 VALUES (COLUMN_CREATE('col1', REPEAT('a',30)));
select column_get(f1,'col1' as char(30)) from t1;
# +-----------------------------------+
# | column_get(f1,'col1' as char(30)) |
# +-----------------------------------+
# | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa    |
# +-----------------------------------+
 
UPDATE t1 SET f1 = COLUMN_ADD( f1, REPEAT('c',211), 'val3' );
show warnings;
# +---------+------+-----------------------------------------+
# | Level   | Code | Message                                 |
# +---------+------+-----------------------------------------+
# | Warning | 1265 | Data truncated for column 'f1' at row 1 |
# +---------+------+-----------------------------------------+
 
select column_get(f1,'col1' as char(30)) from t1;
# +-----------------------------------+
# | column_get(f1,'col1' as char(30)) |
# +-----------------------------------+
# | aaaaaaaaaaaaaaaaaaaaaaaa¦¦¦¦¦¦          |
# +-----------------------------------+
 
 select column_get(f1,'col1' as char(30)) = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' as test from t1; 
# +------+
# | test |
# +------+
# |    0 |
# +------+

Test case (same as above, but only essential commands)

drop table if exists t1;
CREATE TABLE t1 (f1 tinyblob);
INSERT INTO t1 VALUES (COLUMN_CREATE('col1', REPEAT('a',30)));
UPDATE t1 SET f1 = COLUMN_ADD( f1, REPEAT('c',211), 'val3' );
select column_get(f1,'col1' as char(30)) from t1;



 Comments   
Comment by Oleksandr Byelkin [ 2012-09-28 ]

It is expected behavior - tyniblob can be 256 bytes max, so the string was cut (see warning) and so corrupted.

Generated at Thu Feb 08 06:29:38 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.