1
0
mirror of https://github.com/MariaDB/server.git synced 2025-11-28 17:36:30 +03:00
Files
mariadb/mysql-test/suite/innodb/r/instant_alter_extend.result
Marko Mäkelä 2c74799d64 MDEV-18627 Wrong result after instant size change of integer
If we instantly change the size of a fixed-length field
and treat it as kind-of variable-length, then we will need
conversions between old column values and new ones.

I tried adding such a conversion to row_build(), but then I
noticed that more conversions would be needed, because
old values still appeared in a freshly rebuilt secondary index,
causing a mismatch when trying to search with the correct
longer value that was converted in my provisional fix to row_build().

So, we will revert the essential part of
MDEV-15563: Instant ROW_FORMAT=REDUNDANT column extension
(commit 22feb179ae), but not
remove any tests.
2019-02-18 18:30:01 +02:00

306 lines
8.5 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#
# MDEV-15563: Instant ROW_FORMAT=REDUNDANT column type change&extension
# (reverted in MDEV-18627)
#
create or replace database test;
use test;
set default_storage_engine=innodb;
set @bigval= repeat('0123456789', 30);
create or replace procedure check_table(table_name varchar(255))
begin
select table_id into @table_id
from information_schema.innodb_sys_tables
where name = concat('test/', table_name);
select name, mtype, hex(prtype) as prtype, len
from information_schema.innodb_sys_columns
where table_id = @table_id;
end~~
# VARCHAR -> CHAR, VARBINARY -> BINARY conversion
set @bigval= repeat('0123456789', 20);
create or replace table t (a varchar(300));
alter table t modify a char(255), algorithm=instant;
ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: Cannot change column type INPLACE. Try ALGORITHM=COPY
alter table t modify a char(255), algorithm=copy;
create or replace table t (a varchar(200));
insert into t values (@bigval);
insert into t values ('z');
alter table t modify a char(200);
affected rows: 2
info: Records: 2 Duplicates: 0 Warnings: 0
select count(a) from t where a = @bigval;
count(a)
1
select a, length(a) from t where a = 'z';
a length(a)
z 1
check table t extended;
Table Op Msg_type Msg_text
test.t check status OK
call check_table('t');
name mtype prtype len
a 2 800FE 200
# CHAR enlargement
alter table t modify a char(220);
affected rows: 2
info: Records: 2 Duplicates: 0 Warnings: 0
select count(a) from t where a = @bigval;
count(a)
1
select a, length(a) from t where a = 'z';
a length(a)
z 1
check table t extended;
Table Op Msg_type Msg_text
test.t check status OK
call check_table('t');
name mtype prtype len
a 2 800FE 220
# Convert from VARCHAR to a bigger CHAR
alter table t modify a varchar(200);
affected rows: 2
info: Records: 2 Duplicates: 0 Warnings: 0
alter table t modify a char(255);
affected rows: 2
info: Records: 2 Duplicates: 0 Warnings: 0
select count(a) from t where a = @bigval;
count(a)
1
select a, length(a) from t where a = 'z';
a length(a)
z 1
select * from t;
a
01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
z
check table t extended;
Table Op Msg_type Msg_text
test.t check status OK
call check_table('t');
name mtype prtype len
a 2 800FE 255
# BINARY/VARBINARY test
create or replace table t (a varbinary(300));
insert into t values(NULL);
alter table t modify a binary(255);
affected rows: 1
info: Records: 1 Duplicates: 0 Warnings: 0
create or replace table t (a varbinary(200));
insert into t values (@bigval);
insert into t values ('z');
alter table t modify a binary(200);
affected rows: 2
info: Records: 2 Duplicates: 0 Warnings: 0
select count(a) from t where a = @bigval;
count(a)
1
select length(a) from t where left(a, 1) = 'z';
length(a)
200
check table t extended;
Table Op Msg_type Msg_text
test.t check status OK
call check_table('t');
name mtype prtype len
a 3 3F04FE 200
# BINARY enlargement
alter table t modify a binary(220);
affected rows: 2
info: Records: 2 Duplicates: 0 Warnings: 0
check table t extended;
Table Op Msg_type Msg_text
test.t check status OK
call check_table('t');
name mtype prtype len
a 3 3F04FE 220
# Convert from VARBINARY to a bigger BINARY
alter table t modify a varbinary(220);
affected rows: 2
info: Records: 2 Duplicates: 0 Warnings: 0
alter table t modify a binary(255);
affected rows: 2
info: Records: 2 Duplicates: 0 Warnings: 0
select count(a) from t where a = @bigval;
count(a)
0
select a, length(a) from t where a = 'z';
a length(a)
select * from t;
a
01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
z
check table t extended;
Table Op Msg_type Msg_text
test.t check status OK
call check_table('t');
name mtype prtype len
a 3 3F04FE 255
# Integer conversions
create or replace table t (x tinyint);
insert into t values (127);
alter table t modify x smallint;
affected rows: 1
info: Records: 1 Duplicates: 0 Warnings: 0
select * from t;
x
127
check table t extended;
Table Op Msg_type Msg_text
test.t check status OK
call check_table('t');
name mtype prtype len
x 6 402 2
update t set x= 32767;
alter table t modify x mediumint;
affected rows: 1
info: Records: 1 Duplicates: 0 Warnings: 0
select * from t;
x
32767
check table t extended;
Table Op Msg_type Msg_text
test.t check status OK
call check_table('t');
name mtype prtype len
x 6 409 3
update t set x= 8388607;
alter table t modify x int;
affected rows: 1
info: Records: 1 Duplicates: 0 Warnings: 0
select * from t;
x
8388607
check table t extended;
Table Op Msg_type Msg_text
test.t check status OK
call check_table('t');
name mtype prtype len
x 6 403 4
update t set x= 2147483647;
alter table t modify x bigint;
affected rows: 1
info: Records: 1 Duplicates: 0 Warnings: 0
select * from t;
x
2147483647
check table t extended;
Table Op Msg_type Msg_text
test.t check status OK
call check_table('t');
name mtype prtype len
x 6 408 8
# Check IMPORT TABLESPACE
create or replace table t2 (x int);
alter table t2 discard tablespace;
create or replace table t1 (x tinyint);
insert into t1 set x= 42;
alter table t1 modify x int;
flush tables t1 for export;
unlock tables;
alter table t2 import tablespace;
select * from t2;
x
42
check table t2 extended;
Table Op Msg_type Msg_text
test.t2 check status OK
call check_table('t2');
name mtype prtype len
x 6 403 4
# Check innobase_col_to_mysql() len < flen
create or replace table t1 (x mediumint);
insert into t1 values (1);
insert into t1 values (1);
alter table t1 add column y int first, modify x int;
affected rows: 2
info: Records: 2 Duplicates: 0 Warnings: 0
alter table t1 add column z int first, add primary key (x);
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
# Check assertion in wrong instant operation
create or replace table t1 (a varchar(26) not null) default character set utf8mb4;
insert into t1 values ('abcdef'), (repeat('x',26));
alter ignore table t1 modify a varchar(25) not null;
affected rows: 2
info: Records: 2 Duplicates: 0 Warnings: 1
Warnings:
Warning 1265 Data truncated for column 'a' at row 2
select * from t1;
a
abcdef
xxxxxxxxxxxxxxxxxxxxxxxxx
# Check row_mysql_store_col_in_innobase_format()
create or replace table t1(x int primary key, a varchar(20));
insert into t1 (x) values (1);
update t1 set a= 'foo' where x = 2;
#
# MDEV-18124 PK on inplace-enlarged type fails
#
create or replace table t1 (x int, y int);
insert into t1 (x, y) values (11, 22);
alter table t1 modify x bigint;
affected rows: 1
info: Records: 1 Duplicates: 0 Warnings: 0
alter table t1 add primary key (x);
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
select * from t1;
x y
11 22
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
create or replace table t1 (a varchar(10), y int);
insert into t1 (a, y) values ("0123456789", 33);
alter table t1 modify a char(15);
affected rows: 1
info: Records: 1 Duplicates: 0 Warnings: 0
alter table t1 add primary key (a);
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
select * from t1;
a y
0123456789 33
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
create or replace table t1 (x int primary key, y int);
insert into t1 (x, y) values (44, 55);
alter table t1 modify x bigint;
affected rows: 1
info: Records: 1 Duplicates: 0 Warnings: 0
select * from t1;
x y
44 55
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
create or replace table t1 (x int primary key, y int);
insert into t1 values (66, 77);
alter table t1 add column z int;
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
alter table t1 drop column y;
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
select * from t1;
x z
66 NULL
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
create or replace table t1 (x integer, a varchar(20));
insert into t1 (x, a) values (73, 'a');
affected rows: 1
alter table t1 add index idx3 (a);
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
alter table t1 modify a char(20);
affected rows: 1
info: Records: 1 Duplicates: 0 Warnings: 0
select * from t1;
x a
73 a
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
create or replace database test charset latin1;