The main commit of Andrey Zhakov's patch introducing vurtual(computed) columns.
The original patch has been ameliorated by Sanja and Igor.
This commit is contained in:
parent
8ea19fa73e
commit
f7a75b999b
@ -67,7 +67,8 @@ enum enum_server_command
|
||||
COM_END
|
||||
};
|
||||
|
||||
|
||||
/* sql type stored in .frm files for virtual fields */
|
||||
#define MYSQL_TYPE_VIRTUAL 245
|
||||
/*
|
||||
Length of random string sent by server on handshake; this is also length of
|
||||
obfuscated password, recieved from client
|
||||
|
344
mysql-test/suite/vcol/inc/vcol_blocked_sql_funcs_main.inc
Normal file
344
mysql-test/suite/vcol/inc/vcol_blocked_sql_funcs_main.inc
Normal file
@ -0,0 +1,344 @@
|
||||
################################################################################
|
||||
# inc/vcol_blocked_sql_funcs_main.inc #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Tests around sql functions #
|
||||
# #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-08-31 #
|
||||
# Change Author: Oleksandr Byelkin (Monty program Ab)
|
||||
# Date: 2009-03-24
|
||||
# Change: Syntax changed
|
||||
################################################################################
|
||||
|
||||
#
|
||||
# NOTE: All SQL functions should be rejected, otherwise BUG.
|
||||
#
|
||||
|
||||
--echo # RAND()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (b double as (rand()));
|
||||
|
||||
--echo # LOAD_FILE()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a varchar(64), b varchar(1024) as (load_file(a)));
|
||||
|
||||
--echo # CURDATE()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a datetime as (curdate()));
|
||||
|
||||
--echo # CURRENT_DATE(), CURRENT_DATE
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a datetime as (current_date));
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a datetime as (current_date()));
|
||||
|
||||
--echo # CURRENT_TIME(), CURRENT_TIME
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a datetime as (current_time));
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a datetime as (current_time()));
|
||||
|
||||
--echo # CURRENT_TIMESTAMP(), CURRENT_TIMESTAMP
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a datetime as (current_timestamp()));
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a datetime as (current_timestamp));
|
||||
|
||||
--echo # CURTIME()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a datetime as (curtime()));
|
||||
|
||||
--echo # LOCALTIME(), LOCALTIME
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a datetime, b varchar(10) as (localtime()));
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a datetime, b varchar(10) as (localtime));
|
||||
|
||||
--echo # LOCALTIMESTAMP, LOCALTIMESTAMP()(v4.0.6)
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a datetime, b varchar(10) as (localtimestamp()));
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a datetime, b varchar(10) as (localtimestamp));
|
||||
|
||||
--echo # NOW()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a datetime, b varchar(10) as (now()));
|
||||
|
||||
--echo # SYSDATE()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int, b varchar(10) as (sysdate()));
|
||||
|
||||
--echo # UNIX_TIMESTAMP()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a datetime, b datetime as (unix_timestamp()));
|
||||
|
||||
--echo # UTC_DATE()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a datetime, b datetime as (utc_date()));
|
||||
|
||||
--echo # UTC_TIME()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a datetime, b datetime as (utc_time()));
|
||||
|
||||
--echo # UTC_TIMESTAMP()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a datetime, b datetime as (utc_timestamp()));
|
||||
|
||||
--echo # MATCH()
|
||||
if (!$skip_full_text_checks)
|
||||
{
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a varchar(32), b bool as (match a against ('sample text')));
|
||||
}
|
||||
|
||||
--echo # BENCHMARK()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a varchar(1024), b varchar(1024) as (benchmark(a,3)));
|
||||
|
||||
--echo # CONNECTION_ID()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int as (connection_id()));
|
||||
|
||||
--echo # CURRENT_USER(), CURRENT_USER
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a varchar(32) as (current_user()));
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a varchar(32) as (current_user));
|
||||
|
||||
--echo # DATABASE()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a varchar(1024), b varchar(1024) as (database()));
|
||||
|
||||
--echo # FOUND_ROWS()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a varchar(1024), b varchar(1024) as (found_rows()));
|
||||
|
||||
--echo # GET_LOCK()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a varchar(1024), b varchar(1024) as (get_lock(a,10)));
|
||||
|
||||
--echo # IS_FREE_LOCK()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a varchar(1024), b varchar(1024) as (is_free_lock(a)));
|
||||
|
||||
--echo # IS_USED_LOCK()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a varchar(1024), b varchar(1024) as (is_used_lock(a)));
|
||||
|
||||
--echo # LAST_INSERT_ID()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int as (last_insert_id()));
|
||||
|
||||
--echo # MASTER_POS_WAIT()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a varchar(32), b int as (master_pos_wait(a,0,2)));
|
||||
|
||||
--echo # NAME_CONST()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a varchar(32) as (name_const('test',1)));
|
||||
|
||||
--echo # RELEASE_LOCK()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a varchar(32), b int as (release_lock(a)));
|
||||
|
||||
--echo # ROW_COUNT()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int as (row_count()));
|
||||
|
||||
--echo # SCHEMA()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a varchar(32) as (schema()));
|
||||
|
||||
--echo # SESSION_USER()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a varchar(32) as (session_user()));
|
||||
|
||||
--echo # SLEEP()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int, b int as (sleep(a)));
|
||||
|
||||
--echo # SYSTEM_USER()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a varchar(32) as (system_user()));
|
||||
|
||||
--echo # USER()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a varchar(1024), b varchar(1024) as (user()));
|
||||
|
||||
--echo # UUID_SHORT()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a varchar(1024) as (uuid_short()));
|
||||
|
||||
--echo # UUID()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a varchar(1024) as (uuid()));
|
||||
|
||||
--echo # VALUES()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a varchar(1024), b varchar(1024) as (values(a)));
|
||||
|
||||
--echo # VERSION()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a varchar(1024), b varchar(1024) as (version()));
|
||||
|
||||
--echo # ENCRYPT()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a varchar(1024), b varchar(1024) as (encrypt(a)));
|
||||
|
||||
--echo # Stored procedures
|
||||
|
||||
delimiter //;
|
||||
create procedure p1()
|
||||
begin
|
||||
select current_user();
|
||||
end //
|
||||
|
||||
create function f1()
|
||||
returns int
|
||||
begin
|
||||
return 1;
|
||||
end //
|
||||
|
||||
delimiter ;//
|
||||
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int as (p1()));
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int as (f1()));
|
||||
|
||||
drop procedure p1;
|
||||
drop function f1;
|
||||
|
||||
--echo # Unknown functions
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int as (f1()));
|
||||
|
||||
--echo #
|
||||
--echo # GROUP BY FUNCTIONS
|
||||
--echo #
|
||||
|
||||
--echo # AVG()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int, b int as (avg(a)));
|
||||
|
||||
--echo # BIT_AND()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int, b int as (bit_and(a)));
|
||||
|
||||
--echo # BIT_OR()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int, b int as (bit_or(a)));
|
||||
|
||||
--echo # BIT_XOR()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int, b int as (bit_xor(a)));
|
||||
|
||||
--echo # COUNT(DISTINCT)
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int, b int as (count(distinct a)));
|
||||
|
||||
--echo # COUNT()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int, b int as (count(a)));
|
||||
|
||||
--echo # GROUP_CONCAT()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a varchar(32), b int as (group_concat(a,'')));
|
||||
|
||||
--echo # MAX()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int, b int as (max(a)));
|
||||
|
||||
--echo # MIN()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int, b int as (min(a)));
|
||||
|
||||
--echo # STD()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int, b int as (std(a)));
|
||||
|
||||
--echo # STDDEV_POP()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int, b int as (stddev_pop(a)));
|
||||
|
||||
--echo # STDDEV_SAMP()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int, b int as (stddev_samp(a)));
|
||||
|
||||
--echo # STDDEV()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int, b int as (stddev(a)));
|
||||
|
||||
--echo # SUM()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int, b int as (sum(a)));
|
||||
|
||||
--echo # VAR_POP()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int, b int as (var_pop(a)));
|
||||
|
||||
--echo # VAR_SAMP()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int, b int as (var_samp(a)));
|
||||
|
||||
--echo # VARIANCE()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int, b int as (variance(a)));
|
||||
|
||||
--echo #
|
||||
--echo # XML FUNCTIONS
|
||||
--echo #
|
||||
|
||||
--echo # ExtractValue()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a varchar(1024), b varchar(1024) as (ExtractValue(a,'//b[$@j]')));
|
||||
|
||||
--echo # UpdateXML()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a varchar(1024), b varchar(1024) as (UpdateXML(a,'/a','<e>fff</e>')));
|
||||
|
||||
--echo #
|
||||
--echo # Sub-selects
|
||||
--echo #
|
||||
|
||||
create table t1 (a int);
|
||||
-- error ER_PARSE_ERROR
|
||||
create table t2 (a int, b int as (select count(*) from t1));
|
||||
drop table t1;
|
||||
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int, b int as ((select 1)));
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int, b int as (a+(select 1)));
|
||||
|
||||
--echo #
|
||||
--echo # SP functions
|
||||
--echo #
|
||||
|
||||
--disable_warnings
|
||||
drop function if exists sub1;
|
||||
--enable_warnings
|
||||
create function sub1(i int) returns int deterministic
|
||||
return i+1;
|
||||
select sub1(1);
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int, b int as (a+sub3(1)));
|
||||
drop function sub1;
|
||||
|
||||
--echo #
|
||||
--echo # Long expression
|
||||
|
||||
let $tmp_long_string = `SELECT repeat('a',240)`;
|
||||
eval create table t1 (a int, b varchar(300) as (concat(a,'$tmp_long_string')));
|
||||
drop table t1;
|
||||
let $tmp_long_string = `SELECT repeat('a',243)`;
|
||||
--error ER_WRONG_STRING_LENGTH
|
||||
eval create table t1 (a int, b varchar(300) as (concat(a,'$tmp_long_string')));
|
||||
|
||||
--echo #
|
||||
--echo # Constant expression
|
||||
--error ER_CONST_EXPR_IN_VCOL
|
||||
create table t1 (a int as (PI()));
|
25
mysql-test/suite/vcol/inc/vcol_cleanup.inc
Normal file
25
mysql-test/suite/vcol/inc/vcol_cleanup.inc
Normal file
@ -0,0 +1,25 @@
|
||||
################################################################################
|
||||
# inc/vcol_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
|
||||
--disable_query_log
|
||||
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;
|
||||
--enable_query_log
|
||||
--enable_warnings
|
113
mysql-test/suite/vcol/inc/vcol_column_def_options.inc
Normal file
113
mysql-test/suite/vcol/inc/vcol_column_def_options.inc
Normal file
@ -0,0 +1,113 @@
|
||||
################################################################################
|
||||
# inc/vcol_column_def_options.inc #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Testing different optional parameters specified when defining #
|
||||
# a virtual column. #
|
||||
# #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-09-02 #
|
||||
# Change Author: Oleksandr Byelkin (Monty program Ab)
|
||||
# Date: 2009-03-24
|
||||
# Change: Syntax changed
|
||||
################################################################################
|
||||
|
||||
--echo #
|
||||
--echo # Section 1. Wrong column definition options
|
||||
--echo # - NOT NULL
|
||||
--echo # - NULL
|
||||
--echo # - DEFAULT <value>
|
||||
--echo # - AUTO_INCREMENT
|
||||
--echo # - [PRIMARY] KEY
|
||||
|
||||
--echo # NOT NULL
|
||||
--error ER_PARSE_ERROR
|
||||
create table t1 (a int, b int as (a+1) not null);
|
||||
create table t1 (a int);
|
||||
--error ER_PARSE_ERROR
|
||||
alter table t1 add column b int as (a+1) not null;
|
||||
drop table t1;
|
||||
|
||||
--echo # NULL
|
||||
--error ER_PARSE_ERROR
|
||||
create table t1 (a int, b int as (a+1) null);
|
||||
create table t1 (a int);
|
||||
--error ER_PARSE_ERROR
|
||||
alter table t1 add column b int as (a+1) null;
|
||||
drop table t1;
|
||||
|
||||
--echo # DEFAULT
|
||||
--error ER_PARSE_ERROR
|
||||
create table t1 (a int, b int as (a+1) default 0);
|
||||
create table t1 (a int);
|
||||
--error ER_PARSE_ERROR
|
||||
alter table t1 add column b int as (a+1) default 0;
|
||||
drop table t1;
|
||||
|
||||
--echo # AUTO_INCREMENT
|
||||
--error ER_PARSE_ERROR
|
||||
create table t1 (a int, b int as (a+1) AUTO_INCREMENT);
|
||||
create table t1 (a int);
|
||||
--error ER_PARSE_ERROR
|
||||
alter table t1 add column b int as (a+1) AUTO_INCREMENT;
|
||||
drop table t1;
|
||||
|
||||
--echo # [PRIMARY] KEY
|
||||
--error ER_PARSE_ERROR
|
||||
create table t1 (a int, b int as (a+1) key);
|
||||
--error ER_PARSE_ERROR
|
||||
create table t1 (a int, b int as (a+1) primary key);
|
||||
create table t1 (a int);
|
||||
--error ER_PARSE_ERROR
|
||||
alter table t1 add column b int as (a+1) key;
|
||||
--error ER_PARSE_ERROR
|
||||
alter table t1 add column b int as (a+1) primary key;
|
||||
drop table t1;
|
||||
|
||||
--echo # Section 2. Other column definition options
|
||||
--echo # - COMMENT
|
||||
--echo # - REFERENCES (only syntax testing here)
|
||||
--echo # - STORED (only systax testing here)
|
||||
create table t1 (a int, b int as (a % 2) comment 'my comment');
|
||||
show create table t1;
|
||||
describe t1;
|
||||
drop table t1;
|
||||
create table t1 (a int, b int as (a % 2));
|
||||
alter table t1 modify b int as (a % 2) comment 'my comment';
|
||||
show create table t1;
|
||||
describe t1;
|
||||
insert into t1 (a) values (1);
|
||||
select * from t1;
|
||||
insert into t1 values (2,default);
|
||||
select a,b from t1;
|
||||
create table t2 like t1;
|
||||
show create table t2;
|
||||
describe t2;
|
||||
insert into t2 (a) values (1);
|
||||
select * from t2;
|
||||
insert into t2 values (2,default);
|
||||
select a,b from t2;
|
||||
drop table t2;
|
||||
drop table t1;
|
||||
|
||||
create table t1 (a int, b int as (a % 2) persistent);
|
||||
show create table t1;
|
||||
describe t1;
|
||||
insert into t1 (a) values (1);
|
||||
select * from t1;
|
||||
insert into t1 values (2,default);
|
||||
select a,b from t1;
|
||||
drop table t1;
|
||||
|
||||
|
||||
create table t2 (a int);
|
||||
create table t1 (a int, b int as (a % 2) persistent references t2(a));
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
create table t1 (a int, b int as (a % 2));
|
||||
--error ER_PARSE_ERROR
|
||||
alter table t1 modify b int as (a % 2) persistent references t2(a);
|
||||
show create table t1;
|
||||
drop table t1;
|
43
mysql-test/suite/vcol/inc/vcol_dependancies_on_vcol.inc
Normal file
43
mysql-test/suite/vcol/inc/vcol_dependancies_on_vcol.inc
Normal file
@ -0,0 +1,43 @@
|
||||
################################################################################
|
||||
# inc/vcol_dependencies_on_vcol.inc #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Testing scenarios when columns depend on virtual columns, i.e. such as #
|
||||
# - a virtual column is based on a virtual column #
|
||||
# - a "real" column on which a virtual one is renamed/dropped #
|
||||
# - a virtual column involved in partitioning is renamed/dropped #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-09-02 #
|
||||
# Change Author: Oleksandr Byelkin (Monty program Ab)
|
||||
# Date: 2009-03-24
|
||||
# Change: Syntax changed
|
||||
################################################################################
|
||||
|
||||
--echo # Can't define a virtual column on another virtual column
|
||||
--error ER_VCOL_BASED_ON_VCOL
|
||||
create table t1 (a int, b int as (a+1), c int as (b+1));
|
||||
create table t1 (a int, b int as (a+1));
|
||||
--error ER_VCOL_BASED_ON_VCOL
|
||||
alter table t1 add column c int as (b+1);
|
||||
drop table t1;
|
||||
|
||||
--echo # Can't rename or drop a column used in the function of a virtual column
|
||||
create table t1 (a int, b int as (a+1));
|
||||
--echo # On renaming/dropping a column on which a virtual field is
|
||||
--echo # defined the following error is displayed:
|
||||
--echo # "Unknown column 'a' in 'virtual column function'"
|
||||
--error ER_BAD_FIELD_ERROR
|
||||
alter table t1 drop column a;
|
||||
--error ER_BAD_FIELD_ERROR
|
||||
alter table t1 change a c int;
|
||||
drop table t1;
|
||||
|
||||
--echo # Can't rename or drop a virtual column used by the paritition function
|
||||
create table t1 (a int, b int as (a+1)) partition by hash(b);
|
||||
--error ER_BAD_FIELD_ERROR
|
||||
alter table t1 drop b;
|
||||
--error ER_BAD_FIELD_ERROR
|
||||
alter table t1 change b c int as (a+1);
|
||||
|
77
mysql-test/suite/vcol/inc/vcol_handler.inc
Normal file
77
mysql-test/suite/vcol/inc/vcol_handler.inc
Normal file
@ -0,0 +1,77 @@
|
||||
################################################################################
|
||||
# inc/vcol_handler.inc #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Testing HANDLER. #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-09-04 #
|
||||
# Change Author: Oleksandr Byelkin (Monty program Ab)
|
||||
# Date: 2009-03-24
|
||||
# Change: Syntax changed
|
||||
################################################################################
|
||||
|
||||
create table t1 (a int,
|
||||
b int as (-a),
|
||||
c int as (-a) persistent,
|
||||
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-vcol_index_name > (value1,value2,...)
|
||||
handler t1 read a > (2);
|
||||
|
||||
--echo # HANDLER tbl_name READ non-vcol_index_name > (value1,value2,...) WHERE non-vcol_field=expr
|
||||
handler t1 read a > (2) where d='c';
|
||||
|
||||
--echo # HANDLER tbl_name READ vcol_index_name = (value1,value2,...)
|
||||
handler t1 read c = (-2);
|
||||
|
||||
--echo # HANDLER tbl_name READ vcol_index_name = (value1,value2,...) WHERE non-vcol_field=expr
|
||||
handler t1 read c = (-2) where d='c';
|
||||
|
||||
--echo # HANDLER tbl_name READ non-vcol_index_name > (value1,value2,...) WHERE vcol_field=expr
|
||||
handler t1 read a > (2) where b=-3 && c=-3;
|
||||
|
||||
--echo # HANDLER tbl_name READ vcol_index_name <= (value1,value2,...)
|
||||
handler t1 read c <= (-2);
|
||||
|
||||
--echo # HANDLER tbl_name READ vcol_index_name > (value1,value2,...) WHERE vcol_field=expr
|
||||
handler t1 read c <= (-2) where b=-3;
|
||||
|
||||
--echo # HANDLER tbl_name READ vcol_index_name FIRST
|
||||
handler t1 read c first;
|
||||
|
||||
--echo # HANDLER tbl_name READ vcol_index_name NEXT
|
||||
handler t1 read c next;
|
||||
|
||||
--echo # HANDLER tbl_name READ vcol_index_name PREV
|
||||
handler t1 read c prev;
|
||||
|
||||
--echo # HANDLER tbl_name READ vcol_index_name LAST
|
||||
handler t1 read c last;
|
||||
|
||||
--echo # HANDLER tbl_name READ FIRST where non-vcol=expr
|
||||
handler t1 read FIRST where a >= 2;
|
||||
|
||||
--echo # HANDLER tbl_name READ FIRST where vcol=expr
|
||||
handler t1 read FIRST where b >= -2;
|
||||
|
||||
--echo # HANDLER tbl_name READ NEXT where non-vcol=expr
|
||||
handler t1 read NEXT where d='c';
|
||||
|
||||
--echo # HANDLER tbl_name READ NEXT where vcol=expr
|
||||
handler t1 read NEXT where b<=-4;
|
||||
|
||||
--echo # HANDLER tbl_name CLOSE
|
||||
handler t1 close;
|
||||
|
||||
drop table t1;
|
17
mysql-test/suite/vcol/inc/vcol_init_vars.pre
Normal file
17
mysql-test/suite/vcol/inc/vcol_init_vars.pre
Normal file
@ -0,0 +1,17 @@
|
||||
################################################################################
|
||||
# inc/vcol_init_vars.pre #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Initialize variables used in t/<name> test cases. #
|
||||
# #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-08-31 #
|
||||
# Change Author: #
|
||||
# Change Date: #
|
||||
# Change: #
|
||||
################################################################################
|
||||
|
||||
let $skip_full_text_check = 0;
|
||||
let $skip_spatial_index_check = 0;
|
289
mysql-test/suite/vcol/inc/vcol_ins_upd.inc
Normal file
289
mysql-test/suite/vcol/inc/vcol_ins_upd.inc
Normal file
@ -0,0 +1,289 @@
|
||||
################################################################################
|
||||
# inc/vcol_ins_upd.inc #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Testing DDL operations such as INSERT, UPDATE, REPLACE and DELETE. #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-09-04 #
|
||||
# Change Author: Oleksandr Byelkin (Monty program Ab)
|
||||
# Date: 2009-03-24
|
||||
# Change: Syntax changed
|
||||
################################################################################
|
||||
|
||||
let $create1 = create table t1 (a int,
|
||||
b int as (-a),
|
||||
c int as (-a) persistent);
|
||||
let $create2 = create table t1 (a int unique,
|
||||
b int as (-a),
|
||||
c int as (-a) persistent);
|
||||
let $create3 = create table t1 (a int,
|
||||
b int as (-a),
|
||||
c int as (-a) persistent unique);
|
||||
let $create4 = create table t1 (a int,
|
||||
b int as (-a),
|
||||
c int as (-a) persistent unique,
|
||||
d varchar(16));
|
||||
eval $create1;
|
||||
set sql_warnings = 1;
|
||||
|
||||
--echo #
|
||||
--echo # *** INSERT ***
|
||||
--echo #
|
||||
|
||||
--echo # INSERT INTO tbl_name VALUES... DEFAULT is specified against vcols
|
||||
insert into t1 values (1,default,default);
|
||||
select * from t1;
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
|
||||
--echo # INSERT INTO tbl_name VALUES... NULL is specified against vcols
|
||||
insert into t1 values (1,null,null);
|
||||
select * from t1;
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
|
||||
--echo # INSERT INTO tbl_name VALUES... a non-NULL value is specified against vcols
|
||||
insert into t1 values (1,2,3);
|
||||
select * from t1;
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
|
||||
--echo # INSERT INTO tbl_name (<non_vcol_list>) VALUES...
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1;
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
|
||||
--echo # INSERT INTO tbl_name (<normal+vcols>) VALUES... DEFAULT is specified
|
||||
--echo # against vcols
|
||||
insert into t1 (a,b) values (1,default), (2,default);
|
||||
select * from t1;
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
|
||||
--echo # INSERT INTO tbl_name (<normal+vcols>) VALUES... NULL is specified against vcols
|
||||
insert into t1 (a,b) values (1,null), (2,null);
|
||||
select * from t1;
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
|
||||
--echo # INSERT INTO tbl_name (<normal+vcols>) VALUES... a non-NULL value is specified
|
||||
--echo # against vcols
|
||||
insert into t1 (a,b) values (1,3), (2,4);
|
||||
select * from t1;
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
drop table t1;
|
||||
|
||||
--echo # Table with UNIQUE non-vcol field. INSERT INTO tbl_name VALUES... ON DUPLICATE
|
||||
--echo # KEY UPDATE <non_vcol>=expr, <vcol>=expr
|
||||
eval $create2;
|
||||
insert into t1 values (1,default,default);
|
||||
insert into t1 values (1,default,default)
|
||||
on duplicate key update a=2, b=default;
|
||||
select a,b,c from t1;
|
||||
delete from t1 where b in (1,2);
|
||||
select * from t1;
|
||||
drop table t1;
|
||||
|
||||
--echo # Table with UNIQUE vcol field. INSERT INTO tbl_name VALUES... ON DUPLICATE
|
||||
--echo # KEY UPDATE <non_vcol>=expr, <vcol>=expr
|
||||
eval $create3;
|
||||
insert into t1 values (1,default,default);
|
||||
insert into t1 values (1,default,default)
|
||||
on duplicate key update a=2, b=default;
|
||||
select a,b,c from t1;
|
||||
|
||||
--echo # CREATE new_table ... LIKE old_table
|
||||
--echo # INSERT INTO new_table SELECT * from old_table
|
||||
create table t2 like t1;
|
||||
insert into t2 select * from t1;
|
||||
select * from t1;
|
||||
drop table t2;
|
||||
|
||||
--echo # CREATE new_table ... LIKE old_table INSERT INTO new_table (<non-vcols>, <vcols>)
|
||||
--echo # SELECT <non-vcols>, <vcols> from old_table
|
||||
insert into t1 values (1,default,default);
|
||||
select * from t1;
|
||||
create table t2 like t1;
|
||||
insert into t2 (a,b) select a,b from t1;
|
||||
select * from t2;
|
||||
drop table t2;
|
||||
drop table t1;
|
||||
|
||||
--echo #
|
||||
--echo # *** UPDATE ***
|
||||
--echo #
|
||||
|
||||
--echo # UPDATE tbl_name SET non-vcol=expr WHERE non-vcol=expr
|
||||
eval $create1;
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1;
|
||||
update t1 set a=3 where a=2;
|
||||
select * from t1;
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
|
||||
--echo # UPDATE tbl_name SET vcol=expr WHERE non-vcol=expr
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1;
|
||||
update t1 set c=3 where a=2;
|
||||
select * from t1;
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
|
||||
--echo # UPDATE tbl_name SET non-vcol=expr WHERE vcol=expr
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1;
|
||||
update t1 set a=3 where b=-2;
|
||||
select * from t1;
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
|
||||
--echo # UPDATE tbl_name SET vcol=expr WHERE vcol=expr
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1;
|
||||
update t1 set c=3 where b=-2;
|
||||
select * from t1;
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
drop table t1;
|
||||
|
||||
--echo # INDEX created on vcol
|
||||
--echo # UPDATE tbl_name SET non-vcol=expr WHERE vcol=const
|
||||
eval $create3;
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1;
|
||||
update t1 set a=3 where c=-2;
|
||||
select * from t1;
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
|
||||
|
||||
--echo # INDEX created on vcol
|
||||
--echo # UPDATE tbl_name SET non-vcol=expr WHERE vcol=between const1 and const2
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1;
|
||||
update t1 set a=3 where c between -3 and -2;
|
||||
select * from t1;
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
|
||||
--echo # No INDEX created on vcol
|
||||
--echo # UPDATE tbl_name SET non-vcol=expr WHERE vcol=between const1 and const2
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1;
|
||||
update t1 set a=3 where b between -3 and -2;
|
||||
select * from t1;
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
|
||||
--echo # INDEX created on vcol
|
||||
--echo # UPDATE tbl_name SET non-vcol=expr
|
||||
--echo # WHERE vcol=between const1 and const2 ORDER BY vcol
|
||||
insert into t1 (a) values (1), (2), (3), (4), (5);
|
||||
select * from t1;
|
||||
update t1 set a=6 where c between -1 and 0
|
||||
order by c;
|
||||
select * from t1;
|
||||
delete from t1 where c between -6 and 0;
|
||||
select * from t1;
|
||||
|
||||
--echo # INDEX created on vcol
|
||||
--echo # UPDATE tbl_name SET non-vcol=expr
|
||||
--echo # WHERE vcol=between const1 and const2 ORDER BY vcol LIMIT 2
|
||||
insert into t1 (a) values (1), (2), (3), (4), (5);
|
||||
select * from t1;
|
||||
update t1 set a=6 where c between -1 and 0
|
||||
order by c limit 2;
|
||||
select * from t1;
|
||||
delete from t1 where c between -2 and 0 order by c;
|
||||
select * from t1;
|
||||
delete from t1;
|
||||
|
||||
--echo # INDEX created on vcol
|
||||
--echo # UPDATE tbl_name SET non-vcol=expr
|
||||
--echo # WHERE indexed vcol=between const1 and const2 and non-indexed vcol=const3
|
||||
insert into t1 (a) values (1), (2), (3), (4), (5);
|
||||
select * from t1;
|
||||
update t1 set a=6 where (c between -2 and 0) and (b=-1);
|
||||
select * from t1;
|
||||
delete from t1;
|
||||
|
||||
--echo # INDEX created on vcol
|
||||
--echo # UPDATE tbl_name SET non-vcol=expr
|
||||
--echo # WHERE indexed vcol=between const1 and const2 and non-indexed vcol=const3
|
||||
--echo # ORDER BY indexed vcol
|
||||
insert into t1 (a) values (1), (2), (3), (4), (5);
|
||||
select * from t1;
|
||||
update t1 set a=6 where (c between -2 and 0) and (b=-1) order by c;
|
||||
select * from t1;
|
||||
delete from t1;
|
||||
drop table t1;
|
||||
|
||||
let $innodb_engine = `SELECT @@session.storage_engine='innodb'`;
|
||||
if ($innodb_engine)
|
||||
{
|
||||
--echo #
|
||||
--echo # Verify ON UPDATE/DELETE actions of FOREIGN KEYs
|
||||
create table t2 (a int primary key, name varchar(10));
|
||||
create table t1 (a int primary key, b int as (a % 10) persistent);
|
||||
insert into t2 values (1, 'value1'), (2,'value2'), (3,'value3');
|
||||
insert into t1 (a) values (1),(2),(3);
|
||||
select * from t1;
|
||||
select * from t2;
|
||||
select t1.a, t1.b, t2.name from t1,t2 where t1.b=t2.a;
|
||||
|
||||
--echo # - ON UPDATE RESTRICT
|
||||
alter table t1 add foreign key (b) references t2(a) on update restrict;
|
||||
--error ER_NO_REFERENCED_ROW_2
|
||||
insert into t1 (a) values (4);
|
||||
--error ER_ROW_IS_REFERENCED_2
|
||||
update t2 set a=4 where a=3;
|
||||
select t1.a, t1.b, t2.name from t1,t2 where t1.b=t2.a;
|
||||
alter table t1 drop foreign key t1_ibfk_1;
|
||||
|
||||
--echo # - ON DELETE RESTRICT
|
||||
alter table t1 add foreign key (b) references t2(a) on delete restrict;
|
||||
--error ER_ROW_IS_REFERENCED_2
|
||||
delete from t2 where a=3;
|
||||
select t1.a, t1.b, t2.name from t1,t2 where t1.b=t2.a;
|
||||
select t1.a, t1.b, t2.name from t1 left outer join t2 on (t1.b=t2.a);
|
||||
alter table t1 drop foreign key t1_ibfk_1;
|
||||
|
||||
--echo # - ON DELETE CASCADE
|
||||
alter table t1 add foreign key (b) references t2(a) on delete cascade;
|
||||
delete from t2 where a=3;
|
||||
select t1.a, t1.b, t2.name from t1,t2 where t1.b=t2.a;
|
||||
select t1.a, t1.b, t2.name from t1 left outer join t2 on (t1.b=t2.a);
|
||||
alter table t1 drop foreign key t1_ibfk_1;
|
||||
|
||||
drop table t1;
|
||||
drop table t2;
|
||||
}
|
||||
|
||||
--echo #
|
||||
--echo # *** REPLACE ***
|
||||
--echo #
|
||||
|
||||
--echo # UNIQUE INDEX on vcol
|
||||
--echo # REPLACE tbl_name (non-vcols) VALUES (non-vcols);
|
||||
eval $create4;
|
||||
insert into t1 (a,d) values (1,'a'), (2,'b');
|
||||
select * from t1;
|
||||
replace t1 (a,d) values (1,'c');
|
||||
select * from t1;
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
|
||||
|
||||
# *** DELETE
|
||||
# All required tests for DELETE are performed as part of the above testing
|
||||
# for INSERT, UPDATE and REPLACE.
|
||||
|
||||
set sql_warnings = 0;
|
||||
drop table t1;
|
163
mysql-test/suite/vcol/inc/vcol_keys.inc
Normal file
163
mysql-test/suite/vcol/inc/vcol_keys.inc
Normal file
@ -0,0 +1,163 @@
|
||||
################################################################################
|
||||
# inc/vcol_keys.inc #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Testing keys, indexes defined upon virtual columns. #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-09-02 #
|
||||
# Change Author: Oleksandr Byelkin (Monty program Ab)
|
||||
# Date: 2009-03-24
|
||||
# Change: Syntax changed
|
||||
################################################################################
|
||||
|
||||
|
||||
--echo # - UNIQUE KEY
|
||||
--echo # - INDEX
|
||||
--echo # - FULLTEXT INDEX
|
||||
--echo # - SPATIAL INDEX (not supported)
|
||||
--echo # - FOREIGN INDEX (partially supported)
|
||||
--echo # - CHECK (allowed but not used)
|
||||
|
||||
--echo # UNIQUE
|
||||
--error ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN
|
||||
create table t1 (a int, b int as (a*2) unique);
|
||||
create table t1 (a int, b int as (a*2) persistent unique);
|
||||
show create table t1;
|
||||
describe t1;
|
||||
drop table t1;
|
||||
|
||||
--error ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN
|
||||
create table t1 (a int, b int as (a*2), unique key (b));
|
||||
create table t1 (a int, b int as (a*2) persistent, unique (b));
|
||||
show create table t1;
|
||||
describe t1;
|
||||
drop table t1;
|
||||
|
||||
create table t1 (a int, b int as (a*2));
|
||||
--error ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN
|
||||
alter table t1 add unique key (b);
|
||||
drop table t1;
|
||||
create table t1 (a int, b int as (a*2) persistent);
|
||||
alter table t1 add unique key (b);
|
||||
drop table t1;
|
||||
|
||||
--echo # Testing data manipulation operations involving UNIQUE keys
|
||||
--echo # on virtual columns can be found in:
|
||||
--echo # - vcol_ins_upd.inc
|
||||
--echo # - vcol_select.inc
|
||||
|
||||
--echo #
|
||||
--echo # INDEX
|
||||
--error ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN
|
||||
create table t1 (a int, b int as (a*2), index (b));
|
||||
--error ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN
|
||||
create table t1 (a int, b int as (a*2), index (a,b));
|
||||
|
||||
create table t1 (a int, b int as (a*2) persistent, index (b));
|
||||
show create table t1;
|
||||
describe t1;
|
||||
drop table t1;
|
||||
|
||||
create table t1 (a int, b int as (a*2) persistent, index (a,b));
|
||||
show create table t1;
|
||||
describe t1;
|
||||
drop table t1;
|
||||
|
||||
create table t1 (a int, b int as (a*2));
|
||||
--error ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN
|
||||
alter table t1 add index (b);
|
||||
--error ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN
|
||||
alter table t1 add index (a,b);
|
||||
drop table t1;
|
||||
|
||||
create table t1 (a int, b int as (a*2) persistent);
|
||||
alter table t1 add index (b);
|
||||
drop table t1;
|
||||
|
||||
create table t1 (a int, b int as (a*2) persistent);
|
||||
alter table t1 add index (a,b);
|
||||
create table t2 like t1;
|
||||
drop table t2;
|
||||
drop table t1;
|
||||
|
||||
--echo # Testing data manipulation operations involving INDEX
|
||||
--echo # on virtual columns can be found in:
|
||||
--echo # - vcol_select.inc
|
||||
|
||||
--echo #
|
||||
--echo # TODO: FULLTEXT INDEX
|
||||
|
||||
--echo # SPATIAL INDEX
|
||||
if (!$skip_spatial_index_check)
|
||||
{
|
||||
--echo # Error "All parts of a SPATIAL index must be NOT NULL"
|
||||
--error ER_SPATIAL_CANT_HAVE_NULL
|
||||
create table t1 (a int, b int as (a+1) persistent, spatial index (b));
|
||||
create table t1 (a int, b int as (a+1) persistent);
|
||||
--error ER_SPATIAL_CANT_HAVE_NULL
|
||||
alter table t1 add spatial index (b);
|
||||
drop table t1;
|
||||
}
|
||||
|
||||
--echo # FOREIGN KEY
|
||||
|
||||
--echo # Rejected FK options.
|
||||
--error ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN
|
||||
create table t1 (a int, b int as (a+1) persistent,
|
||||
foreign key (b) references t2(a) on update set null);
|
||||
--error ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN
|
||||
create table t1 (a int, b int as (a+1) persistent,
|
||||
foreign key (b) references t2(a) on update cascade);
|
||||
--error ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN
|
||||
create table t1 (a int, b int as (a+1) persistent,
|
||||
foreign key (b) references t2(a) on delete set null);
|
||||
|
||||
create table t1 (a int, b int as (a+1) persistent);
|
||||
--error ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN
|
||||
alter table t1 add foreign key (b) references t2(a) on update set null;
|
||||
--error ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN
|
||||
alter table t1 add foreign key (b) references t2(a) on update cascade;
|
||||
--error ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN
|
||||
alter table t1 add foreign key (b) references t2(a) on delete set null;
|
||||
drop table t1;
|
||||
|
||||
--error ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN
|
||||
create table t1 (a int, b int as (a+1),
|
||||
foreign key (b) references t2(a));
|
||||
|
||||
create table t1 (a int, b int as (a+1));
|
||||
--error ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN
|
||||
alter table t1 add foreign key (b) references t2(a);
|
||||
drop table t1;
|
||||
|
||||
--echo # Allowed FK options.
|
||||
create table t2 (a int primary key, b char(5));
|
||||
create table t1 (a int, b int as (a % 10) persistent,
|
||||
foreign key (b) references t2(a) on update restrict);
|
||||
drop table t1;
|
||||
create table t1 (a int, b int as (a % 10) persistent,
|
||||
foreign key (b) references t2(a) on update no action);
|
||||
drop table t1;
|
||||
create table t1 (a int, b int as (a % 10) persistent,
|
||||
foreign key (b) references t2(a) on delete restrict);
|
||||
drop table t1;
|
||||
create table t1 (a int, b int as (a % 10) persistent,
|
||||
foreign key (b) references t2(a) on delete cascade);
|
||||
drop table t1;
|
||||
create table t1 (a int, b int as (a % 10) persistent,
|
||||
foreign key (b) references t2(a) on delete no action);
|
||||
drop table t1;
|
||||
|
||||
--echo
|
||||
--echo # Testing data manipulation operations involving FOREIGN KEY
|
||||
--echo # on virtual columns can be found in:
|
||||
--echo # - vcol_ins_upd.inc
|
||||
--echo # - vcol_select.inc
|
||||
|
||||
--echo #
|
||||
--echo # TODO: CHECK
|
||||
|
162
mysql-test/suite/vcol/inc/vcol_non_stored_columns.inc
Normal file
162
mysql-test/suite/vcol/inc/vcol_non_stored_columns.inc
Normal file
@ -0,0 +1,162 @@
|
||||
################################################################################
|
||||
# inc/vcol_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: Oleksandr Byelkin (Monty program Ab)
|
||||
# Date: 2009-03-24
|
||||
# Change: Syntax changed
|
||||
################################################################################
|
||||
|
||||
--echo # Case 1. All non-stored columns.
|
||||
--echo # This scenario is currently impossible due to the fact that virtual columns
|
||||
--echo # with a constant expression are not allowed.
|
||||
|
||||
--echo # Case 2. CREATE
|
||||
--echo # - Column1: "real"
|
||||
--echo # - Column 2: virtual non-stored
|
||||
create table t1 (a int, b int as (-a));
|
||||
insert into t1 values (1,default);
|
||||
select * from t1;
|
||||
insert into t1 values (2,default);
|
||||
select * from t1;
|
||||
drop table t1;
|
||||
|
||||
--echo # Case 3. CREATE
|
||||
--echo # - Column1: "real"
|
||||
--echo # - Column 2: virtual stored
|
||||
create table t1 (a int, b int as (-a) persistent);
|
||||
insert into t1 values (1,default);
|
||||
select * from t1;
|
||||
insert into t1 values (2,default);
|
||||
select * from t1;
|
||||
drop table t1;
|
||||
|
||||
--echo # Case 4. CREATE
|
||||
--echo # - Column1: virtual non-stored
|
||||
--echo # - Column2: "real"
|
||||
create table t1 (a int as (-b), b int);
|
||||
insert into t1 values (default,1);
|
||||
select * from t1;
|
||||
insert into t1 values (default,2);
|
||||
select * from t1;
|
||||
drop table t1;
|
||||
|
||||
--echo # Case 5. CREATE
|
||||
--echo # - Column1: virtual stored
|
||||
--echo # - Column2: "real"
|
||||
create table t1 (a int as (-b) persistent, b int);
|
||||
insert into t1 values (default,1);
|
||||
select * from t1;
|
||||
insert into t1 values (default,2);
|
||||
select * from t1;
|
||||
drop table t1;
|
||||
|
||||
--echo # Case 6. CREATE
|
||||
--echo # - Column1: "real"
|
||||
--echo # - Column2: virtual non-stored
|
||||
--echo # - Column3: virtual stored
|
||||
create table t1 (a int, b int as (-a), c int as (-a) persistent);
|
||||
insert into t1 values (1,default,default);
|
||||
select * from t1;
|
||||
insert into t1 values (2,default,default);
|
||||
select * from t1;
|
||||
drop table t1;
|
||||
|
||||
--echo # Case 7. ALTER. Modify virtual stored -> virtual non-stored
|
||||
create table t1 (a int, b int as (a % 2) persistent);
|
||||
--error ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN
|
||||
alter table t1 modify b int as (a % 2);
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
|
||||
--echo # Case 8. ALTER. Modify virtual non-stored -> virtual stored
|
||||
create table t1 (a int, b int as (a % 2));
|
||||
--error ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN
|
||||
alter table t1 modify b int as (a % 2) persistent;
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
|
||||
--echo # Case 9. CREATE LIKE
|
||||
--echo # - Column1: "real"
|
||||
--echo # - Column2: virtual non-stored
|
||||
--echo # - Column3: virtual stored
|
||||
create table t1 (a int, b int as (-a), c int as (-a) persistent);
|
||||
create table t2 like t1;
|
||||
insert into t2 values (1,default,default);
|
||||
select * from t2;
|
||||
insert into t2 values (2,default,default);
|
||||
select * from t2;
|
||||
drop table t2;
|
||||
drop table t1;
|
||||
|
||||
--echo # Case 10. ALTER. Dropping a virtual non-stored column.
|
||||
--echo # - Column1: virtual non-stored
|
||||
--echo # - Column2: "real"
|
||||
create table t1 (a int as (-b), b int, c varchar(5));
|
||||
insert into t1 values (default,1,'v1');
|
||||
insert into t1 values (default,2,'v2');
|
||||
select * from t1;
|
||||
alter table t1 drop column a;
|
||||
select * from t1;
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
|
||||
--echo # Case 11. ALTER. Dropping a virtual stored column.
|
||||
--echo # - Column1: virtual stored
|
||||
--echo # - Column2: "real"
|
||||
create table t1 (a int as (-b) persistent, b int, c char(5));
|
||||
insert into t1 values (default,1,'v1');
|
||||
insert into t1 values (default,2,'v2');
|
||||
select * from t1;
|
||||
alter table t1 drop column a;
|
||||
select * from t1;
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
|
||||
--echo # Case 12. ALTER. Adding a new virtual non-stored column.
|
||||
create 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;
|
||||
alter table t1 add column c int as (dayofyear(b)) after a;
|
||||
select * from t1;
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
|
||||
--echo # Case 13. ALTER. Adding a new virtual stored column.
|
||||
create 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;
|
||||
alter table t1 add column c int as (dayofyear(b)) persistent after a;
|
||||
select * from t1;
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
|
||||
--echo # Case 14. ALTER. Changing the expression of a virtual stored column.
|
||||
create table t1 (a int, b datetime, c int as (week(b)) persistent);
|
||||
insert into t1 values (1,'2008-09-04',default);
|
||||
insert into t1 values (2,'2008-09-05',default);
|
||||
select * from t1;
|
||||
alter table t1 change column c c int as (week(b,1)) persistent;
|
||||
select * from t1;
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
|
||||
--echo # Case 15. ALTER. Changing the expression of a virtual non-stored column.
|
||||
create table t1 (a int, b datetime, c int as (week(b)));
|
||||
insert into t1 values (1,'2008-09-04',default);
|
||||
insert into t1 values (2,'2008-09-05',default);
|
||||
select * from t1;
|
||||
alter table t1 change column c c int as (week(b,1));
|
||||
select * from t1;
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
|
160
mysql-test/suite/vcol/inc/vcol_partition.inc
Normal file
160
mysql-test/suite/vcol/inc/vcol_partition.inc
Normal file
@ -0,0 +1,160 @@
|
||||
################################################################################
|
||||
# inc/vcol_partition.inc #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Testing partitioning tables with virtual columns. #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-09-04 #
|
||||
# Change Author: Oleksandr Byelkin (Monty program Ab)
|
||||
# Date: 2009-03-24
|
||||
# Change: Syntax changed
|
||||
################################################################################
|
||||
|
||||
--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 virtual column.
|
||||
|
||||
CREATE TABLE t1 (
|
||||
a DATE NOT NULL,
|
||||
b int as (year(a))
|
||||
)
|
||||
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/mysqld.1/data/test/t1*p?.MYD files
|
||||
let $myisam_engine = `select @@session.storage_engine='myisam'`;
|
||||
if ($myisam_engine)
|
||||
{
|
||||
--echo # Check how data is physically partitioned.
|
||||
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
||||
--exec du -b $MYSQLTEST_VARDIR/mysqld.1/data/test/t1*p?.MYD
|
||||
}
|
||||
|
||||
--echo # Modify the expression of virtual column b
|
||||
ALTER TABLE t1 modify b int as (year(a)-1);
|
||||
|
||||
select * from t1;
|
||||
|
||||
if ($myisam_engine)
|
||||
{
|
||||
--echo # Check how data is physically partitioned.
|
||||
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
||||
--exec du -b $MYSQLTEST_VARDIR/mysqld.1/data/test/t1*p?.MYD
|
||||
}
|
||||
|
||||
drop table t1;
|
||||
|
||||
--echo # Case 2. Partitioning by LIST based on a stored virtual column.
|
||||
|
||||
CREATE TABLE t1 (a int, b int as (a % 3 ) persistent)
|
||||
PARTITION BY LIST (a+1)
|
||||
(PARTITION p1 VALUES IN (1), PARTITION p2 VALUES IN (2));
|
||||
|
||||
insert into t1 values (1,default);
|
||||
if ($myisam_engine)
|
||||
{
|
||||
--echo # Check how data is physically partitioned.
|
||||
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
||||
--exec du -b $MYSQLTEST_VARDIR/mysqld.1/data/test/t1*p?.MYD
|
||||
}
|
||||
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 virtual 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 int as ((a % 3)+1) persistent;
|
||||
#--error ER_NO_PARTITION_FOR_GIVEN_VALUE
|
||||
#alter table t1 change b b int as (a % 2) persistent;
|
||||
#if ($myisam_engine)
|
||||
#{
|
||||
# --echo # Check how data is physically partitioned.
|
||||
# --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
||||
# --exec du -b $MYSQLTEST_VARDIR/mysqld.1/data/test/t1*p?.MYD
|
||||
#}
|
||||
|
||||
select * from t1;
|
||||
|
||||
drop table t1;
|
||||
|
||||
--echo # Case 3. Partitioning by HASH based on a non-stored virtual column.
|
||||
|
||||
CREATE TABLE t1 (
|
||||
a DATE NOT NULL,
|
||||
b int as (year(a))
|
||||
)
|
||||
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;
|
||||
|
||||
if ($myisam_engine)
|
||||
{
|
||||
--echo # Check how data is physically partitioned.
|
||||
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
||||
--exec du -b $MYSQLTEST_VARDIR/mysqld.1/data/test/t1*p?.MYD
|
||||
}
|
||||
|
||||
--echo # Modify the expression of virtual column b
|
||||
ALTER TABLE t1 modify b int as (year(a)-1);
|
||||
|
||||
select * from t1;
|
||||
|
||||
if ($myisam_engine)
|
||||
{
|
||||
--echo # Check how data is physically partitioned.
|
||||
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
||||
--exec du -b $MYSQLTEST_VARDIR/mysqld.1/data/test/t1*p?.MYD
|
||||
}
|
||||
|
||||
drop table t1;
|
216
mysql-test/suite/vcol/inc/vcol_select.inc
Normal file
216
mysql-test/suite/vcol/inc/vcol_select.inc
Normal file
@ -0,0 +1,216 @@
|
||||
################################################################################
|
||||
# inc/vcol_select.inc #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Testing different SELECTs. #
|
||||
# #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-09-18 #
|
||||
# Change Author: Oleksandr Byelkin (Monty program Ab)
|
||||
# Date: 2009-03-24
|
||||
# Change: Syntax changed
|
||||
################################################################################
|
||||
|
||||
# Table t1 is used below to test:
|
||||
# - Join type of ALL (sequential scan of the entire table)
|
||||
# - Join type of Index
|
||||
# - Join type of Range
|
||||
# - Join type of Ref_or_null
|
||||
create table t1 (a int,
|
||||
b int as (-a),
|
||||
c int as (-a) persistent,
|
||||
index (c));
|
||||
insert into t1 (a) values (2), (1), (1), (3), (NULL);
|
||||
|
||||
# Table t2 is used below to test:
|
||||
# - Join type of system and const
|
||||
create table t2 like t1;
|
||||
insert into t2 (a) values (1);
|
||||
|
||||
# Table t3 is used below to test
|
||||
# - Join type of Eq_ref with a unique virtual column
|
||||
# - Join type of Const
|
||||
create table t3 (a int primary key,
|
||||
b int as (-a),
|
||||
c int as (-a) persistent unique);
|
||||
insert into t3 (a) values (2),(1),(3);
|
||||
|
||||
|
||||
--echo # select_type=SIMPLE, type=system
|
||||
let $s = select * from t2;
|
||||
eval $s;
|
||||
eval explain $s;
|
||||
|
||||
let $s = select * from t2 where c=-1;
|
||||
eval $s;
|
||||
eval explain $s;
|
||||
|
||||
--echo # select_type=SIMPLE, type=ALL
|
||||
let $s = select * from t1 where b=-1;
|
||||
eval $s;
|
||||
eval explain $s;
|
||||
|
||||
--echo # select_type=SIMPLE, type=const
|
||||
let $s = select * from t3 where a=1;
|
||||
eval $s;
|
||||
eval explain $s;
|
||||
|
||||
--echo # select_type=SIMPLE, type=range
|
||||
let $s = select * from t3 where c>=-1;
|
||||
eval $s;
|
||||
eval explain $s;
|
||||
|
||||
--echo # select_type=SIMPLE, type=ref
|
||||
let $s = select * from t1,t3 where t1.c=t3.c and t3.c=-1;
|
||||
eval $s;
|
||||
eval explain $s;
|
||||
|
||||
--echo # select_type=PRIMARY, type=index,ALL
|
||||
let $s = select * from t1 where b in (select c from t3);
|
||||
eval $s;
|
||||
eval explain $s;
|
||||
|
||||
--echo # select_type=PRIMARY, type=range,ref
|
||||
let $s = select * from t1 where c in (select c from t3 where c between -2 and -1);
|
||||
eval $s;
|
||||
eval explain $s;
|
||||
|
||||
--echo # select_type=UNION, type=system
|
||||
--echo # select_type=UNION RESULT, type=<union1,2>
|
||||
let $s = select * from t1 union select * from t2;
|
||||
eval $s;
|
||||
eval explain $s;
|
||||
|
||||
--echo # select_type=DERIVED, type=system
|
||||
let $s = select * from (select a,b,c from t1) as t11;
|
||||
eval $s;
|
||||
eval explain $s;
|
||||
|
||||
--echo ###
|
||||
--echo ### Using aggregate functions with/without DISTINCT
|
||||
--echo ###
|
||||
--echo # SELECT COUNT(*) FROM tbl_name
|
||||
let $s = select count(*) from t1;
|
||||
eval $s;
|
||||
eval explain $s;
|
||||
|
||||
--echo # SELECT COUNT(DISTINCT <non-vcol>) FROM tbl_name
|
||||
let $s = select count(distinct a) from t1;
|
||||
eval $s;
|
||||
eval explain $s;
|
||||
|
||||
--echo # SELECT COUNT(DISTINCT <non-stored vcol>) FROM tbl_name
|
||||
let $s = select count(distinct b) from t1;
|
||||
eval $s;
|
||||
eval explain $s;
|
||||
|
||||
--echo # SELECT COUNT(DISTINCT <stored vcol>) FROM tbl_name
|
||||
let $s = select count(distinct c) from t1;
|
||||
eval $s;
|
||||
eval explain $s;
|
||||
|
||||
--echo ###
|
||||
--echo ### filesort & range-based utils
|
||||
--echo ###
|
||||
--echo # SELECT * FROM tbl_name WHERE <vcol expr>
|
||||
let $s = select * from t3 where c >= -2;
|
||||
eval $s;
|
||||
eval explain $s;
|
||||
|
||||
--echo # SELECT * FROM tbl_name WHERE <non-vcol expr>
|
||||
let $s = select * from t3 where a between 1 and 2;
|
||||
eval $s;
|
||||
eval explain $s;
|
||||
|
||||
--echo # SELECT * FROM tbl_name WHERE <non-indexed vcol expr>
|
||||
let $s = select * from t3 where b between -2 and -1;
|
||||
eval $s;
|
||||
eval explain $s;
|
||||
|
||||
--echo # SELECT * FROM tbl_name WHERE <indexed vcol expr>
|
||||
let $s = select * from t3 where c between -2 and -1;
|
||||
eval $s;
|
||||
eval explain $s;
|
||||
|
||||
#### Remove for MyISAM due to a bug
|
||||
#### when all the three records are returned (a=1,2,3)
|
||||
#### instead of just two (a=1,2).
|
||||
#### This bug is presumably in base SQL routines as the same happens
|
||||
#### with this table:
|
||||
#### create table t4 (a int primary key, b int, c int unique);
|
||||
let $myisam_engine = `SELECT @@session.storage_engine='myisam'`;
|
||||
if (!$myisam_engine)
|
||||
{
|
||||
--echo # SELECT * FROM tbl_name WHERE <non-vcol expr> ORDER BY <non-indexed vcol>
|
||||
let $s = select * from t3 where a between 1 and 2 order by b;
|
||||
eval $s;
|
||||
eval explain $s;
|
||||
}
|
||||
|
||||
--echo # SELECT * FROM tbl_name WHERE <non-vcol expr> ORDER BY <indexed vcol>
|
||||
let $s = select * from t3 where a between 1 and 2 order by c;
|
||||
eval $s;
|
||||
eval explain $s;
|
||||
|
||||
--echo # SELECT * FROM tbl_name WHERE <non-indexed vcol expr> ORDER BY <non-vcol>
|
||||
let $s = select * from t3 where b between -2 and -1 order by a;
|
||||
eval $s;
|
||||
eval explain $s;
|
||||
|
||||
#### Remove for MyISAM due to a bug
|
||||
#### when all the three records are returned (a=1,2,3)
|
||||
#### instead of just two (a=1,2).
|
||||
#### This bug is presumably in base SQL routines as the same happens
|
||||
#### with this table:
|
||||
#### create table t4 (a int primary key, b int, c int unique);
|
||||
let $innodb_engine = `SELECT @@session.storage_engine='innodb'`;
|
||||
if (!$innodb_engine)
|
||||
{
|
||||
--echo # SELECT * FROM tbl_name WHERE <indexed vcol expr> ORDER BY <non-vcol>
|
||||
let $s = select * from t3 where c between -2 and -1 order by a;
|
||||
eval $s;
|
||||
eval explain $s;
|
||||
}
|
||||
|
||||
--echo # SELECT * FROM tbl_name WHERE <non-indexed vcol expr> ORDER BY <non-indexed vcol>
|
||||
let $s = select * from t3 where b between -2 and -1 order by b;
|
||||
eval $s;
|
||||
eval explain $s;
|
||||
|
||||
--echo # SELECT * FROM tbl_name WHERE <indexed vcol expr> ORDER BY <non-indexed vcol>
|
||||
let $s = select * from t3 where c between -2 and -1 order by b;
|
||||
eval $s;
|
||||
eval explain $s;
|
||||
|
||||
--echo # SELECT * FROM tbl_name WHERE <non-indexed vcol expr> ORDER BY <indexed vcol>
|
||||
let $s = select * from t3 where b between -2 and -1 order by c;
|
||||
eval $s;
|
||||
eval explain $s;
|
||||
|
||||
--echo # SELECT * FROM tbl_name WHERE <indexed vcol expr> ORDER BY <indexed vcol>
|
||||
let $s = select * from t3 where c between -2 and -1 order by c;
|
||||
eval $s;
|
||||
eval explain $s;
|
||||
|
||||
--echo # SELECT sum(<non-indexed vcol>) FROM tbl_name GROUP BY <non-indexed vcol>
|
||||
let $s = select sum(b) from t1 group by b;
|
||||
eval $s;
|
||||
eval explain $s;
|
||||
|
||||
--echo # SELECT sum(<indexed vcol>) FROM tbl_name GROUP BY <indexed vcol>
|
||||
let $s = select sum(c) from t1 group by c;
|
||||
eval $s;
|
||||
eval explain $s;
|
||||
|
||||
--echo # SELECT sum(<non-indexed vcol>) FROM tbl_name GROUP BY <indexed vcol>
|
||||
let $s = select sum(b) from t1 group by c;
|
||||
eval $s;
|
||||
eval explain $s;
|
||||
|
||||
--echo # SELECT sum(<indexed vcol>) FROM tbl_name GROUP BY <non-indexed vcol>
|
||||
let $s = select sum(c) from t1 group by b;
|
||||
eval $s;
|
||||
eval explain $s;
|
||||
|
42
mysql-test/suite/vcol/inc/vcol_supported_sql_funcs.inc
Normal file
42
mysql-test/suite/vcol/inc/vcol_supported_sql_funcs.inc
Normal file
@ -0,0 +1,42 @@
|
||||
################################################################################
|
||||
# inc/vcol_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)
|
||||
{
|
||||
eval insert into t1 values ($values1);
|
||||
dec $rows;
|
||||
}
|
||||
if ($rows)
|
||||
{
|
||||
eval insert into t1 values ($values2);
|
||||
dec $rows;
|
||||
}
|
||||
if ($rows)
|
||||
{
|
||||
eval insert into t1 values ($values3);
|
||||
dec $rows;
|
||||
}
|
||||
if ($rows)
|
||||
{
|
||||
eval insert into t1 values ($values4);
|
||||
dec $rows;
|
||||
}
|
||||
select * from t1;
|
||||
drop table t1;
|
||||
set sql_warnings = 0;
|
1228
mysql-test/suite/vcol/inc/vcol_supported_sql_funcs_main.inc
Normal file
1228
mysql-test/suite/vcol/inc/vcol_supported_sql_funcs_main.inc
Normal file
File diff suppressed because it is too large
Load Diff
110
mysql-test/suite/vcol/inc/vcol_trigger_sp.inc
Normal file
110
mysql-test/suite/vcol/inc/vcol_trigger_sp.inc
Normal file
@ -0,0 +1,110 @@
|
||||
################################################################################
|
||||
# inc/vcol_trigger_sp.inc #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Testing triggers, stored procedures and functions #
|
||||
# defined on tables with virtual columns. #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-09-04 #
|
||||
# Change Author: Oleksandr Byelkin (Monty program Ab)
|
||||
# Date: 2009-03-24
|
||||
# Change: Syntax changed
|
||||
################################################################################
|
||||
|
||||
create table t1 (a int,
|
||||
b int as (a/10),
|
||||
c int as (a/10) persistent);
|
||||
|
||||
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);
|
||||
select * from t1;
|
||||
select * from t2;
|
||||
|
||||
insert into t1 (a) values (600);
|
||||
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();
|
||||
|
||||
select * from t2;
|
||||
select * from t1;
|
||||
|
||||
drop table t1,t2;
|
||||
drop procedure p1;
|
@ -0,0 +1,21 @@
|
||||
################################################################################
|
||||
# inc/vcol_unsupported_storage_engines.inc #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Ensure that defining a virtual column for an unsupported table type #
|
||||
# results in a graceful error. #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-09-02 #
|
||||
# Change Author: Oleksandr Byelkin (Monty program Ab)
|
||||
# Date: 2009-03-24
|
||||
# Change: Syntax changed
|
||||
################################################################################
|
||||
|
||||
--error ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN
|
||||
create table t1 (a int, b int as (a+1));
|
||||
create table t1 (a int);
|
||||
--error ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN
|
||||
alter table t1 add column b int as (a+1);
|
||||
drop table t1;
|
201
mysql-test/suite/vcol/inc/vcol_view.inc
Normal file
201
mysql-test/suite/vcol/inc/vcol_view.inc
Normal file
@ -0,0 +1,201 @@
|
||||
################################################################################
|
||||
# inc/vcol_view.inc #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Testing views defined on tables with virtual columns. #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-09-04 #
|
||||
# Change Author: Oleksandr Byelkin (Monty program Ab)
|
||||
# Date: 2009-03-24
|
||||
# Change: Syntax changed
|
||||
################################################################################
|
||||
|
||||
|
||||
|
||||
create table t1 (a int not null,
|
||||
b int as (-a),
|
||||
c int as (-a) persistent);
|
||||
insert into t1 (a) values (1), (1), (2), (2), (3);
|
||||
|
||||
# simple view
|
||||
create view v1 (d,e) as select abs(b), abs(c) from t1;
|
||||
select d,e from v1;
|
||||
select is_updatable from information_schema.views where table_name='v1';
|
||||
|
||||
# view with different algorithms (explain output differs)
|
||||
explain extended select d,e from v1;
|
||||
create algorithm=temptable view v2 (d,e) as select abs(b), abs(c) from t1;
|
||||
show create view v2;
|
||||
select d,e from v2;
|
||||
explain extended select d,e from v2;
|
||||
|
||||
# VIEW on VIEW test
|
||||
create view v3 (d,e) as select d*2, e*2 from v1;
|
||||
select * from v3;
|
||||
explain extended select * from v3;
|
||||
|
||||
drop view v1,v2,v3;
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# DISTINCT option for VIEW
|
||||
#
|
||||
create table t1 (a int not null,
|
||||
b int as (-a),
|
||||
c int as (-a) persistent);
|
||||
insert into t1 (a) values (1), (2), (3), (1), (2), (3);
|
||||
create view v1 as select distinct b from t1;
|
||||
select * from v1;
|
||||
explain select * from v1;
|
||||
select * from t1;
|
||||
drop view v1;
|
||||
create view v1 as select distinct c from t1;
|
||||
select * from v1;
|
||||
explain select * from v1;
|
||||
select * from t1;
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# LIMIT clause test
|
||||
#
|
||||
create table t1 (a int not null,
|
||||
b int as (-a),
|
||||
c int as (-a) persistent);
|
||||
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;
|
||||
explain select * from v1;
|
||||
drop view v1;
|
||||
create view v1 as select c+1 from t1 order by 1 desc limit 2;
|
||||
select * from v1;
|
||||
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 as (-a),
|
||||
d int as (-a) persistent,
|
||||
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;
|
||||
select * from t1;
|
||||
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 as (-a),
|
||||
c int as (-a) persistent,
|
||||
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;
|
||||
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;
|
||||
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 as (-a1),
|
||||
c1 int as (-a1) persistent);
|
||||
create table t2 (a2 int,
|
||||
b2 int as (-a2),
|
||||
c2 int as (-a2) persistent);
|
||||
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;
|
||||
select * from v1;
|
||||
drop view v1;
|
||||
drop table t1, t2;
|
||||
|
||||
#
|
||||
# Showing VIEW with VIEWs in subquery
|
||||
#
|
||||
create table t1 (a int,
|
||||
b int as (-a),
|
||||
c int as (-a) persistent);
|
||||
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 as (-a),
|
||||
c int as (-a) persistent);
|
||||
insert into t1 (a) values (1),(1),(2),(2),(3),(3);
|
||||
create view v1 as select b from t1;
|
||||
select distinct b from v1;
|
||||
select distinct b from v1 limit 2;
|
||||
select distinct b from t1 limit 2;
|
||||
prepare stmt1 from "select distinct b from v1 limit 2";
|
||||
execute stmt1;
|
||||
execute stmt1;
|
||||
deallocate prepare stmt1;
|
||||
drop view v1;
|
||||
create view v1 as select c from t1;
|
||||
select distinct c from v1;
|
||||
select distinct c from v1 limit 2;
|
||||
select distinct c from t1 limit 2;
|
||||
prepare stmt1 from "select distinct c from v1 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 as (-a),
|
||||
c int as (-a) persistent);
|
||||
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);
|
||||
select * from t1;
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
|
25
mysql-test/suite/vcol/r/rpl_vcol.result
Normal file
25
mysql-test/suite/vcol/r/rpl_vcol.result
Normal file
@ -0,0 +1,25 @@
|
||||
SET @@session.storage_engine = 'InnoDB';
|
||||
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;
|
||||
create table t1 (a int, b int as (a+1));
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` int(11) AS (a+1) VIRTUAL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
insert into t1 values (1,default);
|
||||
insert into t1 values (2,default);
|
||||
select * from t1;
|
||||
a b
|
||||
1 2
|
||||
2 3
|
||||
select * from t1;
|
||||
a b
|
||||
1 2
|
||||
2 3
|
||||
drop table t1;
|
7
mysql-test/suite/vcol/r/vcol_archive.result
Normal file
7
mysql-test/suite/vcol/r/vcol_archive.result
Normal file
@ -0,0 +1,7 @@
|
||||
SET @@session.storage_engine = 'archive';
|
||||
create table t1 (a int, b int as (a+1));
|
||||
ERROR HY000: 'Specified storage engine' is not yet supported for computed columns.
|
||||
create table t1 (a int);
|
||||
alter table t1 add column b int as (a+1);
|
||||
ERROR HY000: 'Specified storage engine' is not yet supported for computed columns.
|
||||
drop table t1;
|
7
mysql-test/suite/vcol/r/vcol_blackhole.result
Normal file
7
mysql-test/suite/vcol/r/vcol_blackhole.result
Normal file
@ -0,0 +1,7 @@
|
||||
SET @@session.storage_engine = 'blackhole';
|
||||
create table t1 (a int, b int as (a+1));
|
||||
ERROR HY000: 'Specified storage engine' is not yet supported for computed columns.
|
||||
create table t1 (a int);
|
||||
alter table t1 add column b int as (a+1);
|
||||
ERROR HY000: 'Specified storage engine' is not yet supported for computed columns.
|
||||
drop table t1;
|
243
mysql-test/suite/vcol/r/vcol_blocked_sql_funcs_innodb.result
Normal file
243
mysql-test/suite/vcol/r/vcol_blocked_sql_funcs_innodb.result
Normal file
@ -0,0 +1,243 @@
|
||||
SET @@session.storage_engine = 'InnoDB';
|
||||
# RAND()
|
||||
create table t1 (b double as (rand()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# LOAD_FILE()
|
||||
create table t1 (a varchar(64), b varchar(1024) as (load_file(a)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# CURDATE()
|
||||
create table t1 (a datetime as (curdate()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'a'.
|
||||
# CURRENT_DATE(), CURRENT_DATE
|
||||
create table t1 (a datetime as (current_date));
|
||||
ERROR HY000: Function or expression is not allowed for column 'a'.
|
||||
create table t1 (a datetime as (current_date()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'a'.
|
||||
# CURRENT_TIME(), CURRENT_TIME
|
||||
create table t1 (a datetime as (current_time));
|
||||
ERROR HY000: Function or expression is not allowed for column 'a'.
|
||||
create table t1 (a datetime as (current_time()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'a'.
|
||||
# CURRENT_TIMESTAMP(), CURRENT_TIMESTAMP
|
||||
create table t1 (a datetime as (current_timestamp()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'a'.
|
||||
create table t1 (a datetime as (current_timestamp));
|
||||
ERROR HY000: Function or expression is not allowed for column 'a'.
|
||||
# CURTIME()
|
||||
create table t1 (a datetime as (curtime()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'a'.
|
||||
# LOCALTIME(), LOCALTIME
|
||||
create table t1 (a datetime, b varchar(10) as (localtime()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
create table t1 (a datetime, b varchar(10) as (localtime));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# LOCALTIMESTAMP, LOCALTIMESTAMP()(v4.0.6)
|
||||
create table t1 (a datetime, b varchar(10) as (localtimestamp()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
create table t1 (a datetime, b varchar(10) as (localtimestamp));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# NOW()
|
||||
create table t1 (a datetime, b varchar(10) as (now()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# SYSDATE()
|
||||
create table t1 (a int, b varchar(10) as (sysdate()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# UNIX_TIMESTAMP()
|
||||
create table t1 (a datetime, b datetime as (unix_timestamp()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# UTC_DATE()
|
||||
create table t1 (a datetime, b datetime as (utc_date()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# UTC_TIME()
|
||||
create table t1 (a datetime, b datetime as (utc_time()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# UTC_TIMESTAMP()
|
||||
create table t1 (a datetime, b datetime as (utc_timestamp()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# MATCH()
|
||||
# BENCHMARK()
|
||||
create table t1 (a varchar(1024), b varchar(1024) as (benchmark(a,3)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# CONNECTION_ID()
|
||||
create table t1 (a int as (connection_id()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'a'.
|
||||
# CURRENT_USER(), CURRENT_USER
|
||||
create table t1 (a varchar(32) as (current_user()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'a'.
|
||||
create table t1 (a varchar(32) as (current_user));
|
||||
ERROR HY000: Function or expression is not allowed for column 'a'.
|
||||
# DATABASE()
|
||||
create table t1 (a varchar(1024), b varchar(1024) as (database()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# FOUND_ROWS()
|
||||
create table t1 (a varchar(1024), b varchar(1024) as (found_rows()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# GET_LOCK()
|
||||
create table t1 (a varchar(1024), b varchar(1024) as (get_lock(a,10)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# IS_FREE_LOCK()
|
||||
create table t1 (a varchar(1024), b varchar(1024) as (is_free_lock(a)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# IS_USED_LOCK()
|
||||
create table t1 (a varchar(1024), b varchar(1024) as (is_used_lock(a)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# LAST_INSERT_ID()
|
||||
create table t1 (a int as (last_insert_id()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'a'.
|
||||
# MASTER_POS_WAIT()
|
||||
create table t1 (a varchar(32), b int as (master_pos_wait(a,0,2)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# NAME_CONST()
|
||||
create table t1 (a varchar(32) as (name_const('test',1)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'a'.
|
||||
# RELEASE_LOCK()
|
||||
create table t1 (a varchar(32), b int as (release_lock(a)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# ROW_COUNT()
|
||||
create table t1 (a int as (row_count()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'a'.
|
||||
# SCHEMA()
|
||||
create table t1 (a varchar(32) as (schema()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'a'.
|
||||
# SESSION_USER()
|
||||
create table t1 (a varchar(32) as (session_user()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'a'.
|
||||
# SLEEP()
|
||||
create table t1 (a int, b int as (sleep(a)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# SYSTEM_USER()
|
||||
create table t1 (a varchar(32) as (system_user()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'a'.
|
||||
# USER()
|
||||
create table t1 (a varchar(1024), b varchar(1024) as (user()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# UUID_SHORT()
|
||||
create table t1 (a varchar(1024) as (uuid_short()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'a'.
|
||||
# UUID()
|
||||
create table t1 (a varchar(1024) as (uuid()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'a'.
|
||||
# VALUES()
|
||||
create table t1 (a varchar(1024), b varchar(1024) as (values(a)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# VERSION()
|
||||
create table t1 (a varchar(1024), b varchar(1024) as (version()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# ENCRYPT()
|
||||
create table t1 (a varchar(1024), b varchar(1024) as (encrypt(a)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# Stored procedures
|
||||
create procedure p1()
|
||||
begin
|
||||
select current_user();
|
||||
end //
|
||||
create function f1()
|
||||
returns int
|
||||
begin
|
||||
return 1;
|
||||
end //
|
||||
create table t1 (a int as (p1()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'a'.
|
||||
create table t1 (a int as (f1()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'a'.
|
||||
drop procedure p1;
|
||||
drop function f1;
|
||||
# Unknown functions
|
||||
create table t1 (a int as (f1()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'a'.
|
||||
#
|
||||
# GROUP BY FUNCTIONS
|
||||
#
|
||||
# AVG()
|
||||
create table t1 (a int, b int as (avg(a)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# BIT_AND()
|
||||
create table t1 (a int, b int as (bit_and(a)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# BIT_OR()
|
||||
create table t1 (a int, b int as (bit_or(a)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# BIT_XOR()
|
||||
create table t1 (a int, b int as (bit_xor(a)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# COUNT(DISTINCT)
|
||||
create table t1 (a int, b int as (count(distinct a)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# COUNT()
|
||||
create table t1 (a int, b int as (count(a)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# GROUP_CONCAT()
|
||||
create table t1 (a varchar(32), b int as (group_concat(a,'')));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# MAX()
|
||||
create table t1 (a int, b int as (max(a)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# MIN()
|
||||
create table t1 (a int, b int as (min(a)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# STD()
|
||||
create table t1 (a int, b int as (std(a)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# STDDEV_POP()
|
||||
create table t1 (a int, b int as (stddev_pop(a)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# STDDEV_SAMP()
|
||||
create table t1 (a int, b int as (stddev_samp(a)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# STDDEV()
|
||||
create table t1 (a int, b int as (stddev(a)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# SUM()
|
||||
create table t1 (a int, b int as (sum(a)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# VAR_POP()
|
||||
create table t1 (a int, b int as (var_pop(a)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# VAR_SAMP()
|
||||
create table t1 (a int, b int as (var_samp(a)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# VARIANCE()
|
||||
create table t1 (a int, b int as (variance(a)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
#
|
||||
# XML FUNCTIONS
|
||||
#
|
||||
# ExtractValue()
|
||||
create table t1 (a varchar(1024), b varchar(1024) as (ExtractValue(a,'//b[$@j]')));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# UpdateXML()
|
||||
create table t1 (a varchar(1024), b varchar(1024) as (UpdateXML(a,'/a','<e>fff</e>')));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
#
|
||||
# Sub-selects
|
||||
#
|
||||
create table t1 (a int);
|
||||
create table t2 (a int, b int as (select count(*) from t1));
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select count(*) from t1))' at line 1
|
||||
drop table t1;
|
||||
create table t1 (a int, b int as ((select 1)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
create table t1 (a int, b int as (a+(select 1)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
#
|
||||
# SP functions
|
||||
#
|
||||
drop function if exists sub1;
|
||||
create function sub1(i int) returns int deterministic
|
||||
return i+1;
|
||||
select sub1(1);
|
||||
sub1(1)
|
||||
2
|
||||
create table t1 (a int, b int as (a+sub3(1)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
drop function sub1;
|
||||
#
|
||||
# Long expression
|
||||
create table t1 (a int, b varchar(300) as (concat(a,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')));
|
||||
drop table t1;
|
||||
create table t1 (a int, b varchar(300) as (concat(a,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')));
|
||||
ERROR HY000: String 'concat(a,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' is too long for VIRTUAL COLUMN EXPRESSION (should be no longer than 252)
|
||||
#
|
||||
# Constant expression
|
||||
create table t1 (a int as (PI()));
|
||||
ERROR HY000: Constant expression in computed column function is not allowed.
|
245
mysql-test/suite/vcol/r/vcol_blocked_sql_funcs_myisam.result
Normal file
245
mysql-test/suite/vcol/r/vcol_blocked_sql_funcs_myisam.result
Normal file
@ -0,0 +1,245 @@
|
||||
SET @@session.storage_engine = 'MyISAM';
|
||||
# RAND()
|
||||
create table t1 (b double as (rand()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# LOAD_FILE()
|
||||
create table t1 (a varchar(64), b varchar(1024) as (load_file(a)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# CURDATE()
|
||||
create table t1 (a datetime as (curdate()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'a'.
|
||||
# CURRENT_DATE(), CURRENT_DATE
|
||||
create table t1 (a datetime as (current_date));
|
||||
ERROR HY000: Function or expression is not allowed for column 'a'.
|
||||
create table t1 (a datetime as (current_date()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'a'.
|
||||
# CURRENT_TIME(), CURRENT_TIME
|
||||
create table t1 (a datetime as (current_time));
|
||||
ERROR HY000: Function or expression is not allowed for column 'a'.
|
||||
create table t1 (a datetime as (current_time()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'a'.
|
||||
# CURRENT_TIMESTAMP(), CURRENT_TIMESTAMP
|
||||
create table t1 (a datetime as (current_timestamp()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'a'.
|
||||
create table t1 (a datetime as (current_timestamp));
|
||||
ERROR HY000: Function or expression is not allowed for column 'a'.
|
||||
# CURTIME()
|
||||
create table t1 (a datetime as (curtime()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'a'.
|
||||
# LOCALTIME(), LOCALTIME
|
||||
create table t1 (a datetime, b varchar(10) as (localtime()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
create table t1 (a datetime, b varchar(10) as (localtime));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# LOCALTIMESTAMP, LOCALTIMESTAMP()(v4.0.6)
|
||||
create table t1 (a datetime, b varchar(10) as (localtimestamp()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
create table t1 (a datetime, b varchar(10) as (localtimestamp));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# NOW()
|
||||
create table t1 (a datetime, b varchar(10) as (now()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# SYSDATE()
|
||||
create table t1 (a int, b varchar(10) as (sysdate()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# UNIX_TIMESTAMP()
|
||||
create table t1 (a datetime, b datetime as (unix_timestamp()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# UTC_DATE()
|
||||
create table t1 (a datetime, b datetime as (utc_date()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# UTC_TIME()
|
||||
create table t1 (a datetime, b datetime as (utc_time()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# UTC_TIMESTAMP()
|
||||
create table t1 (a datetime, b datetime as (utc_timestamp()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# MATCH()
|
||||
create table t1 (a varchar(32), b bool as (match a against ('sample text')));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# BENCHMARK()
|
||||
create table t1 (a varchar(1024), b varchar(1024) as (benchmark(a,3)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# CONNECTION_ID()
|
||||
create table t1 (a int as (connection_id()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'a'.
|
||||
# CURRENT_USER(), CURRENT_USER
|
||||
create table t1 (a varchar(32) as (current_user()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'a'.
|
||||
create table t1 (a varchar(32) as (current_user));
|
||||
ERROR HY000: Function or expression is not allowed for column 'a'.
|
||||
# DATABASE()
|
||||
create table t1 (a varchar(1024), b varchar(1024) as (database()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# FOUND_ROWS()
|
||||
create table t1 (a varchar(1024), b varchar(1024) as (found_rows()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# GET_LOCK()
|
||||
create table t1 (a varchar(1024), b varchar(1024) as (get_lock(a,10)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# IS_FREE_LOCK()
|
||||
create table t1 (a varchar(1024), b varchar(1024) as (is_free_lock(a)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# IS_USED_LOCK()
|
||||
create table t1 (a varchar(1024), b varchar(1024) as (is_used_lock(a)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# LAST_INSERT_ID()
|
||||
create table t1 (a int as (last_insert_id()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'a'.
|
||||
# MASTER_POS_WAIT()
|
||||
create table t1 (a varchar(32), b int as (master_pos_wait(a,0,2)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# NAME_CONST()
|
||||
create table t1 (a varchar(32) as (name_const('test',1)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'a'.
|
||||
# RELEASE_LOCK()
|
||||
create table t1 (a varchar(32), b int as (release_lock(a)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# ROW_COUNT()
|
||||
create table t1 (a int as (row_count()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'a'.
|
||||
# SCHEMA()
|
||||
create table t1 (a varchar(32) as (schema()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'a'.
|
||||
# SESSION_USER()
|
||||
create table t1 (a varchar(32) as (session_user()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'a'.
|
||||
# SLEEP()
|
||||
create table t1 (a int, b int as (sleep(a)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# SYSTEM_USER()
|
||||
create table t1 (a varchar(32) as (system_user()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'a'.
|
||||
# USER()
|
||||
create table t1 (a varchar(1024), b varchar(1024) as (user()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# UUID_SHORT()
|
||||
create table t1 (a varchar(1024) as (uuid_short()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'a'.
|
||||
# UUID()
|
||||
create table t1 (a varchar(1024) as (uuid()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'a'.
|
||||
# VALUES()
|
||||
create table t1 (a varchar(1024), b varchar(1024) as (values(a)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# VERSION()
|
||||
create table t1 (a varchar(1024), b varchar(1024) as (version()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# ENCRYPT()
|
||||
create table t1 (a varchar(1024), b varchar(1024) as (encrypt(a)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# Stored procedures
|
||||
create procedure p1()
|
||||
begin
|
||||
select current_user();
|
||||
end //
|
||||
create function f1()
|
||||
returns int
|
||||
begin
|
||||
return 1;
|
||||
end //
|
||||
create table t1 (a int as (p1()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'a'.
|
||||
create table t1 (a int as (f1()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'a'.
|
||||
drop procedure p1;
|
||||
drop function f1;
|
||||
# Unknown functions
|
||||
create table t1 (a int as (f1()));
|
||||
ERROR HY000: Function or expression is not allowed for column 'a'.
|
||||
#
|
||||
# GROUP BY FUNCTIONS
|
||||
#
|
||||
# AVG()
|
||||
create table t1 (a int, b int as (avg(a)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# BIT_AND()
|
||||
create table t1 (a int, b int as (bit_and(a)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# BIT_OR()
|
||||
create table t1 (a int, b int as (bit_or(a)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# BIT_XOR()
|
||||
create table t1 (a int, b int as (bit_xor(a)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# COUNT(DISTINCT)
|
||||
create table t1 (a int, b int as (count(distinct a)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# COUNT()
|
||||
create table t1 (a int, b int as (count(a)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# GROUP_CONCAT()
|
||||
create table t1 (a varchar(32), b int as (group_concat(a,'')));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# MAX()
|
||||
create table t1 (a int, b int as (max(a)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# MIN()
|
||||
create table t1 (a int, b int as (min(a)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# STD()
|
||||
create table t1 (a int, b int as (std(a)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# STDDEV_POP()
|
||||
create table t1 (a int, b int as (stddev_pop(a)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# STDDEV_SAMP()
|
||||
create table t1 (a int, b int as (stddev_samp(a)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# STDDEV()
|
||||
create table t1 (a int, b int as (stddev(a)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# SUM()
|
||||
create table t1 (a int, b int as (sum(a)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# VAR_POP()
|
||||
create table t1 (a int, b int as (var_pop(a)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# VAR_SAMP()
|
||||
create table t1 (a int, b int as (var_samp(a)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# VARIANCE()
|
||||
create table t1 (a int, b int as (variance(a)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
#
|
||||
# XML FUNCTIONS
|
||||
#
|
||||
# ExtractValue()
|
||||
create table t1 (a varchar(1024), b varchar(1024) as (ExtractValue(a,'//b[$@j]')));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
# UpdateXML()
|
||||
create table t1 (a varchar(1024), b varchar(1024) as (UpdateXML(a,'/a','<e>fff</e>')));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
#
|
||||
# Sub-selects
|
||||
#
|
||||
create table t1 (a int);
|
||||
create table t2 (a int, b int as (select count(*) from t1));
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select count(*) from t1))' at line 1
|
||||
drop table t1;
|
||||
create table t1 (a int, b int as ((select 1)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
create table t1 (a int, b int as (a+(select 1)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
#
|
||||
# SP functions
|
||||
#
|
||||
drop function if exists sub1;
|
||||
create function sub1(i int) returns int deterministic
|
||||
return i+1;
|
||||
select sub1(1);
|
||||
sub1(1)
|
||||
2
|
||||
create table t1 (a int, b int as (a+sub3(1)));
|
||||
ERROR HY000: Function or expression is not allowed for column 'b'.
|
||||
drop function sub1;
|
||||
#
|
||||
# Long expression
|
||||
create table t1 (a int, b varchar(300) as (concat(a,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')));
|
||||
drop table t1;
|
||||
create table t1 (a int, b varchar(300) as (concat(a,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')));
|
||||
ERROR HY000: String 'concat(a,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' is too long for VIRTUAL COLUMN EXPRESSION (should be no longer than 252)
|
||||
#
|
||||
# Constant expression
|
||||
create table t1 (a int as (PI()));
|
||||
ERROR HY000: Constant expression in computed column function is not allowed.
|
146
mysql-test/suite/vcol/r/vcol_column_def_options_innodb.result
Normal file
146
mysql-test/suite/vcol/r/vcol_column_def_options_innodb.result
Normal file
@ -0,0 +1,146 @@
|
||||
SET @@session.storage_engine = 'InnoDB';
|
||||
#
|
||||
# Section 1. Wrong column definition options
|
||||
# - NOT NULL
|
||||
# - NULL
|
||||
# - DEFAULT <value>
|
||||
# - AUTO_INCREMENT
|
||||
# - [PRIMARY] KEY
|
||||
# NOT NULL
|
||||
create table t1 (a int, b int as (a+1) not null);
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'not null)' at line 1
|
||||
create table t1 (a int);
|
||||
alter table t1 add column b int as (a+1) not null;
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'not null' at line 1
|
||||
drop table t1;
|
||||
# NULL
|
||||
create table t1 (a int, b int as (a+1) null);
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'null)' at line 1
|
||||
create table t1 (a int);
|
||||
alter table t1 add column b int as (a+1) null;
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'null' at line 1
|
||||
drop table t1;
|
||||
# DEFAULT
|
||||
create table t1 (a int, b int as (a+1) default 0);
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'default 0)' at line 1
|
||||
create table t1 (a int);
|
||||
alter table t1 add column b int as (a+1) default 0;
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'default 0' at line 1
|
||||
drop table t1;
|
||||
# AUTO_INCREMENT
|
||||
create table t1 (a int, b int as (a+1) AUTO_INCREMENT);
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AUTO_INCREMENT)' at line 1
|
||||
create table t1 (a int);
|
||||
alter table t1 add column b int as (a+1) AUTO_INCREMENT;
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AUTO_INCREMENT' at line 1
|
||||
drop table t1;
|
||||
# [PRIMARY] KEY
|
||||
create table t1 (a int, b int as (a+1) key);
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key)' at line 1
|
||||
create table t1 (a int, b int as (a+1) primary key);
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'primary key)' at line 1
|
||||
create table t1 (a int);
|
||||
alter table t1 add column b int as (a+1) key;
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key' at line 1
|
||||
alter table t1 add column b int as (a+1) primary key;
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'primary key' at line 1
|
||||
drop table t1;
|
||||
# Section 2. Other column definition options
|
||||
# - COMMENT
|
||||
# - REFERENCES (only syntax testing here)
|
||||
# - STORED (only systax testing here)
|
||||
create table t1 (a int, b int as (a % 2) comment 'my comment');
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` int(11) AS (a % 2) VIRTUAL COMMENT 'my comment'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
describe t1;
|
||||
Field Type Null Key Default Extra
|
||||
a int(11) YES NULL
|
||||
b int(11) YES NULL VIRTUAL
|
||||
drop table t1;
|
||||
create table t1 (a int, b int as (a % 2));
|
||||
alter table t1 modify b int as (a % 2) comment 'my comment';
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` int(11) AS (a % 2) VIRTUAL COMMENT 'my comment'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
describe t1;
|
||||
Field Type Null Key Default Extra
|
||||
a int(11) YES NULL
|
||||
b int(11) YES NULL VIRTUAL
|
||||
insert into t1 (a) values (1);
|
||||
select * from t1;
|
||||
a b
|
||||
1 1
|
||||
insert into t1 values (2,default);
|
||||
select a,b from t1;
|
||||
a b
|
||||
1 1
|
||||
2 0
|
||||
create table t2 like t1;
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` int(11) AS (a % 2) VIRTUAL COMMENT 'my comment'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
describe t2;
|
||||
Field Type Null Key Default Extra
|
||||
a int(11) YES NULL
|
||||
b int(11) YES NULL VIRTUAL
|
||||
insert into t2 (a) values (1);
|
||||
select * from t2;
|
||||
a b
|
||||
1 1
|
||||
insert into t2 values (2,default);
|
||||
select a,b from t2;
|
||||
a b
|
||||
1 1
|
||||
2 0
|
||||
drop table t2;
|
||||
drop table t1;
|
||||
create table t1 (a int, b int as (a % 2) persistent);
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` int(11) AS (a % 2) PERSISTENT
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
describe t1;
|
||||
Field Type Null Key Default Extra
|
||||
a int(11) YES NULL
|
||||
b int(11) YES NULL VIRTUAL
|
||||
insert into t1 (a) values (1);
|
||||
select * from t1;
|
||||
a b
|
||||
1 1
|
||||
insert into t1 values (2,default);
|
||||
select a,b from t1;
|
||||
a b
|
||||
1 1
|
||||
2 0
|
||||
drop table t1;
|
||||
create table t2 (a int);
|
||||
create table t1 (a int, b int as (a % 2) persistent references t2(a));
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` int(11) AS (a % 2) PERSISTENT
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
create table t1 (a int, b int as (a % 2));
|
||||
alter table t1 modify b int as (a % 2) persistent references t2(a);
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'references t2(a)' at line 1
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` int(11) AS (a % 2) VIRTUAL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
146
mysql-test/suite/vcol/r/vcol_column_def_options_myisam.result
Normal file
146
mysql-test/suite/vcol/r/vcol_column_def_options_myisam.result
Normal file
@ -0,0 +1,146 @@
|
||||
SET @@session.storage_engine = 'MyISAM';
|
||||
#
|
||||
# Section 1. Wrong column definition options
|
||||
# - NOT NULL
|
||||
# - NULL
|
||||
# - DEFAULT <value>
|
||||
# - AUTO_INCREMENT
|
||||
# - [PRIMARY] KEY
|
||||
# NOT NULL
|
||||
create table t1 (a int, b int as (a+1) not null);
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'not null)' at line 1
|
||||
create table t1 (a int);
|
||||
alter table t1 add column b int as (a+1) not null;
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'not null' at line 1
|
||||
drop table t1;
|
||||
# NULL
|
||||
create table t1 (a int, b int as (a+1) null);
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'null)' at line 1
|
||||
create table t1 (a int);
|
||||
alter table t1 add column b int as (a+1) null;
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'null' at line 1
|
||||
drop table t1;
|
||||
# DEFAULT
|
||||
create table t1 (a int, b int as (a+1) default 0);
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'default 0)' at line 1
|
||||
create table t1 (a int);
|
||||
alter table t1 add column b int as (a+1) default 0;
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'default 0' at line 1
|
||||
drop table t1;
|
||||
# AUTO_INCREMENT
|
||||
create table t1 (a int, b int as (a+1) AUTO_INCREMENT);
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AUTO_INCREMENT)' at line 1
|
||||
create table t1 (a int);
|
||||
alter table t1 add column b int as (a+1) AUTO_INCREMENT;
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AUTO_INCREMENT' at line 1
|
||||
drop table t1;
|
||||
# [PRIMARY] KEY
|
||||
create table t1 (a int, b int as (a+1) key);
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key)' at line 1
|
||||
create table t1 (a int, b int as (a+1) primary key);
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'primary key)' at line 1
|
||||
create table t1 (a int);
|
||||
alter table t1 add column b int as (a+1) key;
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key' at line 1
|
||||
alter table t1 add column b int as (a+1) primary key;
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'primary key' at line 1
|
||||
drop table t1;
|
||||
# Section 2. Other column definition options
|
||||
# - COMMENT
|
||||
# - REFERENCES (only syntax testing here)
|
||||
# - STORED (only systax testing here)
|
||||
create table t1 (a int, b int as (a % 2) comment 'my comment');
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` int(11) AS (a % 2) VIRTUAL COMMENT 'my comment'
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
describe t1;
|
||||
Field Type Null Key Default Extra
|
||||
a int(11) YES NULL
|
||||
b int(11) YES NULL VIRTUAL
|
||||
drop table t1;
|
||||
create table t1 (a int, b int as (a % 2));
|
||||
alter table t1 modify b int as (a % 2) comment 'my comment';
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` int(11) AS (a % 2) VIRTUAL COMMENT 'my comment'
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
describe t1;
|
||||
Field Type Null Key Default Extra
|
||||
a int(11) YES NULL
|
||||
b int(11) YES NULL VIRTUAL
|
||||
insert into t1 (a) values (1);
|
||||
select * from t1;
|
||||
a b
|
||||
1 1
|
||||
insert into t1 values (2,default);
|
||||
select a,b from t1;
|
||||
a b
|
||||
1 1
|
||||
2 0
|
||||
create table t2 like t1;
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` int(11) AS (a % 2) VIRTUAL COMMENT 'my comment'
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
describe t2;
|
||||
Field Type Null Key Default Extra
|
||||
a int(11) YES NULL
|
||||
b int(11) YES NULL VIRTUAL
|
||||
insert into t2 (a) values (1);
|
||||
select * from t2;
|
||||
a b
|
||||
1 1
|
||||
insert into t2 values (2,default);
|
||||
select a,b from t2;
|
||||
a b
|
||||
1 1
|
||||
2 0
|
||||
drop table t2;
|
||||
drop table t1;
|
||||
create table t1 (a int, b int as (a % 2) persistent);
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` int(11) AS (a % 2) PERSISTENT
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
describe t1;
|
||||
Field Type Null Key Default Extra
|
||||
a int(11) YES NULL
|
||||
b int(11) YES NULL VIRTUAL
|
||||
insert into t1 (a) values (1);
|
||||
select * from t1;
|
||||
a b
|
||||
1 1
|
||||
insert into t1 values (2,default);
|
||||
select a,b from t1;
|
||||
a b
|
||||
1 1
|
||||
2 0
|
||||
drop table t1;
|
||||
create table t2 (a int);
|
||||
create table t1 (a int, b int as (a % 2) persistent references t2(a));
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` int(11) AS (a % 2) PERSISTENT
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
create table t1 (a int, b int as (a % 2));
|
||||
alter table t1 modify b int as (a % 2) persistent references t2(a);
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'references t2(a)' at line 1
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` int(11) AS (a % 2) VIRTUAL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
7
mysql-test/suite/vcol/r/vcol_csv.result
Normal file
7
mysql-test/suite/vcol/r/vcol_csv.result
Normal file
@ -0,0 +1,7 @@
|
||||
SET @@session.storage_engine = 'CSV';
|
||||
create table t1 (a int, b int as (a+1));
|
||||
ERROR HY000: 'Specified storage engine' is not yet supported for computed columns.
|
||||
create table t1 (a int not null);
|
||||
alter table t1 add column b int as (a+1);
|
||||
ERROR HY000: 'Specified storage engine' is not yet supported for computed columns.
|
||||
drop table t1;
|
76
mysql-test/suite/vcol/r/vcol_handler_innodb.result
Normal file
76
mysql-test/suite/vcol/r/vcol_handler_innodb.result
Normal file
@ -0,0 +1,76 @@
|
||||
SET @@session.storage_engine = 'InnoDB';
|
||||
create table t1 (a int,
|
||||
b int as (-a),
|
||||
c int as (-a) persistent,
|
||||
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-vcol_index_name > (value1,value2,...)
|
||||
handler t1 read a > (2);
|
||||
a b c d
|
||||
3 -3 -3 d
|
||||
# HANDLER tbl_name READ non-vcol_index_name > (value1,value2,...) WHERE non-vcol_field=expr
|
||||
handler t1 read a > (2) where d='c';
|
||||
a b c d
|
||||
# HANDLER tbl_name READ vcol_index_name = (value1,value2,...)
|
||||
handler t1 read c = (-2);
|
||||
a b c d
|
||||
2 -2 -2 b
|
||||
# HANDLER tbl_name READ vcol_index_name = (value1,value2,...) WHERE non-vcol_field=expr
|
||||
handler t1 read c = (-2) where d='c';
|
||||
a b c d
|
||||
# HANDLER tbl_name READ non-vcol_index_name > (value1,value2,...) WHERE vcol_field=expr
|
||||
handler t1 read a > (2) where b=-3 && c=-3;
|
||||
a b c d
|
||||
3 -3 -3 d
|
||||
# HANDLER tbl_name READ vcol_index_name <= (value1,value2,...)
|
||||
handler t1 read c <= (-2);
|
||||
a b c d
|
||||
2 -2 -2 b
|
||||
# HANDLER tbl_name READ vcol_index_name > (value1,value2,...) WHERE vcol_field=expr
|
||||
handler t1 read c <= (-2) where b=-3;
|
||||
a b c d
|
||||
3 -3 -3 d
|
||||
# HANDLER tbl_name READ vcol_index_name FIRST
|
||||
handler t1 read c first;
|
||||
a b c d
|
||||
4 -4 -4 a
|
||||
# HANDLER tbl_name READ vcol_index_name NEXT
|
||||
handler t1 read c next;
|
||||
a b c d
|
||||
3 -3 -3 d
|
||||
# HANDLER tbl_name READ vcol_index_name PREV
|
||||
handler t1 read c prev;
|
||||
a b c d
|
||||
4 -4 -4 a
|
||||
# HANDLER tbl_name READ vcol_index_name LAST
|
||||
handler t1 read c last;
|
||||
a b c d
|
||||
1 -1 -1 c
|
||||
# HANDLER tbl_name READ FIRST where non-vcol=expr
|
||||
handler t1 read FIRST where a >= 2;
|
||||
a b c d
|
||||
4 -4 -4 a
|
||||
# HANDLER tbl_name READ FIRST where vcol=expr
|
||||
handler t1 read FIRST where b >= -2;
|
||||
a b c d
|
||||
2 -2 -2 b
|
||||
# HANDLER tbl_name READ NEXT where non-vcol=expr
|
||||
handler t1 read NEXT where d='c';
|
||||
a b c d
|
||||
1 -1 -1 c
|
||||
# HANDLER tbl_name READ NEXT where vcol=expr
|
||||
handler t1 read NEXT where b<=-4;
|
||||
a b c d
|
||||
# HANDLER tbl_name CLOSE
|
||||
handler t1 close;
|
||||
drop table t1;
|
76
mysql-test/suite/vcol/r/vcol_handler_myisam.result
Normal file
76
mysql-test/suite/vcol/r/vcol_handler_myisam.result
Normal file
@ -0,0 +1,76 @@
|
||||
SET @@session.storage_engine = 'MyISAM';
|
||||
create table t1 (a int,
|
||||
b int as (-a),
|
||||
c int as (-a) persistent,
|
||||
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-vcol_index_name > (value1,value2,...)
|
||||
handler t1 read a > (2);
|
||||
a b c d
|
||||
3 -3 -3 d
|
||||
# HANDLER tbl_name READ non-vcol_index_name > (value1,value2,...) WHERE non-vcol_field=expr
|
||||
handler t1 read a > (2) where d='c';
|
||||
a b c d
|
||||
# HANDLER tbl_name READ vcol_index_name = (value1,value2,...)
|
||||
handler t1 read c = (-2);
|
||||
a b c d
|
||||
2 -2 -2 b
|
||||
# HANDLER tbl_name READ vcol_index_name = (value1,value2,...) WHERE non-vcol_field=expr
|
||||
handler t1 read c = (-2) where d='c';
|
||||
a b c d
|
||||
# HANDLER tbl_name READ non-vcol_index_name > (value1,value2,...) WHERE vcol_field=expr
|
||||
handler t1 read a > (2) where b=-3 && c=-3;
|
||||
a b c d
|
||||
3 -3 -3 d
|
||||
# HANDLER tbl_name READ vcol_index_name <= (value1,value2,...)
|
||||
handler t1 read c <= (-2);
|
||||
a b c d
|
||||
2 -2 -2 b
|
||||
# HANDLER tbl_name READ vcol_index_name > (value1,value2,...) WHERE vcol_field=expr
|
||||
handler t1 read c <= (-2) where b=-3;
|
||||
a b c d
|
||||
3 -3 -3 d
|
||||
# HANDLER tbl_name READ vcol_index_name FIRST
|
||||
handler t1 read c first;
|
||||
a b c d
|
||||
4 -4 -4 a
|
||||
# HANDLER tbl_name READ vcol_index_name NEXT
|
||||
handler t1 read c next;
|
||||
a b c d
|
||||
3 -3 -3 d
|
||||
# HANDLER tbl_name READ vcol_index_name PREV
|
||||
handler t1 read c prev;
|
||||
a b c d
|
||||
4 -4 -4 a
|
||||
# HANDLER tbl_name READ vcol_index_name LAST
|
||||
handler t1 read c last;
|
||||
a b c d
|
||||
1 -1 -1 c
|
||||
# HANDLER tbl_name READ FIRST where non-vcol=expr
|
||||
handler t1 read FIRST where a >= 2;
|
||||
a b c d
|
||||
4 -4 -4 a
|
||||
# HANDLER tbl_name READ FIRST where vcol=expr
|
||||
handler t1 read FIRST where b >= -2;
|
||||
a b c d
|
||||
2 -2 -2 b
|
||||
# HANDLER tbl_name READ NEXT where non-vcol=expr
|
||||
handler t1 read NEXT where d='c';
|
||||
a b c d
|
||||
1 -1 -1 c
|
||||
# HANDLER tbl_name READ NEXT where vcol=expr
|
||||
handler t1 read NEXT where b<=-4;
|
||||
a b c d
|
||||
# HANDLER tbl_name CLOSE
|
||||
handler t1 close;
|
||||
drop table t1;
|
427
mysql-test/suite/vcol/r/vcol_ins_upd_innodb.result
Normal file
427
mysql-test/suite/vcol/r/vcol_ins_upd_innodb.result
Normal file
@ -0,0 +1,427 @@
|
||||
SET @@session.storage_engine = 'InnoDB';
|
||||
create table t1 (a int,
|
||||
b int as (-a),
|
||||
c int as (-a) persistent);
|
||||
set sql_warnings = 1;
|
||||
#
|
||||
# *** INSERT ***
|
||||
#
|
||||
# INSERT INTO tbl_name VALUES... DEFAULT is specified against vcols
|
||||
insert into t1 values (1,default,default);
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a b c
|
||||
# INSERT INTO tbl_name VALUES... NULL is specified against vcols
|
||||
insert into t1 values (1,null,null);
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a b c
|
||||
# INSERT INTO tbl_name VALUES... a non-NULL value is specified against vcols
|
||||
insert into t1 values (1,2,3);
|
||||
Warnings:
|
||||
Warning 1645 The value specified for computed column 'b' in table 't1' ignored.
|
||||
Warning 1645 The value specified for computed column 'c' in table 't1' ignored.
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a b c
|
||||
# INSERT INTO tbl_name (<non_vcol_list>) VALUES...
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a b c
|
||||
# INSERT INTO tbl_name (<normal+vcols>) VALUES... DEFAULT is specified
|
||||
# against vcols
|
||||
insert into t1 (a,b) values (1,default), (2,default);
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a b c
|
||||
# INSERT INTO tbl_name (<normal+vcols>) VALUES... NULL is specified against vcols
|
||||
insert into t1 (a,b) values (1,null), (2,null);
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a b c
|
||||
# INSERT INTO tbl_name (<normal+vcols>) VALUES... a non-NULL value is specified
|
||||
# against vcols
|
||||
insert into t1 (a,b) values (1,3), (2,4);
|
||||
Warnings:
|
||||
Warning 1645 The value specified for computed column 'b' in table 't1' ignored.
|
||||
Warning 1645 The value specified for computed column 'b' in table 't1' ignored.
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a b c
|
||||
drop table t1;
|
||||
# Table with UNIQUE non-vcol field. INSERT INTO tbl_name VALUES... ON DUPLICATE
|
||||
# KEY UPDATE <non_vcol>=expr, <vcol>=expr
|
||||
create table t1 (a int unique,
|
||||
b int as (-a),
|
||||
c int as (-a) persistent);
|
||||
insert into t1 values (1,default,default);
|
||||
insert into t1 values (1,default,default)
|
||||
on duplicate key update a=2, b=default;
|
||||
select a,b,c from t1;
|
||||
a b c
|
||||
2 -2 -2
|
||||
delete from t1 where b in (1,2);
|
||||
select * from t1;
|
||||
a b c
|
||||
2 -2 -2
|
||||
drop table t1;
|
||||
# Table with UNIQUE vcol field. INSERT INTO tbl_name VALUES... ON DUPLICATE
|
||||
# KEY UPDATE <non_vcol>=expr, <vcol>=expr
|
||||
create table t1 (a int,
|
||||
b int as (-a),
|
||||
c int as (-a) persistent unique);
|
||||
insert into t1 values (1,default,default);
|
||||
insert into t1 values (1,default,default)
|
||||
on duplicate key update a=2, b=default;
|
||||
select a,b,c from t1;
|
||||
a b c
|
||||
2 -2 -2
|
||||
# CREATE new_table ... LIKE old_table
|
||||
# INSERT INTO new_table SELECT * from old_table
|
||||
create table t2 like t1;
|
||||
insert into t2 select * from t1;
|
||||
Warnings:
|
||||
Warning 1645 The value specified for computed column 'b' in table 't2' ignored.
|
||||
Warning 1645 The value specified for computed column 'c' in table 't2' ignored.
|
||||
select * from t1;
|
||||
a b c
|
||||
2 -2 -2
|
||||
drop table t2;
|
||||
# CREATE new_table ... LIKE old_table INSERT INTO new_table (<non-vcols>, <vcols>)
|
||||
# SELECT <non-vcols>, <vcols> from old_table
|
||||
insert into t1 values (1,default,default);
|
||||
select * from t1;
|
||||
a b c
|
||||
2 -2 -2
|
||||
1 -1 -1
|
||||
create table t2 like t1;
|
||||
insert into t2 (a,b) select a,b from t1;
|
||||
Warnings:
|
||||
Warning 1645 The value specified for computed column 'b' in table 't2' ignored.
|
||||
Warning 1645 The value specified for computed column 'b' in table 't2' ignored.
|
||||
select * from t2;
|
||||
a b c
|
||||
2 -2 -2
|
||||
1 -1 -1
|
||||
drop table t2;
|
||||
drop table t1;
|
||||
#
|
||||
# *** UPDATE ***
|
||||
#
|
||||
# UPDATE tbl_name SET non-vcol=expr WHERE non-vcol=expr
|
||||
create table t1 (a int,
|
||||
b int as (-a),
|
||||
c int as (-a) persistent);
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
update t1 set a=3 where a=2;
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
3 -3 -3
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a b c
|
||||
# UPDATE tbl_name SET vcol=expr WHERE non-vcol=expr
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
update t1 set c=3 where a=2;
|
||||
Warnings:
|
||||
Warning 1645 The value specified for computed column 'c' in table 't1' ignored.
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a b c
|
||||
# UPDATE tbl_name SET non-vcol=expr WHERE vcol=expr
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
update t1 set a=3 where b=-2;
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
3 -3 -3
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a b c
|
||||
# UPDATE tbl_name SET vcol=expr WHERE vcol=expr
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
update t1 set c=3 where b=-2;
|
||||
Warnings:
|
||||
Warning 1645 The value specified for computed column 'c' in table 't1' ignored.
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a b c
|
||||
drop table t1;
|
||||
# INDEX created on vcol
|
||||
# UPDATE tbl_name SET non-vcol=expr WHERE vcol=const
|
||||
create table t1 (a int,
|
||||
b int as (-a),
|
||||
c int as (-a) persistent unique);
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
update t1 set a=3 where c=-2;
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
3 -3 -3
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a b c
|
||||
# INDEX created on vcol
|
||||
# UPDATE tbl_name SET non-vcol=expr WHERE vcol=between const1 and const2
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
update t1 set a=3 where c between -3 and -2;
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
3 -3 -3
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a b c
|
||||
# No INDEX created on vcol
|
||||
# UPDATE tbl_name SET non-vcol=expr WHERE vcol=between const1 and const2
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
update t1 set a=3 where b between -3 and -2;
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
3 -3 -3
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a b c
|
||||
# INDEX created on vcol
|
||||
# UPDATE tbl_name SET non-vcol=expr
|
||||
# WHERE vcol=between const1 and const2 ORDER BY vcol
|
||||
insert into t1 (a) values (1), (2), (3), (4), (5);
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
3 -3 -3
|
||||
4 -4 -4
|
||||
5 -5 -5
|
||||
update t1 set a=6 where c between -1 and 0
|
||||
order by c;
|
||||
select * from t1;
|
||||
a b c
|
||||
6 -6 -6
|
||||
2 -2 -2
|
||||
3 -3 -3
|
||||
4 -4 -4
|
||||
5 -5 -5
|
||||
delete from t1 where c between -6 and 0;
|
||||
select * from t1;
|
||||
a b c
|
||||
# INDEX created on vcol
|
||||
# UPDATE tbl_name SET non-vcol=expr
|
||||
# WHERE vcol=between const1 and const2 ORDER BY vcol LIMIT 2
|
||||
insert into t1 (a) values (1), (2), (3), (4), (5);
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
3 -3 -3
|
||||
4 -4 -4
|
||||
5 -5 -5
|
||||
update t1 set a=6 where c between -1 and 0
|
||||
order by c limit 2;
|
||||
select * from t1;
|
||||
a b c
|
||||
6 -6 -6
|
||||
2 -2 -2
|
||||
3 -3 -3
|
||||
4 -4 -4
|
||||
5 -5 -5
|
||||
delete from t1 where c between -2 and 0 order by c;
|
||||
select * from t1;
|
||||
a b c
|
||||
6 -6 -6
|
||||
3 -3 -3
|
||||
4 -4 -4
|
||||
5 -5 -5
|
||||
delete from t1;
|
||||
# INDEX created on vcol
|
||||
# UPDATE tbl_name SET non-vcol=expr
|
||||
# WHERE indexed vcol=between const1 and const2 and non-indexed vcol=const3
|
||||
insert into t1 (a) values (1), (2), (3), (4), (5);
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
3 -3 -3
|
||||
4 -4 -4
|
||||
5 -5 -5
|
||||
update t1 set a=6 where (c between -2 and 0) and (b=-1);
|
||||
select * from t1;
|
||||
a b c
|
||||
6 -6 -6
|
||||
2 -2 -2
|
||||
3 -3 -3
|
||||
4 -4 -4
|
||||
5 -5 -5
|
||||
delete from t1;
|
||||
# INDEX created on vcol
|
||||
# UPDATE tbl_name SET non-vcol=expr
|
||||
# WHERE indexed vcol=between const1 and const2 and non-indexed vcol=const3
|
||||
# ORDER BY indexed vcol
|
||||
insert into t1 (a) values (1), (2), (3), (4), (5);
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
3 -3 -3
|
||||
4 -4 -4
|
||||
5 -5 -5
|
||||
update t1 set a=6 where (c between -2 and 0) and (b=-1) order by c;
|
||||
select * from t1;
|
||||
a b c
|
||||
6 -6 -6
|
||||
2 -2 -2
|
||||
3 -3 -3
|
||||
4 -4 -4
|
||||
5 -5 -5
|
||||
delete from t1;
|
||||
drop table t1;
|
||||
#
|
||||
# Verify ON UPDATE/DELETE actions of FOREIGN KEYs
|
||||
create table t2 (a int primary key, name varchar(10));
|
||||
create table t1 (a int primary key, b int as (a % 10) persistent);
|
||||
insert into t2 values (1, 'value1'), (2,'value2'), (3,'value3');
|
||||
insert into t1 (a) values (1),(2),(3);
|
||||
select * from t1;
|
||||
a b
|
||||
1 1
|
||||
2 2
|
||||
3 3
|
||||
select * from t2;
|
||||
a name
|
||||
1 value1
|
||||
2 value2
|
||||
3 value3
|
||||
select t1.a, t1.b, t2.name from t1,t2 where t1.b=t2.a;
|
||||
a b name
|
||||
1 1 value1
|
||||
2 2 value2
|
||||
3 3 value3
|
||||
# - ON UPDATE RESTRICT
|
||||
alter table t1 add foreign key (b) references t2(a) on update restrict;
|
||||
insert into t1 (a) values (4);
|
||||
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t1`, CONSTRAINT `t1_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t2` (`a`))
|
||||
update t2 set a=4 where a=3;
|
||||
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t1`, CONSTRAINT `t1_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t2` (`a`))
|
||||
select t1.a, t1.b, t2.name from t1,t2 where t1.b=t2.a;
|
||||
a b name
|
||||
1 1 value1
|
||||
2 2 value2
|
||||
3 3 value3
|
||||
alter table t1 drop foreign key t1_ibfk_1;
|
||||
# - ON DELETE RESTRICT
|
||||
alter table t1 add foreign key (b) references t2(a) on delete restrict;
|
||||
delete from t2 where a=3;
|
||||
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t1`, CONSTRAINT `t1_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t2` (`a`))
|
||||
select t1.a, t1.b, t2.name from t1,t2 where t1.b=t2.a;
|
||||
a b name
|
||||
1 1 value1
|
||||
2 2 value2
|
||||
3 3 value3
|
||||
select t1.a, t1.b, t2.name from t1 left outer join t2 on (t1.b=t2.a);
|
||||
a b name
|
||||
1 1 value1
|
||||
2 2 value2
|
||||
3 3 value3
|
||||
alter table t1 drop foreign key t1_ibfk_1;
|
||||
# - ON DELETE CASCADE
|
||||
alter table t1 add foreign key (b) references t2(a) on delete cascade;
|
||||
delete from t2 where a=3;
|
||||
select t1.a, t1.b, t2.name from t1,t2 where t1.b=t2.a;
|
||||
a b name
|
||||
1 1 value1
|
||||
2 2 value2
|
||||
select t1.a, t1.b, t2.name from t1 left outer join t2 on (t1.b=t2.a);
|
||||
a b name
|
||||
1 1 value1
|
||||
2 2 value2
|
||||
alter table t1 drop foreign key t1_ibfk_1;
|
||||
drop table t1;
|
||||
drop table t2;
|
||||
#
|
||||
# *** REPLACE ***
|
||||
#
|
||||
# UNIQUE INDEX on vcol
|
||||
# REPLACE tbl_name (non-vcols) VALUES (non-vcols);
|
||||
create table t1 (a int,
|
||||
b int as (-a),
|
||||
c int as (-a) persistent unique,
|
||||
d varchar(16));
|
||||
insert into t1 (a,d) values (1,'a'), (2,'b');
|
||||
select * from t1;
|
||||
a b c d
|
||||
1 -1 -1 a
|
||||
2 -2 -2 b
|
||||
replace t1 (a,d) values (1,'c');
|
||||
select * from t1;
|
||||
a b c d
|
||||
1 -1 -1 c
|
||||
2 -2 -2 b
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a b c d
|
||||
set sql_warnings = 0;
|
||||
drop table t1;
|
365
mysql-test/suite/vcol/r/vcol_ins_upd_myisam.result
Normal file
365
mysql-test/suite/vcol/r/vcol_ins_upd_myisam.result
Normal file
@ -0,0 +1,365 @@
|
||||
SET @@session.storage_engine = 'MyISAM';
|
||||
create table t1 (a int,
|
||||
b int as (-a),
|
||||
c int as (-a) persistent);
|
||||
set sql_warnings = 1;
|
||||
#
|
||||
# *** INSERT ***
|
||||
#
|
||||
# INSERT INTO tbl_name VALUES... DEFAULT is specified against vcols
|
||||
insert into t1 values (1,default,default);
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a b c
|
||||
# INSERT INTO tbl_name VALUES... NULL is specified against vcols
|
||||
insert into t1 values (1,null,null);
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a b c
|
||||
# INSERT INTO tbl_name VALUES... a non-NULL value is specified against vcols
|
||||
insert into t1 values (1,2,3);
|
||||
Warnings:
|
||||
Warning 1645 The value specified for computed column 'b' in table 't1' ignored.
|
||||
Warning 1645 The value specified for computed column 'c' in table 't1' ignored.
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a b c
|
||||
# INSERT INTO tbl_name (<non_vcol_list>) VALUES...
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a b c
|
||||
# INSERT INTO tbl_name (<normal+vcols>) VALUES... DEFAULT is specified
|
||||
# against vcols
|
||||
insert into t1 (a,b) values (1,default), (2,default);
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a b c
|
||||
# INSERT INTO tbl_name (<normal+vcols>) VALUES... NULL is specified against vcols
|
||||
insert into t1 (a,b) values (1,null), (2,null);
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a b c
|
||||
# INSERT INTO tbl_name (<normal+vcols>) VALUES... a non-NULL value is specified
|
||||
# against vcols
|
||||
insert into t1 (a,b) values (1,3), (2,4);
|
||||
Warnings:
|
||||
Warning 1645 The value specified for computed column 'b' in table 't1' ignored.
|
||||
Warning 1645 The value specified for computed column 'b' in table 't1' ignored.
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a b c
|
||||
drop table t1;
|
||||
# Table with UNIQUE non-vcol field. INSERT INTO tbl_name VALUES... ON DUPLICATE
|
||||
# KEY UPDATE <non_vcol>=expr, <vcol>=expr
|
||||
create table t1 (a int unique,
|
||||
b int as (-a),
|
||||
c int as (-a) persistent);
|
||||
insert into t1 values (1,default,default);
|
||||
insert into t1 values (1,default,default)
|
||||
on duplicate key update a=2, b=default;
|
||||
select a,b,c from t1;
|
||||
a b c
|
||||
2 -2 -2
|
||||
delete from t1 where b in (1,2);
|
||||
select * from t1;
|
||||
a b c
|
||||
2 -2 -2
|
||||
drop table t1;
|
||||
# Table with UNIQUE vcol field. INSERT INTO tbl_name VALUES... ON DUPLICATE
|
||||
# KEY UPDATE <non_vcol>=expr, <vcol>=expr
|
||||
create table t1 (a int,
|
||||
b int as (-a),
|
||||
c int as (-a) persistent unique);
|
||||
insert into t1 values (1,default,default);
|
||||
insert into t1 values (1,default,default)
|
||||
on duplicate key update a=2, b=default;
|
||||
select a,b,c from t1;
|
||||
a b c
|
||||
2 -2 -2
|
||||
# CREATE new_table ... LIKE old_table
|
||||
# INSERT INTO new_table SELECT * from old_table
|
||||
create table t2 like t1;
|
||||
insert into t2 select * from t1;
|
||||
Warnings:
|
||||
Warning 1645 The value specified for computed column 'b' in table 't2' ignored.
|
||||
Warning 1645 The value specified for computed column 'c' in table 't2' ignored.
|
||||
select * from t1;
|
||||
a b c
|
||||
2 -2 -2
|
||||
drop table t2;
|
||||
# CREATE new_table ... LIKE old_table INSERT INTO new_table (<non-vcols>, <vcols>)
|
||||
# SELECT <non-vcols>, <vcols> from old_table
|
||||
insert into t1 values (1,default,default);
|
||||
select * from t1;
|
||||
a b c
|
||||
2 -2 -2
|
||||
1 -1 -1
|
||||
create table t2 like t1;
|
||||
insert into t2 (a,b) select a,b from t1;
|
||||
Warnings:
|
||||
Warning 1645 The value specified for computed column 'b' in table 't2' ignored.
|
||||
Warning 1645 The value specified for computed column 'b' in table 't2' ignored.
|
||||
select * from t2;
|
||||
a b c
|
||||
2 -2 -2
|
||||
1 -1 -1
|
||||
drop table t2;
|
||||
drop table t1;
|
||||
#
|
||||
# *** UPDATE ***
|
||||
#
|
||||
# UPDATE tbl_name SET non-vcol=expr WHERE non-vcol=expr
|
||||
create table t1 (a int,
|
||||
b int as (-a),
|
||||
c int as (-a) persistent);
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
update t1 set a=3 where a=2;
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
3 -3 -3
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a b c
|
||||
# UPDATE tbl_name SET vcol=expr WHERE non-vcol=expr
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
update t1 set c=3 where a=2;
|
||||
Warnings:
|
||||
Warning 1645 The value specified for computed column 'c' in table 't1' ignored.
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a b c
|
||||
# UPDATE tbl_name SET non-vcol=expr WHERE vcol=expr
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
update t1 set a=3 where b=-2;
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
3 -3 -3
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a b c
|
||||
# UPDATE tbl_name SET vcol=expr WHERE vcol=expr
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
update t1 set c=3 where b=-2;
|
||||
Warnings:
|
||||
Warning 1645 The value specified for computed column 'c' in table 't1' ignored.
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a b c
|
||||
drop table t1;
|
||||
# INDEX created on vcol
|
||||
# UPDATE tbl_name SET non-vcol=expr WHERE vcol=const
|
||||
create table t1 (a int,
|
||||
b int as (-a),
|
||||
c int as (-a) persistent unique);
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
update t1 set a=3 where c=-2;
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
3 -3 -3
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a b c
|
||||
# INDEX created on vcol
|
||||
# UPDATE tbl_name SET non-vcol=expr WHERE vcol=between const1 and const2
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
update t1 set a=3 where c between -3 and -2;
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
3 -3 -3
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a b c
|
||||
# No INDEX created on vcol
|
||||
# UPDATE tbl_name SET non-vcol=expr WHERE vcol=between const1 and const2
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
update t1 set a=3 where b between -3 and -2;
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
3 -3 -3
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a b c
|
||||
# INDEX created on vcol
|
||||
# UPDATE tbl_name SET non-vcol=expr
|
||||
# WHERE vcol=between const1 and const2 ORDER BY vcol
|
||||
insert into t1 (a) values (1), (2), (3), (4), (5);
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
3 -3 -3
|
||||
4 -4 -4
|
||||
5 -5 -5
|
||||
update t1 set a=6 where c between -1 and 0
|
||||
order by c;
|
||||
select * from t1;
|
||||
a b c
|
||||
6 -6 -6
|
||||
2 -2 -2
|
||||
3 -3 -3
|
||||
4 -4 -4
|
||||
5 -5 -5
|
||||
delete from t1 where c between -6 and 0;
|
||||
select * from t1;
|
||||
a b c
|
||||
# INDEX created on vcol
|
||||
# UPDATE tbl_name SET non-vcol=expr
|
||||
# WHERE vcol=between const1 and const2 ORDER BY vcol LIMIT 2
|
||||
insert into t1 (a) values (1), (2), (3), (4), (5);
|
||||
select * from t1;
|
||||
a b c
|
||||
5 -5 -5
|
||||
4 -4 -4
|
||||
3 -3 -3
|
||||
2 -2 -2
|
||||
1 -1 -1
|
||||
update t1 set a=6 where c between -1 and 0
|
||||
order by c limit 2;
|
||||
select * from t1;
|
||||
a b c
|
||||
5 -5 -5
|
||||
4 -4 -4
|
||||
3 -3 -3
|
||||
2 -2 -2
|
||||
6 -6 -6
|
||||
delete from t1 where c between -2 and 0 order by c;
|
||||
select * from t1;
|
||||
a b c
|
||||
5 -5 -5
|
||||
4 -4 -4
|
||||
3 -3 -3
|
||||
6 -6 -6
|
||||
delete from t1;
|
||||
# INDEX created on vcol
|
||||
# UPDATE tbl_name SET non-vcol=expr
|
||||
# WHERE indexed vcol=between const1 and const2 and non-indexed vcol=const3
|
||||
insert into t1 (a) values (1), (2), (3), (4), (5);
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
3 -3 -3
|
||||
4 -4 -4
|
||||
5 -5 -5
|
||||
update t1 set a=6 where (c between -2 and 0) and (b=-1);
|
||||
select * from t1;
|
||||
a b c
|
||||
6 -6 -6
|
||||
2 -2 -2
|
||||
3 -3 -3
|
||||
4 -4 -4
|
||||
5 -5 -5
|
||||
delete from t1;
|
||||
# INDEX created on vcol
|
||||
# UPDATE tbl_name SET non-vcol=expr
|
||||
# WHERE indexed vcol=between const1 and const2 and non-indexed vcol=const3
|
||||
# ORDER BY indexed vcol
|
||||
insert into t1 (a) values (1), (2), (3), (4), (5);
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
3 -3 -3
|
||||
4 -4 -4
|
||||
5 -5 -5
|
||||
update t1 set a=6 where (c between -2 and 0) and (b=-1) order by c;
|
||||
select * from t1;
|
||||
a b c
|
||||
6 -6 -6
|
||||
2 -2 -2
|
||||
3 -3 -3
|
||||
4 -4 -4
|
||||
5 -5 -5
|
||||
delete from t1;
|
||||
drop table t1;
|
||||
#
|
||||
# *** REPLACE ***
|
||||
#
|
||||
# UNIQUE INDEX on vcol
|
||||
# REPLACE tbl_name (non-vcols) VALUES (non-vcols);
|
||||
create table t1 (a int,
|
||||
b int as (-a),
|
||||
c int as (-a) persistent unique,
|
||||
d varchar(16));
|
||||
insert into t1 (a,d) values (1,'a'), (2,'b');
|
||||
select * from t1;
|
||||
a b c d
|
||||
1 -1 -1 a
|
||||
2 -2 -2 b
|
||||
replace t1 (a,d) values (1,'c');
|
||||
select * from t1;
|
||||
a b c d
|
||||
1 -1 -1 c
|
||||
2 -2 -2 b
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a b c d
|
||||
set sql_warnings = 0;
|
||||
drop table t1;
|
151
mysql-test/suite/vcol/r/vcol_keys_innodb.result
Normal file
151
mysql-test/suite/vcol/r/vcol_keys_innodb.result
Normal file
@ -0,0 +1,151 @@
|
||||
SET @@session.storage_engine = 'InnoDB';
|
||||
# - UNIQUE KEY
|
||||
# - INDEX
|
||||
# - FULLTEXT INDEX
|
||||
# - SPATIAL INDEX (not supported)
|
||||
# - FOREIGN INDEX (partially supported)
|
||||
# - CHECK (allowed but not used)
|
||||
# UNIQUE
|
||||
create table t1 (a int, b int as (a*2) unique);
|
||||
ERROR HY000: Key/Index cannot be defined on a non-stored computed column.
|
||||
create table t1 (a int, b int as (a*2) persistent unique);
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` int(11) AS (a*2) PERSISTENT,
|
||||
UNIQUE KEY `b` (`b`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
describe t1;
|
||||
Field Type Null Key Default Extra
|
||||
a int(11) YES NULL
|
||||
b int(11) YES UNI NULL VIRTUAL
|
||||
drop table t1;
|
||||
create table t1 (a int, b int as (a*2), unique key (b));
|
||||
ERROR HY000: Key/Index cannot be defined on a non-stored computed column.
|
||||
create table t1 (a int, b int as (a*2) persistent, unique (b));
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` int(11) AS (a*2) PERSISTENT,
|
||||
UNIQUE KEY `b` (`b`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
describe t1;
|
||||
Field Type Null Key Default Extra
|
||||
a int(11) YES NULL
|
||||
b int(11) YES UNI NULL VIRTUAL
|
||||
drop table t1;
|
||||
create table t1 (a int, b int as (a*2));
|
||||
alter table t1 add unique key (b);
|
||||
ERROR HY000: Key/Index cannot be defined on a non-stored computed column.
|
||||
drop table t1;
|
||||
create table t1 (a int, b int as (a*2) persistent);
|
||||
alter table t1 add unique key (b);
|
||||
drop table t1;
|
||||
# Testing data manipulation operations involving UNIQUE keys
|
||||
# on virtual columns can be found in:
|
||||
# - vcol_ins_upd.inc
|
||||
# - vcol_select.inc
|
||||
#
|
||||
# INDEX
|
||||
create table t1 (a int, b int as (a*2), index (b));
|
||||
ERROR HY000: Key/Index cannot be defined on a non-stored computed column.
|
||||
create table t1 (a int, b int as (a*2), index (a,b));
|
||||
ERROR HY000: Key/Index cannot be defined on a non-stored computed column.
|
||||
create table t1 (a int, b int as (a*2) persistent, index (b));
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` int(11) AS (a*2) PERSISTENT,
|
||||
KEY `b` (`b`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
describe t1;
|
||||
Field Type Null Key Default Extra
|
||||
a int(11) YES NULL
|
||||
b int(11) YES MUL NULL VIRTUAL
|
||||
drop table t1;
|
||||
create table t1 (a int, b int as (a*2) persistent, index (a,b));
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` int(11) AS (a*2) PERSISTENT,
|
||||
KEY `a` (`a`,`b`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
describe t1;
|
||||
Field Type Null Key Default Extra
|
||||
a int(11) YES MUL NULL
|
||||
b int(11) YES NULL VIRTUAL
|
||||
drop table t1;
|
||||
create table t1 (a int, b int as (a*2));
|
||||
alter table t1 add index (b);
|
||||
ERROR HY000: Key/Index cannot be defined on a non-stored computed column.
|
||||
alter table t1 add index (a,b);
|
||||
ERROR HY000: Key/Index cannot be defined on a non-stored computed column.
|
||||
drop table t1;
|
||||
create table t1 (a int, b int as (a*2) persistent);
|
||||
alter table t1 add index (b);
|
||||
drop table t1;
|
||||
create table t1 (a int, b int as (a*2) persistent);
|
||||
alter table t1 add index (a,b);
|
||||
create table t2 like t1;
|
||||
drop table t2;
|
||||
drop table t1;
|
||||
# Testing data manipulation operations involving INDEX
|
||||
# on virtual columns can be found in:
|
||||
# - vcol_select.inc
|
||||
#
|
||||
# TODO: FULLTEXT INDEX
|
||||
# SPATIAL INDEX
|
||||
# FOREIGN KEY
|
||||
# Rejected FK options.
|
||||
create table t1 (a int, b int as (a+1) persistent,
|
||||
foreign key (b) references t2(a) on update set null);
|
||||
ERROR HY000: Cannot define foreign key with ON UPDATE SET NULL clause on a computed column.
|
||||
create table t1 (a int, b int as (a+1) persistent,
|
||||
foreign key (b) references t2(a) on update cascade);
|
||||
ERROR HY000: Cannot define foreign key with ON UPDATE CASCADE clause on a computed column.
|
||||
create table t1 (a int, b int as (a+1) persistent,
|
||||
foreign key (b) references t2(a) on delete set null);
|
||||
ERROR HY000: Cannot define foreign key with ON DELETE SET NULL clause on a computed column.
|
||||
create table t1 (a int, b int as (a+1) persistent);
|
||||
alter table t1 add foreign key (b) references t2(a) on update set null;
|
||||
ERROR HY000: Cannot define foreign key with ON UPDATE SET NULL clause on a computed column.
|
||||
alter table t1 add foreign key (b) references t2(a) on update cascade;
|
||||
ERROR HY000: Cannot define foreign key with ON UPDATE CASCADE clause on a computed column.
|
||||
alter table t1 add foreign key (b) references t2(a) on delete set null;
|
||||
ERROR HY000: Cannot define foreign key with ON DELETE SET NULL clause on a computed column.
|
||||
drop table t1;
|
||||
create table t1 (a int, b int as (a+1),
|
||||
foreign key (b) references t2(a));
|
||||
ERROR HY000: Key/Index cannot be defined on a non-stored computed column.
|
||||
create table t1 (a int, b int as (a+1));
|
||||
alter table t1 add foreign key (b) references t2(a);
|
||||
ERROR HY000: Key/Index cannot be defined on a non-stored computed column.
|
||||
drop table t1;
|
||||
# Allowed FK options.
|
||||
create table t2 (a int primary key, b char(5));
|
||||
create table t1 (a int, b int as (a % 10) persistent,
|
||||
foreign key (b) references t2(a) on update restrict);
|
||||
drop table t1;
|
||||
create table t1 (a int, b int as (a % 10) persistent,
|
||||
foreign key (b) references t2(a) on update no action);
|
||||
drop table t1;
|
||||
create table t1 (a int, b int as (a % 10) persistent,
|
||||
foreign key (b) references t2(a) on delete restrict);
|
||||
drop table t1;
|
||||
create table t1 (a int, b int as (a % 10) persistent,
|
||||
foreign key (b) references t2(a) on delete cascade);
|
||||
drop table t1;
|
||||
create table t1 (a int, b int as (a % 10) persistent,
|
||||
foreign key (b) references t2(a) on delete no action);
|
||||
drop table t1;
|
||||
|
||||
# Testing data manipulation operations involving FOREIGN KEY
|
||||
# on virtual columns can be found in:
|
||||
# - vcol_ins_upd.inc
|
||||
# - vcol_select.inc
|
||||
#
|
||||
# TODO: CHECK
|
158
mysql-test/suite/vcol/r/vcol_keys_myisam.result
Normal file
158
mysql-test/suite/vcol/r/vcol_keys_myisam.result
Normal file
@ -0,0 +1,158 @@
|
||||
SET @@session.storage_engine = 'MyISAM';
|
||||
# - UNIQUE KEY
|
||||
# - INDEX
|
||||
# - FULLTEXT INDEX
|
||||
# - SPATIAL INDEX (not supported)
|
||||
# - FOREIGN INDEX (partially supported)
|
||||
# - CHECK (allowed but not used)
|
||||
# UNIQUE
|
||||
create table t1 (a int, b int as (a*2) unique);
|
||||
ERROR HY000: Key/Index cannot be defined on a non-stored computed column.
|
||||
create table t1 (a int, b int as (a*2) persistent unique);
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` int(11) AS (a*2) PERSISTENT,
|
||||
UNIQUE KEY `b` (`b`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
describe t1;
|
||||
Field Type Null Key Default Extra
|
||||
a int(11) YES NULL
|
||||
b int(11) YES UNI NULL VIRTUAL
|
||||
drop table t1;
|
||||
create table t1 (a int, b int as (a*2), unique key (b));
|
||||
ERROR HY000: Key/Index cannot be defined on a non-stored computed column.
|
||||
create table t1 (a int, b int as (a*2) persistent, unique (b));
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` int(11) AS (a*2) PERSISTENT,
|
||||
UNIQUE KEY `b` (`b`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
describe t1;
|
||||
Field Type Null Key Default Extra
|
||||
a int(11) YES NULL
|
||||
b int(11) YES UNI NULL VIRTUAL
|
||||
drop table t1;
|
||||
create table t1 (a int, b int as (a*2));
|
||||
alter table t1 add unique key (b);
|
||||
ERROR HY000: Key/Index cannot be defined on a non-stored computed column.
|
||||
drop table t1;
|
||||
create table t1 (a int, b int as (a*2) persistent);
|
||||
alter table t1 add unique key (b);
|
||||
drop table t1;
|
||||
# Testing data manipulation operations involving UNIQUE keys
|
||||
# on virtual columns can be found in:
|
||||
# - vcol_ins_upd.inc
|
||||
# - vcol_select.inc
|
||||
#
|
||||
# INDEX
|
||||
create table t1 (a int, b int as (a*2), index (b));
|
||||
ERROR HY000: Key/Index cannot be defined on a non-stored computed column.
|
||||
create table t1 (a int, b int as (a*2), index (a,b));
|
||||
ERROR HY000: Key/Index cannot be defined on a non-stored computed column.
|
||||
create table t1 (a int, b int as (a*2) persistent, index (b));
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` int(11) AS (a*2) PERSISTENT,
|
||||
KEY `b` (`b`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
describe t1;
|
||||
Field Type Null Key Default Extra
|
||||
a int(11) YES NULL
|
||||
b int(11) YES MUL NULL VIRTUAL
|
||||
drop table t1;
|
||||
create table t1 (a int, b int as (a*2) persistent, index (a,b));
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` int(11) AS (a*2) PERSISTENT,
|
||||
KEY `a` (`a`,`b`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
describe t1;
|
||||
Field Type Null Key Default Extra
|
||||
a int(11) YES MUL NULL
|
||||
b int(11) YES NULL VIRTUAL
|
||||
drop table t1;
|
||||
create table t1 (a int, b int as (a*2));
|
||||
alter table t1 add index (b);
|
||||
ERROR HY000: Key/Index cannot be defined on a non-stored computed column.
|
||||
alter table t1 add index (a,b);
|
||||
ERROR HY000: Key/Index cannot be defined on a non-stored computed column.
|
||||
drop table t1;
|
||||
create table t1 (a int, b int as (a*2) persistent);
|
||||
alter table t1 add index (b);
|
||||
drop table t1;
|
||||
create table t1 (a int, b int as (a*2) persistent);
|
||||
alter table t1 add index (a,b);
|
||||
create table t2 like t1;
|
||||
drop table t2;
|
||||
drop table t1;
|
||||
# Testing data manipulation operations involving INDEX
|
||||
# on virtual columns can be found in:
|
||||
# - vcol_select.inc
|
||||
#
|
||||
# TODO: FULLTEXT INDEX
|
||||
# SPATIAL INDEX
|
||||
# Error "All parts of a SPATIAL index must be NOT NULL"
|
||||
create table t1 (a int, b int as (a+1) persistent, spatial index (b));
|
||||
ERROR 42000: All parts of a SPATIAL index must be NOT NULL
|
||||
create table t1 (a int, b int as (a+1) persistent);
|
||||
alter table t1 add spatial index (b);
|
||||
ERROR 42000: All parts of a SPATIAL index must be NOT NULL
|
||||
drop table t1;
|
||||
# FOREIGN KEY
|
||||
# Rejected FK options.
|
||||
create table t1 (a int, b int as (a+1) persistent,
|
||||
foreign key (b) references t2(a) on update set null);
|
||||
ERROR HY000: Cannot define foreign key with ON UPDATE SET NULL clause on a computed column.
|
||||
create table t1 (a int, b int as (a+1) persistent,
|
||||
foreign key (b) references t2(a) on update cascade);
|
||||
ERROR HY000: Cannot define foreign key with ON UPDATE CASCADE clause on a computed column.
|
||||
create table t1 (a int, b int as (a+1) persistent,
|
||||
foreign key (b) references t2(a) on delete set null);
|
||||
ERROR HY000: Cannot define foreign key with ON DELETE SET NULL clause on a computed column.
|
||||
create table t1 (a int, b int as (a+1) persistent);
|
||||
alter table t1 add foreign key (b) references t2(a) on update set null;
|
||||
ERROR HY000: Cannot define foreign key with ON UPDATE SET NULL clause on a computed column.
|
||||
alter table t1 add foreign key (b) references t2(a) on update cascade;
|
||||
ERROR HY000: Cannot define foreign key with ON UPDATE CASCADE clause on a computed column.
|
||||
alter table t1 add foreign key (b) references t2(a) on delete set null;
|
||||
ERROR HY000: Cannot define foreign key with ON DELETE SET NULL clause on a computed column.
|
||||
drop table t1;
|
||||
create table t1 (a int, b int as (a+1),
|
||||
foreign key (b) references t2(a));
|
||||
ERROR HY000: Key/Index cannot be defined on a non-stored computed column.
|
||||
create table t1 (a int, b int as (a+1));
|
||||
alter table t1 add foreign key (b) references t2(a);
|
||||
ERROR HY000: Key/Index cannot be defined on a non-stored computed column.
|
||||
drop table t1;
|
||||
# Allowed FK options.
|
||||
create table t2 (a int primary key, b char(5));
|
||||
create table t1 (a int, b int as (a % 10) persistent,
|
||||
foreign key (b) references t2(a) on update restrict);
|
||||
drop table t1;
|
||||
create table t1 (a int, b int as (a % 10) persistent,
|
||||
foreign key (b) references t2(a) on update no action);
|
||||
drop table t1;
|
||||
create table t1 (a int, b int as (a % 10) persistent,
|
||||
foreign key (b) references t2(a) on delete restrict);
|
||||
drop table t1;
|
||||
create table t1 (a int, b int as (a % 10) persistent,
|
||||
foreign key (b) references t2(a) on delete cascade);
|
||||
drop table t1;
|
||||
create table t1 (a int, b int as (a % 10) persistent,
|
||||
foreign key (b) references t2(a) on delete no action);
|
||||
drop table t1;
|
||||
|
||||
# Testing data manipulation operations involving FOREIGN KEY
|
||||
# on virtual columns can be found in:
|
||||
# - vcol_ins_upd.inc
|
||||
# - vcol_select.inc
|
||||
#
|
||||
# TODO: CHECK
|
7
mysql-test/suite/vcol/r/vcol_memory.result
Normal file
7
mysql-test/suite/vcol/r/vcol_memory.result
Normal file
@ -0,0 +1,7 @@
|
||||
SET @@session.storage_engine = 'memory';
|
||||
create table t1 (a int, b int as (a+1));
|
||||
ERROR HY000: 'Specified storage engine' is not yet supported for computed columns.
|
||||
create table t1 (a int);
|
||||
alter table t1 add column b int as (a+1);
|
||||
ERROR HY000: 'Specified storage engine' is not yet supported for computed columns.
|
||||
drop table t1;
|
8
mysql-test/suite/vcol/r/vcol_merge.result
Normal file
8
mysql-test/suite/vcol/r/vcol_merge.result
Normal file
@ -0,0 +1,8 @@
|
||||
drop table if exists t1, t2, t3;
|
||||
create table t1 (a int, b int as (a % 10));
|
||||
create table t2 (a int, b int as (a % 10));
|
||||
insert into t1 values (1,default);
|
||||
insert into t2 values (2,default);
|
||||
create table t3 (a int, b int as (a % 10)) engine=MERGE UNION=(t1,t2);
|
||||
ERROR HY000: 'Specified storage engine' is not yet supported for computed columns.
|
||||
drop table t1,t2;
|
242
mysql-test/suite/vcol/r/vcol_non_stored_columns_innodb.result
Normal file
242
mysql-test/suite/vcol/r/vcol_non_stored_columns_innodb.result
Normal file
@ -0,0 +1,242 @@
|
||||
SET @@session.storage_engine = 'InnoDB';
|
||||
# Case 1. All non-stored columns.
|
||||
# This scenario is currently impossible due to the fact that virtual columns
|
||||
# with a constant expression are not allowed.
|
||||
# Case 2. CREATE
|
||||
# - Column1: "real"
|
||||
# - Column 2: virtual non-stored
|
||||
create table t1 (a int, b int as (-a));
|
||||
insert into t1 values (1,default);
|
||||
select * from t1;
|
||||
a b
|
||||
1 -1
|
||||
insert into t1 values (2,default);
|
||||
select * from t1;
|
||||
a b
|
||||
1 -1
|
||||
2 -2
|
||||
drop table t1;
|
||||
# Case 3. CREATE
|
||||
# - Column1: "real"
|
||||
# - Column 2: virtual stored
|
||||
create table t1 (a int, b int as (-a) persistent);
|
||||
insert into t1 values (1,default);
|
||||
select * from t1;
|
||||
a b
|
||||
1 -1
|
||||
insert into t1 values (2,default);
|
||||
select * from t1;
|
||||
a b
|
||||
1 -1
|
||||
2 -2
|
||||
drop table t1;
|
||||
# Case 4. CREATE
|
||||
# - Column1: virtual non-stored
|
||||
# - Column2: "real"
|
||||
create table t1 (a int as (-b), b int);
|
||||
insert into t1 values (default,1);
|
||||
select * from t1;
|
||||
a b
|
||||
-1 1
|
||||
insert into t1 values (default,2);
|
||||
select * from t1;
|
||||
a b
|
||||
-1 1
|
||||
-2 2
|
||||
drop table t1;
|
||||
# Case 5. CREATE
|
||||
# - Column1: virtual stored
|
||||
# - Column2: "real"
|
||||
create table t1 (a int as (-b) persistent, b int);
|
||||
insert into t1 values (default,1);
|
||||
select * from t1;
|
||||
a b
|
||||
-1 1
|
||||
insert into t1 values (default,2);
|
||||
select * from t1;
|
||||
a b
|
||||
-1 1
|
||||
-2 2
|
||||
drop table t1;
|
||||
# Case 6. CREATE
|
||||
# - Column1: "real"
|
||||
# - Column2: virtual non-stored
|
||||
# - Column3: virtual stored
|
||||
create table t1 (a int, b int as (-a), c int as (-a) persistent);
|
||||
insert into t1 values (1,default,default);
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
insert into t1 values (2,default,default);
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
drop table t1;
|
||||
# Case 7. ALTER. Modify virtual stored -> virtual non-stored
|
||||
create table t1 (a int, b int as (a % 2) persistent);
|
||||
alter table t1 modify b int as (a % 2);
|
||||
ERROR HY000: 'Changing the STORED status' is not yet supported for computed columns.
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` int(11) AS (a % 2) PERSISTENT
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
# Case 8. ALTER. Modify virtual non-stored -> virtual stored
|
||||
create table t1 (a int, b int as (a % 2));
|
||||
alter table t1 modify b int as (a % 2) persistent;
|
||||
ERROR HY000: 'Changing the STORED status' is not yet supported for computed columns.
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` int(11) AS (a % 2) VIRTUAL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
# Case 9. CREATE LIKE
|
||||
# - Column1: "real"
|
||||
# - Column2: virtual non-stored
|
||||
# - Column3: virtual stored
|
||||
create table t1 (a int, b int as (-a), c int as (-a) persistent);
|
||||
create table t2 like t1;
|
||||
insert into t2 values (1,default,default);
|
||||
select * from t2;
|
||||
a b c
|
||||
1 -1 -1
|
||||
insert into t2 values (2,default,default);
|
||||
select * from t2;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
drop table t2;
|
||||
drop table t1;
|
||||
# Case 10. ALTER. Dropping a virtual non-stored column.
|
||||
# - Column1: virtual non-stored
|
||||
# - Column2: "real"
|
||||
create table t1 (a int as (-b), b int, c varchar(5));
|
||||
insert into t1 values (default,1,'v1');
|
||||
insert into t1 values (default,2,'v2');
|
||||
select * from t1;
|
||||
a b c
|
||||
-1 1 v1
|
||||
-2 2 v2
|
||||
alter table t1 drop column a;
|
||||
select * from t1;
|
||||
b c
|
||||
1 v1
|
||||
2 v2
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`b` int(11) DEFAULT NULL,
|
||||
`c` varchar(5) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
# Case 11. ALTER. Dropping a virtual stored column.
|
||||
# - Column1: virtual stored
|
||||
# - Column2: "real"
|
||||
create table t1 (a int as (-b) persistent, b int, c char(5));
|
||||
insert into t1 values (default,1,'v1');
|
||||
insert into t1 values (default,2,'v2');
|
||||
select * from t1;
|
||||
a b c
|
||||
-1 1 v1
|
||||
-2 2 v2
|
||||
alter table t1 drop column a;
|
||||
select * from t1;
|
||||
b c
|
||||
1 v1
|
||||
2 v2
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`b` int(11) DEFAULT NULL,
|
||||
`c` char(5) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
# Case 12. ALTER. Adding a new virtual non-stored column.
|
||||
create 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;
|
||||
a b
|
||||
1 2008-09-04 00:00:00
|
||||
2 2008-09-05 00:00:00
|
||||
alter table t1 add column c int as (dayofyear(b)) after a;
|
||||
select * from t1;
|
||||
a c b
|
||||
1 248 2008-09-04 00:00:00
|
||||
2 249 2008-09-05 00:00:00
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`c` int(11) AS (dayofyear(b)) VIRTUAL,
|
||||
`b` datetime DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
# Case 13. ALTER. Adding a new virtual stored column.
|
||||
create 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;
|
||||
a b
|
||||
1 2008-09-04 00:00:00
|
||||
2 2008-09-05 00:00:00
|
||||
alter table t1 add column c int as (dayofyear(b)) persistent after a;
|
||||
select * from t1;
|
||||
a c b
|
||||
1 248 2008-09-04 00:00:00
|
||||
2 249 2008-09-05 00:00:00
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`c` int(11) AS (dayofyear(b)) PERSISTENT,
|
||||
`b` datetime DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
# Case 14. ALTER. Changing the expression of a virtual stored column.
|
||||
create table t1 (a int, b datetime, c int as (week(b)) persistent);
|
||||
insert into t1 values (1,'2008-09-04',default);
|
||||
insert into t1 values (2,'2008-09-05',default);
|
||||
select * from t1;
|
||||
a b c
|
||||
1 2008-09-04 00:00:00 35
|
||||
2 2008-09-05 00:00:00 35
|
||||
alter table t1 change column c c int as (week(b,1)) persistent;
|
||||
select * from t1;
|
||||
a b c
|
||||
1 2008-09-04 00:00:00 36
|
||||
2 2008-09-05 00:00:00 36
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` datetime DEFAULT NULL,
|
||||
`c` int(11) AS (week(b,1)) PERSISTENT
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
# Case 15. ALTER. Changing the expression of a virtual non-stored column.
|
||||
create table t1 (a int, b datetime, c int as (week(b)));
|
||||
insert into t1 values (1,'2008-09-04',default);
|
||||
insert into t1 values (2,'2008-09-05',default);
|
||||
select * from t1;
|
||||
a b c
|
||||
1 2008-09-04 00:00:00 35
|
||||
2 2008-09-05 00:00:00 35
|
||||
alter table t1 change column c c int as (week(b,1));
|
||||
select * from t1;
|
||||
a b c
|
||||
1 2008-09-04 00:00:00 36
|
||||
2 2008-09-05 00:00:00 36
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` datetime DEFAULT NULL,
|
||||
`c` int(11) AS (week(b,1)) VIRTUAL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
242
mysql-test/suite/vcol/r/vcol_non_stored_columns_myisam.result
Normal file
242
mysql-test/suite/vcol/r/vcol_non_stored_columns_myisam.result
Normal file
@ -0,0 +1,242 @@
|
||||
SET @@session.storage_engine = 'MyISAM';
|
||||
# Case 1. All non-stored columns.
|
||||
# This scenario is currently impossible due to the fact that virtual columns
|
||||
# with a constant expression are not allowed.
|
||||
# Case 2. CREATE
|
||||
# - Column1: "real"
|
||||
# - Column 2: virtual non-stored
|
||||
create table t1 (a int, b int as (-a));
|
||||
insert into t1 values (1,default);
|
||||
select * from t1;
|
||||
a b
|
||||
1 -1
|
||||
insert into t1 values (2,default);
|
||||
select * from t1;
|
||||
a b
|
||||
1 -1
|
||||
2 -2
|
||||
drop table t1;
|
||||
# Case 3. CREATE
|
||||
# - Column1: "real"
|
||||
# - Column 2: virtual stored
|
||||
create table t1 (a int, b int as (-a) persistent);
|
||||
insert into t1 values (1,default);
|
||||
select * from t1;
|
||||
a b
|
||||
1 -1
|
||||
insert into t1 values (2,default);
|
||||
select * from t1;
|
||||
a b
|
||||
1 -1
|
||||
2 -2
|
||||
drop table t1;
|
||||
# Case 4. CREATE
|
||||
# - Column1: virtual non-stored
|
||||
# - Column2: "real"
|
||||
create table t1 (a int as (-b), b int);
|
||||
insert into t1 values (default,1);
|
||||
select * from t1;
|
||||
a b
|
||||
-1 1
|
||||
insert into t1 values (default,2);
|
||||
select * from t1;
|
||||
a b
|
||||
-1 1
|
||||
-2 2
|
||||
drop table t1;
|
||||
# Case 5. CREATE
|
||||
# - Column1: virtual stored
|
||||
# - Column2: "real"
|
||||
create table t1 (a int as (-b) persistent, b int);
|
||||
insert into t1 values (default,1);
|
||||
select * from t1;
|
||||
a b
|
||||
-1 1
|
||||
insert into t1 values (default,2);
|
||||
select * from t1;
|
||||
a b
|
||||
-1 1
|
||||
-2 2
|
||||
drop table t1;
|
||||
# Case 6. CREATE
|
||||
# - Column1: "real"
|
||||
# - Column2: virtual non-stored
|
||||
# - Column3: virtual stored
|
||||
create table t1 (a int, b int as (-a), c int as (-a) persistent);
|
||||
insert into t1 values (1,default,default);
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
insert into t1 values (2,default,default);
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
drop table t1;
|
||||
# Case 7. ALTER. Modify virtual stored -> virtual non-stored
|
||||
create table t1 (a int, b int as (a % 2) persistent);
|
||||
alter table t1 modify b int as (a % 2);
|
||||
ERROR HY000: 'Changing the STORED status' is not yet supported for computed columns.
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` int(11) AS (a % 2) PERSISTENT
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
# Case 8. ALTER. Modify virtual non-stored -> virtual stored
|
||||
create table t1 (a int, b int as (a % 2));
|
||||
alter table t1 modify b int as (a % 2) persistent;
|
||||
ERROR HY000: 'Changing the STORED status' is not yet supported for computed columns.
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` int(11) AS (a % 2) VIRTUAL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
# Case 9. CREATE LIKE
|
||||
# - Column1: "real"
|
||||
# - Column2: virtual non-stored
|
||||
# - Column3: virtual stored
|
||||
create table t1 (a int, b int as (-a), c int as (-a) persistent);
|
||||
create table t2 like t1;
|
||||
insert into t2 values (1,default,default);
|
||||
select * from t2;
|
||||
a b c
|
||||
1 -1 -1
|
||||
insert into t2 values (2,default,default);
|
||||
select * from t2;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
drop table t2;
|
||||
drop table t1;
|
||||
# Case 10. ALTER. Dropping a virtual non-stored column.
|
||||
# - Column1: virtual non-stored
|
||||
# - Column2: "real"
|
||||
create table t1 (a int as (-b), b int, c varchar(5));
|
||||
insert into t1 values (default,1,'v1');
|
||||
insert into t1 values (default,2,'v2');
|
||||
select * from t1;
|
||||
a b c
|
||||
-1 1 v1
|
||||
-2 2 v2
|
||||
alter table t1 drop column a;
|
||||
select * from t1;
|
||||
b c
|
||||
1 v1
|
||||
2 v2
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`b` int(11) DEFAULT NULL,
|
||||
`c` varchar(5) DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
# Case 11. ALTER. Dropping a virtual stored column.
|
||||
# - Column1: virtual stored
|
||||
# - Column2: "real"
|
||||
create table t1 (a int as (-b) persistent, b int, c char(5));
|
||||
insert into t1 values (default,1,'v1');
|
||||
insert into t1 values (default,2,'v2');
|
||||
select * from t1;
|
||||
a b c
|
||||
-1 1 v1
|
||||
-2 2 v2
|
||||
alter table t1 drop column a;
|
||||
select * from t1;
|
||||
b c
|
||||
1 v1
|
||||
2 v2
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`b` int(11) DEFAULT NULL,
|
||||
`c` char(5) DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
# Case 12. ALTER. Adding a new virtual non-stored column.
|
||||
create 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;
|
||||
a b
|
||||
1 2008-09-04 00:00:00
|
||||
2 2008-09-05 00:00:00
|
||||
alter table t1 add column c int as (dayofyear(b)) after a;
|
||||
select * from t1;
|
||||
a c b
|
||||
1 248 2008-09-04 00:00:00
|
||||
2 249 2008-09-05 00:00:00
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`c` int(11) AS (dayofyear(b)) VIRTUAL,
|
||||
`b` datetime DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
# Case 13. ALTER. Adding a new virtual stored column.
|
||||
create 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;
|
||||
a b
|
||||
1 2008-09-04 00:00:00
|
||||
2 2008-09-05 00:00:00
|
||||
alter table t1 add column c int as (dayofyear(b)) persistent after a;
|
||||
select * from t1;
|
||||
a c b
|
||||
1 248 2008-09-04 00:00:00
|
||||
2 249 2008-09-05 00:00:00
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`c` int(11) AS (dayofyear(b)) PERSISTENT,
|
||||
`b` datetime DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
# Case 14. ALTER. Changing the expression of a virtual stored column.
|
||||
create table t1 (a int, b datetime, c int as (week(b)) persistent);
|
||||
insert into t1 values (1,'2008-09-04',default);
|
||||
insert into t1 values (2,'2008-09-05',default);
|
||||
select * from t1;
|
||||
a b c
|
||||
1 2008-09-04 00:00:00 35
|
||||
2 2008-09-05 00:00:00 35
|
||||
alter table t1 change column c c int as (week(b,1)) persistent;
|
||||
select * from t1;
|
||||
a b c
|
||||
1 2008-09-04 00:00:00 36
|
||||
2 2008-09-05 00:00:00 36
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` datetime DEFAULT NULL,
|
||||
`c` int(11) AS (week(b,1)) PERSISTENT
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
# Case 15. ALTER. Changing the expression of a virtual non-stored column.
|
||||
create table t1 (a int, b datetime, c int as (week(b)));
|
||||
insert into t1 values (1,'2008-09-04',default);
|
||||
insert into t1 values (2,'2008-09-05',default);
|
||||
select * from t1;
|
||||
a b c
|
||||
1 2008-09-04 00:00:00 35
|
||||
2 2008-09-05 00:00:00 35
|
||||
alter table t1 change column c c int as (week(b,1));
|
||||
select * from t1;
|
||||
a b c
|
||||
1 2008-09-04 00:00:00 36
|
||||
2 2008-09-05 00:00:00 36
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` datetime DEFAULT NULL,
|
||||
`c` int(11) AS (week(b,1)) VIRTUAL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
58
mysql-test/suite/vcol/r/vcol_partition_innodb.result
Normal file
58
mysql-test/suite/vcol/r/vcol_partition_innodb.result
Normal file
@ -0,0 +1,58 @@
|
||||
SET @@session.storage_engine = 'InnoDB';
|
||||
drop table if exists t1;
|
||||
# Case 1. Partitioning by RANGE based on a non-stored virtual column.
|
||||
CREATE TABLE t1 (
|
||||
a DATE NOT NULL,
|
||||
b int as (year(a))
|
||||
)
|
||||
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;
|
||||
a b
|
||||
2005-01-01 2005
|
||||
2006-01-01 2006
|
||||
2007-01-01 2007
|
||||
# Modify the expression of virtual column b
|
||||
ALTER TABLE t1 modify b int as (year(a)-1);
|
||||
select * from t1;
|
||||
a b
|
||||
2005-01-01 2004
|
||||
2006-01-01 2005
|
||||
2007-01-01 2006
|
||||
drop table t1;
|
||||
# Case 2. Partitioning by LIST based on a stored virtual column.
|
||||
CREATE TABLE t1 (a int, b int as (a % 3 ) persistent)
|
||||
PARTITION BY LIST (a+1)
|
||||
(PARTITION p1 VALUES IN (1), PARTITION p2 VALUES IN (2));
|
||||
insert into t1 values (1,default);
|
||||
select * from t1;
|
||||
a b
|
||||
1 1
|
||||
select * from t1;
|
||||
a b
|
||||
1 1
|
||||
drop table t1;
|
||||
# Case 3. Partitioning by HASH based on a non-stored virtual column.
|
||||
CREATE TABLE t1 (
|
||||
a DATE NOT NULL,
|
||||
b int as (year(a))
|
||||
)
|
||||
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;
|
||||
a b
|
||||
2005-01-01 2005
|
||||
2006-01-01 2006
|
||||
# Modify the expression of virtual column b
|
||||
ALTER TABLE t1 modify b int as (year(a)-1);
|
||||
select * from t1;
|
||||
a b
|
||||
2005-01-01 2004
|
||||
2006-01-01 2005
|
||||
drop table t1;
|
75
mysql-test/suite/vcol/r/vcol_partition_myisam.result
Normal file
75
mysql-test/suite/vcol/r/vcol_partition_myisam.result
Normal file
@ -0,0 +1,75 @@
|
||||
SET @@session.storage_engine = 'MyISAM';
|
||||
drop table if exists t1;
|
||||
# Case 1. Partitioning by RANGE based on a non-stored virtual column.
|
||||
CREATE TABLE t1 (
|
||||
a DATE NOT NULL,
|
||||
b int as (year(a))
|
||||
)
|
||||
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;
|
||||
a b
|
||||
2005-01-01 2005
|
||||
2006-01-01 2006
|
||||
2007-01-01 2007
|
||||
# Check how data is physically partitioned.
|
||||
7 MYSQLTEST_VARDIR/mysqld.1/data/test/t1#P#p0.MYD
|
||||
14 MYSQLTEST_VARDIR/mysqld.1/data/test/t1#P#p2.MYD
|
||||
# Modify the expression of virtual column b
|
||||
ALTER TABLE t1 modify b int as (year(a)-1);
|
||||
select * from t1;
|
||||
a b
|
||||
2005-01-01 2004
|
||||
2006-01-01 2005
|
||||
2007-01-01 2006
|
||||
# Check how data is physically partitioned.
|
||||
14 MYSQLTEST_VARDIR/mysqld.1/data/test/t1#P#p0.MYD
|
||||
7 MYSQLTEST_VARDIR/mysqld.1/data/test/t1#P#p2.MYD
|
||||
drop table t1;
|
||||
# Case 2. Partitioning by LIST based on a stored virtual column.
|
||||
CREATE TABLE t1 (a int, b int as (a % 3 ) persistent)
|
||||
PARTITION BY LIST (a+1)
|
||||
(PARTITION p1 VALUES IN (1), PARTITION p2 VALUES IN (2));
|
||||
insert into t1 values (1,default);
|
||||
# Check how data is physically partitioned.
|
||||
0 MYSQLTEST_VARDIR/mysqld.1/data/test/t1#P#p1.MYD
|
||||
9 MYSQLTEST_VARDIR/mysqld.1/data/test/t1#P#p2.MYD
|
||||
select * from t1;
|
||||
a b
|
||||
1 1
|
||||
select * from t1;
|
||||
a b
|
||||
1 1
|
||||
drop table t1;
|
||||
# Case 3. Partitioning by HASH based on a non-stored virtual column.
|
||||
CREATE TABLE t1 (
|
||||
a DATE NOT NULL,
|
||||
b int as (year(a))
|
||||
)
|
||||
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;
|
||||
a b
|
||||
2005-01-01 2005
|
||||
2006-01-01 2006
|
||||
# Check how data is physically partitioned.
|
||||
0 MYSQLTEST_VARDIR/mysqld.1/data/test/t1#P#p0.MYD
|
||||
7 MYSQLTEST_VARDIR/mysqld.1/data/test/t1#P#p1.MYD
|
||||
7 MYSQLTEST_VARDIR/mysqld.1/data/test/t1#P#p2.MYD
|
||||
# Modify the expression of virtual column b
|
||||
ALTER TABLE t1 modify b int as (year(a)-1);
|
||||
select * from t1;
|
||||
a b
|
||||
2005-01-01 2004
|
||||
2006-01-01 2005
|
||||
# Check how data is physically partitioned.
|
||||
7 MYSQLTEST_VARDIR/mysqld.1/data/test/t1#P#p0.MYD
|
||||
7 MYSQLTEST_VARDIR/mysqld.1/data/test/t1#P#p1.MYD
|
||||
0 MYSQLTEST_VARDIR/mysqld.1/data/test/t1#P#p2.MYD
|
||||
drop table t1;
|
264
mysql-test/suite/vcol/r/vcol_select_innodb.result
Normal file
264
mysql-test/suite/vcol/r/vcol_select_innodb.result
Normal file
@ -0,0 +1,264 @@
|
||||
SET @@session.storage_engine = 'InnoDB';
|
||||
create table t1 (a int,
|
||||
b int as (-a),
|
||||
c int as (-a) persistent,
|
||||
index (c));
|
||||
insert into t1 (a) values (2), (1), (1), (3), (NULL);
|
||||
create table t2 like t1;
|
||||
insert into t2 (a) values (1);
|
||||
create table t3 (a int primary key,
|
||||
b int as (-a),
|
||||
c int as (-a) persistent unique);
|
||||
insert into t3 (a) values (2),(1),(3);
|
||||
# select_type=SIMPLE, type=system
|
||||
select * from t2;
|
||||
a b c
|
||||
1 -1 -1
|
||||
explain select * from t2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 1
|
||||
select * from t2 where c=-1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
explain select * from t2 where c=-1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ref c c 5 const 1 Using where
|
||||
# select_type=SIMPLE, type=ALL
|
||||
select * from t1 where b=-1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
1 -1 -1
|
||||
explain select * from t1 where b=-1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where
|
||||
# select_type=SIMPLE, type=const
|
||||
select * from t3 where a=1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
explain select * from t3 where a=1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 const PRIMARY PRIMARY 4 const 1
|
||||
# select_type=SIMPLE, type=range
|
||||
select * from t3 where c>=-1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
explain select * from t3 where c>=-1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 range c c 5 NULL 1 Using where
|
||||
# select_type=SIMPLE, type=ref
|
||||
select * from t1,t3 where t1.c=t3.c and t3.c=-1;
|
||||
a b c a b c
|
||||
1 -1 -1 1 -1 -1
|
||||
1 -1 -1 1 -1 -1
|
||||
explain select * from t1,t3 where t1.c=t3.c and t3.c=-1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 const c c 5 const 1
|
||||
1 SIMPLE t1 ref c c 5 const 2 Using where
|
||||
# select_type=PRIMARY, type=index,ALL
|
||||
select * from t1 where b in (select c from t3);
|
||||
a b c
|
||||
2 -2 -2
|
||||
1 -1 -1
|
||||
1 -1 -1
|
||||
3 -3 -3
|
||||
explain select * from t1 where b in (select c from t3);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where
|
||||
2 DEPENDENT SUBQUERY t3 index_subquery c c 5 func 1 Using index; Using where
|
||||
# select_type=PRIMARY, type=range,ref
|
||||
select * from t1 where c in (select c from t3 where c between -2 and -1);
|
||||
a b c
|
||||
2 -2 -2
|
||||
1 -1 -1
|
||||
1 -1 -1
|
||||
explain select * from t1 where c in (select c from t3 where c between -2 and -1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where
|
||||
2 DEPENDENT SUBQUERY t3 index_subquery c c 5 func 1 Using index; Using where
|
||||
# select_type=UNION, type=system
|
||||
# select_type=UNION RESULT, type=<union1,2>
|
||||
select * from t1 union select * from t2;
|
||||
a b c
|
||||
2 -2 -2
|
||||
1 -1 -1
|
||||
3 -3 -3
|
||||
NULL NULL NULL
|
||||
explain select * from t1 union select * from t2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 5
|
||||
2 UNION t2 ALL NULL NULL NULL NULL 1
|
||||
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL
|
||||
# select_type=DERIVED, type=system
|
||||
select * from (select a,b,c from t1) as t11;
|
||||
a b c
|
||||
2 -2 -2
|
||||
1 -1 -1
|
||||
1 -1 -1
|
||||
3 -3 -3
|
||||
NULL NULL NULL
|
||||
explain select * from (select a,b,c from t1) as t11;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 5
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 5
|
||||
###
|
||||
### Using aggregate functions with/without DISTINCT
|
||||
###
|
||||
# SELECT COUNT(*) FROM tbl_name
|
||||
select count(*) from t1;
|
||||
count(*)
|
||||
5
|
||||
explain select count(*) from t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL c 5 NULL 5 Using index
|
||||
# SELECT COUNT(DISTINCT <non-vcol>) FROM tbl_name
|
||||
select count(distinct a) from t1;
|
||||
count(distinct a)
|
||||
3
|
||||
explain select count(distinct a) from t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 5
|
||||
# SELECT COUNT(DISTINCT <non-stored vcol>) FROM tbl_name
|
||||
select count(distinct b) from t1;
|
||||
count(distinct b)
|
||||
3
|
||||
explain select count(distinct b) from t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 5
|
||||
# SELECT COUNT(DISTINCT <stored vcol>) FROM tbl_name
|
||||
select count(distinct c) from t1;
|
||||
count(distinct c)
|
||||
3
|
||||
explain select count(distinct c) from t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL c 5 NULL 5 Using index
|
||||
###
|
||||
### filesort & range-based utils
|
||||
###
|
||||
# SELECT * FROM tbl_name WHERE <vcol expr>
|
||||
select * from t3 where c >= -2;
|
||||
a b c
|
||||
2 -2 -2
|
||||
1 -1 -1
|
||||
explain select * from t3 where c >= -2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 range c c 5 NULL 1 Using where
|
||||
# SELECT * FROM tbl_name WHERE <non-vcol expr>
|
||||
select * from t3 where a between 1 and 2;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
explain select * from t3 where a between 1 and 2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 range PRIMARY PRIMARY 4 NULL 1 Using where
|
||||
# SELECT * FROM tbl_name WHERE <non-indexed vcol expr>
|
||||
select * from t3 where b between -2 and -1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
explain select * from t3 where b between -2 and -1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 ALL NULL NULL NULL NULL 3 Using where
|
||||
# SELECT * FROM tbl_name WHERE <indexed vcol expr>
|
||||
select * from t3 where c between -2 and -1;
|
||||
a b c
|
||||
2 -2 -2
|
||||
1 -1 -1
|
||||
explain select * from t3 where c between -2 and -1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 range c c 5 NULL 1 Using where
|
||||
# SELECT * FROM tbl_name WHERE <non-vcol expr> ORDER BY <non-indexed vcol>
|
||||
select * from t3 where a between 1 and 2 order by b;
|
||||
a b c
|
||||
2 -2 -2
|
||||
1 -1 -1
|
||||
explain select * from t3 where a between 1 and 2 order by b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 range PRIMARY PRIMARY 4 NULL 1 Using where; Using filesort
|
||||
# SELECT * FROM tbl_name WHERE <non-vcol expr> ORDER BY <indexed vcol>
|
||||
select * from t3 where a between 1 and 2 order by c;
|
||||
a b c
|
||||
2 -2 -2
|
||||
1 -1 -1
|
||||
explain select * from t3 where a between 1 and 2 order by c;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 range PRIMARY PRIMARY 4 NULL 1 Using where; Using filesort
|
||||
# SELECT * FROM tbl_name WHERE <non-indexed vcol expr> ORDER BY <non-vcol>
|
||||
select * from t3 where b between -2 and -1 order by a;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
explain select * from t3 where b between -2 and -1 order by a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 index NULL PRIMARY 4 NULL 3 Using where
|
||||
# SELECT * FROM tbl_name WHERE <non-indexed vcol expr> ORDER BY <non-indexed vcol>
|
||||
select * from t3 where b between -2 and -1 order by b;
|
||||
a b c
|
||||
2 -2 -2
|
||||
1 -1 -1
|
||||
explain select * from t3 where b between -2 and -1 order by b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 ALL NULL NULL NULL NULL 3 Using where; Using filesort
|
||||
# SELECT * FROM tbl_name WHERE <indexed vcol expr> ORDER BY <non-indexed vcol>
|
||||
select * from t3 where c between -2 and -1 order by b;
|
||||
a b c
|
||||
2 -2 -2
|
||||
1 -1 -1
|
||||
explain select * from t3 where c between -2 and -1 order by b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 range c c 5 NULL 1 Using where; Using filesort
|
||||
# SELECT * FROM tbl_name WHERE <non-indexed vcol expr> ORDER BY <indexed vcol>
|
||||
select * from t3 where b between -2 and -1 order by c;
|
||||
a b c
|
||||
2 -2 -2
|
||||
1 -1 -1
|
||||
explain select * from t3 where b between -2 and -1 order by c;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 ALL NULL NULL NULL NULL 3 Using where; Using filesort
|
||||
# SELECT * FROM tbl_name WHERE <indexed vcol expr> ORDER BY <indexed vcol>
|
||||
select * from t3 where c between -2 and -1 order by c;
|
||||
a b c
|
||||
2 -2 -2
|
||||
1 -1 -1
|
||||
explain select * from t3 where c between -2 and -1 order by c;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 range c c 5 NULL 1 Using where
|
||||
# SELECT sum(<non-indexed vcol>) FROM tbl_name GROUP BY <non-indexed vcol>
|
||||
select sum(b) from t1 group by b;
|
||||
sum(b)
|
||||
NULL
|
||||
-3
|
||||
-2
|
||||
-2
|
||||
explain select sum(b) from t1 group by b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using temporary; Using filesort
|
||||
# SELECT sum(<indexed vcol>) FROM tbl_name GROUP BY <indexed vcol>
|
||||
select sum(c) from t1 group by c;
|
||||
sum(c)
|
||||
NULL
|
||||
-3
|
||||
-2
|
||||
-2
|
||||
explain select sum(c) from t1 group by c;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL c 5 NULL 5 Using index
|
||||
# SELECT sum(<non-indexed vcol>) FROM tbl_name GROUP BY <indexed vcol>
|
||||
select sum(b) from t1 group by c;
|
||||
sum(b)
|
||||
NULL
|
||||
-3
|
||||
-2
|
||||
-2
|
||||
explain select sum(b) from t1 group by c;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL c 5 NULL 5
|
||||
# SELECT sum(<indexed vcol>) FROM tbl_name GROUP BY <non-indexed vcol>
|
||||
select sum(c) from t1 group by b;
|
||||
sum(c)
|
||||
NULL
|
||||
-3
|
||||
-2
|
||||
-2
|
||||
explain select sum(c) from t1 group by b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using temporary; Using filesort
|
264
mysql-test/suite/vcol/r/vcol_select_myisam.result
Normal file
264
mysql-test/suite/vcol/r/vcol_select_myisam.result
Normal file
@ -0,0 +1,264 @@
|
||||
SET @@session.storage_engine = 'MyISAM';
|
||||
create table t1 (a int,
|
||||
b int as (-a),
|
||||
c int as (-a) persistent,
|
||||
index (c));
|
||||
insert into t1 (a) values (2), (1), (1), (3), (NULL);
|
||||
create table t2 like t1;
|
||||
insert into t2 (a) values (1);
|
||||
create table t3 (a int primary key,
|
||||
b int as (-a),
|
||||
c int as (-a) persistent unique);
|
||||
insert into t3 (a) values (2),(1),(3);
|
||||
# select_type=SIMPLE, type=system
|
||||
select * from t2;
|
||||
a b c
|
||||
1 -1 -1
|
||||
explain select * from t2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 system NULL NULL NULL NULL 1
|
||||
select * from t2 where c=-1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
explain select * from t2 where c=-1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 system c NULL NULL NULL 1
|
||||
# select_type=SIMPLE, type=ALL
|
||||
select * from t1 where b=-1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
1 -1 -1
|
||||
explain select * from t1 where b=-1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where
|
||||
# select_type=SIMPLE, type=const
|
||||
select * from t3 where a=1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
explain select * from t3 where a=1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 const PRIMARY PRIMARY 4 const 1
|
||||
# select_type=SIMPLE, type=range
|
||||
select * from t3 where c>=-1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
explain select * from t3 where c>=-1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 range c c 5 NULL 2 Using where
|
||||
# select_type=SIMPLE, type=ref
|
||||
select * from t1,t3 where t1.c=t3.c and t3.c=-1;
|
||||
a b c a b c
|
||||
1 -1 -1 1 -1 -1
|
||||
1 -1 -1 1 -1 -1
|
||||
explain select * from t1,t3 where t1.c=t3.c and t3.c=-1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 const c c 5 const 1
|
||||
1 SIMPLE t1 ref c c 5 const 2 Using where
|
||||
# select_type=PRIMARY, type=index,ALL
|
||||
select * from t1 where b in (select c from t3);
|
||||
a b c
|
||||
2 -2 -2
|
||||
1 -1 -1
|
||||
1 -1 -1
|
||||
3 -3 -3
|
||||
explain select * from t1 where b in (select c from t3);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where
|
||||
2 DEPENDENT SUBQUERY t3 index_subquery c c 5 func 2 Using index; Using where
|
||||
# select_type=PRIMARY, type=range,ref
|
||||
select * from t1 where c in (select c from t3 where c between -2 and -1);
|
||||
a b c
|
||||
2 -2 -2
|
||||
1 -1 -1
|
||||
1 -1 -1
|
||||
explain select * from t1 where c in (select c from t3 where c between -2 and -1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where
|
||||
2 DEPENDENT SUBQUERY t3 index_subquery c c 5 func 2 Using index; Using where
|
||||
# select_type=UNION, type=system
|
||||
# select_type=UNION RESULT, type=<union1,2>
|
||||
select * from t1 union select * from t2;
|
||||
a b c
|
||||
2 -2 -2
|
||||
1 -1 -1
|
||||
3 -3 -3
|
||||
NULL NULL NULL
|
||||
explain select * from t1 union select * from t2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 5
|
||||
2 UNION t2 system NULL NULL NULL NULL 1
|
||||
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL
|
||||
# select_type=DERIVED, type=system
|
||||
select * from (select a,b,c from t1) as t11;
|
||||
a b c
|
||||
2 -2 -2
|
||||
1 -1 -1
|
||||
1 -1 -1
|
||||
3 -3 -3
|
||||
NULL NULL NULL
|
||||
explain select * from (select a,b,c from t1) as t11;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 5
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 5
|
||||
###
|
||||
### Using aggregate functions with/without DISTINCT
|
||||
###
|
||||
# SELECT COUNT(*) FROM tbl_name
|
||||
select count(*) from t1;
|
||||
count(*)
|
||||
5
|
||||
explain select count(*) from t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
|
||||
# SELECT COUNT(DISTINCT <non-vcol>) FROM tbl_name
|
||||
select count(distinct a) from t1;
|
||||
count(distinct a)
|
||||
3
|
||||
explain select count(distinct a) from t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 5
|
||||
# SELECT COUNT(DISTINCT <non-stored vcol>) FROM tbl_name
|
||||
select count(distinct b) from t1;
|
||||
count(distinct b)
|
||||
3
|
||||
explain select count(distinct b) from t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 5
|
||||
# SELECT COUNT(DISTINCT <stored vcol>) FROM tbl_name
|
||||
select count(distinct c) from t1;
|
||||
count(distinct c)
|
||||
3
|
||||
explain select count(distinct c) from t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL c 5 NULL 5 Using index
|
||||
###
|
||||
### filesort & range-based utils
|
||||
###
|
||||
# SELECT * FROM tbl_name WHERE <vcol expr>
|
||||
select * from t3 where c >= -2;
|
||||
a b c
|
||||
2 -2 -2
|
||||
1 -1 -1
|
||||
explain select * from t3 where c >= -2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 range c c 5 NULL 2 Using where
|
||||
# SELECT * FROM tbl_name WHERE <non-vcol expr>
|
||||
select * from t3 where a between 1 and 2;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
explain select * from t3 where a between 1 and 2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 range PRIMARY PRIMARY 4 NULL 1 Using where
|
||||
# SELECT * FROM tbl_name WHERE <non-indexed vcol expr>
|
||||
select * from t3 where b between -2 and -1;
|
||||
a b c
|
||||
2 -2 -2
|
||||
1 -1 -1
|
||||
explain select * from t3 where b between -2 and -1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 ALL NULL NULL NULL NULL 3 Using where
|
||||
# SELECT * FROM tbl_name WHERE <indexed vcol expr>
|
||||
select * from t3 where c between -2 and -1;
|
||||
a b c
|
||||
2 -2 -2
|
||||
1 -1 -1
|
||||
explain select * from t3 where c between -2 and -1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 range c c 5 NULL 1 Using where
|
||||
# SELECT * FROM tbl_name WHERE <non-vcol expr> ORDER BY <indexed vcol>
|
||||
select * from t3 where a between 1 and 2 order by c;
|
||||
a b c
|
||||
2 -2 -2
|
||||
1 -1 -1
|
||||
explain select * from t3 where a between 1 and 2 order by c;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 range PRIMARY PRIMARY 4 NULL 1 Using where; Using filesort
|
||||
# SELECT * FROM tbl_name WHERE <non-indexed vcol expr> ORDER BY <non-vcol>
|
||||
select * from t3 where b between -2 and -1 order by a;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
explain select * from t3 where b between -2 and -1 order by a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 ALL NULL NULL NULL NULL 3 Using where; Using filesort
|
||||
# SELECT * FROM tbl_name WHERE <indexed vcol expr> ORDER BY <non-vcol>
|
||||
select * from t3 where c between -2 and -1 order by a;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
explain select * from t3 where c between -2 and -1 order by a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 range c c 5 NULL 1 Using where; Using filesort
|
||||
# SELECT * FROM tbl_name WHERE <non-indexed vcol expr> ORDER BY <non-indexed vcol>
|
||||
select * from t3 where b between -2 and -1 order by b;
|
||||
a b c
|
||||
2 -2 -2
|
||||
1 -1 -1
|
||||
explain select * from t3 where b between -2 and -1 order by b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 ALL NULL NULL NULL NULL 3 Using where; Using filesort
|
||||
# SELECT * FROM tbl_name WHERE <indexed vcol expr> ORDER BY <non-indexed vcol>
|
||||
select * from t3 where c between -2 and -1 order by b;
|
||||
a b c
|
||||
2 -2 -2
|
||||
1 -1 -1
|
||||
explain select * from t3 where c between -2 and -1 order by b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 range c c 5 NULL 1 Using where; Using filesort
|
||||
# SELECT * FROM tbl_name WHERE <non-indexed vcol expr> ORDER BY <indexed vcol>
|
||||
select * from t3 where b between -2 and -1 order by c;
|
||||
a b c
|
||||
2 -2 -2
|
||||
1 -1 -1
|
||||
explain select * from t3 where b between -2 and -1 order by c;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 ALL NULL NULL NULL NULL 3 Using where; Using filesort
|
||||
# SELECT * FROM tbl_name WHERE <indexed vcol expr> ORDER BY <indexed vcol>
|
||||
select * from t3 where c between -2 and -1 order by c;
|
||||
a b c
|
||||
2 -2 -2
|
||||
1 -1 -1
|
||||
explain select * from t3 where c between -2 and -1 order by c;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 range c c 5 NULL 1 Using where
|
||||
# SELECT sum(<non-indexed vcol>) FROM tbl_name GROUP BY <non-indexed vcol>
|
||||
select sum(b) from t1 group by b;
|
||||
sum(b)
|
||||
NULL
|
||||
-3
|
||||
-2
|
||||
-2
|
||||
explain select sum(b) from t1 group by b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using temporary; Using filesort
|
||||
# SELECT sum(<indexed vcol>) FROM tbl_name GROUP BY <indexed vcol>
|
||||
select sum(c) from t1 group by c;
|
||||
sum(c)
|
||||
NULL
|
||||
-3
|
||||
-2
|
||||
-2
|
||||
explain select sum(c) from t1 group by c;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL c 5 NULL 5 Using index
|
||||
# SELECT sum(<non-indexed vcol>) FROM tbl_name GROUP BY <indexed vcol>
|
||||
select sum(b) from t1 group by c;
|
||||
sum(b)
|
||||
NULL
|
||||
-3
|
||||
-2
|
||||
-2
|
||||
explain select sum(b) from t1 group by c;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using temporary; Using filesort
|
||||
# SELECT sum(<indexed vcol>) FROM tbl_name GROUP BY <non-indexed vcol>
|
||||
select sum(c) from t1 group by b;
|
||||
sum(c)
|
||||
NULL
|
||||
-3
|
||||
-2
|
||||
-2
|
||||
explain select sum(c) from t1 group by b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using temporary; Using filesort
|
2942
mysql-test/suite/vcol/r/vcol_supported_sql_funcs_innodb.result
Normal file
2942
mysql-test/suite/vcol/r/vcol_supported_sql_funcs_innodb.result
Normal file
File diff suppressed because it is too large
Load Diff
2942
mysql-test/suite/vcol/r/vcol_supported_sql_funcs_myisam.result
Normal file
2942
mysql-test/suite/vcol/r/vcol_supported_sql_funcs_myisam.result
Normal file
File diff suppressed because it is too large
Load Diff
52
mysql-test/suite/vcol/r/vcol_syntax.result
Normal file
52
mysql-test/suite/vcol/r/vcol_syntax.result
Normal file
@ -0,0 +1,52 @@
|
||||
drop table if exists t1;
|
||||
set @OLD_SQL_MODE=@@SESSION.SQL_MODE;
|
||||
create table t1 (a int, b int generated always as (a+1));
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` int(11) AS (a+1) VIRTUAL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
create table t1 (a int, b int as (a+1) virtual);
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` int(11) AS (a+1) VIRTUAL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
create table t1 (a int, b int generated always as (a+1) persistent);
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` int(11) AS (a+1) PERSISTENT
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
set session sql_mode='ORACLE';
|
||||
create table t1 (a int, b int as (a+1));
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE "t1" (
|
||||
"a" int(11) DEFAULT NULL,
|
||||
"b" int(11) AS (a+1) VIRTUAL
|
||||
)
|
||||
drop table t1;
|
||||
create table t1 (a int, b int generated always as (a+1) virtual);
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE "t1" (
|
||||
"a" int(11) DEFAULT NULL,
|
||||
"b" int(11) AS (a+1) VIRTUAL
|
||||
)
|
||||
drop table t1;
|
||||
create table t1 (a int, b int as (a+1) persistent);
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE "t1" (
|
||||
"a" int(11) DEFAULT NULL,
|
||||
"b" int(11) AS (a+1) PERSISTENT
|
||||
)
|
||||
drop table t1;
|
||||
set session sql_mode=@OLD_SQL_MODE;
|
87
mysql-test/suite/vcol/r/vcol_trigger_sp_innodb.result
Normal file
87
mysql-test/suite/vcol/r/vcol_trigger_sp_innodb.result
Normal file
@ -0,0 +1,87 @@
|
||||
SET @@session.storage_engine = 'InnoDB';
|
||||
create table t1 (a int,
|
||||
b int as (a/10),
|
||||
c int as (a/10) persistent);
|
||||
create table t2 (a timestamp);
|
||||
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|
|
||||
set sql_warnings = 1;
|
||||
insert into t1 (a) values (200);
|
||||
select * from t1;
|
||||
a b c
|
||||
200 20 20
|
||||
select * from t2;
|
||||
a
|
||||
insert into t1 (a) values (10);
|
||||
select * from t1;
|
||||
a b c
|
||||
200 20 20
|
||||
100 10 10
|
||||
select * from t2;
|
||||
a
|
||||
insert into t1 (a) values (600);
|
||||
select * from t1;
|
||||
a b c
|
||||
200 20 20
|
||||
100 10 10
|
||||
500 50 50
|
||||
select * from t2;
|
||||
a
|
||||
select f1();
|
||||
f1()
|
||||
80
|
||||
set sql_warnings = 0;
|
||||
drop trigger trg1;
|
||||
drop trigger trg2;
|
||||
drop table t2;
|
||||
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|
|
||||
delete from t1;
|
||||
call p1();
|
||||
select * from t2;
|
||||
a b c
|
||||
100 10 10
|
||||
200 20 20
|
||||
select * from t1;
|
||||
a b c
|
||||
300 30 30
|
||||
drop table t1,t2;
|
||||
drop procedure p1;
|
87
mysql-test/suite/vcol/r/vcol_trigger_sp_myisam.result
Normal file
87
mysql-test/suite/vcol/r/vcol_trigger_sp_myisam.result
Normal file
@ -0,0 +1,87 @@
|
||||
SET @@session.storage_engine = 'MyISAM';
|
||||
create table t1 (a int,
|
||||
b int as (a/10),
|
||||
c int as (a/10) persistent);
|
||||
create table t2 (a timestamp);
|
||||
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|
|
||||
set sql_warnings = 1;
|
||||
insert into t1 (a) values (200);
|
||||
select * from t1;
|
||||
a b c
|
||||
200 20 20
|
||||
select * from t2;
|
||||
a
|
||||
insert into t1 (a) values (10);
|
||||
select * from t1;
|
||||
a b c
|
||||
200 20 20
|
||||
100 10 10
|
||||
select * from t2;
|
||||
a
|
||||
insert into t1 (a) values (600);
|
||||
select * from t1;
|
||||
a b c
|
||||
200 20 20
|
||||
100 10 10
|
||||
500 50 50
|
||||
select * from t2;
|
||||
a
|
||||
select f1();
|
||||
f1()
|
||||
80
|
||||
set sql_warnings = 0;
|
||||
drop trigger trg1;
|
||||
drop trigger trg2;
|
||||
drop table t2;
|
||||
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|
|
||||
delete from t1;
|
||||
call p1();
|
||||
select * from t2;
|
||||
a b c
|
||||
100 10 10
|
||||
200 20 20
|
||||
select * from t1;
|
||||
a b c
|
||||
300 30 30
|
||||
drop table t1,t2;
|
||||
drop procedure p1;
|
276
mysql-test/suite/vcol/r/vcol_view_innodb.result
Normal file
276
mysql-test/suite/vcol/r/vcol_view_innodb.result
Normal file
@ -0,0 +1,276 @@
|
||||
SET @@session.storage_engine = 'InnoDB';
|
||||
create table t1 (a int not null,
|
||||
b int as (-a),
|
||||
c int as (-a) persistent);
|
||||
insert into t1 (a) values (1), (1), (2), (2), (3);
|
||||
create view v1 (d,e) as select abs(b), abs(c) from t1;
|
||||
select d,e from v1;
|
||||
d e
|
||||
1 1
|
||||
1 1
|
||||
2 2
|
||||
2 2
|
||||
3 3
|
||||
select is_updatable from information_schema.views where table_name='v1';
|
||||
is_updatable
|
||||
NO
|
||||
explain extended select d,e from v1;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00
|
||||
Warnings:
|
||||
Note 1003 select abs(`test`.`t1`.`b`) AS `d`,abs(`test`.`t1`.`c`) AS `e` from `test`.`t1`
|
||||
create algorithm=temptable view v2 (d,e) as select abs(b), abs(c) from t1;
|
||||
show create view v2;
|
||||
View Create View character_set_client collation_connection
|
||||
v2 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select abs(`t1`.`b`) AS `d`,abs(`t1`.`c`) AS `e` from `t1` latin1 latin1_swedish_ci
|
||||
select d,e from v2;
|
||||
d e
|
||||
1 1
|
||||
1 1
|
||||
2 2
|
||||
2 2
|
||||
3 3
|
||||
explain extended select d,e from v2;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 5 100.00
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 5 100.00
|
||||
Warnings:
|
||||
Note 1003 select `v2`.`d` AS `d`,`v2`.`e` AS `e` from `test`.`v2`
|
||||
create view v3 (d,e) as select d*2, e*2 from v1;
|
||||
select * from v3;
|
||||
d e
|
||||
2 2
|
||||
2 2
|
||||
4 4
|
||||
4 4
|
||||
6 6
|
||||
explain extended select * from v3;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00
|
||||
Warnings:
|
||||
Note 1003 select (abs(`test`.`t1`.`b`) * 2) AS `d`,(abs(`test`.`t1`.`c`) * 2) AS `e` from `test`.`t1`
|
||||
drop view v1,v2,v3;
|
||||
drop table t1;
|
||||
create table t1 (a int not null,
|
||||
b int as (-a),
|
||||
c int as (-a) persistent);
|
||||
insert into t1 (a) values (1), (2), (3), (1), (2), (3);
|
||||
create view v1 as select distinct b from t1;
|
||||
select * from v1;
|
||||
b
|
||||
-1
|
||||
-2
|
||||
-3
|
||||
explain select * from v1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 6 Using temporary
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
3 -3 -3
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
3 -3 -3
|
||||
drop view v1;
|
||||
create view v1 as select distinct c from t1;
|
||||
select * from v1;
|
||||
c
|
||||
-1
|
||||
-2
|
||||
-3
|
||||
explain select * from v1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 6 Using temporary
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
3 -3 -3
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
3 -3 -3
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
create table t1 (a int not null,
|
||||
b int as (-a),
|
||||
c int as (-a) persistent);
|
||||
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;
|
||||
b+1
|
||||
0
|
||||
-1
|
||||
explain select * from v1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 4 Using filesort
|
||||
drop view v1;
|
||||
create view v1 as select c+1 from t1 order by 1 desc limit 2;
|
||||
select * from v1;
|
||||
c+1
|
||||
0
|
||||
-1
|
||||
explain select * from v1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 4 Using filesort
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
create table t1 (a int,
|
||||
b int,
|
||||
c int as (-a),
|
||||
d int as (-a) persistent,
|
||||
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;
|
||||
update v1 set a=a+e;
|
||||
select * from v1;
|
||||
a e f g
|
||||
13 3 -12 -12
|
||||
24 4 -23 -23
|
||||
35 5 -34 -34
|
||||
46 6 -45 -45
|
||||
61 11 -60 -60
|
||||
select * from t1;
|
||||
a b c d
|
||||
13 2 -13 -13
|
||||
24 3 -24 -24
|
||||
35 4 -35 -35
|
||||
46 5 -46 -46
|
||||
61 10 -61 -61
|
||||
delete from v1;
|
||||
select * from v1;
|
||||
a e f g
|
||||
select * from t1;
|
||||
a b c d
|
||||
insert into v1 (a,e) values (60,15);
|
||||
ERROR HY000: The target table v1 of the INSERT is not insertable-into
|
||||
drop table t1;
|
||||
drop view v1;
|
||||
create table t1 (a int,
|
||||
b int as (-a),
|
||||
c int as (-a) persistent,
|
||||
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;
|
||||
select t1.a, v1.x, v1.y, v1.z from t1 left join v1 on (t1.b= v1.y);
|
||||
a x y z
|
||||
1 NULL NULL NULL
|
||||
2 2 -2 -2
|
||||
3 3 -3 -3
|
||||
drop view v1;
|
||||
create view v1 (x,y,z) as select a,b,c from t1 where c < -1;
|
||||
select t1.a, v1.x, v1.y, v1.z from t1 left join v1 on (t1.c= v1.z);
|
||||
a x y z
|
||||
1 NULL NULL NULL
|
||||
2 2 -2 -2
|
||||
3 3 -3 -3
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
create table t1 (a1 int,
|
||||
b1 int as (-a1),
|
||||
c1 int as (-a1) persistent);
|
||||
create table t2 (a2 int,
|
||||
b2 int as (-a2),
|
||||
c2 int as (-a2) persistent);
|
||||
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;
|
||||
select * from v1;
|
||||
a1 b1 c1 a2 b2 c2
|
||||
1 -1 -1 2 -2 -2
|
||||
2 -2 -2 2 -2 -2
|
||||
1 -1 -1 3 -3 -3
|
||||
2 -2 -2 3 -3 -3
|
||||
1 -1 -1 2 -2 -2
|
||||
2 -2 -2 2 -2 -2
|
||||
1 -1 -1 3 -3 -3
|
||||
2 -2 -2 3 -3 -3
|
||||
drop view v1;
|
||||
drop table t1, t2;
|
||||
create table t1 (a int,
|
||||
b int as (-a),
|
||||
c int as (-a) persistent);
|
||||
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;
|
||||
View Create View character_set_client collation_connection
|
||||
v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `t2`.`a` AS `a`,`t2`.`b` AS `b`,`t2`.`c` AS `c` from `t2` where `t2`.`b` in (select `v1`.`b` AS `b` from `v1`) latin1 latin1_swedish_ci
|
||||
drop view v2, v1;
|
||||
drop table t1, t2;
|
||||
create table t1 (a int,
|
||||
b int as (-a),
|
||||
c int as (-a) persistent);
|
||||
insert into t1 (a) values (1),(1),(2),(2),(3),(3);
|
||||
create view v1 as select b from t1;
|
||||
select distinct b from v1;
|
||||
b
|
||||
-1
|
||||
-2
|
||||
-3
|
||||
select distinct b from v1 limit 2;
|
||||
b
|
||||
-1
|
||||
-2
|
||||
select distinct b from t1 limit 2;
|
||||
b
|
||||
-1
|
||||
-2
|
||||
prepare stmt1 from "select distinct b from v1 limit 2";
|
||||
execute stmt1;
|
||||
b
|
||||
-1
|
||||
-2
|
||||
execute stmt1;
|
||||
b
|
||||
-1
|
||||
-2
|
||||
deallocate prepare stmt1;
|
||||
drop view v1;
|
||||
create view v1 as select c from t1;
|
||||
select distinct c from v1;
|
||||
c
|
||||
-1
|
||||
-2
|
||||
-3
|
||||
select distinct c from v1 limit 2;
|
||||
c
|
||||
-1
|
||||
-2
|
||||
select distinct c from t1 limit 2;
|
||||
c
|
||||
-1
|
||||
-2
|
||||
prepare stmt1 from "select distinct c from v1 limit 2";
|
||||
execute stmt1;
|
||||
c
|
||||
-1
|
||||
-2
|
||||
execute stmt1;
|
||||
c
|
||||
-1
|
||||
-2
|
||||
deallocate prepare stmt1;
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
create table t1 (a int,
|
||||
b int as (-a),
|
||||
c int as (-a) persistent);
|
||||
create view v1 as select * from t1 where b > -2 && c >-2 with check option;
|
||||
insert into v1 (a) values (1);
|
||||
insert into v1 (a) values (3);
|
||||
ERROR HY000: CHECK OPTION failed 'test.v1'
|
||||
insert ignore into v1 (a) values (2),(3),(0);
|
||||
Warnings:
|
||||
Error 1369 CHECK OPTION failed 'test.v1'
|
||||
Error 1369 CHECK OPTION failed 'test.v1'
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
0 0 0
|
||||
drop view v1;
|
||||
drop table t1;
|
276
mysql-test/suite/vcol/r/vcol_view_myisam.result
Normal file
276
mysql-test/suite/vcol/r/vcol_view_myisam.result
Normal file
@ -0,0 +1,276 @@
|
||||
SET @@session.storage_engine = 'MyISAM';
|
||||
create table t1 (a int not null,
|
||||
b int as (-a),
|
||||
c int as (-a) persistent);
|
||||
insert into t1 (a) values (1), (1), (2), (2), (3);
|
||||
create view v1 (d,e) as select abs(b), abs(c) from t1;
|
||||
select d,e from v1;
|
||||
d e
|
||||
1 1
|
||||
1 1
|
||||
2 2
|
||||
2 2
|
||||
3 3
|
||||
select is_updatable from information_schema.views where table_name='v1';
|
||||
is_updatable
|
||||
NO
|
||||
explain extended select d,e from v1;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00
|
||||
Warnings:
|
||||
Note 1003 select abs(`test`.`t1`.`b`) AS `d`,abs(`test`.`t1`.`c`) AS `e` from `test`.`t1`
|
||||
create algorithm=temptable view v2 (d,e) as select abs(b), abs(c) from t1;
|
||||
show create view v2;
|
||||
View Create View character_set_client collation_connection
|
||||
v2 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select abs(`t1`.`b`) AS `d`,abs(`t1`.`c`) AS `e` from `t1` latin1 latin1_swedish_ci
|
||||
select d,e from v2;
|
||||
d e
|
||||
1 1
|
||||
1 1
|
||||
2 2
|
||||
2 2
|
||||
3 3
|
||||
explain extended select d,e from v2;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 5 100.00
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 5 100.00
|
||||
Warnings:
|
||||
Note 1003 select `v2`.`d` AS `d`,`v2`.`e` AS `e` from `test`.`v2`
|
||||
create view v3 (d,e) as select d*2, e*2 from v1;
|
||||
select * from v3;
|
||||
d e
|
||||
2 2
|
||||
2 2
|
||||
4 4
|
||||
4 4
|
||||
6 6
|
||||
explain extended select * from v3;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00
|
||||
Warnings:
|
||||
Note 1003 select (abs(`test`.`t1`.`b`) * 2) AS `d`,(abs(`test`.`t1`.`c`) * 2) AS `e` from `test`.`t1`
|
||||
drop view v1,v2,v3;
|
||||
drop table t1;
|
||||
create table t1 (a int not null,
|
||||
b int as (-a),
|
||||
c int as (-a) persistent);
|
||||
insert into t1 (a) values (1), (2), (3), (1), (2), (3);
|
||||
create view v1 as select distinct b from t1;
|
||||
select * from v1;
|
||||
b
|
||||
-1
|
||||
-2
|
||||
-3
|
||||
explain select * from v1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 6 Using temporary
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
3 -3 -3
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
3 -3 -3
|
||||
drop view v1;
|
||||
create view v1 as select distinct c from t1;
|
||||
select * from v1;
|
||||
c
|
||||
-1
|
||||
-2
|
||||
-3
|
||||
explain select * from v1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 6 Using temporary
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
3 -3 -3
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
3 -3 -3
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
create table t1 (a int not null,
|
||||
b int as (-a),
|
||||
c int as (-a) persistent);
|
||||
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;
|
||||
b+1
|
||||
0
|
||||
-1
|
||||
explain select * from v1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 4 Using filesort
|
||||
drop view v1;
|
||||
create view v1 as select c+1 from t1 order by 1 desc limit 2;
|
||||
select * from v1;
|
||||
c+1
|
||||
0
|
||||
-1
|
||||
explain select * from v1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 4 Using filesort
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
create table t1 (a int,
|
||||
b int,
|
||||
c int as (-a),
|
||||
d int as (-a) persistent,
|
||||
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;
|
||||
update v1 set a=a+e;
|
||||
select * from v1;
|
||||
a e f g
|
||||
13 3 -12 -12
|
||||
24 4 -23 -23
|
||||
35 5 -34 -34
|
||||
46 6 -45 -45
|
||||
61 11 -60 -60
|
||||
select * from t1;
|
||||
a b c d
|
||||
13 2 -13 -13
|
||||
24 3 -24 -24
|
||||
35 4 -35 -35
|
||||
46 5 -46 -46
|
||||
61 10 -61 -61
|
||||
delete from v1;
|
||||
select * from v1;
|
||||
a e f g
|
||||
select * from t1;
|
||||
a b c d
|
||||
insert into v1 (a,e) values (60,15);
|
||||
ERROR HY000: The target table v1 of the INSERT is not insertable-into
|
||||
drop table t1;
|
||||
drop view v1;
|
||||
create table t1 (a int,
|
||||
b int as (-a),
|
||||
c int as (-a) persistent,
|
||||
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;
|
||||
select t1.a, v1.x, v1.y, v1.z from t1 left join v1 on (t1.b= v1.y);
|
||||
a x y z
|
||||
1 NULL NULL NULL
|
||||
2 2 -2 -2
|
||||
3 3 -3 -3
|
||||
drop view v1;
|
||||
create view v1 (x,y,z) as select a,b,c from t1 where c < -1;
|
||||
select t1.a, v1.x, v1.y, v1.z from t1 left join v1 on (t1.c= v1.z);
|
||||
a x y z
|
||||
1 NULL NULL NULL
|
||||
2 2 -2 -2
|
||||
3 3 -3 -3
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
create table t1 (a1 int,
|
||||
b1 int as (-a1),
|
||||
c1 int as (-a1) persistent);
|
||||
create table t2 (a2 int,
|
||||
b2 int as (-a2),
|
||||
c2 int as (-a2) persistent);
|
||||
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;
|
||||
select * from v1;
|
||||
a1 b1 c1 a2 b2 c2
|
||||
1 -1 -1 2 -2 -2
|
||||
2 -2 -2 2 -2 -2
|
||||
1 -1 -1 3 -3 -3
|
||||
2 -2 -2 3 -3 -3
|
||||
1 -1 -1 2 -2 -2
|
||||
2 -2 -2 2 -2 -2
|
||||
1 -1 -1 3 -3 -3
|
||||
2 -2 -2 3 -3 -3
|
||||
drop view v1;
|
||||
drop table t1, t2;
|
||||
create table t1 (a int,
|
||||
b int as (-a),
|
||||
c int as (-a) persistent);
|
||||
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;
|
||||
View Create View character_set_client collation_connection
|
||||
v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `t2`.`a` AS `a`,`t2`.`b` AS `b`,`t2`.`c` AS `c` from `t2` where `t2`.`b` in (select `v1`.`b` AS `b` from `v1`) latin1 latin1_swedish_ci
|
||||
drop view v2, v1;
|
||||
drop table t1, t2;
|
||||
create table t1 (a int,
|
||||
b int as (-a),
|
||||
c int as (-a) persistent);
|
||||
insert into t1 (a) values (1),(1),(2),(2),(3),(3);
|
||||
create view v1 as select b from t1;
|
||||
select distinct b from v1;
|
||||
b
|
||||
-1
|
||||
-2
|
||||
-3
|
||||
select distinct b from v1 limit 2;
|
||||
b
|
||||
-1
|
||||
-2
|
||||
select distinct b from t1 limit 2;
|
||||
b
|
||||
-1
|
||||
-2
|
||||
prepare stmt1 from "select distinct b from v1 limit 2";
|
||||
execute stmt1;
|
||||
b
|
||||
-1
|
||||
-2
|
||||
execute stmt1;
|
||||
b
|
||||
-1
|
||||
-2
|
||||
deallocate prepare stmt1;
|
||||
drop view v1;
|
||||
create view v1 as select c from t1;
|
||||
select distinct c from v1;
|
||||
c
|
||||
-1
|
||||
-2
|
||||
-3
|
||||
select distinct c from v1 limit 2;
|
||||
c
|
||||
-1
|
||||
-2
|
||||
select distinct c from t1 limit 2;
|
||||
c
|
||||
-1
|
||||
-2
|
||||
prepare stmt1 from "select distinct c from v1 limit 2";
|
||||
execute stmt1;
|
||||
c
|
||||
-1
|
||||
-2
|
||||
execute stmt1;
|
||||
c
|
||||
-1
|
||||
-2
|
||||
deallocate prepare stmt1;
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
create table t1 (a int,
|
||||
b int as (-a),
|
||||
c int as (-a) persistent);
|
||||
create view v1 as select * from t1 where b > -2 && c >-2 with check option;
|
||||
insert into v1 (a) values (1);
|
||||
insert into v1 (a) values (3);
|
||||
ERROR HY000: CHECK OPTION failed 'test.v1'
|
||||
insert ignore into v1 (a) values (2),(3),(0);
|
||||
Warnings:
|
||||
Error 1369 CHECK OPTION failed 'test.v1'
|
||||
Error 1369 CHECK OPTION failed 'test.v1'
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
0 0 0
|
||||
drop view v1;
|
||||
drop table t1;
|
69
mysql-test/suite/vcol/t/rpl_vcol.test
Normal file
69
mysql-test/suite/vcol/t/rpl_vcol.test
Normal file
@ -0,0 +1,69 @@
|
||||
################################################################################
|
||||
# t/vcol_rpl.test #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Test replication of tables with virtual columns. #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-09-04
|
||||
# Change Author: Oleksandr Byelkin (Monty program Ab)
|
||||
# Date: 2009-03-24
|
||||
# Change: Syntax changed
|
||||
################################################################################
|
||||
|
||||
#
|
||||
# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
|
||||
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
|
||||
# THE SOURCED FILES ONLY.
|
||||
#
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# General not engine specific settings and requirements
|
||||
--source suite/vcol/inc/vcol_init_vars.pre
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
--source include/have_innodb.inc
|
||||
SET @@session.storage_engine = 'InnoDB';
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
--source include/master-slave.inc
|
||||
|
||||
connection master;
|
||||
create table t1 (a int, b int as (a+1));
|
||||
show create table t1;
|
||||
insert into t1 values (1,default);
|
||||
insert into t1 values (2,default);
|
||||
select * from t1;
|
||||
save_master_pos;
|
||||
|
||||
connection slave;
|
||||
sync_with_master;
|
||||
select * from t1;
|
||||
|
||||
connection master;
|
||||
drop table t1;
|
||||
save_master_pos;
|
||||
|
||||
connection slave;
|
||||
sync_with_master;
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
49
mysql-test/suite/vcol/t/vcol_archive.test
Normal file
49
mysql-test/suite/vcol/t/vcol_archive.test
Normal file
@ -0,0 +1,49 @@
|
||||
################################################################################
|
||||
# t/vcol_archive.test #
|
||||
# #
|
||||
# Purpose: #
|
||||
# ARCHIVE branch #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-09-02 #
|
||||
# Change Author: #
|
||||
# Change Date: #
|
||||
# Change: #
|
||||
################################################################################
|
||||
|
||||
#
|
||||
# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
|
||||
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
|
||||
# THE SOURCED FILES ONLY.
|
||||
#
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# General not engine specific settings and requirements
|
||||
--source suite/vcol/inc/vcol_init_vars.pre
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
--source include/have_archive.inc
|
||||
SET @@session.storage_engine = 'archive';
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
--source suite/vcol/inc/vcol_unsupported_storage_engines.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
49
mysql-test/suite/vcol/t/vcol_blackhole.test
Normal file
49
mysql-test/suite/vcol/t/vcol_blackhole.test
Normal file
@ -0,0 +1,49 @@
|
||||
################################################################################
|
||||
# t/vcol_blackhole.test #
|
||||
# #
|
||||
# Purpose: #
|
||||
# BLACKHOLE branch #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-09-02 #
|
||||
# Change Author: #
|
||||
# Change Date: #
|
||||
# Change: #
|
||||
################################################################################
|
||||
|
||||
#
|
||||
# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
|
||||
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
|
||||
# THE SOURCED FILES ONLY.
|
||||
#
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# General not engine specific settings and requirements
|
||||
--source suite/vcol/inc/vcol_init_vars.pre
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
--source include/have_blackhole.inc
|
||||
SET @@session.storage_engine = 'blackhole';
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
--source suite/vcol/inc/vcol_unsupported_storage_engines.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
52
mysql-test/suite/vcol/t/vcol_blocked_sql_funcs_innodb.test
Normal file
52
mysql-test/suite/vcol/t/vcol_blocked_sql_funcs_innodb.test
Normal file
@ -0,0 +1,52 @@
|
||||
################################################################################
|
||||
# t/vcol_supported_sql_funcs.test #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Test SQL functions not allowed for virtual columns #
|
||||
# InnoDB branch #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-08-31 #
|
||||
# Change Author: #
|
||||
# Change Date: #
|
||||
# Change: #
|
||||
################################################################################
|
||||
|
||||
#
|
||||
# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
|
||||
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
|
||||
# THE SOURCED FILES ONLY.
|
||||
#
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# General not engine specific settings and requirements
|
||||
--source suite/vcol/inc/vcol_init_vars.pre
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
--source include/have_innodb.inc
|
||||
eval SET @@session.storage_engine = 'InnoDB';
|
||||
|
||||
let $skip_full_text_checks = 1;
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
--source suite/vcol/inc/vcol_blocked_sql_funcs_main.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
49
mysql-test/suite/vcol/t/vcol_blocked_sql_funcs_myisam.test
Normal file
49
mysql-test/suite/vcol/t/vcol_blocked_sql_funcs_myisam.test
Normal file
@ -0,0 +1,49 @@
|
||||
################################################################################
|
||||
# t/vcol_supported_sql_funcs.test #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Test SQL functions not allowed for virtual columns #
|
||||
# MyISAM branch #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-08-31 #
|
||||
# Change Author: #
|
||||
# Change Date: #
|
||||
# Change: #
|
||||
################################################################################
|
||||
|
||||
#
|
||||
# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
|
||||
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
|
||||
# THE SOURCED FILES ONLY.
|
||||
#
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# General not engine specific settings and requirements
|
||||
--source suite/vcol/inc/vcol_init_vars.pre
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
eval SET @@session.storage_engine = 'MyISAM';
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
--source suite/vcol/inc/vcol_blocked_sql_funcs_main.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
51
mysql-test/suite/vcol/t/vcol_column_def_options_innodb.test
Normal file
51
mysql-test/suite/vcol/t/vcol_column_def_options_innodb.test
Normal file
@ -0,0 +1,51 @@
|
||||
################################################################################
|
||||
# t/vcol_column_def_options_innodb.test #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Testing different optional parameters of virtual columns. #
|
||||
# #
|
||||
# InnoDB branch #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-09-02 #
|
||||
# Change Author: #
|
||||
# Change Date: #
|
||||
# Change: #
|
||||
################################################################################
|
||||
|
||||
#
|
||||
# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
|
||||
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
|
||||
# THE SOURCED FILES ONLY.
|
||||
#
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# General not engine specific settings and requirements
|
||||
--source suite/vcol/inc/vcol_init_vars.pre
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
--source include/have_innodb.inc
|
||||
eval SET @@session.storage_engine = 'InnoDB';
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
--source suite/vcol/inc/vcol_column_def_options.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
50
mysql-test/suite/vcol/t/vcol_column_def_options_myisam.test
Normal file
50
mysql-test/suite/vcol/t/vcol_column_def_options_myisam.test
Normal file
@ -0,0 +1,50 @@
|
||||
################################################################################
|
||||
# t/vcol_column_def_options_myisam.test #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Testing different optional parameters of virtual columns. #
|
||||
# #
|
||||
# MyISAM branch #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-09-02 #
|
||||
# Change Author: #
|
||||
# Change Date: #
|
||||
# Change: #
|
||||
################################################################################
|
||||
|
||||
#
|
||||
# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
|
||||
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
|
||||
# THE SOURCED FILES ONLY.
|
||||
#
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# General not engine specific settings and requirements
|
||||
--source suite/vcol/inc/vcol_init_vars.pre
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
eval SET @@session.storage_engine = 'MyISAM';
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
--source suite/vcol/inc/vcol_column_def_options.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
54
mysql-test/suite/vcol/t/vcol_csv.test
Normal file
54
mysql-test/suite/vcol/t/vcol_csv.test
Normal file
@ -0,0 +1,54 @@
|
||||
################################################################################
|
||||
# t/vcol_csv.test #
|
||||
# #
|
||||
# Purpose: #
|
||||
# CSV branch #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-09-02 #
|
||||
# Change Author: Oleksandr Byelkin (Monty program Ab)
|
||||
# Date: 2009-03-24
|
||||
# Change: Syntax changed
|
||||
################################################################################
|
||||
|
||||
#
|
||||
# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
|
||||
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
|
||||
# THE SOURCED FILES ONLY.
|
||||
#
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# General not engine specific settings and requirements
|
||||
--source suite/vcol/inc/vcol_init_vars.pre
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
--source include/have_csv.inc
|
||||
SET @@session.storage_engine = 'CSV';
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
--error ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN
|
||||
create table t1 (a int, b int as (a+1));
|
||||
create table t1 (a int not null);
|
||||
--error ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN
|
||||
alter table t1 add column b int as (a+1);
|
||||
drop table t1;
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
51
mysql-test/suite/vcol/t/vcol_handler_innodb.test
Normal file
51
mysql-test/suite/vcol/t/vcol_handler_innodb.test
Normal file
@ -0,0 +1,51 @@
|
||||
################################################################################
|
||||
# t/vcol_handler_innodb.test #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Testing HANDLER.
|
||||
# #
|
||||
# InnoDB branch #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-09-04 #
|
||||
# Change Author: #
|
||||
# Change Date: #
|
||||
# Change: #
|
||||
################################################################################
|
||||
|
||||
#
|
||||
# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
|
||||
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
|
||||
# THE SOURCED FILES ONLY.
|
||||
#
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# General not engine specific settings and requirements
|
||||
--source suite/vcol/inc/vcol_init_vars.pre
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
--source include/have_innodb.inc
|
||||
eval SET @@session.storage_engine = 'InnoDB';
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
--source suite/vcol/inc/vcol_handler.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
50
mysql-test/suite/vcol/t/vcol_handler_myisam.test
Normal file
50
mysql-test/suite/vcol/t/vcol_handler_myisam.test
Normal file
@ -0,0 +1,50 @@
|
||||
################################################################################
|
||||
# t/vcol_handler_myisam.test #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Testing HANDLER.
|
||||
# #
|
||||
# MyISAM branch #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-09-04 #
|
||||
# Change Author: #
|
||||
# Change Date: #
|
||||
# Change: #
|
||||
################################################################################
|
||||
|
||||
#
|
||||
# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
|
||||
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
|
||||
# THE SOURCED FILES ONLY.
|
||||
#
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# General not engine specific settings and requirements
|
||||
--source suite/vcol/inc/vcol_init_vars.pre
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
eval SET @@session.storage_engine = 'MyISAM';
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
--source suite/vcol/inc/vcol_handler.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
51
mysql-test/suite/vcol/t/vcol_ins_upd_innodb.test
Normal file
51
mysql-test/suite/vcol/t/vcol_ins_upd_innodb.test
Normal file
@ -0,0 +1,51 @@
|
||||
################################################################################
|
||||
# t/vcol_ins_upd_innodb.test #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Testing DDL operations such as INSERT, UPDATE, REPLACE and DELETE. #
|
||||
# #
|
||||
# InnoDB branch #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-09-04 #
|
||||
# Change Author: #
|
||||
# Change Date: #
|
||||
# Change: #
|
||||
################################################################################
|
||||
|
||||
#
|
||||
# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
|
||||
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
|
||||
# THE SOURCED FILES ONLY.
|
||||
#
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# General not engine specific settings and requirements
|
||||
--source suite/vcol/inc/vcol_init_vars.pre
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
--source include/have_innodb.inc
|
||||
eval SET @@session.storage_engine = 'InnoDB';
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
--source suite/vcol/inc/vcol_ins_upd.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
50
mysql-test/suite/vcol/t/vcol_ins_upd_myisam.test
Normal file
50
mysql-test/suite/vcol/t/vcol_ins_upd_myisam.test
Normal file
@ -0,0 +1,50 @@
|
||||
################################################################################
|
||||
# t/vcol_ins_upd_myisam.test #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Testing DDL operations such as INSERT, UPDATE, REPLACE and DELETE. #
|
||||
# #
|
||||
# MyISAM branch #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-09-04 #
|
||||
# Change Author: #
|
||||
# Change Date: #
|
||||
# Change: #
|
||||
################################################################################
|
||||
|
||||
#
|
||||
# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
|
||||
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
|
||||
# THE SOURCED FILES ONLY.
|
||||
#
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# General not engine specific settings and requirements
|
||||
--source suite/vcol/inc/vcol_init_vars.pre
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
eval SET @@session.storage_engine = 'MyISAM';
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
--source suite/vcol/inc/vcol_ins_upd.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
52
mysql-test/suite/vcol/t/vcol_keys_innodb.test
Normal file
52
mysql-test/suite/vcol/t/vcol_keys_innodb.test
Normal file
@ -0,0 +1,52 @@
|
||||
################################################################################
|
||||
# t/vcol_keys_innodb.test #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Testing keys, indexes defined upon virtual columns. #
|
||||
# #
|
||||
# InnoDB branch #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-09-04 #
|
||||
# Change Author: #
|
||||
# Change Date: #
|
||||
# Change: #
|
||||
################################################################################
|
||||
|
||||
#
|
||||
# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
|
||||
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
|
||||
# THE SOURCED FILES ONLY.
|
||||
#
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# General not engine specific settings and requirements
|
||||
--source suite/vcol/inc/vcol_init_vars.pre
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
--source include/have_innodb.inc
|
||||
eval SET @@session.storage_engine = 'InnoDB';
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
let $skip_spatial_index_check = 1;
|
||||
--source suite/vcol/inc/vcol_keys.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
50
mysql-test/suite/vcol/t/vcol_keys_myisam.test
Normal file
50
mysql-test/suite/vcol/t/vcol_keys_myisam.test
Normal file
@ -0,0 +1,50 @@
|
||||
################################################################################
|
||||
# t/vcol_keys_myisam.test #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Testing keys, indexes defined upon virtual columns. #
|
||||
# #
|
||||
# MyISAM branch #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-09-04 #
|
||||
# Change Author: #
|
||||
# Change Date: #
|
||||
# Change: #
|
||||
################################################################################
|
||||
|
||||
#
|
||||
# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
|
||||
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
|
||||
# THE SOURCED FILES ONLY.
|
||||
#
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# General not engine specific settings and requirements
|
||||
--source suite/vcol/inc/vcol_init_vars.pre
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
eval SET @@session.storage_engine = 'MyISAM';
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
--source suite/vcol/inc/vcol_keys.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
48
mysql-test/suite/vcol/t/vcol_memory.test
Normal file
48
mysql-test/suite/vcol/t/vcol_memory.test
Normal file
@ -0,0 +1,48 @@
|
||||
################################################################################
|
||||
# t/vcol_memory.test #
|
||||
# #
|
||||
# Purpose: #
|
||||
# MEMORY branch #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-09-02 #
|
||||
# Change Author: #
|
||||
# Change Date: #
|
||||
# Change: #
|
||||
################################################################################
|
||||
|
||||
#
|
||||
# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
|
||||
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
|
||||
# THE SOURCED FILES ONLY.
|
||||
#
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# General not engine specific settings and requirements
|
||||
--source suite/vcol/inc/vcol_init_vars.pre
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
SET @@session.storage_engine = 'memory';
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
--source suite/vcol/inc/vcol_unsupported_storage_engines.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
57
mysql-test/suite/vcol/t/vcol_merge.test
Normal file
57
mysql-test/suite/vcol/t/vcol_merge.test
Normal file
@ -0,0 +1,57 @@
|
||||
################################################################################
|
||||
# t/vcol_merge.test #
|
||||
# #
|
||||
# Purpose: #
|
||||
# MERGE branch #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-09-03 #
|
||||
# Change Author: Oleksandr Byelkin (Monty program Ab)
|
||||
# Date: 2009-03-24
|
||||
# Change: Syntax changed
|
||||
################################################################################
|
||||
|
||||
#
|
||||
# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
|
||||
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
|
||||
# THE SOURCED FILES ONLY.
|
||||
#
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# General not engine specific settings and requirements
|
||||
--source suite/vcol/inc/vcol_init_vars.pre
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
--disable_warnings
|
||||
drop table if exists t1, t2, t3;
|
||||
--enable_warnings
|
||||
|
||||
create table t1 (a int, b int as (a % 10));
|
||||
create table t2 (a int, b int as (a % 10));
|
||||
insert into t1 values (1,default);
|
||||
insert into t2 values (2,default);
|
||||
--error ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN
|
||||
create table t3 (a int, b int as (a % 10)) engine=MERGE UNION=(t1,t2);
|
||||
drop table t1,t2;
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
53
mysql-test/suite/vcol/t/vcol_non_stored_columns_innodb.test
Normal file
53
mysql-test/suite/vcol/t/vcol_non_stored_columns_innodb.test
Normal file
@ -0,0 +1,53 @@
|
||||
################################################################################
|
||||
# t/vcol_non_stored_columns_innodb.test #
|
||||
# #
|
||||
# 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. #
|
||||
# #
|
||||
# InnoDB branch #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-09-04 #
|
||||
# Change Author: #
|
||||
# Change Date: #
|
||||
# Change: #
|
||||
################################################################################
|
||||
|
||||
#
|
||||
# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
|
||||
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
|
||||
# THE SOURCED FILES ONLY.
|
||||
#
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# General not engine specific settings and requirements
|
||||
--source suite/vcol/inc/vcol_init_vars.pre
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
--source include/have_innodb.inc
|
||||
eval SET @@session.storage_engine = 'InnoDB';
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
--source suite/vcol/inc/vcol_non_stored_columns.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
52
mysql-test/suite/vcol/t/vcol_non_stored_columns_myisam.test
Normal file
52
mysql-test/suite/vcol/t/vcol_non_stored_columns_myisam.test
Normal file
@ -0,0 +1,52 @@
|
||||
################################################################################
|
||||
# t/vcol_non_stored_columns_myisam.test #
|
||||
# #
|
||||
# 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. #
|
||||
# #
|
||||
# MyISAM branch #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-09-04 #
|
||||
# Change Author: #
|
||||
# Change Date: #
|
||||
# Change: #
|
||||
################################################################################
|
||||
|
||||
#
|
||||
# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
|
||||
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
|
||||
# THE SOURCED FILES ONLY.
|
||||
#
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# General not engine specific settings and requirements
|
||||
--source suite/vcol/inc/vcol_init_vars.pre
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
eval SET @@session.storage_engine = 'MyISAM';
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
--source suite/vcol/inc/vcol_non_stored_columns.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
52
mysql-test/suite/vcol/t/vcol_partition_innodb.test
Normal file
52
mysql-test/suite/vcol/t/vcol_partition_innodb.test
Normal file
@ -0,0 +1,52 @@
|
||||
################################################################################
|
||||
# t/vcol_partition_innodb.test #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Testing partitioning tables with virtual columns. #
|
||||
# #
|
||||
# InnoDB branch #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-09-04 #
|
||||
# Change Author: #
|
||||
# Change Date: #
|
||||
# Change: #
|
||||
################################################################################
|
||||
--source include/have_partition.inc
|
||||
|
||||
#
|
||||
# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
|
||||
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
|
||||
# THE SOURCED FILES ONLY.
|
||||
#
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# General not engine specific settings and requirements
|
||||
--source suite/vcol/inc/vcol_init_vars.pre
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
--source include/have_innodb.inc
|
||||
eval SET @@session.storage_engine = 'InnoDB';
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
--source suite/vcol/inc/vcol_partition.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
51
mysql-test/suite/vcol/t/vcol_partition_myisam.test
Normal file
51
mysql-test/suite/vcol/t/vcol_partition_myisam.test
Normal file
@ -0,0 +1,51 @@
|
||||
################################################################################
|
||||
# t/vcol_partition_myisam.test #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Testing partitioning tables with virtual columns. #
|
||||
# #
|
||||
# MyISAM branch #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-09-04 #
|
||||
# Change Author: #
|
||||
# Change Date: #
|
||||
# Change: #
|
||||
################################################################################
|
||||
--source include/have_partition.inc
|
||||
|
||||
#
|
||||
# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
|
||||
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
|
||||
# THE SOURCED FILES ONLY.
|
||||
#
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# General not engine specific settings and requirements
|
||||
--source suite/vcol/inc/vcol_init_vars.pre
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
eval SET @@session.storage_engine = 'MyISAM';
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
--source suite/vcol/inc/vcol_partition.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
51
mysql-test/suite/vcol/t/vcol_select_innodb.test
Normal file
51
mysql-test/suite/vcol/t/vcol_select_innodb.test
Normal file
@ -0,0 +1,51 @@
|
||||
################################################################################
|
||||
# t/vcol_select_innodb.test #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Testing different SELECTs. #
|
||||
# #
|
||||
# InnoDB branch #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-09-18 #
|
||||
# Change Author: #
|
||||
# Change Date: #
|
||||
# Change: #
|
||||
################################################################################
|
||||
|
||||
#
|
||||
# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
|
||||
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
|
||||
# THE SOURCED FILES ONLY.
|
||||
#
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# General not engine specific settings and requirements
|
||||
--source suite/vcol/inc/vcol_init_vars.pre
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
--source include/have_innodb.inc
|
||||
eval SET @@session.storage_engine = 'InnoDB';
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
--source suite/vcol/inc/vcol_select.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
50
mysql-test/suite/vcol/t/vcol_select_myisam.test
Normal file
50
mysql-test/suite/vcol/t/vcol_select_myisam.test
Normal file
@ -0,0 +1,50 @@
|
||||
################################################################################
|
||||
# t/vcol_select.test #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Testing different SELECTs. #
|
||||
# #
|
||||
# MyISAM branch #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-09-18 #
|
||||
# Change Author: #
|
||||
# Change Date: #
|
||||
# Change: #
|
||||
################################################################################
|
||||
|
||||
#
|
||||
# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
|
||||
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
|
||||
# THE SOURCED FILES ONLY.
|
||||
#
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# General not engine specific settings and requirements
|
||||
--source suite/vcol/inc/vcol_init_vars.pre
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
eval SET @@session.storage_engine = 'MyISAM';
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
--source suite/vcol/inc/vcol_select.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
50
mysql-test/suite/vcol/t/vcol_supported_sql_funcs_innodb.test
Normal file
50
mysql-test/suite/vcol/t/vcol_supported_sql_funcs_innodb.test
Normal file
@ -0,0 +1,50 @@
|
||||
################################################################################
|
||||
# t/vcol_supported_sql_funcs.test #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Test SQL functions allowed for virtual columns #
|
||||
# InnoDB branch #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-08-31 #
|
||||
# Change Author: #
|
||||
# Change Date: #
|
||||
# Change: #
|
||||
################################################################################
|
||||
|
||||
#
|
||||
# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
|
||||
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
|
||||
# THE SOURCED FILES ONLY.
|
||||
#
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# General not engine specific settings and requirements
|
||||
--source suite/vcol/inc/vcol_init_vars.pre
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
--source include/have_innodb.inc
|
||||
SET @@session.storage_engine = 'InnoDB';
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
--source suite/vcol/inc/vcol_supported_sql_funcs_main.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
49
mysql-test/suite/vcol/t/vcol_supported_sql_funcs_myisam.test
Normal file
49
mysql-test/suite/vcol/t/vcol_supported_sql_funcs_myisam.test
Normal file
@ -0,0 +1,49 @@
|
||||
################################################################################
|
||||
# t/vcol_supported_sql_funcs.test #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Test SQL functions allowed for virtual columns #
|
||||
# MyISAM branch #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-08-31 #
|
||||
# Change Author: #
|
||||
# Change Date: #
|
||||
# Change: #
|
||||
################################################################################
|
||||
|
||||
#
|
||||
# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
|
||||
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
|
||||
# THE SOURCED FILES ONLY.
|
||||
#
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# General not engine specific settings and requirements
|
||||
--source suite/vcol/inc/vcol_init_vars.pre
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
eval SET @@session.storage_engine = 'MyISAM';
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
--source suite/vcol/inc/vcol_supported_sql_funcs_main.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
30
mysql-test/suite/vcol/t/vcol_syntax.test
Normal file
30
mysql-test/suite/vcol/t/vcol_syntax.test
Normal file
@ -0,0 +1,30 @@
|
||||
#
|
||||
# test syntax
|
||||
#
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
|
||||
set @OLD_SQL_MODE=@@SESSION.SQL_MODE;
|
||||
create table t1 (a int, b int generated always as (a+1));
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
create table t1 (a int, b int as (a+1) virtual);
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
create table t1 (a int, b int generated always as (a+1) persistent);
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
|
||||
set session sql_mode='ORACLE';
|
||||
create table t1 (a int, b int as (a+1));
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
create table t1 (a int, b int generated always as (a+1) virtual);
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
create table t1 (a int, b int as (a+1) persistent);
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
set session sql_mode=@OLD_SQL_MODE;
|
||||
|
52
mysql-test/suite/vcol/t/vcol_trigger_sp_innodb.test
Normal file
52
mysql-test/suite/vcol/t/vcol_trigger_sp_innodb.test
Normal file
@ -0,0 +1,52 @@
|
||||
################################################################################
|
||||
# t/vcol_trigger_sp_innodb.test #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Testing triggers, stored procedures and functions #
|
||||
# defined on tables with virtual columns. #
|
||||
# #
|
||||
# InnoDB branch #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-09-04 #
|
||||
# Change Author: #
|
||||
# Change Date: #
|
||||
# Change: #
|
||||
################################################################################
|
||||
|
||||
#
|
||||
# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
|
||||
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
|
||||
# THE SOURCED FILES ONLY.
|
||||
#
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# General not engine specific settings and requirements
|
||||
--source suite/vcol/inc/vcol_init_vars.pre
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
--source include/have_innodb.inc
|
||||
eval SET @@session.storage_engine = 'InnoDB';
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
--source suite/vcol/inc/vcol_trigger_sp.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
51
mysql-test/suite/vcol/t/vcol_trigger_sp_myisam.test
Normal file
51
mysql-test/suite/vcol/t/vcol_trigger_sp_myisam.test
Normal file
@ -0,0 +1,51 @@
|
||||
################################################################################
|
||||
# t/vcol_trigger_sp_myisam.test #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Testing triggers, stored procedures and functions #
|
||||
# defined on tables with virtual columns. #
|
||||
# #
|
||||
# MyISAM branch #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-09-04 #
|
||||
# Change Author: #
|
||||
# Change Date: #
|
||||
# Change: #
|
||||
################################################################################
|
||||
|
||||
#
|
||||
# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
|
||||
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
|
||||
# THE SOURCED FILES ONLY.
|
||||
#
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# General not engine specific settings and requirements
|
||||
--source suite/vcol/inc/vcol_init_vars.pre
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
eval SET @@session.storage_engine = 'MyISAM';
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
--source suite/vcol/inc/vcol_trigger_sp.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
51
mysql-test/suite/vcol/t/vcol_view_innodb.test
Normal file
51
mysql-test/suite/vcol/t/vcol_view_innodb.test
Normal file
@ -0,0 +1,51 @@
|
||||
################################################################################
|
||||
# t/vcol_view_innodb.test #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Testing views defined on tables with virtual columns. #
|
||||
# #
|
||||
# InnoDB branch #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-09-04 #
|
||||
# Change Author: #
|
||||
# Change Date: #
|
||||
# Change: #
|
||||
################################################################################
|
||||
|
||||
#
|
||||
# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
|
||||
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
|
||||
# THE SOURCED FILES ONLY.
|
||||
#
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# General not engine specific settings and requirements
|
||||
--source suite/vcol/inc/vcol_init_vars.pre
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
--source include/have_innodb.inc
|
||||
eval SET @@session.storage_engine = 'InnoDB';
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
--source suite/vcol/inc/vcol_view.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
50
mysql-test/suite/vcol/t/vcol_view_myisam.test
Normal file
50
mysql-test/suite/vcol/t/vcol_view_myisam.test
Normal file
@ -0,0 +1,50 @@
|
||||
################################################################################
|
||||
# t/vcol_view_myisam.test #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Testing views defined on tables with virtual columns. #
|
||||
# #
|
||||
# MyISAM branch #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-09-04 #
|
||||
# Change Author: #
|
||||
# Change Date: #
|
||||
# Change: #
|
||||
################################################################################
|
||||
|
||||
#
|
||||
# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
|
||||
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
|
||||
# THE SOURCED FILES ONLY.
|
||||
#
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# General not engine specific settings and requirements
|
||||
--source suite/vcol/inc/vcol_init_vars.pre
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
eval SET @@session.storage_engine = 'MyISAM';
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
--source suite/vcol/inc/vcol_view.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/vcol/inc/vcol_cleanup.inc
|
149
sql/field.cc
149
sql/field.cc
@ -57,7 +57,7 @@ const char field_separator=',';
|
||||
((ulong) ((LL(1) << min(arg, 4) * 8) - LL(1)))
|
||||
|
||||
#define ASSERT_COLUMN_MARKED_FOR_READ DBUG_ASSERT(!table || (!table->read_set || bitmap_is_set(table->read_set, field_index)))
|
||||
#define ASSERT_COLUMN_MARKED_FOR_WRITE DBUG_ASSERT(!table || (!table->write_set || bitmap_is_set(table->write_set, field_index)))
|
||||
#define ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED DBUG_ASSERT(!table || (!table->write_set || bitmap_is_set(table->write_set, field_index) || bitmap_is_set(&table->vcol_set, field_index)))
|
||||
|
||||
/*
|
||||
Rules for merging different types of fields in UNION
|
||||
@ -1312,7 +1312,8 @@ Field::Field(uchar *ptr_arg,uint32 length_arg,uchar *null_ptr_arg,
|
||||
key_start(0), part_of_key(0), part_of_key_not_clustered(0),
|
||||
part_of_sortkey(0), unireg_check(unireg_check_arg),
|
||||
field_length(length_arg), null_bit(null_bit_arg),
|
||||
is_created_from_null_item(FALSE)
|
||||
is_created_from_null_item(FALSE),
|
||||
vcol_info(0), stored_in_db(TRUE)
|
||||
{
|
||||
flags=null_ptr ? 0: NOT_NULL_FLAG;
|
||||
comment.str= (char*) "";
|
||||
@ -1611,7 +1612,7 @@ longlong Field::convert_decimal2longlong(const my_decimal *val,
|
||||
|
||||
int Field_num::store_decimal(const my_decimal *val)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
int err= 0;
|
||||
longlong i= convert_decimal2longlong(val, unsigned_flag, &err);
|
||||
return test(err | store(i, unsigned_flag));
|
||||
@ -1683,7 +1684,7 @@ void Field_num::make_field(Send_field *field)
|
||||
|
||||
int Field_str::store_decimal(const my_decimal *d)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
double val;
|
||||
/* TODO: use decimal2string? */
|
||||
int err= warn_if_overflow(my_decimal2double(E_DEC_FATAL_ERROR &
|
||||
@ -1760,7 +1761,7 @@ bool Field::get_time(MYSQL_TIME *ltime)
|
||||
|
||||
int Field::store_time(MYSQL_TIME *ltime, timestamp_type type_arg)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
char buff[MAX_DATE_STRING_REP_LENGTH];
|
||||
uint length= (uint) my_TIME_to_str(ltime, buff);
|
||||
return store(buff, length, &my_charset_bin);
|
||||
@ -1887,7 +1888,7 @@ void Field_decimal::overflow(bool negative)
|
||||
|
||||
int Field_decimal::store(const char *from_arg, uint len, CHARSET_INFO *cs)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
char buff[STRING_BUFFER_USUAL_SIZE];
|
||||
String tmp(buff,sizeof(buff), &my_charset_bin);
|
||||
const uchar *from= (uchar*) from_arg;
|
||||
@ -2258,7 +2259,7 @@ int Field_decimal::store(const char *from_arg, uint len, CHARSET_INFO *cs)
|
||||
|
||||
int Field_decimal::store(double nr)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
if (unsigned_flag && nr < 0)
|
||||
{
|
||||
overflow(1);
|
||||
@ -2303,7 +2304,7 @@ int Field_decimal::store(double nr)
|
||||
|
||||
int Field_decimal::store(longlong nr, bool unsigned_val)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
char buff[22];
|
||||
uint length, int_part;
|
||||
char fyllchar;
|
||||
@ -2539,7 +2540,7 @@ void Field_new_decimal::set_value_on_overflow(my_decimal *decimal_value,
|
||||
|
||||
bool Field_new_decimal::store_value(const my_decimal *decimal_value)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
int error= 0;
|
||||
DBUG_ENTER("Field_new_decimal::store_value");
|
||||
#ifndef DBUG_OFF
|
||||
@ -2584,7 +2585,7 @@ bool Field_new_decimal::store_value(const my_decimal *decimal_value)
|
||||
int Field_new_decimal::store(const char *from, uint length,
|
||||
CHARSET_INFO *charset_arg)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
int err;
|
||||
my_decimal decimal_value;
|
||||
DBUG_ENTER("Field_new_decimal::store(char*)");
|
||||
@ -2651,7 +2652,7 @@ int Field_new_decimal::store(const char *from, uint length,
|
||||
|
||||
int Field_new_decimal::store(double nr)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
my_decimal decimal_value;
|
||||
int err;
|
||||
DBUG_ENTER("Field_new_decimal::store(double)");
|
||||
@ -2686,7 +2687,7 @@ int Field_new_decimal::store(double nr)
|
||||
|
||||
int Field_new_decimal::store(longlong nr, bool unsigned_val)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
my_decimal decimal_value;
|
||||
int err;
|
||||
|
||||
@ -2708,7 +2709,7 @@ int Field_new_decimal::store(longlong nr, bool unsigned_val)
|
||||
|
||||
int Field_new_decimal::store_decimal(const my_decimal *decimal_value)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
return store_value(decimal_value);
|
||||
}
|
||||
|
||||
@ -2929,7 +2930,7 @@ Field_new_decimal::unpack(uchar* to,
|
||||
|
||||
int Field_tiny::store(const char *from,uint len,CHARSET_INFO *cs)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
int error;
|
||||
longlong rnd;
|
||||
|
||||
@ -2941,7 +2942,7 @@ int Field_tiny::store(const char *from,uint len,CHARSET_INFO *cs)
|
||||
|
||||
int Field_tiny::store(double nr)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
int error= 0;
|
||||
nr=rint(nr);
|
||||
if (unsigned_flag)
|
||||
@ -2984,7 +2985,7 @@ int Field_tiny::store(double nr)
|
||||
|
||||
int Field_tiny::store(longlong nr, bool unsigned_val)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
int error= 0;
|
||||
|
||||
if (unsigned_flag)
|
||||
@ -3104,7 +3105,7 @@ void Field_tiny::sql_type(String &res) const
|
||||
|
||||
int Field_short::store(const char *from,uint len,CHARSET_INFO *cs)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
int store_tmp;
|
||||
int error;
|
||||
longlong rnd;
|
||||
@ -3125,7 +3126,7 @@ int Field_short::store(const char *from,uint len,CHARSET_INFO *cs)
|
||||
|
||||
int Field_short::store(double nr)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
int error= 0;
|
||||
int16 res;
|
||||
nr=rint(nr);
|
||||
@ -3177,7 +3178,7 @@ int Field_short::store(double nr)
|
||||
|
||||
int Field_short::store(longlong nr, bool unsigned_val)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
int error= 0;
|
||||
int16 res;
|
||||
|
||||
@ -3351,7 +3352,7 @@ void Field_short::sql_type(String &res) const
|
||||
|
||||
int Field_medium::store(const char *from,uint len,CHARSET_INFO *cs)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
int store_tmp;
|
||||
int error;
|
||||
longlong rnd;
|
||||
@ -3365,7 +3366,7 @@ int Field_medium::store(const char *from,uint len,CHARSET_INFO *cs)
|
||||
|
||||
int Field_medium::store(double nr)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
int error= 0;
|
||||
nr=rint(nr);
|
||||
if (unsigned_flag)
|
||||
@ -3411,7 +3412,7 @@ int Field_medium::store(double nr)
|
||||
|
||||
int Field_medium::store(longlong nr, bool unsigned_val)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
int error= 0;
|
||||
|
||||
if (unsigned_flag)
|
||||
@ -3541,7 +3542,7 @@ void Field_medium::sql_type(String &res) const
|
||||
|
||||
int Field_long::store(const char *from,uint len,CHARSET_INFO *cs)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
long store_tmp;
|
||||
int error;
|
||||
longlong rnd;
|
||||
@ -3562,7 +3563,7 @@ int Field_long::store(const char *from,uint len,CHARSET_INFO *cs)
|
||||
|
||||
int Field_long::store(double nr)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
int error= 0;
|
||||
int32 res;
|
||||
nr=rint(nr);
|
||||
@ -3614,7 +3615,7 @@ int Field_long::store(double nr)
|
||||
|
||||
int Field_long::store(longlong nr, bool unsigned_val)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
int error= 0;
|
||||
int32 res;
|
||||
|
||||
@ -3788,7 +3789,7 @@ void Field_long::sql_type(String &res) const
|
||||
|
||||
int Field_longlong::store(const char *from,uint len,CHARSET_INFO *cs)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
int error= 0;
|
||||
char *end;
|
||||
ulonglong tmp;
|
||||
@ -3818,7 +3819,7 @@ int Field_longlong::store(const char *from,uint len,CHARSET_INFO *cs)
|
||||
|
||||
int Field_longlong::store(double nr)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
int error= 0;
|
||||
longlong res;
|
||||
|
||||
@ -3870,7 +3871,7 @@ int Field_longlong::store(double nr)
|
||||
|
||||
int Field_longlong::store(longlong nr, bool unsigned_val)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
int error= 0;
|
||||
|
||||
if (nr < 0) // Only possible error
|
||||
@ -4096,7 +4097,7 @@ int Field_float::store(const char *from,uint len,CHARSET_INFO *cs)
|
||||
|
||||
int Field_float::store(double nr)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
int error= truncate(&nr, FLT_MAX);
|
||||
float j= (float)nr;
|
||||
|
||||
@ -4358,7 +4359,7 @@ int Field_double::store(const char *from,uint len,CHARSET_INFO *cs)
|
||||
|
||||
int Field_double::store(double nr)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
int error= truncate(&nr, DBL_MAX);
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
@ -4785,7 +4786,7 @@ timestamp_auto_set_type Field_timestamp::get_auto_set_type() const
|
||||
|
||||
int Field_timestamp::store(const char *from,uint len,CHARSET_INFO *cs)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
MYSQL_TIME l_time;
|
||||
my_time_t tmp= 0;
|
||||
int error;
|
||||
@ -4848,7 +4849,7 @@ int Field_timestamp::store(double nr)
|
||||
|
||||
int Field_timestamp::store(longlong nr, bool unsigned_val)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
MYSQL_TIME l_time;
|
||||
my_time_t timestamp= 0;
|
||||
int error;
|
||||
@ -5147,7 +5148,7 @@ int Field_time::store_time(MYSQL_TIME *ltime, timestamp_type time_type)
|
||||
|
||||
int Field_time::store(double nr)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
long tmp;
|
||||
int error= 0;
|
||||
if (nr > (double)TIME_MAX_VALUE)
|
||||
@ -5185,7 +5186,7 @@ int Field_time::store(double nr)
|
||||
|
||||
int Field_time::store(longlong nr, bool unsigned_val)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
long tmp;
|
||||
int error= 0;
|
||||
if (nr < (longlong) -TIME_MAX_VALUE && !unsigned_val)
|
||||
@ -5356,7 +5357,7 @@ void Field_time::sql_type(String &res) const
|
||||
|
||||
int Field_year::store(const char *from, uint len,CHARSET_INFO *cs)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
char *end;
|
||||
int error;
|
||||
longlong nr= cs->cset->strntoull10rnd(cs, from, len, 0, &end, &error);
|
||||
@ -5404,7 +5405,7 @@ int Field_year::store(double nr)
|
||||
|
||||
int Field_year::store(longlong nr, bool unsigned_val)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
if (nr < 0 || (nr >= 100 && nr <= 1900) || nr > 2155)
|
||||
{
|
||||
*ptr= 0;
|
||||
@ -5477,7 +5478,7 @@ void Field_year::sql_type(String &res) const
|
||||
|
||||
int Field_date::store(const char *from, uint len,CHARSET_INFO *cs)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
MYSQL_TIME l_time;
|
||||
uint32 tmp;
|
||||
int error;
|
||||
@ -5532,7 +5533,7 @@ int Field_date::store(double nr)
|
||||
|
||||
int Field_date::store(longlong nr, bool unsigned_val)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
MYSQL_TIME not_used;
|
||||
int error;
|
||||
longlong initial_nr= nr;
|
||||
@ -5711,7 +5712,7 @@ void Field_date::sql_type(String &res) const
|
||||
|
||||
int Field_newdate::store(const char *from,uint len,CHARSET_INFO *cs)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
long tmp;
|
||||
MYSQL_TIME l_time;
|
||||
int error;
|
||||
@ -5761,7 +5762,7 @@ int Field_newdate::store(double nr)
|
||||
|
||||
int Field_newdate::store(longlong nr, bool unsigned_val)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
MYSQL_TIME l_time;
|
||||
longlong tmp;
|
||||
int error;
|
||||
@ -5797,7 +5798,7 @@ int Field_newdate::store(longlong nr, bool unsigned_val)
|
||||
|
||||
int Field_newdate::store_time(MYSQL_TIME *ltime,timestamp_type time_type)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
long tmp;
|
||||
int error= 0;
|
||||
if (time_type == MYSQL_TIMESTAMP_DATE ||
|
||||
@ -5944,7 +5945,7 @@ void Field_newdate::sql_type(String &res) const
|
||||
|
||||
int Field_datetime::store(const char *from,uint len,CHARSET_INFO *cs)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
MYSQL_TIME time_tmp;
|
||||
int error;
|
||||
ulonglong tmp= 0;
|
||||
@ -5997,7 +5998,7 @@ int Field_datetime::store(double nr)
|
||||
|
||||
int Field_datetime::store(longlong nr, bool unsigned_val)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
MYSQL_TIME not_used;
|
||||
int error;
|
||||
longlong initial_nr= nr;
|
||||
@ -6035,7 +6036,7 @@ int Field_datetime::store(longlong nr, bool unsigned_val)
|
||||
|
||||
int Field_datetime::store_time(MYSQL_TIME *ltime,timestamp_type time_type)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
longlong tmp;
|
||||
int error= 0;
|
||||
/*
|
||||
@ -6338,7 +6339,7 @@ Field_longstr::report_if_important_data(const char *ptr, const char *end,
|
||||
|
||||
int Field_string::store(const char *from,uint length,CHARSET_INFO *cs)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
uint copy_length;
|
||||
const char *well_formed_error_pos;
|
||||
const char *cannot_convert_error_pos;
|
||||
@ -6379,7 +6380,7 @@ int Field_string::store(const char *from,uint length,CHARSET_INFO *cs)
|
||||
|
||||
int Field_str::store(double nr)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
char buff[DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE];
|
||||
uint length;
|
||||
uint local_char_length= field_length / charset()->mbmaxlen;
|
||||
@ -6994,7 +6995,7 @@ int Field_varstring::do_save_field_metadata(uchar *metadata_ptr)
|
||||
|
||||
int Field_varstring::store(const char *from,uint length,CHARSET_INFO *cs)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
uint copy_length;
|
||||
const char *well_formed_error_pos;
|
||||
const char *cannot_convert_error_pos;
|
||||
@ -7658,7 +7659,7 @@ void Field_blob::put_length(uchar *pos, uint32 length)
|
||||
|
||||
int Field_blob::store(const char *from,uint length,CHARSET_INFO *cs)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
uint copy_length, new_length;
|
||||
const char *well_formed_error_pos;
|
||||
const char *cannot_convert_error_pos;
|
||||
@ -8420,7 +8421,7 @@ void Field_enum::store_type(ulonglong value)
|
||||
|
||||
int Field_enum::store(const char *from,uint length,CHARSET_INFO *cs)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
int err= 0;
|
||||
uint32 not_used;
|
||||
char buff[STRING_BUFFER_USUAL_SIZE];
|
||||
@ -8469,7 +8470,7 @@ int Field_enum::store(double nr)
|
||||
|
||||
int Field_enum::store(longlong nr, bool unsigned_val)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
int error= 0;
|
||||
if ((ulonglong) nr > typelib->count || nr == 0)
|
||||
{
|
||||
@ -8638,7 +8639,7 @@ Field *Field_enum::new_field(MEM_ROOT *root, struct st_table *new_table,
|
||||
|
||||
int Field_set::store(const char *from,uint length,CHARSET_INFO *cs)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
bool got_warning= 0;
|
||||
int err= 0;
|
||||
char *not_used;
|
||||
@ -8678,7 +8679,7 @@ int Field_set::store(const char *from,uint length,CHARSET_INFO *cs)
|
||||
|
||||
int Field_set::store(longlong nr, bool unsigned_val)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
int error= 0;
|
||||
ulonglong max_nr= set_bits(ulonglong, typelib->count);
|
||||
if ((ulonglong) nr > max_nr)
|
||||
@ -8942,7 +8943,7 @@ uint Field_bit::is_equal(Create_field *new_field)
|
||||
|
||||
int Field_bit::store(const char *from, uint length, CHARSET_INFO *cs)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
int delta;
|
||||
|
||||
for (; length && !*from; from++, length--) // skip left 0's
|
||||
@ -9353,7 +9354,7 @@ Field_bit_as_char::Field_bit_as_char(uchar *ptr_arg, uint32 len_arg,
|
||||
|
||||
int Field_bit_as_char::store(const char *from, uint length, CHARSET_INFO *cs)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||
int delta;
|
||||
uchar bits= (uchar) (field_length & 7);
|
||||
|
||||
@ -9461,6 +9462,8 @@ void Create_field::init_for_tmp_table(enum_field_types sql_type_arg,
|
||||
((decimals_arg & FIELDFLAG_MAX_DEC) << FIELDFLAG_DEC_SHIFT) |
|
||||
(maybe_null ? FIELDFLAG_MAYBE_NULL : 0) |
|
||||
(is_unsigned ? 0 : FIELDFLAG_DECIMAL));
|
||||
vcol_info= 0;
|
||||
stored_in_db= TRUE;
|
||||
}
|
||||
|
||||
|
||||
@ -9480,6 +9483,7 @@ void Create_field::init_for_tmp_table(enum_field_types sql_type_arg,
|
||||
@param fld_interval_list Interval list (if any)
|
||||
@param fld_charset Field charset
|
||||
@param fld_geom_type Field geometry type (if any)
|
||||
@param fld_vcol_info Virtual column data
|
||||
|
||||
@retval
|
||||
FALSE on success
|
||||
@ -9492,13 +9496,14 @@ bool Create_field::init(THD *thd, char *fld_name, enum_field_types fld_type,
|
||||
uint fld_type_modifier, Item *fld_default_value,
|
||||
Item *fld_on_update_value, LEX_STRING *fld_comment,
|
||||
char *fld_change, List<String> *fld_interval_list,
|
||||
CHARSET_INFO *fld_charset, uint fld_geom_type)
|
||||
CHARSET_INFO *fld_charset, uint fld_geom_type,
|
||||
Virtual_column_info *fld_vcol_info)
|
||||
{
|
||||
uint sign_len, allowed_type_modifier= 0;
|
||||
ulong max_field_charlength= MAX_FIELD_CHARLENGTH;
|
||||
|
||||
DBUG_ENTER("Create_field::init()");
|
||||
|
||||
|
||||
field= 0;
|
||||
field_name= fld_name;
|
||||
def= fld_default_value;
|
||||
@ -9523,6 +9528,33 @@ bool Create_field::init(THD *thd, char *fld_name, enum_field_types fld_type,
|
||||
interval_list.empty();
|
||||
|
||||
comment= *fld_comment;
|
||||
vcol_info= fld_vcol_info;
|
||||
stored_in_db= TRUE;
|
||||
|
||||
/* Initialize data for a computed field */
|
||||
if ((uchar)fld_type == (uchar)MYSQL_TYPE_VIRTUAL)
|
||||
{
|
||||
DBUG_ASSERT(vcol_info && vcol_info->expr_item);
|
||||
stored_in_db= vcol_info->is_stored();
|
||||
/*
|
||||
Walk through the Item tree checking if all items are valid
|
||||
to be part of the virtual column
|
||||
*/
|
||||
if (vcol_info->expr_item->walk(&Item::check_vcol_func_processor, 0, NULL))
|
||||
{
|
||||
my_error(ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED, MYF(0), field_name);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
Make a field created for the real type.
|
||||
Note that regular and computed fields differ from each other only by
|
||||
Field::vcol_info. It is is always NULL for a column that is not
|
||||
computed.
|
||||
*/
|
||||
sql_type= fld_type= vcol_info->get_real_type();
|
||||
}
|
||||
|
||||
/*
|
||||
Set NO_DEFAULT_VALUE_FLAG if this field doesn't have a default value and
|
||||
it is NOT NULL, not an AUTO_INCREMENT field and not a TIMESTAMP.
|
||||
@ -9813,7 +9845,7 @@ bool Create_field::init(THD *thd, char *fld_name, enum_field_types fld_type,
|
||||
}
|
||||
case MYSQL_TYPE_DECIMAL:
|
||||
DBUG_ASSERT(0); /* Was obsolete */
|
||||
}
|
||||
}
|
||||
/* Remember the value of length */
|
||||
char_length= length;
|
||||
|
||||
@ -9912,7 +9944,6 @@ uint pack_length_to_packflag(uint type)
|
||||
return 0; // This shouldn't happen
|
||||
}
|
||||
|
||||
|
||||
Field *make_field(TABLE_SHARE *share, uchar *ptr, uint32 field_length,
|
||||
uchar *null_pos, uchar null_bit,
|
||||
uint pack_flag,
|
||||
@ -10106,6 +10137,8 @@ Create_field::Create_field(Field *old_field,Field *orig_field)
|
||||
charset= old_field->charset(); // May be NULL ptr
|
||||
comment= old_field->comment;
|
||||
decimals= old_field->decimals();
|
||||
vcol_info= old_field->vcol_info;
|
||||
stored_in_db= old_field->stored_in_db;
|
||||
|
||||
/* Fix if the original table had 4 byte pointer blobs */
|
||||
if (flags & BLOB_FLAG)
|
||||
|
114
sql/field.h
114
sql/field.h
@ -45,6 +45,80 @@ inline uint get_set_pack_length(int elements)
|
||||
return len > 4 ? 8 : len;
|
||||
}
|
||||
|
||||
/*
|
||||
Virtual_column_info is the class to contain additional
|
||||
characteristics that is specific for a virtual/computed
|
||||
field such as:
|
||||
- the defining expression that is evaluated to compute the value
|
||||
of the field
|
||||
- whether the field is to be stored in the database
|
||||
- whether the field is used in a partitioning expression
|
||||
*/
|
||||
|
||||
class Virtual_column_info: public Sql_alloc
|
||||
{
|
||||
private:
|
||||
/*
|
||||
The following data is only updated by the parser and read
|
||||
when a Create_field object is created/initialized.
|
||||
*/
|
||||
enum_field_types field_type; /* Real field type*/
|
||||
/* Flag indicating that the field is physically stored in the database */
|
||||
my_bool stored_in_db;
|
||||
/* Flag indicating that the field used in a partitioning expression */
|
||||
my_bool in_partitioning_expr;
|
||||
|
||||
public:
|
||||
/* The expression to compute the value of the virtual column */
|
||||
Item *expr_item;
|
||||
/* Text representation of the defining expression */
|
||||
LEX_STRING expr_str;
|
||||
/*
|
||||
The list of items created when the defining expression for the virtual
|
||||
column is being parsed and validated. These items are freed in the closefrm
|
||||
function when the table containing this virtual column is removed from
|
||||
the TABLE cache.
|
||||
TODO. Items for all different virtual columns of a table should be put into
|
||||
one list attached to the TABLE structure.
|
||||
*/
|
||||
Item *item_free_list;
|
||||
|
||||
Virtual_column_info()
|
||||
: field_type((enum enum_field_types)MYSQL_TYPE_VIRTUAL),
|
||||
stored_in_db(FALSE), in_partitioning_expr(FALSE),
|
||||
expr_item(NULL), item_free_list(NULL)
|
||||
{
|
||||
expr_str.str= NULL;
|
||||
expr_str.length= 0;
|
||||
};
|
||||
~Virtual_column_info() {}
|
||||
enum_field_types get_real_type()
|
||||
{
|
||||
return field_type;
|
||||
}
|
||||
void set_field_type(enum_field_types fld_type)
|
||||
{
|
||||
/* Calling this function can only be done once. */
|
||||
field_type= fld_type;
|
||||
}
|
||||
bool is_stored()
|
||||
{
|
||||
return stored_in_db;
|
||||
}
|
||||
void set_stored_in_db_flag(bool stored)
|
||||
{
|
||||
stored_in_db= stored;
|
||||
}
|
||||
bool is_in_partitioning_expr()
|
||||
{
|
||||
return in_partitioning_expr;
|
||||
}
|
||||
void mark_as_in_partitioning_expr()
|
||||
{
|
||||
in_partitioning_expr= TRUE;
|
||||
}
|
||||
};
|
||||
|
||||
class Field
|
||||
{
|
||||
Field(const Item &); /* Prevent use of these */
|
||||
@ -57,7 +131,7 @@ public:
|
||||
uchar *ptr; // Position to field in record
|
||||
uchar *null_ptr; // Byte where null_bit is
|
||||
/*
|
||||
Note that you can use table->in_use as replacement for current_thd member
|
||||
Note that you can use table->in_use as replacement for current_thd member
|
||||
only inside of val_*() and store() members (e.g. you can't use it in cons)
|
||||
*/
|
||||
struct st_table *table; // Pointer for table
|
||||
@ -67,10 +141,10 @@ public:
|
||||
/* Field is part of the following keys */
|
||||
key_map key_start, part_of_key, part_of_key_not_clustered;
|
||||
key_map part_of_sortkey;
|
||||
/*
|
||||
We use three additional unireg types for TIMESTAMP to overcome limitation
|
||||
of current binary format of .frm file. We'd like to be able to support
|
||||
NOW() as default and on update value for such fields but unable to hold
|
||||
/*
|
||||
We use three additional unireg types for TIMESTAMP to overcome limitation
|
||||
of current binary format of .frm file. We'd like to be able to support
|
||||
NOW() as default and on update value for such fields but unable to hold
|
||||
this info anywhere except unireg_check field. This issue will be resolved
|
||||
in more clean way with transition to new text based .frm format.
|
||||
See also comment for Field_timestamp::Field_timestamp().
|
||||
@ -103,6 +177,19 @@ public:
|
||||
*/
|
||||
bool is_created_from_null_item;
|
||||
|
||||
/*
|
||||
This is additional data provided for any computed(virtual) field.
|
||||
In particular it includes a pointer to the item by which this field
|
||||
can be computed from other fields.
|
||||
*/
|
||||
Virtual_column_info *vcol_info;
|
||||
/*
|
||||
Flag indicating that the field is physically stored in tables
|
||||
rather than just computed from other fields.
|
||||
As of now, FALSE can be set only for computed virtual columns.
|
||||
*/
|
||||
bool stored_in_db;
|
||||
|
||||
Field(uchar *ptr_arg,uint32 length_arg,uchar *null_ptr_arg,
|
||||
uchar null_bit_arg, utype unireg_check_arg,
|
||||
const char *field_name_arg);
|
||||
@ -2044,6 +2131,20 @@ public:
|
||||
|
||||
uint8 row,col,sc_length,interval_id; // For rea_create_table
|
||||
uint offset,pack_flag;
|
||||
|
||||
/*
|
||||
This is additinal data provided for any computed(virtual) field.
|
||||
In particular it includes a pointer to the item by which this field
|
||||
can be computed from other fields.
|
||||
*/
|
||||
Virtual_column_info *vcol_info;
|
||||
/*
|
||||
Flag indicating that the field is physically stored in tables
|
||||
rather than just computed from other fields.
|
||||
As of now, FALSE can be set only for computed virtual columns.
|
||||
*/
|
||||
bool stored_in_db;
|
||||
|
||||
Create_field() :after(0) {}
|
||||
Create_field(Field *field, Field *orig_field);
|
||||
/* Used to make a clone of this object for ALTER/CREATE TABLE */
|
||||
@ -2060,7 +2161,8 @@ public:
|
||||
char *decimals, uint type_modifier, Item *default_value,
|
||||
Item *on_update_value, LEX_STRING *comment, char *change,
|
||||
List<String> *interval_list, CHARSET_INFO *cs,
|
||||
uint uint_geom_type);
|
||||
uint uint_geom_type,
|
||||
Virtual_column_info *vcol_info);
|
||||
};
|
||||
|
||||
|
||||
|
@ -565,6 +565,8 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select,
|
||||
{
|
||||
if ((error= select->quick->get_next()))
|
||||
break;
|
||||
if (!error)
|
||||
update_virtual_fields(sort_form);
|
||||
file->position(sort_form->record[0]);
|
||||
DBUG_EXECUTE_IF("debug_filesort", dbug_print_record(sort_form, TRUE););
|
||||
}
|
||||
@ -582,6 +584,8 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select,
|
||||
else
|
||||
{
|
||||
error=file->rnd_next(sort_form->record[0]);
|
||||
if (!error)
|
||||
update_virtual_fields(sort_form);
|
||||
if (!flag)
|
||||
{
|
||||
my_store_ptr(ref_pos,ref_length,record); // Position to row
|
||||
|
@ -2436,7 +2436,7 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked)
|
||||
DBUG_RETURN(1);
|
||||
m_start_key.length= 0;
|
||||
m_rec0= table->record[0];
|
||||
m_rec_length= table_share->reclength;
|
||||
m_rec_length= table_share->stored_rec_length;
|
||||
alloc_len= m_tot_parts * (m_rec_length + PARTITION_BYTES_IN_POS);
|
||||
alloc_len+= table_share->max_key_length;
|
||||
if (!m_ordered_rec_buffer)
|
||||
|
@ -245,6 +245,7 @@ public:
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
virtual void change_table_ptr(TABLE *table_arg, TABLE_SHARE *share);
|
||||
bool check_if_supported_virtual_columns(void) { return TRUE;}
|
||||
virtual bool check_if_incompatible_data(HA_CREATE_INFO *create_info,
|
||||
uint table_changes);
|
||||
private:
|
||||
|
@ -1760,6 +1760,17 @@ public:
|
||||
|
||||
LEX_STRING *engine_name() { return hton_name(ht); }
|
||||
|
||||
/*
|
||||
@brief
|
||||
Check whether the engine supports virtual columns
|
||||
|
||||
@retval
|
||||
FALSE if the engine does not support virtual columns
|
||||
@retval
|
||||
TRUE if the engine supports virtual columns
|
||||
*/
|
||||
virtual bool check_if_supported_virtual_columns(void) { return FALSE;}
|
||||
|
||||
protected:
|
||||
/* Service methods for use by storage engines. */
|
||||
void ha_statistic_increment(ulong SSV::*offset) const;
|
||||
|
30
sql/item.cc
30
sql/item.cc
@ -681,9 +681,24 @@ bool Item_field::register_field_in_read_map(uchar *arg)
|
||||
TABLE *table= (TABLE *) arg;
|
||||
if (field->table == table || !table)
|
||||
bitmap_set_bit(field->table->read_set, field->field_index);
|
||||
if (field->vcol_info && field->vcol_info->expr_item)
|
||||
return field->vcol_info->expr_item->walk(&Item::register_field_in_read_map,
|
||||
1, arg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@brief
|
||||
Mark field in bitmap supplied as *arg
|
||||
*/
|
||||
|
||||
bool Item_field::register_field_in_bitmap(uchar *arg)
|
||||
{
|
||||
MY_BITMAP *bitmap= (MY_BITMAP *) arg;
|
||||
DBUG_ASSERT(bitmap);
|
||||
bitmap_set_bit(bitmap, field->field_index);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Item::check_cols(uint c)
|
||||
{
|
||||
@ -4453,6 +4468,21 @@ error:
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
@brief
|
||||
Mark virtual columns as used in a partitioning expression
|
||||
*/
|
||||
|
||||
bool Item_field::vcol_in_partition_func_processor(uchar *int_arg)
|
||||
{
|
||||
DBUG_ASSERT(fixed);
|
||||
if (field->vcol_info)
|
||||
{
|
||||
field->vcol_info->mark_as_in_partitioning_expr();
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
Item *Item_field::safe_charset_converter(CHARSET_INFO *tocs)
|
||||
{
|
||||
|
115
sql/item.h
115
sql/item.h
@ -18,6 +18,24 @@
|
||||
#pragma interface /* gcc class implementation */
|
||||
#endif
|
||||
|
||||
inline
|
||||
bool trace_unsupported_func(const char *where, const char *processor_name)
|
||||
{
|
||||
char buff[64];
|
||||
sprintf(buff, "%s::%s", where, processor_name);
|
||||
DBUG_ENTER(buff);
|
||||
sprintf(buff, "%s returns TRUE: unsupported function", processor_name);
|
||||
DBUG_PRINT("info", (buff));
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
|
||||
inline
|
||||
bool trace_unsupported_by_check_vcol_func_processor(const char *where)
|
||||
{
|
||||
return trace_unsupported_func(where, "check_vcol_func_processor");
|
||||
}
|
||||
|
||||
|
||||
class Protocol;
|
||||
struct TABLE_LIST;
|
||||
void item_init(void); /* Init item functions */
|
||||
@ -894,6 +912,11 @@ public:
|
||||
virtual bool register_field_in_read_map(uchar *arg) { return 0; }
|
||||
virtual bool enumerate_field_refs_processor(uchar *arg) { return 0; }
|
||||
virtual bool mark_as_eliminated_processor(uchar *arg) { return 0; }
|
||||
/*
|
||||
The next function differs from the previous one that a bitmap to be updated
|
||||
is passed as uchar *arg.
|
||||
*/
|
||||
virtual bool register_field_in_bitmap(uchar *arg) { return 0; }
|
||||
/*
|
||||
Check if a partition function is allowed
|
||||
SYNOPSIS
|
||||
@ -946,11 +969,43 @@ public:
|
||||
fields.
|
||||
*/
|
||||
virtual bool check_partition_func_processor(uchar *bool_arg) { return TRUE;}
|
||||
/*
|
||||
@brief
|
||||
Processor used to mark virtual columns used in partitioning expression
|
||||
|
||||
@param
|
||||
arg always ignored
|
||||
|
||||
@retval
|
||||
FALSE always
|
||||
*/
|
||||
virtual bool vcol_in_partition_func_processor(uchar *arg)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
virtual bool subst_argument_checker(uchar **arg)
|
||||
{
|
||||
{
|
||||
if (*arg)
|
||||
*arg= NULL;
|
||||
return TRUE;
|
||||
*arg= NULL;
|
||||
return TRUE;
|
||||
}
|
||||
/*
|
||||
@brief
|
||||
Processor used to check acceptability of an item in the defining
|
||||
expression for a virtual column
|
||||
|
||||
@param
|
||||
arg always ignored
|
||||
|
||||
@retval
|
||||
FALSE the item is accepted in the definition of a virtual column
|
||||
@retval
|
||||
TRUE otherwise
|
||||
*/
|
||||
virtual bool check_vcol_func_processor(uchar *arg)
|
||||
{
|
||||
return trace_unsupported_by_check_vcol_func_processor(full_name());
|
||||
}
|
||||
|
||||
virtual Item *equal_fields_propagator(uchar * arg) { return this; }
|
||||
@ -1327,6 +1382,10 @@ public:
|
||||
{
|
||||
return value_item->send(protocol, str);
|
||||
}
|
||||
bool check_vcol_func_processor(uchar *arg)
|
||||
{
|
||||
return trace_unsupported_by_check_vcol_func_processor("name_const");
|
||||
}
|
||||
};
|
||||
|
||||
bool agg_item_collations(DTCollation &c, const char *name,
|
||||
@ -1346,6 +1405,7 @@ public:
|
||||
virtual Item_num *neg()= 0;
|
||||
Item *safe_charset_converter(CHARSET_INFO *tocs);
|
||||
bool check_partition_func_processor(uchar *int_arg) { return FALSE;}
|
||||
bool check_vcol_func_processor(uchar *arg) { return FALSE;}
|
||||
};
|
||||
|
||||
#define NO_CACHED_FIELD_INDEX ((uint)(-1))
|
||||
@ -1505,7 +1565,10 @@ public:
|
||||
bool collect_item_field_processor(uchar * arg);
|
||||
bool find_item_in_field_list_processor(uchar *arg);
|
||||
bool register_field_in_read_map(uchar *arg);
|
||||
bool register_field_in_bitmap(uchar *arg);
|
||||
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
|
||||
bool vcol_in_partition_func_processor(uchar *bool_arg);
|
||||
bool check_vcol_func_processor(uchar *arg) { return FALSE;}
|
||||
bool enumerate_field_refs_processor(uchar *arg);
|
||||
void cleanup();
|
||||
bool result_as_longlong()
|
||||
@ -1566,6 +1629,7 @@ public:
|
||||
|
||||
Item *safe_charset_converter(CHARSET_INFO *tocs);
|
||||
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
|
||||
bool check_vcol_func_processor(uchar *arg) { return FALSE;}
|
||||
};
|
||||
|
||||
class Item_null_result :public Item_null
|
||||
@ -1579,7 +1643,11 @@ public:
|
||||
save_in_field(result_field, no_conversions);
|
||||
}
|
||||
bool check_partition_func_processor(uchar *int_arg) {return TRUE;}
|
||||
};
|
||||
bool check_vcol_func_processor(uchar *arg)
|
||||
{
|
||||
return trace_unsupported_by_check_vcol_func_processor(full_name());
|
||||
}
|
||||
};
|
||||
|
||||
/* Item represents one placeholder ('?') of prepared statement */
|
||||
|
||||
@ -1720,6 +1788,7 @@ public:
|
||||
/** Item is a argument to a limit clause. */
|
||||
bool limit_clause_param;
|
||||
void set_param_type_and_swap_value(Item_param *from);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -1755,6 +1824,7 @@ public:
|
||||
{ return (uint)(max_length - test(value < 0)); }
|
||||
bool eq(const Item *, bool binary_cmp) const;
|
||||
bool check_partition_func_processor(uchar *bool_arg) { return FALSE;}
|
||||
bool check_vcol_func_processor(uchar arg) { return FALSE;}
|
||||
};
|
||||
|
||||
|
||||
@ -1773,6 +1843,7 @@ public:
|
||||
Item_num *neg ();
|
||||
uint decimal_precision() const { return max_length; }
|
||||
bool check_partition_func_processor(uchar *bool_arg) { return FALSE;}
|
||||
bool check_vcol_func_processor(uchar *arg) { return FALSE;}
|
||||
};
|
||||
|
||||
|
||||
@ -1814,6 +1885,7 @@ public:
|
||||
bool eq(const Item *, bool binary_cmp) const;
|
||||
void set_decimal_value(my_decimal *value_par);
|
||||
bool check_partition_func_processor(uchar *bool_arg) { return FALSE;}
|
||||
bool check_vcol_func_processor(uchar *arg) { return FALSE;}
|
||||
};
|
||||
|
||||
|
||||
@ -1971,6 +2043,7 @@ public:
|
||||
}
|
||||
virtual void print(String *str, enum_query_type query_type);
|
||||
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
|
||||
bool check_vcol_func_processor(uchar *arg) { return FALSE;}
|
||||
|
||||
/**
|
||||
Return TRUE if character-set-introducer was explicitly specified in the
|
||||
@ -2024,7 +2097,7 @@ double_from_string_with_check (CHARSET_INFO *cs, const char *cptr, char *end);
|
||||
class Item_static_string_func :public Item_string
|
||||
{
|
||||
const char *func_name;
|
||||
public:
|
||||
public:
|
||||
Item_static_string_func(const char *name_par, const char *str, uint length,
|
||||
CHARSET_INFO *cs,
|
||||
Derivation dv= DERIVATION_COERCIBLE)
|
||||
@ -2038,6 +2111,10 @@ public:
|
||||
}
|
||||
|
||||
bool check_partition_func_processor(uchar *int_arg) {return TRUE;}
|
||||
bool check_vcol_func_processor(uchar *arg)
|
||||
{
|
||||
return trace_unsupported_by_check_vcol_func_processor(func_name);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -2049,6 +2126,10 @@ public:
|
||||
CHARSET_INFO *cs= NULL):
|
||||
Item_string(name_arg, length, cs)
|
||||
{}
|
||||
bool check_vcol_func_processor(uchar *arg)
|
||||
{
|
||||
return trace_unsupported_by_check_vcol_func_processor("safe_string");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -2128,6 +2209,7 @@ public:
|
||||
bool eq(const Item *item, bool binary_cmp) const;
|
||||
virtual Item *safe_charset_converter(CHARSET_INFO *tocs);
|
||||
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
|
||||
bool check_vcol_func_processor(uchar *arg) { return FALSE;}
|
||||
};
|
||||
|
||||
|
||||
@ -2158,6 +2240,7 @@ public:
|
||||
save_in_field(result_field, no_conversions);
|
||||
}
|
||||
void cleanup();
|
||||
bool check_vcol_func_processor(uchar *arg) { return FALSE;}
|
||||
};
|
||||
|
||||
|
||||
@ -2287,7 +2370,10 @@ public:
|
||||
if (ref && result_type() == ROW_RESULT)
|
||||
(*ref)->bring_value();
|
||||
}
|
||||
|
||||
bool check_vcol_func_processor(uchar *arg)
|
||||
{
|
||||
return trace_unsupported_by_check_vcol_func_processor("ref");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -2563,6 +2649,10 @@ public:
|
||||
table_map used_tables() const { return (table_map) 1L; }
|
||||
bool const_item() const { return 0; }
|
||||
bool is_null() { return null_value; }
|
||||
bool check_vcol_func_processor(uchar *arg)
|
||||
{
|
||||
return trace_unsupported_by_check_vcol_func_processor("copy");
|
||||
}
|
||||
|
||||
/*
|
||||
Override the methods below as pure virtual to make sure all the
|
||||
@ -2805,6 +2895,10 @@ public:
|
||||
return arg->walk(processor, walk_subquery, args) ||
|
||||
(this->*processor)(args);
|
||||
}
|
||||
bool check_vcol_func_processor(uchar *arg)
|
||||
{
|
||||
return trace_unsupported_by_check_vcol_func_processor("values");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -2901,6 +2995,10 @@ private:
|
||||
BEFORE INSERT of BEFORE UPDATE trigger.
|
||||
*/
|
||||
bool read_only;
|
||||
virtual bool check_vcol_func_processor(uchar *arg)
|
||||
{
|
||||
return trace_unsupported_by_check_vcol_func_processor("trigger");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -2960,6 +3058,11 @@ public:
|
||||
{
|
||||
return this == item;
|
||||
}
|
||||
bool check_vcol_func_processor(uchar *arg)
|
||||
{
|
||||
return trace_unsupported_by_check_vcol_func_processor("cache");
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -3940,10 +3940,30 @@ bool Item_func_set_user_var::register_field_in_read_map(uchar *arg)
|
||||
TABLE *table= (TABLE *) arg;
|
||||
if (result_field->table == table || !table)
|
||||
bitmap_set_bit(result_field->table->read_set, result_field->field_index);
|
||||
if (result_field->vcol_info)
|
||||
return result_field->vcol_info->
|
||||
expr_item->walk(&Item::register_field_in_read_map, 1, arg);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
Mark field in bitmap supplied as *arg
|
||||
|
||||
*/
|
||||
|
||||
bool Item_func_set_user_var::register_field_in_bitmap(uchar *arg)
|
||||
{
|
||||
MY_BITMAP *bitmap = (MY_BITMAP *) arg;
|
||||
DBUG_ASSERT(bitmap);
|
||||
if (result_field)
|
||||
{
|
||||
if (!bitmap)
|
||||
return 1;
|
||||
bitmap_set_bit(bitmap, result_field->field_index);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
Set value to user variable.
|
||||
|
@ -339,6 +339,7 @@ public:
|
||||
void fix_length_and_dec();
|
||||
bool fix_fields(THD *thd, Item **ref);
|
||||
longlong val_int() { DBUG_ASSERT(fixed == 1); return value; }
|
||||
bool check_vcol_func_processor(uchar *int_arg) { return TRUE;}
|
||||
};
|
||||
|
||||
|
||||
@ -399,6 +400,7 @@ public:
|
||||
Item_func_additive_op(Item *a,Item *b) :Item_num_op(a,b) {}
|
||||
void result_precision();
|
||||
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
|
||||
bool check_vcol_func_processor(uchar *int_arg) { return FALSE;}
|
||||
};
|
||||
|
||||
|
||||
@ -434,6 +436,7 @@ public:
|
||||
my_decimal *decimal_op(my_decimal *);
|
||||
void result_precision();
|
||||
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
|
||||
bool check_vcol_func_processor(uchar *int_arg) { return FALSE;}
|
||||
};
|
||||
|
||||
|
||||
@ -466,6 +469,7 @@ public:
|
||||
}
|
||||
|
||||
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
|
||||
bool check_vcol_func_processor(uchar *int_arg) { return FALSE;}
|
||||
};
|
||||
|
||||
|
||||
@ -480,6 +484,7 @@ public:
|
||||
void result_precision();
|
||||
void fix_length_and_dec();
|
||||
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
|
||||
bool check_vcol_func_processor(uchar *int_arg) { return FALSE;}
|
||||
};
|
||||
|
||||
|
||||
@ -496,6 +501,7 @@ public:
|
||||
void fix_num_length_and_dec();
|
||||
uint decimal_precision() const { return args[0]->decimal_precision(); }
|
||||
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
|
||||
bool check_vcol_func_processor(uchar *int_arg) { return FALSE;}
|
||||
};
|
||||
|
||||
|
||||
@ -509,6 +515,7 @@ public:
|
||||
const char *func_name() const { return "abs"; }
|
||||
void fix_length_and_dec();
|
||||
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
|
||||
bool check_vcol_func_processor(uchar *int_arg) { return FALSE;}
|
||||
};
|
||||
|
||||
// A class to handle logarithmic and trigonometric functions
|
||||
@ -664,6 +671,7 @@ public:
|
||||
double real_op();
|
||||
my_decimal *decimal_op(my_decimal *);
|
||||
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
|
||||
bool check_vcol_func_processor(uchar *int_arg) { return FALSE;}
|
||||
};
|
||||
|
||||
|
||||
@ -676,6 +684,7 @@ public:
|
||||
double real_op();
|
||||
my_decimal *decimal_op(my_decimal *);
|
||||
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
|
||||
bool check_vcol_func_processor(uchar *int_arg) { return FALSE;}
|
||||
};
|
||||
|
||||
/* This handles round and truncate */
|
||||
@ -707,6 +716,10 @@ public:
|
||||
void update_used_tables();
|
||||
bool fix_fields(THD *thd, Item **ref);
|
||||
void cleanup() { first_eval= TRUE; Item_real_func::cleanup(); }
|
||||
bool check_vcol_func_processor(uchar *int_arg)
|
||||
{
|
||||
return trace_unsupported_by_check_vcol_func_processor(func_name());
|
||||
}
|
||||
private:
|
||||
void seed_random (Item * val);
|
||||
};
|
||||
@ -989,6 +1002,10 @@ public:
|
||||
max_length= args[0]->max_length;
|
||||
}
|
||||
bool fix_fields(THD *thd, Item **ref);
|
||||
bool check_vcol_func_processor(uchar *int_arg)
|
||||
{
|
||||
return trace_unsupported_by_check_vcol_func_processor(func_name());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -1002,6 +1019,10 @@ public:
|
||||
const char *func_name() const { return "benchmark"; }
|
||||
void fix_length_and_dec() { max_length=1; maybe_null=0; }
|
||||
virtual void print(String *str, enum_query_type query_type);
|
||||
bool check_vcol_func_processor(uchar *int_arg)
|
||||
{
|
||||
return trace_unsupported_by_check_vcol_func_processor(func_name());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -1017,6 +1038,10 @@ public:
|
||||
used_tables_cache|= RAND_TABLE_BIT;
|
||||
}
|
||||
longlong val_int();
|
||||
bool check_vcol_func_processor(uchar *int_arg)
|
||||
{
|
||||
return trace_unsupported_by_check_vcol_func_processor(func_name());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -1266,6 +1291,10 @@ class Item_func_get_lock :public Item_int_func
|
||||
longlong val_int();
|
||||
const char *func_name() const { return "get_lock"; }
|
||||
void fix_length_and_dec() { max_length=1; maybe_null=1;}
|
||||
bool check_vcol_func_processor(uchar *int_arg)
|
||||
{
|
||||
return trace_unsupported_by_check_vcol_func_processor(func_name());
|
||||
}
|
||||
};
|
||||
|
||||
class Item_func_release_lock :public Item_int_func
|
||||
@ -1276,6 +1305,10 @@ public:
|
||||
longlong val_int();
|
||||
const char *func_name() const { return "release_lock"; }
|
||||
void fix_length_and_dec() { max_length=1; maybe_null=1;}
|
||||
bool check_vcol_func_processor(uchar *int_arg)
|
||||
{
|
||||
return trace_unsupported_by_check_vcol_func_processor(func_name());
|
||||
}
|
||||
};
|
||||
|
||||
/* replication functions */
|
||||
@ -1289,6 +1322,10 @@ public:
|
||||
longlong val_int();
|
||||
const char *func_name() const { return "master_pos_wait"; }
|
||||
void fix_length_and_dec() { max_length=21; maybe_null=1;}
|
||||
bool check_vcol_func_processor(uchar *int_arg)
|
||||
{
|
||||
return trace_unsupported_by_check_vcol_func_processor(func_name());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -1360,6 +1397,7 @@ public:
|
||||
}
|
||||
void save_org_in_field(Field *field) { (void)save_in_field(field, 1, 0); }
|
||||
bool register_field_in_read_map(uchar *arg);
|
||||
bool register_field_in_bitmap(uchar *arg);
|
||||
bool set_entry(THD *thd, bool create_if_not_exists);
|
||||
void cleanup();
|
||||
};
|
||||
@ -1534,6 +1572,11 @@ public:
|
||||
|
||||
bool fix_index();
|
||||
void init_search(bool no_order);
|
||||
bool check_vcol_func_processor(uchar *int_arg)
|
||||
{
|
||||
/* TODO: consider adding in support for the MATCH-based virtual columns */
|
||||
return trace_unsupported_by_check_vcol_func_processor(func_name());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -1553,6 +1596,17 @@ public:
|
||||
longlong val_int();
|
||||
const char *func_name() const { return "is_free_lock"; }
|
||||
void fix_length_and_dec() { decimals=0; max_length=1; maybe_null=1;}
|
||||
bool check_vcol_func_processor(uchar *int_arg)
|
||||
{
|
||||
#if 0
|
||||
DBUG_ENTER("Item_func_is_free_lock::check_vcol_func_processor");
|
||||
DBUG_PRINT("info",
|
||||
("check_vcol_func_processor returns TRUE: unsupported function"));
|
||||
DBUG_RETURN(TRUE);
|
||||
#else
|
||||
return trace_unsupported_by_check_vcol_func_processor(func_name());
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
class Item_func_is_used_lock :public Item_int_func
|
||||
@ -1563,6 +1617,10 @@ public:
|
||||
longlong val_int();
|
||||
const char *func_name() const { return "is_used_lock"; }
|
||||
void fix_length_and_dec() { decimals=0; max_length=10; maybe_null=1;}
|
||||
bool check_vcol_func_processor(uchar *int_arg)
|
||||
{
|
||||
return trace_unsupported_by_check_vcol_func_processor(func_name());
|
||||
}
|
||||
};
|
||||
|
||||
/* For type casts */
|
||||
@ -1582,6 +1640,11 @@ public:
|
||||
longlong val_int();
|
||||
const char *func_name() const { return "row_count"; }
|
||||
void fix_length_and_dec() { decimals= 0; maybe_null=0; }
|
||||
bool check_vcol_func_processor(uchar *int_arg)
|
||||
{
|
||||
|
||||
return trace_unsupported_by_check_vcol_func_processor(func_name());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -1690,6 +1753,10 @@ public:
|
||||
{
|
||||
return sp_result_field;
|
||||
}
|
||||
bool check_vcol_func_processor(uchar *int_arg)
|
||||
{
|
||||
return trace_unsupported_by_check_vcol_func_processor(func_name());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -1700,6 +1767,10 @@ public:
|
||||
longlong val_int();
|
||||
const char *func_name() const { return "found_rows"; }
|
||||
void fix_length_and_dec() { decimals= 0; maybe_null=0; }
|
||||
bool check_vcol_func_processor(uchar *int_arg)
|
||||
{
|
||||
return trace_unsupported_by_check_vcol_func_processor(func_name());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -1714,5 +1785,9 @@ public:
|
||||
void fix_length_and_dec()
|
||||
{ max_length= 21; unsigned_flag=1; }
|
||||
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
|
||||
bool check_vcol_func_processor(uchar *int_arg)
|
||||
{
|
||||
return trace_unsupported_by_check_vcol_func_processor(func_name());
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -76,4 +76,5 @@ public:
|
||||
bool check_cols(uint c);
|
||||
bool null_inside() { return with_null; };
|
||||
void bring_value();
|
||||
};
|
||||
bool check_vcol_func_processor(uchar *int_arg) {return FALSE; }
|
||||
};
|
||||
|
@ -344,6 +344,10 @@ public:
|
||||
String *val_str(String *);
|
||||
void fix_length_and_dec() { maybe_null=1; max_length = 13; }
|
||||
const char *func_name() const { return "encrypt"; }
|
||||
bool check_vcol_func_processor(uchar *int_arg)
|
||||
{
|
||||
return trace_unsupported_by_check_vcol_func_processor(func_name());
|
||||
}
|
||||
};
|
||||
|
||||
#include "sql_crypt.h"
|
||||
@ -381,6 +385,11 @@ public:
|
||||
call
|
||||
*/
|
||||
virtual const char *fully_qualified_func_name() const = 0;
|
||||
bool check_vcol_func_processor(uchar *int_arg)
|
||||
{
|
||||
return trace_unsupported_by_check_vcol_func_processor(
|
||||
fully_qualified_func_name());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -644,6 +653,10 @@ public:
|
||||
maybe_null=1;
|
||||
max_length=MAX_BLOB_WIDTH;
|
||||
}
|
||||
bool check_vcol_func_processor(uchar *int_arg)
|
||||
{
|
||||
return trace_unsupported_by_check_vcol_func_processor(func_name());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -840,5 +853,9 @@ public:
|
||||
}
|
||||
const char *func_name() const{ return "uuid"; }
|
||||
String *val_str(String *);
|
||||
bool check_vcol_func_processor(uchar *int_arg)
|
||||
{
|
||||
return trace_unsupported_by_check_vcol_func_processor(func_name());
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -136,6 +136,10 @@ public:
|
||||
bool walk(Item_processor processor, bool walk_subquery, uchar *arg);
|
||||
bool mark_as_eliminated_processor(uchar *arg);
|
||||
bool enumerate_field_refs_processor(uchar *arg);
|
||||
bool check_vcol_func_processor(uchar *int_arg)
|
||||
{
|
||||
return trace_unsupported_by_check_vcol_func_processor("subselect");
|
||||
}
|
||||
|
||||
/**
|
||||
Get the SELECT_LEX structure associated with this Item.
|
||||
|
@ -399,6 +399,10 @@ public:
|
||||
Item *get_arg(int i) { return args[i]; }
|
||||
Item *set_arg(int i, THD *thd, Item *new_val);
|
||||
uint get_arg_count() { return arg_count; }
|
||||
bool check_vcol_func_processor(uchar *int_arg)
|
||||
{
|
||||
return trace_unsupported_by_check_vcol_func_processor(func_name());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -679,6 +683,10 @@ public:
|
||||
}
|
||||
void fix_length_and_dec() {}
|
||||
enum Item_result result_type () const { return hybrid_type; }
|
||||
bool check_vcol_func_processor(uchar *int_arg)
|
||||
{
|
||||
return trace_unsupported_by_check_vcol_func_processor("avg_field");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -747,6 +755,10 @@ public:
|
||||
}
|
||||
void fix_length_and_dec() {}
|
||||
enum Item_result result_type () const { return hybrid_type; }
|
||||
bool check_vcol_func_processor(uchar *int_arg)
|
||||
{
|
||||
return trace_unsupported_by_check_vcol_func_processor("var_field");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@ -70,6 +70,7 @@ public:
|
||||
enum_monotonicity_info get_monotonicity_info() const;
|
||||
longlong val_int_endpoint(bool left_endp, bool *incl_endp);
|
||||
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
|
||||
bool check_vcol_func_processor(uchar *int_arg) { return FALSE;}
|
||||
};
|
||||
|
||||
|
||||
@ -86,6 +87,7 @@ public:
|
||||
maybe_null=1;
|
||||
}
|
||||
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
|
||||
bool check_vcol_func_processor(uchar *int_arg) { return FALSE;}
|
||||
};
|
||||
|
||||
|
||||
@ -111,6 +113,7 @@ public:
|
||||
maybe_null=1;
|
||||
}
|
||||
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
|
||||
bool check_vcol_func_processor(uchar *int_arg) { return FALSE;}
|
||||
};
|
||||
|
||||
|
||||
@ -124,6 +127,7 @@ public:
|
||||
enum Item_result result_type () const { return STRING_RESULT; }
|
||||
void fix_length_and_dec();
|
||||
bool check_partition_func_processor(uchar *int_arg) {return TRUE;}
|
||||
bool check_vcol_func_processor(uchar *int_arg) {return FALSE;}
|
||||
};
|
||||
|
||||
|
||||
@ -140,6 +144,7 @@ public:
|
||||
maybe_null=1;
|
||||
}
|
||||
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
|
||||
bool check_vcol_func_processor(uchar *int_arg) { return FALSE;}
|
||||
};
|
||||
|
||||
|
||||
@ -156,6 +161,7 @@ public:
|
||||
maybe_null=1;
|
||||
}
|
||||
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
|
||||
bool check_vcol_func_processor(uchar *int_arg) { return FALSE;}
|
||||
};
|
||||
|
||||
|
||||
@ -172,6 +178,7 @@ public:
|
||||
maybe_null=1;
|
||||
}
|
||||
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
|
||||
bool check_vcol_func_processor(uchar *int_arg) { return FALSE;}
|
||||
};
|
||||
|
||||
|
||||
@ -188,6 +195,7 @@ public:
|
||||
maybe_null=1;
|
||||
}
|
||||
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
|
||||
bool check_vcol_func_processor(uchar *int_arg) { return FALSE;}
|
||||
};
|
||||
|
||||
|
||||
@ -204,6 +212,7 @@ public:
|
||||
maybe_null=1;
|
||||
}
|
||||
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
|
||||
bool check_vcol_func_processor(uchar *int_arg) { return FALSE;}
|
||||
};
|
||||
|
||||
|
||||
@ -234,6 +243,7 @@ public:
|
||||
maybe_null=1;
|
||||
}
|
||||
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
|
||||
bool check_vcol_func_processor(uchar *int_arg) { return FALSE;}
|
||||
};
|
||||
|
||||
|
||||
@ -252,6 +262,7 @@ public:
|
||||
maybe_null=1;
|
||||
}
|
||||
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
|
||||
bool check_vcol_func_processor(uchar *int_arg) { return FALSE;}
|
||||
};
|
||||
|
||||
|
||||
@ -282,6 +293,7 @@ public:
|
||||
maybe_null=1;
|
||||
}
|
||||
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
|
||||
bool check_vcol_func_processor(uchar *int_arg) { return FALSE;}
|
||||
};
|
||||
|
||||
class Item_func_dayname :public Item_func_weekday
|
||||
@ -294,6 +306,7 @@ class Item_func_dayname :public Item_func_weekday
|
||||
enum Item_result result_type () const { return STRING_RESULT; }
|
||||
void fix_length_and_dec();
|
||||
bool check_partition_func_processor(uchar *int_arg) {return TRUE;}
|
||||
bool check_vcol_func_processor(uchar *int_arg) { return FALSE;}
|
||||
};
|
||||
|
||||
|
||||
@ -310,6 +323,14 @@ public:
|
||||
decimals=0;
|
||||
max_length=10*MY_CHARSET_BIN_MB_MAXLEN;
|
||||
}
|
||||
bool check_vcol_func_processor(uchar *int_arg)
|
||||
{
|
||||
/*
|
||||
TODO: Allow UNIX_TIMESTAMP called with an argument to be a part
|
||||
of the expression for a virtual column
|
||||
*/
|
||||
return trace_unsupported_by_check_vcol_func_processor(func_name());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -325,6 +346,7 @@ public:
|
||||
max_length=10*MY_CHARSET_BIN_MB_MAXLEN;
|
||||
}
|
||||
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
|
||||
bool check_vcol_func_processor(uchar *int_arg) { return FALSE;}
|
||||
};
|
||||
|
||||
|
||||
@ -445,6 +467,10 @@ public:
|
||||
*/
|
||||
virtual void store_now_in_TIME(MYSQL_TIME *now_time)=0;
|
||||
bool result_as_longlong() { return TRUE; }
|
||||
bool check_vcol_func_processor(uchar *int_arg)
|
||||
{
|
||||
return trace_unsupported_by_check_vcol_func_processor(func_name());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -481,6 +507,10 @@ public:
|
||||
void fix_length_and_dec();
|
||||
bool get_date(MYSQL_TIME *res, uint fuzzy_date);
|
||||
virtual void store_now_in_TIME(MYSQL_TIME *now_time)=0;
|
||||
bool check_vcol_func_processor(uchar *int_arg)
|
||||
{
|
||||
return trace_unsupported_by_check_vcol_func_processor(func_name());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -521,6 +551,10 @@ public:
|
||||
void fix_length_and_dec();
|
||||
bool get_date(MYSQL_TIME *res, uint fuzzy_date);
|
||||
virtual void store_now_in_TIME(MYSQL_TIME *now_time)=0;
|
||||
bool check_vcol_func_processor(uchar *int_arg)
|
||||
{
|
||||
return trace_unsupported_by_check_vcol_func_processor(func_name());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -578,6 +612,7 @@ public:
|
||||
const char *func_name() const { return "from_days"; }
|
||||
bool get_date(MYSQL_TIME *res, uint fuzzy_date);
|
||||
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
|
||||
bool check_vcol_func_processor(uchar *int_arg) { return FALSE;}
|
||||
};
|
||||
|
||||
|
||||
@ -705,6 +740,7 @@ class Item_extract :public Item_int_func
|
||||
bool eq(const Item *item, bool binary_cmp) const;
|
||||
virtual void print(String *str, enum_query_type query_type);
|
||||
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
|
||||
bool check_vcol_func_processor(uchar *int_arg) { return FALSE;}
|
||||
};
|
||||
|
||||
|
||||
@ -953,6 +989,7 @@ public:
|
||||
maybe_null=1;
|
||||
}
|
||||
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
|
||||
bool check_vcol_func_processor(uchar *int_arg) { return FALSE;}
|
||||
};
|
||||
|
||||
|
||||
|
@ -220,6 +220,11 @@ public:
|
||||
collation.collation= pxml->charset();
|
||||
}
|
||||
const char *func_name() const { return "nodeset"; }
|
||||
bool check_vcol_func_processor(uchar *int_arg)
|
||||
{
|
||||
return trace_unsupported_by_check_vcol_func_processor(func_name());
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -526,6 +531,10 @@ public:
|
||||
enum Type type() const { return XPATH_NODESET_CMP; };
|
||||
const char *func_name() const { return "xpath_nodeset_to_const_comparator"; }
|
||||
bool is_bool_func() { return 1; }
|
||||
bool check_vcol_func_processor(uchar *int_arg)
|
||||
{
|
||||
return trace_unsupported_by_check_vcol_func_processor(func_name());
|
||||
}
|
||||
|
||||
longlong val_int()
|
||||
{
|
||||
|
@ -40,6 +40,10 @@ public:
|
||||
}
|
||||
void fix_length_and_dec();
|
||||
String *parse_xml(String *raw_xml, String *parsed_xml_buf);
|
||||
bool check_vcol_func_processor(uchar *int_arg)
|
||||
{
|
||||
return trace_unsupported_by_check_vcol_func_processor(func_name());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@ -62,6 +62,7 @@ static SYMBOL symbols[] = {
|
||||
{ "ALL", SYM(ALL)},
|
||||
{ "ALGORITHM", SYM(ALGORITHM_SYM)},
|
||||
{ "ALTER", SYM(ALTER)},
|
||||
{ "ALWAYS", SYM(ALWAYS_SYM)},
|
||||
{ "ANALYZE", SYM(ANALYZE_SYM)},
|
||||
{ "AND", SYM(AND_SYM)},
|
||||
{ "ANY", SYM(ANY_SYM)},
|
||||
@ -220,6 +221,7 @@ static SYMBOL symbols[] = {
|
||||
{ "FULL", SYM(FULL)},
|
||||
{ "FULLTEXT", SYM(FULLTEXT_SYM)},
|
||||
{ "FUNCTION", SYM(FUNCTION_SYM)},
|
||||
{ "GENERATED", SYM(GENERATED_SYM)},
|
||||
{ "GEOMETRY", SYM(GEOMETRY_SYM)},
|
||||
{ "GEOMETRYCOLLECTION",SYM(GEOMETRYCOLLECTION)},
|
||||
{ "GET_FORMAT", SYM(GET_FORMAT)},
|
||||
@ -385,14 +387,16 @@ static SYMBOL symbols[] = {
|
||||
{ "OUTFILE", SYM(OUTFILE)},
|
||||
{ "OWNER", SYM(OWNER_SYM)},
|
||||
{ "PACK_KEYS", SYM(PACK_KEYS_SYM)},
|
||||
{ "PARSER", SYM(PARSER_SYM)},
|
||||
{ "PAGE", SYM(PAGE_SYM)},
|
||||
{ "PAGE_CHECKSUM", SYM(PAGE_CHECKSUM_SYM)},
|
||||
{ "PARSER", SYM(PARSER_SYM)},
|
||||
{ "PARSE_VCOL_EXPR", SYM(PARSE_VCOL_EXPR_SYM)},
|
||||
{ "PARTIAL", SYM(PARTIAL)},
|
||||
{ "PARTITION", SYM(PARTITION_SYM)},
|
||||
{ "PARTITIONING", SYM(PARTITIONING_SYM)},
|
||||
{ "PARTITIONS", SYM(PARTITIONS_SYM)},
|
||||
{ "PASSWORD", SYM(PASSWORD)},
|
||||
{ "PERSISTENT", SYM(PERSISTENT_SYM)},
|
||||
{ "PHASE", SYM(PHASE_SYM)},
|
||||
{ "PLUGIN", SYM(PLUGIN_SYM)},
|
||||
{ "PLUGINS", SYM(PLUGINS_SYM)},
|
||||
@ -581,13 +585,14 @@ static SYMBOL symbols[] = {
|
||||
{ "VARCHARACTER", SYM(VARCHAR)},
|
||||
{ "VARIABLES", SYM(VARIABLES)},
|
||||
{ "VARYING", SYM(VARYING)},
|
||||
{ "VIEW", SYM(VIEW_SYM)},
|
||||
{ "VIRTUAL", SYM(VIRTUAL_SYM)},
|
||||
{ "WAIT", SYM(WAIT_SYM)},
|
||||
{ "WARNINGS", SYM(WARNINGS)},
|
||||
{ "WEEK", SYM(WEEK_SYM)},
|
||||
{ "WHEN", SYM(WHEN_SYM)},
|
||||
{ "WHERE", SYM(WHERE)},
|
||||
{ "WHILE", SYM(WHILE_SYM)},
|
||||
{ "VIEW", SYM(VIEW_SYM)},
|
||||
{ "WITH", SYM(WITH)},
|
||||
{ "WORK", SYM(WORK_SYM)},
|
||||
{ "WRAPPER", SYM(WRAPPER_SYM)},
|
||||
|
@ -1350,6 +1350,7 @@ find_field_in_table(THD *thd, TABLE *table, const char *name, uint length,
|
||||
bool allow_rowid, uint *cached_field_index_ptr);
|
||||
Field *
|
||||
find_field_in_table_sef(TABLE *table, const char *name);
|
||||
int update_virtual_fields(TABLE *table, bool ignore_stored= FALSE);
|
||||
|
||||
#endif /* MYSQL_SERVER */
|
||||
|
||||
@ -1470,14 +1471,16 @@ bool add_field_to_list(THD *thd, LEX_STRING *field_name, enum enum_field_types t
|
||||
LEX_STRING *comment,
|
||||
char *change, List<String> *interval_list,
|
||||
CHARSET_INFO *cs,
|
||||
uint uint_geom_type);
|
||||
uint uint_geom_type,
|
||||
Virtual_column_info *vcol_info);
|
||||
Create_field * new_create_field(THD *thd, char *field_name, enum_field_types type,
|
||||
char *length, char *decimals,
|
||||
uint type_modifier,
|
||||
Item *default_value, Item *on_update_value,
|
||||
LEX_STRING *comment, char *change,
|
||||
List<String> *interval_list, CHARSET_INFO *cs,
|
||||
uint uint_geom_type);
|
||||
uint uint_geom_type,
|
||||
Virtual_column_info *vcol_info);
|
||||
void store_position_for_column(const char *name);
|
||||
bool add_to_list(THD *thd, SQL_LIST &list,Item *group,bool asc);
|
||||
bool push_new_name_resolution_context(THD *thd,
|
||||
|
@ -42,7 +42,11 @@ public:
|
||||
{
|
||||
init_make_field(tmp_field,field_type());
|
||||
}
|
||||
unsigned int size_of() { return sizeof(*this);}
|
||||
unsigned int size_of() { return sizeof(*this);}
|
||||
bool check_vcol_func_processor(uchar *int_arg)
|
||||
{
|
||||
return trace_unsupported_by_check_vcol_func_processor("proc");
|
||||
}
|
||||
};
|
||||
|
||||
class Item_proc_real :public Item_proc
|
||||
|
@ -323,6 +323,7 @@ static int rr_quick(READ_RECORD *info)
|
||||
break;
|
||||
}
|
||||
}
|
||||
update_virtual_fields(info->table);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
@ -395,6 +396,8 @@ int rr_sequential(READ_RECORD *info)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!tmp)
|
||||
update_virtual_fields(info->table);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
@ -6206,3 +6206,30 @@ ER_TOO_MANY_CONCURRENT_TRXS
|
||||
|
||||
WARN_NON_ASCII_SEPARATOR_NOT_IMPLEMENTED
|
||||
eng "Non-ASCII separator arguments are not fully supported"
|
||||
|
||||
ER_VCOL_BASED_ON_VCOL
|
||||
eng "A computed column cannot be based on a computed column"
|
||||
|
||||
ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
eng "Function or expression is not allowed for column '%s'."
|
||||
|
||||
ER_DATA_CONVERSION_ERROR_FOR_VIRTUAL_COLUMN
|
||||
eng "Generated value for computed column '%s' cannot be converted to type '%s'."
|
||||
|
||||
ER_PRIMARY_KEY_BASED_ON_VIRTUAL_COLUMN
|
||||
eng "Primary key cannot be defined upon a computed column."
|
||||
|
||||
ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN
|
||||
eng "Key/Index cannot be defined on a non-stored computed column."
|
||||
|
||||
ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN
|
||||
eng "Cannot define foreign key with %s clause on a computed column."
|
||||
|
||||
ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN
|
||||
eng "The value specified for computed column '%s' in table '%s' ignored."
|
||||
|
||||
ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN
|
||||
eng "'%s' is not yet supported for computed columns."
|
||||
|
||||
ER_CONST_EXPR_IN_VCOL
|
||||
eng "Constant expression in computed column function is not allowed."
|
||||
|
@ -816,6 +816,8 @@ sp_head::create_result_field(uint field_max_length, const char *field_name,
|
||||
m_return_field_def.interval,
|
||||
field_name ? field_name : (const char *) m_name.str);
|
||||
|
||||
field->vcol_info= m_return_field_def.vcol_info;
|
||||
field->stored_in_db= m_return_field_def.stored_in_db;
|
||||
if (field)
|
||||
field->init(table);
|
||||
|
||||
@ -2197,7 +2199,8 @@ sp_head::fill_field_definition(THD *thd, LEX *lex,
|
||||
&lex->interval_list,
|
||||
lex->charset ? lex->charset :
|
||||
thd->variables.collation_database,
|
||||
lex->uint_geom_type))
|
||||
lex->uint_geom_type,
|
||||
lex->vcol_info))
|
||||
return TRUE;
|
||||
|
||||
if (field_def->interval_list.elements)
|
||||
|
142
sql/sql_base.cc
142
sql/sql_base.cc
@ -5594,6 +5594,9 @@ static void update_field_dependencies(THD *thd, Field *field, TABLE *table)
|
||||
table->covering_keys.intersect(field->part_of_key);
|
||||
table->merge_keys.merge(field->part_of_key);
|
||||
|
||||
if (field->vcol_info)
|
||||
table->mark_virtual_col(field);
|
||||
|
||||
if (thd->mark_used_columns == MARK_COLUMNS_READ)
|
||||
current_bitmap= table->read_set;
|
||||
else
|
||||
@ -7887,6 +7890,12 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name,
|
||||
{
|
||||
/* Mark fields as used to allow storage engine to optimze access */
|
||||
bitmap_set_bit(field->table->read_set, field->field_index);
|
||||
/*
|
||||
Mark virtual fields for write and others that the virtual fields
|
||||
depend on for read.
|
||||
*/
|
||||
if (field->vcol_info)
|
||||
field->table->mark_virtual_col(field);
|
||||
if (table)
|
||||
{
|
||||
table->covering_keys.intersect(field->part_of_key);
|
||||
@ -8098,7 +8107,10 @@ fill_record(THD * thd, List<Item> &fields, List<Item> &values,
|
||||
Item *value, *fld;
|
||||
Item_field *field;
|
||||
TABLE *table= 0;
|
||||
List<TABLE> tbl_list;
|
||||
bool abort_on_warning_saved= thd->abort_on_warning;
|
||||
DBUG_ENTER("fill_record");
|
||||
tbl_list.empty();
|
||||
|
||||
/*
|
||||
Reset the table->auto_increment_field_not_null as it is valid for
|
||||
@ -8132,14 +8144,54 @@ fill_record(THD * thd, List<Item> &fields, List<Item> &values,
|
||||
table= rfield->table;
|
||||
if (rfield == table->next_number_field)
|
||||
table->auto_increment_field_not_null= TRUE;
|
||||
if (rfield->vcol_info &&
|
||||
value->type() != Item::DEFAULT_VALUE_ITEM &&
|
||||
value->type() != Item::NULL_ITEM &&
|
||||
table->s->table_category != TABLE_CATEGORY_TEMPORARY)
|
||||
{
|
||||
thd->abort_on_warning= FALSE;
|
||||
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||
ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN,
|
||||
ER(ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN),
|
||||
rfield->field_name, table->s->table_name.str);
|
||||
thd->abort_on_warning= abort_on_warning_saved;
|
||||
}
|
||||
if ((value->save_in_field(rfield, 0) < 0) && !ignore_errors)
|
||||
{
|
||||
my_message(ER_UNKNOWN_ERROR, ER(ER_UNKNOWN_ERROR), MYF(0));
|
||||
goto err;
|
||||
}
|
||||
tbl_list.push_back(table);
|
||||
}
|
||||
/* Update virtual fields*/
|
||||
thd->abort_on_warning= FALSE;
|
||||
if (tbl_list.head())
|
||||
{
|
||||
List_iterator_fast<TABLE> it(tbl_list);
|
||||
TABLE *prev_table= 0;
|
||||
while ((table= it++))
|
||||
{
|
||||
/*
|
||||
Do simple optimization to prevent unnecessary re-generating
|
||||
values for virtual fields
|
||||
*/
|
||||
if (table != prev_table)
|
||||
{
|
||||
prev_table= table;
|
||||
if (table->vfield)
|
||||
{
|
||||
if (update_virtual_fields(table, TRUE))
|
||||
{
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
thd->abort_on_warning= abort_on_warning_saved;
|
||||
DBUG_RETURN(thd->is_error());
|
||||
err:
|
||||
thd->abort_on_warning= abort_on_warning_saved;
|
||||
if (table)
|
||||
table->auto_increment_field_not_null= FALSE;
|
||||
DBUG_RETURN(TRUE);
|
||||
@ -8175,9 +8227,31 @@ fill_record_n_invoke_before_triggers(THD *thd, List<Item> &fields,
|
||||
Table_triggers_list *triggers,
|
||||
enum trg_event_type event)
|
||||
{
|
||||
return (fill_record(thd, fields, values, ignore_errors) ||
|
||||
(triggers && triggers->process_triggers(thd, event,
|
||||
TRG_ACTION_BEFORE, TRUE)));
|
||||
bool result;
|
||||
result= (fill_record(thd, fields, values, ignore_errors) ||
|
||||
(triggers && triggers->process_triggers(thd, event,
|
||||
TRG_ACTION_BEFORE, TRUE)));
|
||||
/*
|
||||
Re-calculate virtual fields to cater for cases when base columns are
|
||||
updated by the triggers.
|
||||
*/
|
||||
if (!result && triggers)
|
||||
{
|
||||
TABLE *table= 0;
|
||||
List_iterator_fast<Item> f(fields);
|
||||
Item *fld;
|
||||
Item_field *item_field;
|
||||
if (fields.elements)
|
||||
{
|
||||
fld= (Item_field*)f++;
|
||||
item_field= fld->filed_for_view_update();
|
||||
if (item_field && item_field->field &&
|
||||
(table= item_field->field->table) &&
|
||||
table->vfield)
|
||||
result= update_virtual_fields(table, TRUE);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@ -8205,11 +8279,14 @@ bool
|
||||
fill_record(THD *thd, Field **ptr, List<Item> &values, bool ignore_errors)
|
||||
{
|
||||
List_iterator_fast<Item> v(values);
|
||||
List<TABLE> tbl_list;
|
||||
Item *value;
|
||||
TABLE *table= 0;
|
||||
bool abort_on_warning_saved= thd->abort_on_warning;
|
||||
DBUG_ENTER("fill_record");
|
||||
|
||||
Field *field;
|
||||
tbl_list.empty();
|
||||
/*
|
||||
Reset the table->auto_increment_field_not_null as it is valid for
|
||||
only one row.
|
||||
@ -8229,12 +8306,52 @@ fill_record(THD *thd, Field **ptr, List<Item> &values, bool ignore_errors)
|
||||
table= field->table;
|
||||
if (field == table->next_number_field)
|
||||
table->auto_increment_field_not_null= TRUE;
|
||||
if (field->vcol_info &&
|
||||
value->type() != Item::DEFAULT_VALUE_ITEM &&
|
||||
value->type() != Item::NULL_ITEM &&
|
||||
table->s->table_category != TABLE_CATEGORY_TEMPORARY)
|
||||
{
|
||||
thd->abort_on_warning= FALSE;
|
||||
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||
ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN,
|
||||
ER(ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN),
|
||||
field->field_name, table->s->table_name.str);
|
||||
thd->abort_on_warning= abort_on_warning_saved;
|
||||
}
|
||||
if (value->save_in_field(field, 0) < 0)
|
||||
goto err;
|
||||
tbl_list.push_back(table);
|
||||
}
|
||||
/* Update virtual fields*/
|
||||
thd->abort_on_warning= FALSE;
|
||||
if (tbl_list.head())
|
||||
{
|
||||
List_iterator_fast<TABLE> t(tbl_list);
|
||||
TABLE *prev_table= 0;
|
||||
while ((table= t++))
|
||||
{
|
||||
/*
|
||||
Do simple optimization to prevent unnecessary re-generating
|
||||
values for virtual fields
|
||||
*/
|
||||
if (table != prev_table)
|
||||
{
|
||||
prev_table= table;
|
||||
if (table->vfield)
|
||||
{
|
||||
if (update_virtual_fields(table, TRUE))
|
||||
{
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
thd->abort_on_warning= abort_on_warning_saved;
|
||||
DBUG_RETURN(thd->is_error());
|
||||
|
||||
err:
|
||||
thd->abort_on_warning= abort_on_warning_saved;
|
||||
if (table)
|
||||
table->auto_increment_field_not_null= FALSE;
|
||||
DBUG_RETURN(TRUE);
|
||||
@ -8270,9 +8387,22 @@ fill_record_n_invoke_before_triggers(THD *thd, Field **ptr,
|
||||
Table_triggers_list *triggers,
|
||||
enum trg_event_type event)
|
||||
{
|
||||
return (fill_record(thd, ptr, values, ignore_errors) ||
|
||||
(triggers && triggers->process_triggers(thd, event,
|
||||
TRG_ACTION_BEFORE, TRUE)));
|
||||
bool result;
|
||||
result= (fill_record(thd, ptr, values, ignore_errors) ||
|
||||
(triggers && triggers->process_triggers(thd, event,
|
||||
TRG_ACTION_BEFORE, TRUE)));
|
||||
/*
|
||||
Re-calculate virtual fields to cater for cases when base columns are
|
||||
updated by the triggers.
|
||||
*/
|
||||
if (!result && triggers && *ptr)
|
||||
{
|
||||
TABLE *table= (*ptr)->table;
|
||||
if (table->vfield)
|
||||
result= update_virtual_fields(table, TRUE);
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -194,6 +194,59 @@ bool foreign_key_prefix(Key *a, Key *b)
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
@brief
|
||||
Check if the foreign key options are compatible with the specification
|
||||
of the columns on which the key is created
|
||||
|
||||
@retval
|
||||
FALSE The foreign key options are compatible with key columns
|
||||
@retval
|
||||
TRUE Otherwise
|
||||
*/
|
||||
bool Foreign_key::validate(List<Create_field> &table_fields)
|
||||
{
|
||||
Create_field *sql_field;
|
||||
Key_part_spec *column;
|
||||
List_iterator<Key_part_spec> cols(columns);
|
||||
List_iterator<Create_field> it(table_fields);
|
||||
DBUG_ENTER("Foreign_key::validate");
|
||||
while ((column= cols++))
|
||||
{
|
||||
it.rewind();
|
||||
while ((sql_field= it++) &&
|
||||
my_strcasecmp(system_charset_info,
|
||||
column->field_name,
|
||||
sql_field->field_name)) {}
|
||||
if (!sql_field)
|
||||
{
|
||||
my_error(ER_KEY_COLUMN_DOES_NOT_EXITS, MYF(0), column->field_name);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
if (type == Key::FOREIGN_KEY && sql_field->vcol_info)
|
||||
{
|
||||
if (delete_opt == FK_OPTION_SET_NULL)
|
||||
{
|
||||
my_error(ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN, MYF(0),
|
||||
"ON DELETE SET NULL");
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
if (update_opt == FK_OPTION_SET_NULL)
|
||||
{
|
||||
my_error(ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN, MYF(0),
|
||||
"ON UPDATE SET NULL");
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
if (update_opt == FK_OPTION_CASCADE)
|
||||
{
|
||||
my_error(ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN, MYF(0),
|
||||
"ON UPDATE CASCADE");
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
DBUG_RETURN(FALSE);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
** Thread specific functions
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user