mirror of
https://github.com/MariaDB/server.git
synced 2025-04-20 14:15:30 +02:00
gcol mysql-test suite from 5.7
update tests and results, fix bugs
This commit is contained in:
parent
4136968ca0
commit
a418c99200
90 changed files with 21645 additions and 22 deletions
mysql-test
mysql-test-run.pl
suite
gcol
inc
gcol_blocked_sql_funcs_main.incgcol_cleanup.incgcol_column_def_options.incgcol_dependancies_on_vcol.incgcol_handler.incgcol_ins_upd.incgcol_keys.incgcol_non_stored_columns.incgcol_partition.incgcol_select.incgcol_supported_sql_funcs.incgcol_supported_sql_funcs_main.incgcol_trigger_sp.incgcol_unsupported_storage_engines.incgcol_view.inc
r
federated_gcol.resultgcol_archive.resultgcol_blackhole.resultgcol_blocked_sql_funcs_innodb.resultgcol_blocked_sql_funcs_myisam.resultgcol_bug20746926.resultgcol_bugfixes.resultgcol_column_def_options_innodb.resultgcol_column_def_options_myisam.resultgcol_csv.resultgcol_falcon.resultgcol_handler_innodb.resultgcol_handler_myisam.resultgcol_ins_upd_innodb.resultgcol_ins_upd_myisam.resultgcol_keys_innodb.resultgcol_keys_myisam.resultgcol_memory.resultgcol_merge.resultgcol_ndb.resultgcol_non_stored_columns_innodb.resultgcol_non_stored_columns_myisam.resultgcol_partition_innodb.resultgcol_partition_myisam.resultgcol_rejected_innodb.resultgcol_rollback.resultgcol_select_innodb.resultgcol_select_myisam.resultgcol_supported_sql_funcs_innodb.resultgcol_supported_sql_funcs_myisam.resultgcol_trigger_sp_innodb.resultgcol_trigger_sp_myisam.resultgcol_update.resultgcol_view_innodb.resultgcol_view_myisam.resultrpl_gcol.result
t
gcol_archive.testgcol_blackhole.testgcol_blocked_sql_funcs_innodb.testgcol_blocked_sql_funcs_myisam.testgcol_bug20746926.testgcol_bugfixes.testgcol_column_def_options_innodb.testgcol_column_def_options_myisam.testgcol_handler_innodb.testgcol_handler_myisam.testgcol_ins_upd_innodb.testgcol_ins_upd_myisam.testgcol_keys_innodb.testgcol_keys_myisam.testgcol_memory.testgcol_merge.testgcol_non_stored_columns_innodb.testgcol_non_stored_columns_myisam.testgcol_partition_innodb.testgcol_partition_myisam.testgcol_rejected_innodb.testgcol_rollback.testgcol_select_innodb.testgcol_select_myisam.testgcol_supported_sql_funcs_innodb.testgcol_supported_sql_funcs_myisam.testgcol_trigger_sp_innodb.testgcol_trigger_sp_myisam.testgcol_update.testgcol_view_innodb.testgcol_view_myisam.testrpl_gcol.test
vcol
sql
|
@ -175,6 +175,7 @@ my @DEFAULT_SUITES= qw(
|
|||
federated-
|
||||
funcs_1-
|
||||
funcs_2-
|
||||
gcol-
|
||||
handler-
|
||||
heap-
|
||||
innodb-
|
||||
|
|
249
mysql-test/suite/gcol/inc/gcol_blocked_sql_funcs_main.inc
Normal file
249
mysql-test/suite/gcol/inc/gcol_blocked_sql_funcs_main.inc
Normal file
|
@ -0,0 +1,249 @@
|
|||
################################################################################
|
||||
# inc/gcol_blocked_sql_funcs_main.inc #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Tests around sql functions #
|
||||
# #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-08-31 #
|
||||
# Change Author: #
|
||||
# Change Date: #
|
||||
# Change: #
|
||||
################################################################################
|
||||
|
||||
#
|
||||
# MySQL doesn't support them, but MariaDB does:
|
||||
#
|
||||
create or replace table t1 (b double generated always as (rand()) virtual);
|
||||
create or replace table t1 (a datetime generated always as (curdate()) virtual);
|
||||
create or replace table t1 (a datetime generated always as (current_date) virtual);
|
||||
create or replace table t1 (a datetime generated always as (current_date()) virtual);
|
||||
create or replace table t1 (a datetime generated always as (current_time) virtual);
|
||||
create or replace table t1 (a datetime generated always as (current_time()) virtual);
|
||||
create or replace table t1 (a datetime generated always as (current_timestamp()) virtual);
|
||||
create or replace table t1 (a datetime generated always as (current_timestamp) virtual);
|
||||
create or replace table t1 (a datetime generated always as (curtime()) virtual);
|
||||
create or replace table t1 (a datetime, b varchar(10) generated always as (localtime()) virtual);
|
||||
create or replace table t1 (a datetime, b varchar(10) generated always as (localtime) virtual);
|
||||
create or replace table t1 (a datetime, b varchar(10) generated always as (localtimestamp()) virtual);
|
||||
create or replace table t1 (a datetime, b varchar(10) generated always as (localtimestamp) virtual);
|
||||
create or replace table t1 (a datetime, b varchar(10) generated always as (now()) virtual);
|
||||
create or replace table t1 (a int, b varchar(10) generated always as (sysdate()) virtual);
|
||||
create or replace table t1 (a datetime, b datetime generated always as (unix_timestamp()) virtual);
|
||||
create or replace table t1 (a datetime, b datetime generated always as (utc_date()) virtual);
|
||||
create or replace table t1 (a datetime, b datetime generated always as (utc_time()) virtual);
|
||||
create or replace table t1 (a datetime, b datetime generated always as (utc_timestamp()) virtual);
|
||||
create or replace table t1 (a int generated always as (connection_id()) virtual);
|
||||
create or replace table t1 (a varchar(32) generated always as (current_user()) virtual);
|
||||
create or replace table t1 (a varchar(32) generated always as (current_user) virtual);
|
||||
create or replace table t1 (a varchar(1024), b varchar(1024) generated always as (database()) virtual);
|
||||
create or replace table t1 (a varchar(32) generated always as (schema()) virtual);
|
||||
create or replace table t1 (a varchar(32) generated always as (session_user()) virtual);
|
||||
create or replace table t1 (a varchar(32) generated always as (system_user()) virtual);
|
||||
create or replace table t1 (a varchar(1024), b varchar(1024) generated always as (user()) virtual);
|
||||
create or replace table t1 (a varchar(1024) generated always as (uuid_short()) virtual);
|
||||
create or replace table t1 (a varchar(1024) generated always as (uuid()) virtual);
|
||||
create or replace table t1 (a varchar(1024), b varchar(1024) generated always as (version()) virtual);
|
||||
create or replace table t1 (a varchar(1024), b varchar(1024) generated always as (encrypt(a)) virtual);
|
||||
create or replace table t1 (a varchar(1024), b varchar(1024) generated always as (UpdateXML(a,'/a','<e>fff</e>')) virtual);
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# NOTE: All SQL functions below should be rejected, otherwise BUG.
|
||||
#
|
||||
|
||||
--echo # LOAD_FILE()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a varchar(64), b varchar(1024) generated always as (load_file(a)) virtual);
|
||||
|
||||
--echo # MATCH()
|
||||
if (!$skip_full_text_check)
|
||||
{
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a varchar(32), b bool generated always as (match a against ('sample text')) virtual);
|
||||
}
|
||||
|
||||
--echo # BENCHMARK()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a varchar(1024), b varchar(1024) generated always as (benchmark(a,3)) virtual);
|
||||
|
||||
--echo # FOUND_ROWS()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a varchar(1024), b varchar(1024) generated always as (found_rows()) virtual);
|
||||
|
||||
--echo # GET_LOCK()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a varchar(1024), b varchar(1024) generated always as (get_lock(a,10)) virtual);
|
||||
|
||||
--echo # IS_FREE_LOCK()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a varchar(1024), b varchar(1024) generated always as (is_free_lock(a)) virtual);
|
||||
|
||||
--echo # IS_USED_LOCK()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a varchar(1024), b varchar(1024) generated always as (is_used_lock(a)) virtual);
|
||||
|
||||
--echo # LAST_INSERT_ID()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int generated always as (last_insert_id()) virtual);
|
||||
|
||||
--echo # MASTER_POS_WAIT()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a varchar(32), b int generated always as (master_pos_wait(a,0,2)) virtual);
|
||||
|
||||
--echo # NAME_CONST()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a varchar(32) generated always as (name_const('test',1)) virtual);
|
||||
|
||||
--echo # RELEASE_LOCK()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a varchar(32), b int generated always as (release_lock(a)) virtual);
|
||||
|
||||
--echo # ROW_COUNT()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int generated always as (row_count()) virtual);
|
||||
|
||||
--echo # SLEEP()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int, b int generated always as (sleep(a)) virtual);
|
||||
|
||||
--echo # VALUES()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a varchar(1024), b varchar(1024) generated always as (values(a)) virtual);
|
||||
|
||||
--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 generated always as (p1()) virtual);
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int generated always as (f1()) virtual);
|
||||
|
||||
drop procedure p1;
|
||||
drop function f1;
|
||||
|
||||
--echo # Unknown functions
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int generated always as (f1()) virtual);
|
||||
|
||||
--echo #
|
||||
--echo # GROUP BY FUNCTIONS
|
||||
--echo #
|
||||
|
||||
--echo # AVG()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int, b int generated always as (avg(a)) virtual);
|
||||
|
||||
--echo # BIT_AND()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int, b int generated always as (bit_and(a)) virtual);
|
||||
|
||||
--echo # BIT_OR()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int, b int generated always as (bit_or(a)) virtual);
|
||||
|
||||
--echo # BIT_XOR()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int, b int generated always as (bit_xor(a)) virtual);
|
||||
|
||||
--echo # COUNT(DISTINCT)
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int, b int generated always as (count(distinct a)) virtual);
|
||||
|
||||
--echo # COUNT()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int, b int generated always as (count(a)) virtual);
|
||||
|
||||
--echo # GROUP_CONCAT()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a varchar(32), b int generated always as (group_concat(a,'')) virtual);
|
||||
|
||||
--echo # MAX()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int, b int generated always as (max(a)) virtual);
|
||||
|
||||
--echo # MIN()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int, b int generated always as (min(a)) virtual);
|
||||
|
||||
--echo # STD()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int, b int generated always as (std(a)) virtual);
|
||||
|
||||
--echo # STDDEV_POP()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int, b int generated always as (stddev_pop(a)) virtual);
|
||||
|
||||
--echo # STDDEV_SAMP()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int, b int generated always as (stddev_samp(a)) virtual);
|
||||
|
||||
--echo # STDDEV()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int, b int generated always as (stddev(a)) virtual);
|
||||
|
||||
--echo # SUM()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int, b int generated always as (sum(a)) virtual);
|
||||
|
||||
--echo # VAR_POP()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int, b int generated always as (var_pop(a)) virtual);
|
||||
|
||||
--echo # VAR_SAMP()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int, b int generated always as (var_samp(a)) virtual);
|
||||
|
||||
--echo # VARIANCE()
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t1 (a int, b int generated always as (variance(a)) virtual);
|
||||
|
||||
--echo #
|
||||
--echo # Sub-selects
|
||||
--echo #
|
||||
|
||||
create table t1 (a int);
|
||||
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
create table t2 (a int, b int generated always as (select count(*) virtual from t1));
|
||||
drop table t1;
|
||||
|
||||
--echo #
|
||||
--echo # Long expression
|
||||
|
||||
let $tmp_long_string = `SELECT repeat('a',240)`;
|
||||
eval create table t1 (a int, b varchar(300) generated always as (concat(a,'$tmp_long_string')) virtual);
|
||||
drop table t1;
|
||||
let $tmp_long_string = `SELECT repeat('a',243)`;
|
||||
# Limit is lifted to 64K. TODO write a test for it.
|
||||
# --error 1470
|
||||
eval create table t1 (a int, b varchar(300) generated always as (concat(a,'$tmp_long_string')) virtual);
|
||||
drop table t1;
|
||||
|
||||
--echo #
|
||||
--echo # Constant expression
|
||||
create table t1 (a int generated always as (PI()) virtual);
|
||||
drop table t1;
|
||||
|
||||
--echo # bug#21098119: GCOL WITH MATCH/AGAINST -->
|
||||
--echo # ASSERTION FAILED: TR && TR->TABLE->FILE
|
||||
--echo #
|
||||
create table t1 (a int);
|
||||
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
alter table t1 add column r blob generated always
|
||||
as (match(a) against ('' in boolean mode)) virtual;
|
||||
drop table t1;
|
24
mysql-test/suite/gcol/inc/gcol_cleanup.inc
Normal file
24
mysql-test/suite/gcol/inc/gcol_cleanup.inc
Normal file
|
@ -0,0 +1,24 @@
|
|||
################################################################################
|
||||
# inc/gcol_cleanup.inc #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Removal of the objects created by the t/<test_name>.test #
|
||||
# scripts. #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-08-31 #
|
||||
# Change Author: #
|
||||
# Change Date: #
|
||||
# Change: #
|
||||
################################################################################
|
||||
|
||||
--disable_warnings
|
||||
DROP VIEW IF EXISTS v1,v2;
|
||||
DROP TABLE IF EXISTS t1,t2,t3;
|
||||
DROP PROCEDURE IF EXISTS p1;
|
||||
DROP FUNCTION IF EXISTS f1;
|
||||
DROP TRIGGER IF EXISTS trg1;
|
||||
DROP TRIGGER IF EXISTS trg2;
|
||||
set sql_warnings = 0;
|
||||
--enable_warnings
|
585
mysql-test/suite/gcol/inc/gcol_column_def_options.inc
Normal file
585
mysql-test/suite/gcol/inc/gcol_column_def_options.inc
Normal file
|
@ -0,0 +1,585 @@
|
|||
################################################################################
|
||||
# inc/gcol_column_def_options.inc #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Testing different optional parameters specified when defining #
|
||||
# a generated column. #
|
||||
# #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-09-02 #
|
||||
# Change Author: #
|
||||
# Change Date: #
|
||||
# Change: #
|
||||
################################################################################
|
||||
--source include/have_partition.inc
|
||||
|
||||
--echo #
|
||||
--echo # Section 1. Wrong column definition options
|
||||
--echo # - DEFAULT <value>
|
||||
--echo # - AUTO_INCREMENT
|
||||
|
||||
--echo # NOT NULL
|
||||
--error ER_PARSE_ERROR
|
||||
create table t1 (a int, b int generated always as (a+1) virtual not null);
|
||||
--error ER_PARSE_ERROR
|
||||
create table t1 (a int, b int generated always as (a+1) stored not null);
|
||||
create table t1 (a int);
|
||||
--error ER_PARSE_ERROR
|
||||
alter table t1 add column b int generated always as (a+1) virtual not null;
|
||||
drop table t1;
|
||||
|
||||
--error ER_PARSE_ERROR
|
||||
create table t1 (a int, b int generated always as (a+1) virtual null);
|
||||
create table t1 (a int);
|
||||
--error ER_PARSE_ERROR
|
||||
alter table t1 add column b int generated always as (a+1) virtual null;
|
||||
drop table t1;
|
||||
|
||||
--echo # Added columns mixed with virtual GC and other columns
|
||||
create table t1 (a int);
|
||||
insert into t1 values(1);
|
||||
--enable_info
|
||||
alter table t1 add column (b int generated always as (a+1) virtual, c int);
|
||||
alter table t1 add column (d int, e int generated always as (a+1) virtual);
|
||||
alter table t1 add column (f int generated always as (a+1) virtual, g int as(5) stored);
|
||||
alter table t1 add column (h int generated always as (a+1) virtual, i int as(5) virtual);
|
||||
--disable_info
|
||||
drop table t1;
|
||||
|
||||
--echo # DEFAULT
|
||||
--error 1064
|
||||
create table t1 (a int, b int generated always as (a+1) virtual default 0);
|
||||
create table t1 (a int);
|
||||
--error 1064
|
||||
alter table t1 add column b int generated always as (a+1) virtual default 0;
|
||||
drop table t1;
|
||||
|
||||
--echo # AUTO_INCREMENT
|
||||
--error 1064
|
||||
create table t1 (a int, b int generated always as (a+1) virtual AUTO_INCREMENT);
|
||||
create table t1 (a int);
|
||||
--error 1064
|
||||
alter table t1 add column b int generated always as (a+1) virtual AUTO_INCREMENT;
|
||||
drop table t1;
|
||||
|
||||
--echo # [PRIMARY] KEY
|
||||
if ($support_virtual_index)
|
||||
{
|
||||
--error ER_PARSE_ERROR
|
||||
create table t1 (a int, b int generated always as (a+1) virtual key);
|
||||
}
|
||||
--error ER_PARSE_ERROR
|
||||
create table t1 (a int, b int generated always as (a+1) stored key);
|
||||
if ($support_virtual_index)
|
||||
{
|
||||
--error ER_PARSE_ERROR
|
||||
create table t1 (a int, b int generated always as (a+1) virtual primary key);
|
||||
}
|
||||
--error ER_PARSE_ERROR
|
||||
create table t1 (a int, b int generated always as (a+1) stored primary key);
|
||||
create table t1 (a int);
|
||||
if ($support_virtual_index)
|
||||
{
|
||||
--error ER_PARSE_ERROR
|
||||
alter table t1 add column b int generated always as (a+1) virtual key;
|
||||
}
|
||||
--error ER_PARSE_ERROR
|
||||
alter table t1 add column b int generated always as (a+1) stored key;
|
||||
if ($support_virtual_index)
|
||||
{
|
||||
--error ER_PARSE_ERROR
|
||||
alter table t1 add column c int generated always as (a+2) virtual primary key;
|
||||
}
|
||||
show create table t1;
|
||||
--error ER_PARSE_ERROR
|
||||
alter table t1 add column c int generated always as (a+2) stored 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 generated always as (a % 2) virtual comment 'my comment');
|
||||
show create table t1;
|
||||
describe t1;
|
||||
drop table t1;
|
||||
create table t1 (a int, b int generated always as (a % 2) virtual);
|
||||
alter table t1 modify b int generated always as (a % 2) virtual 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 order by a;
|
||||
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 order by a;
|
||||
drop table t2;
|
||||
drop table t1;
|
||||
|
||||
create table t1 (a int, b int generated always as (a % 2) stored);
|
||||
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 order by a;
|
||||
drop table t1;
|
||||
|
||||
|
||||
create table t2 (a int);
|
||||
create table t1 (a int, b int generated always as (a % 2) stored references t2(a));
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
create table t1 (a int, b int generated always as (a % 2) virtual);
|
||||
--error 1064
|
||||
alter table t1 modify b int generated always as (a % 2) stored references t2(a);
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
drop table t2;
|
||||
--echo FK options
|
||||
create table t1(a int, b int as (a % 2), c int as (a) stored);
|
||||
create table t2 (a int);
|
||||
--error ER_KEY_COLUMN_DOES_NOT_EXITS
|
||||
alter table t1 add constraint foreign key fk(d) references t2(a);
|
||||
if ($support_virtual_foreign)
|
||||
{
|
||||
--replace_regex /`#sql-.*`/`#sql-temporary`/
|
||||
--error ER_CANT_CREATE_TABLE
|
||||
alter table t1 add constraint foreign key fk(b) references t2(a);
|
||||
}
|
||||
--error ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN
|
||||
alter table t1 add constraint foreign key fk(c) references t2(a) on delete set null;
|
||||
--error ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN
|
||||
alter table t1 add constraint foreign key fk(c) references t2(a) on update set null;
|
||||
--error ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN
|
||||
alter table t1 add constraint foreign key fk(c) references t2(a) on update cascade;
|
||||
drop table t1;
|
||||
drop table t2;
|
||||
--echo Generated always is optional
|
||||
create table t1 (a int, b int as (a % 2) virtual);
|
||||
show create table t1;
|
||||
describe t1;
|
||||
drop table t1;
|
||||
create table t1 (a int, b int as (a % 2) stored);
|
||||
show create table t1;
|
||||
describe t1;
|
||||
drop table t1;
|
||||
--echo Default should be non-stored column
|
||||
create table t1 (a int, b int as (a % 2));
|
||||
show create table t1;
|
||||
describe t1;
|
||||
drop table t1;
|
||||
--echo Expression can be constant
|
||||
create table t1 (a int, b int as (5 * 2));
|
||||
show create table t1;
|
||||
describe t1;
|
||||
drop table t1;
|
||||
--echo Test generated columns referencing other generated columns
|
||||
create table t1 (a int unique, b int generated always as(-a) virtual, c int generated always as (b + 1) virtual);
|
||||
insert into t1 (a) values (1), (2);
|
||||
--sorted_result
|
||||
select * from t1;
|
||||
insert into t1(a) values (1) on duplicate key update a=3;
|
||||
--sorted_result
|
||||
select * from t1;
|
||||
update t1 set a=4 where a=2;
|
||||
--sorted_result
|
||||
select * from t1;
|
||||
drop table t1;
|
||||
|
||||
--error ER_EXPRESSION_REFERS_TO_UNINIT_FIELD
|
||||
create table t1 (a int, b int generated always as(-b) virtual, c int generated always as (b + 1) virtual);
|
||||
--error ER_EXPRESSION_REFERS_TO_UNINIT_FIELD
|
||||
create table t1 (a int, b int generated always as(-c) virtual, c int generated always as (b + 1) virtual);
|
||||
--error ER_EXPRESSION_REFERS_TO_UNINIT_FIELD
|
||||
create table t1 (pk int auto_increment primary key, col_int_nokey int generated always as (pk + col_int_key) stored, col_int_key int);
|
||||
|
||||
--echo # Bug#20339347: FAIL TO USE CREATE ....SELECT STATEMENT TO CREATE A NEW TABLE
|
||||
create table t1 (a int, b int generated always as(-a) virtual, c int generated always as (b + 1) stored);
|
||||
insert into t1(a) values(1),(2);
|
||||
create table tt as select * from t1;
|
||||
select * from t1 order by a;
|
||||
select * from tt order by a;
|
||||
drop table t1,tt;
|
||||
|
||||
if (!$support_virtual_index)
|
||||
{
|
||||
--echo # Bug#20769299: INCORRECT KEY ERROR WHEN TRYING TO CREATE INDEX ON
|
||||
--echo # VIRTUAL GC FOR MYISAM
|
||||
--error ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN
|
||||
CREATE TABLE A (
|
||||
pk INTEGER,
|
||||
col_int_nokey INTEGER,
|
||||
col_int_key INTEGER GENERATED ALWAYS AS (pk + col_int_nokey) VIRTUAL, KEY
|
||||
(col_int_key));
|
||||
}
|
||||
|
||||
--echo # Bug#20745142: GENERATED COLUMNS: ASSERTION FAILED:
|
||||
--echo # THD->CHANGE_LIST.IS_EMPTY()
|
||||
--echo #
|
||||
--error ER_EXPRESSION_REFERS_TO_UNINIT_FIELD
|
||||
CREATE TABLE t1(a bigint AS (a between 1 and 1));
|
||||
|
||||
--echo # Bug#20757211: GENERATED COLUMNS: ALTER TABLE CRASHES
|
||||
--echo # IN FIND_FIELD_IN_TABLE
|
||||
--echo #
|
||||
CREATE TABLE t1(a int);
|
||||
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
ALTER TABLE t1 ADD COLUMN z int GENERATED ALWAYS AS
|
||||
( 1 NOT IN (SELECT 1 FROM t1 WHERE c0006) ) virtual;
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo # Bug#20566243: ERROR WHILE DOING CREATE TABLE T1 SELECT (QUERY ON GC COLUMNS)
|
||||
CREATE TABLE t1(a int, b int as (a + 1),
|
||||
c varchar(12) as ("aaaabb") stored, d blob as (c));
|
||||
INSERT INTO t1(a) VALUES(1),(3);
|
||||
SHOW CREATE TABLE t1;
|
||||
SELECT * FROM t1 order by a;
|
||||
CREATE TABLE t2 LIKE t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
CREATE TABLE t3 AS SELECT * FROM t1;
|
||||
SHOW CREATE TABLE t3;
|
||||
SELECT * FROM t3 order by a;
|
||||
CREATE TABLE t4 AS SELECT b,c,d FROM t1;
|
||||
SHOW CREATE TABLE t4;
|
||||
SELECT * FROM t4 order by b;
|
||||
DROP TABLE t1,t2,t3,t4;
|
||||
|
||||
--echo # Bug#21025003:WL8149:ASSERTION `CTX->NUM_TO_DROP_FK
|
||||
--echo # == HA_ALTER_INFO->ALTER_INFO-> FAILED
|
||||
--echo #
|
||||
CREATE TABLE t1 (
|
||||
col1 int(11) DEFAULT NULL,
|
||||
col2 int(11) DEFAULT NULL,
|
||||
col3 int(11) DEFAULT NULL,
|
||||
col4 int(11) DEFAULT NULL,
|
||||
col5 int(11) GENERATED ALWAYS AS (col4 / col2) VIRTUAL,
|
||||
col6 text
|
||||
);
|
||||
INSERT INTO t1(col1,col2,col3,col4,col6) VALUES(NULL,1,4,0,REPEAT(2,1000));
|
||||
--error ER_CANT_DROP_FIELD_OR_KEY
|
||||
ALTER TABLE t1 DROP PRIMARY KEY , ADD KEY idx ( col5, col2 );
|
||||
DROP TABLE t1;
|
||||
--echo # Bug#20949226:i CAN ASSIGN NON-DEFAULT() VALUE TO GENERATED COLUMN
|
||||
--echo #
|
||||
CREATE TABLE t1 (c1 INT, c2 INT AS (c1 * 2)) SELECT 1 AS c1, 5 AS c2;
|
||||
CREATE TABLE t2 (a int);
|
||||
INSERT INTO t2 values(1);
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (c1 INT, c2 INT AS (c1 * 2)) SELECT 1 AS c1, a AS c2 from t2;
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (c1 INT, c2 INT AS (c1 * 2)) SELECT 1 AS c1, 5;
|
||||
SELECT * FROM t1;
|
||||
DROP TABLE t1, t2;
|
||||
|
||||
if ($support_virtual_index)
|
||||
{
|
||||
--echo # Bug#21074624:i WL8149:SIG 11 INNOBASE_GET_COMPUTED_VALUE |
|
||||
--echo # INNOBASE/HANDLER/HA_INNODB.CC:19082
|
||||
CREATE TABLE t1 (
|
||||
col1 int(11) NOT NULL,
|
||||
col2 int(11) DEFAULT NULL,
|
||||
col3 int(11) NOT NULL,
|
||||
col4 int(11) DEFAULT NULL,
|
||||
col5 int(11) GENERATED ALWAYS AS (col2 % col4) VIRTUAL,
|
||||
col6 int(11) GENERATED ALWAYS AS (col3 + col3) VIRTUAL,
|
||||
col7 int(11) GENERATED ALWAYS AS (col5 / col5) VIRTUAL,
|
||||
col8 int(11) GENERATED ALWAYS AS (col6 / col5) VIRTUAL,
|
||||
col9 text,
|
||||
extra int(11) DEFAULT NULL,
|
||||
KEY idx (col5)
|
||||
);
|
||||
INSERT INTO t1(col1,col2,col3,col4,col9,extra)
|
||||
VALUES(0,6,3,4,REPEAT(4,1000),0);
|
||||
ALTER TABLE t1 DROP COLUMN col1;
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo # Bug#21390605:VALGRIND ERROR ON DELETE FROM TABLE CONTAINING
|
||||
--echo # AN INDEXED VIRTUAL COLUMN
|
||||
CREATE TABLE t1 (
|
||||
a INTEGER,
|
||||
b INTEGER GENERATED ALWAYS AS (a) VIRTUAL,
|
||||
c INTEGER GENERATED ALWAYS AS (b) VIRTUAL,
|
||||
INDEX idx (b,c)
|
||||
);
|
||||
INSERT INTO t1 (a) VALUES (42);
|
||||
DELETE FROM t1 WHERE c = 42;
|
||||
DROP TABLE t1;
|
||||
}
|
||||
|
||||
--echo # Bug#20757211: GENERATED COLUMNS: ALTER TABLE CRASHES
|
||||
--echo # IN FIND_FIELD_IN_TABLE
|
||||
--echo #
|
||||
CREATE TABLE t1(a int);
|
||||
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
ALTER TABLE t1 ADD COLUMN z int GENERATED ALWAYS AS
|
||||
( 1 NOT IN (SELECT 1 FROM t1 WHERE c0006) ) virtual;
|
||||
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
CREATE TABLE t2(a int, b int as (1 NOT IN (SELECT 1 FROM t1 WHERE not_exist_col)));
|
||||
--error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
CREATE TABLE t2(a int, b int as (1 NOT IN (SELECT 1 FROM dual)));
|
||||
DROP TABLE t1;
|
||||
|
||||
if(! $testing_ndb) {
|
||||
--echo # Bug#21142905: PARTITIONED GENERATED COLS -
|
||||
--echo # !TABLE || (!TABLE->WRITE_SET || BITMAP_IS_SET
|
||||
--echo #
|
||||
CREATE TABLE t1 (
|
||||
a int,
|
||||
b int generated always as (a) virtual,
|
||||
c int generated always as (b+a) virtual,
|
||||
d int generated always as (b+a) virtual
|
||||
) PARTITION BY LINEAR HASH (b);
|
||||
INSERT INTO t1(a) VALUES(0);
|
||||
DELETE FROM t1 WHERE c=1;
|
||||
DROP TABLE t1;
|
||||
}
|
||||
|
||||
--error ER_PARSE_ERROR
|
||||
CREATE TABLE t1 (c CHAR(10) CHARACTER SET utf8 COLLATE utf8_bin GENERATED ALWAYS AS ("foo bar"));
|
||||
CREATE TABLE t1 (i INT);
|
||||
--error ER_PARSE_ERROR
|
||||
ALTER TABLE t1 ADD COLUMN c CHAR(10) CHARACTER SET utf8 COLLATE utf8_bin GENERATED ALWAYS AS ("foo bar");
|
||||
DROP TABLE t1;
|
||||
--error ER_PARSE_ERROR
|
||||
CREATE TABLE t1 (i INT COLLATE utf8_bin, c INT COLLATE utf8_bin GENERATED ALWAYS AS (10));
|
||||
|
||||
--echo # Check for a charset mismatch processing:
|
||||
|
||||
--echo # Bug #21469535: VALGRIND ERROR (CONDITIONAL JUMP) WHEN INSERT
|
||||
--echo # ROWS INTO A PARTITIONED TABLE
|
||||
--echo #
|
||||
CREATE TABLE t1 (
|
||||
id INT NOT NULL,
|
||||
store_id INT NOT NULL,
|
||||
x INT GENERATED ALWAYS AS (id + store_id)
|
||||
)
|
||||
PARTITION BY RANGE (store_id) (
|
||||
PARTITION p0 VALUES LESS THAN (6),
|
||||
PARTITION p1 VALUES LESS THAN (11),
|
||||
PARTITION p2 VALUES LESS THAN (16),
|
||||
PARTITION p3 VALUES LESS THAN (21)
|
||||
);
|
||||
|
||||
INSERT INTO t1 VALUES(1, 2, default);
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo # Bug#21465626:ASSERT/CRASH ON DROPPING/ADDING VIRTUAL COLUMN
|
||||
CREATE TABLE t (a int(11), b int(11),
|
||||
c int(11) GENERATED ALWAYS AS (a+b) VIRTUAL,
|
||||
d int(11) GENERATED ALWAYS AS (a+b) VIRTUAL);
|
||||
INSERT INTO t(a,b) VALUES(1,2);
|
||||
--enable_info
|
||||
--echo # Mixed drop/add/rename virtual with non-virtual columns,
|
||||
--echo # ALGORITHM=INPLACE is not supported for InnoDB
|
||||
ALTER TABLE t DROP d, ADD e varchar(10);
|
||||
ALTER TABLE t ADD d int, ADD f char(10) AS ('aaa');
|
||||
ALTER TABLE t CHANGE d dd int, CHANGE f ff varchar(10) AS ('bbb');
|
||||
--echo # Only drop/add/change virtual, inplace is supported for Innodb
|
||||
ALTER TABLE t DROP c, DROP ff;
|
||||
ALTER TABLE t ADD c int(11) as (a+b), ADD f varchar(10) as ('aaa');
|
||||
ALTER TABLE t CHANGE c c int(11) as (a), CHANGE f f varchar(10) as('bbb');
|
||||
--echo # Change order should be ALGORITHM=INPLACE on Innodb
|
||||
ALTER TABLE t CHANGE c c int(11) as (a) after f;
|
||||
ALTER TABLE t CHANGE b b int(11) after c;
|
||||
--echo # TODO: Changing virtual column type should be ALGORITHM=INPLACE on InnoDB, current it goes only with COPY method
|
||||
ALTER TABLE t CHANGE c c varchar(10) as ('a');
|
||||
--echo # Changing stored column type is ALGORITHM=COPY
|
||||
ALTER TABLE t CHANGE dd d varchar(10);
|
||||
if ($support_virtual_index)
|
||||
{
|
||||
|
||||
#ALTER TABLE t ADD INDEX idx(a), ADD INDEX idx1(c);
|
||||
#ALTER TABLE t RENAME INDEX idx TO idx2, RENAME INDEX idx1 TO idx3;
|
||||
#ALTER TABLE t DROP INDEX idx2, DROP INDEX idx3;
|
||||
ALTER TABLE t ADD INDEX idx(c), ADD INDEX idx1(d);
|
||||
ALTER TABLE t DROP INDEX idx, DROP INDEX idx1;
|
||||
}
|
||||
--disable_info
|
||||
DROP TABLE t;
|
||||
|
||||
--echo # Bug#21854004: GCOLS:INNODB: FAILING ASSERTION: I < TABLE->N_DEF
|
||||
CREATE TABLE t1(
|
||||
col1 INTEGER PRIMARY KEY,
|
||||
col2 INTEGER,
|
||||
col3 INTEGER,
|
||||
col4 INTEGER,
|
||||
vgc1 INTEGER AS (col2 + col3) VIRTUAL,
|
||||
sgc1 INTEGER AS (col2 - col3) STORED
|
||||
);
|
||||
|
||||
INSERT INTO t1(col1, col2, col3) VALUES
|
||||
(1, 10, 100), (2, 20, 200);
|
||||
|
||||
SELECT * FROM t1 order by col1;
|
||||
|
||||
# Change expression of a virtual generated column
|
||||
ALTER TABLE t1 MODIFY COLUMN vgc1 INTEGER AS (col2 * col3) VIRTUAL;
|
||||
SELECT * FROM t1 order by col1;
|
||||
|
||||
# Change expression of a stored generated column
|
||||
ALTER TABLE t1 MODIFY COLUMN sgc1 INTEGER AS (col2 / col3) STORED;
|
||||
SELECT * FROM t1 order by col1;
|
||||
|
||||
ALTER TABLE t1 MODIFY COLUMN vgc1 INTEGER AS (col2 + col3) VIRTUAL;
|
||||
ALTER TABLE t1 MODIFY COLUMN sgc1 INTEGER AS (col2 - col3) STORED;
|
||||
|
||||
if ($support_virtual_index)
|
||||
{
|
||||
ALTER TABLE t1 ADD INDEX vgc1 (vgc1);
|
||||
}
|
||||
ALTER TABLE t1 ADD INDEX sgc1 (sgc1);
|
||||
|
||||
if ($support_virtual_index)
|
||||
{
|
||||
# Change expression of a virtual generated column, with index
|
||||
ALTER TABLE t1 MODIFY COLUMN vgc1 INTEGER AS (col2 * col3) VIRTUAL;
|
||||
SELECT * FROM t1 order by col1;
|
||||
SELECT vgc1 FROM t1 order by vgc1;
|
||||
}
|
||||
|
||||
# Change expression of a stored generated column, with index
|
||||
ALTER TABLE t1 MODIFY COLUMN sgc1 INTEGER AS (col2 / col3) STORED;
|
||||
SELECT * FROM t1 order by col1;
|
||||
SELECT sgc1 FROM t1 order by sgc1;
|
||||
|
||||
if ($support_virtual_index)
|
||||
{
|
||||
ALTER TABLE t1 DROP INDEX vgc1;
|
||||
}
|
||||
ALTER TABLE t1 DROP INDEX sgc1;
|
||||
|
||||
if ($support_virtual_index)
|
||||
{
|
||||
ALTER TABLE t1 MODIFY COLUMN vgc1 INTEGER AS (col2 + col3) VIRTUAL;
|
||||
ALTER TABLE t1 ADD UNIQUE INDEX vgc1 (vgc1);
|
||||
}
|
||||
ALTER TABLE t1 MODIFY COLUMN sgc1 INTEGER AS (col2 - col3) STORED;
|
||||
ALTER TABLE t1 ADD UNIQUE INDEX sgc1 (sgc1);
|
||||
|
||||
# Change expression of a virtual generated column, with unique index
|
||||
if ($support_virtual_index)
|
||||
{
|
||||
--error ER_DUP_ENTRY
|
||||
ALTER TABLE t1 MODIFY COLUMN vgc1 INTEGER AS (col2 / col3) VIRTUAL;
|
||||
}
|
||||
--error ER_DUP_ENTRY
|
||||
ALTER TABLE t1 MODIFY COLUMN sgc1 INTEGER AS (col2 / col3) STORED;
|
||||
|
||||
ALTER TABLE t1 MODIFY COLUMN vgc1 INTEGER AS (col2 * col3) VIRTUAL;
|
||||
SELECT * FROM t1 order by col1;
|
||||
SELECT vgc1 FROM t1 order by col1;
|
||||
|
||||
ALTER TABLE t1 MODIFY COLUMN sgc1 INTEGER AS (col2 * col3) STORED;
|
||||
SELECT * FROM t1 order by col1;
|
||||
SELECT sgc1 FROM t1 order by sgc1;
|
||||
|
||||
# Change virtual generated column to become stored
|
||||
--error ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN
|
||||
ALTER TABLE t1 MODIFY COLUMN vgc1 INTEGER AS (col2 * col3) STORED;
|
||||
|
||||
# Change stored generated column to become virtual
|
||||
--error ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN
|
||||
ALTER TABLE t1 MODIFY COLUMN sgc1 INTEGER AS (col2 / col3) VIRTUAL;
|
||||
|
||||
# Change base column to become stored generated column:
|
||||
ALTER TABLE t1 MODIFY COLUMN col4 INTEGER AS (col1 + col2 + col3) STORED;
|
||||
SELECT * FROM t1 order by col1;
|
||||
|
||||
# Change stored generated column to become base column:
|
||||
ALTER TABLE t1 MODIFY COLUMN col4 INTEGER;
|
||||
SELECT * FROM t1 order by col1;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
if ($support_virtual_index)
|
||||
{
|
||||
--echo #
|
||||
--echo # bug#22018979: RECORD NOT FOUND ON UPDATE,
|
||||
--echo # VIRTUAL COLUMN, ASSERTION 0
|
||||
--disable_warnings
|
||||
SET @sql_mode_save= @@sql_mode;
|
||||
SET sql_mode= 'ANSI';
|
||||
CREATE TABLE t1 (
|
||||
a INT,
|
||||
b VARCHAR(10),
|
||||
c CHAR(3) GENERATED ALWAYS AS (substr(b,1,3)) VIRTUAL,
|
||||
PRIMARY KEY (a),
|
||||
KEY c(c)
|
||||
);
|
||||
INSERT INTO t1(a, b) values(1, 'bbbb'), (2, 'cc');
|
||||
SHOW CREATE TABLE t1;
|
||||
SELECT * FROM t1 order by a;
|
||||
|
||||
SET sql_mode= '';
|
||||
FLUSH TABLE t1;
|
||||
SHOW CREATE TABLE t1;
|
||||
SELECT * FROM t1 order by a;
|
||||
DELETE FROM t1 where a= 2;
|
||||
|
||||
SET sql_mode= @sql_mode_save;
|
||||
DROP TABLE t1;
|
||||
--enable_warnings
|
||||
}
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # Bug#22680839: DEFAULT IS NOT DETERMINISTIC AND SHOULD NOT BE
|
||||
--echo # ALLOWED IN GENERATED COLUMNS
|
||||
--echo #
|
||||
if ($support_virtual_index)
|
||||
{
|
||||
CREATE TABLE tzz(a INT DEFAULT 5,
|
||||
gc1 INT AS (a+DEFAULT(a)) VIRTUAL,
|
||||
gc2 INT AS (a+DEFAULT(a)) STORED,
|
||||
KEY k1(gc1));
|
||||
INSERT INTO tzz(A) VALUES (1);
|
||||
SELECT * FROM tzz;
|
||||
SELECT gc1 FROM tzz;
|
||||
|
||||
ALTER TABLE tzz MODIFY COLUMN a INT DEFAULT 6;
|
||||
SELECT * FROM tzz;
|
||||
SELECT gc1 FROM tzz;
|
||||
DROP TABLE tzz;
|
||||
}
|
||||
|
||||
--echo # Test 1: ALTER DEFAULT
|
||||
--echo #
|
||||
CREATE TABLE t1(a INT PRIMARY KEY DEFAULT 5,
|
||||
b INT AS (1 + DEFAULT(a)) STORED,
|
||||
c INT AS (1 + DEFAULT(a)) VIRTUAL);
|
||||
INSERT INTO t1 VALUES ();
|
||||
--disable_warnings
|
||||
# Check how many rows are accessed: >0 = COPY
|
||||
--enable_info
|
||||
ALTER TABLE t1 ALTER COLUMN a SET DEFAULT 7;
|
||||
ALTER TABLE t1 MODIFY COLUMN a INT DEFAULT 8;
|
||||
ALTER TABLE t1 CHANGE COLUMN a a DOUBLE DEFAULT 5;
|
||||
--disable_info
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo # Test 2: ALTER DEFAULT + ADD GCOL
|
||||
--echo #
|
||||
CREATE TABLE t1(a INT PRIMARY KEY DEFAULT 5);
|
||||
INSERT INTO t1 VALUES();
|
||||
--enable_info
|
||||
ALTER TABLE t1 ALTER COLUMN a SET DEFAULT 7,
|
||||
ADD COLUMN b1 INT AS (1 + DEFAULT(a)) STORED;
|
||||
ALTER TABLE t1 ALTER COLUMN a SET DEFAULT 7,
|
||||
ADD COLUMN c1 INT AS (1 + DEFAULT(a)) VIRTUAL;
|
||||
--disable_info
|
||||
# Check how many rows are accessed: >0 = COPY
|
||||
--enable_info
|
||||
ALTER TABLE t1 ALTER COLUMN a SET DEFAULT 7,
|
||||
ADD COLUMN b INT AS (1 + DEFAULT(a)) STORED,
|
||||
ADD COLUMN c INT AS (1 + DEFAULT(a)) VIRTUAL;
|
||||
--disable_info
|
||||
DROP TABLE t1;
|
||||
--enable_warnings
|
43
mysql-test/suite/gcol/inc/gcol_dependancies_on_vcol.inc
Normal file
43
mysql-test/suite/gcol/inc/gcol_dependancies_on_vcol.inc
Normal file
|
@ -0,0 +1,43 @@
|
|||
################################################################################
|
||||
# inc/gcol_dependencies_on_gcol.inc #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Testing scenarios when columns depend on generated columns, i.e. such as #
|
||||
# - a generated column is based on a generated column #
|
||||
# - a "real" column on which a generated one is renamed/dropped #
|
||||
# - a generated column involved in partitioning is renamed/dropped #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-09-02 #
|
||||
# Change Author: #
|
||||
# Change Date: #
|
||||
# Change: #
|
||||
################################################################################
|
||||
|
||||
--echo # Can't define a generated column on another generated column
|
||||
--error ER_VCOL_BASED_ON_VCOL
|
||||
create table t1 (a int, b int generated always as (a+1) virtual, c int generated always as (b+1) virtual);
|
||||
create table t1 (a int, b int generated always as (a+1) virtual);
|
||||
--error ER_VCOL_BASED_ON_VCOL
|
||||
alter table t1 add column c int generated always as (b+1) virtual;
|
||||
drop table t1;
|
||||
|
||||
--echo # Can't rename or drop a column used in the function of a generated column
|
||||
create table t1 (a int, b int generated always as (a+1) virtual);
|
||||
--echo # On renaming/dropping a column on which a virtual field is
|
||||
--echo # defined the following error is displayed:
|
||||
--echo # "Unknown column 'a' in 'generated column function'"
|
||||
--error 1054
|
||||
alter table t1 drop column a;
|
||||
--error 1054
|
||||
alter table t1 change a c int;
|
||||
drop table t1;
|
||||
|
||||
--echo # Can't rename or drop a generated column used by the paritition function
|
||||
create table t1 (a int, b int generated always as (a+1) virtual) partition by hash(b);
|
||||
--error 1054
|
||||
alter table t1 drop b;
|
||||
--error 1054
|
||||
alter table t1 change b c int generated always as (a+1) virtual;
|
||||
|
77
mysql-test/suite/gcol/inc/gcol_handler.inc
Normal file
77
mysql-test/suite/gcol/inc/gcol_handler.inc
Normal file
|
@ -0,0 +1,77 @@
|
|||
################################################################################
|
||||
# inc/gcol_handler.inc #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Testing HANDLER. #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-09-04 #
|
||||
# Change Author: #
|
||||
# Change Date: #
|
||||
# Change: #
|
||||
################################################################################
|
||||
|
||||
create table t1 (a int,
|
||||
b int generated always as (-a) virtual,
|
||||
c int generated always as (-a) stored,
|
||||
d char(1),
|
||||
index (a),
|
||||
index (c));
|
||||
insert into t1 (a,d) values (4,'a'), (2,'b'), (1,'c'), (3,'d');
|
||||
select * from t1;
|
||||
|
||||
--echo # HANDLER tbl_name OPEN
|
||||
handler t1 open;
|
||||
|
||||
--echo # HANDLER tbl_name READ non-gcol_index_name > (value1,value2,...)
|
||||
handler t1 read a > (2);
|
||||
|
||||
--echo # HANDLER tbl_name READ non-gcol_index_name > (value1,value2,...) WHERE non-gcol_field=expr
|
||||
handler t1 read a > (2) where d='c';
|
||||
|
||||
--echo # HANDLER tbl_name READ gcol_index_name = (value1,value2,...)
|
||||
handler t1 read c = (-2);
|
||||
|
||||
--echo # HANDLER tbl_name READ gcol_index_name = (value1,value2,...) WHERE non-gcol_field=expr
|
||||
handler t1 read c = (-2) where d='c';
|
||||
|
||||
--echo # HANDLER tbl_name READ non-gcol_index_name > (value1,value2,...) WHERE gcol_field=expr
|
||||
handler t1 read a > (2) where b=-3 && c=-3;
|
||||
|
||||
--echo # HANDLER tbl_name READ gcol_index_name <= (value1,value2,...)
|
||||
handler t1 read c <= (-2);
|
||||
|
||||
--echo # HANDLER tbl_name READ gcol_index_name > (value1,value2,...) WHERE gcol_field=expr
|
||||
handler t1 read c <= (-2) where b=-3;
|
||||
|
||||
--echo # HANDLER tbl_name READ gcol_index_name FIRST
|
||||
handler t1 read c first;
|
||||
|
||||
--echo # HANDLER tbl_name READ gcol_index_name NEXT
|
||||
handler t1 read c next;
|
||||
|
||||
--echo # HANDLER tbl_name READ gcol_index_name PREV
|
||||
handler t1 read c prev;
|
||||
|
||||
--echo # HANDLER tbl_name READ gcol_index_name LAST
|
||||
handler t1 read c last;
|
||||
|
||||
--echo # HANDLER tbl_name READ FIRST where non-gcol=expr
|
||||
handler t1 read FIRST where a >= 2;
|
||||
|
||||
--echo # HANDLER tbl_name READ FIRST where gcol=expr
|
||||
handler t1 read FIRST where b >= -2;
|
||||
|
||||
--echo # HANDLER tbl_name READ NEXT where non-gcol=expr
|
||||
handler t1 read NEXT where d='c';
|
||||
|
||||
--echo # HANDLER tbl_name READ NEXT where gcol=expr
|
||||
handler t1 read NEXT where b<=-4;
|
||||
|
||||
--echo # HANDLER tbl_name CLOSE
|
||||
handler t1 close;
|
||||
|
||||
drop table t1;
|
609
mysql-test/suite/gcol/inc/gcol_ins_upd.inc
Normal file
609
mysql-test/suite/gcol/inc/gcol_ins_upd.inc
Normal file
|
@ -0,0 +1,609 @@
|
|||
################################################################################
|
||||
# inc/gcol_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: #
|
||||
# Change Date: #
|
||||
# Change: #
|
||||
################################################################################
|
||||
|
||||
let $create1 = create table t1 (a int,
|
||||
b int generated always as (-a) virtual,
|
||||
c int generated always as (-a) stored);
|
||||
let $create2 = create table t1 (a int unique,
|
||||
b int generated always as (-a) virtual,
|
||||
c int generated always as (-a) stored);
|
||||
let $create3 = create table t1 (a int,
|
||||
b int generated always as (-a) virtual,
|
||||
c int generated always as (-a) stored unique);
|
||||
let $create4 = create table t1 (a int,
|
||||
b int generated always as (-a) virtual,
|
||||
c int generated always as (-a) stored unique,
|
||||
d varchar(16));
|
||||
eval $create1;
|
||||
set sql_warnings = 1;
|
||||
|
||||
--echo #
|
||||
--echo # *** INSERT ***
|
||||
--echo #
|
||||
|
||||
--echo # INSERT INTO tbl_name VALUES... DEFAULT is specified against gcols
|
||||
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 gcols
|
||||
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 gcols
|
||||
insert into t1 values (1,2,3);
|
||||
select * from t1;
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
|
||||
--echo # INSERT INTO tbl_name (<non_gcol_list>) VALUES...
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1 order by a;
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
|
||||
--echo # INSERT INTO tbl_name (<normal+gcols>) VALUES... DEFAULT is specified
|
||||
--echo # against gcols
|
||||
insert into t1 (a,b) values (1,default), (2,default);
|
||||
select * from t1 order by a;
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
|
||||
--echo # INSERT INTO tbl_name (<normal+gcols>) VALUES... NULL is specified against gcols
|
||||
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+gcols>) VALUES... a non-NULL value is specified
|
||||
--echo # against gcols
|
||||
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-gcol field. INSERT INTO tbl_name VALUES... ON DUPLICATE
|
||||
--echo # KEY UPDATE <non_gcol>=expr, <gcol>=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 gcol field. INSERT INTO tbl_name VALUES... ON DUPLICATE
|
||||
--echo # KEY UPDATE <non_gcol>=expr, <gcol>=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(a) select a from t1;
|
||||
select * from t2;
|
||||
drop table t2;
|
||||
|
||||
--echo # CREATE new_table ... LIKE old_table INSERT INTO new_table (<non-gcols>, <gcols>)
|
||||
--echo # SELECT <non-gcols>, <gcols> from old_table
|
||||
insert into t1 values (1,default,default);
|
||||
select * from t1;
|
||||
create table t2 like t1;
|
||||
insert into t2 (a) select a from t1;
|
||||
select * from t2 order by a;
|
||||
drop table t2;
|
||||
drop table t1;
|
||||
|
||||
--echo #
|
||||
--echo # *** UPDATE ***
|
||||
--echo #
|
||||
|
||||
--echo # UPDATE tbl_name SET non-gcol=expr WHERE non-gcol=expr
|
||||
eval $create1;
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1 order by a;
|
||||
update t1 set a=3 where a=2;
|
||||
select * from t1 order by a;
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
|
||||
--echo # UPDATE tbl_name SET gcol=expr WHERE non-gcol=expr
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1 order by a;
|
||||
update t1 set c=3 where a=2;
|
||||
select * from t1 order by a;
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
|
||||
--echo # UPDATE tbl_name SET non-gcol=expr WHERE gcol=expr
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1 order by a;
|
||||
update t1 set a=3 where b=-2;
|
||||
select * from t1 order by a;
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
|
||||
--echo # UPDATE tbl_name SET gcol=expr WHERE gcol=expr
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1 order by a;
|
||||
update t1 set c=3 where b=-2;
|
||||
select * from t1 order by a;
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
drop table t1;
|
||||
|
||||
--echo # INDEX created on gcol
|
||||
--echo # UPDATE tbl_name SET non-gcol=expr WHERE gcol=const
|
||||
eval $create3;
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1 order by a;
|
||||
update t1 set a=3 where c=-2;
|
||||
select * from t1;
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
|
||||
|
||||
--echo # INDEX created on gcol
|
||||
--echo # UPDATE tbl_name SET non-gcol=expr WHERE gcol=between const1 and const2
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1 order by a;
|
||||
update t1 set a=3 where c between -3 and -2;
|
||||
select * from t1 order by a;
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
|
||||
--echo # No INDEX created on gcol
|
||||
--echo # UPDATE tbl_name SET non-gcol=expr WHERE gcol=between const1 and const2
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1 order by a;
|
||||
update t1 set a=3 where b between -3 and -2;
|
||||
select * from t1 order by a;
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
|
||||
--echo # INDEX created on gcol
|
||||
--echo # UPDATE tbl_name SET non-gcol=expr
|
||||
--echo # WHERE gcol=between const1 and const2 ORDER BY gcol
|
||||
insert into t1 (a) values (1), (2), (3), (4), (5);
|
||||
select * from t1 order by a;
|
||||
update t1 set a=6 where c between -1 and 0
|
||||
order by c;
|
||||
select * from t1 order by a;
|
||||
delete from t1 where c between -6 and 0;
|
||||
select * from t1;
|
||||
|
||||
--echo # INDEX created on gcol
|
||||
--echo # UPDATE tbl_name SET non-gcol=expr
|
||||
--echo # WHERE gcol=between const1 and const2 ORDER BY gcol LIMIT 2
|
||||
insert into t1 (a) values (1), (2), (3), (4), (5);
|
||||
select * from t1 order by a;
|
||||
update t1 set a=6 where c between -1 and 0
|
||||
order by c limit 2;
|
||||
select * from t1 order by a;
|
||||
delete from t1 where c between -2 and 0 order by c;
|
||||
select * from t1 order by a;
|
||||
delete from t1;
|
||||
|
||||
--echo # INDEX created on gcol
|
||||
--echo # UPDATE tbl_name SET non-gcol=expr
|
||||
--echo # WHERE indexed gcol=between const1 and const2 and non-indexed gcol=const3
|
||||
insert into t1 (a) values (1), (2), (3), (4), (5);
|
||||
select * from t1 order by a;
|
||||
update t1 set a=6 where (c between -2 and 0) and (b=-1);
|
||||
select * from t1 order by a;
|
||||
delete from t1;
|
||||
|
||||
--echo # INDEX created on gcol
|
||||
--echo # UPDATE tbl_name SET non-gcol=expr
|
||||
--echo # WHERE indexed gcol=between const1 and const2 and non-indexed gcol=const3
|
||||
--echo # ORDER BY indexed gcol
|
||||
insert into t1 (a) values (1), (2), (3), (4), (5);
|
||||
select * from t1 order by a;
|
||||
update t1 set a=6 where (c between -2 and 0) and (b=-1) order by c;
|
||||
select * from t1 order by a;
|
||||
delete from t1;
|
||||
drop table t1;
|
||||
|
||||
let $innodb_engine = `SELECT @@session.default_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 generated always as (a % 10) stored);
|
||||
insert into t2 values (1, 'value1'), (2,'value2'), (3,'value3');
|
||||
insert into t1 (a) values (1),(2),(3);
|
||||
select * from t1 order by a;
|
||||
select * from t2 order by a;
|
||||
select t1.a, t1.b, t2.name from t1,t2 where t1.b=t2.a order by t1.a;
|
||||
|
||||
--echo # - ON UPDATE RESTRICT
|
||||
alter table t1 add foreign key (b) references t2(a) on update restrict;
|
||||
--error 1452
|
||||
insert into t1 (a) values (4);
|
||||
--error 1451
|
||||
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 1451
|
||||
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 gcol
|
||||
--echo # REPLACE tbl_name (non-gcols) VALUES (non-gcols);
|
||||
eval $create4;
|
||||
insert into t1 (a,d) values (1,'a'), (2,'b');
|
||||
select * from t1 order by a;
|
||||
replace t1 (a,d) values (1,'c');
|
||||
select * from t1 order by a;
|
||||
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;
|
||||
|
||||
if ($innodb_engine) {
|
||||
--echo Bug#20170778: WL411:FAILING ASSERTION `!TABLE || (!TABLE->WRITE_SET ||
|
||||
--echo BITMAP_IS_SET(TABLE->WR
|
||||
--echo #
|
||||
CREATE TABLE t1 (col1 INT, col2 INT, col3 INT, col4 INT, col5
|
||||
INT GENERATED ALWAYS AS (col3 * col2) VIRTUAL, col6 INT GENERATED ALWAYS AS
|
||||
(col4 * col1) STORED, col7 INT GENERATED ALWAYS AS (col6 + col6) VIRTUAL,
|
||||
col8 INT GENERATED ALWAYS AS (col6 / col5) STORED, col9 TEXT);
|
||||
|
||||
SET @fill_amount = (@@innodb_page_size / 2 ) + 1;
|
||||
|
||||
INSERT INTO t1 (col1,col2,col3,col4,col5,col6,col7,col8,col9) VALUES /* 3 */
|
||||
(3, 3 / 3, 3 + 3, 3 / 3, DEFAULT, DEFAULT, DEFAULT, DEFAULT ,REPEAT(CAST(3 AS
|
||||
CHAR(1)),@fill_amount)) , (3, 3 * 3, 3 + 3, 3 / 3, DEFAULT, DEFAULT, DEFAULT,
|
||||
DEFAULT ,REPEAT(CAST(3 AS CHAR(1)),@fill_amount));
|
||||
|
||||
UPDATE t1 SET col1 = 2;
|
||||
UPDATE t1 SET col7 = DEFAULT;
|
||||
UPDATE t1 SET col8 = DEFAULT;
|
||||
DROP TABLE t1;
|
||||
}
|
||||
|
||||
if ($support_virtual_index)
|
||||
{
|
||||
--echo Bug#20797344: WL#8149: ALLOCATED SPACE FOR INDEXED BLOB VGC CAN BE
|
||||
--echo OVERWRITTEN FOR UPDATE
|
||||
--echo #
|
||||
CREATE TABLE t (a varchar(100), b blob,
|
||||
c blob GENERATED ALWAYS AS (concat(a,b)) VIRTUAL,
|
||||
d blob GENERATED ALWAYS AS (b) VIRTUAL,
|
||||
e int(11) GENERATED ALWAYS AS (10) VIRTUAL,
|
||||
h int(11) NOT NULL, PRIMARY KEY (h), key(c(20)));
|
||||
INSERT INTO t(a,b,h) VALUES('aaaaaaa','1111111', 11);
|
||||
INSERT INTO t(a,b,h) VALUES('bbbbbbb','2222222', 22);
|
||||
SELECT c FROM t;
|
||||
UPDATE t SET a='ccccccc';
|
||||
SELECT c FROM t;
|
||||
DROP TABLE t;
|
||||
}
|
||||
|
||||
--echo # Bug#21081742: ASSERTION !TABLE || (!TABLE->WRITE_SET ||
|
||||
--echo # BITMAP_IS_SET(TABLE->WRITE_SET
|
||||
--echo #
|
||||
|
||||
CREATE TABLE b (
|
||||
pk INTEGER AUTO_INCREMENT,
|
||||
col_varchar_nokey VARCHAR(1),
|
||||
col_varchar_key VARCHAR(2) GENERATED ALWAYS AS
|
||||
(CONCAT(col_varchar_nokey, col_varchar_nokey)),
|
||||
PRIMARY KEY (pk)
|
||||
);
|
||||
|
||||
INSERT INTO b (col_varchar_nokey) VALUES ('v'),('v');
|
||||
|
||||
CREATE TABLE d (
|
||||
pk INTEGER AUTO_INCREMENT,
|
||||
col_varchar_nokey VARCHAR(1),
|
||||
col_varchar_key VARCHAR(2) GENERATED ALWAYS AS
|
||||
(CONCAT(col_varchar_nokey, col_varchar_nokey)),
|
||||
PRIMARY KEY (pk)
|
||||
) ;
|
||||
|
||||
INSERT INTO d (col_varchar_nokey) VALUES ('q'),('g'),('e'),('l'),(NULL),('v'),('c'),('u'),('x');
|
||||
|
||||
CREATE TABLE bb (
|
||||
pk INTEGER AUTO_INCREMENT,
|
||||
col_varchar_nokey VARCHAR(1) /*! NULL */,
|
||||
col_varchar_key VARCHAR(2) GENERATED ALWAYS AS
|
||||
(CONCAT(col_varchar_nokey, col_varchar_nokey)),
|
||||
PRIMARY KEY (pk)
|
||||
);
|
||||
|
||||
INSERT INTO bb (col_varchar_nokey) VALUES ('j'),('h');
|
||||
|
||||
EXPLAIN UPDATE
|
||||
d AS OUTR1, b AS OUTR2
|
||||
SET OUTR1.col_varchar_nokey = NULL
|
||||
WHERE
|
||||
( 't', 'b' ) IN
|
||||
(
|
||||
SELECT
|
||||
INNR1.col_varchar_nokey AS x,
|
||||
INNR1.col_varchar_key AS y
|
||||
FROM bb AS INNR1
|
||||
WHERE OUTR1.pk = 1
|
||||
);
|
||||
|
||||
DROP TABLE IF EXISTS b,bb,d;
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # Bug#21216067 ASSERTION FAILED ROW_UPD_SEC_INDEX_ENTRY (INNOBASE/ROW/ROW0UPD.CC:2103)
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t (
|
||||
x INT, y INT, gc INT GENERATED ALWAYS AS (x+1) STORED
|
||||
);
|
||||
INSERT INTO t VALUES ();
|
||||
UPDATE t t1, t t2 SET t2.y = 1, t1.x = 2;
|
||||
SELECT * FROM t;
|
||||
DROP TABLE t;
|
||||
|
||||
if ($support_virtual_index)
|
||||
{
|
||||
CREATE TABLE t (
|
||||
x INT, y INT, gc INT GENERATED ALWAYS AS (x+1), KEY (x,gc)
|
||||
);
|
||||
INSERT INTO t VALUES ();
|
||||
UPDATE t t1, t t2 SET t1.x = 1, t2.y = 2;
|
||||
SELECT * FROM t;
|
||||
SELECT gc FROM t;
|
||||
DROP TABLE t;
|
||||
}
|
||||
|
||||
let $query=
|
||||
UPDATE C AS OUTR1, C AS OUTR2
|
||||
SET OUTR1.`col_varchar_nokey` = 'f',
|
||||
OUTR2.`col_varchar_nokey` = "a";
|
||||
|
||||
--echo # stored
|
||||
|
||||
CREATE TABLE C (
|
||||
col_varchar_nokey VARCHAR(1),
|
||||
col_varchar_key VARCHAR(2) GENERATED ALWAYS AS
|
||||
(CONCAT(col_varchar_nokey, col_varchar_nokey)) STORED
|
||||
);
|
||||
|
||||
INSERT INTO C (col_varchar_nokey) VALUES ('c');
|
||||
eval EXPLAIN $query;
|
||||
eval $query;
|
||||
SELECT * from C;
|
||||
DROP TABLE C;
|
||||
|
||||
--echo # stored, indexed
|
||||
|
||||
CREATE TABLE C (
|
||||
col_varchar_nokey VARCHAR(1),
|
||||
col_varchar_key VARCHAR(2) GENERATED ALWAYS AS
|
||||
(CONCAT(col_varchar_nokey, col_varchar_nokey)) STORED,
|
||||
KEY (col_varchar_key, col_varchar_nokey)
|
||||
);
|
||||
|
||||
INSERT INTO C (col_varchar_nokey) VALUES ('c');
|
||||
eval EXPLAIN $query;
|
||||
eval $query;
|
||||
SELECT * from C;
|
||||
DROP TABLE C;
|
||||
|
||||
--echo # virtual
|
||||
|
||||
CREATE TABLE C (
|
||||
col_varchar_nokey VARCHAR(1),
|
||||
col_varchar_key VARCHAR(2) GENERATED ALWAYS AS
|
||||
(CONCAT(col_varchar_nokey, col_varchar_nokey)) VIRTUAL
|
||||
);
|
||||
|
||||
INSERT INTO C (col_varchar_nokey) VALUES ('c');
|
||||
eval EXPLAIN $query;
|
||||
eval $query;
|
||||
SELECT * from C;
|
||||
DROP TABLE C;
|
||||
|
||||
if ($support_virtual_index)
|
||||
{
|
||||
--echo # virtual, indexed
|
||||
|
||||
CREATE TABLE C (
|
||||
col_varchar_nokey VARCHAR(1),
|
||||
col_varchar_key VARCHAR(2) GENERATED ALWAYS AS
|
||||
(CONCAT(col_varchar_nokey, col_varchar_nokey)) VIRTUAL,
|
||||
KEY (col_varchar_key, col_varchar_nokey)
|
||||
);
|
||||
|
||||
INSERT INTO C (col_varchar_nokey) VALUES ('c');
|
||||
eval EXPLAIN $query;
|
||||
eval $query;
|
||||
SELECT * from C;
|
||||
DROP TABLE C;
|
||||
|
||||
--echo #
|
||||
--echo # Bug #21530366 CRASH/ASSERTION, CORRUPTION WITH INDEXES +
|
||||
--echo # VIRTUAL COLUMNS, BLOB
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t (
|
||||
a INTEGER,
|
||||
b BLOB GENERATED ALWAYS AS (a) VIRTUAL,
|
||||
INDEX (b(57))
|
||||
);
|
||||
|
||||
INSERT INTO t (a) VALUES (9);
|
||||
UPDATE t SET a = 10;
|
||||
DELETE FROM t WHERE a = 10;
|
||||
|
||||
DROP TABLE t;
|
||||
|
||||
--echo # Bug#21807818: Generated columns not updated with empty insert list
|
||||
|
||||
CREATE TABLE t (
|
||||
a BLOB GENERATED ALWAYS AS ('') VIRTUAL,
|
||||
b TIMESTAMP(4) GENERATED ALWAYS AS ('') VIRTUAL,
|
||||
KEY (a(183),b)
|
||||
);
|
||||
|
||||
INSERT INTO t VALUES(), (), ();
|
||||
|
||||
DELETE IGNORE FROM t;
|
||||
|
||||
DROP TABLE t;
|
||||
|
||||
--echo #
|
||||
--echo # Bug#22195458:GCOLS: ASSERTION 0 AND CORRUPTION...
|
||||
--echo #
|
||||
--disable_warnings
|
||||
CREATE TABLE t (
|
||||
a INT,
|
||||
b YEAR GENERATED ALWAYS AS ('a') VIRTUAL,
|
||||
c YEAR GENERATED ALWAYS AS ('aaaa') VIRTUAL,
|
||||
b1 YEAR GENERATED ALWAYS AS ('a') STORED,
|
||||
c1 YEAR GENERATED ALWAYS AS ('aaaa') STORED,
|
||||
UNIQUE(b),
|
||||
UNIQUE(b1)
|
||||
);
|
||||
INSERT INTO t VALUES();
|
||||
SELECT b from t;
|
||||
SELECT b1 from t;
|
||||
SELECT * from t;
|
||||
DELETE FROM t;
|
||||
CHECK TABLE t EXTENDED;
|
||||
DROP TABLE t;
|
||||
--enable_warnings
|
||||
|
||||
--echo # Bug#22195364:GCOLS: FAILING ASSERTION:
|
||||
--echo # DFIELD_IS_NULL(DFIELD2) || DFIELD2->DATA
|
||||
CREATE TABLE t (
|
||||
a INT,
|
||||
c BLOB GENERATED ALWAYS AS ('') VIRTUAL,
|
||||
UNIQUE KEY(c(1),a)
|
||||
);
|
||||
INSERT INTO t(a) VALUES(1) ON DUPLICATE KEY UPDATE a=2;
|
||||
SELECT * FROM t;
|
||||
INSERT INTO t(a) VALUES(1) ON DUPLICATE KEY UPDATE a=2;
|
||||
SELECT * FROM t;
|
||||
# Test Field_blob::store_to_mem
|
||||
SELECT GROUP_CONCAT(c ORDER BY c) FROM t;
|
||||
DROP TABLE t;
|
||||
}
|
||||
|
||||
--echo #Bug#21929967:GCOLS:GCOL VALUE CHANGES WHEN SESSION CHANGES SQL_MODE
|
||||
CREATE TABLE t(c1 INT GENERATED ALWAYS AS (1) VIRTUAL,
|
||||
c2 INT GENERATED ALWAYS AS(2) STORED);
|
||||
INSERT INTO t VALUES(DEFAULT, DEFAULT);
|
||||
SELECT * FROM t;
|
||||
CREATE TABLE t1(c1 INT, c2 INT GENERATED ALWAYS AS(c1 + 1) STORED);
|
||||
INSERT INTO t1(c2) VALUES(DEFAULT);
|
||||
SELECT * FROM t1;
|
||||
CREATE TABLE t2(c1 INT DEFAULT 1, c2 INT GENERATED ALWAYS AS(c1 + 1) STORED);
|
||||
INSERT INTO t2(c2) VALUES(DEFAULT);
|
||||
SELECT * FROM t2;
|
||||
DROP TABLE t, t1, t2;
|
||||
|
||||
--echo # Bug#22179637: INSERT INTO TABLE FROM SELECT ACCEPTS TO INSERT INTO
|
||||
--echo # GENERATED COLUMNS
|
||||
CREATE TABLE t1 (
|
||||
i1 INTEGER,
|
||||
i2 INTEGER GENERATED ALWAYS AS (i1 + i1)
|
||||
);
|
||||
INSERT INTO t1 (i1) SELECT 5;
|
||||
INSERT INTO t1 (i1) SELECT 5 ON DUPLICATE KEY UPDATE i2= DEFAULT;
|
||||
SELECT * FROM t1;
|
||||
|
||||
CREATE TABLE t2 (
|
||||
i1 INTEGER,
|
||||
i2 INTEGER GENERATED ALWAYS AS (i1 + i1) STORED
|
||||
);
|
||||
INSERT INTO t2 (i1) SELECT 5;
|
||||
INSERT INTO t2 (i1) SELECT 5 ON DUPLICATE KEY UPDATE i2= DEFAULT;
|
||||
SELECT * FROM t2;
|
||||
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
if ($support_virtual_index)
|
||||
{
|
||||
|
||||
--echo #
|
||||
--echo # Bug#22070021 GCOL:ASSERTION `!TABLE || (!TABLE->WRITE_SET ||
|
||||
--echo # BITMAP_IS_SET(TABLE->WRITE_SET,
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1(
|
||||
c1 INT,
|
||||
c2 INT GENERATED ALWAYS AS (c1 + c1) VIRTUAL,
|
||||
KEY(c2)
|
||||
);
|
||||
|
||||
INSERT INTO t1(c1) VALUES(0);
|
||||
DELETE O1.* FROM t1 AS O1, t1 AS O2;
|
||||
SELECT * FROM t1;
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo #
|
||||
--echo # Bug#21944199 SIMPLE DELETE QUERY CAUSES INNODB: FAILING ASSERTION: 0
|
||||
--echo # & DATA CORRUPTION
|
||||
--echo #
|
||||
|
||||
CREATE TEMPORARY TABLE t1 (
|
||||
a INTEGER NOT NULL,
|
||||
b INTEGER GENERATED ALWAYS AS (a+1) VIRTUAL
|
||||
);
|
||||
|
||||
INSERT INTO t1 (a) VALUES (0), (0), (0);
|
||||
|
||||
ALTER TABLE t1 ADD INDEX idx (b);
|
||||
|
||||
DELETE FROM t1;
|
||||
|
||||
DROP TEMPORARY TABLE t1;
|
||||
|
||||
}
|
766
mysql-test/suite/gcol/inc/gcol_keys.inc
Normal file
766
mysql-test/suite/gcol/inc/gcol_keys.inc
Normal file
|
@ -0,0 +1,766 @@
|
|||
################################################################################
|
||||
# inc/gcol_keys.inc #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Testing keys, indexes defined upon generated columns. #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-09-02 #
|
||||
# Change Author: #
|
||||
# Change Date: #
|
||||
# Change: #
|
||||
################################################################################
|
||||
|
||||
if (!$support_virtual_index) {
|
||||
let $skip_spatial_index_check=1;
|
||||
}
|
||||
|
||||
--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
|
||||
if($support_virtual_index)
|
||||
{
|
||||
create table t1 (a int, b int generated always as (a*2) virtual unique);
|
||||
show create table t1;
|
||||
describe t1;
|
||||
drop table t1;
|
||||
}
|
||||
create table t1 (a int, b int generated always as (a*2) stored unique);
|
||||
show create table t1;
|
||||
describe t1;
|
||||
drop table t1;
|
||||
|
||||
if($support_virtual_index)
|
||||
{
|
||||
create table t1 (a int, b int generated always as (a*2) virtual, unique key (b));
|
||||
show create table t1;
|
||||
describe t1;
|
||||
drop table t1;
|
||||
}
|
||||
create table t1 (a int, b int generated always as (a*2) stored, unique (b));
|
||||
show create table t1;
|
||||
describe t1;
|
||||
drop table t1;
|
||||
|
||||
if($support_virtual_index)
|
||||
{
|
||||
create table t1 (a int, b int generated always as (a*2) virtual);
|
||||
alter table t1 add unique key (b);
|
||||
drop table t1;
|
||||
}
|
||||
create table t1 (a int, b int generated always as (a*2) stored);
|
||||
alter table t1 add unique key (b);
|
||||
drop table t1;
|
||||
|
||||
--echo # Testing data manipulation operations involving UNIQUE keys
|
||||
--echo # on generated columns can be found in:
|
||||
--echo # - gcol_ins_upd.inc
|
||||
--echo # - gcol_select.inc
|
||||
|
||||
--echo #
|
||||
--echo # INDEX
|
||||
if($support_virtual_index)
|
||||
{
|
||||
create table t1 (a int, b int generated always as (a*2) virtual, index (b));
|
||||
show create table t1;
|
||||
describe t1;
|
||||
drop table t1;
|
||||
|
||||
create table t1 (a int, b int generated always as (a*2) virtual, index (a,b));
|
||||
drop table t1;
|
||||
}
|
||||
|
||||
create table t1 (a int, b int generated always as (a*2) stored, index (b));
|
||||
show create table t1;
|
||||
describe t1;
|
||||
drop table t1;
|
||||
|
||||
create table t1 (a int, b int generated always as (a*2) stored, index (a,b));
|
||||
show create table t1;
|
||||
describe t1;
|
||||
drop table t1;
|
||||
|
||||
if($support_virtual_index)
|
||||
{
|
||||
create table t1 (a int, b int generated always as (a*2) virtual);
|
||||
alter table t1 add index (b);
|
||||
|
||||
alter table t1 add index (a,b);
|
||||
drop table t1;
|
||||
}
|
||||
|
||||
create table t1 (a int, b int generated always as (a*2) stored);
|
||||
alter table t1 add index (b);
|
||||
drop table t1;
|
||||
|
||||
create table t1 (a int, b int generated always as (a*2) stored);
|
||||
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 generated columns can be found in:
|
||||
--echo # - gcol_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 geometrical"
|
||||
--error 1687
|
||||
create table t1 (a int, b int generated always as (a+1) stored, spatial index (b));
|
||||
create table t1 (a int, b int generated always as (a+1) stored);
|
||||
--error 1687
|
||||
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 generated always as (a+1) stored,
|
||||
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 generated always as (a+1) stored,
|
||||
foreign key (b) references t2(a) on update cascade);
|
||||
--error ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN
|
||||
create table t1 (a int, b int generated always as (a+1) stored,
|
||||
foreign key (b) references t2(a) on delete set null);
|
||||
|
||||
create table t1 (a int, b int generated always as (a+1) stored);
|
||||
--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;
|
||||
|
||||
if($support_virtual_index)
|
||||
{
|
||||
--error ER_CANT_CREATE_TABLE
|
||||
create table t1 (a int, b int generated always as (a+1) virtual,
|
||||
foreign key (b) references t2(a));
|
||||
|
||||
create table t1 (a int, b int generated always as (a+1) virtual);
|
||||
--replace_regex /`#sql-.*`/`#sql-temporary`/
|
||||
--error ER_CANT_CREATE_TABLE
|
||||
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 generated always as (a % 10) stored,
|
||||
foreign key (b) references t2(a) on update restrict);
|
||||
drop table t1;
|
||||
create table t1 (a int, b int generated always as (a % 10) stored,
|
||||
foreign key (b) references t2(a) on update no action);
|
||||
drop table t1;
|
||||
create table t1 (a int, b int generated always as (a % 10) stored,
|
||||
foreign key (b) references t2(a) on delete restrict);
|
||||
drop table t1;
|
||||
create table t1 (a int, b int generated always as (a % 10) stored,
|
||||
foreign key (b) references t2(a) on delete cascade);
|
||||
drop table t1;
|
||||
create table t1 (a int, b int generated always as (a % 10) stored,
|
||||
foreign key (b) references t2(a) on delete no action);
|
||||
drop table t1,t2;
|
||||
|
||||
if($support_virtual_index)
|
||||
{
|
||||
--echo #
|
||||
--echo # Bug#20553262: WL8149: ASSERTION `DELSUM+(INT) Y/4-TEMP >= 0' FAILED
|
||||
--echo #
|
||||
CREATE TABLE c (
|
||||
pk integer AUTO_INCREMENT,
|
||||
col_datetime_nokey DATETIME /*! NULL */,
|
||||
col_time_nokey TIME /*! NULL */,
|
||||
col_datetime_key DATETIME GENERATED ALWAYS AS
|
||||
(ADDTIME(col_datetime_nokey, col_time_nokey)),
|
||||
col_time_key TIME GENERATED ALWAYS AS
|
||||
(ADDTIME(col_datetime_nokey, col_time_nokey)),
|
||||
col_varchar_nokey VARCHAR(1) /*! NULL */,
|
||||
PRIMARY KEY (pk),
|
||||
KEY (col_time_key),
|
||||
KEY (col_datetime_key));
|
||||
|
||||
INSERT INTO c ( col_time_nokey,col_datetime_nokey,col_varchar_nokey) values
|
||||
('14:03:03.042673','2001-11-28 00:50:27.051028', 'c'),
|
||||
('01:46:09.016386','2007-10-09 19:53:04.008332', NULL),
|
||||
('16:21:18.052408','2001-11-08 21:02:12.009395', 'x'),
|
||||
('18:56:33.027423','2003-04-01 00:00:00', 'i');
|
||||
|
||||
--replace_column 10 x 11 x
|
||||
EXPLAIN SELECT
|
||||
outr.col_time_key AS x
|
||||
FROM c as outr
|
||||
WHERE
|
||||
outr.col_varchar_nokey in ('c', 'x', 'i')
|
||||
AND (outr.col_time_key IS NULL OR
|
||||
outr.col_datetime_key = '2009-09-27');
|
||||
|
||||
SELECT
|
||||
outr.col_time_key AS x
|
||||
FROM c AS outr
|
||||
WHERE
|
||||
outr.col_varchar_nokey in ('c', 'x', 'i')
|
||||
AND (outr.col_time_key IS NULL OR
|
||||
outr.col_datetime_key = '2009-09-27');
|
||||
|
||||
DROP TABLE c;
|
||||
|
||||
--echo #
|
||||
--echo # Bug#20913803: WL8149: SIG 11 IN DFIELD_DUP |
|
||||
--echo # INNOBASE/INCLUDE/DATA0DATA.IC:253
|
||||
--echo #
|
||||
CREATE TABLE A (
|
||||
col_varchar_nokey TEXT ,
|
||||
col_varchar_key TEXT GENERATED ALWAYS AS (REPEAT(col_varchar_nokey, 1000)),
|
||||
KEY (col_varchar_key(50))
|
||||
);
|
||||
|
||||
INSERT INTO A (col_varchar_nokey) VALUES ('');
|
||||
|
||||
CREATE TABLE D (
|
||||
pk INTEGER AUTO_INCREMENT,
|
||||
col_date_nokey BLOB,
|
||||
col_date_key BLOB GENERATED ALWAYS AS (REPEAT(col_date_nokey,1000)) VIRTUAL,
|
||||
col_datetime_nokey LONGBLOB,
|
||||
col_time_nokey LONGTEXT,
|
||||
|
||||
col_datetime_key LONGBLOB GENERATED ALWAYS AS (REPEAT(col_datetime_nokey, 1000)),
|
||||
col_time_key LONGTEXT GENERATED ALWAYS AS (REPEAT(col_datetime_nokey, 1000)),
|
||||
|
||||
col_varchar_nokey TEXT,
|
||||
col_varchar_key TEXT GENERATED ALWAYS AS (REPEAT(col_varchar_nokey, 1000)),
|
||||
|
||||
PRIMARY KEY (pk),
|
||||
KEY (col_varchar_key(50)),
|
||||
KEY (col_date_key(20)),
|
||||
KEY (col_time_key(20)),
|
||||
KEY (col_datetime_key(20)),
|
||||
KEY (col_varchar_key(10), col_date_key(10), col_time_key(5), col_datetime_key(5))
|
||||
);
|
||||
|
||||
INSERT INTO D (
|
||||
col_date_nokey,
|
||||
col_time_nokey,
|
||||
col_datetime_nokey,
|
||||
col_varchar_nokey
|
||||
) VALUES ('', '', '', ''),('', '', '', '');
|
||||
|
||||
DELETE FROM OUTR1.* USING D AS OUTR1 RIGHT JOIN A AS OUTR2 ON
|
||||
( OUTR1 . `col_varchar_nokey` = OUTR2 . `col_varchar_nokey` );
|
||||
|
||||
DROP TABLE IF EXISTS A,D;
|
||||
--echo #
|
||||
--echo # Bug#21024896: SIG 11 INNOBASE_ADD_ONE_VIRTUAL |
|
||||
--echo # INNOBASE/HANDLER/HANDLER0ALTER.CC
|
||||
--echo #
|
||||
CREATE TABLE t1 (
|
||||
col1 int(11) DEFAULT NULL,
|
||||
col2 int(11) DEFAULT NULL,
|
||||
col3 int(11) NOT NULL,
|
||||
col4 int(11) DEFAULT NULL,
|
||||
col5 int(11) GENERATED ALWAYS AS (col2 / col2) VIRTUAL,
|
||||
col7 int(11) GENERATED ALWAYS AS (col5 + col5) VIRTUAL,
|
||||
col8 int(11) GENERATED ALWAYS AS (col5 * col5) VIRTUAL,
|
||||
col9 text,
|
||||
col6 int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (`col3`),
|
||||
UNIQUE KEY uidx (`col2`),
|
||||
KEY idx (`col5`)
|
||||
);
|
||||
|
||||
INSERT INTO t1(col1,col2,col3,col4,col9,col6)
|
||||
VALUES(1,1,0,1,REPEAT(col1,1000),0), (3,2,1,1,REPEAT(col1,1000),NULL);
|
||||
|
||||
ALTER TABLE t1 ADD COLUMN extra INT;
|
||||
DROP TABLE t1;
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # Bug#21316860: WL8149:INNODB: FAILING ASSERTION:
|
||||
--echo # TEMPL->CLUST_REC_FIELD_NO != ULINT_UNDEFINED
|
||||
--echo #
|
||||
CREATE TABLE t1 (
|
||||
pk int(11) NOT NULL,
|
||||
col_int_nokey int(11),
|
||||
col_int_key int(11) GENERATED ALWAYS AS (col_int_nokey) VIRTUAL,
|
||||
col_date_nokey date,
|
||||
col_date_key date GENERATED ALWAYS AS (col_date_nokey) VIRTUAL,
|
||||
PRIMARY KEY (pk),
|
||||
UNIQUE KEY col_int_key (col_int_key)
|
||||
);
|
||||
|
||||
ALTER TABLE t1 DROP COLUMN pk;
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo # Remove the impact on PK choose by index on virtual generated column
|
||||
CREATE TABLE t1 (
|
||||
pk int(11) NOT NULL,
|
||||
col_int_nokey int(11) DEFAULT NULL,
|
||||
col_int_key int(11) GENERATED ALWAYS AS (col_int_nokey) VIRTUAL,
|
||||
UNIQUE KEY col_int_key (col_int_key)
|
||||
);
|
||||
|
||||
ALTER TABLE t1 add unique index idx(pk), algorithm=inplace;
|
||||
DESC t1;
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo #
|
||||
--echo # Bug#21346132: WL8149:INNODB: FAILING ASSERTION:
|
||||
--echo # PRIMARY_KEY_NO == -1 || PRIMARY_KEY_NO == 0
|
||||
--echo #
|
||||
CREATE TABLE t1 (
|
||||
col_int_nokey int(11) NOT NULL,
|
||||
col_int_key int(11) GENERATED ALWAYS AS (col_int_nokey),
|
||||
col_varchar_nokey varchar(1) NOT NULL,
|
||||
col_varchar_key varchar(2) GENERATED ALWAYS AS (col_varchar_nokey),
|
||||
UNIQUE KEY col_int_key (col_int_key),
|
||||
UNIQUE KEY col_varchar_key (col_varchar_key),
|
||||
UNIQUE KEY col_int_key_2 (col_int_key,col_varchar_key),
|
||||
UNIQUE KEY col_varchar_key_2 (col_varchar_key,col_varchar_nokey),
|
||||
KEY col_int_key_3 (col_int_key,col_int_nokey)
|
||||
);
|
||||
|
||||
ALTER TABLE t1 DROP COLUMN col_varchar_key;
|
||||
DROP TABLE t1;
|
||||
--echo #
|
||||
--echo # Bug#21320151 WL8149: WRONG RESULT WITH INDEX SCAN
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (
|
||||
id INTEGER NOT NULL,
|
||||
b INTEGER GENERATED ALWAYS AS (id+1) VIRTUAL,
|
||||
UNIQUE KEY (b)
|
||||
);
|
||||
|
||||
INSERT INTO t1 (id) VALUES (2),(3),(4),(5),(6),(7),(8),(9),(10);
|
||||
|
||||
--disable_query_log
|
||||
--disable_result_log
|
||||
ANALYZE TABLE t1;
|
||||
--enable_result_log
|
||||
--enable_query_log
|
||||
|
||||
# covering index scan
|
||||
let query= SELECT b FROM t1 FORCE INDEX(b);
|
||||
eval EXPLAIN $query;
|
||||
eval $query;
|
||||
|
||||
# range scan
|
||||
let $query= SELECT b FROM t1 FORCE INDEX(b) WHERE b BETWEEN 1 AND 5;
|
||||
eval EXPLAIN $query;
|
||||
eval $query;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
}
|
||||
--echo
|
||||
--echo # Testing data manipulation operations involving FOREIGN KEY
|
||||
--echo # on generated columns can be found in:
|
||||
--echo # - gcol_ins_upd.inc
|
||||
--echo # - gcol_select.inc
|
||||
|
||||
--echo #
|
||||
--echo # TODO: CHECK
|
||||
|
||||
--echo #
|
||||
--echo # Test how optimizer picks indexes defined on a GC
|
||||
--echo #
|
||||
CREATE TABLE t1 (f1 int, gc int AS (f1 + 1) STORED, UNIQUE(gc));
|
||||
INSERT INTO t1(f1) VALUES (1),(2),(0),(9),(3),(4),(8),(7),(5),(6);
|
||||
ANALYZE TABLE t1;
|
||||
--echo # Should use index
|
||||
--sorted_result
|
||||
SELECT * FROM t1 WHERE f1 + 1 > 7;
|
||||
EXPLAIN SELECT * FROM t1 WHERE f1 + 1 > 7;
|
||||
|
||||
SELECT * FROM t1 WHERE f1 + 1 = 7;
|
||||
EXPLAIN SELECT * FROM t1 WHERE f1 + 1 = 7;
|
||||
--sorted_result
|
||||
SELECT * FROM t1 WHERE f1 + 1 IN (7,5);
|
||||
EXPLAIN SELECT * FROM t1 WHERE f1 + 1 IN(7,5);
|
||||
--sorted_result
|
||||
SELECT * FROM t1 WHERE f1 + 1 BETWEEN 5 AND 7;
|
||||
EXPLAIN SELECT * FROM t1 WHERE f1 + 1 BETWEEN 5 AND 7;
|
||||
|
||||
--echo # Check that expression isn't transformed for a disabled key
|
||||
--sorted_result
|
||||
SELECT * FROM t1 IGNORE KEY (gc) WHERE f1 + 1 BETWEEN 5 AND 7;
|
||||
EXPLAIN SELECT * FROM t1 IGNORE KEY (gc) WHERE f1 + 1 BETWEEN 5 AND 7;
|
||||
|
||||
--echo # Check that ORDER BY could be optimized
|
||||
SELECT * FROM t1 ORDER BY f1 + 1;
|
||||
EXPLAIN SELECT * FROM t1 ORDER BY f1 + 1;
|
||||
EXPLAIN SELECT * FROM t1 IGNORE KEY (gc) ORDER BY f1 + 1;
|
||||
|
||||
--echo # Check that GROUP BY could be optimized
|
||||
SELECT f1 + 1, MAX(GC) FROM t1 GROUP BY f1 + 1;
|
||||
EXPLAIN SELECT f1 + 1, MAX(GC) FROM t1 GROUP BY f1 + 1;
|
||||
EXPLAIN SELECT f1 + 1, MAX(GC)
|
||||
FROM t1 IGNORE KEY (gc) GROUP BY f1 + 1;
|
||||
|
||||
--echo # Shouldn't use index
|
||||
--sorted_result
|
||||
SELECT * FROM t1 WHERE f1 + 1 > 7.0;
|
||||
EXPLAIN SELECT * FROM t1 WHERE f1 + 1 > 7.0;
|
||||
|
||||
DROP TABLE t1;
|
||||
--echo # Pick index with proper type
|
||||
CREATE TABLE t1 (f1 int,
|
||||
gc_int int AS (f1 + 1) STORED,
|
||||
gc_date DATE AS (f1 + 1) STORED,
|
||||
KEY gc_int_idx(gc_int),
|
||||
KEY gc_date_idx(gc_date));
|
||||
INSERT INTO t1(f1) VALUES
|
||||
(030303),(040404),
|
||||
(050505),(060606),
|
||||
(010101),(020202),
|
||||
(030303),(040404),
|
||||
(050505),(060606),
|
||||
(010101),(020202),
|
||||
(090909),(101010),
|
||||
(010101),(020202),
|
||||
(070707),(080808);
|
||||
ANALYZE TABLE t1;
|
||||
|
||||
--sorted_result
|
||||
SELECT * FROM t1 WHERE f1 + 1 > 070707;
|
||||
--echo # INT column & index should be picked
|
||||
EXPLAIN SELECT * FROM t1 WHERE f1 + 1 > 070707;
|
||||
--sorted_result
|
||||
SELECT * FROM t1 WHERE f1 + 1 > CAST(070707 AS DATE);
|
||||
--echo # DATE column & index should be picked
|
||||
EXPLAIN SELECT * FROM t1 WHERE f1 + 1 > CAST(070707 AS DATE);
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo #
|
||||
--echo # BUG#21229846: WL8170: SIGNAL 11 IN JOIN::MAKE_SUM_FUNC_LIST
|
||||
--echo #
|
||||
CREATE TABLE t1 (
|
||||
pk int primary key auto_increment,
|
||||
col_int_key INTEGER ,
|
||||
col_int_gc_key INT GENERATED ALWAYS AS (col_int_key + 1) STORED,
|
||||
KEY col_int_gc_key(col_int_gc_key)
|
||||
);
|
||||
|
||||
INSERT INTO t1 ( col_int_key) VALUES (7);
|
||||
|
||||
ANALYZE TABLE t1;
|
||||
|
||||
SELECT table1.col_int_key + 1 AS field1, table2.col_int_key AS field2
|
||||
FROM (t1 AS table1 JOIN t1 AS table2 ON (table2.pk = table1.pk))
|
||||
ORDER BY field1, field2;
|
||||
|
||||
EXPLAIN SELECT table1.col_int_key + 1 AS field1, table2.col_int_key AS field2
|
||||
FROM (t1 AS table1 JOIN t1 AS table2 ON (table2.pk = table1.pk))
|
||||
ORDER BY field1, field2;
|
||||
|
||||
SELECT table1.col_int_key + 1 AS field1, table2.col_int_key AS field2
|
||||
FROM (t1 AS table1 JOIN t1 AS table2 ON (table2.pk = table1.pk))
|
||||
GROUP BY field1, field2;
|
||||
|
||||
EXPLAIN SELECT table1.col_int_key + 1 AS field1, table2.col_int_key AS field2
|
||||
FROM (t1 AS table1 JOIN t1 AS table2 ON (table2.pk = table1.pk))
|
||||
GROUP BY field1, field2;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
if($support_virtual_index)
|
||||
{
|
||||
--echo #
|
||||
--echo # Bug#21391781 ASSERT WHEN RUNNING ALTER TABLE ON A TABLE WITH INDEX
|
||||
--echo # ON VIRTUAL COLUMN
|
||||
--echo #
|
||||
|
||||
#
|
||||
# Test 1: column number 2 and 66 are virtual and there is an index
|
||||
# on column number 2.
|
||||
#
|
||||
CREATE TABLE t1 (
|
||||
col1 INTEGER NOT NULL,
|
||||
col2 INTEGER NOT NULL,
|
||||
gcol1 INTEGER GENERATED ALWAYS AS (col1 + col2) VIRTUAL,
|
||||
col3 INTEGER NOT NULL,
|
||||
col4 INTEGER NOT NULL,
|
||||
col5 INTEGER DEFAULT NULL,
|
||||
col6 INTEGER DEFAULT NULL,
|
||||
col7 INTEGER DEFAULT NULL,
|
||||
col8 INTEGER DEFAULT NULL,
|
||||
col9 INTEGER DEFAULT NULL,
|
||||
col10 INTEGER DEFAULT NULL,
|
||||
col11 INTEGER DEFAULT NULL,
|
||||
col12 INTEGER DEFAULT NULL,
|
||||
col13 INTEGER DEFAULT NULL,
|
||||
col14 INTEGER DEFAULT NULL,
|
||||
col15 INTEGER DEFAULT NULL,
|
||||
col16 INTEGER DEFAULT NULL,
|
||||
col17 INTEGER DEFAULT NULL,
|
||||
col18 INTEGER DEFAULT NULL,
|
||||
col19 INTEGER DEFAULT NULL,
|
||||
col20 INTEGER DEFAULT NULL,
|
||||
col21 INTEGER DEFAULT NULL,
|
||||
col22 INTEGER DEFAULT NULL,
|
||||
col23 INTEGER DEFAULT NULL,
|
||||
col24 INTEGER DEFAULT NULL,
|
||||
col25 INTEGER DEFAULT NULL,
|
||||
col26 INTEGER DEFAULT NULL,
|
||||
col27 INTEGER DEFAULT NULL,
|
||||
col28 INTEGER DEFAULT NULL,
|
||||
col29 INTEGER DEFAULT NULL,
|
||||
col30 INTEGER DEFAULT NULL,
|
||||
col31 INTEGER DEFAULT NULL,
|
||||
col32 INTEGER DEFAULT NULL,
|
||||
col33 INTEGER DEFAULT NULL,
|
||||
col34 INTEGER DEFAULT NULL,
|
||||
col35 INTEGER DEFAULT NULL,
|
||||
col36 INTEGER DEFAULT NULL,
|
||||
col37 INTEGER DEFAULT NULL,
|
||||
col38 INTEGER DEFAULT NULL,
|
||||
col39 INTEGER DEFAULT NULL,
|
||||
col40 INTEGER DEFAULT NULL,
|
||||
col41 INTEGER DEFAULT NULL,
|
||||
col42 INTEGER DEFAULT NULL,
|
||||
col43 INTEGER DEFAULT NULL,
|
||||
col44 INTEGER DEFAULT NULL,
|
||||
col45 INTEGER DEFAULT NULL,
|
||||
col46 INTEGER DEFAULT NULL,
|
||||
col47 INTEGER DEFAULT NULL,
|
||||
col48 INTEGER DEFAULT NULL,
|
||||
col49 INTEGER DEFAULT NULL,
|
||||
col50 INTEGER DEFAULT NULL,
|
||||
col51 INTEGER DEFAULT NULL,
|
||||
col52 INTEGER DEFAULT NULL,
|
||||
col53 INTEGER DEFAULT NULL,
|
||||
col54 INTEGER DEFAULT NULL,
|
||||
col55 INTEGER DEFAULT NULL,
|
||||
col56 INTEGER DEFAULT NULL,
|
||||
col57 INTEGER DEFAULT NULL,
|
||||
col58 INTEGER DEFAULT NULL,
|
||||
col59 INTEGER DEFAULT NULL,
|
||||
col60 INTEGER DEFAULT NULL,
|
||||
col61 INTEGER DEFAULT NULL,
|
||||
col62 INTEGER DEFAULT NULL,
|
||||
col63 INTEGER DEFAULT NULL,
|
||||
col64 INTEGER DEFAULT NULL,
|
||||
col65 INTEGER DEFAULT NULL,
|
||||
gcol2 INTEGER GENERATED ALWAYS AS (col3 / col4) VIRTUAL,
|
||||
KEY idx1 (gcol1)
|
||||
);
|
||||
|
||||
INSERT INTO t1 (col1, col2, col3, col4)
|
||||
VALUES (1,1,1,1), (2,2,2,2), (3,3,3,3), (4,4,4,4), (5,5,5,5);
|
||||
|
||||
# This will call my_eval_gcolumn_expr to compute the indexed column value
|
||||
ALTER TABLE t1 ADD COLUMN extra INTEGER;
|
||||
|
||||
SELECT gcol1 FROM t1 FORCE INDEX(idx1);
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
#
|
||||
# Test 2: column number 2 and 66 are virtual and there is an index
|
||||
# on column number 66.
|
||||
#
|
||||
CREATE TABLE t1 (
|
||||
col1 INTEGER NOT NULL,
|
||||
col2 INTEGER NOT NULL,
|
||||
gcol1 INTEGER GENERATED ALWAYS AS (col1 + col2) VIRTUAL,
|
||||
col3 INTEGER NOT NULL,
|
||||
col4 INTEGER NOT NULL,
|
||||
col5 INTEGER DEFAULT NULL,
|
||||
col6 INTEGER DEFAULT NULL,
|
||||
col7 INTEGER DEFAULT NULL,
|
||||
col8 INTEGER DEFAULT NULL,
|
||||
col9 INTEGER DEFAULT NULL,
|
||||
col10 INTEGER DEFAULT NULL,
|
||||
col11 INTEGER DEFAULT NULL,
|
||||
col12 INTEGER DEFAULT NULL,
|
||||
col13 INTEGER DEFAULT NULL,
|
||||
col14 INTEGER DEFAULT NULL,
|
||||
col15 INTEGER DEFAULT NULL,
|
||||
col16 INTEGER DEFAULT NULL,
|
||||
col17 INTEGER DEFAULT NULL,
|
||||
col18 INTEGER DEFAULT NULL,
|
||||
col19 INTEGER DEFAULT NULL,
|
||||
col20 INTEGER DEFAULT NULL,
|
||||
col21 INTEGER DEFAULT NULL,
|
||||
col22 INTEGER DEFAULT NULL,
|
||||
col23 INTEGER DEFAULT NULL,
|
||||
col24 INTEGER DEFAULT NULL,
|
||||
col25 INTEGER DEFAULT NULL,
|
||||
col26 INTEGER DEFAULT NULL,
|
||||
col27 INTEGER DEFAULT NULL,
|
||||
col28 INTEGER DEFAULT NULL,
|
||||
col29 INTEGER DEFAULT NULL,
|
||||
col30 INTEGER DEFAULT NULL,
|
||||
col31 INTEGER DEFAULT NULL,
|
||||
col32 INTEGER DEFAULT NULL,
|
||||
col33 INTEGER DEFAULT NULL,
|
||||
col34 INTEGER DEFAULT NULL,
|
||||
col35 INTEGER DEFAULT NULL,
|
||||
col36 INTEGER DEFAULT NULL,
|
||||
col37 INTEGER DEFAULT NULL,
|
||||
col38 INTEGER DEFAULT NULL,
|
||||
col39 INTEGER DEFAULT NULL,
|
||||
col40 INTEGER DEFAULT NULL,
|
||||
col41 INTEGER DEFAULT NULL,
|
||||
col42 INTEGER DEFAULT NULL,
|
||||
col43 INTEGER DEFAULT NULL,
|
||||
col44 INTEGER DEFAULT NULL,
|
||||
col45 INTEGER DEFAULT NULL,
|
||||
col46 INTEGER DEFAULT NULL,
|
||||
col47 INTEGER DEFAULT NULL,
|
||||
col48 INTEGER DEFAULT NULL,
|
||||
col49 INTEGER DEFAULT NULL,
|
||||
col50 INTEGER DEFAULT NULL,
|
||||
col51 INTEGER DEFAULT NULL,
|
||||
col52 INTEGER DEFAULT NULL,
|
||||
col53 INTEGER DEFAULT NULL,
|
||||
col54 INTEGER DEFAULT NULL,
|
||||
col55 INTEGER DEFAULT NULL,
|
||||
col56 INTEGER DEFAULT NULL,
|
||||
col57 INTEGER DEFAULT NULL,
|
||||
col58 INTEGER DEFAULT NULL,
|
||||
col59 INTEGER DEFAULT NULL,
|
||||
col60 INTEGER DEFAULT NULL,
|
||||
col61 INTEGER DEFAULT NULL,
|
||||
col62 INTEGER DEFAULT NULL,
|
||||
col63 INTEGER DEFAULT NULL,
|
||||
col64 INTEGER DEFAULT NULL,
|
||||
col65 INTEGER DEFAULT NULL,
|
||||
gcol2 INTEGER GENERATED ALWAYS AS (col3 / col4) VIRTUAL,
|
||||
KEY idx1 (gcol2)
|
||||
);
|
||||
|
||||
INSERT INTO t1 (col1, col2, col3, col4)
|
||||
VALUES (1,1,1,1), (2,2,2,2), (3,3,3,3), (4,4,4,4), (5,5,5,5);
|
||||
|
||||
# This will call my_eval_gcolumn_expr to compute the indexed column value
|
||||
ALTER TABLE t1 ADD COLUMN extra INTEGER;
|
||||
|
||||
SELECT gcol2 FROM t1 FORCE INDEX(idx1);
|
||||
|
||||
DROP TABLE t1;
|
||||
}
|
||||
|
||||
if($support_virtual_index)
|
||||
{
|
||||
--echo #
|
||||
--echo # Bug#21628161 CRASH/MEMORY CORRUPTION ADDING INDEXES TO VIRTUAL COLUMN
|
||||
--echo #
|
||||
# When generating the value of column b, an out-of-range warning is
|
||||
# raised. A warning is required in order to reproduce the bug, but it
|
||||
# is promoted to an error on insertion unless we turn off strict mode.
|
||||
CREATE TABLE t (a INT,
|
||||
b BOOLEAN GENERATED ALWAYS AS (a+10000) VIRTUAL,
|
||||
c BLOB GENERATED ALWAYS AS (b=2) VIRTUAL);
|
||||
INSERT INTO t(a) VALUES (1);
|
||||
# Before index was created, this query returned the expected one match.
|
||||
SELECT * FROM t WHERE c = '0';
|
||||
# Adding an index sometimes crashed, other times populated it with garbage ...
|
||||
ALTER TABLE t ADD UNIQUE INDEX (c(1));
|
||||
# ... so that this query found no match in the index.
|
||||
SELECT * FROM t WHERE c = '0';
|
||||
DROP TABLE t;
|
||||
|
||||
--echo #
|
||||
--echo # Bug#21688115 VIRTUAL COLUMN COMPUTATION SAVE_IN_FIELD()
|
||||
--echo # DID NOT RETURN TRUE WITH DIVIDE 0
|
||||
--echo #
|
||||
CREATE TABLE t (a INT, b INT, h VARCHAR(10));
|
||||
INSERT INTO t VALUES (12, 3, "ss");
|
||||
INSERT INTO t VALUES (13, 4, "ss");
|
||||
INSERT INTO t VALUES (14, 0, "ss");
|
||||
ALTER TABLE t ADD c INT GENERATED ALWAYS AS (a/b) VIRTUAL;
|
||||
#--error ER_DIVISION_BY_ZERO
|
||||
CREATE INDEX idx ON t(c);
|
||||
CALL mtr.add_suppression("\\[Warning\\] InnoDB: Compute virtual column values failed");
|
||||
DROP TABLE t;
|
||||
}
|
||||
|
||||
--echo #
|
||||
--echo # Bug#21770798 OPTIMIZER DOES NOT USE INDEX FOR GENERATED EXPRESSIONS
|
||||
--echo # WITH LOGICAL OPERATORS
|
||||
--echo #
|
||||
CREATE TABLE t (a INT, b INT,
|
||||
gc_and INT GENERATED ALWAYS AS (a AND b) STORED,
|
||||
gc_or INT GENERATED ALWAYS AS (a OR b) STORED,
|
||||
gc_xor INT GENERATED ALWAYS AS (a XOR b) STORED,
|
||||
gc_not INT GENERATED ALWAYS AS (NOT a) STORED,
|
||||
gc_case INT GENERATED ALWAYS AS
|
||||
(CASE WHEN (a AND b) THEN a ELSE b END) STORED,
|
||||
INDEX(gc_and), INDEX(gc_or), INDEX(gc_xor), INDEX(gc_not),
|
||||
INDEX(gc_case));
|
||||
INSERT INTO t (a, b) VALUES (0, 0), (0, 1), (1, 0), (1, 1);
|
||||
ANALYZE TABLE t;
|
||||
EXPLAIN SELECT a, b FROM t WHERE (a AND b) = 1;
|
||||
SELECT a, b FROM t WHERE (a AND b) = 1;
|
||||
EXPLAIN SELECT a, b FROM t WHERE 1 = (a AND b);
|
||||
SELECT a, b FROM t WHERE 1 = (a AND b);
|
||||
EXPLAIN SELECT a, b FROM t WHERE (a AND b) IN (1, 2, 3);
|
||||
SELECT a, b FROM t WHERE (a AND b) IN (1, 2, 3);
|
||||
EXPLAIN SELECT a, b FROM t WHERE (a OR b) = 1;
|
||||
--sorted_result
|
||||
SELECT a, b FROM t WHERE (a OR b) = 1;
|
||||
EXPLAIN SELECT a, b FROM t WHERE (a OR b) BETWEEN 1 AND 10;
|
||||
--sorted_result
|
||||
SELECT a, b FROM t WHERE (a OR b) BETWEEN 1 AND 10;
|
||||
# XOR and NOT worked even before the bug fix, but we test all logical
|
||||
# operators here for completeness.
|
||||
EXPLAIN SELECT a, b FROM t WHERE (a XOR b) = 1;
|
||||
--sorted_result
|
||||
SELECT a, b FROM t WHERE (a XOR b) = 1;
|
||||
EXPLAIN SELECT a FROM t WHERE (NOT a) = 1;
|
||||
SELECT a FROM t WHERE (NOT a) = 1;
|
||||
# Also verify that a logical expression nested inside another
|
||||
# expression doesn't prevent substitution.
|
||||
EXPLAIN SELECT a FROM t WHERE (CASE WHEN (a AND b) THEN a ELSE b END) = 1;
|
||||
--sorted_result
|
||||
SELECT a FROM t WHERE (CASE WHEN (a AND b) THEN a ELSE b END) = 1;
|
||||
# The expression must be exactly the same as the generated expression.
|
||||
# (b AND a) is not recognized as equivalent to (a AND b).
|
||||
EXPLAIN SELECT a, b FROM t WHERE 1 = (b AND a);
|
||||
SELECT a, b FROM t WHERE 1 = (b AND a);
|
||||
--sorted_result
|
||||
EXPLAIN SELECT a, b FROM t WHERE 1 = (b OR a);
|
||||
SELECT a, b FROM t WHERE 1 = (b OR a);
|
||||
DROP TABLE t;
|
||||
|
||||
--echo #
|
||||
--echo # Bug#22810883: ASSERTION FAILED:
|
||||
--echo # !(USED_TABS & (~READ_TABLES & ~FILTER_FOR_TABLE))
|
||||
--echo #
|
||||
CREATE TABLE t1 (a1 INTEGER GENERATED ALWAYS AS (1 AND 0) STORED,
|
||||
a2 INTEGER, KEY (a1));
|
||||
INSERT INTO t1 VALUES ();
|
||||
CREATE TABLE t2 (b INTEGER);
|
||||
INSERT INTO t2 VALUES (1);
|
||||
ANALYZE TABLE t1, t2;
|
||||
--echo # Used to choose the index on a1 and get wrong results.
|
||||
--let $query= SELECT * FROM t1 WHERE (a2 AND a2) = 0
|
||||
--eval EXPLAIN $query
|
||||
--eval $query
|
||||
--echo # Used to get assertion or wrong results.
|
||||
--let $query= SELECT * FROM t1 STRAIGHT_JOIN t2 ON b WHERE (b AND b) = 1
|
||||
--eval EXPLAIN $query
|
||||
--eval $query
|
||||
DROP TABLE t1, t2;
|
||||
|
||||
--echo #
|
155
mysql-test/suite/gcol/inc/gcol_non_stored_columns.inc
Normal file
155
mysql-test/suite/gcol/inc/gcol_non_stored_columns.inc
Normal file
|
@ -0,0 +1,155 @@
|
|||
################################################################################
|
||||
# inc/gcol_non_stored_columns.inc #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Ensure that MySQL behaviour is consistent irrelevant of #
|
||||
# - the place of a non-stored column among other columns, #
|
||||
# - the total number of non-stored fields. #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-09-04 #
|
||||
# Change Author: #
|
||||
# Change Date: #
|
||||
# Change: #
|
||||
################################################################################
|
||||
|
||||
--echo # Case 1. All non-stored columns.
|
||||
eval create $opt_tmp table t1 (a int generated always as (2+3) virtual);
|
||||
insert into t1 values (default);
|
||||
select * from t1;
|
||||
insert into t1 values (default);
|
||||
select * from t1;
|
||||
drop table t1;
|
||||
--echo # Case 2. CREATE
|
||||
--echo # - Column1: "real"
|
||||
--echo # - Column 2: virtual non-stored
|
||||
eval create $opt_tmp table t1 (a int, b int generated always as (-a) virtual);
|
||||
insert into t1 values (1,default);
|
||||
select * from t1;
|
||||
insert into t1 values (2,default);
|
||||
select * from t1 order by a;
|
||||
drop table t1;
|
||||
|
||||
--echo # Case 3. CREATE
|
||||
--echo # - Column1: "real"
|
||||
--echo # - Column 2: virtual stored
|
||||
eval create $opt_tmp table t1 (a int, b int generated always as (-a) stored);
|
||||
insert into t1 values (1,default);
|
||||
select * from t1;
|
||||
insert into t1 values (2,default);
|
||||
select * from t1 order by a;
|
||||
drop table t1;
|
||||
|
||||
--echo # Case 4. CREATE
|
||||
--echo # - Column1: virtual non-stored
|
||||
--echo # - Column2: "real"
|
||||
eval create $opt_tmp table t1 (a int generated always as (-b) virtual, b int);
|
||||
insert into t1 values (default,1);
|
||||
select * from t1;
|
||||
insert into t1 values (default,2);
|
||||
select * from t1 order by a;
|
||||
drop table t1;
|
||||
|
||||
--echo # Case 5. CREATE
|
||||
--echo # - Column1: virtual stored
|
||||
--echo # - Column2: "real"
|
||||
eval create $opt_tmp table t1 (a int generated always as (-b) stored, b int);
|
||||
insert into t1 values (default,1);
|
||||
select * from t1;
|
||||
insert into t1 values (default,2);
|
||||
select * from t1 order by a;
|
||||
drop table t1;
|
||||
|
||||
--echo # Case 6. CREATE
|
||||
--echo # - Column1: "real"
|
||||
--echo # - Column2: virtual non-stored
|
||||
--echo # - Column3: virtual stored
|
||||
eval create $opt_tmp table t1 (a int, b int generated always as (-a), c int generated always as (-a) stored);
|
||||
insert into t1 values (1,default,default);
|
||||
select * from t1;
|
||||
insert into t1 values (2,default,default);
|
||||
select * from t1 order by a;
|
||||
drop table t1;
|
||||
|
||||
--echo # Case 7. ALTER. Modify virtual stored -> virtual non-stored
|
||||
eval create $opt_tmp table t1 (a int, b int generated always as (a % 2) stored);
|
||||
--error ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN
|
||||
alter table t1 modify b int generated always as (a % 2) virtual;
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
|
||||
--echo # Case 8. ALTER. Modify virtual non-stored -> virtual stored
|
||||
eval create $opt_tmp table t1 (a int, b int generated always as (a % 2) virtual);
|
||||
--error ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN
|
||||
alter table t1 modify b int generated always as (a % 2) stored;
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
|
||||
--echo # Case 9. CREATE LIKE
|
||||
--echo # - Column1: "real"
|
||||
--echo # - Column2: virtual non-stored
|
||||
--echo # - Column3: virtual stored
|
||||
eval create $opt_tmp table t1 (a int, b int generated always as (-a), c int generated always as (-a) stored);
|
||||
eval create $opt_tmp table t2 like t1;
|
||||
insert into t2 values (1,default,default);
|
||||
select * from t2;
|
||||
insert into t2 values (2,default,default);
|
||||
select * from t2 order by a;
|
||||
drop table t2;
|
||||
drop table t1;
|
||||
|
||||
--echo # Case 10. ALTER. Dropping a virtual non-stored column.
|
||||
--echo # - Column1: virtual non-stored
|
||||
--echo # - Column2: "real"
|
||||
eval create $opt_tmp table t1 (a int generated always as (-b) virtual, b int, c varchar(5));
|
||||
insert into t1 values (default,1,'v1');
|
||||
insert into t1 values (default,2,'v2');
|
||||
select * from t1 order by b;
|
||||
alter table t1 drop column a;
|
||||
select * from t1 order by b;
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
|
||||
--echo # Case 11. ALTER. Dropping a virtual stored column.
|
||||
--echo # - Column1: virtual stored
|
||||
--echo # - Column2: "real"
|
||||
eval create $opt_tmp table t1 (a int generated always as (-b) stored, b int, c char(5));
|
||||
insert into t1 values (default,1,'v1');
|
||||
insert into t1 values (default,2,'v2');
|
||||
select * from t1 order by b;
|
||||
alter table t1 drop column a;
|
||||
select * from t1 order by b;
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
|
||||
--echo # Case 12. ALTER. Adding a new virtual non-stored column.
|
||||
eval create $opt_tmp table t1 (a int, b datetime);
|
||||
insert into t1 values (1,'2008-09-04');
|
||||
insert into t1 values (2,'2008-09-05');
|
||||
select * from t1 order by a;
|
||||
alter table t1 add column c int generated always as (dayofyear(b)) virtual after a;
|
||||
select * from t1 order by a;
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
|
||||
--echo # Case 13. ALTER. Adding a new virtual stored column.
|
||||
eval create $opt_tmp table t1 (a int, b datetime);
|
||||
insert into t1 values (1,'2008-09-04');
|
||||
insert into t1 values (2,'2008-09-05');
|
||||
select * from t1 order by a;
|
||||
alter table t1 add column c int generated always as (dayofyear(b)) stored after a;
|
||||
select * from t1 order by a;
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
|
||||
--echo # Case 15. ALTER. Changing the expression of a virtual non-stored column.
|
||||
eval create $opt_tmp table t1 (a int, b datetime, c int generated always as (week(b)) virtual);
|
||||
insert into t1 values (1,'2008-09-04',default);
|
||||
insert into t1 values (2,'2008-09-05',default);
|
||||
select * from t1 order by a;
|
||||
alter table t1 change column c c int generated always as (week(b,1)) virtual;
|
||||
select * from t1 order by a;
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
|
155
mysql-test/suite/gcol/inc/gcol_partition.inc
Normal file
155
mysql-test/suite/gcol/inc/gcol_partition.inc
Normal file
|
@ -0,0 +1,155 @@
|
|||
################################################################################
|
||||
# inc/gcol_partition.inc #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Testing partitioning tables with generated columns. #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-09-04 #
|
||||
# Change Author: #
|
||||
# Change Date: #
|
||||
# Change: #
|
||||
################################################################################
|
||||
|
||||
--source include/have_partition.inc
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
|
||||
--echo # Case 1. Partitioning by RANGE based on a non-stored generated column.
|
||||
|
||||
CREATE TABLE t1 (
|
||||
a DATE NOT NULL,
|
||||
b int generated always as (year(a)) virtual
|
||||
)
|
||||
PARTITION BY RANGE( b ) (
|
||||
PARTITION p0 VALUES LESS THAN (2006),
|
||||
PARTITION p2 VALUES LESS THAN (2008)
|
||||
);
|
||||
|
||||
insert into t1 values ('2006-01-01',default);
|
||||
insert into t1 values ('2007-01-01',default);
|
||||
insert into t1 values ('2005-01-01',default);
|
||||
select * from t1;
|
||||
|
||||
# Specifically for MyISAM, check that data is written into correct
|
||||
# $MYSQLTEST_VARDIR/master-data/test/t1*p?.MYD files
|
||||
|
||||
--echo # Modify the expression of generated column b
|
||||
ALTER TABLE t1 modify b int generated always as (year(a)-1) virtual;
|
||||
|
||||
select * from t1;
|
||||
|
||||
drop table t1;
|
||||
|
||||
--echo # Case 2. Partitioning by LIST based on a stored generated column.
|
||||
|
||||
CREATE TABLE t1 (a int, b int generated always as (a % 3 ) stored)
|
||||
PARTITION BY LIST (a+1)
|
||||
(PARTITION p1 VALUES IN (1), PARTITION p2 VALUES IN (2));
|
||||
|
||||
insert into t1 values (1,default);
|
||||
select * from t1;
|
||||
|
||||
#
|
||||
# NOTE: The following tests are currently failing due to a
|
||||
# [suspected] bug in the existing partition functionality.
|
||||
# Here is what was observed when using mysqld compiled prior
|
||||
# to adding the generated column functionality.
|
||||
# mysql> create table t1 (a int) partition by list (a)
|
||||
# (partition p1 values in (1), partition p2 values in (2));
|
||||
# Query OK, 0 rows affected (0.00 sec)
|
||||
#
|
||||
# mysql> insert into t1 values (1), (1), (2);
|
||||
# Query OK, 3 rows affected (0.00 sec)
|
||||
# Records: 3 Duplicates: 0 Warnings: 0
|
||||
#
|
||||
# mysql> select * from t1;
|
||||
# +------+
|
||||
# | a |
|
||||
# +------+
|
||||
# | 1 |
|
||||
# | 1 |
|
||||
# | 2 |
|
||||
# +------+
|
||||
# 3 rows in set (0.00 sec)
|
||||
#
|
||||
# mysql> alter table t1 reorganize partition p1 into
|
||||
# (partition p1 values in (3));
|
||||
# Query OK, 2 rows affected (3.90 sec)
|
||||
# Records: 2 Duplicates: 2 Warnings: 0
|
||||
#
|
||||
# mysql> select * from t1;
|
||||
# +------+
|
||||
# | a |
|
||||
# +------+
|
||||
# | 2 | <- Two row have been lost!!!
|
||||
# +------+
|
||||
# 1 row in set (0.00 sec)
|
||||
|
||||
#
|
||||
#alter table t1 change b b virtual int as ((a % 3)+1) stored;
|
||||
#--error ER_NO_PARTITION_FOR_GIVEN_VALUE
|
||||
#alter table t1 change b b virtual int as (a % 2) stored;
|
||||
#if ($myisam_engine)
|
||||
#{
|
||||
# --echo # Check how data is physically partitioned.
|
||||
# --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
||||
# --exec du -b $MYSQLTEST_VARDIR/master-data/test/t1*p?.MYD
|
||||
#}
|
||||
|
||||
select * from t1;
|
||||
|
||||
drop table t1;
|
||||
|
||||
--echo # Case 3. Partitioning by HASH based on a non-stored generated column.
|
||||
|
||||
CREATE TABLE t1 (
|
||||
a DATE NOT NULL,
|
||||
b int generated always as (year(a)) virtual
|
||||
)
|
||||
PARTITION BY HASH( b % 3 ) PARTITIONS 3;
|
||||
|
||||
insert into t1 values ('2005-01-01',default);
|
||||
insert into t1 values ('2006-01-01',default);
|
||||
select * from t1;
|
||||
|
||||
--echo # Modify the expression of generated column b
|
||||
ALTER TABLE t1 modify b int generated always as (year(a)-1) virtual;
|
||||
|
||||
select * from t1;
|
||||
|
||||
drop table t1;
|
||||
|
||||
--echo #
|
||||
--echo # Bug#21779011 INVALID READS AND SENDING RANDOM SERVER MEMORY BACK
|
||||
--echo # TO CLIENT
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t (
|
||||
c INTEGER GENERATED ALWAYS AS (2) VIRTUAL,
|
||||
d INTEGER,
|
||||
KEY (d)
|
||||
) PARTITION BY KEY (d) PARTITIONS 2;
|
||||
|
||||
INSERT INTO t (d) VALUES (1),(1),(2),(2);
|
||||
|
||||
SELECT c FROM t WHERE d >= 1 GROUP BY d LIMIT 2;
|
||||
|
||||
DROP TABLE t;
|
||||
|
||||
--echo #
|
||||
--echo # Bug#21779554: CHECK_MISPLACED_ROWS BOGUS "FOUND A MISPLACED ROW"
|
||||
--echo # AND CRASHES
|
||||
--echo #
|
||||
CREATE TABLE t(a INT,b INT GENERATED ALWAYS AS (1) VIRTUAL,c INT)
|
||||
PARTITION BY KEY (b)PARTITIONS 6;
|
||||
INSERT INTO t VALUES();
|
||||
CHECK TABLE t EXTENDED;
|
||||
FLUSH TABLES;
|
||||
CHECK TABLE t EXTENDED;
|
||||
DROP TABLE t;
|
1163
mysql-test/suite/gcol/inc/gcol_select.inc
Normal file
1163
mysql-test/suite/gcol/inc/gcol_select.inc
Normal file
File diff suppressed because it is too large
Load diff
47
mysql-test/suite/gcol/inc/gcol_supported_sql_funcs.inc
Normal file
47
mysql-test/suite/gcol/inc/gcol_supported_sql_funcs.inc
Normal file
|
@ -0,0 +1,47 @@
|
|||
################################################################################
|
||||
# inc/gcol_supported_sql_funcs.inc #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Tests frame for allowed sql functions #
|
||||
# #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-08-31 #
|
||||
# Change Author: #
|
||||
# Change Date: #
|
||||
# Change: #
|
||||
################################################################################
|
||||
|
||||
--enable_warnings
|
||||
set sql_warnings = 1;
|
||||
eval create table t1 ($cols);
|
||||
show create table t1;
|
||||
if ($rows)
|
||||
{
|
||||
# Allow out-of-range errors
|
||||
--error 0,1264,1690,3020
|
||||
eval insert into t1 values ($values1);
|
||||
dec $rows;
|
||||
}
|
||||
if ($rows)
|
||||
{
|
||||
--error 0,1292,1690,3020
|
||||
eval insert into t1 values ($values2);
|
||||
dec $rows;
|
||||
}
|
||||
if ($rows)
|
||||
{
|
||||
--error 0,1690,3020
|
||||
eval insert into t1 values ($values3);
|
||||
dec $rows;
|
||||
}
|
||||
if ($rows)
|
||||
{
|
||||
eval insert into t1 values ($values4);
|
||||
dec $rows;
|
||||
}
|
||||
--sorted_result
|
||||
select * from t1;
|
||||
drop table t1;
|
||||
set sql_warnings = 0;
|
1245
mysql-test/suite/gcol/inc/gcol_supported_sql_funcs_main.inc
Normal file
1245
mysql-test/suite/gcol/inc/gcol_supported_sql_funcs_main.inc
Normal file
File diff suppressed because it is too large
Load diff
114
mysql-test/suite/gcol/inc/gcol_trigger_sp.inc
Normal file
114
mysql-test/suite/gcol/inc/gcol_trigger_sp.inc
Normal file
|
@ -0,0 +1,114 @@
|
|||
################################################################################
|
||||
# inc/gcol_trigger_sp.inc #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Testing triggers, stored procedures and functions #
|
||||
# defined on tables with generated columns. #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-09-04 #
|
||||
# Change Author: #
|
||||
# Change Date: #
|
||||
# Change: #
|
||||
################################################################################
|
||||
|
||||
create table t1 (a int,
|
||||
b int generated always as (a/10) virtual,
|
||||
c int generated always as (a/10) stored);
|
||||
|
||||
create table t2 (a timestamp);
|
||||
|
||||
delimiter |;
|
||||
|
||||
create trigger trg1 before insert on t1 for each row
|
||||
begin
|
||||
if (new.b < 10) then
|
||||
set new.a:= 100;
|
||||
set new.b:= 9;
|
||||
set new.c:= 9;
|
||||
end if;
|
||||
|
||||
if (new.c > 50) then
|
||||
set new.a:= 500;
|
||||
end if;
|
||||
end|
|
||||
|
||||
create trigger trg2 after insert on t1 for each row
|
||||
begin
|
||||
if (new.b >= 60) then
|
||||
insert into t2 values (now());
|
||||
end if;
|
||||
end|
|
||||
|
||||
create function f1()
|
||||
returns int
|
||||
begin
|
||||
declare sum1 int default '0';
|
||||
declare cur1 cursor for select sum(b) from t1;
|
||||
open cur1;
|
||||
fetch cur1 into sum1;
|
||||
close cur1;
|
||||
return sum1;
|
||||
end|
|
||||
|
||||
delimiter ;|
|
||||
|
||||
set sql_warnings = 1;
|
||||
|
||||
insert into t1 (a) values (200);
|
||||
select * from t1;
|
||||
select * from t2;
|
||||
|
||||
insert into t1 (a) values (10);
|
||||
--sorted_result
|
||||
select * from t1;
|
||||
select * from t2;
|
||||
|
||||
insert into t1 (a) values (600);
|
||||
--sorted_result
|
||||
select * from t1;
|
||||
--replace_column 1 <timestamp>
|
||||
select * from t2;
|
||||
|
||||
select f1();
|
||||
|
||||
set sql_warnings = 0;
|
||||
|
||||
drop trigger trg1;
|
||||
drop trigger trg2;
|
||||
drop table t2;
|
||||
|
||||
delimiter |;
|
||||
|
||||
create procedure p1()
|
||||
begin
|
||||
declare i int default '0';
|
||||
create table t2 like t1;
|
||||
insert into t2 (a) values (100), (200);
|
||||
begin
|
||||
declare cur1 cursor for select sum(c) from t2;
|
||||
open cur1;
|
||||
fetch cur1 into i;
|
||||
close cur1;
|
||||
if (i=30) then
|
||||
insert into t1 values (300,default,default);
|
||||
end if;
|
||||
end;
|
||||
end|
|
||||
|
||||
delimiter ;|
|
||||
|
||||
delete from t1;
|
||||
|
||||
call p1();
|
||||
|
||||
--sorted_result
|
||||
select * from t2;
|
||||
--sorted_result
|
||||
select * from t1;
|
||||
|
||||
drop table t1,t2;
|
||||
drop procedure p1;
|
|
@ -0,0 +1,21 @@
|
|||
################################################################################
|
||||
# inc/gcol_unsupported_storage_engines.inc #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Ensure that defining a generated column for an unsupported table type #
|
||||
# results in a graceful error. #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-09-02 #
|
||||
# Change Author: #
|
||||
# Change Date: #
|
||||
# Change: #
|
||||
################################################################################
|
||||
|
||||
--error ER_UNSUPPORTED_ENGINE_FOR_VIRTUAL_COLUMNS
|
||||
create table t1 (a int, b int generated always as (a+1) virtual);
|
||||
create table t1 (a int);
|
||||
--error ER_UNSUPPORTED_ENGINE_FOR_VIRTUAL_COLUMNS
|
||||
alter table t1 add column b int generated always as (a+1) virtual;
|
||||
drop table t1;
|
223
mysql-test/suite/gcol/inc/gcol_view.inc
Normal file
223
mysql-test/suite/gcol/inc/gcol_view.inc
Normal file
|
@ -0,0 +1,223 @@
|
|||
################################################################################
|
||||
# inc/gcol_view.inc #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Testing views defined on tables with generated columns. #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-09-04 #
|
||||
# Change Author: #
|
||||
# Change Date: #
|
||||
# Change: #
|
||||
################################################################################
|
||||
|
||||
|
||||
|
||||
create table t1 (a int not null,
|
||||
b int generated always as (-a) virtual,
|
||||
c int generated always as (-a) stored);
|
||||
insert into t1 (a) values (1), (1), (2), (2), (3);
|
||||
analyze table t1;
|
||||
|
||||
# simple view
|
||||
create view v1 (d,e) as select abs(b), abs(c) from t1;
|
||||
--sorted_result
|
||||
select d,e from v1;
|
||||
select is_updatable from information_schema.views where table_name='v1';
|
||||
|
||||
# view with different algorithms (explain output differs)
|
||||
--replace_column 10 X
|
||||
explain select d,e from v1;
|
||||
create algorithm=temptable view v2 (d,e) as select abs(b), abs(c) from t1;
|
||||
show create view v2;
|
||||
--sorted_result
|
||||
select d,e from v2;
|
||||
--replace_column 10 X
|
||||
explain select d,e from v2;
|
||||
|
||||
# VIEW on VIEW test
|
||||
create view v3 (d,e) as select d*2, e*2 from v1;
|
||||
--sorted_result
|
||||
select * from v3;
|
||||
--replace_column 10 X
|
||||
explain select * from v3;
|
||||
|
||||
drop view v1,v2,v3;
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# DISTINCT option for VIEW
|
||||
#
|
||||
create table t1 (a int not null,
|
||||
b int generated always as (-a) virtual,
|
||||
c int generated always as (-a) stored);
|
||||
insert into t1 (a) values (1), (2), (3), (1), (2), (3);
|
||||
create view v1 as select distinct b from t1;
|
||||
--sorted_result
|
||||
select * from v1;
|
||||
--replace_column 10 X
|
||||
explain select * from v1;
|
||||
--sorted_result
|
||||
select * from t1;
|
||||
drop view v1;
|
||||
create view v1 as select distinct c from t1;
|
||||
--sorted_result
|
||||
select * from v1;
|
||||
--replace_column 10 X
|
||||
explain select * from v1;
|
||||
--sorted_result
|
||||
select * from t1;
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# LIMIT clause test
|
||||
#
|
||||
create table t1 (a int not null,
|
||||
b int generated always as (-a) virtual,
|
||||
c int generated always as (-a) stored);
|
||||
insert into t1 (a) values (1), (2), (3), (4);
|
||||
create view v1 as select b+1 from t1 order by 1 desc limit 2;
|
||||
select * from v1;
|
||||
--replace_column 10 X
|
||||
explain select * from v1;
|
||||
drop view v1;
|
||||
create view v1 as select c+1 from t1 order by 1 desc limit 2;
|
||||
--sorted_result
|
||||
select * from v1;
|
||||
--replace_column 10 X
|
||||
explain select * from v1;
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# simple view + simple update, insert and delete
|
||||
#
|
||||
create table t1 (a int,
|
||||
b int,
|
||||
c int generated always as (-a) virtual,
|
||||
d int generated always as (-a) stored,
|
||||
primary key(a));
|
||||
insert into t1 (a,b) values (10,2), (20,3), (30,4), (40,5), (50,10);
|
||||
create view v1 (a,e,f,g) as select a, b+1,c+1,d+1 from t1;
|
||||
# updatable field of updateable view
|
||||
update v1 set a=a+e;
|
||||
select * from v1 order by a;
|
||||
select * from t1 order by a;
|
||||
delete from v1;
|
||||
select * from v1;
|
||||
select * from t1;
|
||||
--error ER_NON_INSERTABLE_TABLE
|
||||
insert into v1 (a,e) values (60,15);
|
||||
drop table t1;
|
||||
drop view v1;
|
||||
|
||||
#
|
||||
# outer join based on VIEW with WHERE clause
|
||||
#
|
||||
create table t1 (a int,
|
||||
b int generated always as (-a) virtual,
|
||||
c int generated always as (-a) stored,
|
||||
primary key(a));
|
||||
insert into t1 (a) values (1), (2), (3);
|
||||
create view v1 (x,y,z) as select a,b,c from t1 where b < -1;
|
||||
--sorted_result
|
||||
select t1.a, v1.x, v1.y, v1.z from t1 left join v1 on (t1.b= v1.y);
|
||||
drop view v1;
|
||||
create view v1 (x,y,z) as select a,b,c from t1 where c < -1;
|
||||
--sorted_result
|
||||
select t1.a, v1.x, v1.y, v1.z from t1 left join v1 on (t1.c= v1.z);
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# VIEW built over UNION
|
||||
#
|
||||
create table t1 (a1 int,
|
||||
b1 int generated always as (-a1) virtual,
|
||||
c1 int generated always as (-a1) stored);
|
||||
create table t2 (a2 int,
|
||||
b2 int generated always as (-a2) virtual,
|
||||
c2 int generated always as (-a2) stored);
|
||||
insert into t1 (a1) values (1), (2);
|
||||
insert into t2 (a2) values (2), (3);
|
||||
create view v1 as select * from t1,t2 union all select * from t1,t2;
|
||||
--sorted_result
|
||||
select * from v1;
|
||||
drop view v1;
|
||||
drop table t1, t2;
|
||||
|
||||
#
|
||||
# Showing VIEW with VIEWs in subquery
|
||||
#
|
||||
create table t1 (a int,
|
||||
b int generated always as (-a) virtual,
|
||||
c int generated always as (-a) stored);
|
||||
create table t2 like t1;
|
||||
create view v1 as select a,b,c from t1;
|
||||
create view v2 as select a,b,c from t2 where b in (select b from v1);
|
||||
show create view v2;
|
||||
drop view v2, v1;
|
||||
drop table t1, t2;
|
||||
|
||||
#
|
||||
# TODO: VIEW with full text
|
||||
#
|
||||
#CREATE TABLE t1 (c1 int not null auto_increment primary key, c2 varchar(20), fulltext(c2));
|
||||
#insert into t1 (c2) VALUES ('real Beer'),('Water'),('Kossu'),('Coca-Cola'),('Vodka'),('Wine'),('almost real Beer');
|
||||
#select * from t1 WHERE match (c2) against ('Beer');
|
||||
#CREATE VIEW v1 AS SELECT * from t1 WHERE match (c2) against ('Beer');
|
||||
#select * from v1;
|
||||
#drop view v1;
|
||||
#drop table t1;
|
||||
|
||||
#
|
||||
# distinct in temporary table with a VIEW
|
||||
#
|
||||
create table t1 (a int,
|
||||
b int generated always as (-a) virtual,
|
||||
c int generated always as (-a) stored);
|
||||
insert into t1 (a) values (1),(1),(2),(2),(3),(3);
|
||||
create view v1 as select b from t1;
|
||||
--sorted_result
|
||||
select distinct b from v1;
|
||||
select distinct b from v1 order by b limit 2;
|
||||
select distinct b from t1 order by b limit 2;
|
||||
prepare stmt1 from "select distinct b from v1 order by b limit 2";
|
||||
execute stmt1;
|
||||
execute stmt1;
|
||||
deallocate prepare stmt1;
|
||||
drop view v1;
|
||||
create view v1 as select c from t1;
|
||||
--sorted_result
|
||||
select distinct c from v1;
|
||||
select distinct c from v1 order by c limit 2;
|
||||
select distinct c from t1 order by c limit 2;
|
||||
prepare stmt1 from "select distinct c from v1 order by c limit 2";
|
||||
execute stmt1;
|
||||
execute stmt1;
|
||||
deallocate prepare stmt1;
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# WITH CHECK OPTION insert/update test
|
||||
#
|
||||
create table t1 (a int,
|
||||
b int generated always as (-a) virtual,
|
||||
c int generated always as (-a) stored);
|
||||
create view v1 as select * from t1 where b > -2 && c >-2 with check option;
|
||||
# simple insert
|
||||
insert into v1 (a) values (1);
|
||||
-- error 1369
|
||||
insert into v1 (a) values (3);
|
||||
# simple insert with ignore
|
||||
insert ignore into v1 (a) values (2),(3),(0);
|
||||
--sorted_result
|
||||
select * from t1;
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
|
49
mysql-test/suite/gcol/r/federated_gcol.result
Normal file
49
mysql-test/suite/gcol/r/federated_gcol.result
Normal file
|
@ -0,0 +1,49 @@
|
|||
stop slave;
|
||||
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
||||
reset master;
|
||||
reset slave;
|
||||
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
||||
start slave;
|
||||
stop slave;
|
||||
DROP DATABASE IF EXISTS federated;
|
||||
CREATE DATABASE federated;
|
||||
DROP DATABASE IF EXISTS federated;
|
||||
CREATE DATABASE federated;
|
||||
SET @OLD_CONCURRENT_INSERT= @@GLOBAL.CONCURRENT_INSERT;
|
||||
SET @@GLOBAL.CONCURRENT_INSERT= 0;
|
||||
DROP TABLE IF EXISTS federated.t1;
|
||||
Warnings:
|
||||
Note 1051 Unknown table 't1'
|
||||
DROP TABLE IF EXISTS federated.t1;
|
||||
Warnings:
|
||||
Note 1051 Unknown table 't1'
|
||||
CREATE TABLE federated.t1 (
|
||||
`id` int(20) NOT NULL,
|
||||
`group` int NOT NULL default 0,
|
||||
`tmp` virtual int as (`id` + 1)
|
||||
)
|
||||
ENGINE="FEDERATED" DEFAULT CHARSET=latin1
|
||||
CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/federated/t1';
|
||||
ERROR HY000: 'Specified storage engine' is not yet supported for generated columns.
|
||||
CREATE TABLE federated.t1 (
|
||||
`id` int(20) NOT NULL,
|
||||
`group` int NOT NULL default 0
|
||||
)
|
||||
ENGINE="FEDERATED" DEFAULT CHARSET=latin1
|
||||
CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/federated/t1';
|
||||
alter table federated.t1 add column `tmp` virtual int as (`id` + 1);
|
||||
ERROR HY000: Table storage engine for 't1' doesn't have this option
|
||||
DROP TABLE IF EXISTS federated.t1;
|
||||
End of 5.1 tests
|
||||
DROP TABLE IF EXISTS federated.t1;
|
||||
DROP DATABASE IF EXISTS federated;
|
||||
DROP TABLE IF EXISTS federated.t1;
|
||||
DROP DATABASE IF EXISTS federated;
|
||||
SET @@GLOBAL.CONCURRENT_INSERT= @OLD_CONCURRENT_INSERT;
|
||||
DROP VIEW IF EXISTS v1,v2;
|
||||
DROP TABLE IF EXISTS t1,t2,t3;
|
||||
DROP PROCEDURE IF EXISTS p1;
|
||||
DROP FUNCTION IF EXISTS f1;
|
||||
DROP TRIGGER IF EXISTS trg1;
|
||||
DROP TRIGGER IF EXISTS trg2;
|
||||
set sql_warnings = 0;
|
14
mysql-test/suite/gcol/r/gcol_archive.result
Normal file
14
mysql-test/suite/gcol/r/gcol_archive.result
Normal file
|
@ -0,0 +1,14 @@
|
|||
SET @@session.default_storage_engine = 'archive';
|
||||
create table t1 (a int, b int generated always as (a+1) virtual);
|
||||
ERROR HY000: ARCHIVE storage engine does not support computed columns
|
||||
create table t1 (a int);
|
||||
alter table t1 add column b int generated always as (a+1) virtual;
|
||||
ERROR HY000: ARCHIVE storage engine does not support computed columns
|
||||
drop table t1;
|
||||
DROP VIEW IF EXISTS v1,v2;
|
||||
DROP TABLE IF EXISTS t1,t2,t3;
|
||||
DROP PROCEDURE IF EXISTS p1;
|
||||
DROP FUNCTION IF EXISTS f1;
|
||||
DROP TRIGGER IF EXISTS trg1;
|
||||
DROP TRIGGER IF EXISTS trg2;
|
||||
set sql_warnings = 0;
|
14
mysql-test/suite/gcol/r/gcol_blackhole.result
Normal file
14
mysql-test/suite/gcol/r/gcol_blackhole.result
Normal file
|
@ -0,0 +1,14 @@
|
|||
SET @@session.default_storage_engine = 'blackhole';
|
||||
create table t1 (a int, b int generated always as (a+1) virtual);
|
||||
ERROR HY000: BLACKHOLE storage engine does not support computed columns
|
||||
create table t1 (a int);
|
||||
alter table t1 add column b int generated always as (a+1) virtual;
|
||||
ERROR HY000: BLACKHOLE storage engine does not support computed columns
|
||||
drop table t1;
|
||||
DROP VIEW IF EXISTS v1,v2;
|
||||
DROP TABLE IF EXISTS t1,t2,t3;
|
||||
DROP PROCEDURE IF EXISTS p1;
|
||||
DROP FUNCTION IF EXISTS f1;
|
||||
DROP TRIGGER IF EXISTS trg1;
|
||||
DROP TRIGGER IF EXISTS trg2;
|
||||
set sql_warnings = 0;
|
179
mysql-test/suite/gcol/r/gcol_blocked_sql_funcs_innodb.result
Normal file
179
mysql-test/suite/gcol/r/gcol_blocked_sql_funcs_innodb.result
Normal file
|
@ -0,0 +1,179 @@
|
|||
SET @@session.default_storage_engine = 'InnoDB';
|
||||
create or replace table t1 (b double generated always as (rand()) virtual);
|
||||
create or replace table t1 (a datetime generated always as (curdate()) virtual);
|
||||
create or replace table t1 (a datetime generated always as (current_date) virtual);
|
||||
create or replace table t1 (a datetime generated always as (current_date()) virtual);
|
||||
create or replace table t1 (a datetime generated always as (current_time) virtual);
|
||||
create or replace table t1 (a datetime generated always as (current_time()) virtual);
|
||||
create or replace table t1 (a datetime generated always as (current_timestamp()) virtual);
|
||||
create or replace table t1 (a datetime generated always as (current_timestamp) virtual);
|
||||
create or replace table t1 (a datetime generated always as (curtime()) virtual);
|
||||
create or replace table t1 (a datetime, b varchar(10) generated always as (localtime()) virtual);
|
||||
create or replace table t1 (a datetime, b varchar(10) generated always as (localtime) virtual);
|
||||
create or replace table t1 (a datetime, b varchar(10) generated always as (localtimestamp()) virtual);
|
||||
create or replace table t1 (a datetime, b varchar(10) generated always as (localtimestamp) virtual);
|
||||
create or replace table t1 (a datetime, b varchar(10) generated always as (now()) virtual);
|
||||
create or replace table t1 (a int, b varchar(10) generated always as (sysdate()) virtual);
|
||||
create or replace table t1 (a datetime, b datetime generated always as (unix_timestamp()) virtual);
|
||||
create or replace table t1 (a datetime, b datetime generated always as (utc_date()) virtual);
|
||||
create or replace table t1 (a datetime, b datetime generated always as (utc_time()) virtual);
|
||||
create or replace table t1 (a datetime, b datetime generated always as (utc_timestamp()) virtual);
|
||||
create or replace table t1 (a int generated always as (connection_id()) virtual);
|
||||
create or replace table t1 (a varchar(32) generated always as (current_user()) virtual);
|
||||
create or replace table t1 (a varchar(32) generated always as (current_user) virtual);
|
||||
create or replace table t1 (a varchar(1024), b varchar(1024) generated always as (database()) virtual);
|
||||
create or replace table t1 (a varchar(32) generated always as (schema()) virtual);
|
||||
create or replace table t1 (a varchar(32) generated always as (session_user()) virtual);
|
||||
create or replace table t1 (a varchar(32) generated always as (system_user()) virtual);
|
||||
create or replace table t1 (a varchar(1024), b varchar(1024) generated always as (user()) virtual);
|
||||
create or replace table t1 (a varchar(1024) generated always as (uuid_short()) virtual);
|
||||
create or replace table t1 (a varchar(1024) generated always as (uuid()) virtual);
|
||||
create or replace table t1 (a varchar(1024), b varchar(1024) generated always as (version()) virtual);
|
||||
create or replace table t1 (a varchar(1024), b varchar(1024) generated always as (encrypt(a)) virtual);
|
||||
create or replace table t1 (a varchar(1024), b varchar(1024) generated always as (UpdateXML(a,'/a','<e>fff</e>')) virtual);
|
||||
drop table t1;
|
||||
# LOAD_FILE()
|
||||
create table t1 (a varchar(64), b varchar(1024) generated always as (load_file(a)) virtual);
|
||||
ERROR HY000: Function or expression 'load_file()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# MATCH()
|
||||
# BENCHMARK()
|
||||
create table t1 (a varchar(1024), b varchar(1024) generated always as (benchmark(a,3)) virtual);
|
||||
ERROR HY000: Function or expression 'benchmark()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# FOUND_ROWS()
|
||||
create table t1 (a varchar(1024), b varchar(1024) generated always as (found_rows()) virtual);
|
||||
ERROR HY000: Function or expression 'found_rows()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# GET_LOCK()
|
||||
create table t1 (a varchar(1024), b varchar(1024) generated always as (get_lock(a,10)) virtual);
|
||||
ERROR HY000: Function or expression 'get_lock()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# IS_FREE_LOCK()
|
||||
create table t1 (a varchar(1024), b varchar(1024) generated always as (is_free_lock(a)) virtual);
|
||||
ERROR HY000: Function or expression 'is_free_lock()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# IS_USED_LOCK()
|
||||
create table t1 (a varchar(1024), b varchar(1024) generated always as (is_used_lock(a)) virtual);
|
||||
ERROR HY000: Function or expression 'is_used_lock()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# LAST_INSERT_ID()
|
||||
create table t1 (a int generated always as (last_insert_id()) virtual);
|
||||
ERROR HY000: Function or expression 'last_insert_id()' cannot be used in the GENERATED ALWAYS AS clause of `a`
|
||||
# MASTER_POS_WAIT()
|
||||
create table t1 (a varchar(32), b int generated always as (master_pos_wait(a,0,2)) virtual);
|
||||
ERROR HY000: Function or expression 'master_pos_wait()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# NAME_CONST()
|
||||
create table t1 (a varchar(32) generated always as (name_const('test',1)) virtual);
|
||||
ERROR HY000: Function or expression 'name_const()' cannot be used in the GENERATED ALWAYS AS clause of `a`
|
||||
# RELEASE_LOCK()
|
||||
create table t1 (a varchar(32), b int generated always as (release_lock(a)) virtual);
|
||||
ERROR HY000: Function or expression 'release_lock()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# ROW_COUNT()
|
||||
create table t1 (a int generated always as (row_count()) virtual);
|
||||
ERROR HY000: Function or expression 'row_count()' cannot be used in the GENERATED ALWAYS AS clause of `a`
|
||||
# SLEEP()
|
||||
create table t1 (a int, b int generated always as (sleep(a)) virtual);
|
||||
ERROR HY000: Function or expression 'sleep()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# VALUES()
|
||||
create table t1 (a varchar(1024), b varchar(1024) generated always as (values(a)) virtual);
|
||||
ERROR HY000: Function or expression 'values()' cannot be used in the GENERATED ALWAYS AS clause of `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 generated always as (p1()) virtual);
|
||||
ERROR HY000: Function or expression '`p1`()' cannot be used in the GENERATED ALWAYS AS clause of `a`
|
||||
create table t1 (a int generated always as (f1()) virtual);
|
||||
ERROR HY000: Function or expression '`f1`()' cannot be used in the GENERATED ALWAYS AS clause of `a`
|
||||
drop procedure p1;
|
||||
drop function f1;
|
||||
# Unknown functions
|
||||
create table t1 (a int generated always as (f1()) virtual);
|
||||
ERROR HY000: Function or expression '`f1`()' cannot be used in the GENERATED ALWAYS AS clause of `a`
|
||||
#
|
||||
# GROUP BY FUNCTIONS
|
||||
#
|
||||
# AVG()
|
||||
create table t1 (a int, b int generated always as (avg(a)) virtual);
|
||||
ERROR HY000: Function or expression 'avg()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# BIT_AND()
|
||||
create table t1 (a int, b int generated always as (bit_and(a)) virtual);
|
||||
ERROR HY000: Function or expression 'bit_and()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# BIT_OR()
|
||||
create table t1 (a int, b int generated always as (bit_or(a)) virtual);
|
||||
ERROR HY000: Function or expression 'bit_or()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# BIT_XOR()
|
||||
create table t1 (a int, b int generated always as (bit_xor(a)) virtual);
|
||||
ERROR HY000: Function or expression 'bit_xor()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# COUNT(DISTINCT)
|
||||
create table t1 (a int, b int generated always as (count(distinct a)) virtual);
|
||||
ERROR HY000: Function or expression 'count(distinct )' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# COUNT()
|
||||
create table t1 (a int, b int generated always as (count(a)) virtual);
|
||||
ERROR HY000: Function or expression 'count()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# GROUP_CONCAT()
|
||||
create table t1 (a varchar(32), b int generated always as (group_concat(a,'')) virtual);
|
||||
ERROR HY000: Function or expression 'group_concat()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# MAX()
|
||||
create table t1 (a int, b int generated always as (max(a)) virtual);
|
||||
ERROR HY000: Function or expression 'max()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# MIN()
|
||||
create table t1 (a int, b int generated always as (min(a)) virtual);
|
||||
ERROR HY000: Function or expression 'min()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# STD()
|
||||
create table t1 (a int, b int generated always as (std(a)) virtual);
|
||||
ERROR HY000: Function or expression 'std()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# STDDEV_POP()
|
||||
create table t1 (a int, b int generated always as (stddev_pop(a)) virtual);
|
||||
ERROR HY000: Function or expression 'std()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# STDDEV_SAMP()
|
||||
create table t1 (a int, b int generated always as (stddev_samp(a)) virtual);
|
||||
ERROR HY000: Function or expression 'std()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# STDDEV()
|
||||
create table t1 (a int, b int generated always as (stddev(a)) virtual);
|
||||
ERROR HY000: Function or expression 'std()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# SUM()
|
||||
create table t1 (a int, b int generated always as (sum(a)) virtual);
|
||||
ERROR HY000: Function or expression 'sum()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# VAR_POP()
|
||||
create table t1 (a int, b int generated always as (var_pop(a)) virtual);
|
||||
ERROR HY000: Function or expression 'variance()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# VAR_SAMP()
|
||||
create table t1 (a int, b int generated always as (var_samp(a)) virtual);
|
||||
ERROR HY000: Function or expression 'var_samp()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# VARIANCE()
|
||||
create table t1 (a int, b int generated always as (variance(a)) virtual);
|
||||
ERROR HY000: Function or expression 'variance()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
#
|
||||
# Sub-selects
|
||||
#
|
||||
create table t1 (a int);
|
||||
create table t2 (a int, b int generated always as (select count(*) virtual from t1));
|
||||
ERROR HY000: Function or expression 'select ...' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
drop table t1;
|
||||
#
|
||||
# Long expression
|
||||
create table t1 (a int, b varchar(300) generated always as (concat(a,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')) virtual);
|
||||
drop table t1;
|
||||
create table t1 (a int, b varchar(300) generated always as (concat(a,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')) virtual);
|
||||
drop table t1;
|
||||
#
|
||||
# Constant expression
|
||||
create table t1 (a int generated always as (PI()) virtual);
|
||||
drop table t1;
|
||||
# bug#21098119: GCOL WITH MATCH/AGAINST -->
|
||||
# ASSERTION FAILED: TR && TR->TABLE->FILE
|
||||
#
|
||||
create table t1 (a int);
|
||||
alter table t1 add column r blob generated always
|
||||
as (match(a) against ('' in boolean mode)) virtual;
|
||||
ERROR HY000: Function or expression 'match ... against()' cannot be used in the GENERATED ALWAYS AS clause of `r`
|
||||
drop table t1;
|
||||
DROP VIEW IF EXISTS v1,v2;
|
||||
DROP TABLE IF EXISTS t1,t2,t3;
|
||||
DROP PROCEDURE IF EXISTS p1;
|
||||
DROP FUNCTION IF EXISTS f1;
|
||||
DROP TRIGGER IF EXISTS trg1;
|
||||
DROP TRIGGER IF EXISTS trg2;
|
||||
set sql_warnings = 0;
|
181
mysql-test/suite/gcol/r/gcol_blocked_sql_funcs_myisam.result
Normal file
181
mysql-test/suite/gcol/r/gcol_blocked_sql_funcs_myisam.result
Normal file
|
@ -0,0 +1,181 @@
|
|||
SET @@session.default_storage_engine = 'MyISAM';
|
||||
create or replace table t1 (b double generated always as (rand()) virtual);
|
||||
create or replace table t1 (a datetime generated always as (curdate()) virtual);
|
||||
create or replace table t1 (a datetime generated always as (current_date) virtual);
|
||||
create or replace table t1 (a datetime generated always as (current_date()) virtual);
|
||||
create or replace table t1 (a datetime generated always as (current_time) virtual);
|
||||
create or replace table t1 (a datetime generated always as (current_time()) virtual);
|
||||
create or replace table t1 (a datetime generated always as (current_timestamp()) virtual);
|
||||
create or replace table t1 (a datetime generated always as (current_timestamp) virtual);
|
||||
create or replace table t1 (a datetime generated always as (curtime()) virtual);
|
||||
create or replace table t1 (a datetime, b varchar(10) generated always as (localtime()) virtual);
|
||||
create or replace table t1 (a datetime, b varchar(10) generated always as (localtime) virtual);
|
||||
create or replace table t1 (a datetime, b varchar(10) generated always as (localtimestamp()) virtual);
|
||||
create or replace table t1 (a datetime, b varchar(10) generated always as (localtimestamp) virtual);
|
||||
create or replace table t1 (a datetime, b varchar(10) generated always as (now()) virtual);
|
||||
create or replace table t1 (a int, b varchar(10) generated always as (sysdate()) virtual);
|
||||
create or replace table t1 (a datetime, b datetime generated always as (unix_timestamp()) virtual);
|
||||
create or replace table t1 (a datetime, b datetime generated always as (utc_date()) virtual);
|
||||
create or replace table t1 (a datetime, b datetime generated always as (utc_time()) virtual);
|
||||
create or replace table t1 (a datetime, b datetime generated always as (utc_timestamp()) virtual);
|
||||
create or replace table t1 (a int generated always as (connection_id()) virtual);
|
||||
create or replace table t1 (a varchar(32) generated always as (current_user()) virtual);
|
||||
create or replace table t1 (a varchar(32) generated always as (current_user) virtual);
|
||||
create or replace table t1 (a varchar(1024), b varchar(1024) generated always as (database()) virtual);
|
||||
create or replace table t1 (a varchar(32) generated always as (schema()) virtual);
|
||||
create or replace table t1 (a varchar(32) generated always as (session_user()) virtual);
|
||||
create or replace table t1 (a varchar(32) generated always as (system_user()) virtual);
|
||||
create or replace table t1 (a varchar(1024), b varchar(1024) generated always as (user()) virtual);
|
||||
create or replace table t1 (a varchar(1024) generated always as (uuid_short()) virtual);
|
||||
create or replace table t1 (a varchar(1024) generated always as (uuid()) virtual);
|
||||
create or replace table t1 (a varchar(1024), b varchar(1024) generated always as (version()) virtual);
|
||||
create or replace table t1 (a varchar(1024), b varchar(1024) generated always as (encrypt(a)) virtual);
|
||||
create or replace table t1 (a varchar(1024), b varchar(1024) generated always as (UpdateXML(a,'/a','<e>fff</e>')) virtual);
|
||||
drop table t1;
|
||||
# LOAD_FILE()
|
||||
create table t1 (a varchar(64), b varchar(1024) generated always as (load_file(a)) virtual);
|
||||
ERROR HY000: Function or expression 'load_file()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# MATCH()
|
||||
create table t1 (a varchar(32), b bool generated always as (match a against ('sample text')) virtual);
|
||||
ERROR HY000: Function or expression 'match ... against()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# BENCHMARK()
|
||||
create table t1 (a varchar(1024), b varchar(1024) generated always as (benchmark(a,3)) virtual);
|
||||
ERROR HY000: Function or expression 'benchmark()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# FOUND_ROWS()
|
||||
create table t1 (a varchar(1024), b varchar(1024) generated always as (found_rows()) virtual);
|
||||
ERROR HY000: Function or expression 'found_rows()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# GET_LOCK()
|
||||
create table t1 (a varchar(1024), b varchar(1024) generated always as (get_lock(a,10)) virtual);
|
||||
ERROR HY000: Function or expression 'get_lock()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# IS_FREE_LOCK()
|
||||
create table t1 (a varchar(1024), b varchar(1024) generated always as (is_free_lock(a)) virtual);
|
||||
ERROR HY000: Function or expression 'is_free_lock()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# IS_USED_LOCK()
|
||||
create table t1 (a varchar(1024), b varchar(1024) generated always as (is_used_lock(a)) virtual);
|
||||
ERROR HY000: Function or expression 'is_used_lock()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# LAST_INSERT_ID()
|
||||
create table t1 (a int generated always as (last_insert_id()) virtual);
|
||||
ERROR HY000: Function or expression 'last_insert_id()' cannot be used in the GENERATED ALWAYS AS clause of `a`
|
||||
# MASTER_POS_WAIT()
|
||||
create table t1 (a varchar(32), b int generated always as (master_pos_wait(a,0,2)) virtual);
|
||||
ERROR HY000: Function or expression 'master_pos_wait()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# NAME_CONST()
|
||||
create table t1 (a varchar(32) generated always as (name_const('test',1)) virtual);
|
||||
ERROR HY000: Function or expression 'name_const()' cannot be used in the GENERATED ALWAYS AS clause of `a`
|
||||
# RELEASE_LOCK()
|
||||
create table t1 (a varchar(32), b int generated always as (release_lock(a)) virtual);
|
||||
ERROR HY000: Function or expression 'release_lock()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# ROW_COUNT()
|
||||
create table t1 (a int generated always as (row_count()) virtual);
|
||||
ERROR HY000: Function or expression 'row_count()' cannot be used in the GENERATED ALWAYS AS clause of `a`
|
||||
# SLEEP()
|
||||
create table t1 (a int, b int generated always as (sleep(a)) virtual);
|
||||
ERROR HY000: Function or expression 'sleep()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# VALUES()
|
||||
create table t1 (a varchar(1024), b varchar(1024) generated always as (values(a)) virtual);
|
||||
ERROR HY000: Function or expression 'values()' cannot be used in the GENERATED ALWAYS AS clause of `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 generated always as (p1()) virtual);
|
||||
ERROR HY000: Function or expression '`p1`()' cannot be used in the GENERATED ALWAYS AS clause of `a`
|
||||
create table t1 (a int generated always as (f1()) virtual);
|
||||
ERROR HY000: Function or expression '`f1`()' cannot be used in the GENERATED ALWAYS AS clause of `a`
|
||||
drop procedure p1;
|
||||
drop function f1;
|
||||
# Unknown functions
|
||||
create table t1 (a int generated always as (f1()) virtual);
|
||||
ERROR HY000: Function or expression '`f1`()' cannot be used in the GENERATED ALWAYS AS clause of `a`
|
||||
#
|
||||
# GROUP BY FUNCTIONS
|
||||
#
|
||||
# AVG()
|
||||
create table t1 (a int, b int generated always as (avg(a)) virtual);
|
||||
ERROR HY000: Function or expression 'avg()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# BIT_AND()
|
||||
create table t1 (a int, b int generated always as (bit_and(a)) virtual);
|
||||
ERROR HY000: Function or expression 'bit_and()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# BIT_OR()
|
||||
create table t1 (a int, b int generated always as (bit_or(a)) virtual);
|
||||
ERROR HY000: Function or expression 'bit_or()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# BIT_XOR()
|
||||
create table t1 (a int, b int generated always as (bit_xor(a)) virtual);
|
||||
ERROR HY000: Function or expression 'bit_xor()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# COUNT(DISTINCT)
|
||||
create table t1 (a int, b int generated always as (count(distinct a)) virtual);
|
||||
ERROR HY000: Function or expression 'count(distinct )' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# COUNT()
|
||||
create table t1 (a int, b int generated always as (count(a)) virtual);
|
||||
ERROR HY000: Function or expression 'count()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# GROUP_CONCAT()
|
||||
create table t1 (a varchar(32), b int generated always as (group_concat(a,'')) virtual);
|
||||
ERROR HY000: Function or expression 'group_concat()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# MAX()
|
||||
create table t1 (a int, b int generated always as (max(a)) virtual);
|
||||
ERROR HY000: Function or expression 'max()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# MIN()
|
||||
create table t1 (a int, b int generated always as (min(a)) virtual);
|
||||
ERROR HY000: Function or expression 'min()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# STD()
|
||||
create table t1 (a int, b int generated always as (std(a)) virtual);
|
||||
ERROR HY000: Function or expression 'std()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# STDDEV_POP()
|
||||
create table t1 (a int, b int generated always as (stddev_pop(a)) virtual);
|
||||
ERROR HY000: Function or expression 'std()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# STDDEV_SAMP()
|
||||
create table t1 (a int, b int generated always as (stddev_samp(a)) virtual);
|
||||
ERROR HY000: Function or expression 'std()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# STDDEV()
|
||||
create table t1 (a int, b int generated always as (stddev(a)) virtual);
|
||||
ERROR HY000: Function or expression 'std()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# SUM()
|
||||
create table t1 (a int, b int generated always as (sum(a)) virtual);
|
||||
ERROR HY000: Function or expression 'sum()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# VAR_POP()
|
||||
create table t1 (a int, b int generated always as (var_pop(a)) virtual);
|
||||
ERROR HY000: Function or expression 'variance()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# VAR_SAMP()
|
||||
create table t1 (a int, b int generated always as (var_samp(a)) virtual);
|
||||
ERROR HY000: Function or expression 'var_samp()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
# VARIANCE()
|
||||
create table t1 (a int, b int generated always as (variance(a)) virtual);
|
||||
ERROR HY000: Function or expression 'variance()' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
#
|
||||
# Sub-selects
|
||||
#
|
||||
create table t1 (a int);
|
||||
create table t2 (a int, b int generated always as (select count(*) virtual from t1));
|
||||
ERROR HY000: Function or expression 'select ...' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
drop table t1;
|
||||
#
|
||||
# Long expression
|
||||
create table t1 (a int, b varchar(300) generated always as (concat(a,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')) virtual);
|
||||
drop table t1;
|
||||
create table t1 (a int, b varchar(300) generated always as (concat(a,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')) virtual);
|
||||
drop table t1;
|
||||
#
|
||||
# Constant expression
|
||||
create table t1 (a int generated always as (PI()) virtual);
|
||||
drop table t1;
|
||||
# bug#21098119: GCOL WITH MATCH/AGAINST -->
|
||||
# ASSERTION FAILED: TR && TR->TABLE->FILE
|
||||
#
|
||||
create table t1 (a int);
|
||||
alter table t1 add column r blob generated always
|
||||
as (match(a) against ('' in boolean mode)) virtual;
|
||||
ERROR HY000: Function or expression 'match ... against()' cannot be used in the GENERATED ALWAYS AS clause of `r`
|
||||
drop table t1;
|
||||
DROP VIEW IF EXISTS v1,v2;
|
||||
DROP TABLE IF EXISTS t1,t2,t3;
|
||||
DROP PROCEDURE IF EXISTS p1;
|
||||
DROP FUNCTION IF EXISTS f1;
|
||||
DROP TRIGGER IF EXISTS trg1;
|
||||
DROP TRIGGER IF EXISTS trg2;
|
||||
set sql_warnings = 0;
|
32
mysql-test/suite/gcol/r/gcol_bug20746926.result
Normal file
32
mysql-test/suite/gcol/r/gcol_bug20746926.result
Normal file
|
@ -0,0 +1,32 @@
|
|||
#Bug #20746926: GENERATED COLUMNS: INVALID READ OF THD WHEN WARNINGS
|
||||
#
|
||||
# Testing cmp_item_datetime
|
||||
connect con1,localhost,root,,;
|
||||
set sql_mode='';
|
||||
create table t1 (
|
||||
a date not null,
|
||||
b mediumtext generated always as ((a not in (a,a))) virtual,
|
||||
c timestamp generated always as ((a not in (b,b))) stored
|
||||
);
|
||||
insert t1(a) values(7777777777);
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'a' at row 1
|
||||
Warning 1292 Incorrect datetime value: '0'
|
||||
show warnings;
|
||||
Level Code Message
|
||||
Warning 1265 Data truncated for column 'a' at row 1
|
||||
Warning 1292 Incorrect datetime value: '0'
|
||||
disconnect con1;
|
||||
connect con2,localhost,root,,;
|
||||
set sql_mode='';
|
||||
insert t1(a) values(6666666666);
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'a' at row 1
|
||||
Warning 1292 Incorrect datetime value: '0'
|
||||
show warnings;
|
||||
Level Code Message
|
||||
Warning 1265 Data truncated for column 'a' at row 1
|
||||
Warning 1292 Incorrect datetime value: '0'
|
||||
drop table t1;
|
||||
disconnect con2;
|
||||
connection default;
|
628
mysql-test/suite/gcol/r/gcol_bugfixes.result
Normal file
628
mysql-test/suite/gcol/r/gcol_bugfixes.result
Normal file
|
@ -0,0 +1,628 @@
|
|||
# Bug#21230709: Alter table statement fails with division by zero
|
||||
CREATE TABLE t1 (
|
||||
col1 INTEGER NOT NULL,
|
||||
col2 INTEGER NOT NULL,
|
||||
col3 INTEGER NOT NULL,
|
||||
gcol1 INTEGER GENERATED ALWAYS AS (col3 + col3) VIRTUAL,
|
||||
col4 INTEGER DEFAULT NULL,
|
||||
col5 INTEGER DEFAULT NULL,
|
||||
col6 INTEGER DEFAULT NULL,
|
||||
col7 INTEGER DEFAULT NULL,
|
||||
col8 INTEGER DEFAULT NULL,
|
||||
col9 INTEGER DEFAULT NULL,
|
||||
col10 INTEGER DEFAULT NULL,
|
||||
col11 INTEGER DEFAULT NULL,
|
||||
col12 INTEGER DEFAULT NULL,
|
||||
col13 INTEGER DEFAULT NULL,
|
||||
col14 INTEGER DEFAULT NULL,
|
||||
col15 INTEGER DEFAULT NULL,
|
||||
col16 INTEGER DEFAULT NULL,
|
||||
col17 INTEGER DEFAULT NULL,
|
||||
col18 INTEGER DEFAULT NULL,
|
||||
col19 INTEGER DEFAULT NULL,
|
||||
col20 INTEGER DEFAULT NULL,
|
||||
col21 INTEGER DEFAULT NULL,
|
||||
col22 INTEGER DEFAULT NULL,
|
||||
col23 INTEGER DEFAULT NULL,
|
||||
col24 INTEGER DEFAULT NULL,
|
||||
col25 INTEGER DEFAULT NULL,
|
||||
col26 INTEGER DEFAULT NULL,
|
||||
col27 INTEGER DEFAULT NULL,
|
||||
col28 INTEGER DEFAULT NULL,
|
||||
col29 INTEGER DEFAULT NULL,
|
||||
col30 INTEGER DEFAULT NULL,
|
||||
col31 INTEGER DEFAULT NULL,
|
||||
col32 INTEGER DEFAULT NULL,
|
||||
col33 INTEGER DEFAULT NULL,
|
||||
gcol2 INTEGER GENERATED ALWAYS AS (col2 + col2) VIRTUAL,
|
||||
gcol3 INTEGER GENERATED ALWAYS AS (gcol2 / gcol2) VIRTUAL,
|
||||
PRIMARY KEY (col1),
|
||||
KEY idx1 (gcol1)
|
||||
) engine=innodb;
|
||||
INSERT INTO t1 (col1, col2, col3)
|
||||
VALUES (0,1,2), (1,2,3), (2,3,4), (3,4,5), (4,5,6);
|
||||
FLUSH TABLE t1;
|
||||
ALTER TABLE t1 ADD COLUMN extra INTEGER;
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# Bug 21340801 WL8149:ASSERTION `IS_VIRTUAL_GCOL()' FAILED
|
||||
#
|
||||
CREATE TABLE t1 (
|
||||
c_blob BLOB,
|
||||
c_blob_key BLOB GENERATED ALWAYS AS (REPEAT(c_blob,15)) STORED,
|
||||
KEY (c_blob_key(200))
|
||||
);
|
||||
INSERT INTO t1 (c_blob) VALUES ('xceks');
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# Bug#21345972 WL8149:JOIN_CACHE::FILTER_VIRTUAL_GCOL_BASE_COLS(): ASSERTION `FALSE' FAILED.
|
||||
#
|
||||
CREATE TABLE c (
|
||||
pk INTEGER AUTO_INCREMENT,
|
||||
col_int_nokey INTEGER /*! NULL */,
|
||||
col_int_key INTEGER GENERATED ALWAYS AS
|
||||
(col_int_nokey + col_int_nokey) VIRTUAL not null,
|
||||
col_date_nokey DATE /*! NULL */,
|
||||
col_date_key DATE GENERATED ALWAYS AS
|
||||
(DATE_ADD(col_date_nokey,interval 30 day)) VIRTUAL not null,
|
||||
col_datetime_nokey DATETIME /*! NULL */,
|
||||
col_time_nokey TIME /*! NULL */,
|
||||
col_datetime_key DATETIME GENERATED ALWAYS AS
|
||||
(ADDTIME(col_datetime_nokey, col_time_nokey)) VIRTUAL not null,
|
||||
col_time_key TIME GENERATED ALWAYS AS
|
||||
(ADDTIME(col_datetime_nokey, col_time_nokey)) VIRTUAL not null,
|
||||
col_varchar_nokey VARCHAR(1) /*! NULL */,
|
||||
col_varchar_key VARCHAR(2) GENERATED ALWAYS AS
|
||||
(CONCAT(col_varchar_nokey, col_varchar_nokey)) VIRTUAL not null,
|
||||
PRIMARY KEY (pk),
|
||||
UNIQUE KEY (col_int_key),
|
||||
UNIQUE KEY (col_varchar_key),
|
||||
UNIQUE KEY (col_date_key),
|
||||
KEY (col_time_key),
|
||||
KEY (col_datetime_key),
|
||||
UNIQUE KEY (col_int_key, col_varchar_key),
|
||||
KEY (col_int_key, col_int_nokey),
|
||||
KEY(col_int_key,col_date_key),
|
||||
KEY(col_int_key, col_time_key),
|
||||
KEY(col_int_key, col_datetime_key),
|
||||
UNIQUE
|
||||
KEY(col_date_key,col_time_key,col_datetime_key),
|
||||
UNIQUE KEY (col_varchar_key, col_varchar_nokey),
|
||||
UNIQUE KEY (col_int_key, col_varchar_key,
|
||||
col_date_key, col_time_key, col_datetime_key)
|
||||
) ENGINE=INNODB;
|
||||
INSERT /*! IGNORE */ INTO c (
|
||||
col_int_nokey,
|
||||
col_date_nokey,
|
||||
col_time_nokey,
|
||||
col_datetime_nokey,
|
||||
col_varchar_nokey
|
||||
) VALUES (7, '2004-04-09', '14:03:03.042673',
|
||||
'2001-11-28 00:50:27.051028', 'c'),(1, '2006-05-13', '01:46:09.016386',
|
||||
'2007-10-09 19:53:04.008332', NULL);
|
||||
Warnings:
|
||||
Warning 1048 Column 'col_varchar_key' cannot be null
|
||||
CREATE TABLE bb (
|
||||
pk INTEGER AUTO_INCREMENT,
|
||||
col_int_nokey INTEGER /*! NULL */,
|
||||
col_int_key INTEGER GENERATED ALWAYS AS
|
||||
(col_int_nokey + col_int_nokey) VIRTUAL not null,
|
||||
col_date_nokey DATE /*! NULL */,
|
||||
col_date_key DATE GENERATED ALWAYS AS
|
||||
(DATE_ADD(col_date_nokey,interval 30 day)) VIRTUAL not null,
|
||||
col_datetime_nokey DATETIME /*! NULL */,
|
||||
col_time_nokey TIME /*! NULL */,
|
||||
col_datetime_key DATETIME GENERATED ALWAYS AS
|
||||
(ADDTIME(col_datetime_nokey, col_time_nokey)) VIRTUAL not null,
|
||||
col_time_key TIME GENERATED ALWAYS AS
|
||||
(ADDTIME(col_datetime_nokey, col_time_nokey)) VIRTUAL not null,
|
||||
col_varchar_nokey VARCHAR(1) /*! NULL */,
|
||||
col_varchar_key VARCHAR(2) GENERATED ALWAYS AS
|
||||
(CONCAT(col_varchar_nokey, col_varchar_nokey)) VIRTUAL not null,
|
||||
PRIMARY KEY (pk),
|
||||
UNIQUE KEY (col_int_key),
|
||||
UNIQUE KEY (col_varchar_key),
|
||||
UNIQUE KEY (col_date_key),
|
||||
KEY (col_time_key),
|
||||
KEY (col_datetime_key),
|
||||
UNIQUE KEY (col_int_key, col_varchar_key),
|
||||
KEY (col_int_key, col_int_nokey),
|
||||
KEY(col_int_key,col_date_key),
|
||||
KEY(col_int_key, col_time_key),
|
||||
KEY(col_int_key, col_datetime_key),
|
||||
UNIQUE
|
||||
KEY(col_date_key,col_time_key,col_datetime_key),
|
||||
UNIQUE KEY (col_varchar_key, col_varchar_nokey),
|
||||
UNIQUE KEY (col_int_key, col_varchar_key,
|
||||
col_date_key, col_time_key, col_datetime_key)
|
||||
) AUTO_INCREMENT=10 ENGINE=INNODB;
|
||||
INSERT /*! IGNORE */ INTO bb (
|
||||
col_int_nokey,
|
||||
col_date_nokey,
|
||||
col_time_nokey,
|
||||
col_datetime_nokey,
|
||||
col_varchar_nokey
|
||||
) VALUES (0, '2003-08-04', '01:48:05.048577',
|
||||
'2006-11-03 00:00:00', 'p'),(2, '2007-11-06', '00:00:00', '2009-11-26 19:28:11.005115', 'n');
|
||||
CREATE TABLE cc (
|
||||
pk INTEGER AUTO_INCREMENT,
|
||||
col_int_nokey INTEGER /*! NULL */,
|
||||
col_int_key INTEGER GENERATED ALWAYS AS
|
||||
(col_int_nokey + col_int_nokey) VIRTUAL not null,
|
||||
col_date_nokey DATE /*! NULL */,
|
||||
col_date_key DATE GENERATED ALWAYS AS
|
||||
(DATE_ADD(col_date_nokey,interval 30 day)) VIRTUAL not null,
|
||||
col_datetime_nokey DATETIME /*! NULL */,
|
||||
col_time_nokey TIME /*! NULL */,
|
||||
col_datetime_key DATETIME GENERATED ALWAYS AS
|
||||
(ADDTIME(col_datetime_nokey, col_time_nokey)) VIRTUAL not null,
|
||||
col_time_key TIME GENERATED ALWAYS AS
|
||||
(ADDTIME(col_datetime_nokey, col_time_nokey)) VIRTUAL not null,
|
||||
col_varchar_nokey VARCHAR(1) /*! NULL */,
|
||||
col_varchar_key VARCHAR(2) GENERATED ALWAYS AS
|
||||
(CONCAT(col_varchar_nokey, col_varchar_nokey)) VIRTUAL not null,
|
||||
PRIMARY KEY (pk),
|
||||
UNIQUE KEY (col_int_key),
|
||||
UNIQUE KEY (col_varchar_key),
|
||||
UNIQUE KEY (col_date_key),
|
||||
KEY (col_time_key),
|
||||
KEY (col_datetime_key),
|
||||
UNIQUE KEY (col_int_key, col_varchar_key),
|
||||
KEY (col_int_key, col_int_nokey),
|
||||
KEY(col_int_key,col_date_key),
|
||||
KEY(col_int_key, col_time_key),
|
||||
KEY(col_int_key, col_datetime_key),
|
||||
UNIQUE
|
||||
KEY(col_date_key,col_time_key,col_datetime_key),
|
||||
UNIQUE KEY (col_varchar_key, col_varchar_nokey),
|
||||
UNIQUE KEY (col_int_key, col_varchar_key,
|
||||
col_date_key, col_time_key, col_datetime_key)
|
||||
) AUTO_INCREMENT=10 ENGINE=INNODB;
|
||||
INSERT /*! IGNORE */ INTO cc (
|
||||
col_int_nokey,
|
||||
col_date_nokey,
|
||||
col_time_nokey,
|
||||
col_datetime_nokey,
|
||||
col_varchar_nokey
|
||||
) VALUES (172, '2009-04-23', '00:00:00', '2000-12-07 10:17:40.013275', 'h'),(NULL, '2002-10-06', '00:50:49.017545', NULL, 'm');
|
||||
Warnings:
|
||||
Warning 1048 Column 'col_int_key' cannot be null
|
||||
Warning 1048 Column 'col_datetime_key' cannot be null
|
||||
Warning 1048 Column 'col_time_key' cannot be null
|
||||
EXPLAIN SELECT
|
||||
gp1 . col_datetime_key AS g1
|
||||
FROM cc AS gp1 LEFT JOIN c AS gp2 ON ( gp2 . col_datetime_key <> gp1 .
|
||||
col_time_nokey )
|
||||
WHERE
|
||||
gp1 . col_varchar_nokey IN
|
||||
(
|
||||
SELECT
|
||||
DISTINCT p1 . col_varchar_key AS p1
|
||||
FROM bb AS p1 LEFT JOIN bb AS p2
|
||||
ON ( p1 . col_int_key = p2 . pk )
|
||||
)
|
||||
AND gp1 . col_varchar_nokey = 'b'
|
||||
HAVING g1 > 6;
|
||||
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE gp1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where
|
||||
1 SIMPLE p1 NULL const col_varchar_key,col_varchar_key_2 col_varchar_key 4 const 1 100.00 NULL
|
||||
1 SIMPLE p2 NULL eq_ref PRIMARY PRIMARY 4 test.p1.col_int_key 1 100.00 Using index; FirstMatch(gp1)
|
||||
1 SIMPLE gp2 NULL index NULL col_datetime_key 5 NULL 2 100.00 Using where; Using index; Using join buffer (Block Nested Loop)
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: '6' for column 'col_datetime_key' at row 1
|
||||
Note 1003 /* select#1 */ select `test`.`gp1`.`col_datetime_key` AS `g1` from `test`.`cc` `gp1` semi join (`test`.`bb` `p1` left join `test`.`bb` `p2` on((`test`.`p1`.`col_int_key` = `test`.`p2`.`pk`))) left join `test`.`c` `gp2` on((`test`.`gp2`.`col_datetime_key` <> `test`.`gp1`.`col_time_nokey`)) where ((`test`.`gp1`.`col_varchar_nokey` = 'b') and ('b' = `test`.`p1`.`col_varchar_key`)) having (`g1` > 6)
|
||||
SELECT
|
||||
gp1 . col_datetime_key AS g1
|
||||
FROM cc AS gp1 LEFT JOIN c AS gp2 ON ( gp2 . col_datetime_key <> gp1 .
|
||||
col_time_nokey )
|
||||
WHERE
|
||||
gp1 . col_varchar_nokey IN
|
||||
(
|
||||
SELECT
|
||||
DISTINCT p1 . col_varchar_key AS p1
|
||||
FROM bb AS p1 LEFT JOIN bb AS p2
|
||||
ON ( p1 . col_int_key = p2 . pk )
|
||||
)
|
||||
AND gp1 . col_varchar_nokey = 'b'
|
||||
HAVING g1 > 6;
|
||||
g1
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: '6' for column 'col_datetime_key' at row 1
|
||||
DROP TABLE bb, c, cc;
|
||||
# Bug#21284646: Assertion !(table || table->read_set || bitmap_is_set())
|
||||
CREATE TABLE c (
|
||||
pk INTEGER AUTO_INCREMENT,
|
||||
col_int_nokey INTEGER NOT NULL,
|
||||
col_int_key INTEGER GENERATED ALWAYS AS (col_int_nokey + col_int_nokey) VIRTUAL not null,
|
||||
col_date_nokey DATE NOT NULL,
|
||||
col_date_key DATE GENERATED ALWAYS AS (DATE_ADD(col_date_nokey,interval 30 day)) VIRTUAL not null,
|
||||
col_datetime_nokey DATETIME NOT NULL,
|
||||
col_time_nokey TIME NOT NULL,
|
||||
col_datetime_key DATETIME GENERATED ALWAYS AS (ADDTIME(col_datetime_nokey, col_time_nokey)) VIRTUAL not null,
|
||||
col_time_key TIME GENERATED ALWAYS AS (ADDTIME(col_datetime_nokey, col_time_nokey)) VIRTUAL not null,
|
||||
col_varchar_nokey VARCHAR(1) NOT NULL,
|
||||
col_varchar_key VARCHAR(2) GENERATED ALWAYS AS (CONCAT(col_varchar_nokey, col_varchar_nokey)) VIRTUAL not null,
|
||||
PRIMARY KEY (pk,col_int_nokey),
|
||||
UNIQUE KEY (col_int_key),
|
||||
UNIQUE KEY (col_varchar_key),
|
||||
UNIQUE KEY (col_date_key),
|
||||
KEY (col_time_key),
|
||||
KEY (col_datetime_key),
|
||||
UNIQUE KEY (col_int_key, col_varchar_key),
|
||||
KEY (col_int_key, col_int_nokey),
|
||||
KEY(col_int_key,col_date_key),
|
||||
KEY(col_int_key, col_time_key),
|
||||
KEY(col_int_key, col_datetime_key),
|
||||
UNIQUE KEY (col_date_key,col_time_key,col_datetime_key),
|
||||
UNIQUE KEY (col_varchar_key, col_varchar_nokey),
|
||||
UNIQUE KEY (col_int_key, col_varchar_key, col_date_key, col_time_key, col_datetime_key)
|
||||
) ENGINE=INNODB;
|
||||
INSERT INTO c (col_int_nokey, col_date_nokey, col_time_nokey, col_datetime_nokey, col_varchar_nokey) VALUES
|
||||
(1, '2009-12-01', '00:21:38.058143', '2007-05-28 00:00:00', 'c'),
|
||||
(8, '2004-12-17', '04:08:02.046897', '2009-07-25 09:21:20.064099', 'm'),
|
||||
(9, '2000-03-14', '16:25:11.040240', '2002-01-16 00:00:00', 'd'),
|
||||
(6, '2006-05-25', '19:47:59.011283', '2001-02-15 03:08:38.035426', 'y'),
|
||||
(2, '2002-10-13', '00:00:00', '1900-01-01 00:00:00', 's'),
|
||||
(4, '1900-01-01', '15:57:25.019666', '2005-08-15 00:00:00', 'r');
|
||||
ANALYZE TABLE c;
|
||||
Table Op Msg_type Msg_text
|
||||
test.c analyze status OK
|
||||
explain SELECT COUNT(DISTINCT col_varchar_key) AS x
|
||||
FROM c
|
||||
WHERE col_varchar_key IN ('rr', 'rr') OR
|
||||
col_int_nokey <> 9 AND
|
||||
pk >= 8
|
||||
HAVING x > '2000-02-06'
|
||||
ORDER BY col_time_nokey, pk;
|
||||
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE c NULL index_merge PRIMARY,col_varchar_key,col_int_key_2,col_varchar_key_2,col_int_key_7 col_varchar_key,PRIMARY 4,4 NULL 2 100.00 Using sort_union(col_varchar_key,PRIMARY); Using where
|
||||
Warnings:
|
||||
Note 1003 /* select#1 */ select count(distinct `test`.`c`.`col_varchar_key`) AS `x` from `test`.`c` where ((`test`.`c`.`col_varchar_key` in ('rr','rr')) or ((`test`.`c`.`col_int_nokey` <> 9) and (`test`.`c`.`pk` >= 8))) having (`x` > '2000-02-06')
|
||||
SELECT COUNT(DISTINCT col_varchar_key) AS x
|
||||
FROM c
|
||||
WHERE col_varchar_key IN ('rr', 'rr') OR
|
||||
col_int_nokey <> 9 AND
|
||||
pk >= 8
|
||||
HAVING x > '2000-02-06'
|
||||
ORDER BY col_time_nokey, pk;
|
||||
x
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: '2000-02-06'
|
||||
DROP TABLE c;
|
||||
# Bug#21341044: Conditional jump at sort_param::make_sort_key
|
||||
CREATE TABLE t1 (
|
||||
pk INTEGER AUTO_INCREMENT,
|
||||
col_int_nokey INTEGER /*! NULL */,
|
||||
col_int_key INTEGER GENERATED ALWAYS AS (col_int_nokey + col_int_nokey) VIRTUAL,
|
||||
col_blob_nokey BLOB /*! NULL */,
|
||||
col_blob_key BLOB GENERATED ALWAYS AS (REPEAT(col_blob_nokey,15)) VIRTUAL,
|
||||
col_longblob_nokey LONGBLOB /*! NULL */,
|
||||
col_longtext_nokey LONGTEXT /*! NULL */,
|
||||
col_longblob_key LONGBLOB GENERATED ALWAYS AS (REPEAT(col_longblob_nokey, 20)) VIRTUAL,
|
||||
col_longtext_key LONGTEXT GENERATED ALWAYS AS (REPEAT(col_longblob_nokey, 18)) VIRTUAL,
|
||||
col_text_nokey TEXT /*! NULL */,
|
||||
col_text_key TEXT GENERATED ALWAYS AS (REPEAT(col_text_nokey, 30)) VIRTUAL,
|
||||
PRIMARY KEY (pk),
|
||||
KEY (col_int_key),
|
||||
KEY (col_text_key(50)),
|
||||
KEY (col_blob_key(200)),
|
||||
KEY (col_longtext_key(200)),
|
||||
KEY (col_longblob_key(200)),
|
||||
KEY (col_int_key, col_text_key(100)),
|
||||
KEY (col_int_key, col_longtext_key(100)),
|
||||
KEY (col_int_key, col_blob_key(100)),
|
||||
KEY (col_int_key, col_longblob_key(100)),
|
||||
KEY (col_longtext_key(10), col_longblob_key(100)),
|
||||
KEY (col_int_key, col_text_key(10), col_blob_key(100), col_longtext_key(50), col_longblob_key(50))
|
||||
) engine=innodb;
|
||||
INSERT INTO t1 (col_int_nokey,col_blob_nokey,col_longtext_nokey,col_longblob_nokey,col_text_nokey)
|
||||
VALUES
|
||||
(0, 'ijcszxw', 'ijcszxw', 'ijcszxw', 'ijcszxw'),
|
||||
(5, 'jcszxwb', 'jcszxwb', 'jcszxwb', 'jcszxwb'),
|
||||
(4, 'cszxwbjjvv', 'cszxwbjjvv', 'cszxwbjjvv', 'cszxwbjjvv'),
|
||||
(3, 'szxw', 'szxw', 'szxw', 'szxw'),
|
||||
(7, 'zxwb', 'zxwb', 'zxwb', 'zxwb'),
|
||||
(42, 'xwbjjvvky', 'xwbjjvvky', 'xwbjjvvky', 'xwbjjvvky'),
|
||||
(142, 'wbjj', 'wbjj', 'wbjj', 'wbjj'),
|
||||
(5, 'bjjv', 'bjjv', 'bjjv', 'bjjv'),
|
||||
(0, 'jjvvkymalu', 'jjvvkymalu', 'jjvvkymalu', 'jjvvkymalu'),
|
||||
(3, 'j', 'j', 'j', 'j');
|
||||
SELECT alias1.pk AS field1
|
||||
FROM t1 AS alias1 LEFT OUTER JOIN t1 AS alias2
|
||||
ON alias1.col_int_key = alias2.col_int_key
|
||||
WHERE alias2.col_int_key BETWEEN 8 AND (8 + 1 ) OR
|
||||
alias2.col_int_key BETWEEN 8 AND (8 + 5 ) AND
|
||||
alias2.col_int_key != 20 OR
|
||||
alias2.col_int_key IN (8, 5, 8) AND
|
||||
alias2.col_int_key >= 0 AND
|
||||
alias2.col_int_key <= ( 8 + 75 ) AND
|
||||
alias1.pk IS NOT NULL
|
||||
ORDER BY field1;
|
||||
field1
|
||||
2
|
||||
2
|
||||
3
|
||||
8
|
||||
8
|
||||
DROP TABLE t1;
|
||||
# bug#21487651: gcols: memory leak after failed alter table
|
||||
CREATE TABLE t(a int);
|
||||
ALTER TABLE t ADD COLUMN b int GENERATED ALWAYS AS (
|
||||
date_sub(a,interval a month)) VIRTUAL;
|
||||
ALTER TABLE t ADD COLUMN c int GENERATED ALWAYS AS (sum(a));
|
||||
ERROR HY000: Invalid use of group function
|
||||
DROP TABLE t;
|
||||
#
|
||||
# Bug#21628840: CRASH/MEMORY CORRUPTION ADDING INDEXES TO VIRTUAL COLUMN
|
||||
# (II)
|
||||
#
|
||||
CREATE TABLE t1( a INT ) ENGINE = INNODB;
|
||||
INSERT INTO t1( a ) VALUES ( 1 ), ( 2 ), ( 3 ), ( 4 ), ( 5 );
|
||||
ALTER TABLE t1 ADD COLUMN b INT GENERATED ALWAYS AS (a - 1) STORED;
|
||||
ALTER TABLE t1 ADD COLUMN c INT GENERATED ALWAYS AS (b + 1) VIRTUAL;
|
||||
# Used to cause valgrind warning.
|
||||
ALTER TABLE t1 ADD INDEX( c );
|
||||
ANALYZE TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
# Make sure the index is correct. That's kinda important.
|
||||
EXPLAIN
|
||||
SELECT c FROM t1;
|
||||
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 NULL index NULL c 5 NULL 5 100.00 Using index
|
||||
Warnings:
|
||||
Note 1003 /* select#1 */ select `test`.`t1`.`c` AS `c` from `test`.`t1`
|
||||
SELECT c FROM t1;
|
||||
c
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# Bug#21797776 ASSERTION `BIT < MAP->N_BITS' FAILED.
|
||||
#
|
||||
CREATE TABLE C (
|
||||
col_int_1 INT,
|
||||
col_int_2 INT GENERATED ALWAYS AS (col_int_1 + col_int_1) STORED,
|
||||
col_int_3 INT GENERATED ALWAYS AS (col_int_2 + col_int_1) VIRTUAL
|
||||
);
|
||||
CREATE ALGORITHM=TEMPTABLE VIEW v1 AS
|
||||
SELECT
|
||||
col_int_2 AS field1, col_int_2 AS field2,
|
||||
col_int_3 AS field3, col_int_3 AS field4
|
||||
FROM C;
|
||||
SELECT * FROM v1;
|
||||
field1 field2 field3 field4
|
||||
DROP TABLE C;
|
||||
DROP VIEW v1;
|
||||
#
|
||||
# Bug#21613615 GCOLS: ASSERTION FAILED: !TABLE || (!TABLE->READ_SET || BITMAP_IS_SET
|
||||
#
|
||||
CREATE TABLE t (a INT);
|
||||
CREATE TABLE v (
|
||||
a INT,
|
||||
c INT,
|
||||
b CHAR(2) GENERATED ALWAYS AS (a IN (1)) VIRTUAL,
|
||||
KEY(c,b(1)));
|
||||
INSERT INTO v (a,c) VALUES (1,1);
|
||||
EXPLAIN SELECT 1 FROM t WHERE ( SELECT 1 FROM t ) >=ANY( SELECT c FROM v );
|
||||
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
|
||||
2 SUBQUERY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL
|
||||
Warnings:
|
||||
Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t` where 0
|
||||
SELECT 1 FROM t WHERE ( SELECT 1 FROM t ) >=ANY( SELECT c FROM v );
|
||||
1
|
||||
EXPLAIN SELECT (SELECT MAX(c) FROM v);
|
||||
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
|
||||
Warnings:
|
||||
Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`v`.`c`) from `test`.`v`) AS `(SELECT MAX(c) FROM v)`
|
||||
SELECT (SELECT MAX(c) FROM v);
|
||||
(SELECT MAX(c) FROM v)
|
||||
1
|
||||
DROP TABLE t, v;
|
||||
CREATE TABLE v (
|
||||
a INT,
|
||||
c INT,
|
||||
b CHAR(2) GENERATED ALWAYS AS (a IN (1)) VIRTUAL, KEY(c,b(1)));
|
||||
INSERT INTO v (a,c) VALUES (1,1);
|
||||
SELECT MAX(c), COUNT(b) FROM v;
|
||||
MAX(c) COUNT(b)
|
||||
1 1
|
||||
DROP TABLE v;
|
||||
CREATE TABLE v (
|
||||
a INT PRIMARY KEY,
|
||||
b INT, KEY(b));
|
||||
INSERT INTO v (a,b) VALUES (1,1);
|
||||
SELECT MAX(a) FROM v WHERE b=1;
|
||||
MAX(a)
|
||||
1
|
||||
DROP TABLE v;
|
||||
#
|
||||
# Bug#21824519: ASSERTION IN DROP TRIGGER WHEN TABLE HAS
|
||||
# VIRTUAL GENERATED COLUMN
|
||||
#
|
||||
CREATE TABLE t (a INT, b INT GENERATED ALWAYS AS (a) VIRTUAL);
|
||||
CREATE TRIGGER tr BEFORE INSERT ON t FOR EACH ROW BEGIN END;
|
||||
INSERT INTO t (a) VALUES (1);
|
||||
SELECT * FROM t;
|
||||
a b
|
||||
1 1
|
||||
DROP TRIGGER tr;
|
||||
SELECT * FROM t;
|
||||
a b
|
||||
1 1
|
||||
CREATE FUNCTION f() RETURNS INT RETURN (SELECT COUNT(*) FROM t);
|
||||
SELECT f();
|
||||
f()
|
||||
1
|
||||
DROP FUNCTION f;
|
||||
SELECT * FROM t;
|
||||
a b
|
||||
1 1
|
||||
DROP TABLE t;
|
||||
#
|
||||
# Bug#21833760 CALC_DAYNR: ASSERTION `DELSUM+(INT) Y/4-TEMP >= 0' FAILED.
|
||||
#
|
||||
CREATE TABLE C(
|
||||
c1 INT AUTO_INCREMENT,
|
||||
c8 DATETIME,
|
||||
c9 TIME,
|
||||
c11 TIME GENERATED ALWAYS AS(ADDTIME(c8,c9)) VIRTUAL,
|
||||
c13 TIME GENERATED ALWAYS AS(ADDTIME(c8,c11)) VIRTUAL,
|
||||
PRIMARY KEY(c1),
|
||||
UNIQUE KEY(c13)
|
||||
);
|
||||
INSERT INTO C (c8,c9) VALUES('1970-01-01',0),('1970-01-01',1);
|
||||
CREATE VIEW view_C AS SELECT * FROM C;
|
||||
SELECT /*+ NO_BNL(t1) */ t1.c13 FROM C AS t2 STRAIGHT_JOIN C AS t1 FORCE INDEX(c13);
|
||||
c13
|
||||
00:00:00
|
||||
00:00:01
|
||||
00:00:00
|
||||
00:00:01
|
||||
SELECT DISTINCT t1.c13 FROM C AS t1, view_C AS t2;
|
||||
c13
|
||||
00:00:00
|
||||
00:00:01
|
||||
DROP TABLE C;
|
||||
DROP VIEW view_C;
|
||||
#
|
||||
# Bug #21808680: JSON + GENERATED COLUMN CORRUPTS TABLE CACHE
|
||||
# MEMORY, CRASHES
|
||||
#
|
||||
CREATE TABLE t (a INT, b JSON, c TEXT GENERATED ALWAYS AS (REPEAT(a=b, 2)));
|
||||
INSERT INTO t (a, b) VALUES (1, '2'), (3, '3');
|
||||
SELECT * FROM t;
|
||||
a b c
|
||||
1 2 00
|
||||
3 3 11
|
||||
DROP TABLE t;
|
||||
#
|
||||
# Bug#21810529: CRASH IN ITEM_FUNC::WALK WHEN CODE JUMPS TO GARBAGE
|
||||
# LOCATION
|
||||
#
|
||||
CREATE TABLE t (a TIME,b INT GENERATED ALWAYS AS (a=1) VIRTUAL);
|
||||
ALTER TABLE t CHANGE COLUMN q w INT;
|
||||
ERROR 42S22: Unknown column 'q' in 't'
|
||||
ALTER TABLE t CHANGE COLUMN q w INT;
|
||||
ERROR 42S22: Unknown column 'q' in 't'
|
||||
ALTER TABLE t CHANGE COLUMN q w INT;
|
||||
ERROR 42S22: Unknown column 'q' in 't'
|
||||
ALTER TABLE t CHANGE COLUMN q w INT;
|
||||
ERROR 42S22: Unknown column 'q' in 't'
|
||||
DROP TABLE t;
|
||||
#
|
||||
# Bug#21940542 TOO MUCH SPAM: INNODB: COMPUTE VIRTUAL COLUMN VALUES FAILED
|
||||
#
|
||||
CREATE TABLE t(b BLOB);
|
||||
ALTER TABLE t ADD COLUMN c INT GENERATED ALWAYS AS ((1,1)) VIRTUAL;
|
||||
ERROR HY000: Expression of generated column 'c' contains a disallowed function.
|
||||
DROP TABLE t;
|
||||
CREATE TABLE t(b BLOB, c INT GENERATED ALWAYS AS ((1,1)) VIRTUAL);
|
||||
ERROR HY000: Expression of generated column 'c' contains a disallowed function.
|
||||
#
|
||||
# Bug#21929967 GCOLS: GCOL VALUE CHANGES WHEN SESSION CHANGES SQL_MODE
|
||||
#
|
||||
CREATE TABLE t1(a CHAR(1), b CHAR(1), c CHAR(2) AS (a || b));
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` char(1) DEFAULT NULL,
|
||||
`b` char(1) DEFAULT NULL,
|
||||
`c` char(2) GENERATED ALWAYS AS ((`a` or `b`)) VIRTUAL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
INSERT INTO t1 (a,b) VALUES('1','1');
|
||||
SELECT * FROM t1;
|
||||
a b c
|
||||
1 1 1
|
||||
SET SQL_MODE=PIPES_AS_CONCAT;
|
||||
Warnings:
|
||||
Warning 3090 Changing sql mode 'NO_AUTO_CREATE_USER' is deprecated. It will be removed in a future release.
|
||||
SELECT * FROM t1;
|
||||
a b c
|
||||
1 1 1
|
||||
FLUSH TABLES;
|
||||
SELECT * FROM t1;
|
||||
a b c
|
||||
1 1 1
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1(a CHAR(1), b CHAR(1), c CHAR(2) AS (a || b));
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` char(1) DEFAULT NULL,
|
||||
`b` char(1) DEFAULT NULL,
|
||||
`c` char(2) GENERATED ALWAYS AS (concat(`a`,`b`)) VIRTUAL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
INSERT INTO t1 (a,b) VALUES('1','1');
|
||||
SELECT * FROM t1;
|
||||
a b c
|
||||
1 1 11
|
||||
SET SQL_MODE=DEFAULT;
|
||||
SELECT * FROM t1;
|
||||
a b c
|
||||
1 1 11
|
||||
FLUSH TABLES;
|
||||
SELECT * FROM t1;
|
||||
a b c
|
||||
1 1 11
|
||||
DROP TABLE t1;
|
||||
# Bug#22018999: gcols: assertion failed: !error
|
||||
SET @save_old_sql_mode= @@sql_mode;
|
||||
SET sql_mode="";
|
||||
Warnings:
|
||||
Warning 3090 Changing sql mode 'NO_AUTO_CREATE_USER' is deprecated. It will be removed in a future release.
|
||||
CREATE TABLE t (a INTEGER AS (SUBSTR('','a',1))) engine=innodb;
|
||||
ERROR 22007: Truncated incorrect INTEGER value: 'a'
|
||||
CREATE TABLE t (a INTEGER) engine=innodb;
|
||||
ALTER TABLE t ADD b INTEGER AS (SUBSTR('','a',1));
|
||||
ERROR 22007: Truncated incorrect INTEGER value: 'a'
|
||||
DROP TABLE t;
|
||||
set sql_mode= @save_old_sql_mode;
|
||||
Warnings:
|
||||
Warning 3090 Changing sql mode 'NO_AUTO_CREATE_USER' is deprecated. It will be removed in a future release.
|
||||
# Bug#21875520 Problems with virtual column indexes
|
||||
CREATE TABLE t(
|
||||
a TIMESTAMP,
|
||||
b BLOB,
|
||||
c TIMESTAMP GENERATED ALWAYS AS (GREATEST(a, '2000-01-01 00:00:00')) VIRTUAL,
|
||||
UNIQUE KEY(c)
|
||||
);
|
||||
INSERT INTO t(b) VALUES ('');
|
||||
UPDATE t SET a='2001-01-01 00:00:00';
|
||||
SELECT c FROM t;
|
||||
c
|
||||
2001-01-01 00:00:00
|
||||
SELECT c, a FROM t;
|
||||
c a
|
||||
2001-01-01 00:00:00 2001-01-01 00:00:00
|
||||
UPDATE t SET b='xyz';
|
||||
DO (SELECT @c1:= c FROM t);
|
||||
DO (SELECT (@c2:= c) - a FROM t);
|
||||
SELECT @c2 - @c1;
|
||||
@c2 - @c1
|
||||
0
|
||||
DROP TABLE t;
|
||||
#
|
||||
# Bug#22133710 GCOLS: READ UNCOMMITTED: ASSERT !TABLE || (!TABLE->WRITE_SET || BITMAP_IS_SET(TA
|
||||
#
|
||||
CREATE TABLE t (
|
||||
a INT,
|
||||
b INT GENERATED ALWAYS AS (1) VIRTUAL,
|
||||
c INT GENERATED ALWAYS AS (1) VIRTUAL,
|
||||
d INT GENERATED ALWAYS AS (1) VIRTUAL,
|
||||
KEY (b,d)
|
||||
) ENGINE=INNODB;
|
||||
INSERT INTO t VALUES();
|
||||
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED ;
|
||||
SELECT 1 FROM t WHERE c GROUP BY b;
|
||||
1
|
||||
1
|
||||
COMMIT;
|
||||
DROP TABLE t;
|
582
mysql-test/suite/gcol/r/gcol_column_def_options_innodb.result
Normal file
582
mysql-test/suite/gcol/r/gcol_column_def_options_innodb.result
Normal file
|
@ -0,0 +1,582 @@
|
|||
SET @@session.default_storage_engine = 'InnoDB';
|
||||
#
|
||||
# Section 1. Wrong column definition options
|
||||
# - DEFAULT <value>
|
||||
# - AUTO_INCREMENT
|
||||
# NOT NULL
|
||||
create table t1 (a int, b int generated always as (a+1) virtual not null);
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'not null)' at line 1
|
||||
create table t1 (a int, b int generated always as (a+1) stored not null);
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB 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 generated always as (a+1) virtual not null;
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'not null' at line 1
|
||||
drop table t1;
|
||||
create table t1 (a int, b int generated always as (a+1) virtual null);
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB 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 generated always as (a+1) virtual null;
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'null' at line 1
|
||||
drop table t1;
|
||||
# Added columns mixed with virtual GC and other columns
|
||||
create table t1 (a int);
|
||||
insert into t1 values(1);
|
||||
alter table t1 add column (b int generated always as (a+1) virtual, c int);
|
||||
affected rows: 0
|
||||
info: Records: 0 Duplicates: 0 Warnings: 0
|
||||
alter table t1 add column (d int, e int generated always as (a+1) virtual);
|
||||
affected rows: 0
|
||||
info: Records: 0 Duplicates: 0 Warnings: 0
|
||||
alter table t1 add column (f int generated always as (a+1) virtual, g int as(5) stored);
|
||||
affected rows: 1
|
||||
info: Records: 1 Duplicates: 0 Warnings: 0
|
||||
alter table t1 add column (h int generated always as (a+1) virtual, i int as(5) virtual);
|
||||
affected rows: 0
|
||||
info: Records: 0 Duplicates: 0 Warnings: 0
|
||||
drop table t1;
|
||||
# DEFAULT
|
||||
create table t1 (a int, b int generated always as (a+1) virtual default 0);
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB 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 generated always as (a+1) virtual default 0;
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB 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 generated always as (a+1) virtual AUTO_INCREMENT);
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB 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 generated always as (a+1) virtual AUTO_INCREMENT;
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB 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 generated always as (a+1) stored key);
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'key)' at line 1
|
||||
create table t1 (a int, b int generated always as (a+1) stored primary key);
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB 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 generated always as (a+1) stored key;
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'key' at line 1
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
alter table t1 add column c int generated always as (a+2) stored primary key;
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB 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 generated always as (a % 2) virtual 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 generated always as (a % 2) virtual);
|
||||
alter table t1 modify b int generated always as (a % 2) virtual 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 order by a;
|
||||
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 order by a;
|
||||
a b
|
||||
1 1
|
||||
2 0
|
||||
drop table t2;
|
||||
drop table t1;
|
||||
create table t1 (a int, b int generated always as (a % 2) stored);
|
||||
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 PERSISTENT
|
||||
insert into t1 (a) values (1);
|
||||
select * from t1;
|
||||
a b
|
||||
1 1
|
||||
insert into t1 values (2,default);
|
||||
select a,b from t1 order by a;
|
||||
a b
|
||||
1 1
|
||||
2 0
|
||||
drop table t1;
|
||||
create table t2 (a int);
|
||||
create table t1 (a int, b int generated always as (a % 2) stored 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 generated always as (a % 2) virtual);
|
||||
alter table t1 modify b int generated always as (a % 2) stored references t2(a);
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB 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;
|
||||
drop table t2;
|
||||
FK options
|
||||
create table t1(a int, b int as (a % 2), c int as (a) stored);
|
||||
create table t2 (a int);
|
||||
alter table t1 add constraint foreign key fk(d) references t2(a);
|
||||
ERROR 42000: Key column 'd' doesn't exist in table
|
||||
alter table t1 add constraint foreign key fk(c) references t2(a) on delete set null;
|
||||
ERROR HY000: Cannot define foreign key with ON DELETE SET NULL clause on a computed column
|
||||
alter table t1 add constraint foreign key fk(c) 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 constraint foreign key fk(c) references t2(a) on update cascade;
|
||||
ERROR HY000: Cannot define foreign key with ON UPDATE CASCADE clause on a computed column
|
||||
drop table t1;
|
||||
drop table t2;
|
||||
Generated always is optional
|
||||
create table t1 (a int, b int as (a % 2) virtual);
|
||||
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
|
||||
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) stored);
|
||||
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 PERSISTENT
|
||||
drop table t1;
|
||||
Default should be non-stored column
|
||||
create table t1 (a int, b int as (a % 2));
|
||||
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
|
||||
describe t1;
|
||||
Field Type Null Key Default Extra
|
||||
a int(11) YES NULL
|
||||
b int(11) YES NULL VIRTUAL
|
||||
drop table t1;
|
||||
Expression can be constant
|
||||
create table t1 (a int, b int as (5 * 2));
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` int(11) AS (5 * 2) VIRTUAL
|
||||
) 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;
|
||||
Test generated columns referencing other generated columns
|
||||
create table t1 (a int unique, b int generated always as(-a) virtual, c int generated always as (b + 1) virtual);
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 0
|
||||
2 -2 -1
|
||||
insert into t1(a) values (1) on duplicate key update a=3;
|
||||
select * from t1;
|
||||
a b c
|
||||
2 -2 -1
|
||||
3 -3 -2
|
||||
update t1 set a=4 where a=2;
|
||||
select * from t1;
|
||||
a b c
|
||||
3 -3 -2
|
||||
4 -4 -3
|
||||
drop table t1;
|
||||
create table t1 (a int, b int generated always as(-b) virtual, c int generated always as (b + 1) virtual);
|
||||
ERROR 01000: Expression for field `b` is refering to uninitialized field `b`
|
||||
create table t1 (a int, b int generated always as(-c) virtual, c int generated always as (b + 1) virtual);
|
||||
ERROR 01000: Expression for field `b` is refering to uninitialized field `c`
|
||||
create table t1 (pk int auto_increment primary key, col_int_nokey int generated always as (pk + col_int_key) stored, col_int_key int);
|
||||
ERROR 01000: Expression for field `col_int_nokey` is refering to uninitialized field `pk`
|
||||
# Bug#20339347: FAIL TO USE CREATE ....SELECT STATEMENT TO CREATE A NEW TABLE
|
||||
create table t1 (a int, b int generated always as(-a) virtual, c int generated always as (b + 1) stored);
|
||||
insert into t1(a) values(1),(2);
|
||||
create table tt as select * from t1;
|
||||
select * from t1 order by a;
|
||||
a b c
|
||||
1 -1 0
|
||||
2 -2 -1
|
||||
select * from tt order by a;
|
||||
a b c
|
||||
1 -1 0
|
||||
2 -2 -1
|
||||
drop table t1,tt;
|
||||
# Bug#20769299: INCORRECT KEY ERROR WHEN TRYING TO CREATE INDEX ON
|
||||
# VIRTUAL GC FOR MYISAM
|
||||
CREATE TABLE A (
|
||||
pk INTEGER,
|
||||
col_int_nokey INTEGER,
|
||||
col_int_key INTEGER GENERATED ALWAYS AS (pk + col_int_nokey) VIRTUAL, KEY
|
||||
(col_int_key));
|
||||
ERROR HY000: Key/Index cannot be defined on a non-stored computed column
|
||||
# Bug#20745142: GENERATED COLUMNS: ASSERTION FAILED:
|
||||
# THD->CHANGE_LIST.IS_EMPTY()
|
||||
#
|
||||
CREATE TABLE t1(a bigint AS (a between 1 and 1));
|
||||
ERROR 01000: Expression for field `a` is refering to uninitialized field `a`
|
||||
# Bug#20757211: GENERATED COLUMNS: ALTER TABLE CRASHES
|
||||
# IN FIND_FIELD_IN_TABLE
|
||||
#
|
||||
CREATE TABLE t1(a int);
|
||||
ALTER TABLE t1 ADD COLUMN z int GENERATED ALWAYS AS
|
||||
( 1 NOT IN (SELECT 1 FROM t1 WHERE c0006) ) virtual;
|
||||
ERROR HY000: Function or expression 'select ...' cannot be used in the GENERATED ALWAYS AS clause of `z`
|
||||
DROP TABLE t1;
|
||||
# Bug#20566243: ERROR WHILE DOING CREATE TABLE T1 SELECT (QUERY ON GC COLUMNS)
|
||||
CREATE TABLE t1(a int, b int as (a + 1),
|
||||
c varchar(12) as ("aaaabb") stored, d blob as (c));
|
||||
INSERT INTO t1(a) VALUES(1),(3);
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` int(11) AS (a + 1) VIRTUAL,
|
||||
`c` varchar(12) AS ("aaaabb") PERSISTENT,
|
||||
`d` blob AS (c) VIRTUAL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
SELECT * FROM t1 order by a;
|
||||
a b c d
|
||||
1 2 aaaabb aaaabb
|
||||
3 4 aaaabb aaaabb
|
||||
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 + 1) VIRTUAL,
|
||||
`c` varchar(12) AS ("aaaabb") PERSISTENT,
|
||||
`d` blob AS (c) VIRTUAL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
CREATE TABLE t3 AS SELECT * FROM t1;
|
||||
SHOW CREATE TABLE t3;
|
||||
Table Create Table
|
||||
t3 CREATE TABLE `t3` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` int(11) DEFAULT NULL,
|
||||
`c` varchar(12) DEFAULT NULL,
|
||||
`d` blob DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
SELECT * FROM t3 order by a;
|
||||
a b c d
|
||||
1 2 aaaabb aaaabb
|
||||
3 4 aaaabb aaaabb
|
||||
CREATE TABLE t4 AS SELECT b,c,d FROM t1;
|
||||
SHOW CREATE TABLE t4;
|
||||
Table Create Table
|
||||
t4 CREATE TABLE `t4` (
|
||||
`b` int(11) DEFAULT NULL,
|
||||
`c` varchar(12) DEFAULT NULL,
|
||||
`d` blob DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
SELECT * FROM t4 order by b;
|
||||
b c d
|
||||
2 aaaabb aaaabb
|
||||
4 aaaabb aaaabb
|
||||
DROP TABLE t1,t2,t3,t4;
|
||||
# Bug#21025003:WL8149:ASSERTION `CTX->NUM_TO_DROP_FK
|
||||
# == HA_ALTER_INFO->ALTER_INFO-> FAILED
|
||||
#
|
||||
CREATE TABLE t1 (
|
||||
col1 int(11) DEFAULT NULL,
|
||||
col2 int(11) DEFAULT NULL,
|
||||
col3 int(11) DEFAULT NULL,
|
||||
col4 int(11) DEFAULT NULL,
|
||||
col5 int(11) GENERATED ALWAYS AS (col4 / col2) VIRTUAL,
|
||||
col6 text
|
||||
);
|
||||
INSERT INTO t1(col1,col2,col3,col4,col6) VALUES(NULL,1,4,0,REPEAT(2,1000));
|
||||
ALTER TABLE t1 DROP PRIMARY KEY , ADD KEY idx ( col5, col2 );
|
||||
ERROR 42000: Can't DROP INDEX `PRIMARY`; check that it exists
|
||||
DROP TABLE t1;
|
||||
# Bug#20949226:i CAN ASSIGN NON-DEFAULT() VALUE TO GENERATED COLUMN
|
||||
#
|
||||
CREATE TABLE t1 (c1 INT, c2 INT AS (c1 * 2)) SELECT 1 AS c1, 5 AS c2;
|
||||
Warnings:
|
||||
Warning 1906 The value specified for computed column 'c2' in table 't1' ignored
|
||||
CREATE TABLE t2 (a int);
|
||||
INSERT INTO t2 values(1);
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (c1 INT, c2 INT AS (c1 * 2)) SELECT 1 AS c1, a AS c2 from t2;
|
||||
Warnings:
|
||||
Warning 1906 The value specified for computed column 'c2' in table 't1' ignored
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (c1 INT, c2 INT AS (c1 * 2)) SELECT 1 AS c1, 5;
|
||||
SELECT * FROM t1;
|
||||
c2 c1 5
|
||||
2 1 5
|
||||
DROP TABLE t1, t2;
|
||||
# Bug#20757211: GENERATED COLUMNS: ALTER TABLE CRASHES
|
||||
# IN FIND_FIELD_IN_TABLE
|
||||
#
|
||||
CREATE TABLE t1(a int);
|
||||
ALTER TABLE t1 ADD COLUMN z int GENERATED ALWAYS AS
|
||||
( 1 NOT IN (SELECT 1 FROM t1 WHERE c0006) ) virtual;
|
||||
ERROR HY000: Function or expression 'select ...' cannot be used in the GENERATED ALWAYS AS clause of `z`
|
||||
CREATE TABLE t2(a int, b int as (1 NOT IN (SELECT 1 FROM t1 WHERE not_exist_col)));
|
||||
ERROR HY000: Function or expression 'select ...' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
CREATE TABLE t2(a int, b int as (1 NOT IN (SELECT 1 FROM dual)));
|
||||
ERROR HY000: Function or expression 'select ...' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
DROP TABLE t1;
|
||||
# Bug#21142905: PARTITIONED GENERATED COLS -
|
||||
# !TABLE || (!TABLE->WRITE_SET || BITMAP_IS_SET
|
||||
#
|
||||
CREATE TABLE t1 (
|
||||
a int,
|
||||
b int generated always as (a) virtual,
|
||||
c int generated always as (b+a) virtual,
|
||||
d int generated always as (b+a) virtual
|
||||
) PARTITION BY LINEAR HASH (b);
|
||||
INSERT INTO t1(a) VALUES(0);
|
||||
DELETE FROM t1 WHERE c=1;
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (c CHAR(10) CHARACTER SET utf8 COLLATE utf8_bin GENERATED ALWAYS AS ("foo bar"));
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'GENERATED ALWAYS AS ("foo bar"))' at line 1
|
||||
CREATE TABLE t1 (i INT);
|
||||
ALTER TABLE t1 ADD COLUMN c CHAR(10) CHARACTER SET utf8 COLLATE utf8_bin GENERATED ALWAYS AS ("foo bar");
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'GENERATED ALWAYS AS ("foo bar")' at line 1
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (i INT COLLATE utf8_bin, c INT COLLATE utf8_bin GENERATED ALWAYS AS (10));
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'GENERATED ALWAYS AS (10))' at line 1
|
||||
# Check for a charset mismatch processing:
|
||||
# Bug #21469535: VALGRIND ERROR (CONDITIONAL JUMP) WHEN INSERT
|
||||
# ROWS INTO A PARTITIONED TABLE
|
||||
#
|
||||
CREATE TABLE t1 (
|
||||
id INT NOT NULL,
|
||||
store_id INT NOT NULL,
|
||||
x INT GENERATED ALWAYS AS (id + store_id)
|
||||
)
|
||||
PARTITION BY RANGE (store_id) (
|
||||
PARTITION p0 VALUES LESS THAN (6),
|
||||
PARTITION p1 VALUES LESS THAN (11),
|
||||
PARTITION p2 VALUES LESS THAN (16),
|
||||
PARTITION p3 VALUES LESS THAN (21)
|
||||
);
|
||||
INSERT INTO t1 VALUES(1, 2, default);
|
||||
DROP TABLE t1;
|
||||
# Bug#21465626:ASSERT/CRASH ON DROPPING/ADDING VIRTUAL COLUMN
|
||||
CREATE TABLE t (a int(11), b int(11),
|
||||
c int(11) GENERATED ALWAYS AS (a+b) VIRTUAL,
|
||||
d int(11) GENERATED ALWAYS AS (a+b) VIRTUAL);
|
||||
INSERT INTO t(a,b) VALUES(1,2);
|
||||
# Mixed drop/add/rename virtual with non-virtual columns,
|
||||
# ALGORITHM=INPLACE is not supported for InnoDB
|
||||
ALTER TABLE t DROP d, ADD e varchar(10);
|
||||
affected rows: 0
|
||||
info: Records: 0 Duplicates: 0 Warnings: 0
|
||||
ALTER TABLE t ADD d int, ADD f char(10) AS ('aaa');
|
||||
affected rows: 0
|
||||
info: Records: 0 Duplicates: 0 Warnings: 0
|
||||
ALTER TABLE t CHANGE d dd int, CHANGE f ff varchar(10) AS ('bbb');
|
||||
affected rows: 1
|
||||
info: Records: 1 Duplicates: 0 Warnings: 0
|
||||
# Only drop/add/change virtual, inplace is supported for Innodb
|
||||
ALTER TABLE t DROP c, DROP ff;
|
||||
affected rows: 0
|
||||
info: Records: 0 Duplicates: 0 Warnings: 0
|
||||
ALTER TABLE t ADD c int(11) as (a+b), ADD f varchar(10) as ('aaa');
|
||||
affected rows: 0
|
||||
info: Records: 0 Duplicates: 0 Warnings: 0
|
||||
ALTER TABLE t CHANGE c c int(11) as (a), CHANGE f f varchar(10) as('bbb');
|
||||
affected rows: 0
|
||||
info: Records: 0 Duplicates: 0 Warnings: 0
|
||||
# Change order should be ALGORITHM=INPLACE on Innodb
|
||||
ALTER TABLE t CHANGE c c int(11) as (a) after f;
|
||||
affected rows: 0
|
||||
info: Records: 0 Duplicates: 0 Warnings: 0
|
||||
ALTER TABLE t CHANGE b b int(11) after c;
|
||||
affected rows: 0
|
||||
info: Records: 0 Duplicates: 0 Warnings: 0
|
||||
# TODO: Changing virtual column type should be ALGORITHM=INPLACE on InnoDB, current it goes only with COPY method
|
||||
ALTER TABLE t CHANGE c c varchar(10) as ('a');
|
||||
affected rows: 1
|
||||
info: Records: 1 Duplicates: 0 Warnings: 0
|
||||
# Changing stored column type is ALGORITHM=COPY
|
||||
ALTER TABLE t CHANGE dd d varchar(10);
|
||||
affected rows: 1
|
||||
info: Records: 1 Duplicates: 0 Warnings: 0
|
||||
DROP TABLE t;
|
||||
# Bug#21854004: GCOLS:INNODB: FAILING ASSERTION: I < TABLE->N_DEF
|
||||
CREATE TABLE t1(
|
||||
col1 INTEGER PRIMARY KEY,
|
||||
col2 INTEGER,
|
||||
col3 INTEGER,
|
||||
col4 INTEGER,
|
||||
vgc1 INTEGER AS (col2 + col3) VIRTUAL,
|
||||
sgc1 INTEGER AS (col2 - col3) STORED
|
||||
);
|
||||
INSERT INTO t1(col1, col2, col3) VALUES
|
||||
(1, 10, 100), (2, 20, 200);
|
||||
SELECT * FROM t1 order by col1;
|
||||
col1 col2 col3 col4 vgc1 sgc1
|
||||
1 10 100 NULL 110 -90
|
||||
2 20 200 NULL 220 -180
|
||||
ALTER TABLE t1 MODIFY COLUMN vgc1 INTEGER AS (col2 * col3) VIRTUAL;
|
||||
SELECT * FROM t1 order by col1;
|
||||
col1 col2 col3 col4 vgc1 sgc1
|
||||
1 10 100 NULL 1000 -90
|
||||
2 20 200 NULL 4000 -180
|
||||
ALTER TABLE t1 MODIFY COLUMN sgc1 INTEGER AS (col2 / col3) STORED;
|
||||
SELECT * FROM t1 order by col1;
|
||||
col1 col2 col3 col4 vgc1 sgc1
|
||||
1 10 100 NULL 1000 0
|
||||
2 20 200 NULL 4000 0
|
||||
ALTER TABLE t1 MODIFY COLUMN vgc1 INTEGER AS (col2 + col3) VIRTUAL;
|
||||
ALTER TABLE t1 MODIFY COLUMN sgc1 INTEGER AS (col2 - col3) STORED;
|
||||
ALTER TABLE t1 ADD INDEX sgc1 (sgc1);
|
||||
ALTER TABLE t1 MODIFY COLUMN sgc1 INTEGER AS (col2 / col3) STORED;
|
||||
SELECT * FROM t1 order by col1;
|
||||
col1 col2 col3 col4 vgc1 sgc1
|
||||
1 10 100 NULL 110 0
|
||||
2 20 200 NULL 220 0
|
||||
SELECT sgc1 FROM t1 order by sgc1;
|
||||
sgc1
|
||||
0
|
||||
0
|
||||
ALTER TABLE t1 DROP INDEX sgc1;
|
||||
ALTER TABLE t1 MODIFY COLUMN sgc1 INTEGER AS (col2 - col3) STORED;
|
||||
ALTER TABLE t1 ADD UNIQUE INDEX sgc1 (sgc1);
|
||||
ALTER TABLE t1 MODIFY COLUMN sgc1 INTEGER AS (col2 / col3) STORED;
|
||||
ERROR 23000: Duplicate entry '0' for key 'sgc1'
|
||||
ALTER TABLE t1 MODIFY COLUMN vgc1 INTEGER AS (col2 * col3) VIRTUAL;
|
||||
SELECT * FROM t1 order by col1;
|
||||
col1 col2 col3 col4 vgc1 sgc1
|
||||
1 10 100 NULL 1000 -90
|
||||
2 20 200 NULL 4000 -180
|
||||
SELECT vgc1 FROM t1 order by col1;
|
||||
vgc1
|
||||
1000
|
||||
4000
|
||||
ALTER TABLE t1 MODIFY COLUMN sgc1 INTEGER AS (col2 * col3) STORED;
|
||||
SELECT * FROM t1 order by col1;
|
||||
col1 col2 col3 col4 vgc1 sgc1
|
||||
1 10 100 NULL 1000 1000
|
||||
2 20 200 NULL 4000 4000
|
||||
SELECT sgc1 FROM t1 order by sgc1;
|
||||
sgc1
|
||||
1000
|
||||
4000
|
||||
ALTER TABLE t1 MODIFY COLUMN vgc1 INTEGER AS (col2 * col3) STORED;
|
||||
ERROR HY000: This is not yet supported for computed columns
|
||||
ALTER TABLE t1 MODIFY COLUMN sgc1 INTEGER AS (col2 / col3) VIRTUAL;
|
||||
ERROR HY000: This is not yet supported for computed columns
|
||||
ALTER TABLE t1 MODIFY COLUMN col4 INTEGER AS (col1 + col2 + col3) STORED;
|
||||
SELECT * FROM t1 order by col1;
|
||||
col1 col2 col3 col4 vgc1 sgc1
|
||||
1 10 100 111 1000 1000
|
||||
2 20 200 222 4000 4000
|
||||
ALTER TABLE t1 MODIFY COLUMN col4 INTEGER;
|
||||
SELECT * FROM t1 order by col1;
|
||||
col1 col2 col3 col4 vgc1 sgc1
|
||||
1 10 100 111 1000 1000
|
||||
2 20 200 222 4000 4000
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# Bug#22680839: DEFAULT IS NOT DETERMINISTIC AND SHOULD NOT BE
|
||||
# ALLOWED IN GENERATED COLUMNS
|
||||
#
|
||||
# Test 1: ALTER DEFAULT
|
||||
#
|
||||
CREATE TABLE t1(a INT PRIMARY KEY DEFAULT 5,
|
||||
b INT AS (1 + DEFAULT(a)) STORED,
|
||||
c INT AS (1 + DEFAULT(a)) VIRTUAL);
|
||||
INSERT INTO t1 VALUES ();
|
||||
ALTER TABLE t1 ALTER COLUMN a SET DEFAULT 7;
|
||||
affected rows: 0
|
||||
info: Records: 0 Duplicates: 0 Warnings: 0
|
||||
ALTER TABLE t1 MODIFY COLUMN a INT DEFAULT 8;
|
||||
affected rows: 0
|
||||
info: Records: 0 Duplicates: 0 Warnings: 0
|
||||
ALTER TABLE t1 CHANGE COLUMN a a DOUBLE DEFAULT 5;
|
||||
affected rows: 1
|
||||
info: Records: 1 Duplicates: 0 Warnings: 0
|
||||
DROP TABLE t1;
|
||||
# Test 2: ALTER DEFAULT + ADD GCOL
|
||||
#
|
||||
CREATE TABLE t1(a INT PRIMARY KEY DEFAULT 5);
|
||||
INSERT INTO t1 VALUES();
|
||||
ALTER TABLE t1 ALTER COLUMN a SET DEFAULT 7,
|
||||
ADD COLUMN b1 INT AS (1 + DEFAULT(a)) STORED;
|
||||
affected rows: 1
|
||||
info: Records: 1 Duplicates: 0 Warnings: 0
|
||||
ALTER TABLE t1 ALTER COLUMN a SET DEFAULT 7,
|
||||
ADD COLUMN c1 INT AS (1 + DEFAULT(a)) VIRTUAL;
|
||||
affected rows: 0
|
||||
info: Records: 0 Duplicates: 0 Warnings: 0
|
||||
ALTER TABLE t1 ALTER COLUMN a SET DEFAULT 7,
|
||||
ADD COLUMN b INT AS (1 + DEFAULT(a)) STORED,
|
||||
ADD COLUMN c INT AS (1 + DEFAULT(a)) VIRTUAL;
|
||||
affected rows: 1
|
||||
info: Records: 1 Duplicates: 0 Warnings: 0
|
||||
DROP TABLE t1;
|
||||
DROP VIEW IF EXISTS v1,v2;
|
||||
DROP TABLE IF EXISTS t1,t2,t3;
|
||||
DROP PROCEDURE IF EXISTS p1;
|
||||
DROP FUNCTION IF EXISTS f1;
|
||||
DROP TRIGGER IF EXISTS trg1;
|
||||
DROP TRIGGER IF EXISTS trg2;
|
||||
set sql_warnings = 0;
|
582
mysql-test/suite/gcol/r/gcol_column_def_options_myisam.result
Normal file
582
mysql-test/suite/gcol/r/gcol_column_def_options_myisam.result
Normal file
|
@ -0,0 +1,582 @@
|
|||
SET @@session.default_storage_engine = 'MyISAM';
|
||||
#
|
||||
# Section 1. Wrong column definition options
|
||||
# - DEFAULT <value>
|
||||
# - AUTO_INCREMENT
|
||||
# NOT NULL
|
||||
create table t1 (a int, b int generated always as (a+1) virtual not null);
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'not null)' at line 1
|
||||
create table t1 (a int, b int generated always as (a+1) stored not null);
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB 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 generated always as (a+1) virtual not null;
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'not null' at line 1
|
||||
drop table t1;
|
||||
create table t1 (a int, b int generated always as (a+1) virtual null);
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB 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 generated always as (a+1) virtual null;
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'null' at line 1
|
||||
drop table t1;
|
||||
# Added columns mixed with virtual GC and other columns
|
||||
create table t1 (a int);
|
||||
insert into t1 values(1);
|
||||
alter table t1 add column (b int generated always as (a+1) virtual, c int);
|
||||
affected rows: 1
|
||||
info: Records: 1 Duplicates: 0 Warnings: 0
|
||||
alter table t1 add column (d int, e int generated always as (a+1) virtual);
|
||||
affected rows: 1
|
||||
info: Records: 1 Duplicates: 0 Warnings: 0
|
||||
alter table t1 add column (f int generated always as (a+1) virtual, g int as(5) stored);
|
||||
affected rows: 1
|
||||
info: Records: 1 Duplicates: 0 Warnings: 0
|
||||
alter table t1 add column (h int generated always as (a+1) virtual, i int as(5) virtual);
|
||||
affected rows: 1
|
||||
info: Records: 1 Duplicates: 0 Warnings: 0
|
||||
drop table t1;
|
||||
# DEFAULT
|
||||
create table t1 (a int, b int generated always as (a+1) virtual default 0);
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB 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 generated always as (a+1) virtual default 0;
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB 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 generated always as (a+1) virtual AUTO_INCREMENT);
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB 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 generated always as (a+1) virtual AUTO_INCREMENT;
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB 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 generated always as (a+1) stored key);
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'key)' at line 1
|
||||
create table t1 (a int, b int generated always as (a+1) stored primary key);
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB 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 generated always as (a+1) stored key;
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'key' at line 1
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
alter table t1 add column c int generated always as (a+2) stored primary key;
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB 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 generated always as (a % 2) virtual 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 generated always as (a % 2) virtual);
|
||||
alter table t1 modify b int generated always as (a % 2) virtual 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 order by a;
|
||||
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 order by a;
|
||||
a b
|
||||
1 1
|
||||
2 0
|
||||
drop table t2;
|
||||
drop table t1;
|
||||
create table t1 (a int, b int generated always as (a % 2) stored);
|
||||
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 PERSISTENT
|
||||
insert into t1 (a) values (1);
|
||||
select * from t1;
|
||||
a b
|
||||
1 1
|
||||
insert into t1 values (2,default);
|
||||
select a,b from t1 order by a;
|
||||
a b
|
||||
1 1
|
||||
2 0
|
||||
drop table t1;
|
||||
create table t2 (a int);
|
||||
create table t1 (a int, b int generated always as (a % 2) stored 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 generated always as (a % 2) virtual);
|
||||
alter table t1 modify b int generated always as (a % 2) stored references t2(a);
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB 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;
|
||||
drop table t2;
|
||||
FK options
|
||||
create table t1(a int, b int as (a % 2), c int as (a) stored);
|
||||
create table t2 (a int);
|
||||
alter table t1 add constraint foreign key fk(d) references t2(a);
|
||||
ERROR 42000: Key column 'd' doesn't exist in table
|
||||
alter table t1 add constraint foreign key fk(c) references t2(a) on delete set null;
|
||||
ERROR HY000: Cannot define foreign key with ON DELETE SET NULL clause on a computed column
|
||||
alter table t1 add constraint foreign key fk(c) 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 constraint foreign key fk(c) references t2(a) on update cascade;
|
||||
ERROR HY000: Cannot define foreign key with ON UPDATE CASCADE clause on a computed column
|
||||
drop table t1;
|
||||
drop table t2;
|
||||
Generated always is optional
|
||||
create table t1 (a int, b int as (a % 2) virtual);
|
||||
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
|
||||
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) stored);
|
||||
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 PERSISTENT
|
||||
drop table t1;
|
||||
Default should be non-stored column
|
||||
create table t1 (a int, b int as (a % 2));
|
||||
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
|
||||
describe t1;
|
||||
Field Type Null Key Default Extra
|
||||
a int(11) YES NULL
|
||||
b int(11) YES NULL VIRTUAL
|
||||
drop table t1;
|
||||
Expression can be constant
|
||||
create table t1 (a int, b int as (5 * 2));
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` int(11) AS (5 * 2) VIRTUAL
|
||||
) 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;
|
||||
Test generated columns referencing other generated columns
|
||||
create table t1 (a int unique, b int generated always as(-a) virtual, c int generated always as (b + 1) virtual);
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 0
|
||||
2 -2 -1
|
||||
insert into t1(a) values (1) on duplicate key update a=3;
|
||||
select * from t1;
|
||||
a b c
|
||||
2 -2 -1
|
||||
3 -3 -2
|
||||
update t1 set a=4 where a=2;
|
||||
select * from t1;
|
||||
a b c
|
||||
3 -3 -2
|
||||
4 -4 -3
|
||||
drop table t1;
|
||||
create table t1 (a int, b int generated always as(-b) virtual, c int generated always as (b + 1) virtual);
|
||||
ERROR 01000: Expression for field `b` is refering to uninitialized field `b`
|
||||
create table t1 (a int, b int generated always as(-c) virtual, c int generated always as (b + 1) virtual);
|
||||
ERROR 01000: Expression for field `b` is refering to uninitialized field `c`
|
||||
create table t1 (pk int auto_increment primary key, col_int_nokey int generated always as (pk + col_int_key) stored, col_int_key int);
|
||||
ERROR 01000: Expression for field `col_int_nokey` is refering to uninitialized field `pk`
|
||||
# Bug#20339347: FAIL TO USE CREATE ....SELECT STATEMENT TO CREATE A NEW TABLE
|
||||
create table t1 (a int, b int generated always as(-a) virtual, c int generated always as (b + 1) stored);
|
||||
insert into t1(a) values(1),(2);
|
||||
create table tt as select * from t1;
|
||||
select * from t1 order by a;
|
||||
a b c
|
||||
1 -1 0
|
||||
2 -2 -1
|
||||
select * from tt order by a;
|
||||
a b c
|
||||
1 -1 0
|
||||
2 -2 -1
|
||||
drop table t1,tt;
|
||||
# Bug#20769299: INCORRECT KEY ERROR WHEN TRYING TO CREATE INDEX ON
|
||||
# VIRTUAL GC FOR MYISAM
|
||||
CREATE TABLE A (
|
||||
pk INTEGER,
|
||||
col_int_nokey INTEGER,
|
||||
col_int_key INTEGER GENERATED ALWAYS AS (pk + col_int_nokey) VIRTUAL, KEY
|
||||
(col_int_key));
|
||||
ERROR HY000: Key/Index cannot be defined on a non-stored computed column
|
||||
# Bug#20745142: GENERATED COLUMNS: ASSERTION FAILED:
|
||||
# THD->CHANGE_LIST.IS_EMPTY()
|
||||
#
|
||||
CREATE TABLE t1(a bigint AS (a between 1 and 1));
|
||||
ERROR 01000: Expression for field `a` is refering to uninitialized field `a`
|
||||
# Bug#20757211: GENERATED COLUMNS: ALTER TABLE CRASHES
|
||||
# IN FIND_FIELD_IN_TABLE
|
||||
#
|
||||
CREATE TABLE t1(a int);
|
||||
ALTER TABLE t1 ADD COLUMN z int GENERATED ALWAYS AS
|
||||
( 1 NOT IN (SELECT 1 FROM t1 WHERE c0006) ) virtual;
|
||||
ERROR HY000: Function or expression 'select ...' cannot be used in the GENERATED ALWAYS AS clause of `z`
|
||||
DROP TABLE t1;
|
||||
# Bug#20566243: ERROR WHILE DOING CREATE TABLE T1 SELECT (QUERY ON GC COLUMNS)
|
||||
CREATE TABLE t1(a int, b int as (a + 1),
|
||||
c varchar(12) as ("aaaabb") stored, d blob as (c));
|
||||
INSERT INTO t1(a) VALUES(1),(3);
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` int(11) AS (a + 1) VIRTUAL,
|
||||
`c` varchar(12) AS ("aaaabb") PERSISTENT,
|
||||
`d` blob AS (c) VIRTUAL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
SELECT * FROM t1 order by a;
|
||||
a b c d
|
||||
1 2 aaaabb aaaabb
|
||||
3 4 aaaabb aaaabb
|
||||
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 + 1) VIRTUAL,
|
||||
`c` varchar(12) AS ("aaaabb") PERSISTENT,
|
||||
`d` blob AS (c) VIRTUAL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
CREATE TABLE t3 AS SELECT * FROM t1;
|
||||
SHOW CREATE TABLE t3;
|
||||
Table Create Table
|
||||
t3 CREATE TABLE `t3` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` int(11) DEFAULT NULL,
|
||||
`c` varchar(12) DEFAULT NULL,
|
||||
`d` blob DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
SELECT * FROM t3 order by a;
|
||||
a b c d
|
||||
1 2 aaaabb aaaabb
|
||||
3 4 aaaabb aaaabb
|
||||
CREATE TABLE t4 AS SELECT b,c,d FROM t1;
|
||||
SHOW CREATE TABLE t4;
|
||||
Table Create Table
|
||||
t4 CREATE TABLE `t4` (
|
||||
`b` int(11) DEFAULT NULL,
|
||||
`c` varchar(12) DEFAULT NULL,
|
||||
`d` blob DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
SELECT * FROM t4 order by b;
|
||||
b c d
|
||||
2 aaaabb aaaabb
|
||||
4 aaaabb aaaabb
|
||||
DROP TABLE t1,t2,t3,t4;
|
||||
# Bug#21025003:WL8149:ASSERTION `CTX->NUM_TO_DROP_FK
|
||||
# == HA_ALTER_INFO->ALTER_INFO-> FAILED
|
||||
#
|
||||
CREATE TABLE t1 (
|
||||
col1 int(11) DEFAULT NULL,
|
||||
col2 int(11) DEFAULT NULL,
|
||||
col3 int(11) DEFAULT NULL,
|
||||
col4 int(11) DEFAULT NULL,
|
||||
col5 int(11) GENERATED ALWAYS AS (col4 / col2) VIRTUAL,
|
||||
col6 text
|
||||
);
|
||||
INSERT INTO t1(col1,col2,col3,col4,col6) VALUES(NULL,1,4,0,REPEAT(2,1000));
|
||||
ALTER TABLE t1 DROP PRIMARY KEY , ADD KEY idx ( col5, col2 );
|
||||
ERROR 42000: Can't DROP INDEX `PRIMARY`; check that it exists
|
||||
DROP TABLE t1;
|
||||
# Bug#20949226:i CAN ASSIGN NON-DEFAULT() VALUE TO GENERATED COLUMN
|
||||
#
|
||||
CREATE TABLE t1 (c1 INT, c2 INT AS (c1 * 2)) SELECT 1 AS c1, 5 AS c2;
|
||||
Warnings:
|
||||
Warning 1906 The value specified for computed column 'c2' in table 't1' ignored
|
||||
CREATE TABLE t2 (a int);
|
||||
INSERT INTO t2 values(1);
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (c1 INT, c2 INT AS (c1 * 2)) SELECT 1 AS c1, a AS c2 from t2;
|
||||
Warnings:
|
||||
Warning 1906 The value specified for computed column 'c2' in table 't1' ignored
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (c1 INT, c2 INT AS (c1 * 2)) SELECT 1 AS c1, 5;
|
||||
SELECT * FROM t1;
|
||||
c2 c1 5
|
||||
2 1 5
|
||||
DROP TABLE t1, t2;
|
||||
# Bug#20757211: GENERATED COLUMNS: ALTER TABLE CRASHES
|
||||
# IN FIND_FIELD_IN_TABLE
|
||||
#
|
||||
CREATE TABLE t1(a int);
|
||||
ALTER TABLE t1 ADD COLUMN z int GENERATED ALWAYS AS
|
||||
( 1 NOT IN (SELECT 1 FROM t1 WHERE c0006) ) virtual;
|
||||
ERROR HY000: Function or expression 'select ...' cannot be used in the GENERATED ALWAYS AS clause of `z`
|
||||
CREATE TABLE t2(a int, b int as (1 NOT IN (SELECT 1 FROM t1 WHERE not_exist_col)));
|
||||
ERROR HY000: Function or expression 'select ...' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
CREATE TABLE t2(a int, b int as (1 NOT IN (SELECT 1 FROM dual)));
|
||||
ERROR HY000: Function or expression 'select ...' cannot be used in the GENERATED ALWAYS AS clause of `b`
|
||||
DROP TABLE t1;
|
||||
# Bug#21142905: PARTITIONED GENERATED COLS -
|
||||
# !TABLE || (!TABLE->WRITE_SET || BITMAP_IS_SET
|
||||
#
|
||||
CREATE TABLE t1 (
|
||||
a int,
|
||||
b int generated always as (a) virtual,
|
||||
c int generated always as (b+a) virtual,
|
||||
d int generated always as (b+a) virtual
|
||||
) PARTITION BY LINEAR HASH (b);
|
||||
INSERT INTO t1(a) VALUES(0);
|
||||
DELETE FROM t1 WHERE c=1;
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (c CHAR(10) CHARACTER SET utf8 COLLATE utf8_bin GENERATED ALWAYS AS ("foo bar"));
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'GENERATED ALWAYS AS ("foo bar"))' at line 1
|
||||
CREATE TABLE t1 (i INT);
|
||||
ALTER TABLE t1 ADD COLUMN c CHAR(10) CHARACTER SET utf8 COLLATE utf8_bin GENERATED ALWAYS AS ("foo bar");
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'GENERATED ALWAYS AS ("foo bar")' at line 1
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (i INT COLLATE utf8_bin, c INT COLLATE utf8_bin GENERATED ALWAYS AS (10));
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'GENERATED ALWAYS AS (10))' at line 1
|
||||
# Check for a charset mismatch processing:
|
||||
# Bug #21469535: VALGRIND ERROR (CONDITIONAL JUMP) WHEN INSERT
|
||||
# ROWS INTO A PARTITIONED TABLE
|
||||
#
|
||||
CREATE TABLE t1 (
|
||||
id INT NOT NULL,
|
||||
store_id INT NOT NULL,
|
||||
x INT GENERATED ALWAYS AS (id + store_id)
|
||||
)
|
||||
PARTITION BY RANGE (store_id) (
|
||||
PARTITION p0 VALUES LESS THAN (6),
|
||||
PARTITION p1 VALUES LESS THAN (11),
|
||||
PARTITION p2 VALUES LESS THAN (16),
|
||||
PARTITION p3 VALUES LESS THAN (21)
|
||||
);
|
||||
INSERT INTO t1 VALUES(1, 2, default);
|
||||
DROP TABLE t1;
|
||||
# Bug#21465626:ASSERT/CRASH ON DROPPING/ADDING VIRTUAL COLUMN
|
||||
CREATE TABLE t (a int(11), b int(11),
|
||||
c int(11) GENERATED ALWAYS AS (a+b) VIRTUAL,
|
||||
d int(11) GENERATED ALWAYS AS (a+b) VIRTUAL);
|
||||
INSERT INTO t(a,b) VALUES(1,2);
|
||||
# Mixed drop/add/rename virtual with non-virtual columns,
|
||||
# ALGORITHM=INPLACE is not supported for InnoDB
|
||||
ALTER TABLE t DROP d, ADD e varchar(10);
|
||||
affected rows: 1
|
||||
info: Records: 1 Duplicates: 0 Warnings: 0
|
||||
ALTER TABLE t ADD d int, ADD f char(10) AS ('aaa');
|
||||
affected rows: 1
|
||||
info: Records: 1 Duplicates: 0 Warnings: 0
|
||||
ALTER TABLE t CHANGE d dd int, CHANGE f ff varchar(10) AS ('bbb');
|
||||
affected rows: 1
|
||||
info: Records: 1 Duplicates: 0 Warnings: 0
|
||||
# Only drop/add/change virtual, inplace is supported for Innodb
|
||||
ALTER TABLE t DROP c, DROP ff;
|
||||
affected rows: 1
|
||||
info: Records: 1 Duplicates: 0 Warnings: 0
|
||||
ALTER TABLE t ADD c int(11) as (a+b), ADD f varchar(10) as ('aaa');
|
||||
affected rows: 1
|
||||
info: Records: 1 Duplicates: 0 Warnings: 0
|
||||
ALTER TABLE t CHANGE c c int(11) as (a), CHANGE f f varchar(10) as('bbb');
|
||||
affected rows: 0
|
||||
info: Records: 0 Duplicates: 0 Warnings: 0
|
||||
# Change order should be ALGORITHM=INPLACE on Innodb
|
||||
ALTER TABLE t CHANGE c c int(11) as (a) after f;
|
||||
affected rows: 1
|
||||
info: Records: 1 Duplicates: 0 Warnings: 0
|
||||
ALTER TABLE t CHANGE b b int(11) after c;
|
||||
affected rows: 1
|
||||
info: Records: 1 Duplicates: 0 Warnings: 0
|
||||
# TODO: Changing virtual column type should be ALGORITHM=INPLACE on InnoDB, current it goes only with COPY method
|
||||
ALTER TABLE t CHANGE c c varchar(10) as ('a');
|
||||
affected rows: 1
|
||||
info: Records: 1 Duplicates: 0 Warnings: 0
|
||||
# Changing stored column type is ALGORITHM=COPY
|
||||
ALTER TABLE t CHANGE dd d varchar(10);
|
||||
affected rows: 1
|
||||
info: Records: 1 Duplicates: 0 Warnings: 0
|
||||
DROP TABLE t;
|
||||
# Bug#21854004: GCOLS:INNODB: FAILING ASSERTION: I < TABLE->N_DEF
|
||||
CREATE TABLE t1(
|
||||
col1 INTEGER PRIMARY KEY,
|
||||
col2 INTEGER,
|
||||
col3 INTEGER,
|
||||
col4 INTEGER,
|
||||
vgc1 INTEGER AS (col2 + col3) VIRTUAL,
|
||||
sgc1 INTEGER AS (col2 - col3) STORED
|
||||
);
|
||||
INSERT INTO t1(col1, col2, col3) VALUES
|
||||
(1, 10, 100), (2, 20, 200);
|
||||
SELECT * FROM t1 order by col1;
|
||||
col1 col2 col3 col4 vgc1 sgc1
|
||||
1 10 100 NULL 110 -90
|
||||
2 20 200 NULL 220 -180
|
||||
ALTER TABLE t1 MODIFY COLUMN vgc1 INTEGER AS (col2 * col3) VIRTUAL;
|
||||
SELECT * FROM t1 order by col1;
|
||||
col1 col2 col3 col4 vgc1 sgc1
|
||||
1 10 100 NULL 1000 -90
|
||||
2 20 200 NULL 4000 -180
|
||||
ALTER TABLE t1 MODIFY COLUMN sgc1 INTEGER AS (col2 / col3) STORED;
|
||||
SELECT * FROM t1 order by col1;
|
||||
col1 col2 col3 col4 vgc1 sgc1
|
||||
1 10 100 NULL 1000 0
|
||||
2 20 200 NULL 4000 0
|
||||
ALTER TABLE t1 MODIFY COLUMN vgc1 INTEGER AS (col2 + col3) VIRTUAL;
|
||||
ALTER TABLE t1 MODIFY COLUMN sgc1 INTEGER AS (col2 - col3) STORED;
|
||||
ALTER TABLE t1 ADD INDEX sgc1 (sgc1);
|
||||
ALTER TABLE t1 MODIFY COLUMN sgc1 INTEGER AS (col2 / col3) STORED;
|
||||
SELECT * FROM t1 order by col1;
|
||||
col1 col2 col3 col4 vgc1 sgc1
|
||||
1 10 100 NULL 110 0
|
||||
2 20 200 NULL 220 0
|
||||
SELECT sgc1 FROM t1 order by sgc1;
|
||||
sgc1
|
||||
0
|
||||
0
|
||||
ALTER TABLE t1 DROP INDEX sgc1;
|
||||
ALTER TABLE t1 MODIFY COLUMN sgc1 INTEGER AS (col2 - col3) STORED;
|
||||
ALTER TABLE t1 ADD UNIQUE INDEX sgc1 (sgc1);
|
||||
ALTER TABLE t1 MODIFY COLUMN sgc1 INTEGER AS (col2 / col3) STORED;
|
||||
ERROR 23000: Duplicate entry '0' for key 'sgc1'
|
||||
ALTER TABLE t1 MODIFY COLUMN vgc1 INTEGER AS (col2 * col3) VIRTUAL;
|
||||
SELECT * FROM t1 order by col1;
|
||||
col1 col2 col3 col4 vgc1 sgc1
|
||||
1 10 100 NULL 1000 -90
|
||||
2 20 200 NULL 4000 -180
|
||||
SELECT vgc1 FROM t1 order by col1;
|
||||
vgc1
|
||||
1000
|
||||
4000
|
||||
ALTER TABLE t1 MODIFY COLUMN sgc1 INTEGER AS (col2 * col3) STORED;
|
||||
SELECT * FROM t1 order by col1;
|
||||
col1 col2 col3 col4 vgc1 sgc1
|
||||
1 10 100 NULL 1000 1000
|
||||
2 20 200 NULL 4000 4000
|
||||
SELECT sgc1 FROM t1 order by sgc1;
|
||||
sgc1
|
||||
1000
|
||||
4000
|
||||
ALTER TABLE t1 MODIFY COLUMN vgc1 INTEGER AS (col2 * col3) STORED;
|
||||
ERROR HY000: This is not yet supported for computed columns
|
||||
ALTER TABLE t1 MODIFY COLUMN sgc1 INTEGER AS (col2 / col3) VIRTUAL;
|
||||
ERROR HY000: This is not yet supported for computed columns
|
||||
ALTER TABLE t1 MODIFY COLUMN col4 INTEGER AS (col1 + col2 + col3) STORED;
|
||||
SELECT * FROM t1 order by col1;
|
||||
col1 col2 col3 col4 vgc1 sgc1
|
||||
1 10 100 111 1000 1000
|
||||
2 20 200 222 4000 4000
|
||||
ALTER TABLE t1 MODIFY COLUMN col4 INTEGER;
|
||||
SELECT * FROM t1 order by col1;
|
||||
col1 col2 col3 col4 vgc1 sgc1
|
||||
1 10 100 111 1000 1000
|
||||
2 20 200 222 4000 4000
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# Bug#22680839: DEFAULT IS NOT DETERMINISTIC AND SHOULD NOT BE
|
||||
# ALLOWED IN GENERATED COLUMNS
|
||||
#
|
||||
# Test 1: ALTER DEFAULT
|
||||
#
|
||||
CREATE TABLE t1(a INT PRIMARY KEY DEFAULT 5,
|
||||
b INT AS (1 + DEFAULT(a)) STORED,
|
||||
c INT AS (1 + DEFAULT(a)) VIRTUAL);
|
||||
INSERT INTO t1 VALUES ();
|
||||
ALTER TABLE t1 ALTER COLUMN a SET DEFAULT 7;
|
||||
affected rows: 0
|
||||
info: Records: 0 Duplicates: 0 Warnings: 0
|
||||
ALTER TABLE t1 MODIFY COLUMN a INT DEFAULT 8;
|
||||
affected rows: 0
|
||||
info: Records: 0 Duplicates: 0 Warnings: 0
|
||||
ALTER TABLE t1 CHANGE COLUMN a a DOUBLE DEFAULT 5;
|
||||
affected rows: 1
|
||||
info: Records: 1 Duplicates: 0 Warnings: 0
|
||||
DROP TABLE t1;
|
||||
# Test 2: ALTER DEFAULT + ADD GCOL
|
||||
#
|
||||
CREATE TABLE t1(a INT PRIMARY KEY DEFAULT 5);
|
||||
INSERT INTO t1 VALUES();
|
||||
ALTER TABLE t1 ALTER COLUMN a SET DEFAULT 7,
|
||||
ADD COLUMN b1 INT AS (1 + DEFAULT(a)) STORED;
|
||||
affected rows: 1
|
||||
info: Records: 1 Duplicates: 0 Warnings: 0
|
||||
ALTER TABLE t1 ALTER COLUMN a SET DEFAULT 7,
|
||||
ADD COLUMN c1 INT AS (1 + DEFAULT(a)) VIRTUAL;
|
||||
affected rows: 1
|
||||
info: Records: 1 Duplicates: 0 Warnings: 0
|
||||
ALTER TABLE t1 ALTER COLUMN a SET DEFAULT 7,
|
||||
ADD COLUMN b INT AS (1 + DEFAULT(a)) STORED,
|
||||
ADD COLUMN c INT AS (1 + DEFAULT(a)) VIRTUAL;
|
||||
affected rows: 1
|
||||
info: Records: 1 Duplicates: 0 Warnings: 0
|
||||
DROP TABLE t1;
|
||||
DROP VIEW IF EXISTS v1,v2;
|
||||
DROP TABLE IF EXISTS t1,t2,t3;
|
||||
DROP PROCEDURE IF EXISTS p1;
|
||||
DROP FUNCTION IF EXISTS f1;
|
||||
DROP TRIGGER IF EXISTS trg1;
|
||||
DROP TRIGGER IF EXISTS trg2;
|
||||
set sql_warnings = 0;
|
14
mysql-test/suite/gcol/r/gcol_csv.result
Normal file
14
mysql-test/suite/gcol/r/gcol_csv.result
Normal file
|
@ -0,0 +1,14 @@
|
|||
SET @@session.storage_engine = 'CSV';
|
||||
create table t1 (a int, b virtual int as (a+1));
|
||||
ERROR HY000: 'Specified storage engine' is not yet supported for generated columns.
|
||||
create table t1 (a int not null);
|
||||
alter table t1 add column b virtual int as (a+1);
|
||||
ERROR HY000: 'Specified storage engine' is not yet supported for generated columns.
|
||||
drop table t1;
|
||||
DROP VIEW IF EXISTS v1,v2;
|
||||
DROP TABLE IF EXISTS t1,t2,t3;
|
||||
DROP PROCEDURE IF EXISTS p1;
|
||||
DROP FUNCTION IF EXISTS f1;
|
||||
DROP TRIGGER IF EXISTS trg1;
|
||||
DROP TRIGGER IF EXISTS trg2;
|
||||
set sql_warnings = 0;
|
14
mysql-test/suite/gcol/r/gcol_falcon.result
Normal file
14
mysql-test/suite/gcol/r/gcol_falcon.result
Normal file
|
@ -0,0 +1,14 @@
|
|||
SET @@session.storage_engine = 'falcon';
|
||||
create table t1 (a int, b virtual int as (a+1));
|
||||
ERROR HY000: 'Specified storage engine' is not yet supported for generated columns.
|
||||
create table t1 (a int);
|
||||
alter table t1 add column b virtual int as (a+1);
|
||||
ERROR HY000: 'Specified storage engine' is not yet supported for generated columns.
|
||||
drop table t1;
|
||||
DROP VIEW IF EXISTS v1,v2;
|
||||
DROP TABLE IF EXISTS t1,t2,t3;
|
||||
DROP PROCEDURE IF EXISTS p1;
|
||||
DROP FUNCTION IF EXISTS f1;
|
||||
DROP TRIGGER IF EXISTS trg1;
|
||||
DROP TRIGGER IF EXISTS trg2;
|
||||
set sql_warnings = 0;
|
83
mysql-test/suite/gcol/r/gcol_handler_innodb.result
Normal file
83
mysql-test/suite/gcol/r/gcol_handler_innodb.result
Normal file
|
@ -0,0 +1,83 @@
|
|||
SET @@session.default_storage_engine = 'InnoDB';
|
||||
create table t1 (a int,
|
||||
b int generated always as (-a) virtual,
|
||||
c int generated always as (-a) stored,
|
||||
d char(1),
|
||||
index (a),
|
||||
index (c));
|
||||
insert into t1 (a,d) values (4,'a'), (2,'b'), (1,'c'), (3,'d');
|
||||
select * from t1;
|
||||
a b c d
|
||||
4 -4 -4 a
|
||||
2 -2 -2 b
|
||||
1 -1 -1 c
|
||||
3 -3 -3 d
|
||||
# HANDLER tbl_name OPEN
|
||||
handler t1 open;
|
||||
# HANDLER tbl_name READ non-gcol_index_name > (value1,value2,...)
|
||||
handler t1 read a > (2);
|
||||
a b c d
|
||||
3 -3 -3 d
|
||||
# HANDLER tbl_name READ non-gcol_index_name > (value1,value2,...) WHERE non-gcol_field=expr
|
||||
handler t1 read a > (2) where d='c';
|
||||
a b c d
|
||||
# HANDLER tbl_name READ gcol_index_name = (value1,value2,...)
|
||||
handler t1 read c = (-2);
|
||||
a b c d
|
||||
2 -2 -2 b
|
||||
# HANDLER tbl_name READ gcol_index_name = (value1,value2,...) WHERE non-gcol_field=expr
|
||||
handler t1 read c = (-2) where d='c';
|
||||
a b c d
|
||||
# HANDLER tbl_name READ non-gcol_index_name > (value1,value2,...) WHERE gcol_field=expr
|
||||
handler t1 read a > (2) where b=-3 && c=-3;
|
||||
a b c d
|
||||
3 -3 -3 d
|
||||
# HANDLER tbl_name READ gcol_index_name <= (value1,value2,...)
|
||||
handler t1 read c <= (-2);
|
||||
a b c d
|
||||
2 -2 -2 b
|
||||
# HANDLER tbl_name READ gcol_index_name > (value1,value2,...) WHERE gcol_field=expr
|
||||
handler t1 read c <= (-2) where b=-3;
|
||||
a b c d
|
||||
3 -3 -3 d
|
||||
# HANDLER tbl_name READ gcol_index_name FIRST
|
||||
handler t1 read c first;
|
||||
a b c d
|
||||
4 -4 -4 a
|
||||
# HANDLER tbl_name READ gcol_index_name NEXT
|
||||
handler t1 read c next;
|
||||
a b c d
|
||||
3 -3 -3 d
|
||||
# HANDLER tbl_name READ gcol_index_name PREV
|
||||
handler t1 read c prev;
|
||||
a b c d
|
||||
4 -4 -4 a
|
||||
# HANDLER tbl_name READ gcol_index_name LAST
|
||||
handler t1 read c last;
|
||||
a b c d
|
||||
1 -1 -1 c
|
||||
# HANDLER tbl_name READ FIRST where non-gcol=expr
|
||||
handler t1 read FIRST where a >= 2;
|
||||
a b c d
|
||||
4 -4 -4 a
|
||||
# HANDLER tbl_name READ FIRST where gcol=expr
|
||||
handler t1 read FIRST where b >= -2;
|
||||
a b c d
|
||||
2 -2 -2 b
|
||||
# HANDLER tbl_name READ NEXT where non-gcol=expr
|
||||
handler t1 read NEXT where d='c';
|
||||
a b c d
|
||||
1 -1 -1 c
|
||||
# HANDLER tbl_name READ NEXT where gcol=expr
|
||||
handler t1 read NEXT where b<=-4;
|
||||
a b c d
|
||||
# HANDLER tbl_name CLOSE
|
||||
handler t1 close;
|
||||
drop table t1;
|
||||
DROP VIEW IF EXISTS v1,v2;
|
||||
DROP TABLE IF EXISTS t1,t2,t3;
|
||||
DROP PROCEDURE IF EXISTS p1;
|
||||
DROP FUNCTION IF EXISTS f1;
|
||||
DROP TRIGGER IF EXISTS trg1;
|
||||
DROP TRIGGER IF EXISTS trg2;
|
||||
set sql_warnings = 0;
|
83
mysql-test/suite/gcol/r/gcol_handler_myisam.result
Normal file
83
mysql-test/suite/gcol/r/gcol_handler_myisam.result
Normal file
|
@ -0,0 +1,83 @@
|
|||
SET @@session.default_storage_engine = 'MyISAM';
|
||||
create table t1 (a int,
|
||||
b int generated always as (-a) virtual,
|
||||
c int generated always as (-a) stored,
|
||||
d char(1),
|
||||
index (a),
|
||||
index (c));
|
||||
insert into t1 (a,d) values (4,'a'), (2,'b'), (1,'c'), (3,'d');
|
||||
select * from t1;
|
||||
a b c d
|
||||
4 -4 -4 a
|
||||
2 -2 -2 b
|
||||
1 -1 -1 c
|
||||
3 -3 -3 d
|
||||
# HANDLER tbl_name OPEN
|
||||
handler t1 open;
|
||||
# HANDLER tbl_name READ non-gcol_index_name > (value1,value2,...)
|
||||
handler t1 read a > (2);
|
||||
a b c d
|
||||
3 -3 -3 d
|
||||
# HANDLER tbl_name READ non-gcol_index_name > (value1,value2,...) WHERE non-gcol_field=expr
|
||||
handler t1 read a > (2) where d='c';
|
||||
a b c d
|
||||
# HANDLER tbl_name READ gcol_index_name = (value1,value2,...)
|
||||
handler t1 read c = (-2);
|
||||
a b c d
|
||||
2 -2 -2 b
|
||||
# HANDLER tbl_name READ gcol_index_name = (value1,value2,...) WHERE non-gcol_field=expr
|
||||
handler t1 read c = (-2) where d='c';
|
||||
a b c d
|
||||
# HANDLER tbl_name READ non-gcol_index_name > (value1,value2,...) WHERE gcol_field=expr
|
||||
handler t1 read a > (2) where b=-3 && c=-3;
|
||||
a b c d
|
||||
3 -3 -3 d
|
||||
# HANDLER tbl_name READ gcol_index_name <= (value1,value2,...)
|
||||
handler t1 read c <= (-2);
|
||||
a b c d
|
||||
2 -2 -2 b
|
||||
# HANDLER tbl_name READ gcol_index_name > (value1,value2,...) WHERE gcol_field=expr
|
||||
handler t1 read c <= (-2) where b=-3;
|
||||
a b c d
|
||||
3 -3 -3 d
|
||||
# HANDLER tbl_name READ gcol_index_name FIRST
|
||||
handler t1 read c first;
|
||||
a b c d
|
||||
4 -4 -4 a
|
||||
# HANDLER tbl_name READ gcol_index_name NEXT
|
||||
handler t1 read c next;
|
||||
a b c d
|
||||
3 -3 -3 d
|
||||
# HANDLER tbl_name READ gcol_index_name PREV
|
||||
handler t1 read c prev;
|
||||
a b c d
|
||||
4 -4 -4 a
|
||||
# HANDLER tbl_name READ gcol_index_name LAST
|
||||
handler t1 read c last;
|
||||
a b c d
|
||||
1 -1 -1 c
|
||||
# HANDLER tbl_name READ FIRST where non-gcol=expr
|
||||
handler t1 read FIRST where a >= 2;
|
||||
a b c d
|
||||
4 -4 -4 a
|
||||
# HANDLER tbl_name READ FIRST where gcol=expr
|
||||
handler t1 read FIRST where b >= -2;
|
||||
a b c d
|
||||
2 -2 -2 b
|
||||
# HANDLER tbl_name READ NEXT where non-gcol=expr
|
||||
handler t1 read NEXT where d='c';
|
||||
a b c d
|
||||
1 -1 -1 c
|
||||
# HANDLER tbl_name READ NEXT where gcol=expr
|
||||
handler t1 read NEXT where b<=-4;
|
||||
a b c d
|
||||
# HANDLER tbl_name CLOSE
|
||||
handler t1 close;
|
||||
drop table t1;
|
||||
DROP VIEW IF EXISTS v1,v2;
|
||||
DROP TABLE IF EXISTS t1,t2,t3;
|
||||
DROP PROCEDURE IF EXISTS p1;
|
||||
DROP FUNCTION IF EXISTS f1;
|
||||
DROP TRIGGER IF EXISTS trg1;
|
||||
DROP TRIGGER IF EXISTS trg2;
|
||||
set sql_warnings = 0;
|
602
mysql-test/suite/gcol/r/gcol_ins_upd_innodb.result
Normal file
602
mysql-test/suite/gcol/r/gcol_ins_upd_innodb.result
Normal file
|
@ -0,0 +1,602 @@
|
|||
SET @@session.default_storage_engine = 'InnoDB';
|
||||
create table t1 (a int,
|
||||
b int generated always as (-a) virtual,
|
||||
c int generated always as (-a) stored);
|
||||
set sql_warnings = 1;
|
||||
#
|
||||
# *** INSERT ***
|
||||
#
|
||||
# INSERT INTO tbl_name VALUES... DEFAULT is specified against gcols
|
||||
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 gcols
|
||||
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 gcols
|
||||
insert into t1 values (1,2,3);
|
||||
Warnings:
|
||||
Warning 1906 The value specified for computed column 'b' in table 't1' ignored
|
||||
Warning 1906 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_gcol_list>) VALUES...
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1 order by a;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a b c
|
||||
# INSERT INTO tbl_name (<normal+gcols>) VALUES... DEFAULT is specified
|
||||
# against gcols
|
||||
insert into t1 (a,b) values (1,default), (2,default);
|
||||
select * from t1 order by a;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a b c
|
||||
# INSERT INTO tbl_name (<normal+gcols>) VALUES... NULL is specified against gcols
|
||||
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+gcols>) VALUES... a non-NULL value is specified
|
||||
# against gcols
|
||||
insert into t1 (a,b) values (1,3), (2,4);
|
||||
Warnings:
|
||||
Warning 1906 The value specified for computed column 'b' in table 't1' ignored
|
||||
Warning 1906 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-gcol field. INSERT INTO tbl_name VALUES... ON DUPLICATE
|
||||
# KEY UPDATE <non_gcol>=expr, <gcol>=expr
|
||||
create table t1 (a int unique,
|
||||
b int generated always as (-a) virtual,
|
||||
c int generated always as (-a) stored);
|
||||
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 gcol field. INSERT INTO tbl_name VALUES... ON DUPLICATE
|
||||
# KEY UPDATE <non_gcol>=expr, <gcol>=expr
|
||||
create table t1 (a int,
|
||||
b int generated always as (-a) virtual,
|
||||
c int generated always as (-a) stored 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(a) select a from t1;
|
||||
select * from t2;
|
||||
a b c
|
||||
2 -2 -2
|
||||
drop table t2;
|
||||
# CREATE new_table ... LIKE old_table INSERT INTO new_table (<non-gcols>, <gcols>)
|
||||
# SELECT <non-gcols>, <gcols> 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) select a from t1;
|
||||
select * from t2 order by a;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
drop table t2;
|
||||
drop table t1;
|
||||
#
|
||||
# *** UPDATE ***
|
||||
#
|
||||
# UPDATE tbl_name SET non-gcol=expr WHERE non-gcol=expr
|
||||
create table t1 (a int,
|
||||
b int generated always as (-a) virtual,
|
||||
c int generated always as (-a) stored);
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1 order by a;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
update t1 set a=3 where a=2;
|
||||
select * from t1 order by a;
|
||||
a b c
|
||||
1 -1 -1
|
||||
3 -3 -3
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a b c
|
||||
# UPDATE tbl_name SET gcol=expr WHERE non-gcol=expr
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1 order by a;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
update t1 set c=3 where a=2;
|
||||
Warnings:
|
||||
Warning 1906 The value specified for computed column 'c' in table 't1' ignored
|
||||
select * from t1 order by a;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a b c
|
||||
# UPDATE tbl_name SET non-gcol=expr WHERE gcol=expr
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1 order by a;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
update t1 set a=3 where b=-2;
|
||||
select * from t1 order by a;
|
||||
a b c
|
||||
1 -1 -1
|
||||
3 -3 -3
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a b c
|
||||
# UPDATE tbl_name SET gcol=expr WHERE gcol=expr
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1 order by a;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
update t1 set c=3 where b=-2;
|
||||
Warnings:
|
||||
Warning 1906 The value specified for computed column 'c' in table 't1' ignored
|
||||
select * from t1 order by a;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a b c
|
||||
drop table t1;
|
||||
# INDEX created on gcol
|
||||
# UPDATE tbl_name SET non-gcol=expr WHERE gcol=const
|
||||
create table t1 (a int,
|
||||
b int generated always as (-a) virtual,
|
||||
c int generated always as (-a) stored unique);
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1 order by a;
|
||||
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 gcol
|
||||
# UPDATE tbl_name SET non-gcol=expr WHERE gcol=between const1 and const2
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1 order by a;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
update t1 set a=3 where c between -3 and -2;
|
||||
select * from t1 order by a;
|
||||
a b c
|
||||
1 -1 -1
|
||||
3 -3 -3
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a b c
|
||||
# No INDEX created on gcol
|
||||
# UPDATE tbl_name SET non-gcol=expr WHERE gcol=between const1 and const2
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1 order by a;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
update t1 set a=3 where b between -3 and -2;
|
||||
select * from t1 order by a;
|
||||
a b c
|
||||
1 -1 -1
|
||||
3 -3 -3
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a b c
|
||||
# INDEX created on gcol
|
||||
# UPDATE tbl_name SET non-gcol=expr
|
||||
# WHERE gcol=between const1 and const2 ORDER BY gcol
|
||||
insert into t1 (a) values (1), (2), (3), (4), (5);
|
||||
select * from t1 order by a;
|
||||
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 order by a;
|
||||
a b c
|
||||
2 -2 -2
|
||||
3 -3 -3
|
||||
4 -4 -4
|
||||
5 -5 -5
|
||||
6 -6 -6
|
||||
delete from t1 where c between -6 and 0;
|
||||
select * from t1;
|
||||
a b c
|
||||
# INDEX created on gcol
|
||||
# UPDATE tbl_name SET non-gcol=expr
|
||||
# WHERE gcol=between const1 and const2 ORDER BY gcol LIMIT 2
|
||||
insert into t1 (a) values (1), (2), (3), (4), (5);
|
||||
select * from t1 order by a;
|
||||
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 order by a;
|
||||
a b c
|
||||
2 -2 -2
|
||||
3 -3 -3
|
||||
4 -4 -4
|
||||
5 -5 -5
|
||||
6 -6 -6
|
||||
delete from t1 where c between -2 and 0 order by c;
|
||||
select * from t1 order by a;
|
||||
a b c
|
||||
3 -3 -3
|
||||
4 -4 -4
|
||||
5 -5 -5
|
||||
6 -6 -6
|
||||
delete from t1;
|
||||
# INDEX created on gcol
|
||||
# UPDATE tbl_name SET non-gcol=expr
|
||||
# WHERE indexed gcol=between const1 and const2 and non-indexed gcol=const3
|
||||
insert into t1 (a) values (1), (2), (3), (4), (5);
|
||||
select * from t1 order by a;
|
||||
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 order by a;
|
||||
a b c
|
||||
2 -2 -2
|
||||
3 -3 -3
|
||||
4 -4 -4
|
||||
5 -5 -5
|
||||
6 -6 -6
|
||||
delete from t1;
|
||||
# INDEX created on gcol
|
||||
# UPDATE tbl_name SET non-gcol=expr
|
||||
# WHERE indexed gcol=between const1 and const2 and non-indexed gcol=const3
|
||||
# ORDER BY indexed gcol
|
||||
insert into t1 (a) values (1), (2), (3), (4), (5);
|
||||
select * from t1 order by a;
|
||||
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 order by a;
|
||||
a b c
|
||||
2 -2 -2
|
||||
3 -3 -3
|
||||
4 -4 -4
|
||||
5 -5 -5
|
||||
6 -6 -6
|
||||
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 generated always as (a % 10) stored);
|
||||
insert into t2 values (1, 'value1'), (2,'value2'), (3,'value3');
|
||||
insert into t1 (a) values (1),(2),(3);
|
||||
select * from t1 order by a;
|
||||
a b
|
||||
1 1
|
||||
2 2
|
||||
3 3
|
||||
select * from t2 order by a;
|
||||
a name
|
||||
1 value1
|
||||
2 value2
|
||||
3 value3
|
||||
select t1.a, t1.b, t2.name from t1,t2 where t1.b=t2.a order by t1.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 gcol
|
||||
# REPLACE tbl_name (non-gcols) VALUES (non-gcols);
|
||||
create table t1 (a int,
|
||||
b int generated always as (-a) virtual,
|
||||
c int generated always as (-a) stored unique,
|
||||
d varchar(16));
|
||||
insert into t1 (a,d) values (1,'a'), (2,'b');
|
||||
select * from t1 order by a;
|
||||
a b c d
|
||||
1 -1 -1 a
|
||||
2 -2 -2 b
|
||||
replace t1 (a,d) values (1,'c');
|
||||
select * from t1 order by a;
|
||||
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;
|
||||
Bug#20170778: WL411:FAILING ASSERTION `!TABLE || (!TABLE->WRITE_SET ||
|
||||
BITMAP_IS_SET(TABLE->WR
|
||||
#
|
||||
CREATE TABLE t1 (col1 INT, col2 INT, col3 INT, col4 INT, col5
|
||||
INT GENERATED ALWAYS AS (col3 * col2) VIRTUAL, col6 INT GENERATED ALWAYS AS
|
||||
(col4 * col1) STORED, col7 INT GENERATED ALWAYS AS (col6 + col6) VIRTUAL,
|
||||
col8 INT GENERATED ALWAYS AS (col6 / col5) STORED, col9 TEXT);
|
||||
SET @fill_amount = (@@innodb_page_size / 2 ) + 1;
|
||||
INSERT INTO t1 (col1,col2,col3,col4,col5,col6,col7,col8,col9) VALUES /* 3 */
|
||||
(3, 3 / 3, 3 + 3, 3 / 3, DEFAULT, DEFAULT, DEFAULT, DEFAULT ,REPEAT(CAST(3 AS
|
||||
CHAR(1)),@fill_amount)) , (3, 3 * 3, 3 + 3, 3 / 3, DEFAULT, DEFAULT, DEFAULT,
|
||||
DEFAULT ,REPEAT(CAST(3 AS CHAR(1)),@fill_amount));
|
||||
UPDATE t1 SET col1 = 2;
|
||||
UPDATE t1 SET col7 = DEFAULT;
|
||||
UPDATE t1 SET col8 = DEFAULT;
|
||||
DROP TABLE t1;
|
||||
# Bug#21081742: ASSERTION !TABLE || (!TABLE->WRITE_SET ||
|
||||
# BITMAP_IS_SET(TABLE->WRITE_SET
|
||||
#
|
||||
CREATE TABLE b (
|
||||
pk INTEGER AUTO_INCREMENT,
|
||||
col_varchar_nokey VARCHAR(1),
|
||||
col_varchar_key VARCHAR(2) GENERATED ALWAYS AS
|
||||
(CONCAT(col_varchar_nokey, col_varchar_nokey)),
|
||||
PRIMARY KEY (pk)
|
||||
);
|
||||
INSERT INTO b (col_varchar_nokey) VALUES ('v'),('v');
|
||||
CREATE TABLE d (
|
||||
pk INTEGER AUTO_INCREMENT,
|
||||
col_varchar_nokey VARCHAR(1),
|
||||
col_varchar_key VARCHAR(2) GENERATED ALWAYS AS
|
||||
(CONCAT(col_varchar_nokey, col_varchar_nokey)),
|
||||
PRIMARY KEY (pk)
|
||||
) ;
|
||||
INSERT INTO d (col_varchar_nokey) VALUES ('q'),('g'),('e'),('l'),(NULL),('v'),('c'),('u'),('x');
|
||||
CREATE TABLE bb (
|
||||
pk INTEGER AUTO_INCREMENT,
|
||||
col_varchar_nokey VARCHAR(1) /*! NULL */,
|
||||
col_varchar_key VARCHAR(2) GENERATED ALWAYS AS
|
||||
(CONCAT(col_varchar_nokey, col_varchar_nokey)),
|
||||
PRIMARY KEY (pk)
|
||||
);
|
||||
INSERT INTO bb (col_varchar_nokey) VALUES ('j'),('h');
|
||||
EXPLAIN UPDATE
|
||||
d AS OUTR1, b AS OUTR2
|
||||
SET OUTR1.col_varchar_nokey = NULL
|
||||
WHERE
|
||||
( 't', 'b' ) IN
|
||||
(
|
||||
SELECT
|
||||
INNR1.col_varchar_nokey AS x,
|
||||
INNR1.col_varchar_key AS y
|
||||
FROM bb AS INNR1
|
||||
WHERE OUTR1.pk = 1
|
||||
);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY OUTR1 const PRIMARY PRIMARY 4 const 1
|
||||
1 PRIMARY INNR1 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(OUTR1)
|
||||
1 PRIMARY OUTR2 index NULL PRIMARY 4 NULL 2 Using index
|
||||
DROP TABLE IF EXISTS b,bb,d;
|
||||
#
|
||||
# Bug#21216067 ASSERTION FAILED ROW_UPD_SEC_INDEX_ENTRY (INNOBASE/ROW/ROW0UPD.CC:2103)
|
||||
#
|
||||
CREATE TABLE t (
|
||||
x INT, y INT, gc INT GENERATED ALWAYS AS (x+1) STORED
|
||||
);
|
||||
INSERT INTO t VALUES ();
|
||||
UPDATE t t1, t t2 SET t2.y = 1, t1.x = 2;
|
||||
SELECT * FROM t;
|
||||
x y gc
|
||||
2 1 3
|
||||
DROP TABLE t;
|
||||
# stored
|
||||
CREATE TABLE C (
|
||||
col_varchar_nokey VARCHAR(1),
|
||||
col_varchar_key VARCHAR(2) GENERATED ALWAYS AS
|
||||
(CONCAT(col_varchar_nokey, col_varchar_nokey)) STORED
|
||||
);
|
||||
INSERT INTO C (col_varchar_nokey) VALUES ('c');
|
||||
EXPLAIN UPDATE C AS OUTR1, C AS OUTR2
|
||||
SET OUTR1.`col_varchar_nokey` = 'f',
|
||||
OUTR2.`col_varchar_nokey` = "a";
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE OUTR1 ALL NULL NULL NULL NULL 1
|
||||
1 SIMPLE OUTR2 ALL NULL NULL NULL NULL 1
|
||||
UPDATE C AS OUTR1, C AS OUTR2
|
||||
SET OUTR1.`col_varchar_nokey` = 'f',
|
||||
OUTR2.`col_varchar_nokey` = "a";
|
||||
SELECT * from C;
|
||||
col_varchar_nokey col_varchar_key
|
||||
a aa
|
||||
DROP TABLE C;
|
||||
# stored, indexed
|
||||
CREATE TABLE C (
|
||||
col_varchar_nokey VARCHAR(1),
|
||||
col_varchar_key VARCHAR(2) GENERATED ALWAYS AS
|
||||
(CONCAT(col_varchar_nokey, col_varchar_nokey)) STORED,
|
||||
KEY (col_varchar_key, col_varchar_nokey)
|
||||
);
|
||||
INSERT INTO C (col_varchar_nokey) VALUES ('c');
|
||||
EXPLAIN UPDATE C AS OUTR1, C AS OUTR2
|
||||
SET OUTR1.`col_varchar_nokey` = 'f',
|
||||
OUTR2.`col_varchar_nokey` = "a";
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE OUTR1 ALL NULL NULL NULL NULL 1
|
||||
1 SIMPLE OUTR2 ALL NULL NULL NULL NULL 1
|
||||
UPDATE C AS OUTR1, C AS OUTR2
|
||||
SET OUTR1.`col_varchar_nokey` = 'f',
|
||||
OUTR2.`col_varchar_nokey` = "a";
|
||||
SELECT * from C;
|
||||
col_varchar_nokey col_varchar_key
|
||||
a aa
|
||||
DROP TABLE C;
|
||||
# virtual
|
||||
CREATE TABLE C (
|
||||
col_varchar_nokey VARCHAR(1),
|
||||
col_varchar_key VARCHAR(2) GENERATED ALWAYS AS
|
||||
(CONCAT(col_varchar_nokey, col_varchar_nokey)) VIRTUAL
|
||||
);
|
||||
INSERT INTO C (col_varchar_nokey) VALUES ('c');
|
||||
EXPLAIN UPDATE C AS OUTR1, C AS OUTR2
|
||||
SET OUTR1.`col_varchar_nokey` = 'f',
|
||||
OUTR2.`col_varchar_nokey` = "a";
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE OUTR1 ALL NULL NULL NULL NULL 1
|
||||
1 SIMPLE OUTR2 ALL NULL NULL NULL NULL 1
|
||||
UPDATE C AS OUTR1, C AS OUTR2
|
||||
SET OUTR1.`col_varchar_nokey` = 'f',
|
||||
OUTR2.`col_varchar_nokey` = "a";
|
||||
SELECT * from C;
|
||||
col_varchar_nokey col_varchar_key
|
||||
a aa
|
||||
DROP TABLE C;
|
||||
#Bug#21929967:GCOLS:GCOL VALUE CHANGES WHEN SESSION CHANGES SQL_MODE
|
||||
CREATE TABLE t(c1 INT GENERATED ALWAYS AS (1) VIRTUAL,
|
||||
c2 INT GENERATED ALWAYS AS(2) STORED);
|
||||
INSERT INTO t VALUES(DEFAULT, DEFAULT);
|
||||
SELECT * FROM t;
|
||||
c1 c2
|
||||
1 2
|
||||
CREATE TABLE t1(c1 INT, c2 INT GENERATED ALWAYS AS(c1 + 1) STORED);
|
||||
INSERT INTO t1(c2) VALUES(DEFAULT);
|
||||
SELECT * FROM t1;
|
||||
c1 c2
|
||||
NULL NULL
|
||||
CREATE TABLE t2(c1 INT DEFAULT 1, c2 INT GENERATED ALWAYS AS(c1 + 1) STORED);
|
||||
INSERT INTO t2(c2) VALUES(DEFAULT);
|
||||
SELECT * FROM t2;
|
||||
c1 c2
|
||||
1 2
|
||||
DROP TABLE t, t1, t2;
|
||||
# Bug#22179637: INSERT INTO TABLE FROM SELECT ACCEPTS TO INSERT INTO
|
||||
# GENERATED COLUMNS
|
||||
CREATE TABLE t1 (
|
||||
i1 INTEGER,
|
||||
i2 INTEGER GENERATED ALWAYS AS (i1 + i1)
|
||||
);
|
||||
INSERT INTO t1 (i1) SELECT 5;
|
||||
INSERT INTO t1 (i1) SELECT 5 ON DUPLICATE KEY UPDATE i2= DEFAULT;
|
||||
SELECT * FROM t1;
|
||||
i1 i2
|
||||
5 10
|
||||
5 10
|
||||
CREATE TABLE t2 (
|
||||
i1 INTEGER,
|
||||
i2 INTEGER GENERATED ALWAYS AS (i1 + i1) STORED
|
||||
);
|
||||
INSERT INTO t2 (i1) SELECT 5;
|
||||
INSERT INTO t2 (i1) SELECT 5 ON DUPLICATE KEY UPDATE i2= DEFAULT;
|
||||
SELECT * FROM t2;
|
||||
i1 i2
|
||||
5 10
|
||||
5 10
|
||||
DROP TABLE t1,t2;
|
||||
DROP VIEW IF EXISTS v1,v2;
|
||||
DROP TABLE IF EXISTS t1,t2,t3;
|
||||
DROP PROCEDURE IF EXISTS p1;
|
||||
DROP FUNCTION IF EXISTS f1;
|
||||
DROP TRIGGER IF EXISTS trg1;
|
||||
DROP TRIGGER IF EXISTS trg2;
|
||||
set sql_warnings = 0;
|
524
mysql-test/suite/gcol/r/gcol_ins_upd_myisam.result
Normal file
524
mysql-test/suite/gcol/r/gcol_ins_upd_myisam.result
Normal file
|
@ -0,0 +1,524 @@
|
|||
SET @@session.default_storage_engine = 'MyISAM';
|
||||
create table t1 (a int,
|
||||
b int generated always as (-a) virtual,
|
||||
c int generated always as (-a) stored);
|
||||
set sql_warnings = 1;
|
||||
#
|
||||
# *** INSERT ***
|
||||
#
|
||||
# INSERT INTO tbl_name VALUES... DEFAULT is specified against gcols
|
||||
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 gcols
|
||||
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 gcols
|
||||
insert into t1 values (1,2,3);
|
||||
Warnings:
|
||||
Warning 1906 The value specified for computed column 'b' in table 't1' ignored
|
||||
Warning 1906 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_gcol_list>) VALUES...
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1 order by a;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a b c
|
||||
# INSERT INTO tbl_name (<normal+gcols>) VALUES... DEFAULT is specified
|
||||
# against gcols
|
||||
insert into t1 (a,b) values (1,default), (2,default);
|
||||
select * from t1 order by a;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a b c
|
||||
# INSERT INTO tbl_name (<normal+gcols>) VALUES... NULL is specified against gcols
|
||||
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+gcols>) VALUES... a non-NULL value is specified
|
||||
# against gcols
|
||||
insert into t1 (a,b) values (1,3), (2,4);
|
||||
Warnings:
|
||||
Warning 1906 The value specified for computed column 'b' in table 't1' ignored
|
||||
Warning 1906 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-gcol field. INSERT INTO tbl_name VALUES... ON DUPLICATE
|
||||
# KEY UPDATE <non_gcol>=expr, <gcol>=expr
|
||||
create table t1 (a int unique,
|
||||
b int generated always as (-a) virtual,
|
||||
c int generated always as (-a) stored);
|
||||
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 gcol field. INSERT INTO tbl_name VALUES... ON DUPLICATE
|
||||
# KEY UPDATE <non_gcol>=expr, <gcol>=expr
|
||||
create table t1 (a int,
|
||||
b int generated always as (-a) virtual,
|
||||
c int generated always as (-a) stored 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(a) select a from t1;
|
||||
select * from t2;
|
||||
a b c
|
||||
2 -2 -2
|
||||
drop table t2;
|
||||
# CREATE new_table ... LIKE old_table INSERT INTO new_table (<non-gcols>, <gcols>)
|
||||
# SELECT <non-gcols>, <gcols> 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) select a from t1;
|
||||
select * from t2 order by a;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
drop table t2;
|
||||
drop table t1;
|
||||
#
|
||||
# *** UPDATE ***
|
||||
#
|
||||
# UPDATE tbl_name SET non-gcol=expr WHERE non-gcol=expr
|
||||
create table t1 (a int,
|
||||
b int generated always as (-a) virtual,
|
||||
c int generated always as (-a) stored);
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1 order by a;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
update t1 set a=3 where a=2;
|
||||
select * from t1 order by a;
|
||||
a b c
|
||||
1 -1 -1
|
||||
3 -3 -3
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a b c
|
||||
# UPDATE tbl_name SET gcol=expr WHERE non-gcol=expr
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1 order by a;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
update t1 set c=3 where a=2;
|
||||
Warnings:
|
||||
Warning 1906 The value specified for computed column 'c' in table 't1' ignored
|
||||
select * from t1 order by a;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a b c
|
||||
# UPDATE tbl_name SET non-gcol=expr WHERE gcol=expr
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1 order by a;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
update t1 set a=3 where b=-2;
|
||||
select * from t1 order by a;
|
||||
a b c
|
||||
1 -1 -1
|
||||
3 -3 -3
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a b c
|
||||
# UPDATE tbl_name SET gcol=expr WHERE gcol=expr
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1 order by a;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
update t1 set c=3 where b=-2;
|
||||
Warnings:
|
||||
Warning 1906 The value specified for computed column 'c' in table 't1' ignored
|
||||
select * from t1 order by a;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a b c
|
||||
drop table t1;
|
||||
# INDEX created on gcol
|
||||
# UPDATE tbl_name SET non-gcol=expr WHERE gcol=const
|
||||
create table t1 (a int,
|
||||
b int generated always as (-a) virtual,
|
||||
c int generated always as (-a) stored unique);
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1 order by a;
|
||||
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 gcol
|
||||
# UPDATE tbl_name SET non-gcol=expr WHERE gcol=between const1 and const2
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1 order by a;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
update t1 set a=3 where c between -3 and -2;
|
||||
select * from t1 order by a;
|
||||
a b c
|
||||
1 -1 -1
|
||||
3 -3 -3
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a b c
|
||||
# No INDEX created on gcol
|
||||
# UPDATE tbl_name SET non-gcol=expr WHERE gcol=between const1 and const2
|
||||
insert into t1 (a) values (1), (2);
|
||||
select * from t1 order by a;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
update t1 set a=3 where b between -3 and -2;
|
||||
select * from t1 order by a;
|
||||
a b c
|
||||
1 -1 -1
|
||||
3 -3 -3
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
a b c
|
||||
# INDEX created on gcol
|
||||
# UPDATE tbl_name SET non-gcol=expr
|
||||
# WHERE gcol=between const1 and const2 ORDER BY gcol
|
||||
insert into t1 (a) values (1), (2), (3), (4), (5);
|
||||
select * from t1 order by a;
|
||||
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 order by a;
|
||||
a b c
|
||||
2 -2 -2
|
||||
3 -3 -3
|
||||
4 -4 -4
|
||||
5 -5 -5
|
||||
6 -6 -6
|
||||
delete from t1 where c between -6 and 0;
|
||||
select * from t1;
|
||||
a b c
|
||||
# INDEX created on gcol
|
||||
# UPDATE tbl_name SET non-gcol=expr
|
||||
# WHERE gcol=between const1 and const2 ORDER BY gcol LIMIT 2
|
||||
insert into t1 (a) values (1), (2), (3), (4), (5);
|
||||
select * from t1 order by a;
|
||||
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 order by a;
|
||||
a b c
|
||||
2 -2 -2
|
||||
3 -3 -3
|
||||
4 -4 -4
|
||||
5 -5 -5
|
||||
6 -6 -6
|
||||
delete from t1 where c between -2 and 0 order by c;
|
||||
select * from t1 order by a;
|
||||
a b c
|
||||
3 -3 -3
|
||||
4 -4 -4
|
||||
5 -5 -5
|
||||
6 -6 -6
|
||||
delete from t1;
|
||||
# INDEX created on gcol
|
||||
# UPDATE tbl_name SET non-gcol=expr
|
||||
# WHERE indexed gcol=between const1 and const2 and non-indexed gcol=const3
|
||||
insert into t1 (a) values (1), (2), (3), (4), (5);
|
||||
select * from t1 order by a;
|
||||
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 order by a;
|
||||
a b c
|
||||
2 -2 -2
|
||||
3 -3 -3
|
||||
4 -4 -4
|
||||
5 -5 -5
|
||||
6 -6 -6
|
||||
delete from t1;
|
||||
# INDEX created on gcol
|
||||
# UPDATE tbl_name SET non-gcol=expr
|
||||
# WHERE indexed gcol=between const1 and const2 and non-indexed gcol=const3
|
||||
# ORDER BY indexed gcol
|
||||
insert into t1 (a) values (1), (2), (3), (4), (5);
|
||||
select * from t1 order by a;
|
||||
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 order by a;
|
||||
a b c
|
||||
2 -2 -2
|
||||
3 -3 -3
|
||||
4 -4 -4
|
||||
5 -5 -5
|
||||
6 -6 -6
|
||||
delete from t1;
|
||||
drop table t1;
|
||||
#
|
||||
# *** REPLACE ***
|
||||
#
|
||||
# UNIQUE INDEX on gcol
|
||||
# REPLACE tbl_name (non-gcols) VALUES (non-gcols);
|
||||
create table t1 (a int,
|
||||
b int generated always as (-a) virtual,
|
||||
c int generated always as (-a) stored unique,
|
||||
d varchar(16));
|
||||
insert into t1 (a,d) values (1,'a'), (2,'b');
|
||||
select * from t1 order by a;
|
||||
a b c d
|
||||
1 -1 -1 a
|
||||
2 -2 -2 b
|
||||
replace t1 (a,d) values (1,'c');
|
||||
select * from t1 order by a;
|
||||
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;
|
||||
# Bug#21081742: ASSERTION !TABLE || (!TABLE->WRITE_SET ||
|
||||
# BITMAP_IS_SET(TABLE->WRITE_SET
|
||||
#
|
||||
CREATE TABLE b (
|
||||
pk INTEGER AUTO_INCREMENT,
|
||||
col_varchar_nokey VARCHAR(1),
|
||||
col_varchar_key VARCHAR(2) GENERATED ALWAYS AS
|
||||
(CONCAT(col_varchar_nokey, col_varchar_nokey)),
|
||||
PRIMARY KEY (pk)
|
||||
);
|
||||
INSERT INTO b (col_varchar_nokey) VALUES ('v'),('v');
|
||||
CREATE TABLE d (
|
||||
pk INTEGER AUTO_INCREMENT,
|
||||
col_varchar_nokey VARCHAR(1),
|
||||
col_varchar_key VARCHAR(2) GENERATED ALWAYS AS
|
||||
(CONCAT(col_varchar_nokey, col_varchar_nokey)),
|
||||
PRIMARY KEY (pk)
|
||||
) ;
|
||||
INSERT INTO d (col_varchar_nokey) VALUES ('q'),('g'),('e'),('l'),(NULL),('v'),('c'),('u'),('x');
|
||||
CREATE TABLE bb (
|
||||
pk INTEGER AUTO_INCREMENT,
|
||||
col_varchar_nokey VARCHAR(1) /*! NULL */,
|
||||
col_varchar_key VARCHAR(2) GENERATED ALWAYS AS
|
||||
(CONCAT(col_varchar_nokey, col_varchar_nokey)),
|
||||
PRIMARY KEY (pk)
|
||||
);
|
||||
INSERT INTO bb (col_varchar_nokey) VALUES ('j'),('h');
|
||||
EXPLAIN UPDATE
|
||||
d AS OUTR1, b AS OUTR2
|
||||
SET OUTR1.col_varchar_nokey = NULL
|
||||
WHERE
|
||||
( 't', 'b' ) IN
|
||||
(
|
||||
SELECT
|
||||
INNR1.col_varchar_nokey AS x,
|
||||
INNR1.col_varchar_key AS y
|
||||
FROM bb AS INNR1
|
||||
WHERE OUTR1.pk = 1
|
||||
);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY OUTR1 const PRIMARY PRIMARY 4 const 1
|
||||
1 PRIMARY INNR1 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(OUTR1)
|
||||
1 PRIMARY OUTR2 index NULL PRIMARY 4 NULL 2 Using index
|
||||
DROP TABLE IF EXISTS b,bb,d;
|
||||
#
|
||||
# Bug#21216067 ASSERTION FAILED ROW_UPD_SEC_INDEX_ENTRY (INNOBASE/ROW/ROW0UPD.CC:2103)
|
||||
#
|
||||
CREATE TABLE t (
|
||||
x INT, y INT, gc INT GENERATED ALWAYS AS (x+1) STORED
|
||||
);
|
||||
INSERT INTO t VALUES ();
|
||||
UPDATE t t1, t t2 SET t2.y = 1, t1.x = 2;
|
||||
SELECT * FROM t;
|
||||
x y gc
|
||||
2 1 3
|
||||
DROP TABLE t;
|
||||
# stored
|
||||
CREATE TABLE C (
|
||||
col_varchar_nokey VARCHAR(1),
|
||||
col_varchar_key VARCHAR(2) GENERATED ALWAYS AS
|
||||
(CONCAT(col_varchar_nokey, col_varchar_nokey)) STORED
|
||||
);
|
||||
INSERT INTO C (col_varchar_nokey) VALUES ('c');
|
||||
EXPLAIN UPDATE C AS OUTR1, C AS OUTR2
|
||||
SET OUTR1.`col_varchar_nokey` = 'f',
|
||||
OUTR2.`col_varchar_nokey` = "a";
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE OUTR1 system NULL NULL NULL NULL 1
|
||||
1 SIMPLE OUTR2 system NULL NULL NULL NULL 1
|
||||
UPDATE C AS OUTR1, C AS OUTR2
|
||||
SET OUTR1.`col_varchar_nokey` = 'f',
|
||||
OUTR2.`col_varchar_nokey` = "a";
|
||||
SELECT * from C;
|
||||
col_varchar_nokey col_varchar_key
|
||||
a aa
|
||||
DROP TABLE C;
|
||||
# stored, indexed
|
||||
CREATE TABLE C (
|
||||
col_varchar_nokey VARCHAR(1),
|
||||
col_varchar_key VARCHAR(2) GENERATED ALWAYS AS
|
||||
(CONCAT(col_varchar_nokey, col_varchar_nokey)) STORED,
|
||||
KEY (col_varchar_key, col_varchar_nokey)
|
||||
);
|
||||
INSERT INTO C (col_varchar_nokey) VALUES ('c');
|
||||
EXPLAIN UPDATE C AS OUTR1, C AS OUTR2
|
||||
SET OUTR1.`col_varchar_nokey` = 'f',
|
||||
OUTR2.`col_varchar_nokey` = "a";
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE OUTR1 system NULL NULL NULL NULL 1
|
||||
1 SIMPLE OUTR2 system NULL NULL NULL NULL 1
|
||||
UPDATE C AS OUTR1, C AS OUTR2
|
||||
SET OUTR1.`col_varchar_nokey` = 'f',
|
||||
OUTR2.`col_varchar_nokey` = "a";
|
||||
SELECT * from C;
|
||||
col_varchar_nokey col_varchar_key
|
||||
a aa
|
||||
DROP TABLE C;
|
||||
# virtual
|
||||
CREATE TABLE C (
|
||||
col_varchar_nokey VARCHAR(1),
|
||||
col_varchar_key VARCHAR(2) GENERATED ALWAYS AS
|
||||
(CONCAT(col_varchar_nokey, col_varchar_nokey)) VIRTUAL
|
||||
);
|
||||
INSERT INTO C (col_varchar_nokey) VALUES ('c');
|
||||
EXPLAIN UPDATE C AS OUTR1, C AS OUTR2
|
||||
SET OUTR1.`col_varchar_nokey` = 'f',
|
||||
OUTR2.`col_varchar_nokey` = "a";
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE OUTR1 system NULL NULL NULL NULL 1
|
||||
1 SIMPLE OUTR2 system NULL NULL NULL NULL 1
|
||||
UPDATE C AS OUTR1, C AS OUTR2
|
||||
SET OUTR1.`col_varchar_nokey` = 'f',
|
||||
OUTR2.`col_varchar_nokey` = "a";
|
||||
SELECT * from C;
|
||||
col_varchar_nokey col_varchar_key
|
||||
a aa
|
||||
DROP TABLE C;
|
||||
#Bug#21929967:GCOLS:GCOL VALUE CHANGES WHEN SESSION CHANGES SQL_MODE
|
||||
CREATE TABLE t(c1 INT GENERATED ALWAYS AS (1) VIRTUAL,
|
||||
c2 INT GENERATED ALWAYS AS(2) STORED);
|
||||
INSERT INTO t VALUES(DEFAULT, DEFAULT);
|
||||
SELECT * FROM t;
|
||||
c1 c2
|
||||
1 2
|
||||
CREATE TABLE t1(c1 INT, c2 INT GENERATED ALWAYS AS(c1 + 1) STORED);
|
||||
INSERT INTO t1(c2) VALUES(DEFAULT);
|
||||
SELECT * FROM t1;
|
||||
c1 c2
|
||||
NULL NULL
|
||||
CREATE TABLE t2(c1 INT DEFAULT 1, c2 INT GENERATED ALWAYS AS(c1 + 1) STORED);
|
||||
INSERT INTO t2(c2) VALUES(DEFAULT);
|
||||
SELECT * FROM t2;
|
||||
c1 c2
|
||||
1 2
|
||||
DROP TABLE t, t1, t2;
|
||||
# Bug#22179637: INSERT INTO TABLE FROM SELECT ACCEPTS TO INSERT INTO
|
||||
# GENERATED COLUMNS
|
||||
CREATE TABLE t1 (
|
||||
i1 INTEGER,
|
||||
i2 INTEGER GENERATED ALWAYS AS (i1 + i1)
|
||||
);
|
||||
INSERT INTO t1 (i1) SELECT 5;
|
||||
INSERT INTO t1 (i1) SELECT 5 ON DUPLICATE KEY UPDATE i2= DEFAULT;
|
||||
SELECT * FROM t1;
|
||||
i1 i2
|
||||
5 10
|
||||
5 10
|
||||
CREATE TABLE t2 (
|
||||
i1 INTEGER,
|
||||
i2 INTEGER GENERATED ALWAYS AS (i1 + i1) STORED
|
||||
);
|
||||
INSERT INTO t2 (i1) SELECT 5;
|
||||
INSERT INTO t2 (i1) SELECT 5 ON DUPLICATE KEY UPDATE i2= DEFAULT;
|
||||
SELECT * FROM t2;
|
||||
i1 i2
|
||||
5 10
|
||||
5 10
|
||||
DROP TABLE t1,t2;
|
||||
DROP VIEW IF EXISTS v1,v2;
|
||||
DROP TABLE IF EXISTS t1,t2,t3;
|
||||
DROP PROCEDURE IF EXISTS p1;
|
||||
DROP FUNCTION IF EXISTS f1;
|
||||
DROP TRIGGER IF EXISTS trg1;
|
||||
DROP TRIGGER IF EXISTS trg2;
|
||||
set sql_warnings = 0;
|
421
mysql-test/suite/gcol/r/gcol_keys_innodb.result
Normal file
421
mysql-test/suite/gcol/r/gcol_keys_innodb.result
Normal file
|
@ -0,0 +1,421 @@
|
|||
SET @@session.default_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 generated always as (a*2) stored 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 PERSISTENT
|
||||
drop table t1;
|
||||
create table t1 (a int, b int generated always as (a*2) stored, 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 PERSISTENT
|
||||
drop table t1;
|
||||
create table t1 (a int, b int generated always as (a*2) stored);
|
||||
alter table t1 add unique key (b);
|
||||
drop table t1;
|
||||
# Testing data manipulation operations involving UNIQUE keys
|
||||
# on generated columns can be found in:
|
||||
# - gcol_ins_upd.inc
|
||||
# - gcol_select.inc
|
||||
#
|
||||
# INDEX
|
||||
create table t1 (a int, b int generated always as (a*2) stored, 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 PERSISTENT
|
||||
drop table t1;
|
||||
create table t1 (a int, b int generated always as (a*2) stored, 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 PERSISTENT
|
||||
drop table t1;
|
||||
create table t1 (a int, b int generated always as (a*2) stored);
|
||||
alter table t1 add index (b);
|
||||
drop table t1;
|
||||
create table t1 (a int, b int generated always as (a*2) stored);
|
||||
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 generated columns can be found in:
|
||||
# - gcol_select.inc
|
||||
#
|
||||
# TODO: FULLTEXT INDEX
|
||||
# SPATIAL INDEX
|
||||
# FOREIGN KEY
|
||||
# Rejected FK options.
|
||||
create table t1 (a int, b int generated always as (a+1) stored,
|
||||
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 generated always as (a+1) stored,
|
||||
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 generated always as (a+1) stored,
|
||||
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 generated always as (a+1) stored);
|
||||
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;
|
||||
# Allowed FK options.
|
||||
create table t2 (a int primary key, b char(5));
|
||||
create table t1 (a int, b int generated always as (a % 10) stored,
|
||||
foreign key (b) references t2(a) on update restrict);
|
||||
drop table t1;
|
||||
create table t1 (a int, b int generated always as (a % 10) stored,
|
||||
foreign key (b) references t2(a) on update no action);
|
||||
drop table t1;
|
||||
create table t1 (a int, b int generated always as (a % 10) stored,
|
||||
foreign key (b) references t2(a) on delete restrict);
|
||||
drop table t1;
|
||||
create table t1 (a int, b int generated always as (a % 10) stored,
|
||||
foreign key (b) references t2(a) on delete cascade);
|
||||
drop table t1;
|
||||
create table t1 (a int, b int generated always as (a % 10) stored,
|
||||
foreign key (b) references t2(a) on delete no action);
|
||||
drop table t1,t2;
|
||||
|
||||
# Testing data manipulation operations involving FOREIGN KEY
|
||||
# on generated columns can be found in:
|
||||
# - gcol_ins_upd.inc
|
||||
# - gcol_select.inc
|
||||
#
|
||||
# TODO: CHECK
|
||||
#
|
||||
# Test how optimizer picks indexes defined on a GC
|
||||
#
|
||||
CREATE TABLE t1 (f1 int, gc int AS (f1 + 1) STORED, UNIQUE(gc));
|
||||
INSERT INTO t1(f1) VALUES (1),(2),(0),(9),(3),(4),(8),(7),(5),(6);
|
||||
ANALYZE TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
# Should use index
|
||||
SELECT * FROM t1 WHERE f1 + 1 > 7;
|
||||
f1 gc
|
||||
7 8
|
||||
8 9
|
||||
9 10
|
||||
EXPLAIN SELECT * FROM t1 WHERE f1 + 1 > 7;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using where
|
||||
SELECT * FROM t1 WHERE f1 + 1 = 7;
|
||||
f1 gc
|
||||
6 7
|
||||
EXPLAIN SELECT * FROM t1 WHERE f1 + 1 = 7;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using where
|
||||
SELECT * FROM t1 WHERE f1 + 1 IN (7,5);
|
||||
f1 gc
|
||||
4 5
|
||||
6 7
|
||||
EXPLAIN SELECT * FROM t1 WHERE f1 + 1 IN(7,5);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using where
|
||||
SELECT * FROM t1 WHERE f1 + 1 BETWEEN 5 AND 7;
|
||||
f1 gc
|
||||
4 5
|
||||
5 6
|
||||
6 7
|
||||
EXPLAIN SELECT * FROM t1 WHERE f1 + 1 BETWEEN 5 AND 7;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using where
|
||||
# Check that expression isn't transformed for a disabled key
|
||||
SELECT * FROM t1 IGNORE KEY (gc) WHERE f1 + 1 BETWEEN 5 AND 7;
|
||||
f1 gc
|
||||
4 5
|
||||
5 6
|
||||
6 7
|
||||
EXPLAIN SELECT * FROM t1 IGNORE KEY (gc) WHERE f1 + 1 BETWEEN 5 AND 7;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using where
|
||||
# Check that ORDER BY could be optimized
|
||||
SELECT * FROM t1 ORDER BY f1 + 1;
|
||||
f1 gc
|
||||
0 1
|
||||
1 2
|
||||
2 3
|
||||
3 4
|
||||
4 5
|
||||
5 6
|
||||
6 7
|
||||
7 8
|
||||
8 9
|
||||
9 10
|
||||
EXPLAIN SELECT * FROM t1 ORDER BY f1 + 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using filesort
|
||||
EXPLAIN SELECT * FROM t1 IGNORE KEY (gc) ORDER BY f1 + 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using filesort
|
||||
# Check that GROUP BY could be optimized
|
||||
SELECT f1 + 1, MAX(GC) FROM t1 GROUP BY f1 + 1;
|
||||
f1 + 1 MAX(GC)
|
||||
1 1
|
||||
2 2
|
||||
3 3
|
||||
4 4
|
||||
5 5
|
||||
6 6
|
||||
7 7
|
||||
8 8
|
||||
9 9
|
||||
10 10
|
||||
EXPLAIN SELECT f1 + 1, MAX(GC) FROM t1 GROUP BY f1 + 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using temporary; Using filesort
|
||||
EXPLAIN SELECT f1 + 1, MAX(GC)
|
||||
FROM t1 IGNORE KEY (gc) GROUP BY f1 + 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using temporary; Using filesort
|
||||
# Shouldn't use index
|
||||
SELECT * FROM t1 WHERE f1 + 1 > 7.0;
|
||||
f1 gc
|
||||
7 8
|
||||
8 9
|
||||
9 10
|
||||
EXPLAIN SELECT * FROM t1 WHERE f1 + 1 > 7.0;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using where
|
||||
DROP TABLE t1;
|
||||
# Pick index with proper type
|
||||
CREATE TABLE t1 (f1 int,
|
||||
gc_int int AS (f1 + 1) STORED,
|
||||
gc_date DATE AS (f1 + 1) STORED,
|
||||
KEY gc_int_idx(gc_int),
|
||||
KEY gc_date_idx(gc_date));
|
||||
INSERT INTO t1(f1) VALUES
|
||||
(030303),(040404),
|
||||
(050505),(060606),
|
||||
(010101),(020202),
|
||||
(030303),(040404),
|
||||
(050505),(060606),
|
||||
(010101),(020202),
|
||||
(090909),(101010),
|
||||
(010101),(020202),
|
||||
(070707),(080808);
|
||||
ANALYZE TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
SELECT * FROM t1 WHERE f1 + 1 > 070707;
|
||||
f1 gc_int gc_date
|
||||
101010 101011 2010-10-11
|
||||
70707 70708 2007-07-08
|
||||
80808 80809 2008-08-09
|
||||
90909 90910 2009-09-10
|
||||
# INT column & index should be picked
|
||||
EXPLAIN SELECT * FROM t1 WHERE f1 + 1 > 070707;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 18 Using where
|
||||
SELECT * FROM t1 WHERE f1 + 1 > CAST(070707 AS DATE);
|
||||
f1 gc_int gc_date
|
||||
101010 101011 2010-10-11
|
||||
70707 70708 2007-07-08
|
||||
80808 80809 2008-08-09
|
||||
90909 90910 2009-09-10
|
||||
# DATE column & index should be picked
|
||||
EXPLAIN SELECT * FROM t1 WHERE f1 + 1 > CAST(070707 AS DATE);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 18 Using where
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# BUG#21229846: WL8170: SIGNAL 11 IN JOIN::MAKE_SUM_FUNC_LIST
|
||||
#
|
||||
CREATE TABLE t1 (
|
||||
pk int primary key auto_increment,
|
||||
col_int_key INTEGER ,
|
||||
col_int_gc_key INT GENERATED ALWAYS AS (col_int_key + 1) STORED,
|
||||
KEY col_int_gc_key(col_int_gc_key)
|
||||
);
|
||||
INSERT INTO t1 ( col_int_key) VALUES (7);
|
||||
ANALYZE TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
SELECT table1.col_int_key + 1 AS field1, table2.col_int_key AS field2
|
||||
FROM (t1 AS table1 JOIN t1 AS table2 ON (table2.pk = table1.pk))
|
||||
ORDER BY field1, field2;
|
||||
field1 field2
|
||||
8 7
|
||||
EXPLAIN SELECT table1.col_int_key + 1 AS field1, table2.col_int_key AS field2
|
||||
FROM (t1 AS table1 JOIN t1 AS table2 ON (table2.pk = table1.pk))
|
||||
ORDER BY field1, field2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE table1 ALL PRIMARY NULL NULL NULL 1 Using temporary; Using filesort
|
||||
1 SIMPLE table2 eq_ref PRIMARY PRIMARY 4 test.table1.pk 1
|
||||
SELECT table1.col_int_key + 1 AS field1, table2.col_int_key AS field2
|
||||
FROM (t1 AS table1 JOIN t1 AS table2 ON (table2.pk = table1.pk))
|
||||
GROUP BY field1, field2;
|
||||
field1 field2
|
||||
8 7
|
||||
EXPLAIN SELECT table1.col_int_key + 1 AS field1, table2.col_int_key AS field2
|
||||
FROM (t1 AS table1 JOIN t1 AS table2 ON (table2.pk = table1.pk))
|
||||
GROUP BY field1, field2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE table1 ALL PRIMARY NULL NULL NULL 1 Using temporary; Using filesort
|
||||
1 SIMPLE table2 eq_ref PRIMARY PRIMARY 4 test.table1.pk 1
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# Bug#21770798 OPTIMIZER DOES NOT USE INDEX FOR GENERATED EXPRESSIONS
|
||||
# WITH LOGICAL OPERATORS
|
||||
#
|
||||
CREATE TABLE t (a INT, b INT,
|
||||
gc_and INT GENERATED ALWAYS AS (a AND b) STORED,
|
||||
gc_or INT GENERATED ALWAYS AS (a OR b) STORED,
|
||||
gc_xor INT GENERATED ALWAYS AS (a XOR b) STORED,
|
||||
gc_not INT GENERATED ALWAYS AS (NOT a) STORED,
|
||||
gc_case INT GENERATED ALWAYS AS
|
||||
(CASE WHEN (a AND b) THEN a ELSE b END) STORED,
|
||||
INDEX(gc_and), INDEX(gc_or), INDEX(gc_xor), INDEX(gc_not),
|
||||
INDEX(gc_case));
|
||||
INSERT INTO t (a, b) VALUES (0, 0), (0, 1), (1, 0), (1, 1);
|
||||
ANALYZE TABLE t;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t analyze status OK
|
||||
EXPLAIN SELECT a, b FROM t WHERE (a AND b) = 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t ALL NULL NULL NULL NULL 4 Using where
|
||||
SELECT a, b FROM t WHERE (a AND b) = 1;
|
||||
a b
|
||||
1 1
|
||||
EXPLAIN SELECT a, b FROM t WHERE 1 = (a AND b);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t ALL NULL NULL NULL NULL 4 Using where
|
||||
SELECT a, b FROM t WHERE 1 = (a AND b);
|
||||
a b
|
||||
1 1
|
||||
EXPLAIN SELECT a, b FROM t WHERE (a AND b) IN (1, 2, 3);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t ALL NULL NULL NULL NULL 4 Using where
|
||||
SELECT a, b FROM t WHERE (a AND b) IN (1, 2, 3);
|
||||
a b
|
||||
1 1
|
||||
EXPLAIN SELECT a, b FROM t WHERE (a OR b) = 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t ALL NULL NULL NULL NULL 4 Using where
|
||||
SELECT a, b FROM t WHERE (a OR b) = 1;
|
||||
a b
|
||||
0 1
|
||||
1 0
|
||||
1 1
|
||||
EXPLAIN SELECT a, b FROM t WHERE (a OR b) BETWEEN 1 AND 10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t ALL NULL NULL NULL NULL 4 Using where
|
||||
SELECT a, b FROM t WHERE (a OR b) BETWEEN 1 AND 10;
|
||||
a b
|
||||
0 1
|
||||
1 0
|
||||
1 1
|
||||
EXPLAIN SELECT a, b FROM t WHERE (a XOR b) = 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t ALL NULL NULL NULL NULL 4 Using where
|
||||
SELECT a, b FROM t WHERE (a XOR b) = 1;
|
||||
a b
|
||||
0 1
|
||||
1 0
|
||||
EXPLAIN SELECT a FROM t WHERE (NOT a) = 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t ALL NULL NULL NULL NULL 4 Using where
|
||||
SELECT a FROM t WHERE (NOT a) = 1;
|
||||
a
|
||||
0
|
||||
0
|
||||
EXPLAIN SELECT a FROM t WHERE (CASE WHEN (a AND b) THEN a ELSE b END) = 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t ALL NULL NULL NULL NULL 4 Using where
|
||||
SELECT a FROM t WHERE (CASE WHEN (a AND b) THEN a ELSE b END) = 1;
|
||||
a
|
||||
0
|
||||
1
|
||||
EXPLAIN SELECT a, b FROM t WHERE 1 = (b AND a);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t ALL NULL NULL NULL NULL 4 Using where
|
||||
SELECT a, b FROM t WHERE 1 = (b AND a);
|
||||
a b
|
||||
1 1
|
||||
EXPLAIN SELECT a, b FROM t WHERE 1 = (b OR a);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t ALL NULL NULL NULL NULL 4 Using where
|
||||
SELECT a, b FROM t WHERE 1 = (b OR a);
|
||||
a b
|
||||
0 1
|
||||
1 0
|
||||
1 1
|
||||
DROP TABLE t;
|
||||
#
|
||||
# Bug#22810883: ASSERTION FAILED:
|
||||
# !(USED_TABS & (~READ_TABLES & ~FILTER_FOR_TABLE))
|
||||
#
|
||||
CREATE TABLE t1 (a1 INTEGER GENERATED ALWAYS AS (1 AND 0) STORED,
|
||||
a2 INTEGER, KEY (a1));
|
||||
INSERT INTO t1 VALUES ();
|
||||
CREATE TABLE t2 (b INTEGER);
|
||||
INSERT INTO t2 VALUES (1);
|
||||
ANALYZE TABLE t1, t2;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
test.t2 analyze status OK
|
||||
# Used to choose the index on a1 and get wrong results.
|
||||
EXPLAIN SELECT * FROM t1 WHERE (a2 AND a2) = 0;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 1 Using where
|
||||
SELECT * FROM t1 WHERE (a2 AND a2) = 0;
|
||||
a1 a2
|
||||
# Used to get assertion or wrong results.
|
||||
EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t2 ON b WHERE (b AND b) = 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 1
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (flat, BNL join)
|
||||
SELECT * FROM t1 STRAIGHT_JOIN t2 ON b WHERE (b AND b) = 1;
|
||||
a1 a2 b
|
||||
0 NULL 1
|
||||
DROP TABLE t1, t2;
|
||||
#
|
||||
DROP VIEW IF EXISTS v1,v2;
|
||||
DROP TABLE IF EXISTS t1,t2,t3;
|
||||
DROP PROCEDURE IF EXISTS p1;
|
||||
DROP FUNCTION IF EXISTS f1;
|
||||
DROP TRIGGER IF EXISTS trg1;
|
||||
DROP TRIGGER IF EXISTS trg2;
|
||||
set sql_warnings = 0;
|
421
mysql-test/suite/gcol/r/gcol_keys_myisam.result
Normal file
421
mysql-test/suite/gcol/r/gcol_keys_myisam.result
Normal file
|
@ -0,0 +1,421 @@
|
|||
SET @@session.default_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 generated always as (a*2) stored 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 PERSISTENT
|
||||
drop table t1;
|
||||
create table t1 (a int, b int generated always as (a*2) stored, 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 PERSISTENT
|
||||
drop table t1;
|
||||
create table t1 (a int, b int generated always as (a*2) stored);
|
||||
alter table t1 add unique key (b);
|
||||
drop table t1;
|
||||
# Testing data manipulation operations involving UNIQUE keys
|
||||
# on generated columns can be found in:
|
||||
# - gcol_ins_upd.inc
|
||||
# - gcol_select.inc
|
||||
#
|
||||
# INDEX
|
||||
create table t1 (a int, b int generated always as (a*2) stored, 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 PERSISTENT
|
||||
drop table t1;
|
||||
create table t1 (a int, b int generated always as (a*2) stored, 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 PERSISTENT
|
||||
drop table t1;
|
||||
create table t1 (a int, b int generated always as (a*2) stored);
|
||||
alter table t1 add index (b);
|
||||
drop table t1;
|
||||
create table t1 (a int, b int generated always as (a*2) stored);
|
||||
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 generated columns can be found in:
|
||||
# - gcol_select.inc
|
||||
#
|
||||
# TODO: FULLTEXT INDEX
|
||||
# SPATIAL INDEX
|
||||
# FOREIGN KEY
|
||||
# Rejected FK options.
|
||||
create table t1 (a int, b int generated always as (a+1) stored,
|
||||
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 generated always as (a+1) stored,
|
||||
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 generated always as (a+1) stored,
|
||||
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 generated always as (a+1) stored);
|
||||
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;
|
||||
# Allowed FK options.
|
||||
create table t2 (a int primary key, b char(5));
|
||||
create table t1 (a int, b int generated always as (a % 10) stored,
|
||||
foreign key (b) references t2(a) on update restrict);
|
||||
drop table t1;
|
||||
create table t1 (a int, b int generated always as (a % 10) stored,
|
||||
foreign key (b) references t2(a) on update no action);
|
||||
drop table t1;
|
||||
create table t1 (a int, b int generated always as (a % 10) stored,
|
||||
foreign key (b) references t2(a) on delete restrict);
|
||||
drop table t1;
|
||||
create table t1 (a int, b int generated always as (a % 10) stored,
|
||||
foreign key (b) references t2(a) on delete cascade);
|
||||
drop table t1;
|
||||
create table t1 (a int, b int generated always as (a % 10) stored,
|
||||
foreign key (b) references t2(a) on delete no action);
|
||||
drop table t1,t2;
|
||||
|
||||
# Testing data manipulation operations involving FOREIGN KEY
|
||||
# on generated columns can be found in:
|
||||
# - gcol_ins_upd.inc
|
||||
# - gcol_select.inc
|
||||
#
|
||||
# TODO: CHECK
|
||||
#
|
||||
# Test how optimizer picks indexes defined on a GC
|
||||
#
|
||||
CREATE TABLE t1 (f1 int, gc int AS (f1 + 1) STORED, UNIQUE(gc));
|
||||
INSERT INTO t1(f1) VALUES (1),(2),(0),(9),(3),(4),(8),(7),(5),(6);
|
||||
ANALYZE TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
# Should use index
|
||||
SELECT * FROM t1 WHERE f1 + 1 > 7;
|
||||
f1 gc
|
||||
7 8
|
||||
8 9
|
||||
9 10
|
||||
EXPLAIN SELECT * FROM t1 WHERE f1 + 1 > 7;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using where
|
||||
SELECT * FROM t1 WHERE f1 + 1 = 7;
|
||||
f1 gc
|
||||
6 7
|
||||
EXPLAIN SELECT * FROM t1 WHERE f1 + 1 = 7;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using where
|
||||
SELECT * FROM t1 WHERE f1 + 1 IN (7,5);
|
||||
f1 gc
|
||||
4 5
|
||||
6 7
|
||||
EXPLAIN SELECT * FROM t1 WHERE f1 + 1 IN(7,5);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using where
|
||||
SELECT * FROM t1 WHERE f1 + 1 BETWEEN 5 AND 7;
|
||||
f1 gc
|
||||
4 5
|
||||
5 6
|
||||
6 7
|
||||
EXPLAIN SELECT * FROM t1 WHERE f1 + 1 BETWEEN 5 AND 7;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using where
|
||||
# Check that expression isn't transformed for a disabled key
|
||||
SELECT * FROM t1 IGNORE KEY (gc) WHERE f1 + 1 BETWEEN 5 AND 7;
|
||||
f1 gc
|
||||
4 5
|
||||
5 6
|
||||
6 7
|
||||
EXPLAIN SELECT * FROM t1 IGNORE KEY (gc) WHERE f1 + 1 BETWEEN 5 AND 7;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using where
|
||||
# Check that ORDER BY could be optimized
|
||||
SELECT * FROM t1 ORDER BY f1 + 1;
|
||||
f1 gc
|
||||
0 1
|
||||
1 2
|
||||
2 3
|
||||
3 4
|
||||
4 5
|
||||
5 6
|
||||
6 7
|
||||
7 8
|
||||
8 9
|
||||
9 10
|
||||
EXPLAIN SELECT * FROM t1 ORDER BY f1 + 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using filesort
|
||||
EXPLAIN SELECT * FROM t1 IGNORE KEY (gc) ORDER BY f1 + 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using filesort
|
||||
# Check that GROUP BY could be optimized
|
||||
SELECT f1 + 1, MAX(GC) FROM t1 GROUP BY f1 + 1;
|
||||
f1 + 1 MAX(GC)
|
||||
1 1
|
||||
2 2
|
||||
3 3
|
||||
4 4
|
||||
5 5
|
||||
6 6
|
||||
7 7
|
||||
8 8
|
||||
9 9
|
||||
10 10
|
||||
EXPLAIN SELECT f1 + 1, MAX(GC) FROM t1 GROUP BY f1 + 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using temporary; Using filesort
|
||||
EXPLAIN SELECT f1 + 1, MAX(GC)
|
||||
FROM t1 IGNORE KEY (gc) GROUP BY f1 + 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using temporary; Using filesort
|
||||
# Shouldn't use index
|
||||
SELECT * FROM t1 WHERE f1 + 1 > 7.0;
|
||||
f1 gc
|
||||
7 8
|
||||
8 9
|
||||
9 10
|
||||
EXPLAIN SELECT * FROM t1 WHERE f1 + 1 > 7.0;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using where
|
||||
DROP TABLE t1;
|
||||
# Pick index with proper type
|
||||
CREATE TABLE t1 (f1 int,
|
||||
gc_int int AS (f1 + 1) STORED,
|
||||
gc_date DATE AS (f1 + 1) STORED,
|
||||
KEY gc_int_idx(gc_int),
|
||||
KEY gc_date_idx(gc_date));
|
||||
INSERT INTO t1(f1) VALUES
|
||||
(030303),(040404),
|
||||
(050505),(060606),
|
||||
(010101),(020202),
|
||||
(030303),(040404),
|
||||
(050505),(060606),
|
||||
(010101),(020202),
|
||||
(090909),(101010),
|
||||
(010101),(020202),
|
||||
(070707),(080808);
|
||||
ANALYZE TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
SELECT * FROM t1 WHERE f1 + 1 > 070707;
|
||||
f1 gc_int gc_date
|
||||
101010 101011 2010-10-11
|
||||
70707 70708 2007-07-08
|
||||
80808 80809 2008-08-09
|
||||
90909 90910 2009-09-10
|
||||
# INT column & index should be picked
|
||||
EXPLAIN SELECT * FROM t1 WHERE f1 + 1 > 070707;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 18 Using where
|
||||
SELECT * FROM t1 WHERE f1 + 1 > CAST(070707 AS DATE);
|
||||
f1 gc_int gc_date
|
||||
101010 101011 2010-10-11
|
||||
70707 70708 2007-07-08
|
||||
80808 80809 2008-08-09
|
||||
90909 90910 2009-09-10
|
||||
# DATE column & index should be picked
|
||||
EXPLAIN SELECT * FROM t1 WHERE f1 + 1 > CAST(070707 AS DATE);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 18 Using where
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# BUG#21229846: WL8170: SIGNAL 11 IN JOIN::MAKE_SUM_FUNC_LIST
|
||||
#
|
||||
CREATE TABLE t1 (
|
||||
pk int primary key auto_increment,
|
||||
col_int_key INTEGER ,
|
||||
col_int_gc_key INT GENERATED ALWAYS AS (col_int_key + 1) STORED,
|
||||
KEY col_int_gc_key(col_int_gc_key)
|
||||
);
|
||||
INSERT INTO t1 ( col_int_key) VALUES (7);
|
||||
ANALYZE TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
SELECT table1.col_int_key + 1 AS field1, table2.col_int_key AS field2
|
||||
FROM (t1 AS table1 JOIN t1 AS table2 ON (table2.pk = table1.pk))
|
||||
ORDER BY field1, field2;
|
||||
field1 field2
|
||||
8 7
|
||||
EXPLAIN SELECT table1.col_int_key + 1 AS field1, table2.col_int_key AS field2
|
||||
FROM (t1 AS table1 JOIN t1 AS table2 ON (table2.pk = table1.pk))
|
||||
ORDER BY field1, field2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE table1 system PRIMARY NULL NULL NULL 1
|
||||
1 SIMPLE table2 system PRIMARY NULL NULL NULL 1
|
||||
SELECT table1.col_int_key + 1 AS field1, table2.col_int_key AS field2
|
||||
FROM (t1 AS table1 JOIN t1 AS table2 ON (table2.pk = table1.pk))
|
||||
GROUP BY field1, field2;
|
||||
field1 field2
|
||||
8 7
|
||||
EXPLAIN SELECT table1.col_int_key + 1 AS field1, table2.col_int_key AS field2
|
||||
FROM (t1 AS table1 JOIN t1 AS table2 ON (table2.pk = table1.pk))
|
||||
GROUP BY field1, field2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE table1 system PRIMARY NULL NULL NULL 1
|
||||
1 SIMPLE table2 system PRIMARY NULL NULL NULL 1
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# Bug#21770798 OPTIMIZER DOES NOT USE INDEX FOR GENERATED EXPRESSIONS
|
||||
# WITH LOGICAL OPERATORS
|
||||
#
|
||||
CREATE TABLE t (a INT, b INT,
|
||||
gc_and INT GENERATED ALWAYS AS (a AND b) STORED,
|
||||
gc_or INT GENERATED ALWAYS AS (a OR b) STORED,
|
||||
gc_xor INT GENERATED ALWAYS AS (a XOR b) STORED,
|
||||
gc_not INT GENERATED ALWAYS AS (NOT a) STORED,
|
||||
gc_case INT GENERATED ALWAYS AS
|
||||
(CASE WHEN (a AND b) THEN a ELSE b END) STORED,
|
||||
INDEX(gc_and), INDEX(gc_or), INDEX(gc_xor), INDEX(gc_not),
|
||||
INDEX(gc_case));
|
||||
INSERT INTO t (a, b) VALUES (0, 0), (0, 1), (1, 0), (1, 1);
|
||||
ANALYZE TABLE t;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t analyze status OK
|
||||
EXPLAIN SELECT a, b FROM t WHERE (a AND b) = 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t ALL NULL NULL NULL NULL 4 Using where
|
||||
SELECT a, b FROM t WHERE (a AND b) = 1;
|
||||
a b
|
||||
1 1
|
||||
EXPLAIN SELECT a, b FROM t WHERE 1 = (a AND b);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t ALL NULL NULL NULL NULL 4 Using where
|
||||
SELECT a, b FROM t WHERE 1 = (a AND b);
|
||||
a b
|
||||
1 1
|
||||
EXPLAIN SELECT a, b FROM t WHERE (a AND b) IN (1, 2, 3);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t ALL NULL NULL NULL NULL 4 Using where
|
||||
SELECT a, b FROM t WHERE (a AND b) IN (1, 2, 3);
|
||||
a b
|
||||
1 1
|
||||
EXPLAIN SELECT a, b FROM t WHERE (a OR b) = 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t ALL NULL NULL NULL NULL 4 Using where
|
||||
SELECT a, b FROM t WHERE (a OR b) = 1;
|
||||
a b
|
||||
0 1
|
||||
1 0
|
||||
1 1
|
||||
EXPLAIN SELECT a, b FROM t WHERE (a OR b) BETWEEN 1 AND 10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t ALL NULL NULL NULL NULL 4 Using where
|
||||
SELECT a, b FROM t WHERE (a OR b) BETWEEN 1 AND 10;
|
||||
a b
|
||||
0 1
|
||||
1 0
|
||||
1 1
|
||||
EXPLAIN SELECT a, b FROM t WHERE (a XOR b) = 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t ALL NULL NULL NULL NULL 4 Using where
|
||||
SELECT a, b FROM t WHERE (a XOR b) = 1;
|
||||
a b
|
||||
0 1
|
||||
1 0
|
||||
EXPLAIN SELECT a FROM t WHERE (NOT a) = 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t ALL NULL NULL NULL NULL 4 Using where
|
||||
SELECT a FROM t WHERE (NOT a) = 1;
|
||||
a
|
||||
0
|
||||
0
|
||||
EXPLAIN SELECT a FROM t WHERE (CASE WHEN (a AND b) THEN a ELSE b END) = 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t ALL NULL NULL NULL NULL 4 Using where
|
||||
SELECT a FROM t WHERE (CASE WHEN (a AND b) THEN a ELSE b END) = 1;
|
||||
a
|
||||
0
|
||||
1
|
||||
EXPLAIN SELECT a, b FROM t WHERE 1 = (b AND a);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t ALL NULL NULL NULL NULL 4 Using where
|
||||
SELECT a, b FROM t WHERE 1 = (b AND a);
|
||||
a b
|
||||
1 1
|
||||
EXPLAIN SELECT a, b FROM t WHERE 1 = (b OR a);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t ALL NULL NULL NULL NULL 4 Using where
|
||||
SELECT a, b FROM t WHERE 1 = (b OR a);
|
||||
a b
|
||||
0 1
|
||||
1 0
|
||||
1 1
|
||||
DROP TABLE t;
|
||||
#
|
||||
# Bug#22810883: ASSERTION FAILED:
|
||||
# !(USED_TABS & (~READ_TABLES & ~FILTER_FOR_TABLE))
|
||||
#
|
||||
CREATE TABLE t1 (a1 INTEGER GENERATED ALWAYS AS (1 AND 0) STORED,
|
||||
a2 INTEGER, KEY (a1));
|
||||
INSERT INTO t1 VALUES ();
|
||||
CREATE TABLE t2 (b INTEGER);
|
||||
INSERT INTO t2 VALUES (1);
|
||||
ANALYZE TABLE t1, t2;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
test.t2 analyze status OK
|
||||
# Used to choose the index on a1 and get wrong results.
|
||||
EXPLAIN SELECT * FROM t1 WHERE (a2 AND a2) = 0;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
SELECT * FROM t1 WHERE (a2 AND a2) = 0;
|
||||
a1 a2
|
||||
# Used to get assertion or wrong results.
|
||||
EXPLAIN SELECT * FROM t1 STRAIGHT_JOIN t2 ON b WHERE (b AND b) = 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 system NULL NULL NULL NULL 1
|
||||
1 SIMPLE t2 system NULL NULL NULL NULL 1
|
||||
SELECT * FROM t1 STRAIGHT_JOIN t2 ON b WHERE (b AND b) = 1;
|
||||
a1 a2 b
|
||||
0 NULL 1
|
||||
DROP TABLE t1, t2;
|
||||
#
|
||||
DROP VIEW IF EXISTS v1,v2;
|
||||
DROP TABLE IF EXISTS t1,t2,t3;
|
||||
DROP PROCEDURE IF EXISTS p1;
|
||||
DROP FUNCTION IF EXISTS f1;
|
||||
DROP TRIGGER IF EXISTS trg1;
|
||||
DROP TRIGGER IF EXISTS trg2;
|
||||
set sql_warnings = 0;
|
14
mysql-test/suite/gcol/r/gcol_memory.result
Normal file
14
mysql-test/suite/gcol/r/gcol_memory.result
Normal file
|
@ -0,0 +1,14 @@
|
|||
SET @@session.default_storage_engine = 'memory';
|
||||
create table t1 (a int, b int generated always as (a+1) virtual);
|
||||
ERROR HY000: MEMORY storage engine does not support computed columns
|
||||
create table t1 (a int);
|
||||
alter table t1 add column b int generated always as (a+1) virtual;
|
||||
ERROR HY000: MEMORY storage engine does not support computed columns
|
||||
drop table t1;
|
||||
DROP VIEW IF EXISTS v1,v2;
|
||||
DROP TABLE IF EXISTS t1,t2,t3;
|
||||
DROP PROCEDURE IF EXISTS p1;
|
||||
DROP FUNCTION IF EXISTS f1;
|
||||
DROP TRIGGER IF EXISTS trg1;
|
||||
DROP TRIGGER IF EXISTS trg2;
|
||||
set sql_warnings = 0;
|
15
mysql-test/suite/gcol/r/gcol_merge.result
Normal file
15
mysql-test/suite/gcol/r/gcol_merge.result
Normal file
|
@ -0,0 +1,15 @@
|
|||
drop table if exists t1, t2, t3;
|
||||
create table t1 (a int, b int generated always as (a % 10) virtual);
|
||||
create table t2 (a int, b int generated always as (a % 10) virtual);
|
||||
insert into t1 values (1,default);
|
||||
insert into t2 values (2,default);
|
||||
create table t3 (a int, b int generated always as (a % 10) virtual) engine=MERGE UNION=(t1,t2);
|
||||
ERROR HY000: MRG_MyISAM storage engine does not support computed columns
|
||||
drop table t1,t2;
|
||||
DROP VIEW IF EXISTS v1,v2;
|
||||
DROP TABLE IF EXISTS t1,t2,t3;
|
||||
DROP PROCEDURE IF EXISTS p1;
|
||||
DROP FUNCTION IF EXISTS f1;
|
||||
DROP TRIGGER IF EXISTS trg1;
|
||||
DROP TRIGGER IF EXISTS trg2;
|
||||
set sql_warnings = 0;
|
14
mysql-test/suite/gcol/r/gcol_ndb.result
Normal file
14
mysql-test/suite/gcol/r/gcol_ndb.result
Normal file
|
@ -0,0 +1,14 @@
|
|||
SET @@session.default_storage_engine = 'ndbcluster';
|
||||
create table t1 (a int, b int generated always as (a+1) virtual);
|
||||
ERROR HY000: 'Specified storage engine' is not supported for generated columns.
|
||||
create table t1 (a int);
|
||||
alter table t1 add column b int generated always as (a+1) virtual;
|
||||
ERROR HY000: 'Specified storage engine' is not supported for generated columns.
|
||||
drop table t1;
|
||||
DROP VIEW IF EXISTS v1,v2;
|
||||
DROP TABLE IF EXISTS t1,t2,t3;
|
||||
DROP PROCEDURE IF EXISTS p1;
|
||||
DROP FUNCTION IF EXISTS f1;
|
||||
DROP TRIGGER IF EXISTS trg1;
|
||||
DROP TRIGGER IF EXISTS trg2;
|
||||
set sql_warnings = 0;
|
237
mysql-test/suite/gcol/r/gcol_non_stored_columns_innodb.result
Normal file
237
mysql-test/suite/gcol/r/gcol_non_stored_columns_innodb.result
Normal file
|
@ -0,0 +1,237 @@
|
|||
SET @@session.default_storage_engine = 'InnoDB';
|
||||
# Case 1. All non-stored columns.
|
||||
create table t1 (a int generated always as (2+3) virtual);
|
||||
insert into t1 values (default);
|
||||
select * from t1;
|
||||
a
|
||||
5
|
||||
insert into t1 values (default);
|
||||
select * from t1;
|
||||
a
|
||||
5
|
||||
5
|
||||
drop table t1;
|
||||
# Case 2. CREATE
|
||||
# - Column1: "real"
|
||||
# - Column 2: virtual non-stored
|
||||
create table t1 (a int, b int generated always as (-a) virtual);
|
||||
insert into t1 values (1,default);
|
||||
select * from t1;
|
||||
a b
|
||||
1 -1
|
||||
insert into t1 values (2,default);
|
||||
select * from t1 order by a;
|
||||
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 generated always as (-a) stored);
|
||||
insert into t1 values (1,default);
|
||||
select * from t1;
|
||||
a b
|
||||
1 -1
|
||||
insert into t1 values (2,default);
|
||||
select * from t1 order by a;
|
||||
a b
|
||||
1 -1
|
||||
2 -2
|
||||
drop table t1;
|
||||
# Case 4. CREATE
|
||||
# - Column1: virtual non-stored
|
||||
# - Column2: "real"
|
||||
create table t1 (a int generated always as (-b) virtual, b int);
|
||||
insert into t1 values (default,1);
|
||||
select * from t1;
|
||||
a b
|
||||
-1 1
|
||||
insert into t1 values (default,2);
|
||||
select * from t1 order by a;
|
||||
a b
|
||||
-2 2
|
||||
-1 1
|
||||
drop table t1;
|
||||
# Case 5. CREATE
|
||||
# - Column1: virtual stored
|
||||
# - Column2: "real"
|
||||
create table t1 (a int generated always as (-b) stored, b int);
|
||||
insert into t1 values (default,1);
|
||||
select * from t1;
|
||||
a b
|
||||
-1 1
|
||||
insert into t1 values (default,2);
|
||||
select * from t1 order by a;
|
||||
a b
|
||||
-2 2
|
||||
-1 1
|
||||
drop table t1;
|
||||
# Case 6. CREATE
|
||||
# - Column1: "real"
|
||||
# - Column2: virtual non-stored
|
||||
# - Column3: virtual stored
|
||||
create table t1 (a int, b int generated always as (-a), c int generated always as (-a) stored);
|
||||
insert into t1 values (1,default,default);
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
insert into t1 values (2,default,default);
|
||||
select * from t1 order by a;
|
||||
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 generated always as (a % 2) stored);
|
||||
alter table t1 modify b int generated always as (a % 2) virtual;
|
||||
ERROR HY000: This 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 generated always as (a % 2) virtual);
|
||||
alter table t1 modify b int generated always as (a % 2) stored;
|
||||
ERROR HY000: This 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 generated always as (-a), c int generated always as (-a) stored);
|
||||
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 order by a;
|
||||
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 generated always as (-b) virtual, b int, c varchar(5));
|
||||
insert into t1 values (default,1,'v1');
|
||||
insert into t1 values (default,2,'v2');
|
||||
select * from t1 order by b;
|
||||
a b c
|
||||
-1 1 v1
|
||||
-2 2 v2
|
||||
alter table t1 drop column a;
|
||||
select * from t1 order by b;
|
||||
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 generated always as (-b) stored, b int, c char(5));
|
||||
insert into t1 values (default,1,'v1');
|
||||
insert into t1 values (default,2,'v2');
|
||||
select * from t1 order by b;
|
||||
a b c
|
||||
-1 1 v1
|
||||
-2 2 v2
|
||||
alter table t1 drop column a;
|
||||
select * from t1 order by b;
|
||||
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 order by a;
|
||||
a b
|
||||
1 2008-09-04 00:00:00
|
||||
2 2008-09-05 00:00:00
|
||||
alter table t1 add column c int generated always as (dayofyear(b)) virtual after a;
|
||||
select * from t1 order by a;
|
||||
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 order by a;
|
||||
a b
|
||||
1 2008-09-04 00:00:00
|
||||
2 2008-09-05 00:00:00
|
||||
alter table t1 add column c int generated always as (dayofyear(b)) stored after a;
|
||||
select * from t1 order by a;
|
||||
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 15. ALTER. Changing the expression of a virtual non-stored column.
|
||||
create table t1 (a int, b datetime, c int generated always as (week(b)) virtual);
|
||||
insert into t1 values (1,'2008-09-04',default);
|
||||
insert into t1 values (2,'2008-09-05',default);
|
||||
select * from t1 order by a;
|
||||
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 generated always as (week(b,1)) virtual;
|
||||
select * from t1 order by a;
|
||||
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;
|
||||
DROP VIEW IF EXISTS v1,v2;
|
||||
DROP TABLE IF EXISTS t1,t2,t3;
|
||||
DROP PROCEDURE IF EXISTS p1;
|
||||
DROP FUNCTION IF EXISTS f1;
|
||||
DROP TRIGGER IF EXISTS trg1;
|
||||
DROP TRIGGER IF EXISTS trg2;
|
||||
set sql_warnings = 0;
|
237
mysql-test/suite/gcol/r/gcol_non_stored_columns_myisam.result
Normal file
237
mysql-test/suite/gcol/r/gcol_non_stored_columns_myisam.result
Normal file
|
@ -0,0 +1,237 @@
|
|||
SET @@session.default_storage_engine = 'MyISAM';
|
||||
# Case 1. All non-stored columns.
|
||||
create table t1 (a int generated always as (2+3) virtual);
|
||||
insert into t1 values (default);
|
||||
select * from t1;
|
||||
a
|
||||
5
|
||||
insert into t1 values (default);
|
||||
select * from t1;
|
||||
a
|
||||
5
|
||||
5
|
||||
drop table t1;
|
||||
# Case 2. CREATE
|
||||
# - Column1: "real"
|
||||
# - Column 2: virtual non-stored
|
||||
create table t1 (a int, b int generated always as (-a) virtual);
|
||||
insert into t1 values (1,default);
|
||||
select * from t1;
|
||||
a b
|
||||
1 -1
|
||||
insert into t1 values (2,default);
|
||||
select * from t1 order by a;
|
||||
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 generated always as (-a) stored);
|
||||
insert into t1 values (1,default);
|
||||
select * from t1;
|
||||
a b
|
||||
1 -1
|
||||
insert into t1 values (2,default);
|
||||
select * from t1 order by a;
|
||||
a b
|
||||
1 -1
|
||||
2 -2
|
||||
drop table t1;
|
||||
# Case 4. CREATE
|
||||
# - Column1: virtual non-stored
|
||||
# - Column2: "real"
|
||||
create table t1 (a int generated always as (-b) virtual, b int);
|
||||
insert into t1 values (default,1);
|
||||
select * from t1;
|
||||
a b
|
||||
-1 1
|
||||
insert into t1 values (default,2);
|
||||
select * from t1 order by a;
|
||||
a b
|
||||
-2 2
|
||||
-1 1
|
||||
drop table t1;
|
||||
# Case 5. CREATE
|
||||
# - Column1: virtual stored
|
||||
# - Column2: "real"
|
||||
create table t1 (a int generated always as (-b) stored, b int);
|
||||
insert into t1 values (default,1);
|
||||
select * from t1;
|
||||
a b
|
||||
-1 1
|
||||
insert into t1 values (default,2);
|
||||
select * from t1 order by a;
|
||||
a b
|
||||
-2 2
|
||||
-1 1
|
||||
drop table t1;
|
||||
# Case 6. CREATE
|
||||
# - Column1: "real"
|
||||
# - Column2: virtual non-stored
|
||||
# - Column3: virtual stored
|
||||
create table t1 (a int, b int generated always as (-a), c int generated always as (-a) stored);
|
||||
insert into t1 values (1,default,default);
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
insert into t1 values (2,default,default);
|
||||
select * from t1 order by a;
|
||||
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 generated always as (a % 2) stored);
|
||||
alter table t1 modify b int generated always as (a % 2) virtual;
|
||||
ERROR HY000: This 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 generated always as (a % 2) virtual);
|
||||
alter table t1 modify b int generated always as (a % 2) stored;
|
||||
ERROR HY000: This 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 generated always as (-a), c int generated always as (-a) stored);
|
||||
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 order by a;
|
||||
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 generated always as (-b) virtual, b int, c varchar(5));
|
||||
insert into t1 values (default,1,'v1');
|
||||
insert into t1 values (default,2,'v2');
|
||||
select * from t1 order by b;
|
||||
a b c
|
||||
-1 1 v1
|
||||
-2 2 v2
|
||||
alter table t1 drop column a;
|
||||
select * from t1 order by b;
|
||||
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 generated always as (-b) stored, b int, c char(5));
|
||||
insert into t1 values (default,1,'v1');
|
||||
insert into t1 values (default,2,'v2');
|
||||
select * from t1 order by b;
|
||||
a b c
|
||||
-1 1 v1
|
||||
-2 2 v2
|
||||
alter table t1 drop column a;
|
||||
select * from t1 order by b;
|
||||
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 order by a;
|
||||
a b
|
||||
1 2008-09-04 00:00:00
|
||||
2 2008-09-05 00:00:00
|
||||
alter table t1 add column c int generated always as (dayofyear(b)) virtual after a;
|
||||
select * from t1 order by a;
|
||||
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 order by a;
|
||||
a b
|
||||
1 2008-09-04 00:00:00
|
||||
2 2008-09-05 00:00:00
|
||||
alter table t1 add column c int generated always as (dayofyear(b)) stored after a;
|
||||
select * from t1 order by a;
|
||||
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 15. ALTER. Changing the expression of a virtual non-stored column.
|
||||
create table t1 (a int, b datetime, c int generated always as (week(b)) virtual);
|
||||
insert into t1 values (1,'2008-09-04',default);
|
||||
insert into t1 values (2,'2008-09-05',default);
|
||||
select * from t1 order by a;
|
||||
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 generated always as (week(b,1)) virtual;
|
||||
select * from t1 order by a;
|
||||
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;
|
||||
DROP VIEW IF EXISTS v1,v2;
|
||||
DROP TABLE IF EXISTS t1,t2,t3;
|
||||
DROP PROCEDURE IF EXISTS p1;
|
||||
DROP FUNCTION IF EXISTS f1;
|
||||
DROP TRIGGER IF EXISTS trg1;
|
||||
DROP TRIGGER IF EXISTS trg2;
|
||||
set sql_warnings = 0;
|
95
mysql-test/suite/gcol/r/gcol_partition_innodb.result
Normal file
95
mysql-test/suite/gcol/r/gcol_partition_innodb.result
Normal file
|
@ -0,0 +1,95 @@
|
|||
SET @@session.default_storage_engine = 'InnoDB';
|
||||
drop table if exists t1;
|
||||
# Case 1. Partitioning by RANGE based on a non-stored generated column.
|
||||
CREATE TABLE t1 (
|
||||
a DATE NOT NULL,
|
||||
b int generated always as (year(a)) virtual
|
||||
)
|
||||
PARTITION BY RANGE( b ) (
|
||||
PARTITION p0 VALUES LESS THAN (2006),
|
||||
PARTITION p2 VALUES LESS THAN (2008)
|
||||
);
|
||||
insert into t1 values ('2006-01-01',default);
|
||||
insert into t1 values ('2007-01-01',default);
|
||||
insert into t1 values ('2005-01-01',default);
|
||||
select * from t1;
|
||||
a b
|
||||
2005-01-01 2005
|
||||
2006-01-01 2006
|
||||
2007-01-01 2007
|
||||
# Modify the expression of generated column b
|
||||
ALTER TABLE t1 modify b int generated always as (year(a)-1) virtual;
|
||||
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 generated column.
|
||||
CREATE TABLE t1 (a int, b int generated always as (a % 3 ) stored)
|
||||
PARTITION BY LIST (a+1)
|
||||
(PARTITION p1 VALUES IN (1), PARTITION p2 VALUES IN (2));
|
||||
insert into t1 values (1,default);
|
||||
select * from t1;
|
||||
a b
|
||||
1 1
|
||||
select * from t1;
|
||||
a b
|
||||
1 1
|
||||
drop table t1;
|
||||
# Case 3. Partitioning by HASH based on a non-stored generated column.
|
||||
CREATE TABLE t1 (
|
||||
a DATE NOT NULL,
|
||||
b int generated always as (year(a)) virtual
|
||||
)
|
||||
PARTITION BY HASH( b % 3 ) PARTITIONS 3;
|
||||
insert into t1 values ('2005-01-01',default);
|
||||
insert into t1 values ('2006-01-01',default);
|
||||
select * from t1;
|
||||
a b
|
||||
2005-01-01 2005
|
||||
2006-01-01 2006
|
||||
# Modify the expression of generated column b
|
||||
ALTER TABLE t1 modify b int generated always as (year(a)-1) virtual;
|
||||
select * from t1;
|
||||
a b
|
||||
2005-01-01 2004
|
||||
2006-01-01 2005
|
||||
drop table t1;
|
||||
#
|
||||
# Bug#21779011 INVALID READS AND SENDING RANDOM SERVER MEMORY BACK
|
||||
# TO CLIENT
|
||||
#
|
||||
CREATE TABLE t (
|
||||
c INTEGER GENERATED ALWAYS AS (2) VIRTUAL,
|
||||
d INTEGER,
|
||||
KEY (d)
|
||||
) PARTITION BY KEY (d) PARTITIONS 2;
|
||||
INSERT INTO t (d) VALUES (1),(1),(2),(2);
|
||||
SELECT c FROM t WHERE d >= 1 GROUP BY d LIMIT 2;
|
||||
c
|
||||
2
|
||||
2
|
||||
DROP TABLE t;
|
||||
#
|
||||
# Bug#21779554: CHECK_MISPLACED_ROWS BOGUS "FOUND A MISPLACED ROW"
|
||||
# AND CRASHES
|
||||
#
|
||||
CREATE TABLE t(a INT,b INT GENERATED ALWAYS AS (1) VIRTUAL,c INT)
|
||||
PARTITION BY KEY (b)PARTITIONS 6;
|
||||
INSERT INTO t VALUES();
|
||||
CHECK TABLE t EXTENDED;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t check status OK
|
||||
FLUSH TABLES;
|
||||
CHECK TABLE t EXTENDED;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t check status OK
|
||||
DROP TABLE t;
|
||||
DROP VIEW IF EXISTS v1,v2;
|
||||
DROP TABLE IF EXISTS t1,t2,t3;
|
||||
DROP PROCEDURE IF EXISTS p1;
|
||||
DROP FUNCTION IF EXISTS f1;
|
||||
DROP TRIGGER IF EXISTS trg1;
|
||||
DROP TRIGGER IF EXISTS trg2;
|
||||
set sql_warnings = 0;
|
95
mysql-test/suite/gcol/r/gcol_partition_myisam.result
Normal file
95
mysql-test/suite/gcol/r/gcol_partition_myisam.result
Normal file
|
@ -0,0 +1,95 @@
|
|||
SET @@session.default_storage_engine = 'MyISAM';
|
||||
drop table if exists t1;
|
||||
# Case 1. Partitioning by RANGE based on a non-stored generated column.
|
||||
CREATE TABLE t1 (
|
||||
a DATE NOT NULL,
|
||||
b int generated always as (year(a)) virtual
|
||||
)
|
||||
PARTITION BY RANGE( b ) (
|
||||
PARTITION p0 VALUES LESS THAN (2006),
|
||||
PARTITION p2 VALUES LESS THAN (2008)
|
||||
);
|
||||
insert into t1 values ('2006-01-01',default);
|
||||
insert into t1 values ('2007-01-01',default);
|
||||
insert into t1 values ('2005-01-01',default);
|
||||
select * from t1;
|
||||
a b
|
||||
2005-01-01 2005
|
||||
2006-01-01 2006
|
||||
2007-01-01 2007
|
||||
# Modify the expression of generated column b
|
||||
ALTER TABLE t1 modify b int generated always as (year(a)-1) virtual;
|
||||
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 generated column.
|
||||
CREATE TABLE t1 (a int, b int generated always as (a % 3 ) stored)
|
||||
PARTITION BY LIST (a+1)
|
||||
(PARTITION p1 VALUES IN (1), PARTITION p2 VALUES IN (2));
|
||||
insert into t1 values (1,default);
|
||||
select * from t1;
|
||||
a b
|
||||
1 1
|
||||
select * from t1;
|
||||
a b
|
||||
1 1
|
||||
drop table t1;
|
||||
# Case 3. Partitioning by HASH based on a non-stored generated column.
|
||||
CREATE TABLE t1 (
|
||||
a DATE NOT NULL,
|
||||
b int generated always as (year(a)) virtual
|
||||
)
|
||||
PARTITION BY HASH( b % 3 ) PARTITIONS 3;
|
||||
insert into t1 values ('2005-01-01',default);
|
||||
insert into t1 values ('2006-01-01',default);
|
||||
select * from t1;
|
||||
a b
|
||||
2005-01-01 2005
|
||||
2006-01-01 2006
|
||||
# Modify the expression of generated column b
|
||||
ALTER TABLE t1 modify b int generated always as (year(a)-1) virtual;
|
||||
select * from t1;
|
||||
a b
|
||||
2005-01-01 2004
|
||||
2006-01-01 2005
|
||||
drop table t1;
|
||||
#
|
||||
# Bug#21779011 INVALID READS AND SENDING RANDOM SERVER MEMORY BACK
|
||||
# TO CLIENT
|
||||
#
|
||||
CREATE TABLE t (
|
||||
c INTEGER GENERATED ALWAYS AS (2) VIRTUAL,
|
||||
d INTEGER,
|
||||
KEY (d)
|
||||
) PARTITION BY KEY (d) PARTITIONS 2;
|
||||
INSERT INTO t (d) VALUES (1),(1),(2),(2);
|
||||
SELECT c FROM t WHERE d >= 1 GROUP BY d LIMIT 2;
|
||||
c
|
||||
2
|
||||
2
|
||||
DROP TABLE t;
|
||||
#
|
||||
# Bug#21779554: CHECK_MISPLACED_ROWS BOGUS "FOUND A MISPLACED ROW"
|
||||
# AND CRASHES
|
||||
#
|
||||
CREATE TABLE t(a INT,b INT GENERATED ALWAYS AS (1) VIRTUAL,c INT)
|
||||
PARTITION BY KEY (b)PARTITIONS 6;
|
||||
INSERT INTO t VALUES();
|
||||
CHECK TABLE t EXTENDED;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t check status OK
|
||||
FLUSH TABLES;
|
||||
CHECK TABLE t EXTENDED;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t check status OK
|
||||
DROP TABLE t;
|
||||
DROP VIEW IF EXISTS v1,v2;
|
||||
DROP TABLE IF EXISTS t1,t2,t3;
|
||||
DROP PROCEDURE IF EXISTS p1;
|
||||
DROP FUNCTION IF EXISTS f1;
|
||||
DROP TRIGGER IF EXISTS trg1;
|
||||
DROP TRIGGER IF EXISTS trg2;
|
||||
set sql_warnings = 0;
|
8
mysql-test/suite/gcol/r/gcol_rejected_innodb.result
Normal file
8
mysql-test/suite/gcol/r/gcol_rejected_innodb.result
Normal file
|
@ -0,0 +1,8 @@
|
|||
SET @@session.default_storage_engine = 'InnoDB';
|
||||
DROP VIEW IF EXISTS v1,v2;
|
||||
DROP TABLE IF EXISTS t1,t2,t3;
|
||||
DROP PROCEDURE IF EXISTS p1;
|
||||
DROP FUNCTION IF EXISTS f1;
|
||||
DROP TRIGGER IF EXISTS trg1;
|
||||
DROP TRIGGER IF EXISTS trg2;
|
||||
set sql_warnings = 0;
|
75
mysql-test/suite/gcol/r/gcol_rollback.result
Normal file
75
mysql-test/suite/gcol/r/gcol_rollback.result
Normal file
|
@ -0,0 +1,75 @@
|
|||
CREATE TABLE t (
|
||||
a INTEGER,
|
||||
b BLOB GENERATED ALWAYS AS (a) VIRTUAL,
|
||||
INDEX (b(57))
|
||||
)ENGINE=INNODB;
|
||||
INSERT INTO t (a) VALUES (9);
|
||||
BEGIN;
|
||||
SAVEPOINT a;
|
||||
UPDATE t set a = 12;
|
||||
DELETE FROM t where a = 12;
|
||||
ROLLBACK TO SAVEPOINT a;
|
||||
COMMIT;
|
||||
CHECK TABLE t;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t check status OK
|
||||
SELECT * FROM t;
|
||||
a b
|
||||
9 9
|
||||
BEGIN;
|
||||
INSERT INTO t (a) VALUES (10);
|
||||
# Kill and restart
|
||||
SELECT * FROM t;
|
||||
a b
|
||||
9 9
|
||||
DROP TABLE t;
|
||||
CREATE TABLE t (
|
||||
a INTEGER,
|
||||
b BLOB GENERATED ALWAYS AS (a) VIRTUAL,
|
||||
c INTEGER
|
||||
)ENGINE=INNODB;
|
||||
INSERT INTO t (a,c) VALUES (9, 10);
|
||||
SELECT * FROM t;
|
||||
a b c
|
||||
9 9 10
|
||||
SET DEBUG_SYNC = 'row_log_apply_after SIGNAL created WAIT_FOR dml_done';
|
||||
ALTER TABLE t ADD KEY(b(57)), ALGORITHM=INPLACE;
|
||||
SET DEBUG_SYNC = 'now WAIT_FOR created';
|
||||
BEGIN;
|
||||
INSERT INTO t (a,c) VALUES (10, 12);
|
||||
SELECT * FROM t;
|
||||
a b c
|
||||
9 9 10
|
||||
10 10 12
|
||||
ROLLBACK;
|
||||
SET DEBUG_SYNC = 'now SIGNAL dml_done';
|
||||
SELECT * FROM t;
|
||||
a b c
|
||||
9 9 10
|
||||
DROP TABLE t;
|
||||
CREATE TABLE t (
|
||||
a INT,
|
||||
b INT,
|
||||
c INT GENERATED ALWAYS AS(a+b),
|
||||
d INT GENERATED ALWAYS AS(a+b+b),
|
||||
KEY(c, d)
|
||||
)ENGINE=INNODB;
|
||||
INSERT INTO t (a,b) VALUES (9, 10);
|
||||
SELECT * FROM t;
|
||||
a b c d
|
||||
9 10 19 29
|
||||
SET DEBUG_SYNC = 'row_log_apply_after SIGNAL created WAIT_FOR dml_done';
|
||||
ALTER TABLE t DROP COLUMN c, ALGORITHM=INPLACE;
|
||||
SET DEBUG_SYNC = 'now WAIT_FOR created';
|
||||
BEGIN;
|
||||
INSERT INTO t (a,b) VALUES (10, 12);
|
||||
SELECT * FROM t;
|
||||
a b c d
|
||||
9 10 19 29
|
||||
10 12 22 34
|
||||
ROLLBACK;
|
||||
SET DEBUG_SYNC = 'now SIGNAL dml_done';
|
||||
SELECT * FROM t;
|
||||
a b d
|
||||
9 10 29
|
||||
DROP TABLE t;
|
976
mysql-test/suite/gcol/r/gcol_select_innodb.result
Normal file
976
mysql-test/suite/gcol/r/gcol_select_innodb.result
Normal file
|
@ -0,0 +1,976 @@
|
|||
DROP VIEW IF EXISTS v1,v2;
|
||||
DROP TABLE IF EXISTS t1,t2,t3;
|
||||
DROP PROCEDURE IF EXISTS p1;
|
||||
DROP FUNCTION IF EXISTS f1;
|
||||
DROP TRIGGER IF EXISTS trg1;
|
||||
DROP TRIGGER IF EXISTS trg2;
|
||||
set sql_warnings = 0;
|
||||
SET @@session.default_storage_engine = 'InnoDB';
|
||||
SET optimizer_switch='derived_merge=off';
|
||||
create table t1 (a int,
|
||||
b int generated always as (-a) virtual,
|
||||
c int generated always as (-a) stored,
|
||||
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 generated always as (-a) virtual,
|
||||
c int generated always as (-a) stored unique);
|
||||
insert into t3 (a) values (2),(1),(3);
|
||||
analyze table t1,t2,t3;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
test.t2 analyze status OK
|
||||
test.t3 analyze status OK
|
||||
# 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
|
||||
# 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 index condition
|
||||
# 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
|
||||
# select_type=PRIMARY, type=index,ALL
|
||||
select * from t1 where b in (select c from t3);
|
||||
a b c
|
||||
1 -1 -1
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
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 t3 index c c 5 NULL 3 Using index
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join)
|
||||
# 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
|
||||
1 -1 -1
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
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 t3 index c c 5 NULL 3 Using where; Using index
|
||||
1 PRIMARY t1 ALL c NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join)
|
||||
# select_type=UNION, type=system
|
||||
# select_type=UNION RESULT, type=<union1,2>
|
||||
select * from t1 union select * from t2;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
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
|
||||
1 -1 -1
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
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-gcol>) 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 gcol>) 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 gcol>) 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 range NULL c 5 NULL 6 Using index for group-by (scanning)
|
||||
###
|
||||
### filesort & range-based utils
|
||||
###
|
||||
# SELECT * FROM tbl_name WHERE <gcol expr>
|
||||
select * from t3 where c >= -2;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
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 index condition
|
||||
# SELECT * FROM tbl_name WHERE <non-gcol 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 2 Using where
|
||||
# SELECT * FROM tbl_name WHERE <non-indexed gcol 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 gcol expr>
|
||||
select * from t3 where c between -2 and -1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
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 2 Using index condition
|
||||
# SELECT * FROM tbl_name WHERE <non-gcol expr> ORDER BY <non-indexed gcol>
|
||||
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 2 Using where; Using filesort
|
||||
# bug#20022189: WL411:DEBUG ASSERT AT FIELD_LONG::VAL_INT IN SQL/FIELD.CC
|
||||
# SELECT * FROM tbl_name WHERE <non-gcol expr> ORDER BY <non-indexed stored gcol>
|
||||
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 2 Using where; Using filesort
|
||||
# bug#20022189: WL411:DEBUG ASSERT AT FIELD_LONG::VAL_INT IN SQL/FIELD.CC
|
||||
CREATE TABLE t4 (
|
||||
`pk` int(11) NOT NULL ,
|
||||
`col_int_nokey` int(11) GENERATED ALWAYS AS (pk + col_int_key) STORED,
|
||||
`col_int_key` int(11) DEFAULT NULL,
|
||||
`col_date_nokey` date DEFAULT NULL,
|
||||
`col_datetime_key` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`pk`),
|
||||
KEY `col_int_key` (`col_int_key`),
|
||||
KEY `col_datetime_key` (`col_datetime_key`)
|
||||
);
|
||||
INSERT INTO t4 VALUES
|
||||
(1,default,4,'2008-12-05','1900-01-01 00:00:00');
|
||||
SELECT
|
||||
SQL_BIG_RESULT
|
||||
GRANDPARENT1 . `col_int_nokey` AS g1
|
||||
FROM t4 AS GRANDPARENT1 LEFT JOIN t4 AS GRANDPARENT2 ON ( GRANDPARENT2 .
|
||||
`col_datetime_key` <= GRANDPARENT1 . `col_date_nokey` )
|
||||
GROUP BY GRANDPARENT1 . `pk`;
|
||||
g1
|
||||
5
|
||||
DROP TABLE t4;
|
||||
# SELECT * FROM tbl_name WHERE <non-gcol expr> ORDER BY <indexed gcol>
|
||||
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 2 Using where; Using filesort
|
||||
# SELECT * FROM tbl_name WHERE <non-indexed gcol expr> ORDER BY <non-gcol>
|
||||
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 gcol expr> ORDER BY <non-indexed gcol>
|
||||
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 gcol expr> ORDER BY <non-indexed gcol>
|
||||
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 2 Using index condition; Using filesort
|
||||
# SELECT * FROM tbl_name WHERE <non-indexed gcol expr> ORDER BY <indexed gcol>
|
||||
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 gcol expr> ORDER BY <indexed gcol>
|
||||
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 2 Using index condition
|
||||
# SELECT sum(<non-indexed gcol>) FROM tbl_name GROUP BY <non-indexed gcol>
|
||||
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 gcol>) FROM tbl_name GROUP BY <indexed gcol>
|
||||
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 gcol>) FROM tbl_name GROUP BY <indexed gcol>
|
||||
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 gcol>) FROM tbl_name GROUP BY <non-indexed gcol>
|
||||
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
|
||||
drop table t1;
|
||||
#
|
||||
# Bug#20241655: WL411:FAILING ASSERTION ASSERTION
|
||||
#
|
||||
CREATE TABLE BB (
|
||||
col_time_key time NOT NULL,
|
||||
col_time_nokey time GENERATED ALWAYS AS (ADDTIME(col_datetime_key, col_time_key)) VIRTUAL,
|
||||
col_datetime_key datetime NOT NULL);
|
||||
INSERT INTO BB VALUES('23:28:02', default, '2005-03-15 22:48:25');
|
||||
Warnings:
|
||||
Note 1265 Data truncated for column 'col_time_nokey' at row 1
|
||||
CREATE TABLE CC (
|
||||
col_time_key time NOT NULL,
|
||||
col_time_nokey time GENERATED ALWAYS AS (ADDTIME(col_datetime_key, col_time_key)) VIRTUAL,
|
||||
col_datetime_key datetime NOT NULL
|
||||
);
|
||||
INSERT INTO CC VALUES('16:22:51', default, '1900-01-01 00:00:00');
|
||||
Warnings:
|
||||
Note 1265 Data truncated for column 'col_time_nokey' at row 1
|
||||
SELECT 1 AS g1 FROM BB AS gp1 LEFT JOIN BB AS gp2 USING ( col_time_nokey);
|
||||
g1
|
||||
1
|
||||
DROP TABLE BB, CC;
|
||||
#
|
||||
# Bug#20328786: WL411:VALGRIND WARNINGS OF CONDITIONAL
|
||||
# JUMP WHILE SELECTING FROM VIEW
|
||||
#
|
||||
CREATE TABLE A (
|
||||
pk INTEGER AUTO_INCREMENT,
|
||||
col_int_nokey INTEGER,
|
||||
col_int_key INTEGER GENERATED ALWAYS AS (2 + 2 + col_int_nokey) STORED,
|
||||
PRIMARY KEY (pk)
|
||||
);
|
||||
CREATE TABLE C (
|
||||
pk INTEGER AUTO_INCREMENT,
|
||||
col_int_nokey INTEGER,
|
||||
col_int_key INTEGER GENERATED ALWAYS AS (2 + 2 + col_int_nokey) STORED,
|
||||
col_varchar_nokey VARCHAR(1),
|
||||
col_varchar_key VARCHAR(2) GENERATED ALWAYS AS
|
||||
(CONCAT(col_varchar_nokey, col_varchar_nokey)) STORED,
|
||||
PRIMARY KEY (pk),
|
||||
KEY (col_int_key),
|
||||
KEY (col_varchar_key, col_int_key)
|
||||
);
|
||||
INSERT INTO C (
|
||||
col_int_nokey,
|
||||
col_varchar_nokey
|
||||
) VALUES (4, 'v'),(62, 'v'),(7, 'c'),(1, NULL),(0, 'x'),(7, 'i'),(7, 'e'),(1, 'p'),(7, 's'),(1, 'j'),(5, 'z'),(2, 'c'),(0, 'a'),(1, 'q'),(8, 'y'),(1, NULL),(1, 'r'),(9, 'v'),(1, NULL),(5, 'r');
|
||||
CREATE OR REPLACE ALGORITHM=MERGE VIEW V1 AS SELECT alias1.
|
||||
col_varchar_key AS field1 , alias1.pk AS field2, alias2.
|
||||
col_int_nokey AS field3 FROM C AS alias1 LEFT JOIN A AS alias2 ON
|
||||
alias1.pk = alias2.col_int_key WHERE alias1.pk > 8 AND alias1
|
||||
.pk < ( 9 + 2 ) AND alias1.col_int_key <> 1 OR alias1.col_int_key
|
||||
> 0 AND alias1.col_int_key <= ( 3 + 2 ) ORDER BY field1, field2, field3
|
||||
LIMIT 100 OFFSET 6;
|
||||
Warnings:
|
||||
Warning 1354 View merge algorithm can't be used here for now (assumed undefined algorithm)
|
||||
SELECT * FROM V1;
|
||||
field1 field2 field3
|
||||
qq 14 NULL
|
||||
rr 17 NULL
|
||||
ss 9 NULL
|
||||
xx 5 NULL
|
||||
DROP VIEW V1;
|
||||
DROP TABLE A,C;
|
||||
#
|
||||
# Bug#20406510: WL411:VALGRIND WARNINGS WITH
|
||||
# COUNT DISTINCT QUERY ON VIRTUAL GC VARCHAR COLUMN
|
||||
#
|
||||
CREATE TABLE A (
|
||||
pk INTEGER AUTO_INCREMENT,
|
||||
col_time_key TIME NOT NULL,
|
||||
col_datetime_key DATETIME NOT NULL,
|
||||
PRIMARY KEY (pk),
|
||||
KEY (col_time_key),
|
||||
KEY (col_datetime_key)
|
||||
);
|
||||
CREATE TABLE C (
|
||||
pk INTEGER AUTO_INCREMENT,
|
||||
col_int_key INTEGER NOT NULL,
|
||||
col_varchar_key VARCHAR(1) NOT NULL,
|
||||
col_varchar_nokey VARCHAR(2) GENERATED ALWAYS AS
|
||||
(CONCAT(col_varchar_key, col_varchar_key)),
|
||||
PRIMARY KEY (pk),
|
||||
KEY (col_int_key),
|
||||
KEY (col_varchar_key, col_int_key)
|
||||
);
|
||||
INSERT INTO C (col_int_key,col_varchar_key) VALUES (0, 'j'),(8, 'v'),(1, 'c'),(8, 'm'),(9, 'd');
|
||||
SELECT MIN( alias2 . col_int_key ) AS field1,
|
||||
COUNT( DISTINCT alias2 . col_varchar_nokey ) AS field2
|
||||
FROM ( A AS alias1 , C AS alias2 )
|
||||
ORDER BY alias1.col_time_key, alias1.col_datetime_key, alias1.pk ASC;
|
||||
field1 field2
|
||||
NULL 0
|
||||
DROP TABLE A,C;
|
||||
#
|
||||
# Bug#20566325: WL8149: INNODB: FAILING ASSERTION:
|
||||
# COL_NR < TABLE->N_DEF
|
||||
#
|
||||
CREATE TABLE A (
|
||||
pk INTEGER AUTO_INCREMENT,
|
||||
col_varchar_nokey VARCHAR(1) NOT NULL,
|
||||
col_varchar_key VARCHAR(2) GENERATED ALWAYS AS
|
||||
(CONCAT(col_varchar_nokey, col_varchar_nokey)),
|
||||
PRIMARY KEY (pk)
|
||||
);
|
||||
INSERT /*! IGNORE */ INTO A (col_varchar_nokey) VALUES ('k');
|
||||
CREATE TABLE CC (
|
||||
pk INTEGER AUTO_INCREMENT,
|
||||
col_datetime_nokey DATETIME /*! NULL */,
|
||||
col_time_nokey TIME /*! NULL */,
|
||||
col_time_key TIME GENERATED ALWAYS AS
|
||||
(ADDTIME(col_datetime_nokey, col_time_nokey)),
|
||||
col_varchar_nokey VARCHAR(1) /*! NULL */,
|
||||
col_varchar_key VARCHAR(2) GENERATED ALWAYS AS
|
||||
(CONCAT(col_varchar_nokey, col_varchar_nokey)),
|
||||
PRIMARY KEY (pk));
|
||||
INSERT INTO CC (col_time_nokey,col_datetime_nokey,col_varchar_nokey) VALUES
|
||||
('13:06:13.033877','1900-01-01 00:00:00', 'p'),
|
||||
(NULL, '2007-05-25 11:58:54.015689', 'g');
|
||||
SELECT
|
||||
table1.col_time_key AS field1,
|
||||
'z' AS field2
|
||||
FROM
|
||||
(CC AS table1 LEFT OUTER JOIN (A AS table2 STRAIGHT_JOIN CC AS table3 ON
|
||||
(table3.col_varchar_key = table2.col_varchar_nokey)) ON
|
||||
(table3.col_varchar_key = table2.col_varchar_nokey))
|
||||
WHERE
|
||||
table2.pk != 6
|
||||
AND table1.col_varchar_key IN ('l', 's' , 'b' )
|
||||
AND table3.col_varchar_key != table1.col_varchar_key
|
||||
ORDER BY table1.col_varchar_key , field1 , field2;
|
||||
field1 field2
|
||||
DROP TABLE A,CC;
|
||||
CREATE TABLE cc (
|
||||
pk int(11) NOT NULL AUTO_INCREMENT,
|
||||
col_int_nokey int(11) NOT NULL,
|
||||
col_int_key int(11) GENERATED ALWAYS AS (col_int_nokey) STORED,
|
||||
col_date_nokey date NOT NULL,
|
||||
col_date_key date GENERATED ALWAYS AS (col_date_nokey) STORED,
|
||||
col_datetime_nokey datetime NOT NULL,
|
||||
col_time_nokey time NOT NULL,
|
||||
col_datetime_key datetime GENERATED ALWAYS AS (col_datetime_nokey)STORED,
|
||||
col_time_key time GENERATED ALWAYS AS (col_time_nokey) STORED,
|
||||
col_varchar_nokey varchar(1) NOT NULL,
|
||||
col_varchar_key varchar(1) GENERATED ALWAYS AS (col_varchar_nokey)STORED,
|
||||
PRIMARY KEY (pk),
|
||||
KEY gc_idx1 (col_int_key),
|
||||
KEY gc_idx2 (col_varchar_key),
|
||||
KEY gc_idx3 (col_date_key),
|
||||
KEY gc_idx4 (col_time_key),
|
||||
KEY gc_idx5 (col_datetime_key),
|
||||
KEY gc_idx6 (col_varchar_key,col_int_key),
|
||||
KEY gc_idx7 (col_date_key,col_datetime_key,col_time_key),
|
||||
KEY gc_idx8(col_int_key,col_varchar_key,col_date_key,col_time_key,
|
||||
col_datetime_key)
|
||||
);
|
||||
INSERT INTO cc (
|
||||
col_int_nokey,
|
||||
col_date_nokey,
|
||||
col_time_nokey,
|
||||
col_datetime_nokey,
|
||||
col_varchar_nokey
|
||||
) VALUES (1, '2009-12-01', '00:21:38.058143', '2007-05-28 00:00:00', 'c'),
|
||||
(8, '2004-12-17', '04:08:02.046897', '2009-07-25 09:21:20.064099', 'm'),
|
||||
(9, '2000-03-14', '16:25:11.040240', '2002-01-16 00:00:00', 'd'),
|
||||
(24, '2000-10-08', '10:14:58.018534', '2006-10-12 04:32:53.031976', 'd'),
|
||||
(6, '2006-05-25', '19:47:59.011283', '2001-02-15 03:08:38.035426', 'y'),
|
||||
(1, '2008-01-23', '11:14:24.032949', '2004-10-02 20:31:15.022553', 't');
|
||||
SET @save_old_sql_mode= @@sql_mode;
|
||||
SET sql_mode="";
|
||||
SELECT DISTINCT alias1.col_varchar_key AS field1
|
||||
FROM ( cc AS alias1 STRAIGHT_JOIN
|
||||
(( cc AS alias2 STRAIGHT_JOIN cc AS alias3 ON
|
||||
(alias3.col_varchar_key > alias2.col_varchar_key ) ) ) ON
|
||||
(( alias3 .pk >= alias2.col_int_nokey ) AND
|
||||
(alias3 .pk >= alias2.col_int_nokey ) ))
|
||||
WHERE alias1.col_varchar_key <= 'v'
|
||||
GROUP BY field1 HAVING field1 = 91
|
||||
ORDER BY field1, alias1.col_date_key, field1 ASC, field1 DESC,
|
||||
alias1.col_time_key ASC, field1;
|
||||
field1
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'c'
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 't'
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'm'
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'd'
|
||||
DROP TABLE cc;
|
||||
SET sql_mode=@save_old_sql_mode;
|
||||
#
|
||||
# Bug#20797941: WL8149:ASSERTION !TABLE ||
|
||||
# (!TABLE->READ_SET || BITMAP_IS_SET(TABLE->READ_SET
|
||||
#
|
||||
CREATE TABLE t(a int, b int as(a+1));
|
||||
INSERT INTO t(a) values(1),(2);
|
||||
SELECT * FROM t ORDER BY b;
|
||||
a b
|
||||
1 2
|
||||
2 3
|
||||
DROP TABLE t;
|
||||
DROP TABLE t2, t3;
|
||||
#
|
||||
# Bug#21317507:GC: STORED COLUMN REJECTED, BUT VIRTUAL IS ACCEPTED
|
||||
#
|
||||
CREATE TABLE t1(a INT);
|
||||
INSERT INTO t1 VALUES(2147483647);
|
||||
ALTER TABLE t1 ADD COLUMN b SMALLINT AS (a) VIRTUAL;
|
||||
ALTER TABLE t1 DROP COLUMN b;
|
||||
ALTER TABLE t1 ADD COLUMN c SMALLINT AS (a) VIRTUAL;
|
||||
ALTER TABLE t1 DROP COLUMN c;
|
||||
ALTER TABLE t1 ADD COLUMN d SMALLINT AS (a) VIRTUAL;
|
||||
ALTER TABLE t1 DROP COLUMN d;
|
||||
ALTER TABLE t1 ADD COLUMN c INT AS(a) VIRTUAL;
|
||||
ALTER TABLE t1 CHANGE c c SMALLINT AS(a) VIRTUAL;
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'c' at row 1
|
||||
ALTER TABLE t1 MODIFY c TINYINT AS(a) VIRTUAL;
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'c' at row 1
|
||||
SELECT * FROM t1;
|
||||
a c
|
||||
2147483647 127
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1(a INT);
|
||||
INSERT INTO t1 VALUES(2147483647);
|
||||
ALTER TABLE t1 ADD COLUMN h INT AS (a) VIRTUAL;
|
||||
ALTER TABLE t1 CHANGE h i INT AS (a) VIRTUAL, ALGORITHM=COPY;
|
||||
ALTER TABLE t1 ADD COLUMN b SMALLINT AS (a) VIRTUAL, ALGORITHM=COPY, LOCK=NONE;
|
||||
ERROR 0A000: LOCK=NONE is not supported. Reason: COPY algorithm requires a lock. Try LOCK=SHARED
|
||||
ALTER TABLE t1 ADD COLUMN e SMALLINT AS (a) VIRTUAL, ALGORITHM=COPY, LOCK=NONE;
|
||||
ERROR 0A000: LOCK=NONE is not supported. Reason: COPY algorithm requires a lock. Try LOCK=SHARED
|
||||
ALTER TABLE t1 ADD COLUMN f SMALLINT AS (a) VIRTUAL, ALGORITHM=COPY, LOCK=SHARED;
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'f' at row 1
|
||||
ALTER TABLE t1 ADD COLUMN g SMALLINT AS (a) VIRTUAL, ALGORITHM=COPY, LOCK=EXCLUSIVE;
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'f' at row 1
|
||||
Warning 1264 Out of range value for column 'g' at row 1
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# Bug#21980430 GCOLS: CRASHING
|
||||
#
|
||||
CREATE TABLE t (
|
||||
a INT,
|
||||
b BLOB,
|
||||
c BLOB GENERATED ALWAYS AS (a+b) VIRTUAL,
|
||||
UNIQUE KEY i0008 (a)
|
||||
);
|
||||
INSERT INTO t(a,b) VALUES(1,'cccc');
|
||||
EXPLAIN SELECT /*+ bka() */ 1 AS c FROM t AS b RIGHT JOIN t AS c ON b.a > c.c
|
||||
WHERE b.b>c.a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE b ALL i0008 NULL NULL NULL 1
|
||||
1 SIMPLE c ALL i0008 NULL NULL NULL 1 Range checked for each record (index map: 0x1)
|
||||
SELECT /*+ bka() */ 1 AS c FROM t AS b RIGHT JOIN t AS c ON b.a > c.c
|
||||
WHERE b.b>c.a;
|
||||
c
|
||||
DROP TABLE t;
|
||||
set @optimizer_switch_save = @@optimizer_switch;
|
||||
set optimizer_switch='mrr_cost_based=off';
|
||||
set @read_rnd_buffer_size_save= @@read_rnd_buffer_size;
|
||||
set read_rnd_buffer_size=32;
|
||||
CREATE TABLE t0 (
|
||||
i1 INTEGER NOT NULL
|
||||
);
|
||||
INSERT INTO t0 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
||||
CREATE TABLE t1 (
|
||||
pk INTEGER NOT NULL,
|
||||
i1 INTEGER NOT NULL,
|
||||
i2 INTEGER NOT NULL,
|
||||
v1 INTEGER GENERATED ALWAYS AS (i2 + 1) VIRTUAL,
|
||||
v2 INTEGER GENERATED ALWAYS AS (i1 / (i1 - i2 + 57)) VIRTUAL,
|
||||
PRIMARY KEY (pk),
|
||||
INDEX idx(i1)
|
||||
);
|
||||
INSERT INTO t1 (pk, i1, i2)
|
||||
SELECT a0.i1 + a1.i1*10 + a2.i1*100,
|
||||
a0.i1 + a1.i1*10,
|
||||
a0.i1 + a1.i1*10
|
||||
FROM t0 AS a0, t0 AS a1, t0 AS a2;
|
||||
EXPLAIN SELECT * FROM t1
|
||||
WHERE i1 > 41 AND i1 <= 43;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range idx idx 4 NULL 20 Using index condition
|
||||
SELECT * FROM t1
|
||||
WHERE i1 > 41 AND i1 <= 43;
|
||||
pk i1 i2 v1 v2
|
||||
142 42 42 43 1
|
||||
143 43 43 44 1
|
||||
242 42 42 43 1
|
||||
243 43 43 44 1
|
||||
342 42 42 43 1
|
||||
343 43 43 44 1
|
||||
42 42 42 43 1
|
||||
43 43 43 44 1
|
||||
442 42 42 43 1
|
||||
443 43 43 44 1
|
||||
542 42 42 43 1
|
||||
543 43 43 44 1
|
||||
642 42 42 43 1
|
||||
643 43 43 44 1
|
||||
742 42 42 43 1
|
||||
743 43 43 44 1
|
||||
842 42 42 43 1
|
||||
843 43 43 44 1
|
||||
942 42 42 43 1
|
||||
943 43 43 44 1
|
||||
EXPLAIN SELECT * FROM t1
|
||||
WHERE v1 > 41 AND v1 <= 43;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL # Using where
|
||||
SELECT * FROM t1
|
||||
WHERE v1 > 41 AND v1 <= 43;
|
||||
pk i1 i2 v1 v2
|
||||
141 41 41 42 1
|
||||
142 42 42 43 1
|
||||
241 41 41 42 1
|
||||
242 42 42 43 1
|
||||
341 41 41 42 1
|
||||
342 42 42 43 1
|
||||
41 41 41 42 1
|
||||
42 42 42 43 1
|
||||
441 41 41 42 1
|
||||
442 42 42 43 1
|
||||
541 41 41 42 1
|
||||
542 42 42 43 1
|
||||
641 41 41 42 1
|
||||
642 42 42 43 1
|
||||
741 41 41 42 1
|
||||
742 42 42 43 1
|
||||
841 41 41 42 1
|
||||
842 42 42 43 1
|
||||
941 41 41 42 1
|
||||
942 42 42 43 1
|
||||
DROP TABLE t0, t1;
|
||||
set optimizer_switch= @optimizer_switch_save;
|
||||
set @@read_rnd_buffer_size= @read_rnd_buffer_size_save;
|
||||
#
|
||||
# Bug#21872184 CONDITIONAL JUMP AT JOIN_CACHE::WRITE_RECORD_DATA IN
|
||||
# SQL_JOIN_BUFFER.CC
|
||||
#
|
||||
#
|
||||
# Test 1: Dynamic range scan with one covering index
|
||||
#
|
||||
CREATE TABLE t1 (
|
||||
i1 INTEGER NOT NULL,
|
||||
c1 VARCHAR(1) NOT NULL
|
||||
);
|
||||
INSERT INTO t1
|
||||
VALUES (10, 'c'), (10, 'i'), (2, 't'), (4, 'g');
|
||||
CREATE TABLE t2 (
|
||||
i1 INTEGER NOT NULL,
|
||||
c1 VARCHAR(1) NOT NULL
|
||||
);
|
||||
INSERT INTO t2
|
||||
VALUES (2, 'k'), (9, 'k'), (7, 'o'), (5, 'n'), (7, 'e');
|
||||
CREATE TABLE t3 (
|
||||
pk INTEGER NOT NULL,
|
||||
i1 INTEGER,
|
||||
i2_key INTEGER GENERATED ALWAYS AS (i1 + i1) VIRTUAL,
|
||||
PRIMARY KEY (pk)
|
||||
);
|
||||
INSERT INTO t3 (pk, i1)
|
||||
VALUES (1, 1), (2, 48), (3, 228), (4, 3), (5, 5),
|
||||
(6, 39), (7, 6), (8, 8), (9, 3);
|
||||
CREATE TABLE t4 (
|
||||
i1 INTEGER NOT NULL,
|
||||
c1 VARCHAR(1) NOT NULL
|
||||
);
|
||||
INSERT INTO t4
|
||||
VALUES (1, 'j'), (2, 'c'), (0, 'a');
|
||||
ANALYZE TABLE t1, t2, t3, t4;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
test.t2 analyze status OK
|
||||
test.t3 analyze status OK
|
||||
test.t4 analyze status OK
|
||||
EXPLAIN SELECT /*+ NO_SEMIJOIN(@subq1) */ t1.c1, t2.i1
|
||||
FROM t1 STRAIGHT_JOIN t3 STRAIGHT_JOIN t2
|
||||
WHERE ( t3.pk IN
|
||||
(
|
||||
SELECT /*+ QB_NAME(subq1) */ t4.i1
|
||||
FROM t4
|
||||
WHERE t4.c1 < 'o'
|
||||
)
|
||||
)
|
||||
AND t1.i1 <= t3.i2_key;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t3 eq_ref PRIMARY PRIMARY 4 test.t4.i1 1 Using where
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED t4 ALL NULL NULL NULL NULL 3 Using where
|
||||
SELECT /*+ NO_SEMIJOIN(@subq1) */ t1.c1, t2.i1
|
||||
FROM t1 STRAIGHT_JOIN t3 STRAIGHT_JOIN t2
|
||||
WHERE ( t3.pk IN
|
||||
(
|
||||
SELECT /*+ QB_NAME(subq1) */ t4.i1
|
||||
FROM t4
|
||||
WHERE t4.c1 < 'o'
|
||||
)
|
||||
)
|
||||
AND t1.i1 <= t3.i2_key;
|
||||
c1 i1
|
||||
c 2
|
||||
c 5
|
||||
c 7
|
||||
c 7
|
||||
c 9
|
||||
g 2
|
||||
g 5
|
||||
g 7
|
||||
g 7
|
||||
g 9
|
||||
i 2
|
||||
i 5
|
||||
i 7
|
||||
i 7
|
||||
i 9
|
||||
t 2
|
||||
t 2
|
||||
t 5
|
||||
t 5
|
||||
t 7
|
||||
t 7
|
||||
t 7
|
||||
t 7
|
||||
t 9
|
||||
t 9
|
||||
#
|
||||
# Test 2: Two alternative covering indexes for the range scan
|
||||
#
|
||||
EXPLAIN SELECT /*+ NO_SEMIJOIN(@subq1) */ t1.c1, t2.i1
|
||||
FROM t1 STRAIGHT_JOIN t3 STRAIGHT_JOIN t2
|
||||
WHERE ( t3.pk IN
|
||||
(
|
||||
SELECT /*+ QB_NAME(subq1) */ t4.i1
|
||||
FROM t4
|
||||
WHERE t4.c1 < 'o'
|
||||
)
|
||||
)
|
||||
AND t1.i1 <= t3.i2_key;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t3 eq_ref PRIMARY PRIMARY 4 test.t4.i1 1 Using where
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED t4 ALL NULL NULL NULL NULL 3 Using where
|
||||
SELECT /*+ NO_SEMIJOIN(@subq1) */ t1.c1, t2.i1
|
||||
FROM t1 STRAIGHT_JOIN t3 STRAIGHT_JOIN t2
|
||||
WHERE ( t3.pk IN
|
||||
(
|
||||
SELECT /*+ QB_NAME(subq1) */ t4.i1
|
||||
FROM t4
|
||||
WHERE t4.c1 < 'o'
|
||||
)
|
||||
)
|
||||
AND t1.i1 <= t3.i2_key;
|
||||
c1 i1
|
||||
c 2
|
||||
c 5
|
||||
c 7
|
||||
c 7
|
||||
c 9
|
||||
g 2
|
||||
g 5
|
||||
g 7
|
||||
g 7
|
||||
g 9
|
||||
i 2
|
||||
i 5
|
||||
i 7
|
||||
i 7
|
||||
i 9
|
||||
t 2
|
||||
t 2
|
||||
t 5
|
||||
t 5
|
||||
t 7
|
||||
t 7
|
||||
t 7
|
||||
t 7
|
||||
t 9
|
||||
t 9
|
||||
#
|
||||
# Test 3: One covering index including the base column for the virtual
|
||||
# column
|
||||
#
|
||||
EXPLAIN SELECT /*+ NO_SEMIJOIN(@subq1) */ t1.c1, t2.i1
|
||||
FROM t1 STRAIGHT_JOIN t3 STRAIGHT_JOIN t2
|
||||
WHERE ( t3.pk IN
|
||||
(
|
||||
SELECT /*+ QB_NAME(subq1) */ t4.i1
|
||||
FROM t4
|
||||
WHERE t4.c1 < 'o'
|
||||
)
|
||||
)
|
||||
AND t1.i1 <= t3.i2_key;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t3 eq_ref PRIMARY PRIMARY 4 test.t4.i1 1 Using where
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED t4 ALL NULL NULL NULL NULL 3 Using where
|
||||
SELECT /*+ NO_SEMIJOIN(@subq1) */ t1.c1, t2.i1
|
||||
FROM t1 STRAIGHT_JOIN t3 STRAIGHT_JOIN t2
|
||||
WHERE ( t3.pk IN
|
||||
(
|
||||
SELECT /*+ QB_NAME(subq1) */ t4.i1
|
||||
FROM t4
|
||||
WHERE t4.c1 < 'o'
|
||||
)
|
||||
)
|
||||
AND t1.i1 <= t3.i2_key;
|
||||
c1 i1
|
||||
c 2
|
||||
c 5
|
||||
c 7
|
||||
c 7
|
||||
c 9
|
||||
g 2
|
||||
g 5
|
||||
g 7
|
||||
g 7
|
||||
g 9
|
||||
i 2
|
||||
i 5
|
||||
i 7
|
||||
i 7
|
||||
i 9
|
||||
t 2
|
||||
t 2
|
||||
t 5
|
||||
t 5
|
||||
t 7
|
||||
t 7
|
||||
t 7
|
||||
t 7
|
||||
t 9
|
||||
t 9
|
||||
#
|
||||
# Test 4: One non-covering index
|
||||
#
|
||||
# Add more data to the table so that it will run the dynamic range scan
|
||||
# as both table scan and range scan (the purpose of this is to make the
|
||||
# table scan more expensive).
|
||||
INSERT INTO t3 (pk, i1)
|
||||
VALUES (10,1), (11,1), (12,1), (13,1), (14,1),(15,1), (16,1),(17,1), (18,1),
|
||||
(19,1), (20,1), (21,1), (22,1), (23,1), (24,1),(25,1),(26,1),(27,1),
|
||||
(28,1), (29,1);
|
||||
# Change the query to read an extra column (t3.i1) making the index
|
||||
# non-covering.
|
||||
EXPLAIN SELECT /*+ NO_SEMIJOIN(@subq1) */ t1.c1, t2.i1, t3.i1
|
||||
FROM t1 STRAIGHT_JOIN t3 STRAIGHT_JOIN t2
|
||||
WHERE ( t3.pk IN
|
||||
(
|
||||
SELECT /*+ QB_NAME(subq1) */ t4.i1
|
||||
FROM t4
|
||||
WHERE t4.c1 < 'o'
|
||||
)
|
||||
)
|
||||
AND t1.i1 <= t3.i2_key;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t3 eq_ref PRIMARY PRIMARY 4 test.t4.i1 1 Using where
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED t4 ALL NULL NULL NULL NULL 3 Using where
|
||||
SELECT /*+ NO_SEMIJOIN(@subq1) */ t1.c1, t2.i1, t3.i1
|
||||
FROM t1 STRAIGHT_JOIN t3 STRAIGHT_JOIN t2
|
||||
WHERE ( t3.pk IN
|
||||
(
|
||||
SELECT /*+ QB_NAME(subq1) */ t4.i1
|
||||
FROM t4
|
||||
WHERE t4.c1 < 'o'
|
||||
)
|
||||
)
|
||||
AND t1.i1 <= t3.i2_key;
|
||||
c1 i1 i1
|
||||
c 2 48
|
||||
c 5 48
|
||||
c 7 48
|
||||
c 7 48
|
||||
c 9 48
|
||||
g 2 48
|
||||
g 5 48
|
||||
g 7 48
|
||||
g 7 48
|
||||
g 9 48
|
||||
i 2 48
|
||||
i 5 48
|
||||
i 7 48
|
||||
i 7 48
|
||||
i 9 48
|
||||
t 2 1
|
||||
t 2 48
|
||||
t 5 1
|
||||
t 5 48
|
||||
t 7 1
|
||||
t 7 1
|
||||
t 7 48
|
||||
t 7 48
|
||||
t 9 1
|
||||
t 9 48
|
||||
#
|
||||
# Test 5: Test where the added primary key to secondary indexes is
|
||||
# used after it has been included in the join buffer
|
||||
#
|
||||
EXPLAIN SELECT /*+ NO_SEMIJOIN(@subq1) */ t1.c1, t2.i1
|
||||
FROM t1 STRAIGHT_JOIN t3 STRAIGHT_JOIN t2
|
||||
WHERE ( t3.pk IN
|
||||
(
|
||||
SELECT /*+ QB_NAME(subq1) */ t4.i1
|
||||
FROM t4
|
||||
WHERE t4.c1 < 'o' and t4.i1 < (t2.i1 + 1)
|
||||
)
|
||||
)
|
||||
AND t1.i1 <= t3.i2_key;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t4 ALL NULL NULL NULL NULL 3 Using where; Start temporary
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t3 eq_ref PRIMARY PRIMARY 4 test.t4.i1 1 Using where
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using where; End temporary; Using join buffer (flat, BNL join)
|
||||
SELECT /*+ NO_SEMIJOIN(@subq1) */ t1.c1, t2.i1
|
||||
FROM t1 STRAIGHT_JOIN t3 STRAIGHT_JOIN t2
|
||||
WHERE ( t3.pk IN
|
||||
(
|
||||
SELECT /*+ QB_NAME(subq1) */ t4.i1
|
||||
FROM t4
|
||||
WHERE t4.c1 < 'o' and t4.i1 < (t2.i1 + 1)
|
||||
)
|
||||
)
|
||||
AND t1.i1 <= t3.i2_key;
|
||||
c1 i1
|
||||
c 2
|
||||
c 5
|
||||
c 7
|
||||
c 7
|
||||
c 9
|
||||
g 2
|
||||
g 5
|
||||
g 7
|
||||
g 7
|
||||
g 9
|
||||
i 2
|
||||
i 5
|
||||
i 7
|
||||
i 7
|
||||
i 9
|
||||
t 2
|
||||
t 2
|
||||
t 5
|
||||
t 5
|
||||
t 7
|
||||
t 7
|
||||
t 7
|
||||
t 7
|
||||
t 9
|
||||
t 9
|
||||
DROP TABLE t1, t2, t3, t4;
|
||||
SET optimizer_switch='derived_merge=default';
|
||||
DROP VIEW IF EXISTS v1,v2;
|
||||
DROP TABLE IF EXISTS t1,t2,t3;
|
||||
DROP PROCEDURE IF EXISTS p1;
|
||||
DROP FUNCTION IF EXISTS f1;
|
||||
DROP TRIGGER IF EXISTS trg1;
|
||||
DROP TRIGGER IF EXISTS trg2;
|
||||
set sql_warnings = 0;
|
978
mysql-test/suite/gcol/r/gcol_select_myisam.result
Normal file
978
mysql-test/suite/gcol/r/gcol_select_myisam.result
Normal file
|
@ -0,0 +1,978 @@
|
|||
DROP VIEW IF EXISTS v1,v2;
|
||||
DROP TABLE IF EXISTS t1,t2,t3;
|
||||
DROP PROCEDURE IF EXISTS p1;
|
||||
DROP FUNCTION IF EXISTS f1;
|
||||
DROP TRIGGER IF EXISTS trg1;
|
||||
DROP TRIGGER IF EXISTS trg2;
|
||||
set sql_warnings = 0;
|
||||
SET @@session.default_storage_engine = 'MyISAM';
|
||||
SET optimizer_switch='derived_merge=off';
|
||||
create table t1 (a int,
|
||||
b int generated always as (-a) virtual,
|
||||
c int generated always as (-a) stored,
|
||||
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 generated always as (-a) virtual,
|
||||
c int generated always as (-a) stored unique);
|
||||
insert into t3 (a) values (2),(1),(3);
|
||||
analyze table t1,t2,t3;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
test.t2 analyze status OK
|
||||
test.t3 analyze status OK
|
||||
# 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 index condition
|
||||
# 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
|
||||
# select_type=PRIMARY, type=index,ALL
|
||||
select * from t1 where b in (select c from t3);
|
||||
a b c
|
||||
1 -1 -1
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
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 t3 index c c 5 NULL 3 Using index
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join)
|
||||
# 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
|
||||
1 -1 -1
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
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 t3 index c c 5 NULL 3 Using where; Using index
|
||||
1 PRIMARY t1 ref c c 5 test.t3.c 1
|
||||
# select_type=UNION, type=system
|
||||
# select_type=UNION RESULT, type=<union1,2>
|
||||
select * from t1 union select * from t2;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
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
|
||||
1 -1 -1
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
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-gcol>) 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 gcol>) 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 gcol>) 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 range NULL c 5 NULL 6 Using index for group-by (scanning)
|
||||
###
|
||||
### filesort & range-based utils
|
||||
###
|
||||
# SELECT * FROM tbl_name WHERE <gcol expr>
|
||||
select * from t3 where c >= -2;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
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 index condition
|
||||
# SELECT * FROM tbl_name WHERE <non-gcol 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 index condition
|
||||
# SELECT * FROM tbl_name WHERE <non-indexed gcol 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 gcol expr>
|
||||
select * from t3 where c between -2 and -1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
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 index condition
|
||||
# bug#20022189: WL411:DEBUG ASSERT AT FIELD_LONG::VAL_INT IN SQL/FIELD.CC
|
||||
CREATE TABLE t4 (
|
||||
`pk` int(11) NOT NULL ,
|
||||
`col_int_nokey` int(11) GENERATED ALWAYS AS (pk + col_int_key) STORED,
|
||||
`col_int_key` int(11) DEFAULT NULL,
|
||||
`col_date_nokey` date DEFAULT NULL,
|
||||
`col_datetime_key` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`pk`),
|
||||
KEY `col_int_key` (`col_int_key`),
|
||||
KEY `col_datetime_key` (`col_datetime_key`)
|
||||
);
|
||||
INSERT INTO t4 VALUES
|
||||
(1,default,4,'2008-12-05','1900-01-01 00:00:00');
|
||||
SELECT
|
||||
SQL_BIG_RESULT
|
||||
GRANDPARENT1 . `col_int_nokey` AS g1
|
||||
FROM t4 AS GRANDPARENT1 LEFT JOIN t4 AS GRANDPARENT2 ON ( GRANDPARENT2 .
|
||||
`col_datetime_key` <= GRANDPARENT1 . `col_date_nokey` )
|
||||
GROUP BY GRANDPARENT1 . `pk`;
|
||||
g1
|
||||
5
|
||||
DROP TABLE t4;
|
||||
# SELECT * FROM tbl_name WHERE <non-gcol expr> ORDER BY <indexed gcol>
|
||||
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 index condition; Using filesort
|
||||
# SELECT * FROM tbl_name WHERE <non-indexed gcol expr> ORDER BY <non-gcol>
|
||||
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 gcol expr> ORDER BY <non-gcol>
|
||||
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 index condition; Using filesort
|
||||
# SELECT * FROM tbl_name WHERE <non-indexed gcol expr> ORDER BY <non-indexed gcol>
|
||||
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 gcol expr> ORDER BY <non-indexed gcol>
|
||||
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 index condition; Using filesort
|
||||
# SELECT * FROM tbl_name WHERE <non-indexed gcol expr> ORDER BY <indexed gcol>
|
||||
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 gcol expr> ORDER BY <indexed gcol>
|
||||
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 index condition
|
||||
# SELECT sum(<non-indexed gcol>) FROM tbl_name GROUP BY <non-indexed gcol>
|
||||
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 gcol>) FROM tbl_name GROUP BY <indexed gcol>
|
||||
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 gcol>) FROM tbl_name GROUP BY <indexed gcol>
|
||||
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 gcol>) FROM tbl_name GROUP BY <non-indexed gcol>
|
||||
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
|
||||
drop table t1;
|
||||
#
|
||||
# Bug#20241655: WL411:FAILING ASSERTION ASSERTION
|
||||
#
|
||||
CREATE TABLE BB (
|
||||
col_time_key time NOT NULL,
|
||||
col_time_nokey time GENERATED ALWAYS AS (ADDTIME(col_datetime_key, col_time_key)) VIRTUAL,
|
||||
col_datetime_key datetime NOT NULL);
|
||||
INSERT INTO BB VALUES('23:28:02', default, '2005-03-15 22:48:25');
|
||||
Warnings:
|
||||
Note 1265 Data truncated for column 'col_time_nokey' at row 1
|
||||
CREATE TABLE CC (
|
||||
col_time_key time NOT NULL,
|
||||
col_time_nokey time GENERATED ALWAYS AS (ADDTIME(col_datetime_key, col_time_key)) VIRTUAL,
|
||||
col_datetime_key datetime NOT NULL
|
||||
);
|
||||
INSERT INTO CC VALUES('16:22:51', default, '1900-01-01 00:00:00');
|
||||
Warnings:
|
||||
Note 1265 Data truncated for column 'col_time_nokey' at row 1
|
||||
SELECT 1 AS g1 FROM BB AS gp1 LEFT JOIN BB AS gp2 USING ( col_time_nokey);
|
||||
g1
|
||||
1
|
||||
DROP TABLE BB, CC;
|
||||
#
|
||||
# Bug#20328786: WL411:VALGRIND WARNINGS OF CONDITIONAL
|
||||
# JUMP WHILE SELECTING FROM VIEW
|
||||
#
|
||||
CREATE TABLE A (
|
||||
pk INTEGER AUTO_INCREMENT,
|
||||
col_int_nokey INTEGER,
|
||||
col_int_key INTEGER GENERATED ALWAYS AS (2 + 2 + col_int_nokey) STORED,
|
||||
PRIMARY KEY (pk)
|
||||
);
|
||||
CREATE TABLE C (
|
||||
pk INTEGER AUTO_INCREMENT,
|
||||
col_int_nokey INTEGER,
|
||||
col_int_key INTEGER GENERATED ALWAYS AS (2 + 2 + col_int_nokey) STORED,
|
||||
col_varchar_nokey VARCHAR(1),
|
||||
col_varchar_key VARCHAR(2) GENERATED ALWAYS AS
|
||||
(CONCAT(col_varchar_nokey, col_varchar_nokey)) STORED,
|
||||
PRIMARY KEY (pk),
|
||||
KEY (col_int_key),
|
||||
KEY (col_varchar_key, col_int_key)
|
||||
);
|
||||
INSERT INTO C (
|
||||
col_int_nokey,
|
||||
col_varchar_nokey
|
||||
) VALUES (4, 'v'),(62, 'v'),(7, 'c'),(1, NULL),(0, 'x'),(7, 'i'),(7, 'e'),(1, 'p'),(7, 's'),(1, 'j'),(5, 'z'),(2, 'c'),(0, 'a'),(1, 'q'),(8, 'y'),(1, NULL),(1, 'r'),(9, 'v'),(1, NULL),(5, 'r');
|
||||
CREATE OR REPLACE ALGORITHM=MERGE VIEW V1 AS SELECT alias1.
|
||||
col_varchar_key AS field1 , alias1.pk AS field2, alias2.
|
||||
col_int_nokey AS field3 FROM C AS alias1 LEFT JOIN A AS alias2 ON
|
||||
alias1.pk = alias2.col_int_key WHERE alias1.pk > 8 AND alias1
|
||||
.pk < ( 9 + 2 ) AND alias1.col_int_key <> 1 OR alias1.col_int_key
|
||||
> 0 AND alias1.col_int_key <= ( 3 + 2 ) ORDER BY field1, field2, field3
|
||||
LIMIT 100 OFFSET 6;
|
||||
Warnings:
|
||||
Warning 1354 View merge algorithm can't be used here for now (assumed undefined algorithm)
|
||||
SELECT * FROM V1;
|
||||
field1 field2 field3
|
||||
qq 14 NULL
|
||||
rr 17 NULL
|
||||
ss 9 NULL
|
||||
xx 5 NULL
|
||||
DROP VIEW V1;
|
||||
DROP TABLE A,C;
|
||||
#
|
||||
# Bug#20406510: WL411:VALGRIND WARNINGS WITH
|
||||
# COUNT DISTINCT QUERY ON VIRTUAL GC VARCHAR COLUMN
|
||||
#
|
||||
CREATE TABLE A (
|
||||
pk INTEGER AUTO_INCREMENT,
|
||||
col_time_key TIME NOT NULL,
|
||||
col_datetime_key DATETIME NOT NULL,
|
||||
PRIMARY KEY (pk),
|
||||
KEY (col_time_key),
|
||||
KEY (col_datetime_key)
|
||||
);
|
||||
CREATE TABLE C (
|
||||
pk INTEGER AUTO_INCREMENT,
|
||||
col_int_key INTEGER NOT NULL,
|
||||
col_varchar_key VARCHAR(1) NOT NULL,
|
||||
col_varchar_nokey VARCHAR(2) GENERATED ALWAYS AS
|
||||
(CONCAT(col_varchar_key, col_varchar_key)),
|
||||
PRIMARY KEY (pk),
|
||||
KEY (col_int_key),
|
||||
KEY (col_varchar_key, col_int_key)
|
||||
);
|
||||
INSERT INTO C (col_int_key,col_varchar_key) VALUES (0, 'j'),(8, 'v'),(1, 'c'),(8, 'm'),(9, 'd');
|
||||
SELECT MIN( alias2 . col_int_key ) AS field1,
|
||||
COUNT( DISTINCT alias2 . col_varchar_nokey ) AS field2
|
||||
FROM ( A AS alias1 , C AS alias2 )
|
||||
ORDER BY alias1.col_time_key, alias1.col_datetime_key, alias1.pk ASC;
|
||||
field1 field2
|
||||
NULL 0
|
||||
DROP TABLE A,C;
|
||||
#
|
||||
# Bug#20566325: WL8149: INNODB: FAILING ASSERTION:
|
||||
# COL_NR < TABLE->N_DEF
|
||||
#
|
||||
CREATE TABLE A (
|
||||
pk INTEGER AUTO_INCREMENT,
|
||||
col_varchar_nokey VARCHAR(1) NOT NULL,
|
||||
col_varchar_key VARCHAR(2) GENERATED ALWAYS AS
|
||||
(CONCAT(col_varchar_nokey, col_varchar_nokey)),
|
||||
PRIMARY KEY (pk)
|
||||
);
|
||||
INSERT /*! IGNORE */ INTO A (col_varchar_nokey) VALUES ('k');
|
||||
CREATE TABLE CC (
|
||||
pk INTEGER AUTO_INCREMENT,
|
||||
col_datetime_nokey DATETIME /*! NULL */,
|
||||
col_time_nokey TIME /*! NULL */,
|
||||
col_time_key TIME GENERATED ALWAYS AS
|
||||
(ADDTIME(col_datetime_nokey, col_time_nokey)),
|
||||
col_varchar_nokey VARCHAR(1) /*! NULL */,
|
||||
col_varchar_key VARCHAR(2) GENERATED ALWAYS AS
|
||||
(CONCAT(col_varchar_nokey, col_varchar_nokey)),
|
||||
PRIMARY KEY (pk));
|
||||
INSERT INTO CC (col_time_nokey,col_datetime_nokey,col_varchar_nokey) VALUES
|
||||
('13:06:13.033877','1900-01-01 00:00:00', 'p'),
|
||||
(NULL, '2007-05-25 11:58:54.015689', 'g');
|
||||
SELECT
|
||||
table1.col_time_key AS field1,
|
||||
'z' AS field2
|
||||
FROM
|
||||
(CC AS table1 LEFT OUTER JOIN (A AS table2 STRAIGHT_JOIN CC AS table3 ON
|
||||
(table3.col_varchar_key = table2.col_varchar_nokey)) ON
|
||||
(table3.col_varchar_key = table2.col_varchar_nokey))
|
||||
WHERE
|
||||
table2.pk != 6
|
||||
AND table1.col_varchar_key IN ('l', 's' , 'b' )
|
||||
AND table3.col_varchar_key != table1.col_varchar_key
|
||||
ORDER BY table1.col_varchar_key , field1 , field2;
|
||||
field1 field2
|
||||
DROP TABLE A,CC;
|
||||
CREATE TABLE cc (
|
||||
pk int(11) NOT NULL AUTO_INCREMENT,
|
||||
col_int_nokey int(11) NOT NULL,
|
||||
col_int_key int(11) GENERATED ALWAYS AS (col_int_nokey) STORED,
|
||||
col_date_nokey date NOT NULL,
|
||||
col_date_key date GENERATED ALWAYS AS (col_date_nokey) STORED,
|
||||
col_datetime_nokey datetime NOT NULL,
|
||||
col_time_nokey time NOT NULL,
|
||||
col_datetime_key datetime GENERATED ALWAYS AS (col_datetime_nokey)STORED,
|
||||
col_time_key time GENERATED ALWAYS AS (col_time_nokey) STORED,
|
||||
col_varchar_nokey varchar(1) NOT NULL,
|
||||
col_varchar_key varchar(1) GENERATED ALWAYS AS (col_varchar_nokey)STORED,
|
||||
PRIMARY KEY (pk),
|
||||
KEY gc_idx1 (col_int_key),
|
||||
KEY gc_idx2 (col_varchar_key),
|
||||
KEY gc_idx3 (col_date_key),
|
||||
KEY gc_idx4 (col_time_key),
|
||||
KEY gc_idx5 (col_datetime_key),
|
||||
KEY gc_idx6 (col_varchar_key,col_int_key),
|
||||
KEY gc_idx7 (col_date_key,col_datetime_key,col_time_key),
|
||||
KEY gc_idx8(col_int_key,col_varchar_key,col_date_key,col_time_key,
|
||||
col_datetime_key)
|
||||
);
|
||||
INSERT INTO cc (
|
||||
col_int_nokey,
|
||||
col_date_nokey,
|
||||
col_time_nokey,
|
||||
col_datetime_nokey,
|
||||
col_varchar_nokey
|
||||
) VALUES (1, '2009-12-01', '00:21:38.058143', '2007-05-28 00:00:00', 'c'),
|
||||
(8, '2004-12-17', '04:08:02.046897', '2009-07-25 09:21:20.064099', 'm'),
|
||||
(9, '2000-03-14', '16:25:11.040240', '2002-01-16 00:00:00', 'd'),
|
||||
(24, '2000-10-08', '10:14:58.018534', '2006-10-12 04:32:53.031976', 'd'),
|
||||
(6, '2006-05-25', '19:47:59.011283', '2001-02-15 03:08:38.035426', 'y'),
|
||||
(1, '2008-01-23', '11:14:24.032949', '2004-10-02 20:31:15.022553', 't');
|
||||
SET @save_old_sql_mode= @@sql_mode;
|
||||
SET sql_mode="";
|
||||
SELECT DISTINCT alias1.col_varchar_key AS field1
|
||||
FROM ( cc AS alias1 STRAIGHT_JOIN
|
||||
(( cc AS alias2 STRAIGHT_JOIN cc AS alias3 ON
|
||||
(alias3.col_varchar_key > alias2.col_varchar_key ) ) ) ON
|
||||
(( alias3 .pk >= alias2.col_int_nokey ) AND
|
||||
(alias3 .pk >= alias2.col_int_nokey ) ))
|
||||
WHERE alias1.col_varchar_key <= 'v'
|
||||
GROUP BY field1 HAVING field1 = 91
|
||||
ORDER BY field1, alias1.col_date_key, field1 ASC, field1 DESC,
|
||||
alias1.col_time_key ASC, field1;
|
||||
field1
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'c'
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 't'
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'm'
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'd'
|
||||
DROP TABLE cc;
|
||||
SET sql_mode=@save_old_sql_mode;
|
||||
#
|
||||
# Bug#20797941: WL8149:ASSERTION !TABLE ||
|
||||
# (!TABLE->READ_SET || BITMAP_IS_SET(TABLE->READ_SET
|
||||
#
|
||||
CREATE TABLE t(a int, b int as(a+1));
|
||||
INSERT INTO t(a) values(1),(2);
|
||||
SELECT * FROM t ORDER BY b;
|
||||
a b
|
||||
1 2
|
||||
2 3
|
||||
DROP TABLE t;
|
||||
DROP TABLE t2, t3;
|
||||
#
|
||||
# Bug#21317507:GC: STORED COLUMN REJECTED, BUT VIRTUAL IS ACCEPTED
|
||||
#
|
||||
CREATE TABLE t1(a INT);
|
||||
INSERT INTO t1 VALUES(2147483647);
|
||||
ALTER TABLE t1 ADD COLUMN b SMALLINT AS (a) VIRTUAL;
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'b' at row 1
|
||||
ALTER TABLE t1 DROP COLUMN b;
|
||||
ALTER TABLE t1 ADD COLUMN c SMALLINT AS (a) VIRTUAL;
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'c' at row 1
|
||||
ALTER TABLE t1 DROP COLUMN c;
|
||||
ALTER TABLE t1 ADD COLUMN d SMALLINT AS (a) VIRTUAL;
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'd' at row 1
|
||||
ALTER TABLE t1 DROP COLUMN d;
|
||||
ALTER TABLE t1 ADD COLUMN c INT AS(a) VIRTUAL;
|
||||
ALTER TABLE t1 CHANGE c c SMALLINT AS(a) VIRTUAL;
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'c' at row 1
|
||||
ALTER TABLE t1 MODIFY c TINYINT AS(a) VIRTUAL;
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'c' at row 1
|
||||
SELECT * FROM t1;
|
||||
a c
|
||||
2147483647 127
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1(a INT);
|
||||
INSERT INTO t1 VALUES(2147483647);
|
||||
ALTER TABLE t1 ADD COLUMN h INT AS (a) VIRTUAL;
|
||||
ALTER TABLE t1 CHANGE h i INT AS (a) VIRTUAL, ALGORITHM=COPY;
|
||||
ALTER TABLE t1 ADD COLUMN b SMALLINT AS (a) VIRTUAL, ALGORITHM=COPY, LOCK=NONE;
|
||||
ERROR 0A000: LOCK=NONE is not supported. Reason: COPY algorithm requires a lock. Try LOCK=SHARED
|
||||
ALTER TABLE t1 ADD COLUMN e SMALLINT AS (a) VIRTUAL, ALGORITHM=COPY, LOCK=NONE;
|
||||
ERROR 0A000: LOCK=NONE is not supported. Reason: COPY algorithm requires a lock. Try LOCK=SHARED
|
||||
ALTER TABLE t1 ADD COLUMN f SMALLINT AS (a) VIRTUAL, ALGORITHM=COPY, LOCK=SHARED;
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'f' at row 1
|
||||
ALTER TABLE t1 ADD COLUMN g SMALLINT AS (a) VIRTUAL, ALGORITHM=COPY, LOCK=EXCLUSIVE;
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'f' at row 1
|
||||
Warning 1264 Out of range value for column 'g' at row 1
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# Bug#21980430 GCOLS: CRASHING
|
||||
#
|
||||
CREATE TABLE t (
|
||||
a INT,
|
||||
b BLOB,
|
||||
c BLOB GENERATED ALWAYS AS (a+b) VIRTUAL,
|
||||
UNIQUE KEY i0008 (a)
|
||||
);
|
||||
INSERT INTO t(a,b) VALUES(1,'cccc');
|
||||
EXPLAIN SELECT /*+ bka() */ 1 AS c FROM t AS b RIGHT JOIN t AS c ON b.a > c.c
|
||||
WHERE b.b>c.a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'cccc'
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'cccc'
|
||||
SELECT /*+ bka() */ 1 AS c FROM t AS b RIGHT JOIN t AS c ON b.a > c.c
|
||||
WHERE b.b>c.a;
|
||||
c
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'cccc'
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'cccc'
|
||||
DROP TABLE t;
|
||||
set @optimizer_switch_save = @@optimizer_switch;
|
||||
set optimizer_switch='mrr_cost_based=off';
|
||||
set @read_rnd_buffer_size_save= @@read_rnd_buffer_size;
|
||||
set read_rnd_buffer_size=32;
|
||||
CREATE TABLE t0 (
|
||||
i1 INTEGER NOT NULL
|
||||
);
|
||||
INSERT INTO t0 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
||||
CREATE TABLE t1 (
|
||||
pk INTEGER NOT NULL,
|
||||
i1 INTEGER NOT NULL,
|
||||
i2 INTEGER NOT NULL,
|
||||
v1 INTEGER GENERATED ALWAYS AS (i2 + 1) VIRTUAL,
|
||||
v2 INTEGER GENERATED ALWAYS AS (i1 / (i1 - i2 + 57)) VIRTUAL,
|
||||
PRIMARY KEY (pk),
|
||||
INDEX idx(i1)
|
||||
);
|
||||
INSERT INTO t1 (pk, i1, i2)
|
||||
SELECT a0.i1 + a1.i1*10 + a2.i1*100,
|
||||
a0.i1 + a1.i1*10,
|
||||
a0.i1 + a1.i1*10
|
||||
FROM t0 AS a0, t0 AS a1, t0 AS a2;
|
||||
EXPLAIN SELECT * FROM t1
|
||||
WHERE i1 > 41 AND i1 <= 43;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range idx idx 4 NULL 19 Using index condition
|
||||
SELECT * FROM t1
|
||||
WHERE i1 > 41 AND i1 <= 43;
|
||||
pk i1 i2 v1 v2
|
||||
142 42 42 43 1
|
||||
143 43 43 44 1
|
||||
242 42 42 43 1
|
||||
243 43 43 44 1
|
||||
342 42 42 43 1
|
||||
343 43 43 44 1
|
||||
42 42 42 43 1
|
||||
43 43 43 44 1
|
||||
442 42 42 43 1
|
||||
443 43 43 44 1
|
||||
542 42 42 43 1
|
||||
543 43 43 44 1
|
||||
642 42 42 43 1
|
||||
643 43 43 44 1
|
||||
742 42 42 43 1
|
||||
743 43 43 44 1
|
||||
842 42 42 43 1
|
||||
843 43 43 44 1
|
||||
942 42 42 43 1
|
||||
943 43 43 44 1
|
||||
EXPLAIN SELECT * FROM t1
|
||||
WHERE v1 > 41 AND v1 <= 43;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL # Using where
|
||||
SELECT * FROM t1
|
||||
WHERE v1 > 41 AND v1 <= 43;
|
||||
pk i1 i2 v1 v2
|
||||
141 41 41 42 1
|
||||
142 42 42 43 1
|
||||
241 41 41 42 1
|
||||
242 42 42 43 1
|
||||
341 41 41 42 1
|
||||
342 42 42 43 1
|
||||
41 41 41 42 1
|
||||
42 42 42 43 1
|
||||
441 41 41 42 1
|
||||
442 42 42 43 1
|
||||
541 41 41 42 1
|
||||
542 42 42 43 1
|
||||
641 41 41 42 1
|
||||
642 42 42 43 1
|
||||
741 41 41 42 1
|
||||
742 42 42 43 1
|
||||
841 41 41 42 1
|
||||
842 42 42 43 1
|
||||
941 41 41 42 1
|
||||
942 42 42 43 1
|
||||
DROP TABLE t0, t1;
|
||||
set optimizer_switch= @optimizer_switch_save;
|
||||
set @@read_rnd_buffer_size= @read_rnd_buffer_size_save;
|
||||
#
|
||||
# Bug#21872184 CONDITIONAL JUMP AT JOIN_CACHE::WRITE_RECORD_DATA IN
|
||||
# SQL_JOIN_BUFFER.CC
|
||||
#
|
||||
#
|
||||
# Test 1: Dynamic range scan with one covering index
|
||||
#
|
||||
CREATE TABLE t1 (
|
||||
i1 INTEGER NOT NULL,
|
||||
c1 VARCHAR(1) NOT NULL
|
||||
);
|
||||
INSERT INTO t1
|
||||
VALUES (10, 'c'), (10, 'i'), (2, 't'), (4, 'g');
|
||||
CREATE TABLE t2 (
|
||||
i1 INTEGER NOT NULL,
|
||||
c1 VARCHAR(1) NOT NULL
|
||||
);
|
||||
INSERT INTO t2
|
||||
VALUES (2, 'k'), (9, 'k'), (7, 'o'), (5, 'n'), (7, 'e');
|
||||
CREATE TABLE t3 (
|
||||
pk INTEGER NOT NULL,
|
||||
i1 INTEGER,
|
||||
i2_key INTEGER GENERATED ALWAYS AS (i1 + i1) VIRTUAL,
|
||||
PRIMARY KEY (pk)
|
||||
);
|
||||
INSERT INTO t3 (pk, i1)
|
||||
VALUES (1, 1), (2, 48), (3, 228), (4, 3), (5, 5),
|
||||
(6, 39), (7, 6), (8, 8), (9, 3);
|
||||
CREATE TABLE t4 (
|
||||
i1 INTEGER NOT NULL,
|
||||
c1 VARCHAR(1) NOT NULL
|
||||
);
|
||||
INSERT INTO t4
|
||||
VALUES (1, 'j'), (2, 'c'), (0, 'a');
|
||||
ANALYZE TABLE t1, t2, t3, t4;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
test.t2 analyze status OK
|
||||
test.t3 analyze status OK
|
||||
test.t4 analyze status OK
|
||||
EXPLAIN SELECT /*+ NO_SEMIJOIN(@subq1) */ t1.c1, t2.i1
|
||||
FROM t1 STRAIGHT_JOIN t3 STRAIGHT_JOIN t2
|
||||
WHERE ( t3.pk IN
|
||||
(
|
||||
SELECT /*+ QB_NAME(subq1) */ t4.i1
|
||||
FROM t4
|
||||
WHERE t4.c1 < 'o'
|
||||
)
|
||||
)
|
||||
AND t1.i1 <= t3.i2_key;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t3 eq_ref PRIMARY PRIMARY 4 test.t4.i1 1 Using where
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED t4 ALL NULL NULL NULL NULL 3 Using where
|
||||
SELECT /*+ NO_SEMIJOIN(@subq1) */ t1.c1, t2.i1
|
||||
FROM t1 STRAIGHT_JOIN t3 STRAIGHT_JOIN t2
|
||||
WHERE ( t3.pk IN
|
||||
(
|
||||
SELECT /*+ QB_NAME(subq1) */ t4.i1
|
||||
FROM t4
|
||||
WHERE t4.c1 < 'o'
|
||||
)
|
||||
)
|
||||
AND t1.i1 <= t3.i2_key;
|
||||
c1 i1
|
||||
c 2
|
||||
c 5
|
||||
c 7
|
||||
c 7
|
||||
c 9
|
||||
g 2
|
||||
g 5
|
||||
g 7
|
||||
g 7
|
||||
g 9
|
||||
i 2
|
||||
i 5
|
||||
i 7
|
||||
i 7
|
||||
i 9
|
||||
t 2
|
||||
t 2
|
||||
t 5
|
||||
t 5
|
||||
t 7
|
||||
t 7
|
||||
t 7
|
||||
t 7
|
||||
t 9
|
||||
t 9
|
||||
#
|
||||
# Test 2: Two alternative covering indexes for the range scan
|
||||
#
|
||||
EXPLAIN SELECT /*+ NO_SEMIJOIN(@subq1) */ t1.c1, t2.i1
|
||||
FROM t1 STRAIGHT_JOIN t3 STRAIGHT_JOIN t2
|
||||
WHERE ( t3.pk IN
|
||||
(
|
||||
SELECT /*+ QB_NAME(subq1) */ t4.i1
|
||||
FROM t4
|
||||
WHERE t4.c1 < 'o'
|
||||
)
|
||||
)
|
||||
AND t1.i1 <= t3.i2_key;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t3 eq_ref PRIMARY PRIMARY 4 test.t4.i1 1 Using where
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED t4 ALL NULL NULL NULL NULL 3 Using where
|
||||
SELECT /*+ NO_SEMIJOIN(@subq1) */ t1.c1, t2.i1
|
||||
FROM t1 STRAIGHT_JOIN t3 STRAIGHT_JOIN t2
|
||||
WHERE ( t3.pk IN
|
||||
(
|
||||
SELECT /*+ QB_NAME(subq1) */ t4.i1
|
||||
FROM t4
|
||||
WHERE t4.c1 < 'o'
|
||||
)
|
||||
)
|
||||
AND t1.i1 <= t3.i2_key;
|
||||
c1 i1
|
||||
c 2
|
||||
c 5
|
||||
c 7
|
||||
c 7
|
||||
c 9
|
||||
g 2
|
||||
g 5
|
||||
g 7
|
||||
g 7
|
||||
g 9
|
||||
i 2
|
||||
i 5
|
||||
i 7
|
||||
i 7
|
||||
i 9
|
||||
t 2
|
||||
t 2
|
||||
t 5
|
||||
t 5
|
||||
t 7
|
||||
t 7
|
||||
t 7
|
||||
t 7
|
||||
t 9
|
||||
t 9
|
||||
#
|
||||
# Test 3: One covering index including the base column for the virtual
|
||||
# column
|
||||
#
|
||||
EXPLAIN SELECT /*+ NO_SEMIJOIN(@subq1) */ t1.c1, t2.i1
|
||||
FROM t1 STRAIGHT_JOIN t3 STRAIGHT_JOIN t2
|
||||
WHERE ( t3.pk IN
|
||||
(
|
||||
SELECT /*+ QB_NAME(subq1) */ t4.i1
|
||||
FROM t4
|
||||
WHERE t4.c1 < 'o'
|
||||
)
|
||||
)
|
||||
AND t1.i1 <= t3.i2_key;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t3 eq_ref PRIMARY PRIMARY 4 test.t4.i1 1 Using where
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED t4 ALL NULL NULL NULL NULL 3 Using where
|
||||
SELECT /*+ NO_SEMIJOIN(@subq1) */ t1.c1, t2.i1
|
||||
FROM t1 STRAIGHT_JOIN t3 STRAIGHT_JOIN t2
|
||||
WHERE ( t3.pk IN
|
||||
(
|
||||
SELECT /*+ QB_NAME(subq1) */ t4.i1
|
||||
FROM t4
|
||||
WHERE t4.c1 < 'o'
|
||||
)
|
||||
)
|
||||
AND t1.i1 <= t3.i2_key;
|
||||
c1 i1
|
||||
c 2
|
||||
c 5
|
||||
c 7
|
||||
c 7
|
||||
c 9
|
||||
g 2
|
||||
g 5
|
||||
g 7
|
||||
g 7
|
||||
g 9
|
||||
i 2
|
||||
i 5
|
||||
i 7
|
||||
i 7
|
||||
i 9
|
||||
t 2
|
||||
t 2
|
||||
t 5
|
||||
t 5
|
||||
t 7
|
||||
t 7
|
||||
t 7
|
||||
t 7
|
||||
t 9
|
||||
t 9
|
||||
#
|
||||
# Test 4: One non-covering index
|
||||
#
|
||||
# Add more data to the table so that it will run the dynamic range scan
|
||||
# as both table scan and range scan (the purpose of this is to make the
|
||||
# table scan more expensive).
|
||||
INSERT INTO t3 (pk, i1)
|
||||
VALUES (10,1), (11,1), (12,1), (13,1), (14,1),(15,1), (16,1),(17,1), (18,1),
|
||||
(19,1), (20,1), (21,1), (22,1), (23,1), (24,1),(25,1),(26,1),(27,1),
|
||||
(28,1), (29,1);
|
||||
# Change the query to read an extra column (t3.i1) making the index
|
||||
# non-covering.
|
||||
EXPLAIN SELECT /*+ NO_SEMIJOIN(@subq1) */ t1.c1, t2.i1, t3.i1
|
||||
FROM t1 STRAIGHT_JOIN t3 STRAIGHT_JOIN t2
|
||||
WHERE ( t3.pk IN
|
||||
(
|
||||
SELECT /*+ QB_NAME(subq1) */ t4.i1
|
||||
FROM t4
|
||||
WHERE t4.c1 < 'o'
|
||||
)
|
||||
)
|
||||
AND t1.i1 <= t3.i2_key;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t3 eq_ref PRIMARY PRIMARY 4 test.t4.i1 1 Using where
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED t4 ALL NULL NULL NULL NULL 3 Using where
|
||||
SELECT /*+ NO_SEMIJOIN(@subq1) */ t1.c1, t2.i1, t3.i1
|
||||
FROM t1 STRAIGHT_JOIN t3 STRAIGHT_JOIN t2
|
||||
WHERE ( t3.pk IN
|
||||
(
|
||||
SELECT /*+ QB_NAME(subq1) */ t4.i1
|
||||
FROM t4
|
||||
WHERE t4.c1 < 'o'
|
||||
)
|
||||
)
|
||||
AND t1.i1 <= t3.i2_key;
|
||||
c1 i1 i1
|
||||
c 2 48
|
||||
c 5 48
|
||||
c 7 48
|
||||
c 7 48
|
||||
c 9 48
|
||||
g 2 48
|
||||
g 5 48
|
||||
g 7 48
|
||||
g 7 48
|
||||
g 9 48
|
||||
i 2 48
|
||||
i 5 48
|
||||
i 7 48
|
||||
i 7 48
|
||||
i 9 48
|
||||
t 2 1
|
||||
t 2 48
|
||||
t 5 1
|
||||
t 5 48
|
||||
t 7 1
|
||||
t 7 1
|
||||
t 7 48
|
||||
t 7 48
|
||||
t 9 1
|
||||
t 9 48
|
||||
#
|
||||
# Test 5: Test where the added primary key to secondary indexes is
|
||||
# used after it has been included in the join buffer
|
||||
#
|
||||
EXPLAIN SELECT /*+ NO_SEMIJOIN(@subq1) */ t1.c1, t2.i1
|
||||
FROM t1 STRAIGHT_JOIN t3 STRAIGHT_JOIN t2
|
||||
WHERE ( t3.pk IN
|
||||
(
|
||||
SELECT /*+ QB_NAME(subq1) */ t4.i1
|
||||
FROM t4
|
||||
WHERE t4.c1 < 'o' and t4.i1 < (t2.i1 + 1)
|
||||
)
|
||||
)
|
||||
AND t1.i1 <= t3.i2_key;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t4 ALL NULL NULL NULL NULL 3 Using where; Start temporary
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t3 eq_ref PRIMARY PRIMARY 4 test.t4.i1 1 Using where
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using where; End temporary; Using join buffer (flat, BNL join)
|
||||
SELECT /*+ NO_SEMIJOIN(@subq1) */ t1.c1, t2.i1
|
||||
FROM t1 STRAIGHT_JOIN t3 STRAIGHT_JOIN t2
|
||||
WHERE ( t3.pk IN
|
||||
(
|
||||
SELECT /*+ QB_NAME(subq1) */ t4.i1
|
||||
FROM t4
|
||||
WHERE t4.c1 < 'o' and t4.i1 < (t2.i1 + 1)
|
||||
)
|
||||
)
|
||||
AND t1.i1 <= t3.i2_key;
|
||||
c1 i1
|
||||
c 2
|
||||
c 5
|
||||
c 7
|
||||
c 7
|
||||
c 9
|
||||
g 2
|
||||
g 5
|
||||
g 7
|
||||
g 7
|
||||
g 9
|
||||
i 2
|
||||
i 5
|
||||
i 7
|
||||
i 7
|
||||
i 9
|
||||
t 2
|
||||
t 2
|
||||
t 5
|
||||
t 5
|
||||
t 7
|
||||
t 7
|
||||
t 7
|
||||
t 7
|
||||
t 9
|
||||
t 9
|
||||
DROP TABLE t1, t2, t3, t4;
|
||||
SET optimizer_switch='derived_merge=default';
|
||||
DROP VIEW IF EXISTS v1,v2;
|
||||
DROP TABLE IF EXISTS t1,t2,t3;
|
||||
DROP PROCEDURE IF EXISTS p1;
|
||||
DROP FUNCTION IF EXISTS f1;
|
||||
DROP TRIGGER IF EXISTS trg1;
|
||||
DROP TRIGGER IF EXISTS trg2;
|
||||
set sql_warnings = 0;
|
3000
mysql-test/suite/gcol/r/gcol_supported_sql_funcs_innodb.result
Normal file
3000
mysql-test/suite/gcol/r/gcol_supported_sql_funcs_innodb.result
Normal file
File diff suppressed because it is too large
Load diff
3000
mysql-test/suite/gcol/r/gcol_supported_sql_funcs_myisam.result
Normal file
3000
mysql-test/suite/gcol/r/gcol_supported_sql_funcs_myisam.result
Normal file
File diff suppressed because it is too large
Load diff
94
mysql-test/suite/gcol/r/gcol_trigger_sp_innodb.result
Normal file
94
mysql-test/suite/gcol/r/gcol_trigger_sp_innodb.result
Normal file
|
@ -0,0 +1,94 @@
|
|||
SET @@session.default_storage_engine = 'InnoDB';
|
||||
create table t1 (a int,
|
||||
b int generated always as (a/10) virtual,
|
||||
c int generated always as (a/10) stored);
|
||||
create table t2 (a timestamp);
|
||||
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
|
||||
100 10 10
|
||||
200 20 20
|
||||
select * from t2;
|
||||
a
|
||||
insert into t1 (a) values (600);
|
||||
select * from t1;
|
||||
a b c
|
||||
100 10 10
|
||||
200 20 20
|
||||
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;
|
||||
DROP VIEW IF EXISTS v1,v2;
|
||||
DROP TABLE IF EXISTS t1,t2,t3;
|
||||
DROP PROCEDURE IF EXISTS p1;
|
||||
DROP FUNCTION IF EXISTS f1;
|
||||
DROP TRIGGER IF EXISTS trg1;
|
||||
DROP TRIGGER IF EXISTS trg2;
|
||||
set sql_warnings = 0;
|
94
mysql-test/suite/gcol/r/gcol_trigger_sp_myisam.result
Normal file
94
mysql-test/suite/gcol/r/gcol_trigger_sp_myisam.result
Normal file
|
@ -0,0 +1,94 @@
|
|||
SET @@session.default_storage_engine = 'MyISAM';
|
||||
create table t1 (a int,
|
||||
b int generated always as (a/10) virtual,
|
||||
c int generated always as (a/10) stored);
|
||||
create table t2 (a timestamp);
|
||||
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
|
||||
100 10 10
|
||||
200 20 20
|
||||
select * from t2;
|
||||
a
|
||||
insert into t1 (a) values (600);
|
||||
select * from t1;
|
||||
a b c
|
||||
100 10 10
|
||||
200 20 20
|
||||
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;
|
||||
DROP VIEW IF EXISTS v1,v2;
|
||||
DROP TABLE IF EXISTS t1,t2,t3;
|
||||
DROP PROCEDURE IF EXISTS p1;
|
||||
DROP FUNCTION IF EXISTS f1;
|
||||
DROP TRIGGER IF EXISTS trg1;
|
||||
DROP TRIGGER IF EXISTS trg2;
|
||||
set sql_warnings = 0;
|
30
mysql-test/suite/gcol/r/gcol_update.result
Normal file
30
mysql-test/suite/gcol/r/gcol_update.result
Normal file
|
@ -0,0 +1,30 @@
|
|||
set global innodb_purge_stop_now = 1;
|
||||
create table t1(f1 int not null, f2 blob not null, f3 blob not null,
|
||||
vchar char(2) as (substr(f3,2,2)) virtual,
|
||||
primary key(f1, f3(5)), index(vchar))engine=innodb;
|
||||
insert into t1(f1,f2,f3) values(1, repeat('a',8000), repeat('b', 9000));
|
||||
update t1 set f1=5 where f1=1;
|
||||
delete from t1 where f1=5;
|
||||
set global innodb_purge_run_now=1;
|
||||
set global innodb_fast_shutdown=0;
|
||||
set global innodb_purge_stop_now = 1;
|
||||
drop table t1;
|
||||
create table t1(f1 int not null, f2 blob not null, f3 blob not null,
|
||||
vchar char(2) as (substr(f3,2,2)) virtual,
|
||||
primary key(f1, f3(5)), index(vchar, f3(2)))engine=innodb;
|
||||
insert into t1(f1,f2,f3) values(1, repeat('a',8000), repeat('b', 9000));
|
||||
update t1 set f1=5 where f1=1;
|
||||
delete from t1 where f1=5;
|
||||
set global innodb_purge_run_now=1;
|
||||
set global innodb_fast_shutdown=0;
|
||||
set global innodb_purge_stop_now = 1;
|
||||
drop table t1;
|
||||
create table t1(f1 int not null, f2 blob not null, f3 blob not null,
|
||||
vchar blob as (f3) virtual,
|
||||
primary key(f1, f3(5)), index(vchar(3)))engine=innodb;
|
||||
insert into t1(f1,f2,f3) values(1, repeat('a',8000), repeat('b', 9000));
|
||||
update t1 set f1=5 where f1=1;
|
||||
delete from t1 where f1=5;
|
||||
set global innodb_purge_run_now=1;
|
||||
set global innodb_fast_shutdown=0;
|
||||
drop table t1;
|
280
mysql-test/suite/gcol/r/gcol_view_innodb.result
Normal file
280
mysql-test/suite/gcol/r/gcol_view_innodb.result
Normal file
|
@ -0,0 +1,280 @@
|
|||
SET @@session.default_storage_engine = 'InnoDB';
|
||||
create table t1 (a int not null,
|
||||
b int generated always as (-a) virtual,
|
||||
c int generated always as (-a) stored);
|
||||
insert into t1 (a) values (1), (1), (2), (2), (3);
|
||||
analyze table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
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 select d,e from v1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 X
|
||||
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 select d,e from v2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 5 X
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 5 X
|
||||
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 select * from v3;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 X
|
||||
drop view v1,v2,v3;
|
||||
drop table t1;
|
||||
create table t1 (a int not null,
|
||||
b int generated always as (-a) virtual,
|
||||
c int generated always as (-a) stored);
|
||||
insert into t1 (a) values (1), (2), (3), (1), (2), (3);
|
||||
create view v1 as select distinct b from t1;
|
||||
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 6 X
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 6 X
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
2 -2 -2
|
||||
3 -3 -3
|
||||
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 6 X
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 6 X
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
2 -2 -2
|
||||
3 -3 -3
|
||||
3 -3 -3
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
create table t1 (a int not null,
|
||||
b int generated always as (-a) virtual,
|
||||
c int generated always as (-a) stored);
|
||||
insert into t1 (a) values (1), (2), (3), (4);
|
||||
create view v1 as select b+1 from t1 order by 1 desc limit 2;
|
||||
select * from v1;
|
||||
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 X
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 4 X
|
||||
drop view v1;
|
||||
create view v1 as select c+1 from t1 order by 1 desc limit 2;
|
||||
select * from v1;
|
||||
c+1
|
||||
-1
|
||||
0
|
||||
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 X
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 4 X
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
create table t1 (a int,
|
||||
b int,
|
||||
c int generated always as (-a) virtual,
|
||||
d int generated always as (-a) stored,
|
||||
primary key(a));
|
||||
insert into t1 (a,b) values (10,2), (20,3), (30,4), (40,5), (50,10);
|
||||
create view v1 (a,e,f,g) as select a, b+1,c+1,d+1 from t1;
|
||||
update v1 set a=a+e;
|
||||
select * from v1 order by a;
|
||||
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 order by a;
|
||||
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 generated always as (-a) virtual,
|
||||
c int generated always as (-a) stored,
|
||||
primary key(a));
|
||||
insert into t1 (a) values (1), (2), (3);
|
||||
create view v1 (x,y,z) as select a,b,c from t1 where b < -1;
|
||||
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 generated always as (-a1) virtual,
|
||||
c1 int generated always as (-a1) stored);
|
||||
create table t2 (a2 int,
|
||||
b2 int generated always as (-a2) virtual,
|
||||
c2 int generated always as (-a2) stored);
|
||||
insert into t1 (a1) values (1), (2);
|
||||
insert into t2 (a2) values (2), (3);
|
||||
create view v1 as select * from t1,t2 union all select * from t1,t2;
|
||||
select * from v1;
|
||||
a1 b1 c1 a2 b2 c2
|
||||
1 -1 -1 2 -2 -2
|
||||
1 -1 -1 2 -2 -2
|
||||
1 -1 -1 3 -3 -3
|
||||
1 -1 -1 3 -3 -3
|
||||
2 -2 -2 2 -2 -2
|
||||
2 -2 -2 2 -2 -2
|
||||
2 -2 -2 3 -3 -3
|
||||
2 -2 -2 3 -3 -3
|
||||
drop view v1;
|
||||
drop table t1, t2;
|
||||
create table t1 (a int,
|
||||
b int generated always as (-a) virtual,
|
||||
c int generated always as (-a) stored);
|
||||
create table t2 like t1;
|
||||
create view v1 as select a,b,c from t1;
|
||||
create view v2 as select a,b,c from t2 where b in (select b from v1);
|
||||
show create view v2;
|
||||
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` from `v1`) latin1 latin1_swedish_ci
|
||||
drop view v2, v1;
|
||||
drop table t1, t2;
|
||||
create table t1 (a int,
|
||||
b int generated always as (-a) virtual,
|
||||
c int generated always as (-a) stored);
|
||||
insert into t1 (a) values (1),(1),(2),(2),(3),(3);
|
||||
create view v1 as select b from t1;
|
||||
select distinct b from v1;
|
||||
b
|
||||
-1
|
||||
-2
|
||||
-3
|
||||
select distinct b from v1 order by b limit 2;
|
||||
b
|
||||
-3
|
||||
-2
|
||||
select distinct b from t1 order by b limit 2;
|
||||
b
|
||||
-3
|
||||
-2
|
||||
prepare stmt1 from "select distinct b from v1 order by b limit 2";
|
||||
execute stmt1;
|
||||
b
|
||||
-3
|
||||
-2
|
||||
execute stmt1;
|
||||
b
|
||||
-3
|
||||
-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 order by c limit 2;
|
||||
c
|
||||
-3
|
||||
-2
|
||||
select distinct c from t1 order by c limit 2;
|
||||
c
|
||||
-3
|
||||
-2
|
||||
prepare stmt1 from "select distinct c from v1 order by c limit 2";
|
||||
execute stmt1;
|
||||
c
|
||||
-3
|
||||
-2
|
||||
execute stmt1;
|
||||
c
|
||||
-3
|
||||
-2
|
||||
deallocate prepare stmt1;
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
create table t1 (a int,
|
||||
b int generated always as (-a) virtual,
|
||||
c int generated always as (-a) stored);
|
||||
create view v1 as select * from t1 where b > -2 && c >-2 with check option;
|
||||
insert into v1 (a) values (1);
|
||||
insert into v1 (a) values (3);
|
||||
ERROR 44000: CHECK OPTION failed `test`.`v1`
|
||||
insert ignore into v1 (a) values (2),(3),(0);
|
||||
Warnings:
|
||||
Warning 1369 CHECK OPTION failed `test`.`v1`
|
||||
Warning 1369 CHECK OPTION failed `test`.`v1`
|
||||
select * from t1;
|
||||
a b c
|
||||
0 0 0
|
||||
1 -1 -1
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
DROP VIEW IF EXISTS v1,v2;
|
||||
DROP TABLE IF EXISTS t1,t2,t3;
|
||||
DROP PROCEDURE IF EXISTS p1;
|
||||
DROP FUNCTION IF EXISTS f1;
|
||||
DROP TRIGGER IF EXISTS trg1;
|
||||
DROP TRIGGER IF EXISTS trg2;
|
||||
set sql_warnings = 0;
|
280
mysql-test/suite/gcol/r/gcol_view_myisam.result
Normal file
280
mysql-test/suite/gcol/r/gcol_view_myisam.result
Normal file
|
@ -0,0 +1,280 @@
|
|||
SET @@session.default_storage_engine = 'MyISAM';
|
||||
create table t1 (a int not null,
|
||||
b int generated always as (-a) virtual,
|
||||
c int generated always as (-a) stored);
|
||||
insert into t1 (a) values (1), (1), (2), (2), (3);
|
||||
analyze table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
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 select d,e from v1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 X
|
||||
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 select d,e from v2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 5 X
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 5 X
|
||||
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 select * from v3;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 X
|
||||
drop view v1,v2,v3;
|
||||
drop table t1;
|
||||
create table t1 (a int not null,
|
||||
b int generated always as (-a) virtual,
|
||||
c int generated always as (-a) stored);
|
||||
insert into t1 (a) values (1), (2), (3), (1), (2), (3);
|
||||
create view v1 as select distinct b from t1;
|
||||
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 6 X
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 6 X
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
2 -2 -2
|
||||
3 -3 -3
|
||||
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 6 X
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 6 X
|
||||
select * from t1;
|
||||
a b c
|
||||
1 -1 -1
|
||||
1 -1 -1
|
||||
2 -2 -2
|
||||
2 -2 -2
|
||||
3 -3 -3
|
||||
3 -3 -3
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
create table t1 (a int not null,
|
||||
b int generated always as (-a) virtual,
|
||||
c int generated always as (-a) stored);
|
||||
insert into t1 (a) values (1), (2), (3), (4);
|
||||
create view v1 as select b+1 from t1 order by 1 desc limit 2;
|
||||
select * from v1;
|
||||
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 X
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 4 X
|
||||
drop view v1;
|
||||
create view v1 as select c+1 from t1 order by 1 desc limit 2;
|
||||
select * from v1;
|
||||
c+1
|
||||
-1
|
||||
0
|
||||
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 X
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 4 X
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
create table t1 (a int,
|
||||
b int,
|
||||
c int generated always as (-a) virtual,
|
||||
d int generated always as (-a) stored,
|
||||
primary key(a));
|
||||
insert into t1 (a,b) values (10,2), (20,3), (30,4), (40,5), (50,10);
|
||||
create view v1 (a,e,f,g) as select a, b+1,c+1,d+1 from t1;
|
||||
update v1 set a=a+e;
|
||||
select * from v1 order by a;
|
||||
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 order by a;
|
||||
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 generated always as (-a) virtual,
|
||||
c int generated always as (-a) stored,
|
||||
primary key(a));
|
||||
insert into t1 (a) values (1), (2), (3);
|
||||
create view v1 (x,y,z) as select a,b,c from t1 where b < -1;
|
||||
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 generated always as (-a1) virtual,
|
||||
c1 int generated always as (-a1) stored);
|
||||
create table t2 (a2 int,
|
||||
b2 int generated always as (-a2) virtual,
|
||||
c2 int generated always as (-a2) stored);
|
||||
insert into t1 (a1) values (1), (2);
|
||||
insert into t2 (a2) values (2), (3);
|
||||
create view v1 as select * from t1,t2 union all select * from t1,t2;
|
||||
select * from v1;
|
||||
a1 b1 c1 a2 b2 c2
|
||||
1 -1 -1 2 -2 -2
|
||||
1 -1 -1 2 -2 -2
|
||||
1 -1 -1 3 -3 -3
|
||||
1 -1 -1 3 -3 -3
|
||||
2 -2 -2 2 -2 -2
|
||||
2 -2 -2 2 -2 -2
|
||||
2 -2 -2 3 -3 -3
|
||||
2 -2 -2 3 -3 -3
|
||||
drop view v1;
|
||||
drop table t1, t2;
|
||||
create table t1 (a int,
|
||||
b int generated always as (-a) virtual,
|
||||
c int generated always as (-a) stored);
|
||||
create table t2 like t1;
|
||||
create view v1 as select a,b,c from t1;
|
||||
create view v2 as select a,b,c from t2 where b in (select b from v1);
|
||||
show create view v2;
|
||||
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` from `v1`) latin1 latin1_swedish_ci
|
||||
drop view v2, v1;
|
||||
drop table t1, t2;
|
||||
create table t1 (a int,
|
||||
b int generated always as (-a) virtual,
|
||||
c int generated always as (-a) stored);
|
||||
insert into t1 (a) values (1),(1),(2),(2),(3),(3);
|
||||
create view v1 as select b from t1;
|
||||
select distinct b from v1;
|
||||
b
|
||||
-1
|
||||
-2
|
||||
-3
|
||||
select distinct b from v1 order by b limit 2;
|
||||
b
|
||||
-3
|
||||
-2
|
||||
select distinct b from t1 order by b limit 2;
|
||||
b
|
||||
-3
|
||||
-2
|
||||
prepare stmt1 from "select distinct b from v1 order by b limit 2";
|
||||
execute stmt1;
|
||||
b
|
||||
-3
|
||||
-2
|
||||
execute stmt1;
|
||||
b
|
||||
-3
|
||||
-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 order by c limit 2;
|
||||
c
|
||||
-3
|
||||
-2
|
||||
select distinct c from t1 order by c limit 2;
|
||||
c
|
||||
-3
|
||||
-2
|
||||
prepare stmt1 from "select distinct c from v1 order by c limit 2";
|
||||
execute stmt1;
|
||||
c
|
||||
-3
|
||||
-2
|
||||
execute stmt1;
|
||||
c
|
||||
-3
|
||||
-2
|
||||
deallocate prepare stmt1;
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
create table t1 (a int,
|
||||
b int generated always as (-a) virtual,
|
||||
c int generated always as (-a) stored);
|
||||
create view v1 as select * from t1 where b > -2 && c >-2 with check option;
|
||||
insert into v1 (a) values (1);
|
||||
insert into v1 (a) values (3);
|
||||
ERROR 44000: CHECK OPTION failed `test`.`v1`
|
||||
insert ignore into v1 (a) values (2),(3),(0);
|
||||
Warnings:
|
||||
Warning 1369 CHECK OPTION failed `test`.`v1`
|
||||
Warning 1369 CHECK OPTION failed `test`.`v1`
|
||||
select * from t1;
|
||||
a b c
|
||||
0 0 0
|
||||
1 -1 -1
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
DROP VIEW IF EXISTS v1,v2;
|
||||
DROP TABLE IF EXISTS t1,t2,t3;
|
||||
DROP PROCEDURE IF EXISTS p1;
|
||||
DROP FUNCTION IF EXISTS f1;
|
||||
DROP TRIGGER IF EXISTS trg1;
|
||||
DROP TRIGGER IF EXISTS trg2;
|
||||
set sql_warnings = 0;
|
33
mysql-test/suite/gcol/r/rpl_gcol.result
Normal file
33
mysql-test/suite/gcol/r/rpl_gcol.result
Normal file
|
@ -0,0 +1,33 @@
|
|||
SET @@session.default_storage_engine = 'InnoDB';
|
||||
include/master-slave.inc
|
||||
[connection master]
|
||||
connection master;
|
||||
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
|
||||
) 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
|
||||
connection slave;
|
||||
select * from t1;
|
||||
a b
|
||||
1 2
|
||||
2 3
|
||||
connection master;
|
||||
drop table t1;
|
||||
connection slave;
|
||||
DROP VIEW IF EXISTS v1,v2;
|
||||
DROP TABLE IF EXISTS t1,t2,t3;
|
||||
DROP PROCEDURE IF EXISTS p1;
|
||||
DROP FUNCTION IF EXISTS f1;
|
||||
DROP TRIGGER IF EXISTS trg1;
|
||||
DROP TRIGGER IF EXISTS trg2;
|
||||
set sql_warnings = 0;
|
||||
include/rpl_end.inc
|
44
mysql-test/suite/gcol/t/gcol_archive.test
Normal file
44
mysql-test/suite/gcol/t/gcol_archive.test
Normal file
|
@ -0,0 +1,44 @@
|
|||
################################################################################
|
||||
# t/gcol_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
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
--source include/have_archive.inc
|
||||
SET @@session.default_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/gcol/inc/gcol_unsupported_storage_engines.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/gcol/inc/gcol_cleanup.inc
|
44
mysql-test/suite/gcol/t/gcol_blackhole.test
Normal file
44
mysql-test/suite/gcol/t/gcol_blackhole.test
Normal file
|
@ -0,0 +1,44 @@
|
|||
################################################################################
|
||||
# t/gcol_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
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
--source include/have_blackhole.inc
|
||||
SET @@session.default_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/gcol/inc/gcol_unsupported_storage_engines.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/gcol/inc/gcol_cleanup.inc
|
47
mysql-test/suite/gcol/t/gcol_blocked_sql_funcs_innodb.test
Normal file
47
mysql-test/suite/gcol/t/gcol_blocked_sql_funcs_innodb.test
Normal file
|
@ -0,0 +1,47 @@
|
|||
################################################################################
|
||||
# t/gcol_supported_sql_funcs.test #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Test SQL functions not allowed for generated 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
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
--source include/have_innodb.inc
|
||||
eval SET @@session.default_storage_engine = 'InnoDB';
|
||||
|
||||
let $skip_full_text_check = 1;
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
--source suite/gcol/inc/gcol_blocked_sql_funcs_main.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/gcol/inc/gcol_cleanup.inc
|
44
mysql-test/suite/gcol/t/gcol_blocked_sql_funcs_myisam.test
Normal file
44
mysql-test/suite/gcol/t/gcol_blocked_sql_funcs_myisam.test
Normal file
|
@ -0,0 +1,44 @@
|
|||
################################################################################
|
||||
# t/gcol_supported_sql_funcs.test #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Test SQL functions not allowed for generated 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
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
eval SET @@session.default_storage_engine = 'MyISAM';
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
--source suite/gcol/inc/gcol_blocked_sql_funcs_main.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/gcol/inc/gcol_cleanup.inc
|
28
mysql-test/suite/gcol/t/gcol_bug20746926.test
Normal file
28
mysql-test/suite/gcol/t/gcol_bug20746926.test
Normal file
|
@ -0,0 +1,28 @@
|
|||
--echo #Bug #20746926: GENERATED COLUMNS: INVALID READ OF THD WHEN WARNINGS
|
||||
--echo #
|
||||
--echo # Testing cmp_item_datetime
|
||||
connect(con1,localhost,root,,);
|
||||
--disable_warnings
|
||||
set sql_mode='';
|
||||
--enable_warnings
|
||||
create table t1 (
|
||||
a date not null,
|
||||
b mediumtext generated always as ((a not in (a,a))) virtual,
|
||||
c timestamp generated always as ((a not in (b,b))) stored
|
||||
);
|
||||
insert t1(a) values(7777777777);
|
||||
show warnings;
|
||||
disconnect con1;
|
||||
--source include/wait_until_disconnected.inc
|
||||
|
||||
connect(con2,localhost,root,,);
|
||||
--disable_warnings
|
||||
set sql_mode='';
|
||||
--enable_warnings
|
||||
insert t1(a) values(6666666666);
|
||||
show warnings;
|
||||
|
||||
drop table t1;
|
||||
disconnect con2;
|
||||
--source include/wait_until_disconnected.inc
|
||||
connection default;
|
601
mysql-test/suite/gcol/t/gcol_bugfixes.test
Normal file
601
mysql-test/suite/gcol/t/gcol_bugfixes.test
Normal file
|
@ -0,0 +1,601 @@
|
|||
################################################################################
|
||||
# t/gcol_bugfixes.test #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Bug fixes that only need one storage engine #
|
||||
# #
|
||||
################################################################################
|
||||
|
||||
--source include/have_innodb.inc
|
||||
--echo # Bug#21230709: Alter table statement fails with division by zero
|
||||
|
||||
CREATE TABLE t1 (
|
||||
col1 INTEGER NOT NULL,
|
||||
col2 INTEGER NOT NULL,
|
||||
col3 INTEGER NOT NULL,
|
||||
gcol1 INTEGER GENERATED ALWAYS AS (col3 + col3) VIRTUAL,
|
||||
col4 INTEGER DEFAULT NULL,
|
||||
col5 INTEGER DEFAULT NULL,
|
||||
col6 INTEGER DEFAULT NULL,
|
||||
col7 INTEGER DEFAULT NULL,
|
||||
col8 INTEGER DEFAULT NULL,
|
||||
col9 INTEGER DEFAULT NULL,
|
||||
col10 INTEGER DEFAULT NULL,
|
||||
col11 INTEGER DEFAULT NULL,
|
||||
col12 INTEGER DEFAULT NULL,
|
||||
col13 INTEGER DEFAULT NULL,
|
||||
col14 INTEGER DEFAULT NULL,
|
||||
col15 INTEGER DEFAULT NULL,
|
||||
col16 INTEGER DEFAULT NULL,
|
||||
col17 INTEGER DEFAULT NULL,
|
||||
col18 INTEGER DEFAULT NULL,
|
||||
col19 INTEGER DEFAULT NULL,
|
||||
col20 INTEGER DEFAULT NULL,
|
||||
col21 INTEGER DEFAULT NULL,
|
||||
col22 INTEGER DEFAULT NULL,
|
||||
col23 INTEGER DEFAULT NULL,
|
||||
col24 INTEGER DEFAULT NULL,
|
||||
col25 INTEGER DEFAULT NULL,
|
||||
col26 INTEGER DEFAULT NULL,
|
||||
col27 INTEGER DEFAULT NULL,
|
||||
col28 INTEGER DEFAULT NULL,
|
||||
col29 INTEGER DEFAULT NULL,
|
||||
col30 INTEGER DEFAULT NULL,
|
||||
col31 INTEGER DEFAULT NULL,
|
||||
col32 INTEGER DEFAULT NULL,
|
||||
col33 INTEGER DEFAULT NULL,
|
||||
gcol2 INTEGER GENERATED ALWAYS AS (col2 + col2) VIRTUAL,
|
||||
gcol3 INTEGER GENERATED ALWAYS AS (gcol2 / gcol2) VIRTUAL,
|
||||
PRIMARY KEY (col1),
|
||||
KEY idx1 (gcol1)
|
||||
) engine=innodb;
|
||||
|
||||
INSERT INTO t1 (col1, col2, col3)
|
||||
VALUES (0,1,2), (1,2,3), (2,3,4), (3,4,5), (4,5,6);
|
||||
|
||||
# This is likely needed to ensure we allocate a new record buffer that
|
||||
# contains zero in the mis-used field
|
||||
FLUSH TABLE t1;
|
||||
|
||||
ALTER TABLE t1 ADD COLUMN extra INTEGER;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo #
|
||||
--echo # Bug 21340801 WL8149:ASSERTION `IS_VIRTUAL_GCOL()' FAILED
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (
|
||||
c_blob BLOB,
|
||||
c_blob_key BLOB GENERATED ALWAYS AS (REPEAT(c_blob,15)) STORED,
|
||||
KEY (c_blob_key(200))
|
||||
);
|
||||
|
||||
INSERT INTO t1 (c_blob) VALUES ('xceks');
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo #
|
||||
--echo # Bug#21345972 WL8149:JOIN_CACHE::FILTER_VIRTUAL_GCOL_BASE_COLS(): ASSERTION `FALSE' FAILED.
|
||||
--echo #
|
||||
|
||||
CREATE TABLE c (
|
||||
pk INTEGER AUTO_INCREMENT,
|
||||
col_int_nokey INTEGER /*! NULL */,
|
||||
col_int_key INTEGER GENERATED ALWAYS AS
|
||||
(col_int_nokey + col_int_nokey) VIRTUAL not null,
|
||||
|
||||
col_date_nokey DATE /*! NULL */,
|
||||
col_date_key DATE GENERATED ALWAYS AS
|
||||
(DATE_ADD(col_date_nokey,interval 30 day)) VIRTUAL not null,
|
||||
|
||||
col_datetime_nokey DATETIME /*! NULL */,
|
||||
col_time_nokey TIME /*! NULL */,
|
||||
|
||||
col_datetime_key DATETIME GENERATED ALWAYS AS
|
||||
(ADDTIME(col_datetime_nokey, col_time_nokey)) VIRTUAL not null,
|
||||
col_time_key TIME GENERATED ALWAYS AS
|
||||
(ADDTIME(col_datetime_nokey, col_time_nokey)) VIRTUAL not null,
|
||||
|
||||
col_varchar_nokey VARCHAR(1) /*! NULL */,
|
||||
col_varchar_key VARCHAR(2) GENERATED ALWAYS AS
|
||||
(CONCAT(col_varchar_nokey, col_varchar_nokey)) VIRTUAL not null,
|
||||
|
||||
PRIMARY KEY (pk),
|
||||
UNIQUE KEY (col_int_key),
|
||||
UNIQUE KEY (col_varchar_key),
|
||||
UNIQUE KEY (col_date_key),
|
||||
KEY (col_time_key),
|
||||
KEY (col_datetime_key),
|
||||
UNIQUE KEY (col_int_key, col_varchar_key),
|
||||
KEY (col_int_key, col_int_nokey),
|
||||
KEY(col_int_key,col_date_key),
|
||||
KEY(col_int_key, col_time_key),
|
||||
KEY(col_int_key, col_datetime_key),
|
||||
UNIQUE
|
||||
KEY(col_date_key,col_time_key,col_datetime_key),
|
||||
UNIQUE KEY (col_varchar_key, col_varchar_nokey),
|
||||
UNIQUE KEY (col_int_key, col_varchar_key,
|
||||
col_date_key, col_time_key, col_datetime_key)
|
||||
) ENGINE=INNODB;
|
||||
|
||||
INSERT /*! IGNORE */ INTO c (
|
||||
col_int_nokey,
|
||||
col_date_nokey,
|
||||
col_time_nokey,
|
||||
col_datetime_nokey,
|
||||
col_varchar_nokey
|
||||
) VALUES (7, '2004-04-09', '14:03:03.042673',
|
||||
'2001-11-28 00:50:27.051028', 'c'),(1, '2006-05-13', '01:46:09.016386',
|
||||
'2007-10-09 19:53:04.008332', NULL);
|
||||
|
||||
CREATE TABLE bb (
|
||||
pk INTEGER AUTO_INCREMENT,
|
||||
col_int_nokey INTEGER /*! NULL */,
|
||||
col_int_key INTEGER GENERATED ALWAYS AS
|
||||
(col_int_nokey + col_int_nokey) VIRTUAL not null,
|
||||
|
||||
col_date_nokey DATE /*! NULL */,
|
||||
col_date_key DATE GENERATED ALWAYS AS
|
||||
(DATE_ADD(col_date_nokey,interval 30 day)) VIRTUAL not null,
|
||||
|
||||
col_datetime_nokey DATETIME /*! NULL */,
|
||||
col_time_nokey TIME /*! NULL */,
|
||||
|
||||
col_datetime_key DATETIME GENERATED ALWAYS AS
|
||||
(ADDTIME(col_datetime_nokey, col_time_nokey)) VIRTUAL not null,
|
||||
col_time_key TIME GENERATED ALWAYS AS
|
||||
(ADDTIME(col_datetime_nokey, col_time_nokey)) VIRTUAL not null,
|
||||
|
||||
col_varchar_nokey VARCHAR(1) /*! NULL */,
|
||||
col_varchar_key VARCHAR(2) GENERATED ALWAYS AS
|
||||
(CONCAT(col_varchar_nokey, col_varchar_nokey)) VIRTUAL not null,
|
||||
|
||||
PRIMARY KEY (pk),
|
||||
UNIQUE KEY (col_int_key),
|
||||
UNIQUE KEY (col_varchar_key),
|
||||
UNIQUE KEY (col_date_key),
|
||||
KEY (col_time_key),
|
||||
KEY (col_datetime_key),
|
||||
UNIQUE KEY (col_int_key, col_varchar_key),
|
||||
KEY (col_int_key, col_int_nokey),
|
||||
KEY(col_int_key,col_date_key),
|
||||
KEY(col_int_key, col_time_key),
|
||||
KEY(col_int_key, col_datetime_key),
|
||||
UNIQUE
|
||||
KEY(col_date_key,col_time_key,col_datetime_key),
|
||||
UNIQUE KEY (col_varchar_key, col_varchar_nokey),
|
||||
UNIQUE KEY (col_int_key, col_varchar_key,
|
||||
col_date_key, col_time_key, col_datetime_key)
|
||||
) AUTO_INCREMENT=10 ENGINE=INNODB;
|
||||
|
||||
INSERT /*! IGNORE */ INTO bb (
|
||||
col_int_nokey,
|
||||
col_date_nokey,
|
||||
col_time_nokey,
|
||||
col_datetime_nokey,
|
||||
col_varchar_nokey
|
||||
) VALUES (0, '2003-08-04', '01:48:05.048577',
|
||||
'2006-11-03 00:00:00', 'p'),(2, '2007-11-06', '00:00:00', '2009-11-26 19:28:11.005115', 'n');
|
||||
|
||||
CREATE TABLE cc (
|
||||
pk INTEGER AUTO_INCREMENT,
|
||||
col_int_nokey INTEGER /*! NULL */,
|
||||
col_int_key INTEGER GENERATED ALWAYS AS
|
||||
(col_int_nokey + col_int_nokey) VIRTUAL not null,
|
||||
|
||||
col_date_nokey DATE /*! NULL */,
|
||||
col_date_key DATE GENERATED ALWAYS AS
|
||||
(DATE_ADD(col_date_nokey,interval 30 day)) VIRTUAL not null,
|
||||
|
||||
col_datetime_nokey DATETIME /*! NULL */,
|
||||
col_time_nokey TIME /*! NULL */,
|
||||
|
||||
col_datetime_key DATETIME GENERATED ALWAYS AS
|
||||
(ADDTIME(col_datetime_nokey, col_time_nokey)) VIRTUAL not null,
|
||||
col_time_key TIME GENERATED ALWAYS AS
|
||||
(ADDTIME(col_datetime_nokey, col_time_nokey)) VIRTUAL not null,
|
||||
|
||||
col_varchar_nokey VARCHAR(1) /*! NULL */,
|
||||
col_varchar_key VARCHAR(2) GENERATED ALWAYS AS
|
||||
(CONCAT(col_varchar_nokey, col_varchar_nokey)) VIRTUAL not null,
|
||||
|
||||
PRIMARY KEY (pk),
|
||||
UNIQUE KEY (col_int_key),
|
||||
UNIQUE KEY (col_varchar_key),
|
||||
UNIQUE KEY (col_date_key),
|
||||
KEY (col_time_key),
|
||||
KEY (col_datetime_key),
|
||||
UNIQUE KEY (col_int_key, col_varchar_key),
|
||||
KEY (col_int_key, col_int_nokey),
|
||||
KEY(col_int_key,col_date_key),
|
||||
KEY(col_int_key, col_time_key),
|
||||
KEY(col_int_key, col_datetime_key),
|
||||
UNIQUE
|
||||
KEY(col_date_key,col_time_key,col_datetime_key),
|
||||
UNIQUE KEY (col_varchar_key, col_varchar_nokey),
|
||||
UNIQUE KEY (col_int_key, col_varchar_key,
|
||||
col_date_key, col_time_key, col_datetime_key)
|
||||
) AUTO_INCREMENT=10 ENGINE=INNODB;
|
||||
|
||||
INSERT /*! IGNORE */ INTO cc (
|
||||
col_int_nokey,
|
||||
col_date_nokey,
|
||||
col_time_nokey,
|
||||
col_datetime_nokey,
|
||||
col_varchar_nokey
|
||||
) VALUES (172, '2009-04-23', '00:00:00', '2000-12-07 10:17:40.013275', 'h'),(NULL, '2002-10-06', '00:50:49.017545', NULL, 'm');
|
||||
|
||||
let $query=
|
||||
SELECT
|
||||
gp1 . col_datetime_key AS g1
|
||||
FROM cc AS gp1 LEFT JOIN c AS gp2 ON ( gp2 . col_datetime_key <> gp1 .
|
||||
col_time_nokey )
|
||||
WHERE
|
||||
gp1 . col_varchar_nokey IN
|
||||
(
|
||||
SELECT
|
||||
DISTINCT p1 . col_varchar_key AS p1
|
||||
FROM bb AS p1 LEFT JOIN bb AS p2
|
||||
ON ( p1 . col_int_key = p2 . pk )
|
||||
)
|
||||
AND gp1 . col_varchar_nokey = 'b'
|
||||
HAVING g1 > 6;
|
||||
|
||||
eval EXPLAIN $query;
|
||||
eval $query;
|
||||
DROP TABLE bb, c, cc;
|
||||
|
||||
--echo # Bug#21284646: Assertion !(table || table->read_set || bitmap_is_set())
|
||||
|
||||
CREATE TABLE c (
|
||||
pk INTEGER AUTO_INCREMENT,
|
||||
col_int_nokey INTEGER NOT NULL,
|
||||
col_int_key INTEGER GENERATED ALWAYS AS (col_int_nokey + col_int_nokey) VIRTUAL not null,
|
||||
col_date_nokey DATE NOT NULL,
|
||||
col_date_key DATE GENERATED ALWAYS AS (DATE_ADD(col_date_nokey,interval 30 day)) VIRTUAL not null,
|
||||
col_datetime_nokey DATETIME NOT NULL,
|
||||
col_time_nokey TIME NOT NULL,
|
||||
col_datetime_key DATETIME GENERATED ALWAYS AS (ADDTIME(col_datetime_nokey, col_time_nokey)) VIRTUAL not null,
|
||||
col_time_key TIME GENERATED ALWAYS AS (ADDTIME(col_datetime_nokey, col_time_nokey)) VIRTUAL not null,
|
||||
col_varchar_nokey VARCHAR(1) NOT NULL,
|
||||
col_varchar_key VARCHAR(2) GENERATED ALWAYS AS (CONCAT(col_varchar_nokey, col_varchar_nokey)) VIRTUAL not null,
|
||||
PRIMARY KEY (pk,col_int_nokey),
|
||||
UNIQUE KEY (col_int_key),
|
||||
UNIQUE KEY (col_varchar_key),
|
||||
UNIQUE KEY (col_date_key),
|
||||
KEY (col_time_key),
|
||||
KEY (col_datetime_key),
|
||||
UNIQUE KEY (col_int_key, col_varchar_key),
|
||||
KEY (col_int_key, col_int_nokey),
|
||||
KEY(col_int_key,col_date_key),
|
||||
KEY(col_int_key, col_time_key),
|
||||
KEY(col_int_key, col_datetime_key),
|
||||
UNIQUE KEY (col_date_key,col_time_key,col_datetime_key),
|
||||
UNIQUE KEY (col_varchar_key, col_varchar_nokey),
|
||||
UNIQUE KEY (col_int_key, col_varchar_key, col_date_key, col_time_key, col_datetime_key)
|
||||
) ENGINE=INNODB;
|
||||
|
||||
INSERT INTO c (col_int_nokey, col_date_nokey, col_time_nokey, col_datetime_nokey, col_varchar_nokey) VALUES
|
||||
(1, '2009-12-01', '00:21:38.058143', '2007-05-28 00:00:00', 'c'),
|
||||
(8, '2004-12-17', '04:08:02.046897', '2009-07-25 09:21:20.064099', 'm'),
|
||||
(9, '2000-03-14', '16:25:11.040240', '2002-01-16 00:00:00', 'd'),
|
||||
(6, '2006-05-25', '19:47:59.011283', '2001-02-15 03:08:38.035426', 'y'),
|
||||
(2, '2002-10-13', '00:00:00', '1900-01-01 00:00:00', 's'),
|
||||
(4, '1900-01-01', '15:57:25.019666', '2005-08-15 00:00:00', 'r');
|
||||
|
||||
ANALYZE TABLE c;
|
||||
let $query=
|
||||
SELECT COUNT(DISTINCT col_varchar_key) AS x
|
||||
FROM c
|
||||
WHERE col_varchar_key IN ('rr', 'rr') OR
|
||||
col_int_nokey <> 9 AND
|
||||
pk >= 8
|
||||
HAVING x > '2000-02-06'
|
||||
ORDER BY col_time_nokey, pk;
|
||||
|
||||
eval explain $query;
|
||||
eval $query;
|
||||
|
||||
DROP TABLE c;
|
||||
|
||||
--echo # Bug#21341044: Conditional jump at sort_param::make_sort_key
|
||||
|
||||
CREATE TABLE t1 (
|
||||
pk INTEGER AUTO_INCREMENT,
|
||||
col_int_nokey INTEGER /*! NULL */,
|
||||
col_int_key INTEGER GENERATED ALWAYS AS (col_int_nokey + col_int_nokey) VIRTUAL,
|
||||
col_blob_nokey BLOB /*! NULL */,
|
||||
col_blob_key BLOB GENERATED ALWAYS AS (REPEAT(col_blob_nokey,15)) VIRTUAL,
|
||||
col_longblob_nokey LONGBLOB /*! NULL */,
|
||||
col_longtext_nokey LONGTEXT /*! NULL */,
|
||||
col_longblob_key LONGBLOB GENERATED ALWAYS AS (REPEAT(col_longblob_nokey, 20)) VIRTUAL,
|
||||
col_longtext_key LONGTEXT GENERATED ALWAYS AS (REPEAT(col_longblob_nokey, 18)) VIRTUAL,
|
||||
col_text_nokey TEXT /*! NULL */,
|
||||
col_text_key TEXT GENERATED ALWAYS AS (REPEAT(col_text_nokey, 30)) VIRTUAL,
|
||||
PRIMARY KEY (pk),
|
||||
KEY (col_int_key),
|
||||
KEY (col_text_key(50)),
|
||||
KEY (col_blob_key(200)),
|
||||
KEY (col_longtext_key(200)),
|
||||
KEY (col_longblob_key(200)),
|
||||
KEY (col_int_key, col_text_key(100)),
|
||||
KEY (col_int_key, col_longtext_key(100)),
|
||||
KEY (col_int_key, col_blob_key(100)),
|
||||
KEY (col_int_key, col_longblob_key(100)),
|
||||
KEY (col_longtext_key(10), col_longblob_key(100)),
|
||||
KEY (col_int_key, col_text_key(10), col_blob_key(100), col_longtext_key(50), col_longblob_key(50))
|
||||
) engine=innodb;
|
||||
|
||||
INSERT INTO t1 (col_int_nokey,col_blob_nokey,col_longtext_nokey,col_longblob_nokey,col_text_nokey)
|
||||
VALUES
|
||||
(0, 'ijcszxw', 'ijcszxw', 'ijcszxw', 'ijcszxw'),
|
||||
(5, 'jcszxwb', 'jcszxwb', 'jcszxwb', 'jcszxwb'),
|
||||
(4, 'cszxwbjjvv', 'cszxwbjjvv', 'cszxwbjjvv', 'cszxwbjjvv'),
|
||||
(3, 'szxw', 'szxw', 'szxw', 'szxw'),
|
||||
(7, 'zxwb', 'zxwb', 'zxwb', 'zxwb'),
|
||||
(42, 'xwbjjvvky', 'xwbjjvvky', 'xwbjjvvky', 'xwbjjvvky'),
|
||||
(142, 'wbjj', 'wbjj', 'wbjj', 'wbjj'),
|
||||
(5, 'bjjv', 'bjjv', 'bjjv', 'bjjv'),
|
||||
(0, 'jjvvkymalu', 'jjvvkymalu', 'jjvvkymalu', 'jjvvkymalu'),
|
||||
(3, 'j', 'j', 'j', 'j');
|
||||
|
||||
SELECT alias1.pk AS field1
|
||||
FROM t1 AS alias1 LEFT OUTER JOIN t1 AS alias2
|
||||
ON alias1.col_int_key = alias2.col_int_key
|
||||
WHERE alias2.col_int_key BETWEEN 8 AND (8 + 1 ) OR
|
||||
alias2.col_int_key BETWEEN 8 AND (8 + 5 ) AND
|
||||
alias2.col_int_key != 20 OR
|
||||
alias2.col_int_key IN (8, 5, 8) AND
|
||||
alias2.col_int_key >= 0 AND
|
||||
alias2.col_int_key <= ( 8 + 75 ) AND
|
||||
alias1.pk IS NOT NULL
|
||||
ORDER BY field1;
|
||||
|
||||
DROP TABLE t1;
|
||||
--echo # bug#21487651: gcols: memory leak after failed alter table
|
||||
CREATE TABLE t(a int);
|
||||
ALTER TABLE t ADD COLUMN b int GENERATED ALWAYS AS (
|
||||
date_sub(a,interval a month)) VIRTUAL;
|
||||
--error 1111
|
||||
ALTER TABLE t ADD COLUMN c int GENERATED ALWAYS AS (sum(a));
|
||||
DROP TABLE t;
|
||||
|
||||
--echo #
|
||||
--echo # Bug#21628840: CRASH/MEMORY CORRUPTION ADDING INDEXES TO VIRTUAL COLUMN
|
||||
--echo # (II)
|
||||
--echo #
|
||||
CREATE TABLE t1( a INT ) ENGINE = INNODB;
|
||||
INSERT INTO t1( a ) VALUES ( 1 ), ( 2 ), ( 3 ), ( 4 ), ( 5 );
|
||||
|
||||
ALTER TABLE t1 ADD COLUMN b INT GENERATED ALWAYS AS (a - 1) STORED;
|
||||
ALTER TABLE t1 ADD COLUMN c INT GENERATED ALWAYS AS (b + 1) VIRTUAL;
|
||||
|
||||
--echo # Used to cause valgrind warning.
|
||||
ALTER TABLE t1 ADD INDEX( c );
|
||||
|
||||
ANALYZE TABLE t1;
|
||||
|
||||
--echo # Make sure the index is correct. That's kinda important.
|
||||
EXPLAIN
|
||||
SELECT c FROM t1;
|
||||
SELECT c FROM t1;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo #
|
||||
--echo # Bug#21797776 ASSERTION `BIT < MAP->N_BITS' FAILED.
|
||||
--echo #
|
||||
|
||||
CREATE TABLE C (
|
||||
col_int_1 INT,
|
||||
col_int_2 INT GENERATED ALWAYS AS (col_int_1 + col_int_1) STORED,
|
||||
col_int_3 INT GENERATED ALWAYS AS (col_int_2 + col_int_1) VIRTUAL
|
||||
);
|
||||
|
||||
CREATE ALGORITHM=TEMPTABLE VIEW v1 AS
|
||||
SELECT
|
||||
col_int_2 AS field1, col_int_2 AS field2,
|
||||
col_int_3 AS field3, col_int_3 AS field4
|
||||
FROM C;
|
||||
|
||||
SELECT * FROM v1;
|
||||
|
||||
DROP TABLE C;
|
||||
DROP VIEW v1;
|
||||
|
||||
--echo #
|
||||
--echo # Bug#21613615 GCOLS: ASSERTION FAILED: !TABLE || (!TABLE->READ_SET || BITMAP_IS_SET
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t (a INT);
|
||||
CREATE TABLE v (
|
||||
a INT,
|
||||
c INT,
|
||||
b CHAR(2) GENERATED ALWAYS AS (a IN (1)) VIRTUAL,
|
||||
KEY(c,b(1)));
|
||||
INSERT INTO v (a,c) VALUES (1,1);
|
||||
|
||||
let $query=
|
||||
SELECT 1 FROM t WHERE ( SELECT 1 FROM t ) >=ANY( SELECT c FROM v );
|
||||
eval EXPLAIN $query;
|
||||
eval $query;
|
||||
|
||||
# A similar one:
|
||||
let $query=
|
||||
SELECT (SELECT MAX(c) FROM v);
|
||||
eval EXPLAIN $query;
|
||||
eval $query;
|
||||
|
||||
DROP TABLE t, v;
|
||||
|
||||
CREATE TABLE v (
|
||||
a INT,
|
||||
c INT,
|
||||
b CHAR(2) GENERATED ALWAYS AS (a IN (1)) VIRTUAL, KEY(c,b(1)));
|
||||
INSERT INTO v (a,c) VALUES (1,1);
|
||||
SELECT MAX(c), COUNT(b) FROM v;
|
||||
DROP TABLE v;
|
||||
|
||||
# Using PK suffix of secondary index
|
||||
CREATE TABLE v (
|
||||
a INT PRIMARY KEY,
|
||||
b INT, KEY(b));
|
||||
INSERT INTO v (a,b) VALUES (1,1);
|
||||
SELECT MAX(a) FROM v WHERE b=1;
|
||||
DROP TABLE v;
|
||||
|
||||
--echo #
|
||||
--echo # Bug#21824519: ASSERTION IN DROP TRIGGER WHEN TABLE HAS
|
||||
--echo # VIRTUAL GENERATED COLUMN
|
||||
--echo #
|
||||
CREATE TABLE t (a INT, b INT GENERATED ALWAYS AS (a) VIRTUAL);
|
||||
CREATE TRIGGER tr BEFORE INSERT ON t FOR EACH ROW BEGIN END;
|
||||
INSERT INTO t (a) VALUES (1);
|
||||
SELECT * FROM t;
|
||||
# DROP TRIGGER used to hit a DBUG_ASSERT.
|
||||
DROP TRIGGER tr;
|
||||
SELECT * FROM t;
|
||||
CREATE FUNCTION f() RETURNS INT RETURN (SELECT COUNT(*) FROM t);
|
||||
# And this function call hit the same DBUG_ASSERT.
|
||||
SELECT f();
|
||||
DROP FUNCTION f;
|
||||
SELECT * FROM t;
|
||||
DROP TABLE t;
|
||||
|
||||
--echo #
|
||||
--echo # Bug#21833760 CALC_DAYNR: ASSERTION `DELSUM+(INT) Y/4-TEMP >= 0' FAILED.
|
||||
--echo #
|
||||
|
||||
CREATE TABLE C(
|
||||
c1 INT AUTO_INCREMENT,
|
||||
c8 DATETIME,
|
||||
c9 TIME,
|
||||
c11 TIME GENERATED ALWAYS AS(ADDTIME(c8,c9)) VIRTUAL,
|
||||
c13 TIME GENERATED ALWAYS AS(ADDTIME(c8,c11)) VIRTUAL,
|
||||
PRIMARY KEY(c1),
|
||||
UNIQUE KEY(c13)
|
||||
);
|
||||
|
||||
INSERT INTO C (c8,c9) VALUES('1970-01-01',0),('1970-01-01',1);
|
||||
|
||||
CREATE VIEW view_C AS SELECT * FROM C;
|
||||
|
||||
SELECT /*+ NO_BNL(t1) */ t1.c13 FROM C AS t2 STRAIGHT_JOIN C AS t1 FORCE INDEX(c13);
|
||||
SELECT DISTINCT t1.c13 FROM C AS t1, view_C AS t2;
|
||||
|
||||
DROP TABLE C;
|
||||
DROP VIEW view_C;
|
||||
|
||||
--echo #
|
||||
--echo # Bug #21808680: JSON + GENERATED COLUMN CORRUPTS TABLE CACHE
|
||||
--echo # MEMORY, CRASHES
|
||||
--echo #
|
||||
CREATE TABLE t (a INT, b JSON, c TEXT GENERATED ALWAYS AS (REPEAT(a=b, 2)));
|
||||
INSERT INTO t (a, b) VALUES (1, '2'), (3, '3');
|
||||
# The next statement used to crash.
|
||||
SELECT * FROM t;
|
||||
DROP TABLE t;
|
||||
|
||||
--echo #
|
||||
--echo # Bug#21810529: CRASH IN ITEM_FUNC::WALK WHEN CODE JUMPS TO GARBAGE
|
||||
--echo # LOCATION
|
||||
--echo #
|
||||
CREATE TABLE t (a TIME,b INT GENERATED ALWAYS AS (a=1) VIRTUAL);
|
||||
--error ER_BAD_FIELD_ERROR
|
||||
ALTER TABLE t CHANGE COLUMN q w INT;
|
||||
--error ER_BAD_FIELD_ERROR
|
||||
ALTER TABLE t CHANGE COLUMN q w INT;
|
||||
--error ER_BAD_FIELD_ERROR
|
||||
ALTER TABLE t CHANGE COLUMN q w INT;
|
||||
--error ER_BAD_FIELD_ERROR
|
||||
ALTER TABLE t CHANGE COLUMN q w INT;
|
||||
DROP TABLE t;
|
||||
|
||||
--echo #
|
||||
--echo # Bug#21940542 TOO MUCH SPAM: INNODB: COMPUTE VIRTUAL COLUMN VALUES FAILED
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t(b BLOB);
|
||||
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
ALTER TABLE t ADD COLUMN c INT GENERATED ALWAYS AS ((1,1)) VIRTUAL;
|
||||
DROP TABLE t;
|
||||
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
||||
CREATE TABLE t(b BLOB, c INT GENERATED ALWAYS AS ((1,1)) VIRTUAL);
|
||||
|
||||
--echo #
|
||||
--echo # Bug#21929967 GCOLS: GCOL VALUE CHANGES WHEN SESSION CHANGES SQL_MODE
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1(a CHAR(1), b CHAR(1), c CHAR(2) AS (a || b));
|
||||
SHOW CREATE TABLE t1;
|
||||
INSERT INTO t1 (a,b) VALUES('1','1');
|
||||
SELECT * FROM t1;
|
||||
SET SQL_MODE=PIPES_AS_CONCAT;
|
||||
SELECT * FROM t1;
|
||||
FLUSH TABLES;
|
||||
SELECT * FROM t1;
|
||||
DROP TABLE t1;
|
||||
# The other way around:
|
||||
CREATE TABLE t1(a CHAR(1), b CHAR(1), c CHAR(2) AS (a || b));
|
||||
SHOW CREATE TABLE t1;
|
||||
INSERT INTO t1 (a,b) VALUES('1','1');
|
||||
SELECT * FROM t1;
|
||||
SET SQL_MODE=DEFAULT;
|
||||
SELECT * FROM t1;
|
||||
FLUSH TABLES;
|
||||
SELECT * FROM t1;
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo # Bug#22018999: gcols: assertion failed: !error
|
||||
|
||||
SET @save_old_sql_mode= @@sql_mode;
|
||||
SET sql_mode="";
|
||||
|
||||
--error ER_TRUNCATED_WRONG_VALUE
|
||||
CREATE TABLE t (a INTEGER AS (SUBSTR('','a',1))) engine=innodb;
|
||||
|
||||
CREATE TABLE t (a INTEGER) engine=innodb;
|
||||
|
||||
--error ER_TRUNCATED_WRONG_VALUE
|
||||
ALTER TABLE t ADD b INTEGER AS (SUBSTR('','a',1));
|
||||
|
||||
DROP TABLE t;
|
||||
|
||||
set sql_mode= @save_old_sql_mode;
|
||||
|
||||
--echo # Bug#21875520 Problems with virtual column indexes
|
||||
|
||||
CREATE TABLE t(
|
||||
a TIMESTAMP,
|
||||
b BLOB,
|
||||
c TIMESTAMP GENERATED ALWAYS AS (GREATEST(a, '2000-01-01 00:00:00')) VIRTUAL,
|
||||
UNIQUE KEY(c)
|
||||
);
|
||||
INSERT INTO t(b) VALUES ('');
|
||||
UPDATE t SET a='2001-01-01 00:00:00';
|
||||
SELECT c FROM t;
|
||||
SELECT c, a FROM t;
|
||||
UPDATE t SET b='xyz';
|
||||
DO (SELECT @c1:= c FROM t);
|
||||
DO (SELECT (@c2:= c) - a FROM t);
|
||||
SELECT @c2 - @c1;
|
||||
|
||||
DROP TABLE t;
|
||||
|
||||
--echo #
|
||||
--echo # Bug#22133710 GCOLS: READ UNCOMMITTED: ASSERT !TABLE || (!TABLE->WRITE_SET || BITMAP_IS_SET(TA
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t (
|
||||
a INT,
|
||||
b INT GENERATED ALWAYS AS (1) VIRTUAL,
|
||||
c INT GENERATED ALWAYS AS (1) VIRTUAL,
|
||||
d INT GENERATED ALWAYS AS (1) VIRTUAL,
|
||||
KEY (b,d)
|
||||
) ENGINE=INNODB;
|
||||
INSERT INTO t VALUES();
|
||||
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED ;
|
||||
SELECT 1 FROM t WHERE c GROUP BY b;
|
||||
COMMIT;
|
||||
DROP TABLE t;
|
47
mysql-test/suite/gcol/t/gcol_column_def_options_innodb.test
Normal file
47
mysql-test/suite/gcol/t/gcol_column_def_options_innodb.test
Normal file
|
@ -0,0 +1,47 @@
|
|||
################################################################################
|
||||
# t/gcol_column_def_options_innodb.test #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Testing different optional parameters of generated 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
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
--source include/have_innodb.inc
|
||||
eval SET @@session.default_storage_engine = 'InnoDB';
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
let $support_virtual_index= 0;
|
||||
--source suite/gcol/inc/gcol_column_def_options.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/gcol/inc/gcol_cleanup.inc
|
47
mysql-test/suite/gcol/t/gcol_column_def_options_myisam.test
Normal file
47
mysql-test/suite/gcol/t/gcol_column_def_options_myisam.test
Normal file
|
@ -0,0 +1,47 @@
|
|||
################################################################################
|
||||
# t/gcol_column_def_options_myisam.test #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Testing different optional parameters of generated 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
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
eval SET @@session.default_storage_engine = 'MyISAM';
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
let $support_virtual_index= 0;
|
||||
let $support_virtual_foreign= 0;
|
||||
--source suite/gcol/inc/gcol_column_def_options.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/gcol/inc/gcol_cleanup.inc
|
46
mysql-test/suite/gcol/t/gcol_handler_innodb.test
Normal file
46
mysql-test/suite/gcol/t/gcol_handler_innodb.test
Normal file
|
@ -0,0 +1,46 @@
|
|||
################################################################################
|
||||
# t/gcol_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
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
--source include/have_innodb.inc
|
||||
eval SET @@session.default_storage_engine = 'InnoDB';
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
--source suite/gcol/inc/gcol_handler.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/gcol/inc/gcol_cleanup.inc
|
45
mysql-test/suite/gcol/t/gcol_handler_myisam.test
Normal file
45
mysql-test/suite/gcol/t/gcol_handler_myisam.test
Normal file
|
@ -0,0 +1,45 @@
|
|||
################################################################################
|
||||
# t/gcol_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
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
eval SET @@session.default_storage_engine = 'MyISAM';
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
--source suite/gcol/inc/gcol_handler.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/gcol/inc/gcol_cleanup.inc
|
47
mysql-test/suite/gcol/t/gcol_ins_upd_innodb.test
Normal file
47
mysql-test/suite/gcol/t/gcol_ins_upd_innodb.test
Normal file
|
@ -0,0 +1,47 @@
|
|||
################################################################################
|
||||
# t/gcol_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
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
--source include/have_innodb.inc
|
||||
eval SET @@session.default_storage_engine = 'InnoDB';
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
let $support_virtual_index= 0;
|
||||
--source suite/gcol/inc/gcol_ins_upd.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/gcol/inc/gcol_cleanup.inc
|
46
mysql-test/suite/gcol/t/gcol_ins_upd_myisam.test
Normal file
46
mysql-test/suite/gcol/t/gcol_ins_upd_myisam.test
Normal file
|
@ -0,0 +1,46 @@
|
|||
################################################################################
|
||||
# t/gcol_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
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
eval SET @@session.default_storage_engine = 'MyISAM';
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
let $support_virtual_index= 0;
|
||||
--source suite/gcol/inc/gcol_ins_upd.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/gcol/inc/gcol_cleanup.inc
|
89
mysql-test/suite/gcol/t/gcol_keys_innodb.test
Normal file
89
mysql-test/suite/gcol/t/gcol_keys_innodb.test
Normal file
|
@ -0,0 +1,89 @@
|
|||
################################################################################
|
||||
# t/gcol_keys_innodb.test #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Testing keys, indexes defined upon generated 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
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
--source include/have_innodb.inc
|
||||
eval SET @@session.default_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;
|
||||
let $support_virtual_index= 0;
|
||||
--source suite/gcol/inc/gcol_keys.inc
|
||||
|
||||
if ($support_virtual_index) {
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
--echo #
|
||||
--echo # BUG#21365158 WL8149:ASSERTION `!TABLE || (!TABLE->WRITE_SET
|
||||
--echo #
|
||||
CREATE TABLE t1 (
|
||||
pk INTEGER AUTO_INCREMENT,
|
||||
col_int_nokey INTEGER NOT NULL,
|
||||
col_varchar_nokey VARCHAR(1),
|
||||
col_varchar_key VARCHAR(2) GENERATED ALWAYS AS
|
||||
(CONCAT(col_varchar_nokey, col_varchar_nokey)) VIRTUAL,
|
||||
PRIMARY KEY (pk)
|
||||
);
|
||||
|
||||
INSERT INTO t1 ( col_int_nokey, col_varchar_nokey)
|
||||
VALUES (4, 'b'),(9, 'o'),(4, 'k'),(5, 'a'),(5, 'f'),
|
||||
(9, 't'),(3, 'c'),(8, 'c'),(0, 'r'),(98, 'k');
|
||||
|
||||
CREATE TABLE t2 (
|
||||
pk INTEGER AUTO_INCREMENT,
|
||||
col_int_nokey INTEGER NOT NULL,
|
||||
col_varchar_nokey VARCHAR(1) NOT NULL,
|
||||
col_varchar_key VARCHAR(2) GENERATED ALWAYS AS
|
||||
(CONCAT(col_varchar_nokey, col_varchar_nokey)) VIRTUAL,
|
||||
PRIMARY KEY (pk),
|
||||
UNIQUE KEY (col_varchar_key)
|
||||
);
|
||||
|
||||
INSERT INTO t2 ( col_int_nokey, col_varchar_nokey)
|
||||
VALUES (1, 'c'),(8, 'm'),(9, 'd'), (6, 'y'),(1, 't'),
|
||||
(2, 's'),(4, 'r');
|
||||
|
||||
SELECT
|
||||
CONCAT( t2.col_varchar_nokey , t2.col_varchar_nokey ) AS f2,
|
||||
t1.col_varchar_key AS f5
|
||||
FROM
|
||||
t2 LEFT JOIN t1 ON t2.col_int_nokey > t1.col_int_nokey
|
||||
ORDER BY f2, f5;
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
--echo #
|
||||
|
||||
}
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/gcol/inc/gcol_cleanup.inc
|
46
mysql-test/suite/gcol/t/gcol_keys_myisam.test
Normal file
46
mysql-test/suite/gcol/t/gcol_keys_myisam.test
Normal file
|
@ -0,0 +1,46 @@
|
|||
################################################################################
|
||||
# t/gcol_keys_myisam.test #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Testing keys, indexes defined upon generated 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
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
eval SET @@session.default_storage_engine = 'MyISAM';
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
let $support_virtual_index= 0;
|
||||
--source suite/gcol/inc/gcol_keys.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/gcol/inc/gcol_cleanup.inc
|
43
mysql-test/suite/gcol/t/gcol_memory.test
Normal file
43
mysql-test/suite/gcol/t/gcol_memory.test
Normal file
|
@ -0,0 +1,43 @@
|
|||
################################################################################
|
||||
# t/gcol_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
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
SET @@session.default_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/gcol/inc/gcol_unsupported_storage_engines.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/gcol/inc/gcol_cleanup.inc
|
52
mysql-test/suite/gcol/t/gcol_merge.test
Normal file
52
mysql-test/suite/gcol/t/gcol_merge.test
Normal file
|
@ -0,0 +1,52 @@
|
|||
################################################################################
|
||||
# t/gcol_merge.test #
|
||||
# #
|
||||
# Purpose: #
|
||||
# MERGE branch #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# Original Author: Andrey Zhakov #
|
||||
# Original Date: 2008-09-03 #
|
||||
# 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
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# 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 generated always as (a % 10) virtual);
|
||||
create table t2 (a int, b int generated always as (a % 10) virtual);
|
||||
insert into t1 values (1,default);
|
||||
insert into t2 values (2,default);
|
||||
--error ER_UNSUPPORTED_ENGINE_FOR_VIRTUAL_COLUMNS
|
||||
create table t3 (a int, b int generated always as (a % 10) virtual) engine=MERGE UNION=(t1,t2);
|
||||
drop table t1,t2;
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/gcol/inc/gcol_cleanup.inc
|
48
mysql-test/suite/gcol/t/gcol_non_stored_columns_innodb.test
Normal file
48
mysql-test/suite/gcol/t/gcol_non_stored_columns_innodb.test
Normal file
|
@ -0,0 +1,48 @@
|
|||
################################################################################
|
||||
# t/gcol_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
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
--source include/have_innodb.inc
|
||||
eval SET @@session.default_storage_engine = 'InnoDB';
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
--source suite/gcol/inc/gcol_non_stored_columns.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/gcol/inc/gcol_cleanup.inc
|
47
mysql-test/suite/gcol/t/gcol_non_stored_columns_myisam.test
Normal file
47
mysql-test/suite/gcol/t/gcol_non_stored_columns_myisam.test
Normal file
|
@ -0,0 +1,47 @@
|
|||
################################################################################
|
||||
# t/gcol_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
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
eval SET @@session.default_storage_engine = 'MyISAM';
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
--source suite/gcol/inc/gcol_non_stored_columns.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/gcol/inc/gcol_cleanup.inc
|
46
mysql-test/suite/gcol/t/gcol_partition_innodb.test
Normal file
46
mysql-test/suite/gcol/t/gcol_partition_innodb.test
Normal file
|
@ -0,0 +1,46 @@
|
|||
################################################################################
|
||||
# t/gcol_partition_innodb.test #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Testing partitioning tables with generated 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
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
--source include/have_innodb.inc
|
||||
eval SET @@session.default_storage_engine = 'InnoDB';
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
--source suite/gcol/inc/gcol_partition.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/gcol/inc/gcol_cleanup.inc
|
45
mysql-test/suite/gcol/t/gcol_partition_myisam.test
Normal file
45
mysql-test/suite/gcol/t/gcol_partition_myisam.test
Normal file
|
@ -0,0 +1,45 @@
|
|||
################################################################################
|
||||
# t/gcol_partition_myisam.test #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Testing partitioning tables with generated 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
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
eval SET @@session.default_storage_engine = 'MyISAM';
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
--source suite/gcol/inc/gcol_partition.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/gcol/inc/gcol_cleanup.inc
|
41
mysql-test/suite/gcol/t/gcol_rejected_innodb.test
Normal file
41
mysql-test/suite/gcol/t/gcol_rejected_innodb.test
Normal file
|
@ -0,0 +1,41 @@
|
|||
################################################################################
|
||||
# t/gcol_handler_innodb.test #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Testing rejected generated column additions.
|
||||
# #
|
||||
# InnoDB branch #
|
||||
# #
|
||||
################################################################################
|
||||
|
||||
#
|
||||
# NOTE: PLEASE DO NOT ADD NOT INNODB 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
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
--source include/have_innodb.inc
|
||||
eval SET @@session.default_storage_engine = 'InnoDB';
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
# @todo This test is broken for all VIRTUAL columns
|
||||
#--source suite/gcol/inc/gcol_rejected.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/gcol/inc/gcol_cleanup.inc
|
108
mysql-test/suite/gcol/t/gcol_rollback.test
Normal file
108
mysql-test/suite/gcol/t/gcol_rollback.test
Normal file
|
@ -0,0 +1,108 @@
|
|||
--source include/have_debug.inc
|
||||
--source include/have_innodb.inc
|
||||
--source include/have_debug_sync.inc
|
||||
--source include/not_embedded.inc
|
||||
|
||||
# Save the initial number of concurrent sessions.
|
||||
--source include/count_sessions.inc
|
||||
|
||||
CREATE TABLE t (
|
||||
a INTEGER,
|
||||
b BLOB GENERATED ALWAYS AS (a) VIRTUAL,
|
||||
INDEX (b(57))
|
||||
)ENGINE=INNODB;
|
||||
|
||||
INSERT INTO t (a) VALUES (9);
|
||||
BEGIN;
|
||||
SAVEPOINT a;
|
||||
UPDATE t set a = 12;
|
||||
DELETE FROM t where a = 12;
|
||||
ROLLBACK TO SAVEPOINT a;
|
||||
COMMIT;
|
||||
|
||||
CHECK TABLE t;
|
||||
|
||||
SELECT * FROM t;
|
||||
|
||||
BEGIN;
|
||||
INSERT INTO t (a) VALUES (10);
|
||||
--source include/kill_and_restart_mysqld.inc
|
||||
SELECT * FROM t;
|
||||
DROP TABLE t;
|
||||
|
||||
CREATE TABLE t (
|
||||
a INTEGER,
|
||||
b BLOB GENERATED ALWAYS AS (a) VIRTUAL,
|
||||
c INTEGER
|
||||
)ENGINE=INNODB;
|
||||
|
||||
INSERT INTO t (a,c) VALUES (9, 10);
|
||||
SELECT * FROM t;
|
||||
|
||||
connect (con1,localhost,root,,);
|
||||
connection con1;
|
||||
|
||||
# This DEBUG_SYNC should not kick in yet, because the duplicate key will be
|
||||
# detected before we get a chance to apply the online log.
|
||||
|
||||
SET DEBUG_SYNC = 'row_log_apply_after SIGNAL created WAIT_FOR dml_done';
|
||||
--send
|
||||
ALTER TABLE t ADD KEY(b(57)), ALGORITHM=INPLACE;
|
||||
|
||||
connection default;
|
||||
SET DEBUG_SYNC = 'now WAIT_FOR created';
|
||||
BEGIN;
|
||||
INSERT INTO t (a,c) VALUES (10, 12);
|
||||
SELECT * FROM t;
|
||||
ROLLBACK;
|
||||
SET DEBUG_SYNC = 'now SIGNAL dml_done';
|
||||
|
||||
connection con1;
|
||||
reap;
|
||||
disconnect con1;
|
||||
connection default;
|
||||
|
||||
SELECT * FROM t;
|
||||
DROP TABLE t;
|
||||
|
||||
# drop virtual column and alter index
|
||||
CREATE TABLE t (
|
||||
a INT,
|
||||
b INT,
|
||||
c INT GENERATED ALWAYS AS(a+b),
|
||||
d INT GENERATED ALWAYS AS(a+b+b),
|
||||
KEY(c, d)
|
||||
)ENGINE=INNODB;
|
||||
|
||||
INSERT INTO t (a,b) VALUES (9, 10);
|
||||
SELECT * FROM t;
|
||||
|
||||
connect (con1,localhost,root,,);
|
||||
connection con1;
|
||||
|
||||
# This DEBUG_SYNC should not kick in yet, because the duplicate key will be
|
||||
# detected before we get a chance to apply the online log.
|
||||
|
||||
SET DEBUG_SYNC = 'row_log_apply_after SIGNAL created WAIT_FOR dml_done';
|
||||
--send
|
||||
ALTER TABLE t DROP COLUMN c, ALGORITHM=INPLACE;
|
||||
|
||||
connection default;
|
||||
SET DEBUG_SYNC = 'now WAIT_FOR created';
|
||||
BEGIN;
|
||||
INSERT INTO t (a,b) VALUES (10, 12);
|
||||
SELECT * FROM t;
|
||||
ROLLBACK;
|
||||
SET DEBUG_SYNC = 'now SIGNAL dml_done';
|
||||
|
||||
connection con1;
|
||||
reap;
|
||||
disconnect con1;
|
||||
connection default;
|
||||
|
||||
SELECT * FROM t;
|
||||
|
||||
DROP TABLE t;
|
||||
|
||||
# Wait till all disconnects are completed
|
||||
--source include/wait_until_count_sessions.inc
|
53
mysql-test/suite/gcol/t/gcol_select_innodb.test
Normal file
53
mysql-test/suite/gcol/t/gcol_select_innodb.test
Normal file
|
@ -0,0 +1,53 @@
|
|||
################################################################################
|
||||
# t/gcol_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/gcol/inc/gcol_cleanup.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# General not engine specific settings and requirements
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
--source include/have_innodb.inc
|
||||
eval SET @@session.default_storage_engine = 'InnoDB';
|
||||
eval SET optimizer_switch='derived_merge=off';
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
let $support_virtual_index= 0;
|
||||
--source suite/gcol/inc/gcol_select.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
eval SET optimizer_switch='derived_merge=default';
|
||||
--source suite/gcol/inc/gcol_cleanup.inc
|
52
mysql-test/suite/gcol/t/gcol_select_myisam.test
Normal file
52
mysql-test/suite/gcol/t/gcol_select_myisam.test
Normal file
|
@ -0,0 +1,52 @@
|
|||
################################################################################
|
||||
# t/gcol_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/gcol/inc/gcol_cleanup.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# General not engine specific settings and requirements
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
eval SET @@session.default_storage_engine = 'MyISAM';
|
||||
eval SET optimizer_switch='derived_merge=off';
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
let $support_virtual_index= 0;
|
||||
--source suite/gcol/inc/gcol_select.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
eval SET optimizer_switch='derived_merge=default';
|
||||
--source suite/gcol/inc/gcol_cleanup.inc
|
45
mysql-test/suite/gcol/t/gcol_supported_sql_funcs_innodb.test
Normal file
45
mysql-test/suite/gcol/t/gcol_supported_sql_funcs_innodb.test
Normal file
|
@ -0,0 +1,45 @@
|
|||
################################################################################
|
||||
# t/gcol_supported_sql_funcs.test #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Test SQL functions allowed for generated 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
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
--source include/have_innodb.inc
|
||||
SET @@session.default_storage_engine = 'InnoDB';
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
--source suite/gcol/inc/gcol_supported_sql_funcs_main.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/gcol/inc/gcol_cleanup.inc
|
44
mysql-test/suite/gcol/t/gcol_supported_sql_funcs_myisam.test
Normal file
44
mysql-test/suite/gcol/t/gcol_supported_sql_funcs_myisam.test
Normal file
|
@ -0,0 +1,44 @@
|
|||
################################################################################
|
||||
# t/gcol_supported_sql_funcs.test #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Test SQL functions allowed for generated 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
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
eval SET @@session.default_storage_engine = 'MyISAM';
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
--source suite/gcol/inc/gcol_supported_sql_funcs_main.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/gcol/inc/gcol_cleanup.inc
|
47
mysql-test/suite/gcol/t/gcol_trigger_sp_innodb.test
Normal file
47
mysql-test/suite/gcol/t/gcol_trigger_sp_innodb.test
Normal file
|
@ -0,0 +1,47 @@
|
|||
################################################################################
|
||||
# t/gcol_trigger_sp_innodb.test #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Testing triggers, stored procedures and functions #
|
||||
# defined on tables with generated 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
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
--source include/have_innodb.inc
|
||||
eval SET @@session.default_storage_engine = 'InnoDB';
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
--source suite/gcol/inc/gcol_trigger_sp.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/gcol/inc/gcol_cleanup.inc
|
46
mysql-test/suite/gcol/t/gcol_trigger_sp_myisam.test
Normal file
46
mysql-test/suite/gcol/t/gcol_trigger_sp_myisam.test
Normal file
|
@ -0,0 +1,46 @@
|
|||
################################################################################
|
||||
# t/gcol_trigger_sp_myisam.test #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Testing triggers, stored procedures and functions #
|
||||
# defined on tables with generated 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
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
eval SET @@session.default_storage_engine = 'MyISAM';
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
--source suite/gcol/inc/gcol_trigger_sp.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/gcol/inc/gcol_cleanup.inc
|
56
mysql-test/suite/gcol/t/gcol_update.test
Normal file
56
mysql-test/suite/gcol/t/gcol_update.test
Normal file
|
@ -0,0 +1,56 @@
|
|||
--source include/have_debug.inc
|
||||
--source include/have_innodb.inc
|
||||
# The embedded server does not support restarting.
|
||||
--source include/not_embedded.inc
|
||||
|
||||
set global innodb_purge_stop_now = 1;
|
||||
|
||||
# Index on virtual column
|
||||
|
||||
create table t1(f1 int not null, f2 blob not null, f3 blob not null,
|
||||
vchar char(2) as (substr(f3,2,2)) virtual,
|
||||
primary key(f1, f3(5)), index(vchar))engine=innodb;
|
||||
|
||||
insert into t1(f1,f2,f3) values(1, repeat('a',8000), repeat('b', 9000));
|
||||
|
||||
update t1 set f1=5 where f1=1;
|
||||
delete from t1 where f1=5;
|
||||
|
||||
set global innodb_purge_run_now=1;
|
||||
set global innodb_fast_shutdown=0;
|
||||
--source include/restart_mysqld.inc
|
||||
set global innodb_purge_stop_now = 1;
|
||||
drop table t1;
|
||||
|
||||
# Index on virtual column and blob
|
||||
|
||||
create table t1(f1 int not null, f2 blob not null, f3 blob not null,
|
||||
vchar char(2) as (substr(f3,2,2)) virtual,
|
||||
primary key(f1, f3(5)), index(vchar, f3(2)))engine=innodb;
|
||||
|
||||
insert into t1(f1,f2,f3) values(1, repeat('a',8000), repeat('b', 9000));
|
||||
|
||||
update t1 set f1=5 where f1=1;
|
||||
delete from t1 where f1=5;
|
||||
|
||||
set global innodb_purge_run_now=1;
|
||||
set global innodb_fast_shutdown=0;
|
||||
--source include/restart_mysqld.inc
|
||||
set global innodb_purge_stop_now = 1;
|
||||
drop table t1;
|
||||
|
||||
# Index on virtual column of blob type
|
||||
|
||||
create table t1(f1 int not null, f2 blob not null, f3 blob not null,
|
||||
vchar blob as (f3) virtual,
|
||||
primary key(f1, f3(5)), index(vchar(3)))engine=innodb;
|
||||
|
||||
insert into t1(f1,f2,f3) values(1, repeat('a',8000), repeat('b', 9000));
|
||||
|
||||
update t1 set f1=5 where f1=1;
|
||||
delete from t1 where f1=5;
|
||||
|
||||
set global innodb_purge_run_now=1;
|
||||
set global innodb_fast_shutdown=0;
|
||||
--source include/restart_mysqld.inc
|
||||
drop table t1;
|
46
mysql-test/suite/gcol/t/gcol_view_innodb.test
Normal file
46
mysql-test/suite/gcol/t/gcol_view_innodb.test
Normal file
|
@ -0,0 +1,46 @@
|
|||
################################################################################
|
||||
# t/gcol_view_innodb.test #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Testing views defined on tables with generated 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
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
--source include/have_innodb.inc
|
||||
eval SET @@session.default_storage_engine = 'InnoDB';
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
--source suite/gcol/inc/gcol_view.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/gcol/inc/gcol_cleanup.inc
|
45
mysql-test/suite/gcol/t/gcol_view_myisam.test
Normal file
45
mysql-test/suite/gcol/t/gcol_view_myisam.test
Normal file
|
@ -0,0 +1,45 @@
|
|||
################################################################################
|
||||
# t/gcol_view_myisam.test #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Testing views defined on tables with generated 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
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
eval SET @@session.default_storage_engine = 'MyISAM';
|
||||
|
||||
##### Workarounds for known open engine specific bugs
|
||||
# none
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute the tests to be applied to all storage engines
|
||||
--source suite/gcol/inc/gcol_view.inc
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Execute storage engine specific tests
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Cleanup
|
||||
--source suite/gcol/inc/gcol_cleanup.inc
|
65
mysql-test/suite/gcol/t/rpl_gcol.test
Normal file
65
mysql-test/suite/gcol/t/rpl_gcol.test
Normal file
|
@ -0,0 +1,65 @@
|
|||
################################################################################
|
||||
# t/gcol_rpl.test #
|
||||
# #
|
||||
# Purpose: #
|
||||
# Test replication of tables with generated columns. #
|
||||
# #
|
||||
#------------------------------------------------------------------------------#
|
||||
# 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
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
# Engine specific settings and requirements
|
||||
|
||||
##### Storage engine to be tested
|
||||
# Set the session storage engine
|
||||
--source include/have_innodb.inc
|
||||
SET @@session.default_storage_engine = 'InnoDB';
|
||||
|
||||
##### 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 generated always as (a+1) virtual);
|
||||
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/gcol/inc/gcol_cleanup.inc
|
||||
--source include/rpl_end.inc
|
|
@ -1,15 +1,15 @@
|
|||
create table t1 (c2 int as (-c1), c1 int primary key auto_increment) engine=innodb;
|
||||
create table t1 (c2 int as (1+1), c1 int primary key auto_increment) engine=innodb;
|
||||
insert into t1(c1) values (null),(null),(null);
|
||||
select * from t1;
|
||||
c2 c1
|
||||
-1 1
|
||||
-2 2
|
||||
-3 3
|
||||
2 1
|
||||
2 2
|
||||
2 3
|
||||
alter table t1 auto_increment = 3;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`c2` int(11) AS (-c1) VIRTUAL,
|
||||
`c2` int(11) AS (1+1) VIRTUAL,
|
||||
`c1` int(11) NOT NULL AUTO_INCREMENT,
|
||||
PRIMARY KEY (`c1`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
--source include/have_innodb.inc
|
||||
|
||||
create table t1 (c2 int as (-c1), c1 int primary key auto_increment) engine=innodb;
|
||||
create table t1 (c2 int as (1+1), c1 int primary key auto_increment) engine=innodb;
|
||||
insert into t1(c1) values (null),(null),(null);
|
||||
select * from t1;
|
||||
alter table t1 auto_increment = 3;
|
||||
|
|
|
@ -615,7 +615,7 @@ public:
|
|||
name.length= 0;
|
||||
};
|
||||
~Virtual_column_info() {}
|
||||
enum_field_types get_real_type()
|
||||
enum_field_types get_real_type() const
|
||||
{
|
||||
return field_type;
|
||||
}
|
||||
|
@ -624,7 +624,7 @@ public:
|
|||
/* Calling this function can only be done once. */
|
||||
field_type= fld_type;
|
||||
}
|
||||
bool is_stored()
|
||||
bool is_stored() const
|
||||
{
|
||||
return stored_in_db;
|
||||
}
|
||||
|
@ -632,7 +632,7 @@ public:
|
|||
{
|
||||
stored_in_db= stored;
|
||||
}
|
||||
bool is_in_partitioning_expr()
|
||||
bool is_in_partitioning_expr() const
|
||||
{
|
||||
return in_partitioning_expr;
|
||||
}
|
||||
|
@ -640,7 +640,7 @@ public:
|
|||
{
|
||||
in_partitioning_expr= TRUE;
|
||||
}
|
||||
bool is_equal(Virtual_column_info* vcol)
|
||||
bool is_equal(const Virtual_column_info* vcol) const
|
||||
{
|
||||
return field_type == vcol->get_real_type()
|
||||
&& stored_in_db == vcol->is_stored()
|
||||
|
|
13
sql/item.cc
13
sql/item.cc
|
@ -948,7 +948,8 @@ bool Item_field::register_field_in_write_map(void *arg)
|
|||
- All fields that have default value as a constant are initialized first.
|
||||
- Then user-specified values from the INSERT list
|
||||
- Then all fields that has a default expression, in field_index order.
|
||||
- Last all virtual fields, in field_index order.
|
||||
- Then all virtual fields, in field_index order.
|
||||
- Then auto-increment values
|
||||
|
||||
This means:
|
||||
- For default fields we can't access the same field or a field after
|
||||
|
@ -956,6 +957,7 @@ bool Item_field::register_field_in_write_map(void *arg)
|
|||
- A virtual fields can't access itself or a virtual field after itself.
|
||||
- user-specified values will not see virtual fields or default expressions,
|
||||
as in INSERT t1 (a) VALUES (b);
|
||||
- no virtual fields can access auto-increment values
|
||||
|
||||
This is used by fix_vcol_expr() when a table is opened
|
||||
|
||||
|
@ -965,11 +967,18 @@ bool Item_field::register_field_in_write_map(void *arg)
|
|||
|
||||
bool Item_field::check_field_expression_processor(void *arg)
|
||||
{
|
||||
Field *org_field= (Field*) arg;
|
||||
if (field->flags & NO_DEFAULT_VALUE_FLAG)
|
||||
return 0;
|
||||
if (field->flags & AUTO_INCREMENT_FLAG)
|
||||
{
|
||||
my_error(ER_EXPRESSION_REFERS_TO_UNINIT_FIELD,
|
||||
MYF(0),
|
||||
org_field->field_name, field->field_name);
|
||||
return 1;
|
||||
}
|
||||
if ((field->default_value && field->default_value->flags) || field->vcol_info)
|
||||
{
|
||||
Field *org_field= (Field*) arg;
|
||||
if (field == org_field ||
|
||||
(!org_field->vcol_info && field->vcol_info) ||
|
||||
(((field->vcol_info && org_field->vcol_info) ||
|
||||
|
|
11
sql/item.h
11
sql/item.h
|
@ -1628,7 +1628,7 @@ public:
|
|||
return mark_unsupported_function(full_name(), arg, VCOL_IMPOSSIBLE);
|
||||
}
|
||||
virtual bool check_field_expression_processor(void *arg) { return 0; }
|
||||
|
||||
virtual bool check_func_default_processor(void *arg) { return 0; }
|
||||
/*
|
||||
Check if an expression value has allowed arguments, like DATE/DATETIME
|
||||
for date functions. Also used by partitioning code to reject
|
||||
|
@ -3347,9 +3347,11 @@ public:
|
|||
}
|
||||
|
||||
bool check_partition_func_processor(void *int_arg) {return TRUE;}
|
||||
bool check_vcol_func_processor(void *arg)
|
||||
{
|
||||
return mark_unsupported_function(func_name, arg, VCOL_IMPOSSIBLE);
|
||||
|
||||
bool check_vcol_func_processor(void *arg)
|
||||
{ // VCOL_TIME_FUNC because the value is not constant, but does not
|
||||
// require fix_fields() to be re-run for every statement.
|
||||
return mark_unsupported_function(func_name, arg, VCOL_TIME_FUNC);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -5094,6 +5096,7 @@ public:
|
|||
table_map used_tables() const { return (table_map)0L; }
|
||||
Item_field *field_for_view_update() { return 0; }
|
||||
bool update_vcol_processor(void *arg) { return 0; }
|
||||
bool check_func_default_processor(void *arg) { return true; }
|
||||
|
||||
bool walk(Item_processor processor, bool walk_subquery, void *args)
|
||||
{
|
||||
|
|
|
@ -6222,6 +6222,15 @@ static int compare_uint(const uint *s, const uint *t)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
Check if the column is computed and either
|
||||
is stored or is used in the partitioning expression.
|
||||
*/
|
||||
static bool vcol_affecting_storage(const Virtual_column_info* vcol)
|
||||
{
|
||||
return vcol && (vcol->is_stored() || vcol->is_in_partitioning_expr());
|
||||
}
|
||||
|
||||
/**
|
||||
Compare original and new versions of a table and fill Alter_inplace_info
|
||||
describing differences between those versions.
|
||||
|
@ -6428,14 +6437,11 @@ static bool fill_alter_inplace_info(THD *thd,
|
|||
ha_alter_info->handler_flags|= Alter_inplace_info::ALTER_COLUMN_TYPE;
|
||||
}
|
||||
|
||||
/*
|
||||
Check if the column is computed and either
|
||||
is stored or is used in the partitioning expression.
|
||||
*/
|
||||
if (field->vcol_info &&
|
||||
(field->stored_in_db() || field->vcol_info->is_in_partitioning_expr()))
|
||||
if (vcol_affecting_storage(field->vcol_info) ||
|
||||
vcol_affecting_storage(new_field->vcol_info))
|
||||
{
|
||||
if (is_equal == IS_EQUAL_NO ||
|
||||
!field->vcol_info || !new_field->vcol_info ||
|
||||
!field->vcol_info->is_equal(new_field->vcol_info))
|
||||
ha_alter_info->handler_flags|= Alter_inplace_info::ALTER_COLUMN_VCOL;
|
||||
else
|
||||
|
|
Loading…
Add table
Reference in a new issue