Commit a418c992 authored by Sergei Golubchik's avatar Sergei Golubchik

gcol mysql-test suite from 5.7

update tests and results, fix bugs
parent 4136968c
......@@ -175,6 +175,7 @@ my @DEFAULT_SUITES= qw(
federated-
funcs_1-
funcs_2-
gcol-
handler-
heap-
innodb-
......
This diff is collapsed.
################################################################################
# inc/gcol_cleanup.inc #
# #
# Purpose: #
# Removal of the objects created by the t/<test_name>.test #
# scripts. #
# #
#------------------------------------------------------------------------------#
# Original Author: Andrey Zhakov #
# Original Date: 2008-08-31 #
# Change Author: #
# Change Date: #
# Change: #
################################################################################
--disable_warnings
DROP VIEW IF EXISTS v1,v2;
DROP TABLE IF EXISTS t1,t2,t3;
DROP PROCEDURE IF EXISTS p1;
DROP FUNCTION IF EXISTS f1;
DROP TRIGGER IF EXISTS trg1;
DROP TRIGGER IF EXISTS trg2;
set sql_warnings = 0;
--enable_warnings
This diff is collapsed.
################################################################################
# inc/gcol_dependencies_on_gcol.inc #
# #
# Purpose: #
# Testing scenarios when columns depend on generated columns, i.e. such as #
# - a generated column is based on a generated column #
# - a "real" column on which a generated one is renamed/dropped #
# - a generated column involved in partitioning is renamed/dropped #
# #
#------------------------------------------------------------------------------#
# Original Author: Andrey Zhakov #
# Original Date: 2008-09-02 #
# Change Author: #
# Change Date: #
# Change: #
################################################################################
--echo # Can't define a generated column on another generated column
--error ER_VCOL_BASED_ON_VCOL
create table t1 (a int, b int generated always as (a+1) virtual, c int generated always as (b+1) virtual);
create table t1 (a int, b int generated always as (a+1) virtual);
--error ER_VCOL_BASED_ON_VCOL
alter table t1 add column c int generated always as (b+1) virtual;
drop table t1;
--echo # Can't rename or drop a column used in the function of a generated column
create table t1 (a int, b int generated always as (a+1) virtual);
--echo # On renaming/dropping a column on which a virtual field is
--echo # defined the following error is displayed:
--echo # "Unknown column 'a' in 'generated column function'"
--error 1054
alter table t1 drop column a;
--error 1054
alter table t1 change a c int;
drop table t1;
--echo # Can't rename or drop a generated column used by the paritition function
create table t1 (a int, b int generated always as (a+1) virtual) partition by hash(b);
--error 1054
alter table t1 drop b;
--error 1054
alter table t1 change b c int generated always as (a+1) virtual;
################################################################################
# inc/gcol_handler.inc #
# #
# Purpose: #
# Testing HANDLER. #
# #
# #
# #
#------------------------------------------------------------------------------#
# Original Author: Andrey Zhakov #
# Original Date: 2008-09-04 #
# Change Author: #
# Change Date: #
# Change: #
################################################################################
create table t1 (a int,
b int generated always as (-a) virtual,
c int generated always as (-a) stored,
d char(1),
index (a),
index (c));
insert into t1 (a,d) values (4,'a'), (2,'b'), (1,'c'), (3,'d');
select * from t1;
--echo # HANDLER tbl_name OPEN
handler t1 open;
--echo # HANDLER tbl_name READ non-gcol_index_name > (value1,value2,...)
handler t1 read a > (2);
--echo # HANDLER tbl_name READ non-gcol_index_name > (value1,value2,...) WHERE non-gcol_field=expr
handler t1 read a > (2) where d='c';
--echo # HANDLER tbl_name READ gcol_index_name = (value1,value2,...)
handler t1 read c = (-2);
--echo # HANDLER tbl_name READ gcol_index_name = (value1,value2,...) WHERE non-gcol_field=expr
handler t1 read c = (-2) where d='c';
--echo # HANDLER tbl_name READ non-gcol_index_name > (value1,value2,...) WHERE gcol_field=expr
handler t1 read a > (2) where b=-3 && c=-3;
--echo # HANDLER tbl_name READ gcol_index_name <= (value1,value2,...)
handler t1 read c <= (-2);
--echo # HANDLER tbl_name READ gcol_index_name > (value1,value2,...) WHERE gcol_field=expr
handler t1 read c <= (-2) where b=-3;
--echo # HANDLER tbl_name READ gcol_index_name FIRST
handler t1 read c first;
--echo # HANDLER tbl_name READ gcol_index_name NEXT
handler t1 read c next;
--echo # HANDLER tbl_name READ gcol_index_name PREV
handler t1 read c prev;
--echo # HANDLER tbl_name READ gcol_index_name LAST
handler t1 read c last;
--echo # HANDLER tbl_name READ FIRST where non-gcol=expr
handler t1 read FIRST where a >= 2;
--echo # HANDLER tbl_name READ FIRST where gcol=expr
handler t1 read FIRST where b >= -2;
--echo # HANDLER tbl_name READ NEXT where non-gcol=expr
handler t1 read NEXT where d='c';
--echo # HANDLER tbl_name READ NEXT where gcol=expr
handler t1 read NEXT where b<=-4;
--echo # HANDLER tbl_name CLOSE
handler t1 close;
drop table t1;
This diff is collapsed.
This diff is collapsed.
################################################################################
# inc/gcol_non_stored_columns.inc #
# #
# Purpose: #
# Ensure that MySQL behaviour is consistent irrelevant of #
# - the place of a non-stored column among other columns, #
# - the total number of non-stored fields. #
# #
#------------------------------------------------------------------------------#
# Original Author: Andrey Zhakov #
# Original Date: 2008-09-04 #
# Change Author: #
# Change Date: #
# Change: #
################################################################################
--echo # Case 1. All non-stored columns.
eval create $opt_tmp table t1 (a int generated always as (2+3) virtual);
insert into t1 values (default);
select * from t1;
insert into t1 values (default);
select * from t1;
drop table t1;
--echo # Case 2. CREATE
--echo # - Column1: "real"
--echo # - Column 2: virtual non-stored
eval create $opt_tmp table t1 (a int, b int generated always as (-a) virtual);
insert into t1 values (1,default);
select * from t1;
insert into t1 values (2,default);
select * from t1 order by a;
drop table t1;
--echo # Case 3. CREATE
--echo # - Column1: "real"
--echo # - Column 2: virtual stored
eval create $opt_tmp table t1 (a int, b int generated always as (-a) stored);
insert into t1 values (1,default);
select * from t1;
insert into t1 values (2,default);
select * from t1 order by a;
drop table t1;
--echo # Case 4. CREATE
--echo # - Column1: virtual non-stored
--echo # - Column2: "real"
eval create $opt_tmp table t1 (a int generated always as (-b) virtual, b int);
insert into t1 values (default,1);
select * from t1;
insert into t1 values (default,2);
select * from t1 order by a;
drop table t1;
--echo # Case 5. CREATE
--echo # - Column1: virtual stored
--echo # - Column2: "real"
eval create $opt_tmp table t1 (a int generated always as (-b) stored, b int);
insert into t1 values (default,1);
select * from t1;
insert into t1 values (default,2);
select * from t1 order by a;
drop table t1;
--echo # Case 6. CREATE
--echo # - Column1: "real"
--echo # - Column2: virtual non-stored
--echo # - Column3: virtual stored
eval create $opt_tmp table t1 (a int, b int generated always as (-a), c int generated always as (-a) stored);
insert into t1 values (1,default,default);
select * from t1;
insert into t1 values (2,default,default);
select * from t1 order by a;
drop table t1;
--echo # Case 7. ALTER. Modify virtual stored -> virtual non-stored
eval create $opt_tmp table t1 (a int, b int generated always as (a % 2) stored);
--error ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN
alter table t1 modify b int generated always as (a % 2) virtual;
show create table t1;
drop table t1;
--echo # Case 8. ALTER. Modify virtual non-stored -> virtual stored
eval create $opt_tmp table t1 (a int, b int generated always as (a % 2) virtual);
--error ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN
alter table t1 modify b int generated always as (a % 2) stored;
show create table t1;
drop table t1;
--echo # Case 9. CREATE LIKE
--echo # - Column1: "real"
--echo # - Column2: virtual non-stored
--echo # - Column3: virtual stored
eval create $opt_tmp table t1 (a int, b int generated always as (-a), c int generated always as (-a) stored);
eval create $opt_tmp table t2 like t1;
insert into t2 values (1,default,default);
select * from t2;
insert into t2 values (2,default,default);
select * from t2 order by a;
drop table t2;
drop table t1;
--echo # Case 10. ALTER. Dropping a virtual non-stored column.
--echo # - Column1: virtual non-stored
--echo # - Column2: "real"
eval create $opt_tmp table t1 (a int generated always as (-b) virtual, b int, c varchar(5));
insert into t1 values (default,1,'v1');
insert into t1 values (default,2,'v2');
select * from t1 order by b;
alter table t1 drop column a;
select * from t1 order by b;
show create table t1;
drop table t1;
--echo # Case 11. ALTER. Dropping a virtual stored column.
--echo # - Column1: virtual stored
--echo # - Column2: "real"
eval create $opt_tmp table t1 (a int generated always as (-b) stored, b int, c char(5));
insert into t1 values (default,1,'v1');
insert into t1 values (default,2,'v2');
select * from t1 order by b;
alter table t1 drop column a;
select * from t1 order by b;
show create table t1;
drop table t1;
--echo # Case 12. ALTER. Adding a new virtual non-stored column.
eval create $opt_tmp table t1 (a int, b datetime);
insert into t1 values (1,'2008-09-04');
insert into t1 values (2,'2008-09-05');
select * from t1 order by a;
alter table t1 add column c int generated always as (dayofyear(b)) virtual after a;
select * from t1 order by a;
show create table t1;
drop table t1;
--echo # Case 13. ALTER. Adding a new virtual stored column.
eval create $opt_tmp table t1 (a int, b datetime);
insert into t1 values (1,'2008-09-04');
insert into t1 values (2,'2008-09-05');
select * from t1 order by a;
alter table t1 add column c int generated always as (dayofyear(b)) stored after a;
select * from t1 order by a;
show create table t1;
drop table t1;
--echo # Case 15. ALTER. Changing the expression of a virtual non-stored column.
eval create $opt_tmp table t1 (a int, b datetime, c int generated always as (week(b)) virtual);
insert into t1 values (1,'2008-09-04',default);
insert into t1 values (2,'2008-09-05',default);
select * from t1 order by a;
alter table t1 change column c c int generated always as (week(b,1)) virtual;
select * from t1 order by a;
show create table t1;
drop table t1;
################################################################################
# inc/gcol_partition.inc #
# #
# Purpose: #
# Testing partitioning tables with generated columns. #
# #
# #
# #
#------------------------------------------------------------------------------#
# Original Author: Andrey Zhakov #
# Original Date: 2008-09-04 #
# Change Author: #
# Change Date: #
# Change: #
################################################################################
--source include/have_partition.inc
--disable_warnings
drop table if exists t1;
--enable_warnings
--echo # Case 1. Partitioning by RANGE based on a non-stored generated column.
CREATE TABLE t1 (
a DATE NOT NULL,
b int generated always as (year(a)) virtual
)
PARTITION BY RANGE( b ) (
PARTITION p0 VALUES LESS THAN (2006),
PARTITION p2 VALUES LESS THAN (2008)
);
insert into t1 values ('2006-01-01',default);
insert into t1 values ('2007-01-01',default);
insert into t1 values ('2005-01-01',default);
select * from t1;
# Specifically for MyISAM, check that data is written into correct
# $MYSQLTEST_VARDIR/master-data/test/t1*p?.MYD files
--echo # Modify the expression of generated column b
ALTER TABLE t1 modify b int generated always as (year(a)-1) virtual;
select * from t1;
drop table t1;
--echo # Case 2. Partitioning by LIST based on a stored generated column.
CREATE TABLE t1 (a int, b int generated always as (a % 3 ) stored)
PARTITION BY LIST (a+1)
(PARTITION p1 VALUES IN (1), PARTITION p2 VALUES IN (2));
insert into t1 values (1,default);
select * from t1;
#
# NOTE: The following tests are currently failing due to a
# [suspected] bug in the existing partition functionality.
# Here is what was observed when using mysqld compiled prior
# to adding the generated column functionality.
# mysql> create table t1 (a int) partition by list (a)
# (partition p1 values in (1), partition p2 values in (2));
# Query OK, 0 rows affected (0.00 sec)
#
# mysql> insert into t1 values (1), (1), (2);
# Query OK, 3 rows affected (0.00 sec)
# Records: 3 Duplicates: 0 Warnings: 0
#
# mysql> select * from t1;
# +------+
# | a |
# +------+
# | 1 |
# | 1 |
# | 2 |
# +------+
# 3 rows in set (0.00 sec)
#
# mysql> alter table t1 reorganize partition p1 into
# (partition p1 values in (3));
# Query OK, 2 rows affected (3.90 sec)
# Records: 2 Duplicates: 2 Warnings: 0
#
# mysql> select * from t1;
# +------+
# | a |
# +------+
# | 2 | <- Two row have been lost!!!
# +------+
# 1 row in set (0.00 sec)
#
#alter table t1 change b b virtual int as ((a % 3)+1) stored;
#--error ER_NO_PARTITION_FOR_GIVEN_VALUE
#alter table t1 change b b virtual int as (a % 2) stored;
#if ($myisam_engine)
#{
# --echo # Check how data is physically partitioned.
# --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
# --exec du -b $MYSQLTEST_VARDIR/master-data/test/t1*p?.MYD
#}
select * from t1;
drop table t1;
--echo # Case 3. Partitioning by HASH based on a non-stored generated column.
CREATE TABLE t1 (
a DATE NOT NULL,
b int generated always as (year(a)) virtual
)
PARTITION BY HASH( b % 3 ) PARTITIONS 3;
insert into t1 values ('2005-01-01',default);
insert into t1 values ('2006-01-01',default);
select * from t1;
--echo # Modify the expression of generated column b
ALTER TABLE t1 modify b int generated always as (year(a)-1) virtual;
select * from t1;
drop table t1;
--echo #
--echo # Bug#21779011 INVALID READS AND SENDING RANDOM SERVER MEMORY BACK
--echo # TO CLIENT
--echo #
CREATE TABLE t (
c INTEGER GENERATED ALWAYS AS (2) VIRTUAL,
d INTEGER,
KEY (d)
) PARTITION BY KEY (d) PARTITIONS 2;
INSERT INTO t (d) VALUES (1),(1),(2),(2);
SELECT c FROM t WHERE d >= 1 GROUP BY d LIMIT 2;
DROP TABLE t;
--echo #
--echo # Bug#21779554: CHECK_MISPLACED_ROWS BOGUS "FOUND A MISPLACED ROW"
--echo # AND CRASHES
--echo #
CREATE TABLE t(a INT,b INT GENERATED ALWAYS AS (1) VIRTUAL,c INT)
PARTITION BY KEY (b)PARTITIONS 6;
INSERT INTO t VALUES();
CHECK TABLE t EXTENDED;
FLUSH TABLES;
CHECK TABLE t EXTENDED;
DROP TABLE t;
This diff is collapsed.
################################################################################
# inc/gcol_supported_sql_funcs.inc #
# #
# Purpose: #
# Tests frame for allowed sql functions #
# #
# #
#------------------------------------------------------------------------------#
# Original Author: Andrey Zhakov #
# Original Date: 2008-08-31 #
# Change Author: #
# Change Date: #
# Change: #
################################################################################
--enable_warnings
set sql_warnings = 1;
eval create table t1 ($cols);
show create table t1;
if ($rows)
{
# Allow out-of-range errors
--error 0,1264,1690,3020
eval insert into t1 values ($values1);
dec $rows;
}
if ($rows)
{
--error 0,1292,1690,3020
eval insert into t1 values ($values2);
dec $rows;
}
if ($rows)
{
--error 0,1690,3020
eval insert into t1 values ($values3);
dec $rows;
}
if ($rows)
{
eval insert into t1 values ($values4);
dec $rows;
}
--sorted_result
select * from t1;
drop table t1;
set sql_warnings = 0;
This diff is collapsed.
################################################################################
# inc/gcol_trigger_sp.inc #
# #
# Purpose: #
# Testing triggers, stored procedures and functions #
# defined on tables with generated columns. #
# #
# #
# #
#------------------------------------------------------------------------------#
# Original Author: Andrey Zhakov #
# Original Date: 2008-09-04 #
# Change Author: #
# Change Date: #
# Change: #
################################################################################
create table t1 (a int,
b int generated always as (a/10) virtual,
c int generated always as (a/10) stored);
create table t2 (a timestamp);
delimiter |;
create trigger trg1 before insert on t1 for each row
begin
if (new.b < 10) then
set new.a:= 100;
set new.b:= 9;
set new.c:= 9;
end if;
if (new.c > 50) then
set new.a:= 500;
end if;
end|
create trigger trg2 after insert on t1 for each row
begin
if (new.b >= 60) then
insert into t2 values (now());
end if;
end|
create function f1()
returns int
begin
declare sum1 int default '0';
declare cur1 cursor for select sum(b) from t1;
open cur1;
fetch cur1 into sum1;
close cur1;
return sum1;
end|
delimiter ;|
set sql_warnings = 1;
insert into t1 (a) values (200);
select * from t1;
select * from t2;
insert into t1 (a) values (10);
--sorted_result
select * from t1;
select * from t2;
insert into t1 (a) values (600);
--sorted_result
select * from t1;
--replace_column 1 <timestamp>
select * from t2;
select f1();
set sql_warnings = 0;
drop trigger trg1;
drop trigger trg2;
drop table t2;
delimiter |;
create procedure p1()
begin
declare i int default '0';
create table t2 like t1;
insert into t2 (a) values (100), (200);
begin
declare cur1 cursor for select sum(c) from t2;
open cur1;
fetch cur1 into i;
close cur1;
if (i=30) then
insert into t1 values (300,default,default);
end if;
end;
end|
delimiter ;|
delete from t1;
call p1();
--sorted_result
select * from t2;
--sorted_result
select * from t1;
drop table t1,t2;
drop procedure p1;
################################################################################
# inc/gcol_unsupported_storage_engines.inc #
# #
# Purpose: #
# Ensure that defining a generated column for an unsupported table type #
# results in a graceful error. #
# #
#------------------------------------------------------------------------------#
# Original Author: Andrey Zhakov #
# Original Date: 2008-09-02 #
# Change Author: #
# Change Date: #
# Change: #
################################################################################
--error ER_UNSUPPORTED_ENGINE_FOR_VIRTUAL_COLUMNS
create table t1 (a int, b int generated always as (a+1) virtual);
create table t1 (a int);
--error ER_UNSUPPORTED_ENGINE_FOR_VIRTUAL_COLUMNS
alter table t1 add column b int generated always as (a+1) virtual;
drop table t1;
################################################################################
# inc/gcol_view.inc #
# #
# Purpose: #
# Testing views defined on tables with generated columns. #
# #
# #
# #
#------------------------------------------------------------------------------#
# Original Author: Andrey Zhakov #
# Original Date: 2008-09-04 #
# Change Author: #
# Change Date: #
# Change: #
################################################################################
create table t1 (a int not null,
b int generated always as (-a) virtual,
c int generated always as (-a) stored);
insert into t1 (a) values (1), (1), (2), (2), (3);
analyze table t1;
# simple view
create view v1 (d,e) as select abs(b), abs(c) from t1;
--sorted_result
select d,e from v1;
select is_updatable from information_schema.views where table_name='v1';
# view with different algorithms (explain output differs)
--replace_column 10 X
explain select d,e from v1;
create algorithm=temptable view v2 (d,e) as select abs(b), abs(c) from t1;
show create view v2;
--sorted_result
select d,e from v2;
--replace_column 10 X
explain select d,e from v2;
# VIEW on VIEW test
create view v3 (d,e) as select d*2, e*2 from v1;
--sorted_result
select * from v3;
--replace_column 10 X
explain select * from v3;
drop view v1,v2,v3;
drop table t1;
#
# DISTINCT option for VIEW
#
create table t1 (a int not null,
b int generated always as (-a) virtual,
c int generated always as (-a) stored);
insert into t1 (a) values (1), (2), (3), (1), (2), (3);
create view v1 as select distinct b from t1;
--sorted_result
select * from v1;
--replace_column 10 X
explain select * from v1;
--sorted_result
select * from t1;
drop view v1;
create view v1 as select distinct c from t1;
--sorted_result
select * from v1;
--replace_column 10 X
explain select * from v1;
--sorted_result
select * from t1;
drop view v1;
drop table t1;
#
# LIMIT clause test
#
create table t1 (a int not null,
b int generated always as (-a) virtual,
c int generated always as (-a) stored);
insert into t1 (a) values (1), (2), (3), (4);
create view v1 as select b+1 from t1 order by 1 desc limit 2;
select * from v1;
--replace_column 10 X
explain select * from v1;
drop view v1;
create view v1 as select c+1 from t1 order by 1 desc limit 2;
--sorted_result
select * from v1;
--replace_column 10 X
explain select * from v1;
drop view v1;
drop table t1;
#
# simple view + simple update, insert and delete
#
create table t1 (a int,
b int,
c int generated always as (-a) virtual,
d int generated always as (-a) stored,
primary key(a));
insert into t1 (a,b) values (10,2), (20,3), (30,4), (40,5), (50,10);
create view v1 (a,e,f,g) as select a, b+1,c+1,d+1 from t1;
# updatable field of updateable view
update v1 set a=a+e;
select * from v1 order by a;
select * from t1 order by a;
delete from v1;
select * from v1;
select * from t1;
--error ER_NON_INSERTABLE_TABLE
insert into v1 (a,e) values (60,15);
drop table t1;
drop view v1;
#
# outer join based on VIEW with WHERE clause
#
create table t1 (a int,
b int generated always as (-a) virtual,
c int generated always as (-a) stored,
primary key(a));
insert into t1 (a) values (1), (2), (3);
create view v1 (x,y,z) as select a,b,c from t1 where b < -1;
--sorted_result
select t1.a, v1.x, v1.y, v1.z from t1 left join v1 on (t1.b= v1.y);
drop view v1;
create view v1 (x,y,z) as select a,b,c from t1 where c < -1;
--sorted_result
select t1.a, v1.x, v1.y, v1.z from t1 left join v1 on (t1.c= v1.z);
drop view v1;
drop table t1;
#
# VIEW built over UNION
#
create table t1 (a1 int,
b1 int generated always as (-a1) virtual,
c1 int generated always as (-a1) stored);
create table t2 (a2 int,
b2 int generated always as (-a2) virtual,
c2 int generated always as (-a2) stored);
insert into t1 (a1) values (1), (2);
insert into t2 (a2) values (2), (3);
create view v1 as select * from t1,t2 union all select * from t1,t2;
--sorted_result
select * from v1;
drop view v1;
drop table t1, t2;
#
# Showing VIEW with VIEWs in subquery
#
create table t1 (a int,
b int generated always as (-a) virtual,
c int generated always as (-a) stored);
create table t2 like t1;
create view v1 as select a,b,c from t1;
create view v2 as select a,b,c from t2 where b in (select b from v1);
show create view v2;
drop view v2, v1;
drop table t1, t2;
#
# TODO: VIEW with full text
#
#CREATE TABLE t1 (c1 int not null auto_increment primary key, c2 varchar(20), fulltext(c2));
#insert into t1 (c2) VALUES ('real Beer'),('Water'),('Kossu'),('Coca-Cola'),('Vodka'),('Wine'),('almost real Beer');
#select * from t1 WHERE match (c2) against ('Beer');
#CREATE VIEW v1 AS SELECT * from t1 WHERE match (c2) against ('Beer');
#select * from v1;
#drop view v1;
#drop table t1;
#
# distinct in temporary table with a VIEW
#
create table t1 (a int,
b int generated always as (-a) virtual,
c int generated always as (-a) stored);
insert into t1 (a) values (1),(1),(2),(2),(3),(3);
create view v1 as select b from t1;
--sorted_result
select distinct b from v1;
select distinct b from v1 order by b limit 2;
select distinct b from t1 order by b limit 2;
prepare stmt1 from "select distinct b from v1 order by b limit 2";
execute stmt1;
execute stmt1;
deallocate prepare stmt1;
drop view v1;
create view v1 as select c from t1;
--sorted_result
select distinct c from v1;
select distinct c from v1 order by c limit 2;
select distinct c from t1 order by c limit 2;
prepare stmt1 from "select distinct c from v1 order by c limit 2";
execute stmt1;
execute stmt1;
deallocate prepare stmt1;
drop view v1;
drop table t1;
#
# WITH CHECK OPTION insert/update test
#
create table t1 (a int,
b int generated always as (-a) virtual,
c int generated always as (-a) stored);
create view v1 as select * from t1 where b > -2 && c >-2 with check option;
# simple insert
insert into v1 (a) values (1);
-- error 1369
insert into v1 (a) values (3);
# simple insert with ignore
insert ignore into v1 (a) values (2),(3),(0);
--sorted_result
select * from t1;
drop view v1;
drop table t1;
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
stop slave;
DROP DATABASE IF EXISTS federated;
CREATE DATABASE federated;
DROP DATABASE IF EXISTS federated;
CREATE DATABASE federated;
SET @OLD_CONCURRENT_INSERT= @@GLOBAL.CONCURRENT_INSERT;
SET @@GLOBAL.CONCURRENT_INSERT= 0;
DROP TABLE IF EXISTS federated.t1;
Warnings:
Note 1051 Unknown table 't1'
DROP TABLE IF EXISTS federated.t1;
Warnings:
Note 1051 Unknown table 't1'
CREATE TABLE federated.t1 (
`id` int(20) NOT NULL,
`group` int NOT NULL default 0,
`tmp` virtual int as (`id` + 1)
)
ENGINE="FEDERATED" DEFAULT CHARSET=latin1
CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/federated/t1';
ERROR HY000: 'Specified storage engine' is not yet supported for generated columns.
CREATE TABLE federated.t1 (
`id` int(20) NOT NULL,
`group` int NOT NULL default 0
)
ENGINE="FEDERATED" DEFAULT CHARSET=latin1
CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/federated/t1';
alter table federated.t1 add column `tmp` virtual int as (`id` + 1);
ERROR HY000: Table storage engine for 't1' doesn't have this option
DROP TABLE IF EXISTS federated.t1;
End of 5.1 tests
DROP TABLE IF EXISTS federated.t1;
DROP DATABASE IF EXISTS federated;
DROP TABLE IF EXISTS federated.t1;
DROP DATABASE IF EXISTS federated;
SET @@GLOBAL.CONCURRENT_INSERT= @OLD_CONCURRENT_INSERT;
DROP VIEW IF EXISTS v1,v2;
DROP TABLE IF EXISTS t1,t2,t3;
DROP PROCEDURE IF EXISTS p1;
DROP FUNCTION IF EXISTS f1;
DROP TRIGGER IF EXISTS trg1;
DROP TRIGGER IF EXISTS trg2;
set sql_warnings = 0;
SET @@session.default_storage_engine = 'archive';
create table t1 (a int, b int generated always as (a+1) virtual);
ERROR HY000: ARCHIVE storage engine does not support computed columns
create table t1 (a int);
alter table t1 add column b int generated always as (a+1) virtual;
ERROR HY000: ARCHIVE storage engine does not support computed columns
drop table t1;
DROP VIEW IF EXISTS v1,v2;
DROP TABLE IF EXISTS t1,t2,t3;
DROP PROCEDURE IF EXISTS p1;
DROP FUNCTION IF EXISTS f1;
DROP TRIGGER IF EXISTS trg1;
DROP TRIGGER IF EXISTS trg2;
set sql_warnings = 0;
SET @@session.default_storage_engine = 'blackhole';
create table t1 (a int, b int generated always as (a+1) virtual);
ERROR HY000: BLACKHOLE storage engine does not support computed columns
create table t1 (a int);
alter table t1 add column b int generated always as (a+1) virtual;
ERROR HY000: BLACKHOLE storage engine does not support computed columns
drop table t1;
DROP VIEW IF EXISTS v1,v2;
DROP TABLE IF EXISTS t1,t2,t3;
DROP PROCEDURE IF EXISTS p1;
DROP FUNCTION IF EXISTS f1;
DROP TRIGGER IF EXISTS trg1;
DROP TRIGGER IF EXISTS trg2;
set sql_warnings = 0;
This diff is collapsed.
This diff is collapsed.
#Bug #20746926: GENERATED COLUMNS: INVALID READ OF THD WHEN WARNINGS
#
# Testing cmp_item_datetime
connect con1,localhost,root,,;
set sql_mode='';
create table t1 (
a date not null,
b mediumtext generated always as ((a not in (a,a))) virtual,
c timestamp generated always as ((a not in (b,b))) stored
);
insert t1(a) values(7777777777);
Warnings:
Warning 1265 Data truncated for column 'a' at row 1
Warning 1292 Incorrect datetime value: '0'
show warnings;
Level Code Message
Warning 1265 Data truncated for column 'a' at row 1
Warning 1292 Incorrect datetime value: '0'
disconnect con1;
connect con2,localhost,root,,;
set sql_mode='';
insert t1(a) values(6666666666);
Warnings:
Warning 1265 Data truncated for column 'a' at row 1
Warning 1292 Incorrect datetime value: '0'
show warnings;
Level Code Message
Warning 1265 Data truncated for column 'a' at row 1
Warning 1292 Incorrect datetime value: '0'
drop table t1;
disconnect con2;
connection default;
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
SET @@session.storage_engine = 'CSV';
create table t1 (a int, b virtual int as (a+1));
ERROR HY000: 'Specified storage engine' is not yet supported for generated columns.
create table t1 (a int not null);
alter table t1 add column b virtual int as (a+1);
ERROR HY000: 'Specified storage engine' is not yet supported for generated columns.
drop table t1;
DROP VIEW IF EXISTS v1,v2;
DROP TABLE IF EXISTS t1,t2,t3;
DROP PROCEDURE IF EXISTS p1;
DROP FUNCTION IF EXISTS f1;
DROP TRIGGER IF EXISTS trg1;
DROP TRIGGER IF EXISTS trg2;
set sql_warnings = 0;
SET @@session.storage_engine = 'falcon';
create table t1 (a int, b virtual int as (a+1));
ERROR HY000: 'Specified storage engine' is not yet supported for generated columns.
create table t1 (a int);
alter table t1 add column b virtual int as (a+1);
ERROR HY000: 'Specified storage engine' is not yet supported for generated columns.
drop table t1;
DROP VIEW IF EXISTS v1,v2;
DROP TABLE IF EXISTS t1,t2,t3;
DROP PROCEDURE IF EXISTS p1;
DROP FUNCTION IF EXISTS f1;
DROP TRIGGER IF EXISTS trg1;
DROP TRIGGER IF EXISTS trg2;
set sql_warnings = 0;
SET @@session.default_storage_engine = 'InnoDB';
create table t1 (a int,
b int generated always as (-a) virtual,
c int generated always as (-a) stored,
d char(1),
index (a),
index (c));
insert into t1 (a,d) values (4,'a'), (2,'b'), (1,'c'), (3,'d');
select * from t1;
a b c d
4 -4 -4 a
2 -2 -2 b
1 -1 -1 c
3 -3 -3 d
# HANDLER tbl_name OPEN
handler t1 open;
# HANDLER tbl_name READ non-gcol_index_name > (value1,value2,...)
handler t1 read a > (2);
a b c d
3 -3 -3 d
# HANDLER tbl_name READ non-gcol_index_name > (value1,value2,...) WHERE non-gcol_field=expr
handler t1 read a > (2) where d='c';
a b c d
# HANDLER tbl_name READ gcol_index_name = (value1,value2,...)
handler t1 read c = (-2);
a b c d
2 -2 -2 b
# HANDLER tbl_name READ gcol_index_name = (value1,value2,...) WHERE non-gcol_field=expr
handler t1 read c = (-2) where d='c';
a b c d
# HANDLER tbl_name READ non-gcol_index_name > (value1,value2,...) WHERE gcol_field=expr
handler t1 read a > (2) where b=-3 && c=-3;
a b c d
3 -3 -3 d
# HANDLER tbl_name READ gcol_index_name <= (value1,value2,...)
handler t1 read c <= (-2);
a b c d
2 -2 -2 b
# HANDLER tbl_name READ gcol_index_name > (value1,value2,...) WHERE gcol_field=expr
handler t1 read c <= (-2) where b=-3;
a b c d
3 -3 -3 d
# HANDLER tbl_name READ gcol_index_name FIRST
handler t1 read c first;
a b c d
4 -4 -4 a
# HANDLER tbl_name READ gcol_index_name NEXT
handler t1 read c next;
a b c d
3 -3 -3 d
# HANDLER tbl_name READ gcol_index_name PREV
handler t1 read c prev;
a b c d
4 -4 -4 a
# HANDLER tbl_name READ gcol_index_name LAST
handler t1 read c last;
a b c d
1 -1 -1 c
# HANDLER tbl_name READ FIRST where non-gcol=expr
handler t1 read FIRST where a >= 2;
a b c d
4 -4 -4 a
# HANDLER tbl_name READ FIRST where gcol=expr
handler t1 read FIRST where b >= -2;
a b c d
2 -2 -2 b
# HANDLER tbl_name READ NEXT where non-gcol=expr
handler t1 read NEXT where d='c';
a b c d
1 -1 -1 c
# HANDLER tbl_name READ NEXT where gcol=expr
handler t1 read NEXT where b<=-4;
a b c d
# HANDLER tbl_name CLOSE
handler t1 close;
drop table t1;
DROP VIEW IF EXISTS v1,v2;
DROP TABLE IF EXISTS t1,t2,t3;
DROP PROCEDURE IF EXISTS p1;
DROP FUNCTION IF EXISTS f1;
DROP TRIGGER IF EXISTS trg1;
DROP TRIGGER IF EXISTS trg2;
set sql_warnings = 0;
SET @@session.default_storage_engine = 'MyISAM';
create table t1 (a int,
b int generated always as (-a) virtual,
c int generated always as (-a) stored,
d char(1),
index (a),
index (c));
insert into t1 (a,d) values (4,'a'), (2,'b'), (1,'c'), (3,'d');
select * from t1;
a b c d
4 -4 -4 a
2 -2 -2 b
1 -1 -1 c
3 -3 -3 d
# HANDLER tbl_name OPEN
handler t1 open;
# HANDLER tbl_name READ non-gcol_index_name > (value1,value2,...)
handler t1 read a > (2);
a b c d
3 -3 -3 d
# HANDLER tbl_name READ non-gcol_index_name > (value1,value2,...) WHERE non-gcol_field=expr
handler t1 read a > (2) where d='c';
a b c d
# HANDLER tbl_name READ gcol_index_name = (value1,value2,...)
handler t1 read c = (-2);
a b c d
2 -2 -2 b
# HANDLER tbl_name READ gcol_index_name = (value1,value2,...) WHERE non-gcol_field=expr
handler t1 read c = (-2) where d='c';
a b c d
# HANDLER tbl_name READ non-gcol_index_name > (value1,value2,...) WHERE gcol_field=expr
handler t1 read a > (2) where b=-3 && c=-3;
a b c d
3 -3 -3 d
# HANDLER tbl_name READ gcol_index_name <= (value1,value2,...)
handler t1 read c <= (-2);
a b c d
2 -2 -2 b
# HANDLER tbl_name READ gcol_index_name > (value1,value2,...) WHERE gcol_field=expr
handler t1 read c <= (-2) where b=-3;
a b c d
3 -3 -3 d
# HANDLER tbl_name READ gcol_index_name FIRST
handler t1 read c first;
a b c d
4 -4 -4 a
# HANDLER tbl_name READ gcol_index_name NEXT
handler t1 read c next;
a b c d
3 -3 -3 d
# HANDLER tbl_name READ gcol_index_name PREV
handler t1 read c prev;
a b c d
4 -4 -4 a
# HANDLER tbl_name READ gcol_index_name LAST
handler t1 read c last;
a b c d
1 -1 -1 c
# HANDLER tbl_name READ FIRST where non-gcol=expr
handler t1 read FIRST where a >= 2;
a b c d
4 -4 -4 a
# HANDLER tbl_name READ FIRST where gcol=expr
handler t1 read FIRST where b >= -2;
a b c d
2 -2 -2 b
# HANDLER tbl_name READ NEXT where non-gcol=expr
handler t1 read NEXT where d='c';
a b c d
1 -1 -1 c
# HANDLER tbl_name READ NEXT where gcol=expr
handler t1 read NEXT where b<=-4;
a b c d
# HANDLER tbl_name CLOSE
handler t1 close;
drop table t1;
DROP VIEW IF EXISTS v1,v2;
DROP TABLE IF EXISTS t1,t2,t3;
DROP PROCEDURE IF EXISTS p1;
DROP FUNCTION IF EXISTS f1;
DROP TRIGGER IF EXISTS trg1;
DROP TRIGGER IF EXISTS trg2;
set sql_warnings = 0;
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
SET @@session.default_storage_engine = 'memory';
create table t1 (a int, b int generated always as (a+1) virtual);
ERROR HY000: MEMORY storage engine does not support computed columns
create table t1 (a int);
alter table t1 add column b int generated always as (a+1) virtual;
ERROR HY000: MEMORY storage engine does not support computed columns
drop table t1;
DROP VIEW IF EXISTS v1,v2;
DROP TABLE IF EXISTS t1,t2,t3;
DROP PROCEDURE IF EXISTS p1;
DROP FUNCTION IF EXISTS f1;
DROP TRIGGER IF EXISTS trg1;
DROP TRIGGER IF EXISTS trg2;
set sql_warnings = 0;
drop table if exists t1, t2, t3;
create table t1 (a int, b int generated always as (a % 10) virtual);
create table t2 (a int, b int generated always as (a % 10) virtual);
insert into t1 values (1,default);
insert into t2 values (2,default);
create table t3 (a int, b int generated always as (a % 10) virtual) engine=MERGE UNION=(t1,t2);
ERROR HY000: MRG_MyISAM storage engine does not support computed columns
drop table t1,t2;
DROP VIEW IF EXISTS v1,v2;
DROP TABLE IF EXISTS t1,t2,t3;
DROP PROCEDURE IF EXISTS p1;
DROP FUNCTION IF EXISTS f1;
DROP TRIGGER IF EXISTS trg1;
DROP TRIGGER IF EXISTS trg2;
set sql_warnings = 0;
SET @@session.default_storage_engine = 'ndbcluster';
create table t1 (a int, b int generated always as (a+1) virtual);
ERROR HY000: 'Specified storage engine' is not supported for generated columns.
create table t1 (a int);
alter table t1 add column b int generated always as (a+1) virtual;
ERROR HY000: 'Specified storage engine' is not supported for generated columns.
drop table t1;
DROP VIEW IF EXISTS v1,v2;
DROP TABLE IF EXISTS t1,t2,t3;
DROP PROCEDURE IF EXISTS p1;
DROP FUNCTION IF EXISTS f1;
DROP TRIGGER IF EXISTS trg1;
DROP TRIGGER IF EXISTS trg2;
set sql_warnings = 0;
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
SET @@session.default_storage_engine = 'InnoDB';
DROP VIEW IF EXISTS v1,v2;
DROP TABLE IF EXISTS t1,t2,t3;
DROP PROCEDURE IF EXISTS p1;
DROP FUNCTION IF EXISTS f1;
DROP TRIGGER IF EXISTS trg1;
DROP TRIGGER IF EXISTS trg2;
set sql_warnings = 0;
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
set global innodb_purge_stop_now = 1;
create table t1(f1 int not null, f2 blob not null, f3 blob not null,
vchar char(2) as (substr(f3,2,2)) virtual,
primary key(f1, f3(5)), index(vchar))engine=innodb;
insert into t1(f1,f2,f3) values(1, repeat('a',8000), repeat('b', 9000));
update t1 set f1=5 where f1=1;
delete from t1 where f1=5;
set global innodb_purge_run_now=1;
set global innodb_fast_shutdown=0;
set global innodb_purge_stop_now = 1;
drop table t1;
create table t1(f1 int not null, f2 blob not null, f3 blob not null,
vchar char(2) as (substr(f3,2,2)) virtual,
primary key(f1, f3(5)), index(vchar, f3(2)))engine=innodb;
insert into t1(f1,f2,f3) values(1, repeat('a',8000), repeat('b', 9000));
update t1 set f1=5 where f1=1;
delete from t1 where f1=5;
set global innodb_purge_run_now=1;
set global innodb_fast_shutdown=0;
set global innodb_purge_stop_now = 1;
drop table t1;
create table t1(f1 int not null, f2 blob not null, f3 blob not null,
vchar blob as (f3) virtual,
primary key(f1, f3(5)), index(vchar(3)))engine=innodb;
insert into t1(f1,f2,f3) values(1, repeat('a',8000), repeat('b', 9000));
update t1 set f1=5 where f1=1;
delete from t1 where f1=5;
set global innodb_purge_run_now=1;
set global innodb_fast_shutdown=0;
drop table t1;
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
--source include/have_innodb.inc
create table t1 (c2 int as (-c1), c1 int primary key auto_increment) engine=innodb;
create table t1 (c2 int as (1+1), c1 int primary key auto_increment) engine=innodb;
insert into t1(c1) values (null),(null),(null);
select * from t1;
alter table t1 auto_increment = 3;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment