summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Fiala <df@natsys-lab.com>2016-06-19 07:38:28 +0100
committerAleksey Midenkov <midenok@gmail.com>2017-05-05 20:35:08 +0300
commitbe6f2d302cd71677e1fafbeea9347c196f21e1bd (patch)
tree2814467d8c5585f852a47bef2caabea808b1c60d
parent14bdfa85416471e4ccd4aaa65397f282a2b508c3 (diff)
downloadmariadb-git-be6f2d302cd71677e1fafbeea9347c196f21e1bd.tar.gz
0.1: SQL-level System Versioning
-rw-r--r--include/mysql_com.h10
-rw-r--r--mysql-test/extra/binlog_tests/blackhole.test4
-rw-r--r--mysql-test/include/common-tests.inc76
-rw-r--r--mysql-test/r/auto_increment.result59
-rw-r--r--mysql-test/r/compress.result114
-rw-r--r--mysql-test/r/create.result91
-rw-r--r--mysql-test/r/delete.result86
-rw-r--r--mysql-test/r/fulltext.result2
-rw-r--r--mysql-test/r/func_group.result2
-rw-r--r--mysql-test/r/func_time.result2
-rw-r--r--mysql-test/r/func_time_hires.result10
-rw-r--r--mysql-test/r/insert.result109
-rw-r--r--mysql-test/r/insert_select.result118
-rw-r--r--mysql-test/r/insert_update.result90
-rw-r--r--mysql-test/r/multi_update.result212
-rw-r--r--mysql-test/r/named_pipe.result114
-rw-r--r--mysql-test/r/pool_of_threads.result114
-rw-r--r--mysql-test/r/select.result179
-rw-r--r--mysql-test/r/select_jcl6.result179
-rw-r--r--mysql-test/r/select_pkeycache.result179
-rw-r--r--mysql-test/r/shm.result114
-rw-r--r--mysql-test/r/ssl.result114
-rw-r--r--mysql-test/r/ssl_compress.result114
-rw-r--r--mysql-test/r/update.result100
-rw-r--r--mysql-test/r/variables.result165
-rw-r--r--mysql-test/suite/archive/archive.result10
-rw-r--r--mysql-test/suite/archive/archive.test4
-rw-r--r--mysql-test/suite/binlog/r/binlog_stm_blackhole.result10
-rw-r--r--mysql-test/suite/csv/csv.result16
-rw-r--r--mysql-test/suite/csv/csv.test8
-rw-r--r--mysql-test/suite/funcs_1/r/innodb_views.result8
-rw-r--r--mysql-test/suite/funcs_1/r/memory_views.result8
-rw-r--r--mysql-test/suite/funcs_1/r/myisam_views-big.result8
-rw-r--r--mysql-test/suite/funcs_1/r/storedproc.result11
-rw-r--r--mysql-test/suite/innodb_fts/r/fulltext.result2
-rw-r--r--mysql-test/suite/sys_vars/r/delay_key_write_basic.result4
-rw-r--r--mysql-test/suite/sys_vars/r/foreign_key_checks_basic.result4
-rw-r--r--mysql-test/suite/sys_vars/r/innodb_support_xa_basic.result227
-rw-r--r--mysql-test/suite/sys_vars/r/innodb_table_locks_basic.result4
-rw-r--r--mysql-test/suite/sys_vars/r/keep_files_on_create_basic.result4
-rw-r--r--mysql-test/suite/sys_vars/r/log_bin_trust_function_creators_basic.result4
-rw-r--r--mysql-test/suite/sys_vars/r/low_priority_updates_basic.result4
-rw-r--r--mysql-test/suite/sys_vars/r/old_passwords_basic.result4
-rw-r--r--mysql-test/suite/sys_vars/r/optimizer_prune_level_basic.result2
-rw-r--r--mysql-test/suite/sys_vars/r/pseudo_slave_mode_basic.result4
-rw-r--r--mysql-test/suite/sys_vars/r/query_cache_wlock_invalidate_basic.result8
-rw-r--r--mysql-test/suite/sys_vars/r/sql_big_selects_basic.result4
-rw-r--r--mysql-test/suite/sys_vars/r/sql_big_tables_basic.result2
-rw-r--r--mysql-test/suite/sys_vars/r/sql_buffer_result_basic.result4
-rw-r--r--mysql-test/suite/sys_vars/r/sql_log_bin_basic.result4
-rw-r--r--mysql-test/suite/sys_vars/r/sql_log_off_basic.result4
-rw-r--r--mysql-test/suite/sys_vars/r/sql_low_priority_updates_basic.result4
-rw-r--r--mysql-test/suite/sys_vars/r/sql_notes_basic.result4
-rw-r--r--mysql-test/suite/sys_vars/r/sql_quote_show_create_basic.result4
-rw-r--r--mysql-test/suite/sys_vars/r/sql_safe_updates_basic.result4
-rw-r--r--mysql-test/suite/sys_vars/r/sql_warnings_basic.result4
-rw-r--r--mysql-test/suite/sys_vars/r/tx_read_only_basic.result4
-rw-r--r--mysql-test/suite/sys_vars/t/delay_key_write_basic.test2
-rw-r--r--mysql-test/suite/sys_vars/t/foreign_key_checks_basic.test2
-rw-r--r--mysql-test/suite/sys_vars/t/innodb_support_xa_basic.test240
-rw-r--r--mysql-test/suite/sys_vars/t/innodb_table_locks_basic.test4
-rw-r--r--mysql-test/suite/sys_vars/t/keep_files_on_create_basic.test2
-rw-r--r--mysql-test/suite/sys_vars/t/log_bin_trust_function_creators_basic.test2
-rw-r--r--mysql-test/suite/sys_vars/t/low_priority_updates_basic.test2
-rw-r--r--mysql-test/suite/sys_vars/t/old_passwords_basic.test2
-rw-r--r--mysql-test/suite/sys_vars/t/optimizer_prune_level_basic.test2
-rw-r--r--mysql-test/suite/sys_vars/t/pseudo_slave_mode_basic.test2
-rw-r--r--mysql-test/suite/sys_vars/t/query_cache_wlock_invalidate_basic.test4
-rw-r--r--mysql-test/suite/sys_vars/t/sql_big_selects_basic.test2
-rw-r--r--mysql-test/suite/sys_vars/t/sql_buffer_result_basic.test2
-rw-r--r--mysql-test/suite/sys_vars/t/sql_log_bin_basic.test2
-rw-r--r--mysql-test/suite/sys_vars/t/sql_log_off_basic.test2
-rw-r--r--mysql-test/suite/sys_vars/t/sql_notes_basic.test2
-rw-r--r--mysql-test/suite/sys_vars/t/sql_quote_show_create_basic.test2
-rw-r--r--mysql-test/suite/sys_vars/t/sql_safe_updates_basic.test2
-rw-r--r--mysql-test/suite/sys_vars/t/sql_warnings_basic.test2
-rw-r--r--mysql-test/suite/sys_vars/t/tx_read_only_basic.test2
-rw-r--r--mysql-test/t/auto_increment.test34
-rw-r--r--mysql-test/t/create.test98
-rw-r--r--mysql-test/t/delete.test44
-rw-r--r--mysql-test/t/insert.test73
-rw-r--r--mysql-test/t/insert_select.test65
-rw-r--r--mysql-test/t/insert_update.test45
-rw-r--r--mysql-test/t/multi_update.test116
-rw-r--r--mysql-test/t/select.test110
-rw-r--r--mysql-test/t/update.test39
-rw-r--r--mysql-test/t/variables.test160
-rw-r--r--sql/field.cc16
-rw-r--r--sql/field.h67
-rw-r--r--sql/handler.h43
-rw-r--r--sql/item_timefunc.cc9
-rw-r--r--sql/item_timefunc.h3
-rw-r--r--sql/lex.h4
-rw-r--r--sql/share/errmsg-utf8.txt47
-rw-r--r--sql/sql_base.cc19
-rw-r--r--sql/sql_class.h11
-rw-r--r--sql/sql_delete.cc49
-rw-r--r--sql/sql_insert.cc90
-rw-r--r--sql/sql_insert.h1
-rw-r--r--sql/sql_lex.cc24
-rw-r--r--sql/sql_lex.h6
-rw-r--r--sql/sql_parse.cc64
-rw-r--r--sql/sql_select.cc113
-rw-r--r--sql/sql_show.cc25
-rw-r--r--sql/sql_table.cc132
-rw-r--r--sql/sql_trigger.h2
-rw-r--r--sql/sql_update.cc140
-rw-r--r--sql/sql_view.cc4
-rw-r--r--sql/sql_yacc.yy159
-rw-r--r--sql/table.cc124
-rw-r--r--sql/table.h100
-rw-r--r--sql/unireg.cc80
-rw-r--r--sql/unireg.h1
-rw-r--r--storage/tokudb/mysql-test/tokudb/r/tokudb_support_xa.result2
-rw-r--r--storage/tokudb/mysql-test/tokudb/t/tokudb_support_xa.test2
115 files changed, 4055 insertions, 1101 deletions
diff --git a/include/mysql_com.h b/include/mysql_com.h
index ace54767b06..904a64b08f8 100644
--- a/include/mysql_com.h
+++ b/include/mysql_com.h
@@ -184,6 +184,16 @@ enum enum_indicator_type
#define FIELD_FLAGS_COLUMN_FORMAT_MASK (3U << FIELD_FLAGS_COLUMN_FORMAT)
#define FIELD_IS_DROPPED (1U << 26) /* Intern: Field is being dropped */
+#define GENERATED_ROW_START_FLAG (1 << 27) /* autogenerated column declared with
+ `generated always at row start`
+ (see II.a SQL Standard) */
+#define GENERATED_ROW_END_FLAG (1 << 28) /* autogenerated column declared with
+ `generated always at row end`
+ (see II.a SQL Standard).*/
+#define WITHOUT_SYSTEM_VERSIONING_FLAG (1 << 29) /* column that doesn't support
+ system versioning when table
+ itself supports it*/
+
#define REFRESH_GRANT (1ULL << 0) /* Refresh grant tables */
#define REFRESH_LOG (1ULL << 1) /* Start on new log file */
#define REFRESH_TABLES (1ULL << 2) /* close all tables */
diff --git a/mysql-test/extra/binlog_tests/blackhole.test b/mysql-test/extra/binlog_tests/blackhole.test
index 90146d41471..0ffd24adc03 100644
--- a/mysql-test/extra/binlog_tests/blackhole.test
+++ b/mysql-test/extra/binlog_tests/blackhole.test
@@ -17,13 +17,13 @@ drop table if exists t1,t2;
--enable_warnings
CREATE TABLE t1 (
- Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
+ Period_ smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL
) ENGINE=blackhole;
INSERT INTO t1 VALUES (9410,9412);
-select period from t1;
+select period_ from t1;
select * from t1;
select t1.* from t1;
diff --git a/mysql-test/include/common-tests.inc b/mysql-test/include/common-tests.inc
index 204b6d4dd6b..c0ed1427215 100644
--- a/mysql-test/include/common-tests.inc
+++ b/mysql-test/include/common-tests.inc
@@ -14,13 +14,13 @@ drop table if exists t1,t2,t3,t4;
--enable_warnings
CREATE TABLE t1 (
- Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
+ Period_ smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL
);
INSERT INTO t1 VALUES (9410,9412);
-select period from t1;
+select period_ from t1;
select * from t1;
select t1.* from t1;
@@ -1349,7 +1349,7 @@ select fld1,fld3 from t2 where fld1 like "25050_";
select distinct companynr from t2;
select distinct companynr from t2 order by companynr;
select distinct companynr from t2 order by companynr desc;
-select distinct t2.fld3,period from t2,t1 where companynr=37 and fld3 like "O%";
+select distinct t2.fld3,period_ from t2,t1 where companynr=37 and fld3 like "O%";
select distinct fld3 from t2 where companynr = 34 order by fld3;
select distinct fld3 from t2 limit 10;
@@ -1362,26 +1362,26 @@ select distinct substring(fld3,1,3) as a from t2 having a like "A%" limit 10;
# make a big table.
create table t3 (
- period int not null,
+ period_ int not null,
name char(32) not null,
companynr int not null,
price double(11,0),
price2 double(11,0),
- key (period),
+ key (period_),
key (name)
);
--disable_query_log
-INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1001,"Iranizes",37,5987435,234724);
-INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1002,"violinist",37,28357832,8723648);
-INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1003,"extramarital",37,39654943,235872);
-INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1004,"spates",78,726498,72987523);
-INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1005,"cloakroom",78,98439034,823742);
-INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1006,"gazer",101,834598,27348324);
-INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1007,"hand",154,983543950,29837423);
-INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1008,"tucked",311,234298,3275892);
-INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1009,"gems",447,2374834,9872392);
-INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1010,"clinker",512,786542,76234234);
+INSERT INTO t3 (period_,name,companynr,price,price2) VALUES (1001,"Iranizes",37,5987435,234724);
+INSERT INTO t3 (period_,name,companynr,price,price2) VALUES (1002,"violinist",37,28357832,8723648);
+INSERT INTO t3 (period_,name,companynr,price,price2) VALUES (1003,"extramarital",37,39654943,235872);
+INSERT INTO t3 (period_,name,companynr,price,price2) VALUES (1004,"spates",78,726498,72987523);
+INSERT INTO t3 (period_,name,companynr,price,price2) VALUES (1005,"cloakroom",78,98439034,823742);
+INSERT INTO t3 (period_,name,companynr,price,price2) VALUES (1006,"gazer",101,834598,27348324);
+INSERT INTO t3 (period_,name,companynr,price,price2) VALUES (1007,"hand",154,983543950,29837423);
+INSERT INTO t3 (period_,name,companynr,price,price2) VALUES (1008,"tucked",311,234298,3275892);
+INSERT INTO t3 (period_,name,companynr,price,price2) VALUES (1009,"gems",447,2374834,9872392);
+INSERT INTO t3 (period_,name,companynr,price,price2) VALUES (1010,"clinker",512,786542,76234234);
--enable_query_log
create temporary table tmp engine = myisam select * from t3;
@@ -1450,39 +1450,39 @@ explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2
# Some test with ORDER BY and limit
#
-explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period;
-explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10;
-explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10;
+explain select * from t3 as t1,t3 where t1.period_=t3.period_ order by t3.period_;
+explain select * from t3 as t1,t3 where t1.period_=t3.period_ order by t3.period_ limit 10;
+explain select * from t3 as t1,t3 where t1.period_=t3.period_ order by t1.period_ limit 10;
#
# Search with a constant table.
#
-select period from t1;
-select period from t1 where period=1900;
-select fld3,period from t1,t2 where fld1 = 011401 order by period;
+select period_ from t1;
+select period_ from t1 where period_=1900;
+select fld3,period_ from t1,t2 where fld1 = 011401 order by period_;
#
# Search with a constant table and several keyparts. (Rows are read only once
# in the beginning of the search)
#
-select fld3,period from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.period=1001;
+select fld3,period_ from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.period_=1001;
-explain select fld3,period from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period;
+explain select fld3,period_ from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period_;
#
# Search with a constant table and several rows from another table
#
-select fld3,period from t2,t1 where companynr*10 = 37*10;
+select fld3,period_ from t2,t1 where companynr*10 = 37*10;
#
# Search with a table reference and without a key.
# t3 will be the main table.
#
-select fld3,period,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period >= 1001 and period <= 1002 and t2.companynr = 37 order by fld3,period, price;
+select fld3,period_,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period_ >= 1001 and period_ <= 1002 and t2.companynr = 37 order by fld3,period_, price;
#
# Search with an interval on a table with full key on reference table.
@@ -1490,7 +1490,7 @@ select fld3,period,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period >= 1
# t2nr will be checked.
#
-select t2.fld1,fld3,period,price,price2 from t2,t3 where t2.fld1>= 18201 and t2.fld1 <= 18811 and t2.fld1=t3.t2nr and period = 1001 and t2.companynr = 37;
+select t2.fld1,fld3,period_,price,price2 from t2,t3 where t2.fld1>= 18201 and t2.fld1 <= 18811 and t2.fld1=t3.t2nr and period_ = 1001 and t2.companynr = 37;
#
# We need another table for join stuff..
@@ -1588,18 +1588,18 @@ explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=
# each record
#
-select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008;
+select t2.fld1,t2.companynr,fld3,period_ from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period_ = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period_ = 1008;
-select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t2.fld1 = 38208 or t2.fld1 = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009;
+select t2.fld1,t2.companynr,fld3,period_ from t3,t2 where (t2.fld1 = 38208 or t2.fld1 = 38008) and t2.fld1=t3.t2nr and period_>=1008 and period_<=1009;
-select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t3.t2nr = 38208 or t3.t2nr = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009;
+select t2.fld1,t2.companynr,fld3,period_ from t3,t2 where (t3.t2nr = 38208 or t3.t2nr = 38008) and t2.fld1=t3.t2nr and period_>=1008 and period_<=1009;
#
# Test of many parenthesis levels
#
-select period from t1 where (((period > 0) or period < 10000 or (period = 1900)) and (period=1900 and period <= 1901) or (period=1903 and (period=1903)) and period>=1902) or ((period=1904 or period=1905) or (period=1906 or period>1907)) or (period=1908 and period = 1909);
-select period from t1 where ((period > 0 and period < 1) or (((period > 0 and period < 100) and (period > 10)) or (period > 10)) or (period > 0 and (period > 5 or period > 6)));
+select period_ from t1 where (((period_ > 0) or period_ < 10000 or (period_ = 1900)) and (period_=1900 and period_ <= 1901) or (period_=1903 and (period_=1903)) and period_>=1902) or ((period_=1904 or period_=1905) or (period_=1906 or period_>1907)) or (period_=1908 and period_ = 1909);
+select period_ from t1 where ((period_ > 0 and period_ < 1) or (((period_ > 0 and period_ < 100) and (period_ > 10)) or (period_ > 10)) or (period_ > 0 and (period_ > 5 or period_ > 6)));
select a.fld1 from t2 as a,t2 b where ((a.fld1 = 250501 and a.fld1=b.fld1) or a.fld1=250502 or a.fld1=250503 or (a.fld1=250505 and a.fld1<=b.fld1 and b.fld1>=a.fld1)) and a.fld1=b.fld1;
@@ -1657,7 +1657,7 @@ select t2.fld1,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 grou
# Calculation with group functions
#
-select sum(Period)/count(*) from t1;
+select sum(Period_)/count(*) from t1;
select companynr,count(price) as "count",sum(price) as "sum" ,abs(sum(price)/count(price)-avg(price)) as "diff",(0+count(price))*companynr as func from t3 group by companynr;
select companynr,sum(price)/count(price) as avg from t3 group by companynr having avg > 70000000 order by avg;
@@ -1747,13 +1747,13 @@ select max(t2nr) from t3 where price=983543950;
# Test of alias
#
-select t1.period from t3 = t1 limit 1;
-select t1.period from t1 as t1 limit 1;
-select t1.period as "Nuvarande period" from t1 as t1 limit 1;
-select period as ok_period from t1 limit 1;
-select period as ok_period from t1 group by ok_period limit 1;
+select t1.period_ from t3 = t1 limit 1;
+select t1.period_ from t1 as t1 limit 1;
+select t1.period_ as "Nuvarande period_" from t1 as t1 limit 1;
+select period_ as ok_period from t1 limit 1;
+select period_ as ok_period from t1 group by ok_period limit 1;
select 1+1 as summa from t1 group by summa limit 1;
-select period as "Nuvarande period" from t1 group by "Nuvarande period" limit 1;
+select period_ as "Nuvarande period_" from t1 group by "Nuvarande period_" limit 1;
#
# Some simple show commands
diff --git a/mysql-test/r/auto_increment.result b/mysql-test/r/auto_increment.result
index 12cbf294b69..bb684d1930f 100644
--- a/mysql-test/r/auto_increment.result
+++ b/mysql-test/r/auto_increment.result
@@ -537,3 +537,62 @@ pk
-5
1
drop table t1;
+#
+# System Versioning Support
+#
+#
+CREATE TABLE t1(id INT UNSIGNED AUTO_INCREMENT, x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end), PRIMARY KEY (id)) WITH SYSTEM VERSIONING;
+CREATE TABLE T1(id INT UNSIGNED AUTO_INCREMENT, x INT UNSIGNED, y INT UNSIGNED, PRIMARY KEY (id));
+INSERT INTO t1(x, y) VALUES(1, 11);
+INSERT INTO T1(x, y) VALUES(1, 11);
+INSERT INTO t1(x, y) VALUES(2, 12);
+INSERT INTO T1(x, y) VALUES(2, 12);
+INSERT INTO t1(x, y) VALUES(3, 13);
+INSERT INTO T1(x, y) VALUES(3, 13);
+INSERT INTO t1(x, y) VALUES(4, 14);
+INSERT INTO T1(x, y) VALUES(4, 14);
+INSERT INTO t1(x, y) VALUES(5, 15);
+INSERT INTO T1(x, y) VALUES(5, 15);
+INSERT INTO t1(x, y) VALUES(6, 16);
+INSERT INTO T1(x, y) VALUES(6, 16);
+INSERT INTO t1(x, y) VALUES(7, 17);
+INSERT INTO T1(x, y) VALUES(7, 17);
+INSERT INTO t1(x, y) VALUES(8, 18);
+INSERT INTO T1(x, y) VALUES(8, 18);
+INSERT INTO t1(x, y) VALUES(9, 19);
+INSERT INTO T1(x, y) VALUES(9, 19);
+SELECT t1.x = T1.x AND t1.y = T1.y, t1.x, t1.y, T1.x, T1.y FROM t1 INNER JOIN T1 ON(t1.id = T1.id);
+t1.x = T1.x AND t1.y = T1.y x y x y
+1 1 11 1 11
+1 2 12 2 12
+1 3 13 3 13
+1 4 14 4 14
+1 5 15 5 15
+1 6 16 6 16
+1 7 17 7 17
+1 8 18 8 18
+1 9 19 9 19
+DELETE FROM t1 WHERE x=2;
+DELETE FROM T1 WHERE x=2;
+SELECT t1.x = T1.x AND t1.y = T1.y, t1.x, t1.y, T1.x, T1.y FROM t1 INNER JOIN T1 ON(t1.id = T1.id);
+t1.x = T1.x AND t1.y = T1.y x y x y
+1 1 11 1 11
+1 3 13 3 13
+1 4 14 4 14
+1 5 15 5 15
+1 6 16 6 16
+1 7 17 7 17
+1 8 18 8 18
+1 9 19 9 19
+DELETE FROM t1 WHERE x>7;
+DELETE FROM T1 WHERE x>7;
+SELECT t1.x = T1.x AND t1.y = T1.y, t1.x, t1.y, T1.x, T1.y FROM t1 INNER JOIN T1 ON(t1.id = T1.id);
+t1.x = T1.x AND t1.y = T1.y x y x y
+1 1 11 1 11
+1 3 13 3 13
+1 4 14 4 14
+1 5 15 5 15
+1 6 16 6 16
+1 7 17 7 17
+DROP TABLE t1;
+DROP TABLE T1;
diff --git a/mysql-test/r/compress.result b/mysql-test/r/compress.result
index 762ab6630d8..b16a95cc702 100644
--- a/mysql-test/r/compress.result
+++ b/mysql-test/r/compress.result
@@ -7,18 +7,18 @@ VARIABLE_NAME VARIABLE_VALUE
COMPRESSION ON
drop table if exists t1,t2,t3,t4;
CREATE TABLE t1 (
-Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
+Period_ smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL
);
INSERT INTO t1 VALUES (9410,9412);
-select period from t1;
-period
+select period_ from t1;
+period_
9410
select * from t1;
-Period Varor_period
+Period_ Varor_period
9410 9412
select t1.* from t1;
-Period Varor_period
+Period_ Varor_period
9410 9412
CREATE TABLE t2 (
auto int not null auto_increment,
@@ -282,8 +282,8 @@ companynr
34
29
00
-select distinct t2.fld3,period from t2,t1 where companynr=37 and fld3 like "O%";
-fld3 period
+select distinct t2.fld3,period_ from t2,t1 where companynr=37 and fld3 like "O%";
+fld3 period_
obliterates 9410
offload 9410
opaquely 9410
@@ -487,12 +487,12 @@ acu
Ade
adj
create table t3 (
-period int not null,
+period_ int not null,
name char(32) not null,
companynr int not null,
price double(11,0),
price2 double(11,0),
-key (period),
+key (period_),
key (name)
);
create temporary table tmp engine = myisam select * from t3;
@@ -606,35 +606,35 @@ explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL fld1 NULL NULL NULL 1199 Using where; Using temporary; Using filesort
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.fld1 1 Using where; Using index
-explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period;
+explain select * from t3 as t1,t3 where t1.period_=t3.period_ order by t3.period_;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using filesort
-1 SIMPLE t3 ref period period 4 test.t1.period 4181
-explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10;
+1 SIMPLE t1 ALL period_ NULL NULL NULL 41810 Using filesort
+1 SIMPLE t3 ref period_ period_ 4 test.t1.period_ 4181
+explain select * from t3 as t1,t3 where t1.period_=t3.period_ order by t3.period_ limit 10;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 index period period 4 NULL 1
-1 SIMPLE t1 ref period period 4 test.t3.period 4181
-explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10;
+1 SIMPLE t3 index period_ period_ 4 NULL 1
+1 SIMPLE t1 ref period_ period_ 4 test.t3.period_ 4181
+explain select * from t3 as t1,t3 where t1.period_=t3.period_ order by t1.period_ limit 10;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index period period 4 NULL 1
-1 SIMPLE t3 ref period period 4 test.t1.period 4181
-select period from t1;
-period
+1 SIMPLE t1 index period_ period_ 4 NULL 1
+1 SIMPLE t3 ref period_ period_ 4 test.t1.period_ 4181
+select period_ from t1;
+period_
9410
-select period from t1 where period=1900;
-period
-select fld3,period from t1,t2 where fld1 = 011401 order by period;
-fld3 period
+select period_ from t1 where period_=1900;
+period_
+select fld3,period_ from t1,t2 where fld1 = 011401 order by period_;
+fld3 period_
breaking 9410
-select fld3,period from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.period=1001;
-fld3 period
+select fld3,period_ from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.period_=1001;
+fld3 period_
breaking 1001
-explain select fld3,period from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period;
+explain select fld3,period_ from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period_;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 const fld1 fld1 4 const 1
-1 SIMPLE t3 const PRIMARY,period PRIMARY 4 const 1
-select fld3,period from t2,t1 where companynr*10 = 37*10;
-fld3 period
+1 SIMPLE t3 const PRIMARY,period_ PRIMARY 4 const 1
+select fld3,period_ from t2,t1 where companynr*10 = 37*10;
+fld3 period_
breaking 9410
Romans 9410
intercepted 9410
@@ -1223,8 +1223,8 @@ dusted 9410
encompasses 9410
presentation 9410
Kantian 9410
-select fld3,period,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period >= 1001 and period <= 1002 and t2.companynr = 37 order by fld3,period, price;
-fld3 period price price2
+select fld3,period_,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period_ >= 1001 and period_ <= 1002 and t2.companynr = 37 order by fld3,period_, price;
+fld3 period_ price price2
admonishing 1002 28357832 8723648
analyzable 1002 28357832 8723648
annihilates 1001 5987435 234724
@@ -1284,8 +1284,8 @@ ventilate 1001 5987435 234724
wallet 1001 5987435 234724
Weissmuller 1002 28357832 8723648
Wotan 1002 28357832 8723648
-select t2.fld1,fld3,period,price,price2 from t2,t3 where t2.fld1>= 18201 and t2.fld1 <= 18811 and t2.fld1=t3.t2nr and period = 1001 and t2.companynr = 37;
-fld1 fld3 period price price2
+select t2.fld1,fld3,period_,price,price2 from t2,t3 where t2.fld1>= 18201 and t2.fld1 <= 18811 and t2.fld1=t3.t2nr and period_ = 1001 and t2.companynr = 37;
+fld1 fld3 period_ price price2
018201 relaxing 1001 5987435 234724
018601 vacuuming 1001 5987435 234724
018801 inch 1001 5987435 234724
@@ -1325,7 +1325,7 @@ companynr companyname
65 company 9
68 company 10
select * from t1,t1 t12;
-Period Varor_period Period Varor_period
+Period_ Varor_period Period_ Varor_period
9410 9412 9410 9412
select t2.fld1,t22.fld1 from t2,t2 t22 where t2.fld1 >= 250501 and t2.fld1 <= 250505 and t22.fld1 >= 250501 and t22.fld1 <= 250505;
fld1 fld1
@@ -1440,23 +1440,23 @@ explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 index NULL PRIMARY 1 NULL 12 Using index; Using temporary
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where; Using join buffer (flat, BNL join)
-select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008;
-fld1 companynr fld3 period
+select t2.fld1,t2.companynr,fld3,period_ from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period_ = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period_ = 1008;
+fld1 companynr fld3 period_
038008 37 reporters 1008
038208 37 Selfridge 1008
-select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t2.fld1 = 38208 or t2.fld1 = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009;
-fld1 companynr fld3 period
+select t2.fld1,t2.companynr,fld3,period_ from t3,t2 where (t2.fld1 = 38208 or t2.fld1 = 38008) and t2.fld1=t3.t2nr and period_>=1008 and period_<=1009;
+fld1 companynr fld3 period_
038008 37 reporters 1008
038208 37 Selfridge 1008
-select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t3.t2nr = 38208 or t3.t2nr = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009;
-fld1 companynr fld3 period
+select t2.fld1,t2.companynr,fld3,period_ from t3,t2 where (t3.t2nr = 38208 or t3.t2nr = 38008) and t2.fld1=t3.t2nr and period_>=1008 and period_<=1009;
+fld1 companynr fld3 period_
038008 37 reporters 1008
038208 37 Selfridge 1008
-select period from t1 where (((period > 0) or period < 10000 or (period = 1900)) and (period=1900 and period <= 1901) or (period=1903 and (period=1903)) and period>=1902) or ((period=1904 or period=1905) or (period=1906 or period>1907)) or (period=1908 and period = 1909);
-period
+select period_ from t1 where (((period_ > 0) or period_ < 10000 or (period_ = 1900)) and (period_=1900 and period_ <= 1901) or (period_=1903 and (period_=1903)) and period_>=1902) or ((period_=1904 or period_=1905) or (period_=1906 or period_>1907)) or (period_=1908 and period_ = 1909);
+period_
9410
-select period from t1 where ((period > 0 and period < 1) or (((period > 0 and period < 100) and (period > 10)) or (period > 10)) or (period > 0 and (period > 5 or period > 6)));
-period
+select period_ from t1 where ((period_ > 0 and period_ < 1) or (((period_ > 0 and period_ < 100) and (period_ > 10)) or (period_ > 10)) or (period_ > 0 and (period_ > 5 or period_ > 6)));
+period_
9410
select a.fld1 from t2 as a,t2 b where ((a.fld1 = 250501 and a.fld1=b.fld1) or a.fld1=250502 or a.fld1=250503 or (a.fld1=250505 and a.fld1<=b.fld1 and b.fld1>=a.fld1)) and a.fld1=b.fld1;
fld1
@@ -1713,8 +1713,8 @@ companynr companyname count(*)
select t2.fld1,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name;
fld1 count(*)
158402 4181
-select sum(Period)/count(*) from t1;
-sum(Period)/count(*)
+select sum(Period_)/count(*) from t1;
+sum(Period_)/count(*)
9410.0000
select companynr,count(price) as "count",sum(price) as "sum" ,abs(sum(price)/count(price)-avg(price)) as "diff",(0+count(price))*companynr as func from t3 group by companynr;
companynr count sum diff func
@@ -2044,26 +2044,26 @@ t2nr count(*)
select max(t2nr) from t3 where price=983543950;
max(t2nr)
41807
-select t1.period from t3 = t1 limit 1;
-period
+select t1.period_ from t3 = t1 limit 1;
+period_
1001
-select t1.period from t1 as t1 limit 1;
-period
+select t1.period_ from t1 as t1 limit 1;
+period_
9410
-select t1.period as "Nuvarande period" from t1 as t1 limit 1;
-Nuvarande period
+select t1.period_ as "Nuvarande period_" from t1 as t1 limit 1;
+Nuvarande period_
9410
-select period as ok_period from t1 limit 1;
+select period_ as ok_period from t1 limit 1;
ok_period
9410
-select period as ok_period from t1 group by ok_period limit 1;
+select period_ as ok_period from t1 group by ok_period limit 1;
ok_period
9410
select 1+1 as summa from t1 group by summa limit 1;
summa
2
-select period as "Nuvarande period" from t1 group by "Nuvarande period" limit 1;
-Nuvarande period
+select period_ as "Nuvarande period_" from t1 group by "Nuvarande period_" limit 1;
+Nuvarande period_
9410
show tables;
Tables_in_test
diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result
index 81b65c420cd..941ba2837d2 100644
--- a/mysql-test/r/create.result
+++ b/mysql-test/r/create.result
@@ -132,7 +132,7 @@ drop table t2;
create table t2 select now() as a , curtime() as b, curdate() as c , 1+1 as d , 1.0 + 1 as e , 33333333333333333 + 3 as f;
describe t2;
Field Type Null Key Default Extra
-a datetime NO NULL
+a datetime YES NULL
b time NO NULL
c date NO NULL
d int(3) NO NULL
@@ -1931,3 +1931,92 @@ create table t1 (i int, j int, key(i), key(i)) as select 1 as i, 2 as j;
Warnings:
Note 1831 Duplicate index `i_2`. This is deprecated and will be disallowed in a future release
drop table t1;
+#
+# Test for SYSTEM VERSIONING CREATE
+#
+create table t1 (
+XNo INT UNSIGNED,
+Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START,
+Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END,
+PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)
+) WITH SYSTEM VERSIONING;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `XNo` int(10) unsigned DEFAULT NULL,
+ `Sys_start` timestamp(6) NOT NULL GENERATED AS ROW START,
+ `Sys_end` timestamp(6) NOT NULL GENERATED AS ROW END,
+ PERIOD FOR SYSTEM_TIME (`Sys_start`, `Sys_end`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
+drop table if exists t1;
+create table t1 (
+XNo INT UNSIGNED,
+Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START,
+Sys_start2 TIMESTAMP(6) GENERATED ALWAYS AS ROW START,
+Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END,
+PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)
+) WITH SYSTEM VERSIONING;
+ERROR HY000: 'Generated as row start' specified more than once
+create table t1 (
+XNo INT UNSIGNED,
+Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START,
+Sys_end2 TIMESTAMP(6) GENERATED ALWAYS AS ROW END,
+PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)
+) WITH SYSTEM VERSIONING;
+ERROR HY000: Second column in 'period for system time' must be equal to 'generated as row end' column
+create table t1 (
+XNo INT UNSIGNED,
+Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START,
+Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END,
+Sys_end2 TIMESTAMP(6) GENERATED ALWAYS AS ROW END,
+PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)
+) WITH SYSTEM VERSIONING;
+ERROR HY000: Generated as row end specified more than once
+create table t1 (
+XNo INT UNSIGNED,
+PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)
+) WITH SYSTEM VERSIONING;
+ERROR HY000: 'Generated as row start' not specified
+create table t1 (
+XNo INT UNSIGNED,
+Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START,
+Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END,
+Sys_end2 TIMESTAMP(6) GENERATED ALWAYS AS ROW END,
+PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)
+);
+ERROR HY000: Generated as row end specified more than once
+create table t1 (
+XNo INT UNSIGNED,
+Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START,
+Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END,
+PERIOD FOR SYSTEM_TIME (Sys_insert, Sys_remove)
+) WITH SYSTEM VERSIONING;
+ERROR HY000: First column in 'period for system time' must be equal to 'generated as row start' column
+create table t1 (
+XNo INT UNSIGNED,
+Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START,
+Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END,
+PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)
+);
+ERROR HY000: 'With system versioning' is missing
+create table t1 (
+XNo INT UNSIGNED,
+Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START,
+Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END,
+PERIOD FOR SYSTEM_TIME (Sys_start, Sys_start)
+);
+ERROR HY000: 'Period for system_time' must contain two different columns
+create table t1 (
+XNo INT UNSIGNED,
+Sys_start INT GENERATED ALWAYS AS ROW START,
+Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END,
+PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)
+) WITH SYSTEM VERSIONING;
+ERROR HY000: System start field must be of type TIMESTAMP
+create table t1 (
+XNo INT UNSIGNED,
+Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START,
+Sys_end INT GENERATED ALWAYS AS ROW END,
+PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)
+) WITH SYSTEM VERSIONING;
+ERROR HY000: System end field must be of type TIMESTAMP
diff --git a/mysql-test/r/delete.result b/mysql-test/r/delete.result
index ed3683d52f9..1ee160b6864 100644
--- a/mysql-test/r/delete.result
+++ b/mysql-test/r/delete.result
@@ -525,3 +525,89 @@ DELETE v2 FROM v2;
ERROR HY000: Can not delete from join view 'test.v2'
DROP VIEW v2, v1;
DROP TABLE t1, t2;
+#
+# Test for SYSTEM VERSIONING
+#
+SET @@session.time_zone='+00:00';
+create table t1 (
+XNo INT UNSIGNED,
+Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START,
+Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END,
+PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)
+) WITH SYSTEM VERSIONING;
+INSERT INTO t1(XNo) VALUES(0);
+INSERT INTO t1(XNo) VALUES(1);
+INSERT INTO t1(XNo) VALUES(2);
+INSERT INTO t1(XNo) VALUES(3);
+INSERT INTO t1(XNo) VALUES(4);
+INSERT INTO t1(XNo) VALUES(5);
+INSERT INTO t1(XNo) VALUES(6);
+INSERT INTO t1(XNo) VALUES(7);
+INSERT INTO t1(XNo) VALUES(8);
+INSERT INTO t1(XNo) VALUES(9);
+SELECT XNo, Sys_end < '2038-01-19 03:14:07' FROM t1 FOR SYSTEM_TIME BETWEEN TIMESTAMP '0000-0-0 0:0:0' AND TIMESTAMP '2038-01-19 04:14:07';
+XNo Sys_end < '2038-01-19 03:14:07'
+0 0
+1 0
+2 0
+3 0
+4 0
+5 0
+6 0
+7 0
+8 0
+9 0
+DELETE FROM t1 WHERE XNo = 0;
+SELECT XNo, Sys_end < '2038-01-19 03:14:07' FROM t1 FOR SYSTEM_TIME BETWEEN TIMESTAMP '0000-0-0 0:0:0' AND TIMESTAMP '2038-01-19 04:14:07';
+XNo Sys_end < '2038-01-19 03:14:07'
+0 1
+1 0
+2 0
+3 0
+4 0
+5 0
+6 0
+7 0
+8 0
+9 0
+DELETE FROM t1 WHERE XNo = 1;
+SELECT XNo, Sys_end < '2038-01-19 03:14:07' FROM t1 FOR SYSTEM_TIME BETWEEN TIMESTAMP '0000-0-0 0:0:0' AND TIMESTAMP '2038-01-19 04:14:07';
+XNo Sys_end < '2038-01-19 03:14:07'
+0 1
+1 1
+2 0
+3 0
+4 0
+5 0
+6 0
+7 0
+8 0
+9 0
+DELETE FROM t1 WHERE XNo > 5;
+CREATE VIEW vt1 AS SELECT XNo FROM t1;
+SELECT XNo FROM vt1;
+XNo
+2
+3
+4
+5
+DELETE FROM vt1 WHERE XNo = 3;
+SELECT XNo FROM vt1;
+XNo
+2
+4
+5
+SELECT XNo, Sys_end < '2038-01-19 03:14:07' FROM t1 FOR SYSTEM_TIME BETWEEN TIMESTAMP '0000-0-0 0:0:0' AND TIMESTAMP '2038-01-19 04:14:07';
+XNo Sys_end < '2038-01-19 03:14:07'
+0 1
+1 1
+2 0
+3 1
+4 0
+5 0
+6 1
+7 1
+8 1
+9 1
+DROP VIEW vt1;
+DROP TABLE t1;
diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result
index 7ee5a68ca90..fa09d13b868 100644
--- a/mysql-test/r/fulltext.result
+++ b/mysql-test/r/fulltext.result
@@ -49,7 +49,7 @@ a b
Full-text indexes are called collections
Only MyISAM tables support collections
select * from t1 where MATCH(a,b) AGAINST ("indexes" IN BOOLEAN MODE WITH QUERY EXPANSION);
-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 'QUERY EXPANSION)' at line 1
+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 'WITH QUERY EXPANSION)' at line 1
explain select * from t1 where MATCH(a,b) AGAINST ("collections");
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 fulltext a a 0 1 Using where
diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result
index c85a50b2ea9..2b06467ce13 100644
--- a/mysql-test/r/func_group.result
+++ b/mysql-test/r/func_group.result
@@ -787,7 +787,7 @@ drop table t2;
create table t2 select f2 from (select now() f2 from t1) a;
show columns from t2;
Field Type Null Key Default Extra
-f2 datetime NO NULL
+f2 datetime YES NULL
drop table t2, t1;
CREATE TABLE t1(
id int PRIMARY KEY,
diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result
index 54da823c439..b721d7e1146 100644
--- a/mysql-test/r/func_time.result
+++ b/mysql-test/r/func_time.result
@@ -950,7 +950,7 @@ sec_to_time(1) + 0, from_unixtime(1) + 0;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
- `now() - now()` bigint(21) NOT NULL,
+ `now() - now()` bigint(21) DEFAULT NULL,
`curtime() - curtime()` bigint(12) NOT NULL,
`sec_to_time(1) + 0` bigint(12) DEFAULT NULL,
`from_unixtime(1) + 0` bigint(21) DEFAULT NULL
diff --git a/mysql-test/r/func_time_hires.result b/mysql-test/r/func_time_hires.result
index 0f822456724..17c55d554bc 100644
--- a/mysql-test/r/func_time_hires.result
+++ b/mysql-test/r/func_time_hires.result
@@ -39,14 +39,14 @@ t1 CREATE TABLE `t1` (
`sec_to_time(12345)` time DEFAULT NULL,
`sec_to_time(12345.6789)` time(4) DEFAULT NULL,
`sec_to_time(1234567e-2)` time(6) DEFAULT NULL,
- `now()` datetime NOT NULL,
+ `now()` datetime DEFAULT NULL,
`curtime(0)` time NOT NULL,
- `utc_timestamp(1)` datetime(1) NOT NULL,
+ `utc_timestamp(1)` datetime(1) DEFAULT NULL,
`utc_time(2)` time(2) NOT NULL,
`current_time(3)` time(3) NOT NULL,
- `current_timestamp(4)` datetime(4) NOT NULL,
- `localtime(5)` datetime(5) NOT NULL,
- `localtimestamp(6)` datetime(6) NOT NULL,
+ `current_timestamp(4)` datetime(4) DEFAULT NULL,
+ `localtime(5)` datetime(5) DEFAULT NULL,
+ `localtimestamp(6)` datetime(6) DEFAULT NULL,
`time_to_sec(123456)` bigint(17) DEFAULT NULL,
`time_to_sec('12:34:56.789')` decimal(19,3) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
diff --git a/mysql-test/r/insert.result b/mysql-test/r/insert.result
index c9e3dc7b253..5837e1faa44 100644
--- a/mysql-test/r/insert.result
+++ b/mysql-test/r/insert.result
@@ -717,3 +717,112 @@ insert ignore into t1 values (1,12);
Warnings:
Warning 1062 Duplicate entry '1' for key 'f1'
DROP TABLE t1;
+#
+# System Versioning Support
+#
+#
+SET @@session.time_zone='+00:00';
+CREATE TABLE t1(x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)) WITH SYSTEM VERSIONING;
+INSERT INTO t1(x, y) VALUES(3, 4);
+INSERT INTO t1(x, y) VALUES(2, 3);
+INSERT INTO t1 VALUES(40, 33);
+SELECT x, y, Sys_end FROM t1;
+x y Sys_end
+3 4 2038-01-19 03:14:07.000000
+2 3 2038-01-19 03:14:07.000000
+40 33 2038-01-19 03:14:07.000000
+DROP TABLE t1;
+CREATE TABLE t1(x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)) WITH SYSTEM VERSIONING ENGINE=InnoDB;
+INSERT INTO t1(x, y) VALUES(3, 4);
+INSERT INTO t1(x, y) VALUES(2, 3);
+INSERT INTO t1 VALUES(40, 33);
+SELECT x, y, Sys_end FROM t1;
+x y Sys_end
+3 4 2038-01-19 03:14:07.000000
+2 3 2038-01-19 03:14:07.000000
+40 33 2038-01-19 03:14:07.000000
+DROP TABLE t1;
+CREATE TABLE t1(id INT UNSIGNED NOT NULL AUTO_INCREMENT, x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end), PRIMARY KEY(id)) WITH SYSTEM VERSIONING;
+INSERT INTO t1(x, y) VALUES(33, 44);
+INSERT INTO t1(id, x, y) VALUES(20, 33, 44);
+INSERT INTO t1 VALUES(40, 33, 44);
+SELECT id, x, y, Sys_end FROM t1;
+id x y Sys_end
+1 33 44 2038-01-19 03:14:07.000000
+20 33 44 2038-01-19 03:14:07.000000
+40 33 44 2038-01-19 03:14:07.000000
+DROP TABLE t1;
+CREATE TABLE t1(id INT UNSIGNED NOT NULL AUTO_INCREMENT, x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end), PRIMARY KEY(id)) WITH SYSTEM VERSIONING ENGINE=InnoDB;
+INSERT INTO t1(x, y) VALUES(33, 44);
+INSERT INTO t1(id, x, y) VALUES(20, 33, 44);
+INSERT INTO t1 VALUES(40, 33, 44);
+SELECT id, x, y, Sys_end FROM t1;
+id x y Sys_end
+1 33 44 2038-01-19 03:14:07.000000
+20 33 44 2038-01-19 03:14:07.000000
+40 33 44 2038-01-19 03:14:07.000000
+DROP TABLE t1;
+CREATE TABLE t1(x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)) WITH SYSTEM VERSIONING;
+CREATE VIEW vt1_1 AS SELECT x, y FROM t1;
+CREATE VIEW vt1_2 AS SELECT x, y, Sys_end FROM t1;
+INSERT INTO t1(x, y) VALUES(8001, 9001);
+INSERT INTO t1(x, y, Sys_end) VALUES(8001, 9001, '2015-1-1 0:0:0');
+ERROR HY000: Generated field for System Versioning cannot be set by user
+INSERT INTO vt1_1(x, y) VALUES(1001, 2001);
+INSERT INTO vt1_1 VALUES(1002, 2002);
+INSERT INTO vt1_2(x, y) VALUES(3001, 4001);
+INSERT INTO vt1_2 VALUES(3002, 4002, '2015-1-1 0:0:0');
+ERROR HY000: Generated field for System Versioning cannot be set by user
+SELECT x, y, Sys_end FROM t1;
+x y Sys_end
+8001 9001 2038-01-19 03:14:07.000000
+1001 2001 2038-01-19 03:14:07.000000
+1002 2002 2038-01-19 03:14:07.000000
+3001 4001 2038-01-19 03:14:07.000000
+SELECT x, y FROM vt1_1;
+x y
+8001 9001
+1001 2001
+1002 2002
+3001 4001
+SELECT x, y, Sys_end FROM vt1_2;
+x y Sys_end
+8001 9001 2038-01-19 03:14:07.000000
+1001 2001 2038-01-19 03:14:07.000000
+1002 2002 2038-01-19 03:14:07.000000
+3001 4001 2038-01-19 03:14:07.000000
+DROP TABLE t1;
+DROP VIEW vt1_1;
+DROP VIEW vt1_2;
+CREATE TABLE t1(x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)) WITH SYSTEM VERSIONING ENGINE=InnoDB;
+CREATE VIEW vt1_1 AS SELECT x, y FROM t1;
+CREATE VIEW vt1_2 AS SELECT x, y, Sys_end FROM t1;
+INSERT INTO t1(x, y) VALUES(8001, 9001);
+INSERT INTO t1(x, y, Sys_end) VALUES(8001, 9001, '2015-1-1 0:0:0');
+ERROR HY000: Generated field for System Versioning cannot be set by user
+INSERT INTO vt1_1(x, y) VALUES(1001, 2001);
+INSERT INTO vt1_1 VALUES(1002, 2002);
+INSERT INTO vt1_2(x, y) VALUES(3001, 4001);
+INSERT INTO vt1_2 VALUES(3002, 4002, '2015-1-1 0:0:0');
+ERROR HY000: Generated field for System Versioning cannot be set by user
+SELECT x, y, Sys_end FROM t1;
+x y Sys_end
+8001 9001 2038-01-19 03:14:07.000000
+1001 2001 2038-01-19 03:14:07.000000
+1002 2002 2038-01-19 03:14:07.000000
+3001 4001 2038-01-19 03:14:07.000000
+SELECT x, y FROM vt1_1;
+x y
+8001 9001
+1001 2001
+1002 2002
+3001 4001
+SELECT x, y, Sys_end FROM vt1_2;
+x y Sys_end
+8001 9001 2038-01-19 03:14:07.000000
+1001 2001 2038-01-19 03:14:07.000000
+1002 2002 2038-01-19 03:14:07.000000
+3001 4001 2038-01-19 03:14:07.000000
+DROP TABLE t1;
+DROP VIEW vt1_1;
+DROP VIEW vt1_2;
diff --git a/mysql-test/r/insert_select.result b/mysql-test/r/insert_select.result
index 1a3a38b1f35..da236c53825 100644
--- a/mysql-test/r/insert_select.result
+++ b/mysql-test/r/insert_select.result
@@ -856,3 +856,121 @@ INSERT IGNORE INTO t1 SELECT t1.a FROM t1,t1 t2,t1 t3,t1 t4,t1 t5,t1 t6,t1 t7;
SET GLOBAL myisam_data_pointer_size = @old_myisam_data_pointer_size;
DROP TABLE t1;
End of 5.1 tests
+#
+# System Versioning Support
+#
+#
+CREATE TABLE t1(x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)) WITH SYSTEM VERSIONING ENGINE=MyISAM;
+CREATE TABLE t2(x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)) WITH SYSTEM VERSIONING ENGINE=MyISAM;
+INSERT INTO t1(x, y) VALUES
+(1, 1000),
+(2, 2000),
+(3, 3000),
+(4, 4000),
+(5, 5000),
+(6, 6000),
+(7, 7000),
+(8, 8000),
+(9, 9000);
+DELETE FROM t1 WHERE x >= 1;
+INSERT INTO t1(x, y) VALUES
+(1, 1001),
+(2, 2001),
+(3, 3001),
+(4, 4001),
+(5, 5001),
+(6, 6001),
+(7, 7001),
+(8, 8001),
+(9, 9001);
+INSERT INTO t2 SELECT x, y FROM t1 FOR SYSTEM_TIME BETWEEN TIMESTAMP '0000-0-0 0:0:0' AND TIMESTAMP '9999-1-1 0:0:0';
+SELECT x, y FROM t1;
+x y
+1 1001
+2 2001
+3 3001
+4 4001
+5 5001
+6 6001
+7 7001
+8 8001
+9 9001
+SELECT x, y FROM t2;
+x y
+1 1000
+2 2000
+3 3000
+4 4000
+5 5000
+6 6000
+7 7000
+8 8000
+9 9000
+1 1001
+2 2001
+3 3001
+4 4001
+5 5001
+6 6001
+7 7001
+8 8001
+9 9001
+DROP TABLE t1;
+DROP TABLE t2;
+CREATE TABLE t1(x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)) WITH SYSTEM VERSIONING ENGINE=InnoDB;
+CREATE TABLE t2(x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)) WITH SYSTEM VERSIONING ENGINE=InnoDB;
+INSERT INTO t1(x, y) VALUES
+(1, 1000),
+(2, 2000),
+(3, 3000),
+(4, 4000),
+(5, 5000),
+(6, 6000),
+(7, 7000),
+(8, 8000),
+(9, 9000);
+DELETE FROM t1 WHERE x >= 1;
+INSERT INTO t1(x, y) VALUES
+(1, 1001),
+(2, 2001),
+(3, 3001),
+(4, 4001),
+(5, 5001),
+(6, 6001),
+(7, 7001),
+(8, 8001),
+(9, 9001);
+INSERT INTO t2 SELECT x, y FROM t1 FOR SYSTEM_TIME BETWEEN TIMESTAMP '0000-0-0 0:0:0' AND TIMESTAMP '9999-1-1 0:0:0';
+SELECT x, y FROM t1;
+x y
+1 1001
+2 2001
+3 3001
+4 4001
+5 5001
+6 6001
+7 7001
+8 8001
+9 9001
+SELECT x, y FROM t2;
+x y
+1 1000
+2 2000
+3 3000
+4 4000
+5 5000
+6 6000
+7 7000
+8 8000
+9 9000
+1 1001
+2 2001
+3 3001
+4 4001
+5 5001
+6 6001
+7 7001
+8 8001
+9 9001
+DROP TABLE t1;
+DROP TABLE t2;
diff --git a/mysql-test/r/insert_update.result b/mysql-test/r/insert_update.result
index e8e6e16fe5a..6f25fd18b6a 100644
--- a/mysql-test/r/insert_update.result
+++ b/mysql-test/r/insert_update.result
@@ -412,3 +412,93 @@ select if( @stamp1 = @stamp2, "correct", "wrong");
if( @stamp1 = @stamp2, "correct", "wrong")
correct
drop table t1;
+#
+# System Versioning Support
+#
+#
+CREATE TABLE t1(x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end), PRIMARY KEY(x, y)) WITH SYSTEM VERSIONING;
+INSERT INTO t1(x, y) VALUES
+(1, 1000),
+(2, 2000),
+(3, 3000),
+(4, 4000),
+(5, 5000),
+(6, 6000),
+(7, 7000),
+(8, 8000),
+(9, 9000);
+INSERT INTO t1(x, y) VALUES(3, 3000) ON DUPLICATE KEY UPDATE y = y+1;
+INSERT INTO t1(x, y) VALUES(4, 4000) ON DUPLICATE KEY UPDATE y = y+1;
+INSERT INTO t1(x, y) VALUES(4, 4001) ON DUPLICATE KEY UPDATE y = y+1;
+INSERT INTO t1(x, y) VALUES(4, 4444) ON DUPLICATE KEY UPDATE y = y+1;
+SELECT x, y FROM t1 FOR SYSTEM_TIME BETWEEN TIMESTAMP '0-0-0 0:0:0' AND TIMESTAMP '9999-1-1 0:0:0';
+x y
+1 1000
+2 2000
+3 3001
+4 4002
+5 5000
+6 6000
+7 7000
+8 8000
+9 9000
+3 3000
+4 4000
+4 4001
+4 4444
+SELECT x, y FROM t1;
+x y
+1 1000
+2 2000
+3 3001
+4 4002
+5 5000
+6 6000
+7 7000
+8 8000
+9 9000
+4 4444
+DROP TABLE t1;
+CREATE TABLE t1(x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end), PRIMARY KEY(x, y)) WITH SYSTEM VERSIONING ENGINE=InnoDB;
+INSERT INTO t1(x, y) VALUES
+(1, 1000),
+(2, 2000),
+(3, 3000),
+(4, 4000),
+(5, 5000),
+(6, 6000),
+(7, 7000),
+(8, 8000),
+(9, 9000);
+INSERT INTO t1(x, y) VALUES(3, 3000) ON DUPLICATE KEY UPDATE y = y+1;
+INSERT INTO t1(x, y) VALUES(4, 4000) ON DUPLICATE KEY UPDATE y = y+1;
+INSERT INTO t1(x, y) VALUES(4, 4001) ON DUPLICATE KEY UPDATE y = y+1;
+INSERT INTO t1(x, y) VALUES(4, 4444) ON DUPLICATE KEY UPDATE y = y+1;
+SELECT x, y FROM t1 FOR SYSTEM_TIME BETWEEN TIMESTAMP '0-0-0 0:0:0' AND TIMESTAMP '9999-1-1 0:0:0';
+x y
+1 1000
+2 2000
+3 3000
+3 3001
+4 4000
+4 4001
+4 4002
+4 4444
+5 5000
+6 6000
+7 7000
+8 8000
+9 9000
+SELECT x, y FROM t1;
+x y
+1 1000
+2 2000
+3 3001
+4 4002
+4 4444
+5 5000
+6 6000
+7 7000
+8 8000
+9 9000
+DROP TABLE t1;
diff --git a/mysql-test/r/multi_update.result b/mysql-test/r/multi_update.result
index 634b3897ba0..35966f5ac1b 100644
--- a/mysql-test/r/multi_update.result
+++ b/mysql-test/r/multi_update.result
@@ -1002,3 +1002,215 @@ deallocate prepare stmt1;
drop view v3,v2,v1;
drop table t1,t2,t3;
end of 5.5 tests
+
+# Bug mdev-5970
+# Bug#13256831 - ERROR 1032 (HY000): CAN'T FIND RECORD
+
+CREATE TABLE t1 (f1 INT PRIMARY KEY, f2 INT) ENGINE=InnoDB;
+CREATE TABLE t2 (f1 INT PRIMARY KEY, f2 INT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (5, 7);
+INSERT INTO t2 VALUES (6, 97);
+CREATE ALGORITHM = MERGE VIEW v1 AS
+SELECT a2.f1 AS f1, a2.f2 AS f2
+FROM t1 AS a1 JOIN t2 AS a2 ON a1.f2 > a2.f1
+WITH LOCAL CHECK OPTION;
+SELECT * FROM v1;
+f1 f2
+6 97
+UPDATE v1 SET f1 = 1;
+SELECT * FROM v1;
+f1 f2
+1 97
+DROP TABLE t1, t2;
+DROP VIEW v1;
+#
+# MDEV-5973: MySQL Bug#11757486:49539: NON-DESCRIPTIVE ERR (ERROR 0
+# FROM STORAGE ENGINE) WITH MULTI-TABLE UPDATE
+#
+CREATE TABLE table_11757486 (field1 tinyint) ENGINE=INNODB;
+INSERT INTO table_11757486 VALUES (0),(0);
+SET SESSION SQL_MODE='STRICT_ALL_TABLES';
+UPDATE IGNORE (SELECT 128 as col1) x, table_11757486 SET field1=x.col1;
+Warnings:
+Warning 1264 Out of range value for column 'field1' at row 1
+Warning 1264 Out of range value for column 'field1' at row 2
+UPDATE IGNORE table_11757486 SET field1=128;
+Warnings:
+Warning 1264 Out of range value for column 'field1' at row 1
+Warning 1264 Out of range value for column 'field1' at row 2
+Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. UPDATE IGNORE is unsafe because the order in which rows are updated determines which (if any) rows are ignored. This order cannot be predicted and may differ on master and the slave.
+UPDATE (SELECT 128 as col1) x, table_11757486 SET field1=x.col1;
+ERROR 22003: Out of range value for column 'field1' at row 1
+UPDATE table_11757486 SET field1=128;
+ERROR 22003: Out of range value for column 'field1' at row 1
+SET SESSION SQL_MODE='';
+UPDATE IGNORE (SELECT 128 as col1) x, table_11757486 SET field1=x.col1;
+Warnings:
+Warning 1264 Out of range value for column 'field1' at row 1
+Warning 1264 Out of range value for column 'field1' at row 2
+UPDATE IGNORE table_11757486 SET field1=128;
+Warnings:
+Warning 1264 Out of range value for column 'field1' at row 1
+Warning 1264 Out of range value for column 'field1' at row 2
+Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. UPDATE IGNORE is unsafe because the order in which rows are updated determines which (if any) rows are ignored. This order cannot be predicted and may differ on master and the slave.
+DROP TABLE table_11757486;
+SET SESSION SQL_MODE=default;
+end of 10.0 tests
+#
+# System Versioning Support
+#
+#
+CREATE TABLE t1(x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)) WITH SYSTEM VERSIONING;
+CREATE TABLE t2(x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)) WITH SYSTEM VERSIONING;
+INSERT INTO t1(x, y) VALUES
+(1, 1000),
+(2, 2000),
+(3, 3000),
+(4, 4000),
+(5, 5000),
+(6, 6000),
+(7, 7000),
+(8, 8000),
+(9, 9000);
+INSERT INTO t2(x, y) VALUES
+(1, 1010),
+(2, 2010),
+(3, 3010),
+(4, 4010),
+(5, 5010),
+(6, 6010),
+(7, 7010),
+(8, 8010),
+(9, 9010);
+UPDATE t1, t2 SET t1.y = t1.x + t1.y, t2.y = t2.x + t2.y WHERE t1.x > 7 AND t2.x < 7;
+SELECT x, y FROM t1 FOR SYSTEM_TIME BETWEEN TIMESTAMP '0-0-0 0:0:0' AND TIMESTAMP '9999-1-1 0:0:0';
+x y
+1 1000
+2 2000
+3 3000
+4 4000
+5 5000
+6 6000
+7 7000
+8 8008
+9 9009
+8 8000
+9 9000
+SELECT x, y FROM t1;
+x y
+1 1000
+2 2000
+3 3000
+4 4000
+5 5000
+6 6000
+7 7000
+8 8008
+9 9009
+SELECT x, y FROM t2 FOR SYSTEM_TIME BETWEEN TIMESTAMP '0-0-0 0:0:0' AND TIMESTAMP '9999-1-1 0:0:0';
+x y
+1 1011
+2 2012
+3 3013
+4 4014
+5 5015
+6 6016
+7 7010
+8 8010
+9 9010
+1 1010
+2 2010
+3 3010
+4 4010
+5 5010
+6 6010
+SELECT x, y FROM t2;
+x y
+1 1011
+2 2012
+3 3013
+4 4014
+5 5015
+6 6016
+7 7010
+8 8010
+9 9010
+DROP TABLE t1;
+DROP TABLE t2;
+CREATE TABLE t1(x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)) WITH SYSTEM VERSIONING ENGINE=InnoDB;
+CREATE TABLE t2(x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)) WITH SYSTEM VERSIONING ENGINE=InnoDB;
+INSERT INTO t1(x, y) VALUES
+(1, 1000),
+(2, 2000),
+(3, 3000),
+(4, 4000),
+(5, 5000),
+(6, 6000),
+(7, 7000),
+(8, 8000),
+(9, 9000);
+INSERT INTO t2(x, y) VALUES
+(1, 1010),
+(2, 2010),
+(3, 3010),
+(4, 4010),
+(5, 5010),
+(6, 6010),
+(7, 7010),
+(8, 8010),
+(9, 9010);
+UPDATE t1, t2 SET t1.y = t1.x + t1.y, t2.y = t2.x + t2.y WHERE t1.x > 7 AND t2.x < 7;
+SELECT x, y FROM t1 FOR SYSTEM_TIME BETWEEN TIMESTAMP '0-0-0 0:0:0' AND TIMESTAMP '9999-1-1 0:0:0';
+x y
+1 1000
+2 2000
+3 3000
+4 4000
+5 5000
+6 6000
+7 7000
+8 8008
+9 9009
+8 8000
+9 9000
+SELECT x, y FROM t1;
+x y
+1 1000
+2 2000
+3 3000
+4 4000
+5 5000
+6 6000
+7 7000
+8 8008
+9 9009
+SELECT x, y FROM t2 FOR SYSTEM_TIME BETWEEN TIMESTAMP '0-0-0 0:0:0' AND TIMESTAMP '9999-1-1 0:0:0';
+x y
+1 1011
+2 2012
+3 3013
+4 4014
+5 5015
+6 6016
+7 7010
+8 8010
+9 9010
+1 1010
+2 2010
+3 3010
+4 4010
+5 5010
+6 6010
+SELECT x, y FROM t2;
+x y
+1 1011
+2 2012
+3 3013
+4 4014
+5 5015
+6 6016
+7 7010
+8 8010
+9 9010
+DROP TABLE t1;
+DROP TABLE t2;
diff --git a/mysql-test/r/named_pipe.result b/mysql-test/r/named_pipe.result
index 66da9a874b4..b6c409e4590 100644
--- a/mysql-test/r/named_pipe.result
+++ b/mysql-test/r/named_pipe.result
@@ -1,18 +1,18 @@
connect pipe_con,localhost,root,,,,,PIPE;
drop table if exists t1,t2,t3,t4;
CREATE TABLE t1 (
-Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
+Period_ smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL
);
INSERT INTO t1 VALUES (9410,9412);
-select period from t1;
-period
+select period_ from t1;
+period_
9410
select * from t1;
-Period Varor_period
+Period_ Varor_period
9410 9412
select t1.* from t1;
-Period Varor_period
+Period_ Varor_period
9410 9412
CREATE TABLE t2 (
auto int not null auto_increment,
@@ -276,8 +276,8 @@ companynr
34
29
00
-select distinct t2.fld3,period from t2,t1 where companynr=37 and fld3 like "O%";
-fld3 period
+select distinct t2.fld3,period_ from t2,t1 where companynr=37 and fld3 like "O%";
+fld3 period_
obliterates 9410
offload 9410
opaquely 9410
@@ -481,12 +481,12 @@ acu
Ade
adj
create table t3 (
-period int not null,
+period_ int not null,
name char(32) not null,
companynr int not null,
price double(11,0),
price2 double(11,0),
-key (period),
+key (period_),
key (name)
);
create temporary table tmp engine = myisam select * from t3;
@@ -600,35 +600,35 @@ explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL fld1 NULL NULL NULL 1199 Using where; Using temporary; Using filesort
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.fld1 1 Using where; Using index
-explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period;
+explain select * from t3 as t1,t3 where t1.period_=t3.period_ order by t3.period_;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using filesort
-1 SIMPLE t3 ref period period 4 test.t1.period 4181
-explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10;
+1 SIMPLE t1 ALL period_ NULL NULL NULL 41810 Using temporary; Using filesort
+1 SIMPLE t3 ref period_ period_ 4 test.t1.period_ 4181
+explain select * from t3 as t1,t3 where t1.period_=t3.period_ order by t3.period_ limit 10;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 index period period 4 NULL 1
-1 SIMPLE t1 ref period period 4 test.t3.period 4181
-explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10;
+1 SIMPLE t3 index period_ period_ 4 NULL 1
+1 SIMPLE t1 ref period_ period_ 4 test.t3.period_ 4181
+explain select * from t3 as t1,t3 where t1.period_=t3.period_ order by t1.period_ limit 10;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index period period 4 NULL 1
-1 SIMPLE t3 ref period period 4 test.t1.period 4181
-select period from t1;
-period
+1 SIMPLE t1 index period_ period_ 4 NULL 1
+1 SIMPLE t3 ref period_ period_ 4 test.t1.period_ 4181
+select period_ from t1;
+period_
9410
-select period from t1 where period=1900;
-period
-select fld3,period from t1,t2 where fld1 = 011401 order by period;
-fld3 period
+select period_ from t1 where period_=1900;
+period_
+select fld3,period_ from t1,t2 where fld1 = 011401 order by period_;
+fld3 period_
breaking 9410
-select fld3,period from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.period=1001;
-fld3 period
+select fld3,period_ from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.period_=1001;
+fld3 period_
breaking 1001
-explain select fld3,period from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period;
+explain select fld3,period_ from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period_;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 const fld1 fld1 4 const 1
-1 SIMPLE t3 const PRIMARY,period PRIMARY 4 const 1
-select fld3,period from t2,t1 where companynr*10 = 37*10;
-fld3 period
+1 SIMPLE t3 const PRIMARY,period_ PRIMARY 4 const 1
+select fld3,period_ from t2,t1 where companynr*10 = 37*10;
+fld3 period_
breaking 9410
Romans 9410
intercepted 9410
@@ -1217,8 +1217,8 @@ dusted 9410
encompasses 9410
presentation 9410
Kantian 9410
-select fld3,period,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period >= 1001 and period <= 1002 and t2.companynr = 37 order by fld3,period, price;
-fld3 period price price2
+select fld3,period_,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period_ >= 1001 and period_ <= 1002 and t2.companynr = 37 order by fld3,period_, price;
+fld3 period_ price price2
admonishing 1002 28357832 8723648
analyzable 1002 28357832 8723648
annihilates 1001 5987435 234724
@@ -1278,8 +1278,8 @@ ventilate 1001 5987435 234724
wallet 1001 5987435 234724
Weissmuller 1002 28357832 8723648
Wotan 1002 28357832 8723648
-select t2.fld1,fld3,period,price,price2 from t2,t3 where t2.fld1>= 18201 and t2.fld1 <= 18811 and t2.fld1=t3.t2nr and period = 1001 and t2.companynr = 37;
-fld1 fld3 period price price2
+select t2.fld1,fld3,period_,price,price2 from t2,t3 where t2.fld1>= 18201 and t2.fld1 <= 18811 and t2.fld1=t3.t2nr and period_ = 1001 and t2.companynr = 37;
+fld1 fld3 period_ price price2
018201 relaxing 1001 5987435 234724
018601 vacuuming 1001 5987435 234724
018801 inch 1001 5987435 234724
@@ -1319,7 +1319,7 @@ companynr companyname
65 company 9
68 company 10
select * from t1,t1 t12;
-Period Varor_period Period Varor_period
+Period_ Varor_period Period_ Varor_period
9410 9412 9410 9412
select t2.fld1,t22.fld1 from t2,t2 t22 where t2.fld1 >= 250501 and t2.fld1 <= 250505 and t22.fld1 >= 250501 and t22.fld1 <= 250505;
fld1 fld1
@@ -1434,23 +1434,23 @@ explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 index NULL PRIMARY 1 NULL 12 Using index; Using temporary
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where; Using join buffer (flat, BNL join)
-select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008;
-fld1 companynr fld3 period
+select t2.fld1,t2.companynr,fld3,period_ from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period_ = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period_ = 1008;
+fld1 companynr fld3 period_
038008 37 reporters 1008
038208 37 Selfridge 1008
-select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t2.fld1 = 38208 or t2.fld1 = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009;
-fld1 companynr fld3 period
+select t2.fld1,t2.companynr,fld3,period_ from t3,t2 where (t2.fld1 = 38208 or t2.fld1 = 38008) and t2.fld1=t3.t2nr and period_>=1008 and period_<=1009;
+fld1 companynr fld3 period_
038008 37 reporters 1008
038208 37 Selfridge 1008
-select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t3.t2nr = 38208 or t3.t2nr = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009;
-fld1 companynr fld3 period
+select t2.fld1,t2.companynr,fld3,period_ from t3,t2 where (t3.t2nr = 38208 or t3.t2nr = 38008) and t2.fld1=t3.t2nr and period_>=1008 and period_<=1009;
+fld1 companynr fld3 period_
038008 37 reporters 1008
038208 37 Selfridge 1008
-select period from t1 where (((period > 0) or period < 10000 or (period = 1900)) and (period=1900 and period <= 1901) or (period=1903 and (period=1903)) and period>=1902) or ((period=1904 or period=1905) or (period=1906 or period>1907)) or (period=1908 and period = 1909);
-period
+select period_ from t1 where (((period_ > 0) or period_ < 10000 or (period_ = 1900)) and (period_=1900 and period_ <= 1901) or (period_=1903 and (period_=1903)) and period_>=1902) or ((period_=1904 or period_=1905) or (period_=1906 or period_>1907)) or (period_=1908 and period_ = 1909);
+period_
9410
-select period from t1 where ((period > 0 and period < 1) or (((period > 0 and period < 100) and (period > 10)) or (period > 10)) or (period > 0 and (period > 5 or period > 6)));
-period
+select period_ from t1 where ((period_ > 0 and period_ < 1) or (((period_ > 0 and period_ < 100) and (period_ > 10)) or (period_ > 10)) or (period_ > 0 and (period_ > 5 or period_ > 6)));
+period_
9410
select a.fld1 from t2 as a,t2 b where ((a.fld1 = 250501 and a.fld1=b.fld1) or a.fld1=250502 or a.fld1=250503 or (a.fld1=250505 and a.fld1<=b.fld1 and b.fld1>=a.fld1)) and a.fld1=b.fld1;
fld1
@@ -1707,8 +1707,8 @@ companynr companyname count(*)
select t2.fld1,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name;
fld1 count(*)
158402 4181
-select sum(Period)/count(*) from t1;
-sum(Period)/count(*)
+select sum(Period_)/count(*) from t1;
+sum(Period_)/count(*)
9410.0000
select companynr,count(price) as "count",sum(price) as "sum" ,abs(sum(price)/count(price)-avg(price)) as "diff",(0+count(price))*companynr as func from t3 group by companynr;
companynr count sum diff func
@@ -2038,26 +2038,26 @@ t2nr count(*)
select max(t2nr) from t3 where price=983543950;
max(t2nr)
41807
-select t1.period from t3 = t1 limit 1;
-period
+select t1.period_ from t3 = t1 limit 1;
+period_
1001
-select t1.period from t1 as t1 limit 1;
-period
+select t1.period_ from t1 as t1 limit 1;
+period_
9410
-select t1.period as "Nuvarande period" from t1 as t1 limit 1;
-Nuvarande period
+select t1.period_ as "Nuvarande period_" from t1 as t1 limit 1;
+Nuvarande period_
9410
-select period as ok_period from t1 limit 1;
+select period_ as ok_period from t1 limit 1;
ok_period
9410
-select period as ok_period from t1 group by ok_period limit 1;
+select period_ as ok_period from t1 group by ok_period limit 1;
ok_period
9410
select 1+1 as summa from t1 group by summa limit 1;
summa
2
-select period as "Nuvarande period" from t1 group by "Nuvarande period" limit 1;
-Nuvarande period
+select period_ as "Nuvarande period_" from t1 group by "Nuvarande period_" limit 1;
+Nuvarande period_
9410
show tables;
Tables_in_test
diff --git a/mysql-test/r/pool_of_threads.result b/mysql-test/r/pool_of_threads.result
index b25d8d1e50e..85ab577829a 100644
--- a/mysql-test/r/pool_of_threads.result
+++ b/mysql-test/r/pool_of_threads.result
@@ -2,18 +2,18 @@ SET @save_optimizer_switch=@@optimizer_switch;
SET optimizer_switch='outer_join_with_cache=off';
drop table if exists t1,t2,t3,t4;
CREATE TABLE t1 (
-Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
+Period_ smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL
);
INSERT INTO t1 VALUES (9410,9412);
-select period from t1;
-period
+select period_ from t1;
+period_
9410
select * from t1;
-Period Varor_period
+Period_ Varor_period
9410 9412
select t1.* from t1;
-Period Varor_period
+Period_ Varor_period
9410 9412
CREATE TABLE t2 (
auto int not null auto_increment,
@@ -277,8 +277,8 @@ companynr
34
29
00
-select distinct t2.fld3,period from t2,t1 where companynr=37 and fld3 like "O%";
-fld3 period
+select distinct t2.fld3,period_ from t2,t1 where companynr=37 and fld3 like "O%";
+fld3 period_
obliterates 9410
offload 9410
opaquely 9410
@@ -482,12 +482,12 @@ acu
Ade
adj
create table t3 (
-period int not null,
+period_ int not null,
name char(32) not null,
companynr int not null,
price double(11,0),
price2 double(11,0),
-key (period),
+key (period_),
key (name)
);
create temporary table tmp engine = myisam select * from t3;
@@ -601,35 +601,35 @@ explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL fld1 NULL NULL NULL 1199 Using where; Using temporary; Using filesort
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.fld1 1 Using where; Using index
-explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period;
+explain select * from t3 as t1,t3 where t1.period_=t3.period_ order by t3.period_;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using filesort
-1 SIMPLE t3 ref period period 4 test.t1.period 4181
-explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10;
+1 SIMPLE t1 ALL period_ NULL NULL NULL 41810 Using filesort
+1 SIMPLE t3 ref period_ period_ 4 test.t1.period_ 4181
+explain select * from t3 as t1,t3 where t1.period_=t3.period_ order by t3.period_ limit 10;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 index period period 4 NULL 1
-1 SIMPLE t1 ref period period 4 test.t3.period 4181
-explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10;
+1 SIMPLE t3 index period_ period_ 4 NULL 1
+1 SIMPLE t1 ref period_ period_ 4 test.t3.period_ 4181
+explain select * from t3 as t1,t3 where t1.period_=t3.period_ order by t1.period_ limit 10;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index period period 4 NULL 1
-1 SIMPLE t3 ref period period 4 test.t1.period 4181
-select period from t1;
-period
+1 SIMPLE t1 index period_ period_ 4 NULL 1
+1 SIMPLE t3 ref period_ period_ 4 test.t1.period_ 4181
+select period_ from t1;
+period_
9410
-select period from t1 where period=1900;
-period
-select fld3,period from t1,t2 where fld1 = 011401 order by period;
-fld3 period
+select period_ from t1 where period_=1900;
+period_
+select fld3,period_ from t1,t2 where fld1 = 011401 order by period_;
+fld3 period_
breaking 9410
-select fld3,period from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.period=1001;
-fld3 period
+select fld3,period_ from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.period_=1001;
+fld3 period_
breaking 1001
-explain select fld3,period from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period;
+explain select fld3,period_ from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period_;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 const fld1 fld1 4 const 1
-1 SIMPLE t3 const PRIMARY,period PRIMARY 4 const 1
-select fld3,period from t2,t1 where companynr*10 = 37*10;
-fld3 period
+1 SIMPLE t3 const PRIMARY,period_ PRIMARY 4 const 1
+select fld3,period_ from t2,t1 where companynr*10 = 37*10;
+fld3 period_
breaking 9410
Romans 9410
intercepted 9410
@@ -1218,8 +1218,8 @@ dusted 9410
encompasses 9410
presentation 9410
Kantian 9410
-select fld3,period,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period >= 1001 and period <= 1002 and t2.companynr = 37 order by fld3,period, price;
-fld3 period price price2
+select fld3,period_,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period_ >= 1001 and period_ <= 1002 and t2.companynr = 37 order by fld3,period_, price;
+fld3 period_ price price2
admonishing 1002 28357832 8723648
analyzable 1002 28357832 8723648
annihilates 1001 5987435 234724
@@ -1279,8 +1279,8 @@ ventilate 1001 5987435 234724
wallet 1001 5987435 234724
Weissmuller 1002 28357832 8723648
Wotan 1002 28357832 8723648
-select t2.fld1,fld3,period,price,price2 from t2,t3 where t2.fld1>= 18201 and t2.fld1 <= 18811 and t2.fld1=t3.t2nr and period = 1001 and t2.companynr = 37;
-fld1 fld3 period price price2
+select t2.fld1,fld3,period_,price,price2 from t2,t3 where t2.fld1>= 18201 and t2.fld1 <= 18811 and t2.fld1=t3.t2nr and period_ = 1001 and t2.companynr = 37;
+fld1 fld3 period_ price price2
018201 relaxing 1001 5987435 234724
018601 vacuuming 1001 5987435 234724
018801 inch 1001 5987435 234724
@@ -1320,7 +1320,7 @@ companynr companyname
65 company 9
68 company 10
select * from t1,t1 t12;
-Period Varor_period Period Varor_period
+Period_ Varor_period Period_ Varor_period
9410 9412 9410 9412
select t2.fld1,t22.fld1 from t2,t2 t22 where t2.fld1 >= 250501 and t2.fld1 <= 250505 and t22.fld1 >= 250501 and t22.fld1 <= 250505;
fld1 fld1
@@ -1435,23 +1435,23 @@ explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 index NULL PRIMARY 1 NULL 12 Using index; Using temporary
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where; Using join buffer (flat, BNL join)
-select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008;
-fld1 companynr fld3 period
+select t2.fld1,t2.companynr,fld3,period_ from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period_ = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period_ = 1008;
+fld1 companynr fld3 period_
038008 37 reporters 1008
038208 37 Selfridge 1008
-select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t2.fld1 = 38208 or t2.fld1 = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009;
-fld1 companynr fld3 period
+select t2.fld1,t2.companynr,fld3,period_ from t3,t2 where (t2.fld1 = 38208 or t2.fld1 = 38008) and t2.fld1=t3.t2nr and period_>=1008 and period_<=1009;
+fld1 companynr fld3 period_
038008 37 reporters 1008
038208 37 Selfridge 1008
-select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t3.t2nr = 38208 or t3.t2nr = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009;
-fld1 companynr fld3 period
+select t2.fld1,t2.companynr,fld3,period_ from t3,t2 where (t3.t2nr = 38208 or t3.t2nr = 38008) and t2.fld1=t3.t2nr and period_>=1008 and period_<=1009;
+fld1 companynr fld3 period_
038008 37 reporters 1008
038208 37 Selfridge 1008
-select period from t1 where (((period > 0) or period < 10000 or (period = 1900)) and (period=1900 and period <= 1901) or (period=1903 and (period=1903)) and period>=1902) or ((period=1904 or period=1905) or (period=1906 or period>1907)) or (period=1908 and period = 1909);
-period
+select period_ from t1 where (((period_ > 0) or period_ < 10000 or (period_ = 1900)) and (period_=1900 and period_ <= 1901) or (period_=1903 and (period_=1903)) and period_>=1902) or ((period_=1904 or period_=1905) or (period_=1906 or period_>1907)) or (period_=1908 and period_ = 1909);
+period_
9410
-select period from t1 where ((period > 0 and period < 1) or (((period > 0 and period < 100) and (period > 10)) or (period > 10)) or (period > 0 and (period > 5 or period > 6)));
-period
+select period_ from t1 where ((period_ > 0 and period_ < 1) or (((period_ > 0 and period_ < 100) and (period_ > 10)) or (period_ > 10)) or (period_ > 0 and (period_ > 5 or period_ > 6)));
+period_
9410
select a.fld1 from t2 as a,t2 b where ((a.fld1 = 250501 and a.fld1=b.fld1) or a.fld1=250502 or a.fld1=250503 or (a.fld1=250505 and a.fld1<=b.fld1 and b.fld1>=a.fld1)) and a.fld1=b.fld1;
fld1
@@ -1708,8 +1708,8 @@ companynr companyname count(*)
select t2.fld1,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name;
fld1 count(*)
158402 4181
-select sum(Period)/count(*) from t1;
-sum(Period)/count(*)
+select sum(Period_)/count(*) from t1;
+sum(Period_)/count(*)
9410.0000
select companynr,count(price) as "count",sum(price) as "sum" ,abs(sum(price)/count(price)-avg(price)) as "diff",(0+count(price))*companynr as func from t3 group by companynr;
companynr count sum diff func
@@ -2039,26 +2039,26 @@ t2nr count(*)
select max(t2nr) from t3 where price=983543950;
max(t2nr)
41807
-select t1.period from t3 = t1 limit 1;
-period
+select t1.period_ from t3 = t1 limit 1;
+period_
1001
-select t1.period from t1 as t1 limit 1;
-period
+select t1.period_ from t1 as t1 limit 1;
+period_
9410
-select t1.period as "Nuvarande period" from t1 as t1 limit 1;
-Nuvarande period
+select t1.period_ as "Nuvarande period_" from t1 as t1 limit 1;
+Nuvarande period_
9410
-select period as ok_period from t1 limit 1;
+select period_ as ok_period from t1 limit 1;
ok_period
9410
-select period as ok_period from t1 group by ok_period limit 1;
+select period_ as ok_period from t1 group by ok_period limit 1;
ok_period
9410
select 1+1 as summa from t1 group by summa limit 1;
summa
2
-select period as "Nuvarande period" from t1 group by "Nuvarande period" limit 1;
-Nuvarande period
+select period_ as "Nuvarande period_" from t1 group by "Nuvarande period_" limit 1;
+Nuvarande period_
9410
show tables;
Tables_in_test
diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result
index 5859bd0fae6..c260e2ff333 100644
--- a/mysql-test/r/select.result
+++ b/mysql-test/r/select.result
@@ -5,18 +5,18 @@ SET @save_optimizer_switch=@@optimizer_switch;
SET optimizer_switch=ifnull(@optimizer_switch_for_select_test,'outer_join_with_cache=off');
set join_cache_level=1;
CREATE TABLE t1 (
-Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
+Period_ smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL
);
INSERT INTO t1 VALUES (9410,9412);
-select period from t1;
-period
+select period_ from t1;
+period_
9410
select * from t1;
-Period Varor_period
+Period_ Varor_period
9410 9412
select t1.* from t1;
-Period Varor_period
+Period_ Varor_period
9410 9412
CREATE TABLE t2 (
auto int not null auto_increment,
@@ -280,8 +280,8 @@ companynr
34
29
00
-select distinct t2.fld3,period from t2,t1 where companynr=37 and fld3 like "O%";
-fld3 period
+select distinct t2.fld3,period_ from t2,t1 where companynr=37 and fld3 like "O%";
+fld3 period_
obliterates 9410
offload 9410
opaquely 9410
@@ -485,12 +485,12 @@ acu
Ade
adj
create table t3 (
-period int not null,
+period_ int not null,
name char(32) not null,
companynr int not null,
price double(11,0),
price2 double(11,0),
-key (period),
+key (period_),
key (name)
);
create temporary table tmp engine = myisam select * from t3;
@@ -604,35 +604,35 @@ explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL fld1 NULL NULL NULL 1199 Using where; Using temporary; Using filesort
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.fld1 1 Using where; Using index
-explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period;
+explain select * from t3 as t1,t3 where t1.period_=t3.period_ order by t3.period_;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using filesort
-1 SIMPLE t3 ref period period 4 test.t1.period 4181
-explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10;
+1 SIMPLE t1 ALL period_ NULL NULL NULL 41810 Using filesort
+1 SIMPLE t3 ref period_ period_ 4 test.t1.period_ 4181
+explain select * from t3 as t1,t3 where t1.period_=t3.period_ order by t3.period_ limit 10;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 index period period 4 NULL 1
-1 SIMPLE t1 ref period period 4 test.t3.period 4181
-explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10;
+1 SIMPLE t3 index period_ period_ 4 NULL 1
+1 SIMPLE t1 ref period_ period_ 4 test.t3.period_ 4181
+explain select * from t3 as t1,t3 where t1.period_=t3.period_ order by t1.period_ limit 10;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index period period 4 NULL 1
-1 SIMPLE t3 ref period period 4 test.t1.period 4181
-select period from t1;
-period
+1 SIMPLE t1 index period_ period_ 4 NULL 1
+1 SIMPLE t3 ref period_ period_ 4 test.t1.period_ 4181
+select period_ from t1;
+period_
9410
-select period from t1 where period=1900;
-period
-select fld3,period from t1,t2 where fld1 = 011401 order by period;
-fld3 period
+select period_ from t1 where period_=1900;
+period_
+select fld3,period_ from t1,t2 where fld1 = 011401 order by period_;
+fld3 period_
breaking 9410
-select fld3,period from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.period=1001;
-fld3 period
+select fld3,period_ from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.period_=1001;
+fld3 period_
breaking 1001
-explain select fld3,period from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period;
+explain select fld3,period_ from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period_;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 const fld1 fld1 4 const 1
-1 SIMPLE t3 const PRIMARY,period PRIMARY 4 const 1
-select fld3,period from t2,t1 where companynr*10 = 37*10;
-fld3 period
+1 SIMPLE t3 const PRIMARY,period_ PRIMARY 4 const 1
+select fld3,period_ from t2,t1 where companynr*10 = 37*10;
+fld3 period_
breaking 9410
Romans 9410
intercepted 9410
@@ -1221,8 +1221,8 @@ dusted 9410
encompasses 9410
presentation 9410
Kantian 9410
-select fld3,period,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period >= 1001 and period <= 1002 and t2.companynr = 37 order by fld3,period, price;
-fld3 period price price2
+select fld3,period_,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period_ >= 1001 and period_ <= 1002 and t2.companynr = 37 order by fld3,period_, price;
+fld3 period_ price price2
admonishing 1002 28357832 8723648
analyzable 1002 28357832 8723648
annihilates 1001 5987435 234724
@@ -1282,8 +1282,8 @@ ventilate 1001 5987435 234724
wallet 1001 5987435 234724
Weissmuller 1002 28357832 8723648
Wotan 1002 28357832 8723648
-select t2.fld1,fld3,period,price,price2 from t2,t3 where t2.fld1>= 18201 and t2.fld1 <= 18811 and t2.fld1=t3.t2nr and period = 1001 and t2.companynr = 37;
-fld1 fld3 period price price2
+select t2.fld1,fld3,period_,price,price2 from t2,t3 where t2.fld1>= 18201 and t2.fld1 <= 18811 and t2.fld1=t3.t2nr and period_ = 1001 and t2.companynr = 37;
+fld1 fld3 period_ price price2
018201 relaxing 1001 5987435 234724
018601 vacuuming 1001 5987435 234724
018801 inch 1001 5987435 234724
@@ -1323,7 +1323,7 @@ companynr companyname
65 company 9
68 company 10
select * from t1,t1 t12;
-Period Varor_period Period Varor_period
+Period_ Varor_period Period_ Varor_period
9410 9412 9410 9412
select t2.fld1,t22.fld1 from t2,t2 t22 where t2.fld1 >= 250501 and t2.fld1 <= 250505 and t22.fld1 >= 250501 and t22.fld1 <= 250505;
fld1 fld1
@@ -1435,23 +1435,23 @@ explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 index NULL PRIMARY 1 NULL 12 Using index; Using temporary
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where; Using join buffer (flat, BNL join)
-select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008;
-fld1 companynr fld3 period
+select t2.fld1,t2.companynr,fld3,period_ from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period_ = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period_ = 1008;
+fld1 companynr fld3 period_
038008 37 reporters 1008
038208 37 Selfridge 1008
-select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t2.fld1 = 38208 or t2.fld1 = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009;
-fld1 companynr fld3 period
+select t2.fld1,t2.companynr,fld3,period_ from t3,t2 where (t2.fld1 = 38208 or t2.fld1 = 38008) and t2.fld1=t3.t2nr and period_>=1008 and period_<=1009;
+fld1 companynr fld3 period_
038008 37 reporters 1008
038208 37 Selfridge 1008
-select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t3.t2nr = 38208 or t3.t2nr = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009;
-fld1 companynr fld3 period
+select t2.fld1,t2.companynr,fld3,period_ from t3,t2 where (t3.t2nr = 38208 or t3.t2nr = 38008) and t2.fld1=t3.t2nr and period_>=1008 and period_<=1009;
+fld1 companynr fld3 period_
038008 37 reporters 1008
038208 37 Selfridge 1008
-select period from t1 where (((period > 0) or period < 10000 or (period = 1900)) and (period=1900 and period <= 1901) or (period=1903 and (period=1903)) and period>=1902) or ((period=1904 or period=1905) or (period=1906 or period>1907)) or (period=1908 and period = 1909);
-period
+select period_ from t1 where (((period_ > 0) or period_ < 10000 or (period_ = 1900)) and (period_=1900 and period_ <= 1901) or (period_=1903 and (period_=1903)) and period_>=1902) or ((period_=1904 or period_=1905) or (period_=1906 or period_>1907)) or (period_=1908 and period_ = 1909);
+period_
9410
-select period from t1 where ((period > 0 and period < 1) or (((period > 0 and period < 100) and (period > 10)) or (period > 10)) or (period > 0 and (period > 5 or period > 6)));
-period
+select period_ from t1 where ((period_ > 0 and period_ < 1) or (((period_ > 0 and period_ < 100) and (period_ > 10)) or (period_ > 10)) or (period_ > 0 and (period_ > 5 or period_ > 6)));
+period_
9410
select a.fld1 from t2 as a,t2 b where ((a.fld1 = 250501 and a.fld1=b.fld1) or a.fld1=250502 or a.fld1=250503 or (a.fld1=250505 and a.fld1<=b.fld1 and b.fld1>=a.fld1)) and a.fld1=b.fld1;
fld1
@@ -1708,8 +1708,8 @@ companynr companyname count(*)
select t2.fld1,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name;
fld1 count(*)
158402 4181
-select sum(Period)/count(*) from t1;
-sum(Period)/count(*)
+select sum(Period_)/count(*) from t1;
+sum(Period_)/count(*)
9410.0000
select companynr,count(price) as "count",sum(price) as "sum" ,abs(sum(price)/count(price)-avg(price)) as "diff",(0+count(price))*companynr as func from t3 group by companynr;
companynr count sum diff func
@@ -2039,26 +2039,26 @@ t2nr count(*)
select max(t2nr) from t3 where price=983543950;
max(t2nr)
41807
-select t1.period from t3 = t1 limit 1;
-period
+select t1.period_ from t3 = t1 limit 1;
+period_
1001
-select t1.period from t1 as t1 limit 1;
-period
+select t1.period_ from t1 as t1 limit 1;
+period_
9410
-select t1.period as "Nuvarande period" from t1 as t1 limit 1;
-Nuvarande period
+select t1.period_ as "Nuvarande period_" from t1 as t1 limit 1;
+Nuvarande period_
9410
-select period as ok_period from t1 limit 1;
+select period_ as ok_period from t1 limit 1;
ok_period
9410
-select period as ok_period from t1 group by ok_period limit 1;
+select period_ as ok_period from t1 group by ok_period limit 1;
ok_period
9410
select 1+1 as summa from t1 group by summa limit 1;
summa
2
-select period as "Nuvarande period" from t1 group by "Nuvarande period" limit 1;
-Nuvarande period
+select period_ as "Nuvarande period_" from t1 group by "Nuvarande period_" limit 1;
+Nuvarande period_
9410
show tables;
Tables_in_test
@@ -5548,3 +5548,68 @@ select (SELECT name FROM t1 WHERE name='tom' AND pw=PASSWORD(@undefined));
NULL
drop table t1;
End of 10.0 tests
+#
+# System Versioning Support
+#
+#
+CREATE TABLE t1( x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)) WITH SYSTEM VERSIONING;
+INSERT INTO t1(x, y) VALUES
+(0, 100),
+(1, 101),
+(2, 102),
+(3, 103),
+(4, 104),
+(5, 105),
+(6, 106),
+(7, 107),
+(8, 108),
+(9, 109);
+DELETE FROM t1 WHERE x = 3;
+DELETE FROM t1 WHERE x > 7;
+INSERT INTO t1(x, y) VALUES(3, 33);
+SELECT @time := Sys_start FROM t1 FOR SYSTEM_TIME BETWEEN TIMESTAMP '0-0-0 0:0:0' AND TIMESTAMP '2038-01-19 04:14:07' WHERE x = 3 AND y = 33;
+@time := Sys_start
+Sys_start
+SELECT x, y FROM t1;
+x y
+0 100
+1 101
+2 102
+4 104
+5 105
+6 106
+7 107
+3 33
+SET @query=CONCAT('SELECT x, y FROM t1 FOR SYSTEM_TIME FROM TIMESTAMP \'0-0-0 0:0:0\' TO TIMESTAMP \'', @time, '\'');
+PREPARE stmt_t1 FROM @query;
+EXECUTE stmt_t1;
+x y
+0 100
+1 101
+2 102
+3 103
+4 104
+5 105
+6 106
+7 107
+8 108
+9 109
+SET @query=CONCAT('SELECT x, y FROM t1 FOR SYSTEM_TIME BETWEEN TIMESTAMP \'0-0-0 0:0:0\' AND TIMESTAMP \'', @time, '\'');
+PREPARE stmt_t1 FROM @query;
+EXECUTE stmt_t1;
+x y
+0 100
+1 101
+2 102
+3 103
+4 104
+5 105
+6 106
+7 107
+8 108
+9 109
+3 33
+SET @time=NULL;
+SET @query=NULL;
+DEALLOCATE PREPARE stmt_t1;
+DROP TABLE t1;
diff --git a/mysql-test/r/select_jcl6.result b/mysql-test/r/select_jcl6.result
index c9d582bb75a..ade583db19e 100644
--- a/mysql-test/r/select_jcl6.result
+++ b/mysql-test/r/select_jcl6.result
@@ -16,18 +16,18 @@ SET @save_optimizer_switch=@@optimizer_switch;
SET optimizer_switch=ifnull(@optimizer_switch_for_select_test,'outer_join_with_cache=off');
set join_cache_level=@join_cache_level_for_select_test;
CREATE TABLE t1 (
-Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
+Period_ smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL
);
INSERT INTO t1 VALUES (9410,9412);
-select period from t1;
-period
+select period_ from t1;
+period_
9410
select * from t1;
-Period Varor_period
+Period_ Varor_period
9410 9412
select t1.* from t1;
-Period Varor_period
+Period_ Varor_period
9410 9412
CREATE TABLE t2 (
auto int not null auto_increment,
@@ -291,8 +291,8 @@ companynr
34
29
00
-select distinct t2.fld3,period from t2,t1 where companynr=37 and fld3 like "O%";
-fld3 period
+select distinct t2.fld3,period_ from t2,t1 where companynr=37 and fld3 like "O%";
+fld3 period_
obliterates 9410
offload 9410
opaquely 9410
@@ -496,12 +496,12 @@ acu
Ade
adj
create table t3 (
-period int not null,
+period_ int not null,
name char(32) not null,
companynr int not null,
price double(11,0),
price2 double(11,0),
-key (period),
+key (period_),
key (name)
);
create temporary table tmp engine = myisam select * from t3;
@@ -615,35 +615,35 @@ explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL fld1 NULL NULL NULL 1199 Using where; Using temporary; Using filesort
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.fld1 1 Using where; Using index
-explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period;
+explain select * from t3 as t1,t3 where t1.period_=t3.period_ order by t3.period_;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using temporary; Using filesort
-1 SIMPLE t3 ref period period 4 test.t1.period 4181 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
-explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10;
+1 SIMPLE t1 ALL period_ NULL NULL NULL 41810 Using temporary; Using filesort
+1 SIMPLE t3 ref period_ period_ 4 test.t1.period_ 4181 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
+explain select * from t3 as t1,t3 where t1.period_=t3.period_ order by t3.period_ limit 10;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 ALL period NULL NULL NULL 41810 Using temporary; Using filesort
-1 SIMPLE t1 ref period period 4 test.t3.period 4181 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
-explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10;
+1 SIMPLE t3 ALL period_ NULL NULL NULL 41810 Using temporary; Using filesort
+1 SIMPLE t1 ref period_ period_ 4 test.t3.period_ 4181 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
+explain select * from t3 as t1,t3 where t1.period_=t3.period_ order by t1.period_ limit 10;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using temporary; Using filesort
-1 SIMPLE t3 ref period period 4 test.t1.period 4181 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
-select period from t1;
-period
+1 SIMPLE t1 ALL period_ NULL NULL NULL 41810 Using temporary; Using filesort
+1 SIMPLE t3 ref period_ period_ 4 test.t1.period_ 4181 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
+select period_ from t1;
+period_
9410
-select period from t1 where period=1900;
-period
-select fld3,period from t1,t2 where fld1 = 011401 order by period;
-fld3 period
+select period_ from t1 where period_=1900;
+period_
+select fld3,period_ from t1,t2 where fld1 = 011401 order by period_;
+fld3 period_
breaking 9410
-select fld3,period from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.period=1001;
-fld3 period
+select fld3,period_ from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.period_=1001;
+fld3 period_
breaking 1001
-explain select fld3,period from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period;
+explain select fld3,period_ from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period_;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 const fld1 fld1 4 const 1
-1 SIMPLE t3 const PRIMARY,period PRIMARY 4 const 1
-select fld3,period from t2,t1 where companynr*10 = 37*10;
-fld3 period
+1 SIMPLE t3 const PRIMARY,period_ PRIMARY 4 const 1
+select fld3,period_ from t2,t1 where companynr*10 = 37*10;
+fld3 period_
breaking 9410
Romans 9410
intercepted 9410
@@ -1232,8 +1232,8 @@ dusted 9410
encompasses 9410
presentation 9410
Kantian 9410
-select fld3,period,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period >= 1001 and period <= 1002 and t2.companynr = 37 order by fld3,period, price;
-fld3 period price price2
+select fld3,period_,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period_ >= 1001 and period_ <= 1002 and t2.companynr = 37 order by fld3,period_, price;
+fld3 period_ price price2
admonishing 1002 28357832 8723648
analyzable 1002 28357832 8723648
annihilates 1001 5987435 234724
@@ -1293,8 +1293,8 @@ ventilate 1001 5987435 234724
wallet 1001 5987435 234724
Weissmuller 1002 28357832 8723648
Wotan 1002 28357832 8723648
-select t2.fld1,fld3,period,price,price2 from t2,t3 where t2.fld1>= 18201 and t2.fld1 <= 18811 and t2.fld1=t3.t2nr and period = 1001 and t2.companynr = 37;
-fld1 fld3 period price price2
+select t2.fld1,fld3,period_,price,price2 from t2,t3 where t2.fld1>= 18201 and t2.fld1 <= 18811 and t2.fld1=t3.t2nr and period_ = 1001 and t2.companynr = 37;
+fld1 fld3 period_ price price2
018201 relaxing 1001 5987435 234724
018601 vacuuming 1001 5987435 234724
018801 inch 1001 5987435 234724
@@ -1334,7 +1334,7 @@ companynr companyname
65 company 9
68 company 10
select * from t1,t1 t12;
-Period Varor_period Period Varor_period
+Period_ Varor_period Period_ Varor_period
9410 9412 9410 9412
select t2.fld1,t22.fld1 from t2,t2 t22 where t2.fld1 >= 250501 and t2.fld1 <= 250505 and t22.fld1 >= 250501 and t22.fld1 <= 250505;
fld1 fld1
@@ -1446,23 +1446,23 @@ explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 index NULL PRIMARY 1 NULL 12 Using index; Using temporary
1 SIMPLE t2 hash_ALL NULL #hash#$hj 1 func 1199 Using where; Using join buffer (flat, BNLH join)
-select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008;
-fld1 companynr fld3 period
+select t2.fld1,t2.companynr,fld3,period_ from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period_ = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period_ = 1008;
+fld1 companynr fld3 period_
038008 37 reporters 1008
038208 37 Selfridge 1008
-select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t2.fld1 = 38208 or t2.fld1 = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009;
-fld1 companynr fld3 period
+select t2.fld1,t2.companynr,fld3,period_ from t3,t2 where (t2.fld1 = 38208 or t2.fld1 = 38008) and t2.fld1=t3.t2nr and period_>=1008 and period_<=1009;
+fld1 companynr fld3 period_
038008 37 reporters 1008
038208 37 Selfridge 1008
-select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t3.t2nr = 38208 or t3.t2nr = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009;
-fld1 companynr fld3 period
+select t2.fld1,t2.companynr,fld3,period_ from t3,t2 where (t3.t2nr = 38208 or t3.t2nr = 38008) and t2.fld1=t3.t2nr and period_>=1008 and period_<=1009;
+fld1 companynr fld3 period_
038008 37 reporters 1008
038208 37 Selfridge 1008
-select period from t1 where (((period > 0) or period < 10000 or (period = 1900)) and (period=1900 and period <= 1901) or (period=1903 and (period=1903)) and period>=1902) or ((period=1904 or period=1905) or (period=1906 or period>1907)) or (period=1908 and period = 1909);
-period
+select period_ from t1 where (((period_ > 0) or period_ < 10000 or (period_ = 1900)) and (period_=1900 and period_ <= 1901) or (period_=1903 and (period_=1903)) and period_>=1902) or ((period_=1904 or period_=1905) or (period_=1906 or period_>1907)) or (period_=1908 and period_ = 1909);
+period_
9410
-select period from t1 where ((period > 0 and period < 1) or (((period > 0 and period < 100) and (period > 10)) or (period > 10)) or (period > 0 and (period > 5 or period > 6)));
-period
+select period_ from t1 where ((period_ > 0 and period_ < 1) or (((period_ > 0 and period_ < 100) and (period_ > 10)) or (period_ > 10)) or (period_ > 0 and (period_ > 5 or period_ > 6)));
+period_
9410
select a.fld1 from t2 as a,t2 b where ((a.fld1 = 250501 and a.fld1=b.fld1) or a.fld1=250502 or a.fld1=250503 or (a.fld1=250505 and a.fld1<=b.fld1 and b.fld1>=a.fld1)) and a.fld1=b.fld1;
fld1
@@ -1719,8 +1719,8 @@ companynr companyname count(*)
select t2.fld1,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name;
fld1 count(*)
158402 4181
-select sum(Period)/count(*) from t1;
-sum(Period)/count(*)
+select sum(Period_)/count(*) from t1;
+sum(Period_)/count(*)
9410.0000
select companynr,count(price) as "count",sum(price) as "sum" ,abs(sum(price)/count(price)-avg(price)) as "diff",(0+count(price))*companynr as func from t3 group by companynr;
companynr count sum diff func
@@ -2050,26 +2050,26 @@ t2nr count(*)
select max(t2nr) from t3 where price=983543950;
max(t2nr)
41807
-select t1.period from t3 = t1 limit 1;
-period
+select t1.period_ from t3 = t1 limit 1;
+period_
1001
-select t1.period from t1 as t1 limit 1;
-period
+select t1.period_ from t1 as t1 limit 1;
+period_
9410
-select t1.period as "Nuvarande period" from t1 as t1 limit 1;
-Nuvarande period
+select t1.period_ as "Nuvarande period_" from t1 as t1 limit 1;
+Nuvarande period_
9410
-select period as ok_period from t1 limit 1;
+select period_ as ok_period from t1 limit 1;
ok_period
9410
-select period as ok_period from t1 group by ok_period limit 1;
+select period_ as ok_period from t1 group by ok_period limit 1;
ok_period
9410
select 1+1 as summa from t1 group by summa limit 1;
summa
2
-select period as "Nuvarande period" from t1 group by "Nuvarande period" limit 1;
-Nuvarande period
+select period_ as "Nuvarande period_" from t1 group by "Nuvarande period_" limit 1;
+Nuvarande period_
9410
show tables;
Tables_in_test
@@ -5559,6 +5559,71 @@ select (SELECT name FROM t1 WHERE name='tom' AND pw=PASSWORD(@undefined));
NULL
drop table t1;
End of 10.0 tests
+#
+# System Versioning Support
+#
+#
+CREATE TABLE t1( x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)) WITH SYSTEM VERSIONING;
+INSERT INTO t1(x, y) VALUES
+(0, 100),
+(1, 101),
+(2, 102),
+(3, 103),
+(4, 104),
+(5, 105),
+(6, 106),
+(7, 107),
+(8, 108),
+(9, 109);
+DELETE FROM t1 WHERE x = 3;
+DELETE FROM t1 WHERE x > 7;
+INSERT INTO t1(x, y) VALUES(3, 33);
+SELECT @time := Sys_start FROM t1 FOR SYSTEM_TIME BETWEEN TIMESTAMP '0-0-0 0:0:0' AND TIMESTAMP '2038-01-19 04:14:07' WHERE x = 3 AND y = 33;
+@time := Sys_start
+Sys_start
+SELECT x, y FROM t1;
+x y
+0 100
+1 101
+2 102
+4 104
+5 105
+6 106
+7 107
+3 33
+SET @query=CONCAT('SELECT x, y FROM t1 FOR SYSTEM_TIME FROM TIMESTAMP \'0-0-0 0:0:0\' TO TIMESTAMP \'', @time, '\'');
+PREPARE stmt_t1 FROM @query;
+EXECUTE stmt_t1;
+x y
+0 100
+1 101
+2 102
+3 103
+4 104
+5 105
+6 106
+7 107
+8 108
+9 109
+SET @query=CONCAT('SELECT x, y FROM t1 FOR SYSTEM_TIME BETWEEN TIMESTAMP \'0-0-0 0:0:0\' AND TIMESTAMP \'', @time, '\'');
+PREPARE stmt_t1 FROM @query;
+EXECUTE stmt_t1;
+x y
+0 100
+1 101
+2 102
+3 103
+4 104
+5 105
+6 106
+7 107
+8 108
+9 109
+3 33
+SET @time=NULL;
+SET @query=NULL;
+DEALLOCATE PREPARE stmt_t1;
+DROP TABLE t1;
set join_cache_level=default;
show variables like 'join_cache_level';
Variable_name Value
diff --git a/mysql-test/r/select_pkeycache.result b/mysql-test/r/select_pkeycache.result
index 5859bd0fae6..c260e2ff333 100644
--- a/mysql-test/r/select_pkeycache.result
+++ b/mysql-test/r/select_pkeycache.result
@@ -5,18 +5,18 @@ SET @save_optimizer_switch=@@optimizer_switch;
SET optimizer_switch=ifnull(@optimizer_switch_for_select_test,'outer_join_with_cache=off');
set join_cache_level=1;
CREATE TABLE t1 (
-Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
+Period_ smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL
);
INSERT INTO t1 VALUES (9410,9412);
-select period from t1;
-period
+select period_ from t1;
+period_
9410
select * from t1;
-Period Varor_period
+Period_ Varor_period
9410 9412
select t1.* from t1;
-Period Varor_period
+Period_ Varor_period
9410 9412
CREATE TABLE t2 (
auto int not null auto_increment,
@@ -280,8 +280,8 @@ companynr
34
29
00
-select distinct t2.fld3,period from t2,t1 where companynr=37 and fld3 like "O%";
-fld3 period
+select distinct t2.fld3,period_ from t2,t1 where companynr=37 and fld3 like "O%";
+fld3 period_
obliterates 9410
offload 9410
opaquely 9410
@@ -485,12 +485,12 @@ acu
Ade
adj
create table t3 (
-period int not null,
+period_ int not null,
name char(32) not null,
companynr int not null,
price double(11,0),
price2 double(11,0),
-key (period),
+key (period_),
key (name)
);
create temporary table tmp engine = myisam select * from t3;
@@ -604,35 +604,35 @@ explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL fld1 NULL NULL NULL 1199 Using where; Using temporary; Using filesort
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.fld1 1 Using where; Using index
-explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period;
+explain select * from t3 as t1,t3 where t1.period_=t3.period_ order by t3.period_;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using filesort
-1 SIMPLE t3 ref period period 4 test.t1.period 4181
-explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10;
+1 SIMPLE t1 ALL period_ NULL NULL NULL 41810 Using filesort
+1 SIMPLE t3 ref period_ period_ 4 test.t1.period_ 4181
+explain select * from t3 as t1,t3 where t1.period_=t3.period_ order by t3.period_ limit 10;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 index period period 4 NULL 1
-1 SIMPLE t1 ref period period 4 test.t3.period 4181
-explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10;
+1 SIMPLE t3 index period_ period_ 4 NULL 1
+1 SIMPLE t1 ref period_ period_ 4 test.t3.period_ 4181
+explain select * from t3 as t1,t3 where t1.period_=t3.period_ order by t1.period_ limit 10;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index period period 4 NULL 1
-1 SIMPLE t3 ref period period 4 test.t1.period 4181
-select period from t1;
-period
+1 SIMPLE t1 index period_ period_ 4 NULL 1
+1 SIMPLE t3 ref period_ period_ 4 test.t1.period_ 4181
+select period_ from t1;
+period_
9410
-select period from t1 where period=1900;
-period
-select fld3,period from t1,t2 where fld1 = 011401 order by period;
-fld3 period
+select period_ from t1 where period_=1900;
+period_
+select fld3,period_ from t1,t2 where fld1 = 011401 order by period_;
+fld3 period_
breaking 9410
-select fld3,period from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.period=1001;
-fld3 period
+select fld3,period_ from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.period_=1001;
+fld3 period_
breaking 1001
-explain select fld3,period from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period;
+explain select fld3,period_ from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period_;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 const fld1 fld1 4 const 1
-1 SIMPLE t3 const PRIMARY,period PRIMARY 4 const 1
-select fld3,period from t2,t1 where companynr*10 = 37*10;
-fld3 period
+1 SIMPLE t3 const PRIMARY,period_ PRIMARY 4 const 1
+select fld3,period_ from t2,t1 where companynr*10 = 37*10;
+fld3 period_
breaking 9410
Romans 9410
intercepted 9410
@@ -1221,8 +1221,8 @@ dusted 9410
encompasses 9410
presentation 9410
Kantian 9410
-select fld3,period,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period >= 1001 and period <= 1002 and t2.companynr = 37 order by fld3,period, price;
-fld3 period price price2
+select fld3,period_,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period_ >= 1001 and period_ <= 1002 and t2.companynr = 37 order by fld3,period_, price;
+fld3 period_ price price2
admonishing 1002 28357832 8723648
analyzable 1002 28357832 8723648
annihilates 1001 5987435 234724
@@ -1282,8 +1282,8 @@ ventilate 1001 5987435 234724
wallet 1001 5987435 234724
Weissmuller 1002 28357832 8723648
Wotan 1002 28357832 8723648
-select t2.fld1,fld3,period,price,price2 from t2,t3 where t2.fld1>= 18201 and t2.fld1 <= 18811 and t2.fld1=t3.t2nr and period = 1001 and t2.companynr = 37;
-fld1 fld3 period price price2
+select t2.fld1,fld3,period_,price,price2 from t2,t3 where t2.fld1>= 18201 and t2.fld1 <= 18811 and t2.fld1=t3.t2nr and period_ = 1001 and t2.companynr = 37;
+fld1 fld3 period_ price price2
018201 relaxing 1001 5987435 234724
018601 vacuuming 1001 5987435 234724
018801 inch 1001 5987435 234724
@@ -1323,7 +1323,7 @@ companynr companyname
65 company 9
68 company 10
select * from t1,t1 t12;
-Period Varor_period Period Varor_period
+Period_ Varor_period Period_ Varor_period
9410 9412 9410 9412
select t2.fld1,t22.fld1 from t2,t2 t22 where t2.fld1 >= 250501 and t2.fld1 <= 250505 and t22.fld1 >= 250501 and t22.fld1 <= 250505;
fld1 fld1
@@ -1435,23 +1435,23 @@ explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 index NULL PRIMARY 1 NULL 12 Using index; Using temporary
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where; Using join buffer (flat, BNL join)
-select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008;
-fld1 companynr fld3 period
+select t2.fld1,t2.companynr,fld3,period_ from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period_ = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period_ = 1008;
+fld1 companynr fld3 period_
038008 37 reporters 1008
038208 37 Selfridge 1008
-select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t2.fld1 = 38208 or t2.fld1 = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009;
-fld1 companynr fld3 period
+select t2.fld1,t2.companynr,fld3,period_ from t3,t2 where (t2.fld1 = 38208 or t2.fld1 = 38008) and t2.fld1=t3.t2nr and period_>=1008 and period_<=1009;
+fld1 companynr fld3 period_
038008 37 reporters 1008
038208 37 Selfridge 1008
-select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t3.t2nr = 38208 or t3.t2nr = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009;
-fld1 companynr fld3 period
+select t2.fld1,t2.companynr,fld3,period_ from t3,t2 where (t3.t2nr = 38208 or t3.t2nr = 38008) and t2.fld1=t3.t2nr and period_>=1008 and period_<=1009;
+fld1 companynr fld3 period_
038008 37 reporters 1008
038208 37 Selfridge 1008
-select period from t1 where (((period > 0) or period < 10000 or (period = 1900)) and (period=1900 and period <= 1901) or (period=1903 and (period=1903)) and period>=1902) or ((period=1904 or period=1905) or (period=1906 or period>1907)) or (period=1908 and period = 1909);
-period
+select period_ from t1 where (((period_ > 0) or period_ < 10000 or (period_ = 1900)) and (period_=1900 and period_ <= 1901) or (period_=1903 and (period_=1903)) and period_>=1902) or ((period_=1904 or period_=1905) or (period_=1906 or period_>1907)) or (period_=1908 and period_ = 1909);
+period_
9410
-select period from t1 where ((period > 0 and period < 1) or (((period > 0 and period < 100) and (period > 10)) or (period > 10)) or (period > 0 and (period > 5 or period > 6)));
-period
+select period_ from t1 where ((period_ > 0 and period_ < 1) or (((period_ > 0 and period_ < 100) and (period_ > 10)) or (period_ > 10)) or (period_ > 0 and (period_ > 5 or period_ > 6)));
+period_
9410
select a.fld1 from t2 as a,t2 b where ((a.fld1 = 250501 and a.fld1=b.fld1) or a.fld1=250502 or a.fld1=250503 or (a.fld1=250505 and a.fld1<=b.fld1 and b.fld1>=a.fld1)) and a.fld1=b.fld1;
fld1
@@ -1708,8 +1708,8 @@ companynr companyname count(*)
select t2.fld1,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name;
fld1 count(*)
158402 4181
-select sum(Period)/count(*) from t1;
-sum(Period)/count(*)
+select sum(Period_)/count(*) from t1;
+sum(Period_)/count(*)
9410.0000
select companynr,count(price) as "count",sum(price) as "sum" ,abs(sum(price)/count(price)-avg(price)) as "diff",(0+count(price))*companynr as func from t3 group by companynr;
companynr count sum diff func
@@ -2039,26 +2039,26 @@ t2nr count(*)
select max(t2nr) from t3 where price=983543950;
max(t2nr)
41807
-select t1.period from t3 = t1 limit 1;
-period
+select t1.period_ from t3 = t1 limit 1;
+period_
1001
-select t1.period from t1 as t1 limit 1;
-period
+select t1.period_ from t1 as t1 limit 1;
+period_
9410
-select t1.period as "Nuvarande period" from t1 as t1 limit 1;
-Nuvarande period
+select t1.period_ as "Nuvarande period_" from t1 as t1 limit 1;
+Nuvarande period_
9410
-select period as ok_period from t1 limit 1;
+select period_ as ok_period from t1 limit 1;
ok_period
9410
-select period as ok_period from t1 group by ok_period limit 1;
+select period_ as ok_period from t1 group by ok_period limit 1;
ok_period
9410
select 1+1 as summa from t1 group by summa limit 1;
summa
2
-select period as "Nuvarande period" from t1 group by "Nuvarande period" limit 1;
-Nuvarande period
+select period_ as "Nuvarande period_" from t1 group by "Nuvarande period_" limit 1;
+Nuvarande period_
9410
show tables;
Tables_in_test
@@ -5548,3 +5548,68 @@ select (SELECT name FROM t1 WHERE name='tom' AND pw=PASSWORD(@undefined));
NULL
drop table t1;
End of 10.0 tests
+#
+# System Versioning Support
+#
+#
+CREATE TABLE t1( x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)) WITH SYSTEM VERSIONING;
+INSERT INTO t1(x, y) VALUES
+(0, 100),
+(1, 101),
+(2, 102),
+(3, 103),
+(4, 104),
+(5, 105),
+(6, 106),
+(7, 107),
+(8, 108),
+(9, 109);
+DELETE FROM t1 WHERE x = 3;
+DELETE FROM t1 WHERE x > 7;
+INSERT INTO t1(x, y) VALUES(3, 33);
+SELECT @time := Sys_start FROM t1 FOR SYSTEM_TIME BETWEEN TIMESTAMP '0-0-0 0:0:0' AND TIMESTAMP '2038-01-19 04:14:07' WHERE x = 3 AND y = 33;
+@time := Sys_start
+Sys_start
+SELECT x, y FROM t1;
+x y
+0 100
+1 101
+2 102
+4 104
+5 105
+6 106
+7 107
+3 33
+SET @query=CONCAT('SELECT x, y FROM t1 FOR SYSTEM_TIME FROM TIMESTAMP \'0-0-0 0:0:0\' TO TIMESTAMP \'', @time, '\'');
+PREPARE stmt_t1 FROM @query;
+EXECUTE stmt_t1;
+x y
+0 100
+1 101
+2 102
+3 103
+4 104
+5 105
+6 106
+7 107
+8 108
+9 109
+SET @query=CONCAT('SELECT x, y FROM t1 FOR SYSTEM_TIME BETWEEN TIMESTAMP \'0-0-0 0:0:0\' AND TIMESTAMP \'', @time, '\'');
+PREPARE stmt_t1 FROM @query;
+EXECUTE stmt_t1;
+x y
+0 100
+1 101
+2 102
+3 103
+4 104
+5 105
+6 106
+7 107
+8 108
+9 109
+3 33
+SET @time=NULL;
+SET @query=NULL;
+DEALLOCATE PREPARE stmt_t1;
+DROP TABLE t1;
diff --git a/mysql-test/r/shm.result b/mysql-test/r/shm.result
index 65187b6b19b..4a2286a8104 100644
--- a/mysql-test/r/shm.result
+++ b/mysql-test/r/shm.result
@@ -1,18 +1,18 @@
connect shm_con,localhost,root,,,,$shm_name,SHM;
drop table if exists t1,t2,t3,t4;
CREATE TABLE t1 (
-Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
+Period_ smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL
);
INSERT INTO t1 VALUES (9410,9412);
-select period from t1;
-period
+select period_ from t1;
+period_
9410
select * from t1;
-Period Varor_period
+Period_ Varor_period
9410 9412
select t1.* from t1;
-Period Varor_period
+Period_ Varor_period
9410 9412
CREATE TABLE t2 (
auto int not null auto_increment,
@@ -276,8 +276,8 @@ companynr
34
29
00
-select distinct t2.fld3,period from t2,t1 where companynr=37 and fld3 like "O%";
-fld3 period
+select distinct t2.fld3,period_ from t2,t1 where companynr=37 and fld3 like "O%";
+fld3 period_
obliterates 9410
offload 9410
opaquely 9410
@@ -481,12 +481,12 @@ acu
Ade
adj
create table t3 (
-period int not null,
+period_ int not null,
name char(32) not null,
companynr int not null,
price double(11,0),
price2 double(11,0),
-key (period),
+key (period_),
key (name)
);
create temporary table tmp engine = myisam select * from t3;
@@ -600,35 +600,35 @@ explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL fld1 NULL NULL NULL 1199 Using where; Using temporary; Using filesort
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.fld1 1 Using where; Using index
-explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period;
+explain select * from t3 as t1,t3 where t1.period_=t3.period_ order by t3.period_;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using filesort
-1 SIMPLE t3 ref period period 4 test.t1.period 4181
-explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10;
+1 SIMPLE t1 ALL period_ NULL NULL NULL 41810 Using temporary; Using filesort
+1 SIMPLE t3 ref period_ period_ 4 test.t1.period_ 4181
+explain select * from t3 as t1,t3 where t1.period_=t3.period_ order by t3.period_ limit 10;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 index period period 4 NULL 1
-1 SIMPLE t1 ref period period 4 test.t3.period 4181
-explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10;
+1 SIMPLE t3 index period_ period_ 4 NULL 1
+1 SIMPLE t1 ref period_ period_ 4 test.t3.period_ 4181
+explain select * from t3 as t1,t3 where t1.period_=t3.period_ order by t1.period_ limit 10;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index period period 4 NULL 1
-1 SIMPLE t3 ref period period 4 test.t1.period 4181
-select period from t1;
-period
+1 SIMPLE t1 index period_ period_ 4 NULL 1
+1 SIMPLE t3 ref period_ period_ 4 test.t1.period_ 4181
+select period_ from t1;
+period_
9410
-select period from t1 where period=1900;
-period
-select fld3,period from t1,t2 where fld1 = 011401 order by period;
-fld3 period
+select period_ from t1 where period_=1900;
+period_
+select fld3,period_ from t1,t2 where fld1 = 011401 order by period_;
+fld3 period_
breaking 9410
-select fld3,period from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.period=1001;
-fld3 period
+select fld3,period_ from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.period_=1001;
+fld3 period_
breaking 1001
-explain select fld3,period from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period;
+explain select fld3,period_ from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period_;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 const fld1 fld1 4 const 1
-1 SIMPLE t3 const PRIMARY,period PRIMARY 4 const 1
-select fld3,period from t2,t1 where companynr*10 = 37*10;
-fld3 period
+1 SIMPLE t3 const PRIMARY,period_ PRIMARY 4 const 1
+select fld3,period_ from t2,t1 where companynr*10 = 37*10;
+fld3 period_
breaking 9410
Romans 9410
intercepted 9410
@@ -1217,8 +1217,8 @@ dusted 9410
encompasses 9410
presentation 9410
Kantian 9410
-select fld3,period,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period >= 1001 and period <= 1002 and t2.companynr = 37 order by fld3,period, price;
-fld3 period price price2
+select fld3,period_,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period_ >= 1001 and period_ <= 1002 and t2.companynr = 37 order by fld3,period_, price;
+fld3 period_ price price2
admonishing 1002 28357832 8723648
analyzable 1002 28357832 8723648
annihilates 1001 5987435 234724
@@ -1278,8 +1278,8 @@ ventilate 1001 5987435 234724
wallet 1001 5987435 234724
Weissmuller 1002 28357832 8723648
Wotan 1002 28357832 8723648
-select t2.fld1,fld3,period,price,price2 from t2,t3 where t2.fld1>= 18201 and t2.fld1 <= 18811 and t2.fld1=t3.t2nr and period = 1001 and t2.companynr = 37;
-fld1 fld3 period price price2
+select t2.fld1,fld3,period_,price,price2 from t2,t3 where t2.fld1>= 18201 and t2.fld1 <= 18811 and t2.fld1=t3.t2nr and period_ = 1001 and t2.companynr = 37;
+fld1 fld3 period_ price price2
018201 relaxing 1001 5987435 234724
018601 vacuuming 1001 5987435 234724
018801 inch 1001 5987435 234724
@@ -1319,7 +1319,7 @@ companynr companyname
65 company 9
68 company 10
select * from t1,t1 t12;
-Period Varor_period Period Varor_period
+Period_ Varor_period Period_ Varor_period
9410 9412 9410 9412
select t2.fld1,t22.fld1 from t2,t2 t22 where t2.fld1 >= 250501 and t2.fld1 <= 250505 and t22.fld1 >= 250501 and t22.fld1 <= 250505;
fld1 fld1
@@ -1434,23 +1434,23 @@ explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 index NULL PRIMARY 1 NULL 12 Using index; Using temporary
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where; Using join buffer (flat, BNL join)
-select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008;
-fld1 companynr fld3 period
+select t2.fld1,t2.companynr,fld3,period_ from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period_ = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period_ = 1008;
+fld1 companynr fld3 period_
038008 37 reporters 1008
038208 37 Selfridge 1008
-select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t2.fld1 = 38208 or t2.fld1 = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009;
-fld1 companynr fld3 period
+select t2.fld1,t2.companynr,fld3,period_ from t3,t2 where (t2.fld1 = 38208 or t2.fld1 = 38008) and t2.fld1=t3.t2nr and period_>=1008 and period_<=1009;
+fld1 companynr fld3 period_
038008 37 reporters 1008
038208 37 Selfridge 1008
-select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t3.t2nr = 38208 or t3.t2nr = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009;
-fld1 companynr fld3 period
+select t2.fld1,t2.companynr,fld3,period_ from t3,t2 where (t3.t2nr = 38208 or t3.t2nr = 38008) and t2.fld1=t3.t2nr and period_>=1008 and period_<=1009;
+fld1 companynr fld3 period_
038008 37 reporters 1008
038208 37 Selfridge 1008
-select period from t1 where (((period > 0) or period < 10000 or (period = 1900)) and (period=1900 and period <= 1901) or (period=1903 and (period=1903)) and period>=1902) or ((period=1904 or period=1905) or (period=1906 or period>1907)) or (period=1908 and period = 1909);
-period
+select period_ from t1 where (((period_ > 0) or period_ < 10000 or (period_ = 1900)) and (period_=1900 and period_ <= 1901) or (period_=1903 and (period_=1903)) and period_>=1902) or ((period_=1904 or period_=1905) or (period_=1906 or period_>1907)) or (period_=1908 and period_ = 1909);
+period_
9410
-select period from t1 where ((period > 0 and period < 1) or (((period > 0 and period < 100) and (period > 10)) or (period > 10)) or (period > 0 and (period > 5 or period > 6)));
-period
+select period_ from t1 where ((period_ > 0 and period_ < 1) or (((period_ > 0 and period_ < 100) and (period_ > 10)) or (period_ > 10)) or (period_ > 0 and (period_ > 5 or period_ > 6)));
+period_
9410
select a.fld1 from t2 as a,t2 b where ((a.fld1 = 250501 and a.fld1=b.fld1) or a.fld1=250502 or a.fld1=250503 or (a.fld1=250505 and a.fld1<=b.fld1 and b.fld1>=a.fld1)) and a.fld1=b.fld1;
fld1
@@ -1707,8 +1707,8 @@ companynr companyname count(*)
select t2.fld1,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name;
fld1 count(*)
158402 4181
-select sum(Period)/count(*) from t1;
-sum(Period)/count(*)
+select sum(Period_)/count(*) from t1;
+sum(Period_)/count(*)
9410.0000
select companynr,count(price) as "count",sum(price) as "sum" ,abs(sum(price)/count(price)-avg(price)) as "diff",(0+count(price))*companynr as func from t3 group by companynr;
companynr count sum diff func
@@ -2038,26 +2038,26 @@ t2nr count(*)
select max(t2nr) from t3 where price=983543950;
max(t2nr)
41807
-select t1.period from t3 = t1 limit 1;
-period
+select t1.period_ from t3 = t1 limit 1;
+period_
1001
-select t1.period from t1 as t1 limit 1;
-period
+select t1.period_ from t1 as t1 limit 1;
+period_
9410
-select t1.period as "Nuvarande period" from t1 as t1 limit 1;
-Nuvarande period
+select t1.period_ as "Nuvarande period_" from t1 as t1 limit 1;
+Nuvarande period_
9410
-select period as ok_period from t1 limit 1;
+select period_ as ok_period from t1 limit 1;
ok_period
9410
-select period as ok_period from t1 group by ok_period limit 1;
+select period_ as ok_period from t1 group by ok_period limit 1;
ok_period
9410
select 1+1 as summa from t1 group by summa limit 1;
summa
2
-select period as "Nuvarande period" from t1 group by "Nuvarande period" limit 1;
-Nuvarande period
+select period_ as "Nuvarande period_" from t1 group by "Nuvarande period_" limit 1;
+Nuvarande period_
9410
show tables;
Tables_in_test
diff --git a/mysql-test/r/ssl.result b/mysql-test/r/ssl.result
index ac18da81b93..6eb68e93be2 100644
--- a/mysql-test/r/ssl.result
+++ b/mysql-test/r/ssl.result
@@ -10,18 +10,18 @@ Variable_name Value
Ssl_server_not_after Apr 20 14:55:05 2035 GMT
drop table if exists t1,t2,t3,t4;
CREATE TABLE t1 (
-Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
+Period_ smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL
);
INSERT INTO t1 VALUES (9410,9412);
-select period from t1;
-period
+select period_ from t1;
+period_
9410
select * from t1;
-Period Varor_period
+Period_ Varor_period
9410 9412
select t1.* from t1;
-Period Varor_period
+Period_ Varor_period
9410 9412
CREATE TABLE t2 (
auto int not null auto_increment,
@@ -285,8 +285,8 @@ companynr
34
29
00
-select distinct t2.fld3,period from t2,t1 where companynr=37 and fld3 like "O%";
-fld3 period
+select distinct t2.fld3,period_ from t2,t1 where companynr=37 and fld3 like "O%";
+fld3 period_
obliterates 9410
offload 9410
opaquely 9410
@@ -490,12 +490,12 @@ acu
Ade
adj
create table t3 (
-period int not null,
+period_ int not null,
name char(32) not null,
companynr int not null,
price double(11,0),
price2 double(11,0),
-key (period),
+key (period_),
key (name)
);
create temporary table tmp engine = myisam select * from t3;
@@ -609,35 +609,35 @@ explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL fld1 NULL NULL NULL 1199 Using where; Using temporary; Using filesort
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.fld1 1 Using where; Using index
-explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period;
+explain select * from t3 as t1,t3 where t1.period_=t3.period_ order by t3.period_;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using filesort
-1 SIMPLE t3 ref period period 4 test.t1.period 4181
-explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10;
+1 SIMPLE t1 ALL period_ NULL NULL NULL 41810 Using filesort
+1 SIMPLE t3 ref period_ period_ 4 test.t1.period_ 4181
+explain select * from t3 as t1,t3 where t1.period_=t3.period_ order by t3.period_ limit 10;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 index period period 4 NULL 1
-1 SIMPLE t1 ref period period 4 test.t3.period 4181
-explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10;
+1 SIMPLE t3 index period_ period_ 4 NULL 1
+1 SIMPLE t1 ref period_ period_ 4 test.t3.period_ 4181
+explain select * from t3 as t1,t3 where t1.period_=t3.period_ order by t1.period_ limit 10;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index period period 4 NULL 1
-1 SIMPLE t3 ref period period 4 test.t1.period 4181
-select period from t1;
-period
+1 SIMPLE t1 index period_ period_ 4 NULL 1
+1 SIMPLE t3 ref period_ period_ 4 test.t1.period_ 4181
+select period_ from t1;
+period_
9410
-select period from t1 where period=1900;
-period
-select fld3,period from t1,t2 where fld1 = 011401 order by period;
-fld3 period
+select period_ from t1 where period_=1900;
+period_
+select fld3,period_ from t1,t2 where fld1 = 011401 order by period_;
+fld3 period_
breaking 9410
-select fld3,period from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.period=1001;
-fld3 period
+select fld3,period_ from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.period_=1001;
+fld3 period_
breaking 1001
-explain select fld3,period from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period;
+explain select fld3,period_ from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period_;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 const fld1 fld1 4 const 1
-1 SIMPLE t3 const PRIMARY,period PRIMARY 4 const 1
-select fld3,period from t2,t1 where companynr*10 = 37*10;
-fld3 period
+1 SIMPLE t3 const PRIMARY,period_ PRIMARY 4 const 1
+select fld3,period_ from t2,t1 where companynr*10 = 37*10;
+fld3 period_
breaking 9410
Romans 9410
intercepted 9410
@@ -1226,8 +1226,8 @@ dusted 9410
encompasses 9410
presentation 9410
Kantian 9410
-select fld3,period,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period >= 1001 and period <= 1002 and t2.companynr = 37 order by fld3,period, price;
-fld3 period price price2
+select fld3,period_,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period_ >= 1001 and period_ <= 1002 and t2.companynr = 37 order by fld3,period_, price;
+fld3 period_ price price2
admonishing 1002 28357832 8723648
analyzable 1002 28357832 8723648
annihilates 1001 5987435 234724
@@ -1287,8 +1287,8 @@ ventilate 1001 5987435 234724
wallet 1001 5987435 234724
Weissmuller 1002 28357832 8723648
Wotan 1002 28357832 8723648
-select t2.fld1,fld3,period,price,price2 from t2,t3 where t2.fld1>= 18201 and t2.fld1 <= 18811 and t2.fld1=t3.t2nr and period = 1001 and t2.companynr = 37;
-fld1 fld3 period price price2
+select t2.fld1,fld3,period_,price,price2 from t2,t3 where t2.fld1>= 18201 and t2.fld1 <= 18811 and t2.fld1=t3.t2nr and period_ = 1001 and t2.companynr = 37;
+fld1 fld3 period_ price price2
018201 relaxing 1001 5987435 234724
018601 vacuuming 1001 5987435 234724
018801 inch 1001 5987435 234724
@@ -1328,7 +1328,7 @@ companynr companyname
65 company 9
68 company 10
select * from t1,t1 t12;
-Period Varor_period Period Varor_period
+Period_ Varor_period Period_ Varor_period
9410 9412 9410 9412
select t2.fld1,t22.fld1 from t2,t2 t22 where t2.fld1 >= 250501 and t2.fld1 <= 250505 and t22.fld1 >= 250501 and t22.fld1 <= 250505;
fld1 fld1
@@ -1443,23 +1443,23 @@ explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 index NULL PRIMARY 1 NULL 12 Using index; Using temporary
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where; Using join buffer (flat, BNL join)
-select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008;
-fld1 companynr fld3 period
+select t2.fld1,t2.companynr,fld3,period_ from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period_ = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period_ = 1008;
+fld1 companynr fld3 period_
038008 37 reporters 1008
038208 37 Selfridge 1008
-select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t2.fld1 = 38208 or t2.fld1 = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009;
-fld1 companynr fld3 period
+select t2.fld1,t2.companynr,fld3,period_ from t3,t2 where (t2.fld1 = 38208 or t2.fld1 = 38008) and t2.fld1=t3.t2nr and period_>=1008 and period_<=1009;
+fld1 companynr fld3 period_
038008 37 reporters 1008
038208 37 Selfridge 1008
-select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t3.t2nr = 38208 or t3.t2nr = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009;
-fld1 companynr fld3 period
+select t2.fld1,t2.companynr,fld3,period_ from t3,t2 where (t3.t2nr = 38208 or t3.t2nr = 38008) and t2.fld1=t3.t2nr and period_>=1008 and period_<=1009;
+fld1 companynr fld3 period_
038008 37 reporters 1008
038208 37 Selfridge 1008
-select period from t1 where (((period > 0) or period < 10000 or (period = 1900)) and (period=1900 and period <= 1901) or (period=1903 and (period=1903)) and period>=1902) or ((period=1904 or period=1905) or (period=1906 or period>1907)) or (period=1908 and period = 1909);
-period
+select period_ from t1 where (((period_ > 0) or period_ < 10000 or (period_ = 1900)) and (period_=1900 and period_ <= 1901) or (period_=1903 and (period_=1903)) and period_>=1902) or ((period_=1904 or period_=1905) or (period_=1906 or period_>1907)) or (period_=1908 and period_ = 1909);
+period_
9410
-select period from t1 where ((period > 0 and period < 1) or (((period > 0 and period < 100) and (period > 10)) or (period > 10)) or (period > 0 and (period > 5 or period > 6)));
-period
+select period_ from t1 where ((period_ > 0 and period_ < 1) or (((period_ > 0 and period_ < 100) and (period_ > 10)) or (period_ > 10)) or (period_ > 0 and (period_ > 5 or period_ > 6)));
+period_
9410
select a.fld1 from t2 as a,t2 b where ((a.fld1 = 250501 and a.fld1=b.fld1) or a.fld1=250502 or a.fld1=250503 or (a.fld1=250505 and a.fld1<=b.fld1 and b.fld1>=a.fld1)) and a.fld1=b.fld1;
fld1
@@ -1716,8 +1716,8 @@ companynr companyname count(*)
select t2.fld1,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name;
fld1 count(*)
158402 4181
-select sum(Period)/count(*) from t1;
-sum(Period)/count(*)
+select sum(Period_)/count(*) from t1;
+sum(Period_)/count(*)
9410.0000
select companynr,count(price) as "count",sum(price) as "sum" ,abs(sum(price)/count(price)-avg(price)) as "diff",(0+count(price))*companynr as func from t3 group by companynr;
companynr count sum diff func
@@ -2047,26 +2047,26 @@ t2nr count(*)
select max(t2nr) from t3 where price=983543950;
max(t2nr)
41807
-select t1.period from t3 = t1 limit 1;
-period
+select t1.period_ from t3 = t1 limit 1;
+period_
1001
-select t1.period from t1 as t1 limit 1;
-period
+select t1.period_ from t1 as t1 limit 1;
+period_
9410
-select t1.period as "Nuvarande period" from t1 as t1 limit 1;
-Nuvarande period
+select t1.period_ as "Nuvarande period_" from t1 as t1 limit 1;
+Nuvarande period_
9410
-select period as ok_period from t1 limit 1;
+select period_ as ok_period from t1 limit 1;
ok_period
9410
-select period as ok_period from t1 group by ok_period limit 1;
+select period_ as ok_period from t1 group by ok_period limit 1;
ok_period
9410
select 1+1 as summa from t1 group by summa limit 1;
summa
2
-select period as "Nuvarande period" from t1 group by "Nuvarande period" limit 1;
-Nuvarande period
+select period_ as "Nuvarande period_" from t1 group by "Nuvarande period_" limit 1;
+Nuvarande period_
9410
show tables;
Tables_in_test
diff --git a/mysql-test/r/ssl_compress.result b/mysql-test/r/ssl_compress.result
index 4e37cc68a24..d195816caa9 100644
--- a/mysql-test/r/ssl_compress.result
+++ b/mysql-test/r/ssl_compress.result
@@ -7,18 +7,18 @@ Variable_name Value
Compression ON
drop table if exists t1,t2,t3,t4;
CREATE TABLE t1 (
-Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
+Period_ smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL
);
INSERT INTO t1 VALUES (9410,9412);
-select period from t1;
-period
+select period_ from t1;
+period_
9410
select * from t1;
-Period Varor_period
+Period_ Varor_period
9410 9412
select t1.* from t1;
-Period Varor_period
+Period_ Varor_period
9410 9412
CREATE TABLE t2 (
auto int not null auto_increment,
@@ -282,8 +282,8 @@ companynr
34
29
00
-select distinct t2.fld3,period from t2,t1 where companynr=37 and fld3 like "O%";
-fld3 period
+select distinct t2.fld3,period_ from t2,t1 where companynr=37 and fld3 like "O%";
+fld3 period_
obliterates 9410
offload 9410
opaquely 9410
@@ -487,12 +487,12 @@ acu
Ade
adj
create table t3 (
-period int not null,
+period_ int not null,
name char(32) not null,
companynr int not null,
price double(11,0),
price2 double(11,0),
-key (period),
+key (period_),
key (name)
);
create temporary table tmp engine = myisam select * from t3;
@@ -606,35 +606,35 @@ explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL fld1 NULL NULL NULL 1199 Using where; Using temporary; Using filesort
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.fld1 1 Using where; Using index
-explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period;
+explain select * from t3 as t1,t3 where t1.period_=t3.period_ order by t3.period_;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using filesort
-1 SIMPLE t3 ref period period 4 test.t1.period 4181
-explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10;
+1 SIMPLE t1 ALL period_ NULL NULL NULL 41810 Using filesort
+1 SIMPLE t3 ref period_ period_ 4 test.t1.period_ 4181
+explain select * from t3 as t1,t3 where t1.period_=t3.period_ order by t3.period_ limit 10;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 index period period 4 NULL 1
-1 SIMPLE t1 ref period period 4 test.t3.period 4181
-explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10;
+1 SIMPLE t3 index period_ period_ 4 NULL 1
+1 SIMPLE t1 ref period_ period_ 4 test.t3.period_ 4181
+explain select * from t3 as t1,t3 where t1.period_=t3.period_ order by t1.period_ limit 10;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index period period 4 NULL 1
-1 SIMPLE t3 ref period period 4 test.t1.period 4181
-select period from t1;
-period
+1 SIMPLE t1 index period_ period_ 4 NULL 1
+1 SIMPLE t3 ref period_ period_ 4 test.t1.period_ 4181
+select period_ from t1;
+period_
9410
-select period from t1 where period=1900;
-period
-select fld3,period from t1,t2 where fld1 = 011401 order by period;
-fld3 period
+select period_ from t1 where period_=1900;
+period_
+select fld3,period_ from t1,t2 where fld1 = 011401 order by period_;
+fld3 period_
breaking 9410
-select fld3,period from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.period=1001;
-fld3 period
+select fld3,period_ from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.period_=1001;
+fld3 period_
breaking 1001
-explain select fld3,period from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period;
+explain select fld3,period_ from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period_;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 const fld1 fld1 4 const 1
-1 SIMPLE t3 const PRIMARY,period PRIMARY 4 const 1
-select fld3,period from t2,t1 where companynr*10 = 37*10;
-fld3 period
+1 SIMPLE t3 const PRIMARY,period_ PRIMARY 4 const 1
+select fld3,period_ from t2,t1 where companynr*10 = 37*10;
+fld3 period_
breaking 9410
Romans 9410
intercepted 9410
@@ -1223,8 +1223,8 @@ dusted 9410
encompasses 9410
presentation 9410
Kantian 9410
-select fld3,period,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period >= 1001 and period <= 1002 and t2.companynr = 37 order by fld3,period, price;
-fld3 period price price2
+select fld3,period_,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period_ >= 1001 and period_ <= 1002 and t2.companynr = 37 order by fld3,period_, price;
+fld3 period_ price price2
admonishing 1002 28357832 8723648
analyzable 1002 28357832 8723648
annihilates 1001 5987435 234724
@@ -1284,8 +1284,8 @@ ventilate 1001 5987435 234724
wallet 1001 5987435 234724
Weissmuller 1002 28357832 8723648
Wotan 1002 28357832 8723648
-select t2.fld1,fld3,period,price,price2 from t2,t3 where t2.fld1>= 18201 and t2.fld1 <= 18811 and t2.fld1=t3.t2nr and period = 1001 and t2.companynr = 37;
-fld1 fld3 period price price2
+select t2.fld1,fld3,period_,price,price2 from t2,t3 where t2.fld1>= 18201 and t2.fld1 <= 18811 and t2.fld1=t3.t2nr and period_ = 1001 and t2.companynr = 37;
+fld1 fld3 period_ price price2
018201 relaxing 1001 5987435 234724
018601 vacuuming 1001 5987435 234724
018801 inch 1001 5987435 234724
@@ -1325,7 +1325,7 @@ companynr companyname
65 company 9
68 company 10
select * from t1,t1 t12;
-Period Varor_period Period Varor_period
+Period_ Varor_period Period_ Varor_period
9410 9412 9410 9412
select t2.fld1,t22.fld1 from t2,t2 t22 where t2.fld1 >= 250501 and t2.fld1 <= 250505 and t22.fld1 >= 250501 and t22.fld1 <= 250505;
fld1 fld1
@@ -1440,23 +1440,23 @@ explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 index NULL PRIMARY 1 NULL 12 Using index; Using temporary
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where; Using join buffer (flat, BNL join)
-select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008;
-fld1 companynr fld3 period
+select t2.fld1,t2.companynr,fld3,period_ from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period_ = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period_ = 1008;
+fld1 companynr fld3 period_
038008 37 reporters 1008
038208 37 Selfridge 1008
-select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t2.fld1 = 38208 or t2.fld1 = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009;
-fld1 companynr fld3 period
+select t2.fld1,t2.companynr,fld3,period_ from t3,t2 where (t2.fld1 = 38208 or t2.fld1 = 38008) and t2.fld1=t3.t2nr and period_>=1008 and period_<=1009;
+fld1 companynr fld3 period_
038008 37 reporters 1008
038208 37 Selfridge 1008
-select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t3.t2nr = 38208 or t3.t2nr = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009;
-fld1 companynr fld3 period
+select t2.fld1,t2.companynr,fld3,period_ from t3,t2 where (t3.t2nr = 38208 or t3.t2nr = 38008) and t2.fld1=t3.t2nr and period_>=1008 and period_<=1009;
+fld1 companynr fld3 period_
038008 37 reporters 1008
038208 37 Selfridge 1008
-select period from t1 where (((period > 0) or period < 10000 or (period = 1900)) and (period=1900 and period <= 1901) or (period=1903 and (period=1903)) and period>=1902) or ((period=1904 or period=1905) or (period=1906 or period>1907)) or (period=1908 and period = 1909);
-period
+select period_ from t1 where (((period_ > 0) or period_ < 10000 or (period_ = 1900)) and (period_=1900 and period_ <= 1901) or (period_=1903 and (period_=1903)) and period_>=1902) or ((period_=1904 or period_=1905) or (period_=1906 or period_>1907)) or (period_=1908 and period_ = 1909);
+period_
9410
-select period from t1 where ((period > 0 and period < 1) or (((period > 0 and period < 100) and (period > 10)) or (period > 10)) or (period > 0 and (period > 5 or period > 6)));
-period
+select period_ from t1 where ((period_ > 0 and period_ < 1) or (((period_ > 0 and period_ < 100) and (period_ > 10)) or (period_ > 10)) or (period_ > 0 and (period_ > 5 or period_ > 6)));
+period_
9410
select a.fld1 from t2 as a,t2 b where ((a.fld1 = 250501 and a.fld1=b.fld1) or a.fld1=250502 or a.fld1=250503 or (a.fld1=250505 and a.fld1<=b.fld1 and b.fld1>=a.fld1)) and a.fld1=b.fld1;
fld1
@@ -1713,8 +1713,8 @@ companynr companyname count(*)
select t2.fld1,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name;
fld1 count(*)
158402 4181
-select sum(Period)/count(*) from t1;
-sum(Period)/count(*)
+select sum(Period_)/count(*) from t1;
+sum(Period_)/count(*)
9410.0000
select companynr,count(price) as "count",sum(price) as "sum" ,abs(sum(price)/count(price)-avg(price)) as "diff",(0+count(price))*companynr as func from t3 group by companynr;
companynr count sum diff func
@@ -2044,26 +2044,26 @@ t2nr count(*)
select max(t2nr) from t3 where price=983543950;
max(t2nr)
41807
-select t1.period from t3 = t1 limit 1;
-period
+select t1.period_ from t3 = t1 limit 1;
+period_
1001
-select t1.period from t1 as t1 limit 1;
-period
+select t1.period_ from t1 as t1 limit 1;
+period_
9410
-select t1.period as "Nuvarande period" from t1 as t1 limit 1;
-Nuvarande period
+select t1.period_ as "Nuvarande period_" from t1 as t1 limit 1;
+Nuvarande period_
9410
-select period as ok_period from t1 limit 1;
+select period_ as ok_period from t1 limit 1;
ok_period
9410
-select period as ok_period from t1 group by ok_period limit 1;
+select period_ as ok_period from t1 group by ok_period limit 1;
ok_period
9410
select 1+1 as summa from t1 group by summa limit 1;
summa
2
-select period as "Nuvarande period" from t1 group by "Nuvarande period" limit 1;
-Nuvarande period
+select period_ as "Nuvarande period_" from t1 group by "Nuvarande period_" limit 1;
+Nuvarande period_
9410
show tables;
Tables_in_test
diff --git a/mysql-test/r/update.result b/mysql-test/r/update.result
index 73ebb73e313..cab57d4ef3d 100644
--- a/mysql-test/r/update.result
+++ b/mysql-test/r/update.result
@@ -719,3 +719,103 @@ Handler_read_rnd_deleted 0
Handler_read_rnd_next 0
drop table t1, t2;
# End of MariaDB 10.0 tests
+#
+# System Versioning Support
+#
+#
+CREATE TABLE t1(x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)) WITH SYSTEM VERSIONING;
+INSERT INTO t1(x, y) VALUES
+(1, 1000),
+(2, 2000),
+(3, 3000),
+(4, 4000),
+(5, 5000),
+(6, 6000),
+(7, 7000),
+(8, 8000),
+(9, 9000);
+SELECT x, y FROM t1;
+x y
+1 1000
+2 2000
+3 3000
+4 4000
+5 5000
+6 6000
+7 7000
+8 8000
+9 9000
+UPDATE t1 SET y = y + 1 WHERE x > 7;
+SELECT x, y FROM t1;
+x y
+1 1000
+2 2000
+3 3000
+4 4000
+5 5000
+6 6000
+7 7000
+8 8001
+9 9001
+SELECT x, y FROM t1 FOR SYSTEM_TIME BETWEEN TIMESTAMP '0000-0-0 0:0:0' AND TIMESTAMP '2038-01-19 04:14:07';
+x y
+1 1000
+2 2000
+3 3000
+4 4000
+5 5000
+6 6000
+7 7000
+8 8001
+9 9001
+8 8000
+9 9000
+DROP TABLE t1;
+CREATE TABLE t1(x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)) WITH SYSTEM VERSIONING ENGINE=InnoDB;
+INSERT INTO t1(x, y) VALUES
+(1, 1000),
+(2, 2000),
+(3, 3000),
+(4, 4000),
+(5, 5000),
+(6, 6000),
+(7, 7000),
+(8, 8000),
+(9, 9000);
+SELECT x, y FROM t1;
+x y
+1 1000
+2 2000
+3 3000
+4 4000
+5 5000
+6 6000
+7 7000
+8 8000
+9 9000
+UPDATE t1 SET y = y + 1 WHERE x > 7;
+SELECT x, y FROM t1;
+x y
+1 1000
+2 2000
+3 3000
+4 4000
+5 5000
+6 6000
+7 7000
+8 8001
+9 9001
+SELECT x, y FROM t1 FOR SYSTEM_TIME BETWEEN TIMESTAMP '0000-0-0 0:0:0' AND TIMESTAMP '2038-01-19 04:14:07';
+x y
+1 1000
+2 2000
+3 3000
+4 4000
+5 5000
+6 6000
+7 7000
+8 8001
+9 9001
+8 8000
+9 9000
+DROP TABLE t1;
diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result
index 676432690b4..944e8c1392e 100644
--- a/mysql-test/r/variables.result
+++ b/mysql-test/r/variables.result
@@ -1577,171 +1577,6 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
End of 5.1 tests
-
-#
-# Bug#34828: OF is taken as OFF and a value of 0 is set for variable SQL_notes.
-#
-
-# Checking sql_notes...
-SET @sql_notes_saved = @@sql_notes;
-
-SET @@sql_notes = ON;
-SELECT @@sql_notes;
-@@sql_notes
-1
-
-SET @@sql_notes = OF;
-ERROR 42000: Variable 'sql_notes' can't be set to the value of 'OF'
-SELECT @@sql_notes;
-@@sql_notes
-1
-
-SET @@sql_notes = OFF;
-SELECT @@sql_notes;
-@@sql_notes
-0
-
-SET @@sql_notes = @sql_notes_saved;
-
-# Checking delay_key_write...
-SET @delay_key_write_saved = @@delay_key_write;
-
-SET GLOBAL delay_key_write = ON;
-SELECT @@delay_key_write;
-@@delay_key_write
-ON
-
-SET GLOBAL delay_key_write = OF;
-ERROR 42000: Variable 'delay_key_write' can't be set to the value of 'OF'
-SELECT @@delay_key_write;
-@@delay_key_write
-ON
-
-SET GLOBAL delay_key_write = AL;
-ERROR 42000: Variable 'delay_key_write' can't be set to the value of 'AL'
-SELECT @@delay_key_write;
-@@delay_key_write
-ON
-
-SET GLOBAL delay_key_write = OFF;
-SELECT @@delay_key_write;
-@@delay_key_write
-OFF
-
-SET GLOBAL delay_key_write = ALL;
-SELECT @@delay_key_write;
-@@delay_key_write
-ALL
-
-SET GLOBAL delay_key_write = @delay_key_write_saved;
-
-# Checking sql_safe_updates...
-SET @sql_safe_updates_saved = @@sql_safe_updates;
-
-SET @@sql_safe_updates = ON;
-SELECT @@sql_safe_updates;
-@@sql_safe_updates
-1
-
-SET @@sql_safe_updates = OF;
-ERROR 42000: Variable 'sql_safe_updates' can't be set to the value of 'OF'
-SELECT @@sql_safe_updates;
-@@sql_safe_updates
-1
-
-SET @@sql_safe_updates = OFF;
-SELECT @@sql_safe_updates;
-@@sql_safe_updates
-0
-
-SET @@sql_safe_updates = @sql_safe_updates_saved;
-
-# Checking foreign_key_checks...
-SET @foreign_key_checks_saved = @@foreign_key_checks;
-
-SET @@foreign_key_checks = ON;
-SELECT @@foreign_key_checks;
-@@foreign_key_checks
-1
-
-SET @@foreign_key_checks = OF;
-ERROR 42000: Variable 'foreign_key_checks' can't be set to the value of 'OF'
-SELECT @@foreign_key_checks;
-@@foreign_key_checks
-1
-
-SET @@foreign_key_checks = OFF;
-SELECT @@foreign_key_checks;
-@@foreign_key_checks
-0
-
-SET @@foreign_key_checks = @foreign_key_checks_saved;
-
-# Checking unique_checks...
-SET @unique_checks_saved = @@unique_checks;
-
-SET @@unique_checks = ON;
-SELECT @@unique_checks;
-@@unique_checks
-1
-
-SET @@unique_checks = OF;
-ERROR 42000: Variable 'unique_checks' can't be set to the value of 'OF'
-SELECT @@unique_checks;
-@@unique_checks
-1
-
-SET @@unique_checks = OFF;
-SELECT @@unique_checks;
-@@unique_checks
-0
-
-SET @@unique_checks = @unique_checks_saved;
-
-# Checking sql_buffer_result...
-SET @sql_buffer_result_saved = @@sql_buffer_result;
-
-SET @@sql_buffer_result = ON;
-SELECT @@sql_buffer_result;
-@@sql_buffer_result
-1
-
-SET @@sql_buffer_result = OF;
-ERROR 42000: Variable 'sql_buffer_result' can't be set to the value of 'OF'
-SELECT @@sql_buffer_result;
-@@sql_buffer_result
-1
-
-SET @@sql_buffer_result = OFF;
-SELECT @@sql_buffer_result;
-@@sql_buffer_result
-0
-
-SET @@sql_buffer_result = @sql_buffer_result_saved;
-
-# Checking sql_quote_show_create...
-SET @sql_quote_show_create_saved = @@sql_quote_show_create;
-
-SET @@sql_quote_show_create = ON;
-SELECT @@sql_quote_show_create;
-@@sql_quote_show_create
-1
-
-SET @@sql_quote_show_create = OF;
-ERROR 42000: Variable 'sql_quote_show_create' can't be set to the value of 'OF'
-SELECT @@sql_quote_show_create;
-@@sql_quote_show_create
-1
-
-SET @@sql_quote_show_create = OFF;
-SELECT @@sql_quote_show_create;
-@@sql_quote_show_create
-0
-
-SET @@sql_quote_show_create = @sql_quote_show_create_saved;
-
-# End of Bug#34828.
-
# Make sure we can manipulate with autocommit in the
# along with other variables.
drop table if exists t1;
diff --git a/mysql-test/suite/archive/archive.result b/mysql-test/suite/archive/archive.result
index d294d3dfe58..f0ef14495fa 100644
--- a/mysql-test/suite/archive/archive.result
+++ b/mysql-test/suite/archive/archive.result
@@ -3,18 +3,18 @@ call mtr.add_suppression("Table 't1' is marked as crashed and should be repaired
DROP TABLE if exists t1,t2,t3,t4,t5,t6;
SET storage_engine=ARCHIVE;
CREATE TABLE t1 (
-Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
+Period_ smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL
) ENGINE=archive;
INSERT INTO t1 VALUES (9410,9412);
-select period FROM t1;
-period
+select period_ FROM t1;
+period_
9410
select * FROM t1;
-Period Varor_period
+Period_ Varor_period
9410 9412
select t1.* FROM t1;
-Period Varor_period
+Period_ Varor_period
9410 9412
CREATE TABLE t2 (
auto int,
diff --git a/mysql-test/suite/archive/archive.test b/mysql-test/suite/archive/archive.test
index 30f2766507e..19b46195682 100644
--- a/mysql-test/suite/archive/archive.test
+++ b/mysql-test/suite/archive/archive.test
@@ -15,13 +15,13 @@ SET storage_engine=ARCHIVE;
let $MYSQLD_DATADIR= `SELECT @@datadir`;
CREATE TABLE t1 (
- Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
+ Period_ smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL
) ENGINE=archive;
INSERT INTO t1 VALUES (9410,9412);
-select period FROM t1;
+select period_ FROM t1;
select * FROM t1;
select t1.* FROM t1;
diff --git a/mysql-test/suite/binlog/r/binlog_stm_blackhole.result b/mysql-test/suite/binlog/r/binlog_stm_blackhole.result
index feed949a71a..ac2b2003f30 100644
--- a/mysql-test/suite/binlog/r/binlog_stm_blackhole.result
+++ b/mysql-test/suite/binlog/r/binlog_stm_blackhole.result
@@ -1,16 +1,16 @@
CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
drop table if exists t1,t2;
CREATE TABLE t1 (
-Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
+Period_ smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL
) ENGINE=blackhole;
INSERT INTO t1 VALUES (9410,9412);
-select period from t1;
-period
+select period_ from t1;
+period_
select * from t1;
-Period Varor_period
+Period_ Varor_period
select t1.* from t1;
-Period Varor_period
+Period_ Varor_period
CREATE TABLE t2 (
auto int NOT NULL auto_increment,
fld1 int(6) unsigned zerofill DEFAULT '000000' NOT NULL,
diff --git a/mysql-test/suite/csv/csv.result b/mysql-test/suite/csv/csv.result
index 220b84b222e..c9f7c617b40 100644
--- a/mysql-test/suite/csv/csv.result
+++ b/mysql-test/suite/csv/csv.result
@@ -3,18 +3,18 @@ call mtr.add_suppression("Table 'test_repair_table4' is marked as crashed and sh
call mtr.add_suppression("Table 't1' is marked as crashed and should be repaired");
drop table if exists t1,t2,t3,t4;
CREATE TABLE t1 (
-Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
+Period_ smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL
) ENGINE = CSV;
INSERT INTO t1 VALUES (9410,9412);
-select period from t1;
-period
+select period_ from t1;
+period_
9410
select * from t1;
-Period Varor_period
+Period_ Varor_period
9410 9412
select t1.* from t1;
-Period Varor_period
+Period_ Varor_period
9410 9412
CREATE TABLE t2 (
auto int not null,
@@ -4919,12 +4919,12 @@ DROP TABLE t1;
ALTER TABLE t2 RENAME t1;
DROP TABLE t1;
CREATE TABLE t1 (
-Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
+Period_ smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL
) ENGINE = CSV;
INSERT INTO t1 VALUES (9410,9412);
-select period from t1;
-period
+select period_ from t1;
+period_
9410
drop table if exists t1,t2,t3,t4;
Warnings:
diff --git a/mysql-test/suite/csv/csv.test b/mysql-test/suite/csv/csv.test
index 3da9aca7b16..711351a32ae 100644
--- a/mysql-test/suite/csv/csv.test
+++ b/mysql-test/suite/csv/csv.test
@@ -17,13 +17,13 @@ drop table if exists t1,t2,t3,t4;
--enable_warnings
CREATE TABLE t1 (
- Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
+ Period_ smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL
) ENGINE = CSV;
INSERT INTO t1 VALUES (9410,9412);
-select period from t1;
+select period_ from t1;
select * from t1;
select t1.* from t1;
@@ -1308,13 +1308,13 @@ ALTER TABLE t2 RENAME t1;
DROP TABLE t1;
CREATE TABLE t1 (
- Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
+ Period_ smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL
) ENGINE = CSV;
INSERT INTO t1 VALUES (9410,9412);
-select period from t1;
+select period_ from t1;
drop table if exists t1,t2,t3,t4;
diff --git a/mysql-test/suite/funcs_1/r/innodb_views.result b/mysql-test/suite/funcs_1/r/innodb_views.result
index 294e0695226..759ab6fd327 100644
--- a/mysql-test/suite/funcs_1/r/innodb_views.result
+++ b/mysql-test/suite/funcs_1/r/innodb_views.result
@@ -3551,11 +3551,11 @@ CREATE VIEW v1 or REPLACE AS Select * from tb2 my_table;
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 'or REPLACE AS Select * from tb2 my_table' at line 1
CREATE VIEW v1 WITH CASCADED CHECK OPTION AS Select *
from tb2 my_table limit 50;
-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 'CASCADED CHECK OPTION AS Select *
+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 'WITH CASCADED CHECK OPTION AS Select *
from tb2 my_table limit 50' at line 1
CREATE VIEW v1 WITH LOCAL CHECK OPTION AS Select *
from tb2 my_table limit 50;
-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 'LOCAL CHECK OPTION AS Select *
+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 'WITH LOCAL CHECK OPTION AS Select *
from tb2 my_table limit 50' at line 1
SELECT * FROM tb2 my_table CREATE VIEW As v1;
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 'CREATE VIEW As v1' at line 1
@@ -3585,7 +3585,7 @@ FROM test.tb2 my_table CHECK OPTION WITH CASCADED;
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 'CHECK OPTION WITH CASCADED' at line 2
CREATE OR REPLACE VIEW v1 WITH CASCADED CHECK OPTION
AS SELECT F59, F60 FROM test.tb2 my_table;
-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 'CASCADED CHECK OPTION
+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 'WITH CASCADED CHECK OPTION
AS SELECT F59, F60 FROM test.tb2 my_table' at line 1
CREATE OR REPLACE AS SELECT F59, F60
FROM test.tb2 my_table VIEW v1 WITH CASCADED CHECK OPTION;
@@ -3614,7 +3614,7 @@ FROM test.tb2 my_table CHECK OPTION WITH LOCAL;
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 'CHECK OPTION WITH LOCAL' at line 2
CREATE OR REPLACE VIEW v1 WITH CASCADED CHECK OPTION
AS SELECT F59, F60 FROM test.tb2 my_table;
-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 'CASCADED CHECK OPTION
+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 'WITH CASCADED CHECK OPTION
AS SELECT F59, F60 FROM test.tb2 my_table' at line 1
CREATE OR REPLACE AS SELECT F59, F60
FROM test.tb2 my_table VIEW v1 WITH LOCAL CHECK OPTION;
diff --git a/mysql-test/suite/funcs_1/r/memory_views.result b/mysql-test/suite/funcs_1/r/memory_views.result
index 87465035980..60a9d2a3f2e 100644
--- a/mysql-test/suite/funcs_1/r/memory_views.result
+++ b/mysql-test/suite/funcs_1/r/memory_views.result
@@ -3552,11 +3552,11 @@ CREATE VIEW v1 or REPLACE AS Select * from tb2 my_table;
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 'or REPLACE AS Select * from tb2 my_table' at line 1
CREATE VIEW v1 WITH CASCADED CHECK OPTION AS Select *
from tb2 my_table limit 50;
-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 'CASCADED CHECK OPTION AS Select *
+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 'WITH CASCADED CHECK OPTION AS Select *
from tb2 my_table limit 50' at line 1
CREATE VIEW v1 WITH LOCAL CHECK OPTION AS Select *
from tb2 my_table limit 50;
-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 'LOCAL CHECK OPTION AS Select *
+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 'WITH LOCAL CHECK OPTION AS Select *
from tb2 my_table limit 50' at line 1
SELECT * FROM tb2 my_table CREATE VIEW As v1;
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 'CREATE VIEW As v1' at line 1
@@ -3586,7 +3586,7 @@ FROM test.tb2 my_table CHECK OPTION WITH CASCADED;
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 'CHECK OPTION WITH CASCADED' at line 2
CREATE OR REPLACE VIEW v1 WITH CASCADED CHECK OPTION
AS SELECT F59, F60 FROM test.tb2 my_table;
-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 'CASCADED CHECK OPTION
+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 'WITH CASCADED CHECK OPTION
AS SELECT F59, F60 FROM test.tb2 my_table' at line 1
CREATE OR REPLACE AS SELECT F59, F60
FROM test.tb2 my_table VIEW v1 WITH CASCADED CHECK OPTION;
@@ -3615,7 +3615,7 @@ FROM test.tb2 my_table CHECK OPTION WITH LOCAL;
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 'CHECK OPTION WITH LOCAL' at line 2
CREATE OR REPLACE VIEW v1 WITH CASCADED CHECK OPTION
AS SELECT F59, F60 FROM test.tb2 my_table;
-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 'CASCADED CHECK OPTION
+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 'WITH CASCADED CHECK OPTION
AS SELECT F59, F60 FROM test.tb2 my_table' at line 1
CREATE OR REPLACE AS SELECT F59, F60
FROM test.tb2 my_table VIEW v1 WITH LOCAL CHECK OPTION;
diff --git a/mysql-test/suite/funcs_1/r/myisam_views-big.result b/mysql-test/suite/funcs_1/r/myisam_views-big.result
index 9296b9d98a2..420a400905b 100644
--- a/mysql-test/suite/funcs_1/r/myisam_views-big.result
+++ b/mysql-test/suite/funcs_1/r/myisam_views-big.result
@@ -4054,11 +4054,11 @@ CREATE VIEW v1 or REPLACE AS Select * from tb2 my_table;
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 'or REPLACE AS Select * from tb2 my_table' at line 1
CREATE VIEW v1 WITH CASCADED CHECK OPTION AS Select *
from tb2 my_table limit 50;
-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 'CASCADED CHECK OPTION AS Select *
+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 'WITH CASCADED CHECK OPTION AS Select *
from tb2 my_table limit 50' at line 1
CREATE VIEW v1 WITH LOCAL CHECK OPTION AS Select *
from tb2 my_table limit 50;
-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 'LOCAL CHECK OPTION AS Select *
+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 'WITH LOCAL CHECK OPTION AS Select *
from tb2 my_table limit 50' at line 1
SELECT * FROM tb2 my_table CREATE VIEW As v1;
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 'CREATE VIEW As v1' at line 1
@@ -4088,7 +4088,7 @@ FROM test.tb2 my_table CHECK OPTION WITH CASCADED;
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 'CHECK OPTION WITH CASCADED' at line 2
CREATE OR REPLACE VIEW v1 WITH CASCADED CHECK OPTION
AS SELECT F59, F60 FROM test.tb2 my_table;
-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 'CASCADED CHECK OPTION
+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 'WITH CASCADED CHECK OPTION
AS SELECT F59, F60 FROM test.tb2 my_table' at line 1
CREATE OR REPLACE AS SELECT F59, F60
FROM test.tb2 my_table VIEW v1 WITH CASCADED CHECK OPTION;
@@ -4117,7 +4117,7 @@ FROM test.tb2 my_table CHECK OPTION WITH LOCAL;
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 'CHECK OPTION WITH LOCAL' at line 2
CREATE OR REPLACE VIEW v1 WITH CASCADED CHECK OPTION
AS SELECT F59, F60 FROM test.tb2 my_table;
-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 'CASCADED CHECK OPTION
+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 'WITH CASCADED CHECK OPTION
AS SELECT F59, F60 FROM test.tb2 my_table' at line 1
CREATE OR REPLACE AS SELECT F59, F60
FROM test.tb2 my_table VIEW v1 WITH LOCAL CHECK OPTION;
diff --git a/mysql-test/suite/funcs_1/r/storedproc.result b/mysql-test/suite/funcs_1/r/storedproc.result
index 2c86e6c3e73..29d3b23211b 100644
--- a/mysql-test/suite/funcs_1/r/storedproc.result
+++ b/mysql-test/suite/funcs_1/r/storedproc.result
@@ -2807,7 +2807,7 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
SELECT * from t1 where f2=f1' at line 1
CREATE PROCEDURE with()
SELECT * from t1 where f2=f1;
-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 '()
+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 'with()
SELECT * from t1 where f2=f1' at line 1
CREATE PROCEDURE write()
SELECT * from t1 where f2=f1;
@@ -9222,7 +9222,7 @@ CREATE PROCEDURE sp1()
BEGIN
declare with char;
END//
-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 'char;
+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 'with char;
END' at line 3
DROP PROCEDURE IF EXISTS sp1;
Warnings:
@@ -11574,9 +11574,8 @@ BEGIN
declare with condition for sqlstate '02000';
declare exit handler for with set @var2 = 1;
END//
-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 'condition for sqlstate '02000';
-declare exit handler for with set @var2 = 1;
-END' at line 3
+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 'with condition for sqlstate '02000';
+declare exit handler for with set @var2 = 1' at line 3
DROP PROCEDURE IF EXISTS sp1;
Warnings:
Note 1305 PROCEDURE db_storedproc.sp1 does not exist
@@ -13680,7 +13679,7 @@ CREATE PROCEDURE sp1( )
BEGIN
declare with handler for sqlstate '02000' set @var2 = 1;
END//
-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 'handler for sqlstate '02000' set @var2 = 1;
+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 'with handler for sqlstate '02000' set @var2 = 1;
END' at line 3
DROP PROCEDURE IF EXISTS sp1;
Warnings:
diff --git a/mysql-test/suite/innodb_fts/r/fulltext.result b/mysql-test/suite/innodb_fts/r/fulltext.result
index f096f1c7dd5..84822109e2e 100644
--- a/mysql-test/suite/innodb_fts/r/fulltext.result
+++ b/mysql-test/suite/innodb_fts/r/fulltext.result
@@ -57,7 +57,7 @@ Only MyISAM tables support collections
MySQL has now support for full-text search
Full-text search in MySQL implements vector space model
select * from t1 where MATCH(a,b) AGAINST ("indexes" IN BOOLEAN MODE WITH QUERY EXPANSION);
-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 'QUERY EXPANSION)' at line 1
+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 'WITH QUERY EXPANSION)' at line 1
explain select * from t1 where MATCH(a,b) AGAINST ("collections");
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 fulltext a a 0 1 Using where
diff --git a/mysql-test/suite/sys_vars/r/delay_key_write_basic.result b/mysql-test/suite/sys_vars/r/delay_key_write_basic.result
index 2258d7af078..7299737f63b 100644
--- a/mysql-test/suite/sys_vars/r/delay_key_write_basic.result
+++ b/mysql-test/suite/sys_vars/r/delay_key_write_basic.result
@@ -37,8 +37,8 @@ SET @@global.delay_key_write = FALSE0;
ERROR 42000: Variable 'delay_key_write' can't be set to the value of 'FALSE0'
SET @@global.delay_key_write = ONN;
ERROR 42000: Variable 'delay_key_write' can't be set to the value of 'ONN'
-SET @@global.delay_key_write = OF;
-ERROR 42000: Variable 'delay_key_write' can't be set to the value of 'OF'
+SET @@global.delay_key_write = OFFF;
+ERROR 42000: Variable 'delay_key_write' can't be set to the value of 'OFFF'
SET @@global.delay_key_write = ' ';
ERROR 42000: Variable 'delay_key_write' can't be set to the value of ' '
SET @@global.delay_key_write = "";
diff --git a/mysql-test/suite/sys_vars/r/foreign_key_checks_basic.result b/mysql-test/suite/sys_vars/r/foreign_key_checks_basic.result
index 834d693edb8..f33ef34a62a 100644
--- a/mysql-test/suite/sys_vars/r/foreign_key_checks_basic.result
+++ b/mysql-test/suite/sys_vars/r/foreign_key_checks_basic.result
@@ -43,8 +43,8 @@ SET @@session.foreign_key_checks = TRÜE;
ERROR 42000: Variable 'foreign_key_checks' can't be set to the value of 'TRÜE'
SET @@session.foreign_key_checks = ÕN;
ERROR 42000: Variable 'foreign_key_checks' can't be set to the value of 'ÕN'
-SET @@session.foreign_key_checks = OF;
-ERROR 42000: Variable 'foreign_key_checks' can't be set to the value of 'OF'
+SET @@session.foreign_key_checks = OFFF;
+ERROR 42000: Variable 'foreign_key_checks' can't be set to the value of 'OFFF'
SET @@session.foreign_key_checks = ÓFF;
ERROR 42000: Variable 'foreign_key_checks' can't be set to the value of 'ÓFF'
SET @@session.foreign_key_checks = '¹';
diff --git a/mysql-test/suite/sys_vars/r/innodb_support_xa_basic.result b/mysql-test/suite/sys_vars/r/innodb_support_xa_basic.result
new file mode 100644
index 00000000000..5c66ff41355
--- /dev/null
+++ b/mysql-test/suite/sys_vars/r/innodb_support_xa_basic.result
@@ -0,0 +1,227 @@
+SET @session_start_value = @@session.innodb_support_xa;
+SELECT @session_start_value;
+@session_start_value
+1
+SET @global_start_value = @@global.innodb_support_xa;
+SELECT @global_start_value;
+@global_start_value
+1
+'#--------------------FN_DYNVARS_046_01------------------------#'
+SET @@session.innodb_support_xa = 0;
+Warnings:
+Warning 131 Using innodb_support_xa is deprecated and the parameter may be removed in future releases. Only innodb_support_xa=ON is allowed.
+SET @@session.innodb_support_xa = DEFAULT;
+Warnings:
+Warning 131 Using innodb_support_xa is deprecated and the parameter may be removed in future releases.
+SELECT @@session.innodb_support_xa;
+@@session.innodb_support_xa
+1
+SET @@global.innodb_support_xa = 0;
+Warnings:
+Warning 131 Using innodb_support_xa is deprecated and the parameter may be removed in future releases. Only innodb_support_xa=ON is allowed.
+SET @@global.innodb_support_xa = DEFAULT;
+Warnings:
+Warning 131 Using innodb_support_xa is deprecated and the parameter may be removed in future releases.
+SELECT @@global.innodb_support_xa;
+@@global.innodb_support_xa
+1
+'#---------------------FN_DYNVARS_046_02-------------------------#'
+SET innodb_support_xa = 1;
+Warnings:
+Warning 131 Using innodb_support_xa is deprecated and the parameter may be removed in future releases.
+SELECT @@innodb_support_xa;
+@@innodb_support_xa
+1
+SELECT session.innodb_support_xa;
+ERROR 42S02: Unknown table 'session' in field list
+SELECT local.innodb_support_xa;
+ERROR 42S02: Unknown table 'local' in field list
+SELECT global.innodb_support_xa;
+ERROR 42S02: Unknown table 'global' in field list
+SET session innodb_support_xa = 0;
+Warnings:
+Warning 131 Using innodb_support_xa is deprecated and the parameter may be removed in future releases. Only innodb_support_xa=ON is allowed.
+SELECT @@session.innodb_support_xa;
+@@session.innodb_support_xa
+1
+SET global innodb_support_xa = 0;
+Warnings:
+Warning 131 Using innodb_support_xa is deprecated and the parameter may be removed in future releases. Only innodb_support_xa=ON is allowed.
+SELECT @@global.innodb_support_xa;
+@@global.innodb_support_xa
+1
+'#--------------------FN_DYNVARS_046_03------------------------#'
+SET @@session.innodb_support_xa = 0;
+Warnings:
+Warning 131 Using innodb_support_xa is deprecated and the parameter may be removed in future releases. Only innodb_support_xa=ON is allowed.
+SELECT @@session.innodb_support_xa;
+@@session.innodb_support_xa
+1
+SET @@session.innodb_support_xa = 1;
+Warnings:
+Warning 131 Using innodb_support_xa is deprecated and the parameter may be removed in future releases.
+SELECT @@session.innodb_support_xa;
+@@session.innodb_support_xa
+1
+SET @@global.innodb_support_xa = 0;
+Warnings:
+Warning 131 Using innodb_support_xa is deprecated and the parameter may be removed in future releases. Only innodb_support_xa=ON is allowed.
+SELECT @@global.innodb_support_xa;
+@@global.innodb_support_xa
+1
+SET @@global.innodb_support_xa = 1;
+Warnings:
+Warning 131 Using innodb_support_xa is deprecated and the parameter may be removed in future releases.
+SELECT @@global.innodb_support_xa;
+@@global.innodb_support_xa
+1
+'#--------------------FN_DYNVARS_046_04-------------------------#'
+SET @@session.innodb_support_xa = -0.6;
+ERROR 42000: Incorrect argument type to variable 'innodb_support_xa'
+SET @@session.innodb_support_xa = 1.6;
+ERROR 42000: Incorrect argument type to variable 'innodb_support_xa'
+SET @@session.innodb_support_xa = "T";
+ERROR 42000: Variable 'innodb_support_xa' can't be set to the value of 'T'
+SET @@session.innodb_support_xa = "Y";
+ERROR 42000: Variable 'innodb_support_xa' can't be set to the value of 'Y'
+SET @@session.innodb_support_xa = TRÜE;
+ERROR 42000: Variable 'innodb_support_xa' can't be set to the value of 'TRÜE'
+SET @@session.innodb_support_xa = ÕN;
+ERROR 42000: Variable 'innodb_support_xa' can't be set to the value of 'ÕN'
+SET @@session.innodb_support_xa = OFF;
+Warnings:
+Warning 131 Using innodb_support_xa is deprecated and the parameter may be removed in future releases. Only innodb_support_xa=ON is allowed.
+SELECT @@session.innodb_support_xa;
+@@session.innodb_support_xa
+1
+SET @@session.innodb_support_xa = ÓFF;
+ERROR 42000: Variable 'innodb_support_xa' can't be set to the value of 'ÓFF'
+SET @@global.innodb_support_xa = -1;
+ERROR 42000: Variable 'innodb_support_xa' can't be set to the value of '-1'
+SELECT @@global.innodb_support_xa;
+@@global.innodb_support_xa
+1
+SET @@global.innodb_support_xa = 2;
+ERROR 42000: Variable 'innodb_support_xa' can't be set to the value of '2'
+SET @@global.innodb_support_xa = "T";
+ERROR 42000: Variable 'innodb_support_xa' can't be set to the value of 'T'
+SET @@global.innodb_support_xa = "Y";
+ERROR 42000: Variable 'innodb_support_xa' can't be set to the value of 'Y'
+SET @@global.innodb_support_xa = TRÜE;
+ERROR 42000: Variable 'innodb_support_xa' can't be set to the value of 'TRÜE'
+SET @@global.innodb_support_xa = ÕN;
+ERROR 42000: Variable 'innodb_support_xa' can't be set to the value of 'ÕN'
+SET @@global.innodb_support_xa = OFF;
+Warnings:
+Warning 131 Using innodb_support_xa is deprecated and the parameter may be removed in future releases. Only innodb_support_xa=ON is allowed.
+SELECT @@global.innodb_support_xa;
+@@global.innodb_support_xa
+1
+SET @@global.innodb_support_xa = ÓFF;
+ERROR 42000: Variable 'innodb_support_xa' can't be set to the value of 'ÓFF'
+'#-------------------FN_DYNVARS_046_05----------------------------#'
+SET @@global.innodb_support_xa = 0;
+Warnings:
+Warning 131 Using innodb_support_xa is deprecated and the parameter may be removed in future releases. Only innodb_support_xa=ON is allowed.
+SET @@session.innodb_support_xa = 1;
+Warnings:
+Warning 131 Using innodb_support_xa is deprecated and the parameter may be removed in future releases.
+SELECT @@global.innodb_support_xa AS res_is_0;
+res_is_0
+1
+SET @@global.innodb_support_xa = 0;
+Warnings:
+Warning 131 Using innodb_support_xa is deprecated and the parameter may be removed in future releases. Only innodb_support_xa=ON is allowed.
+SELECT @@session.innodb_support_xa AS res_is_1;
+res_is_1
+1
+'#----------------------FN_DYNVARS_046_06------------------------#'
+SELECT IF(@@global.innodb_support_xa, "ON", "OFF") =
+VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
+WHERE VARIABLE_NAME='innodb_support_xa';
+IF(@@global.innodb_support_xa, "ON", "OFF") =
+VARIABLE_VALUE
+1
+SELECT @@global.innodb_support_xa;
+@@global.innodb_support_xa
+1
+SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
+WHERE VARIABLE_NAME='innodb_support_xa';
+VARIABLE_VALUE
+ON
+'#----------------------FN_DYNVARS_046_07------------------------#'
+SELECT IF(@@session.innodb_support_xa, "ON", "OFF") =
+VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_VARIABLES
+WHERE VARIABLE_NAME='innodb_support_xa';
+IF(@@session.innodb_support_xa, "ON", "OFF") =
+VARIABLE_VALUE
+1
+SELECT @@session.innodb_support_xa;
+@@session.innodb_support_xa
+1
+SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_VARIABLES
+WHERE VARIABLE_NAME='innodb_support_xa';
+VARIABLE_VALUE
+ON
+'#---------------------FN_DYNVARS_046_08-------------------------#'
+SET @@session.innodb_support_xa = OFF;
+Warnings:
+Warning 131 Using innodb_support_xa is deprecated and the parameter may be removed in future releases. Only innodb_support_xa=ON is allowed.
+SELECT @@session.innodb_support_xa;
+@@session.innodb_support_xa
+1
+SET @@session.innodb_support_xa = ON;
+Warnings:
+Warning 131 Using innodb_support_xa is deprecated and the parameter may be removed in future releases.
+SELECT @@session.innodb_support_xa;
+@@session.innodb_support_xa
+1
+SET @@global.innodb_support_xa = OFF;
+Warnings:
+Warning 131 Using innodb_support_xa is deprecated and the parameter may be removed in future releases. Only innodb_support_xa=ON is allowed.
+SELECT @@global.innodb_support_xa;
+@@global.innodb_support_xa
+1
+SET @@global.innodb_support_xa = ON;
+Warnings:
+Warning 131 Using innodb_support_xa is deprecated and the parameter may be removed in future releases.
+SELECT @@global.innodb_support_xa;
+@@global.innodb_support_xa
+1
+'#---------------------FN_DYNVARS_046_09----------------------#'
+SET @@session.innodb_support_xa = TRUE;
+Warnings:
+Warning 131 Using innodb_support_xa is deprecated and the parameter may be removed in future releases.
+SELECT @@session.innodb_support_xa;
+@@session.innodb_support_xa
+1
+SET @@session.innodb_support_xa = FALSE;
+Warnings:
+Warning 131 Using innodb_support_xa is deprecated and the parameter may be removed in future releases. Only innodb_support_xa=ON is allowed.
+SELECT @@session.innodb_support_xa;
+@@session.innodb_support_xa
+1
+SET @@global.innodb_support_xa = TRUE;
+Warnings:
+Warning 131 Using innodb_support_xa is deprecated and the parameter may be removed in future releases.
+SELECT @@global.innodb_support_xa;
+@@global.innodb_support_xa
+1
+SET @@global.innodb_support_xa = FALSE;
+Warnings:
+Warning 131 Using innodb_support_xa is deprecated and the parameter may be removed in future releases. Only innodb_support_xa=ON is allowed.
+SELECT @@global.innodb_support_xa;
+@@global.innodb_support_xa
+1
+SET @@session.innodb_support_xa = @session_start_value;
+Warnings:
+Warning 131 Using innodb_support_xa is deprecated and the parameter may be removed in future releases.
+SELECT @@session.innodb_support_xa;
+@@session.innodb_support_xa
+1
+SET @@global.innodb_support_xa = @global_start_value;
+Warnings:
+Warning 131 Using innodb_support_xa is deprecated and the parameter may be removed in future releases.
+SELECT @@global.innodb_support_xa;
+@@global.innodb_support_xa
+1
diff --git a/mysql-test/suite/sys_vars/r/innodb_table_locks_basic.result b/mysql-test/suite/sys_vars/r/innodb_table_locks_basic.result
index 08dc5d7aaca..aec529aece2 100644
--- a/mysql-test/suite/sys_vars/r/innodb_table_locks_basic.result
+++ b/mysql-test/suite/sys_vars/r/innodb_table_locks_basic.result
@@ -66,7 +66,7 @@ SET @@session.innodb_table_locks = TRÜE;
ERROR 42000: Variable 'innodb_table_locks' can't be set to the value of 'TRÜE'
SET @@session.innodb_table_locks = ÕN;
ERROR 42000: Variable 'innodb_table_locks' can't be set to the value of 'ÕN'
-SET @@session.innodb_table_locks = OF;
+SET @@session.innodb_table_locks = OFF;
SELECT @@session.innodb_table_locks;
@@session.innodb_table_locks
0
@@ -84,7 +84,7 @@ SET @@global.innodb_table_locks = TRÜE;
ERROR 42000: Variable 'innodb_table_locks' can't be set to the value of 'TRÜE'
SET @@global.innodb_table_locks = QN;
ERROR 42000: Variable 'innodb_table_locks' can't be set to the value of 'QN'
-SET @@global.innodb_table_locks = OF;
+SET @@global.innodb_table_locks = OFF;
SELECT @@global.innodb_table_locks;
@@global.innodb_table_locks
0
diff --git a/mysql-test/suite/sys_vars/r/keep_files_on_create_basic.result b/mysql-test/suite/sys_vars/r/keep_files_on_create_basic.result
index b7deea88a9c..8e9f7308b73 100644
--- a/mysql-test/suite/sys_vars/r/keep_files_on_create_basic.result
+++ b/mysql-test/suite/sys_vars/r/keep_files_on_create_basic.result
@@ -101,8 +101,8 @@ SET @@session.keep_files_on_create = ONN;
ERROR 42000: Variable 'keep_files_on_create' can't be set to the value of 'ONN'
SET @@session.keep_files_on_create = ONF;
ERROR 42000: Variable 'keep_files_on_create' can't be set to the value of 'ONF'
-SET @@session.keep_files_on_create = OF;
-ERROR 42000: Variable 'keep_files_on_create' can't be set to the value of 'OF'
+SET @@session.keep_files_on_create = OFFF;
+ERROR 42000: Variable 'keep_files_on_create' can't be set to the value of 'OFFF'
SET @@session.keep_files_on_create = 'OFN';
ERROR 42000: Variable 'keep_files_on_create' can't be set to the value of 'OFN'
SET @@session.keep_files_on_create = -2;
diff --git a/mysql-test/suite/sys_vars/r/log_bin_trust_function_creators_basic.result b/mysql-test/suite/sys_vars/r/log_bin_trust_function_creators_basic.result
index 7ed1b689f5a..d3d2e97d249 100644
--- a/mysql-test/suite/sys_vars/r/log_bin_trust_function_creators_basic.result
+++ b/mysql-test/suite/sys_vars/r/log_bin_trust_function_creators_basic.result
@@ -50,8 +50,8 @@ SET @@global.log_bin_trust_function_creators = 'ONN';
ERROR 42000: Variable 'log_bin_trust_function_creators' can't be set to the value of 'ONN'
SET @@global.log_bin_trust_function_creators = "OFFF";
ERROR 42000: Variable 'log_bin_trust_function_creators' can't be set to the value of 'OFFF'
-SET @@global.log_bin_trust_function_creators = OF;
-ERROR 42000: Variable 'log_bin_trust_function_creators' can't be set to the value of 'OF'
+SET @@global.log_bin_trust_function_creators = OFFF;
+ERROR 42000: Variable 'log_bin_trust_function_creators' can't be set to the value of 'OFFF'
SET @@global.log_bin_trust_function_creators = TTRUE;
ERROR 42000: Variable 'log_bin_trust_function_creators' can't be set to the value of 'TTRUE'
SET @@global.log_bin_trust_function_creators = FELSE;
diff --git a/mysql-test/suite/sys_vars/r/low_priority_updates_basic.result b/mysql-test/suite/sys_vars/r/low_priority_updates_basic.result
index 633dc274dec..9e514c8cb35 100644
--- a/mysql-test/suite/sys_vars/r/low_priority_updates_basic.result
+++ b/mysql-test/suite/sys_vars/r/low_priority_updates_basic.result
@@ -101,8 +101,8 @@ SET @@session.low_priority_updates = ONN;
ERROR 42000: Variable 'low_priority_updates' can't be set to the value of 'ONN'
SET @@session.low_priority_updates = ONF;
ERROR 42000: Variable 'low_priority_updates' can't be set to the value of 'ONF'
-SET @@session.low_priority_updates = OF;
-ERROR 42000: Variable 'low_priority_updates' can't be set to the value of 'OF'
+SET @@session.low_priority_updates = OFFF;
+ERROR 42000: Variable 'low_priority_updates' can't be set to the value of 'OFFF'
SET @@session.low_priority_updates = 'OFN';
ERROR 42000: Variable 'low_priority_updates' can't be set to the value of 'OFN'
SET @@session.low_priority_updates = -2;
diff --git a/mysql-test/suite/sys_vars/r/old_passwords_basic.result b/mysql-test/suite/sys_vars/r/old_passwords_basic.result
index 26d0e79071b..dba84b18b11 100644
--- a/mysql-test/suite/sys_vars/r/old_passwords_basic.result
+++ b/mysql-test/suite/sys_vars/r/old_passwords_basic.result
@@ -97,8 +97,8 @@ SET @@session.old_passwords = ONN;
ERROR 42000: Variable 'old_passwords' can't be set to the value of 'ONN'
SET @@session.old_passwords = ONF;
ERROR 42000: Variable 'old_passwords' can't be set to the value of 'ONF'
-SET @@session.old_passwords = OF;
-ERROR 42000: Variable 'old_passwords' can't be set to the value of 'OF'
+SET @@session.old_passwords = OFFF;
+ERROR 42000: Variable 'old_passwords' can't be set to the value of 'OFFF'
SET @@session.old_passwords = 'OFN';
ERROR 42000: Variable 'old_passwords' can't be set to the value of 'OFN'
SET @@session.old_passwords = -2;
diff --git a/mysql-test/suite/sys_vars/r/optimizer_prune_level_basic.result b/mysql-test/suite/sys_vars/r/optimizer_prune_level_basic.result
index 99843f0b93f..c22107292cd 100644
--- a/mysql-test/suite/sys_vars/r/optimizer_prune_level_basic.result
+++ b/mysql-test/suite/sys_vars/r/optimizer_prune_level_basic.result
@@ -104,7 +104,7 @@ SET @@session.optimizer_prune_level = ONF;
ERROR 42000: Incorrect argument type to variable 'optimizer_prune_level'
SET @@session.optimizer_prune_level = ON;
ERROR 42000: Incorrect argument type to variable 'optimizer_prune_level'
-SET @@session.optimizer_prune_level = OF;
+SET @@session.optimizer_prune_level = OFFF;
ERROR 42000: Incorrect argument type to variable 'optimizer_prune_level'
SET @@session.optimizer_prune_level = 'OFN';
ERROR 42000: Incorrect argument type to variable 'optimizer_prune_level'
diff --git a/mysql-test/suite/sys_vars/r/pseudo_slave_mode_basic.result b/mysql-test/suite/sys_vars/r/pseudo_slave_mode_basic.result
index c98dd338909..cec880bf1d5 100644
--- a/mysql-test/suite/sys_vars/r/pseudo_slave_mode_basic.result
+++ b/mysql-test/suite/sys_vars/r/pseudo_slave_mode_basic.result
@@ -58,8 +58,8 @@ SET @@session.pseudo_slave_mode = TRÜE;
ERROR 42000: Variable 'pseudo_slave_mode' can't be set to the value of 'TRÜE'
SET @@session.pseudo_slave_mode = ÕN;
ERROR 42000: Variable 'pseudo_slave_mode' can't be set to the value of 'ÕN'
-SET @@session.pseudo_slave_mode = OF;
-ERROR 42000: Variable 'pseudo_slave_mode' can't be set to the value of 'OF'
+SET @@session.pseudo_slave_mode = OFFF;
+ERROR 42000: Variable 'pseudo_slave_mode' can't be set to the value of 'OFFF'
SET @@session.pseudo_slave_mode = ÓFF;
ERROR 42000: Variable 'pseudo_slave_mode' can't be set to the value of 'ÓFF'
SET @@session.pseudo_slave_mode = '¹';
diff --git a/mysql-test/suite/sys_vars/r/query_cache_wlock_invalidate_basic.result b/mysql-test/suite/sys_vars/r/query_cache_wlock_invalidate_basic.result
index 96f42bbbda3..26169b4b979 100644
--- a/mysql-test/suite/sys_vars/r/query_cache_wlock_invalidate_basic.result
+++ b/mysql-test/suite/sys_vars/r/query_cache_wlock_invalidate_basic.result
@@ -66,8 +66,8 @@ SET @@session.query_cache_wlock_invalidate = TRÜE;
ERROR 42000: Variable 'query_cache_wlock_invalidate' can't be set to the value of 'TRÜE'
SET @@session.query_cache_wlock_invalidate = ÕN;
ERROR 42000: Variable 'query_cache_wlock_invalidate' can't be set to the value of 'ÕN'
-SET @@session.query_cache_wlock_invalidate = OF;
-ERROR 42000: Variable 'query_cache_wlock_invalidate' can't be set to the value of 'OF'
+SET @@session.query_cache_wlock_invalidate = OFFF;
+ERROR 42000: Variable 'query_cache_wlock_invalidate' can't be set to the value of 'OFFF'
SET @@session.query_cache_wlock_invalidate = ÓFF;
ERROR 42000: Variable 'query_cache_wlock_invalidate' can't be set to the value of 'ÓFF'
SET @@global.query_cache_wlock_invalidate = -1;
@@ -82,8 +82,8 @@ SET @@global.query_cache_wlock_invalidate = TRÜE;
ERROR 42000: Variable 'query_cache_wlock_invalidate' can't be set to the value of 'TRÜE'
SET @@global.query_cache_wlock_invalidate = ÕN;
ERROR 42000: Variable 'query_cache_wlock_invalidate' can't be set to the value of 'ÕN'
-SET @@global.query_cache_wlock_invalidate = OF;
-ERROR 42000: Variable 'query_cache_wlock_invalidate' can't be set to the value of 'OF'
+SET @@global.query_cache_wlock_invalidate = OFFF;
+ERROR 42000: Variable 'query_cache_wlock_invalidate' can't be set to the value of 'OFFF'
SET @@global.query_cache_wlock_invalidate = ÓFF;
ERROR 42000: Variable 'query_cache_wlock_invalidate' can't be set to the value of 'ÓFF'
'#-------------------FN_DYNVARS_135_05----------------------------#'
diff --git a/mysql-test/suite/sys_vars/r/sql_big_selects_basic.result b/mysql-test/suite/sys_vars/r/sql_big_selects_basic.result
index 98f05bda488..fc16ecc06f2 100644
--- a/mysql-test/suite/sys_vars/r/sql_big_selects_basic.result
+++ b/mysql-test/suite/sys_vars/r/sql_big_selects_basic.result
@@ -43,8 +43,8 @@ SET @@session.sql_big_selects = TRÜE;
ERROR 42000: Variable 'sql_big_selects' can't be set to the value of 'TRÜE'
SET @@session.sql_big_selects = ÕN;
ERROR 42000: Variable 'sql_big_selects' can't be set to the value of 'ÕN'
-SET @@session.sql_big_selects = OF;
-ERROR 42000: Variable 'sql_big_selects' can't be set to the value of 'OF'
+SET @@session.sql_big_selects = OFFF;
+ERROR 42000: Variable 'sql_big_selects' can't be set to the value of 'OFFF'
SET @@session.sql_big_selects = ÓFF;
ERROR 42000: Variable 'sql_big_selects' can't be set to the value of 'ÓFF'
SET @@session.sql_big_selects = '¹';
diff --git a/mysql-test/suite/sys_vars/r/sql_big_tables_basic.result b/mysql-test/suite/sys_vars/r/sql_big_tables_basic.result
index 09553ae7d57..91081a78328 100644
--- a/mysql-test/suite/sys_vars/r/sql_big_tables_basic.result
+++ b/mysql-test/suite/sys_vars/r/sql_big_tables_basic.result
@@ -48,7 +48,7 @@ SET @@session.sql_big_tables = TRÜE;
ERROR 42000: Variable 'sql_big_tables' can't be set to the value of 'TRÜE'
SET @@session.sql_big_tables = ÕN;
ERROR 42000: Variable 'sql_big_tables' can't be set to the value of 'ÕN'
-SET @@session.sql_big_tables = OF;
+SET @@session.sql_big_tables = OFFF;
ERROR 42000: Variable 'sql_big_tables' can't be set to the value of 'OF'
SET @@session.sql_big_tables = ÓFF;
ERROR 42000: Variable 'sql_big_tables' can't be set to the value of 'ÓFF'
diff --git a/mysql-test/suite/sys_vars/r/sql_buffer_result_basic.result b/mysql-test/suite/sys_vars/r/sql_buffer_result_basic.result
index 2dfdcb26898..83597ef47cb 100644
--- a/mysql-test/suite/sys_vars/r/sql_buffer_result_basic.result
+++ b/mysql-test/suite/sys_vars/r/sql_buffer_result_basic.result
@@ -48,8 +48,8 @@ SET @@session.sql_buffer_result = TRÜE;
ERROR 42000: Variable 'sql_buffer_result' can't be set to the value of 'TRÜE'
SET @@session.sql_buffer_result = ÕN;
ERROR 42000: Variable 'sql_buffer_result' can't be set to the value of 'ÕN'
-SET @@session.sql_buffer_result = OF;
-ERROR 42000: Variable 'sql_buffer_result' can't be set to the value of 'OF'
+SET @@session.sql_buffer_result = OFFF;
+ERROR 42000: Variable 'sql_buffer_result' can't be set to the value of 'OFFF'
SET @@session.sql_buffer_result = ÓFF;
ERROR 42000: Variable 'sql_buffer_result' can't be set to the value of 'ÓFF'
SET @@session.sql_buffer_result = '¹';
diff --git a/mysql-test/suite/sys_vars/r/sql_log_bin_basic.result b/mysql-test/suite/sys_vars/r/sql_log_bin_basic.result
index 909c434340c..a909019fc50 100644
--- a/mysql-test/suite/sys_vars/r/sql_log_bin_basic.result
+++ b/mysql-test/suite/sys_vars/r/sql_log_bin_basic.result
@@ -48,8 +48,8 @@ SET @@session.sql_log_bin = TRÜE;
ERROR 42000: Variable 'sql_log_bin' can't be set to the value of 'TRÜE'
SET @@session.sql_log_bin = ÕN;
ERROR 42000: Variable 'sql_log_bin' can't be set to the value of 'ÕN'
-SET @@session.sql_log_bin = OF;
-ERROR 42000: Variable 'sql_log_bin' can't be set to the value of 'OF'
+SET @@session.sql_log_bin = OFFF;
+ERROR 42000: Variable 'sql_log_bin' can't be set to the value of 'OFFF'
SET @@session.sql_log_bin = ÓFF;
ERROR 42000: Variable 'sql_log_bin' can't be set to the value of 'ÓFF'
SET @@session.sql_log_bin = '¹';
diff --git a/mysql-test/suite/sys_vars/r/sql_log_off_basic.result b/mysql-test/suite/sys_vars/r/sql_log_off_basic.result
index c2ffa17c5fe..0cb5b576127 100644
--- a/mysql-test/suite/sys_vars/r/sql_log_off_basic.result
+++ b/mysql-test/suite/sys_vars/r/sql_log_off_basic.result
@@ -48,8 +48,8 @@ SET @@session.sql_log_off = TRÜE;
ERROR 42000: Variable 'sql_log_off' can't be set to the value of 'TRÜE'
SET @@session.sql_log_off = ÕN;
ERROR 42000: Variable 'sql_log_off' can't be set to the value of 'ÕN'
-SET @@session.sql_log_off = OF;
-ERROR 42000: Variable 'sql_log_off' can't be set to the value of 'OF'
+SET @@session.sql_log_off = OFFF;
+ERROR 42000: Variable 'sql_log_off' can't be set to the value of 'OFFF'
SET @@session.sql_log_off = ÓFF;
ERROR 42000: Variable 'sql_log_off' can't be set to the value of 'ÓFF'
SET @@session.sql_log_off = '¹';
diff --git a/mysql-test/suite/sys_vars/r/sql_low_priority_updates_basic.result b/mysql-test/suite/sys_vars/r/sql_low_priority_updates_basic.result
index 28bc53e5718..ed493e038ca 100644
--- a/mysql-test/suite/sys_vars/r/sql_low_priority_updates_basic.result
+++ b/mysql-test/suite/sys_vars/r/sql_low_priority_updates_basic.result
@@ -63,7 +63,7 @@ SET @@session.sql_low_priority_updates = TRÜE;
ERROR 42000: Variable 'sql_low_priority_updates' can't be set to the value of 'TRÜE'
SET @@session.sql_low_priority_updates = ÕN;
ERROR 42000: Variable 'sql_low_priority_updates' can't be set to the value of 'ÕN'
-SET @@session.sql_low_priority_updates = OF;
+SET @@session.sql_low_priority_updates = OFFF;
ERROR 42000: Variable 'sql_low_priority_updates' can't be set to the value of 'OF'
SET @@session.sql_low_priority_updates = ÓFF;
ERROR 42000: Variable 'sql_low_priority_updates' can't be set to the value of 'ÓFF'
@@ -79,7 +79,7 @@ SET @@global.sql_low_priority_updates = TRÜE;
ERROR 42000: Variable 'sql_low_priority_updates' can't be set to the value of 'TRÜE'
SET @@global.sql_low_priority_updates = ÕN;
ERROR 42000: Variable 'sql_low_priority_updates' can't be set to the value of 'ÕN'
-SET @@global.sql_low_priority_updates = OF;
+SET @@global.sql_low_priority_updates = OFFF;
ERROR 42000: Variable 'sql_low_priority_updates' can't be set to the value of 'OF'
SET @@global.sql_low_priority_updates = ÓFF;
ERROR 42000: Variable 'sql_low_priority_updates' can't be set to the value of 'ÓFF'
diff --git a/mysql-test/suite/sys_vars/r/sql_notes_basic.result b/mysql-test/suite/sys_vars/r/sql_notes_basic.result
index 7a54f90f8b7..18a846874ab 100644
--- a/mysql-test/suite/sys_vars/r/sql_notes_basic.result
+++ b/mysql-test/suite/sys_vars/r/sql_notes_basic.result
@@ -48,8 +48,8 @@ SET @@session.sql_notes = TRÜE;
ERROR 42000: Variable 'sql_notes' can't be set to the value of 'TRÜE'
SET @@session.sql_notes = ÕN;
ERROR 42000: Variable 'sql_notes' can't be set to the value of 'ÕN'
-SET @@session.sql_notes = OF;
-ERROR 42000: Variable 'sql_notes' can't be set to the value of 'OF'
+SET @@session.sql_notes = OFFF;
+ERROR 42000: Variable 'sql_notes' can't be set to the value of 'OFFF'
SET @@session.sql_notes = ÓFF;
ERROR 42000: Variable 'sql_notes' can't be set to the value of 'ÓFF'
SET @@session.sql_notes = '¹';
diff --git a/mysql-test/suite/sys_vars/r/sql_quote_show_create_basic.result b/mysql-test/suite/sys_vars/r/sql_quote_show_create_basic.result
index 8cf99233ef9..97715ae2089 100644
--- a/mysql-test/suite/sys_vars/r/sql_quote_show_create_basic.result
+++ b/mysql-test/suite/sys_vars/r/sql_quote_show_create_basic.result
@@ -48,8 +48,8 @@ SET @@session.sql_quote_show_create = TRÜE;
ERROR 42000: Variable 'sql_quote_show_create' can't be set to the value of 'TRÜE'
SET @@session.sql_quote_show_create = ÕN;
ERROR 42000: Variable 'sql_quote_show_create' can't be set to the value of 'ÕN'
-SET @@session.sql_quote_show_create = OF;
-ERROR 42000: Variable 'sql_quote_show_create' can't be set to the value of 'OF'
+SET @@session.sql_quote_show_create = OFFF;
+ERROR 42000: Variable 'sql_quote_show_create' can't be set to the value of 'OFFF'
SET @@session.sql_quote_show_create = ÓFF;
ERROR 42000: Variable 'sql_quote_show_create' can't be set to the value of 'ÓFF'
SET @@session.sql_quote_show_create = '¹';
diff --git a/mysql-test/suite/sys_vars/r/sql_safe_updates_basic.result b/mysql-test/suite/sys_vars/r/sql_safe_updates_basic.result
index 91bfcb2377e..4bdcc8f6b47 100644
--- a/mysql-test/suite/sys_vars/r/sql_safe_updates_basic.result
+++ b/mysql-test/suite/sys_vars/r/sql_safe_updates_basic.result
@@ -48,8 +48,8 @@ SET @@session.sql_safe_updates = TRÜE;
ERROR 42000: Variable 'sql_safe_updates' can't be set to the value of 'TRÜE'
SET @@session.sql_safe_updates = ÕN;
ERROR 42000: Variable 'sql_safe_updates' can't be set to the value of 'ÕN'
-SET @@session.sql_safe_updates = OF;
-ERROR 42000: Variable 'sql_safe_updates' can't be set to the value of 'OF'
+SET @@session.sql_safe_updates = OFFF;
+ERROR 42000: Variable 'sql_safe_updates' can't be set to the value of 'OFFF'
SET @@session.sql_safe_updates = ÓFF;
ERROR 42000: Variable 'sql_safe_updates' can't be set to the value of 'ÓFF'
SET @@session.sql_safe_updates = '¹';
diff --git a/mysql-test/suite/sys_vars/r/sql_warnings_basic.result b/mysql-test/suite/sys_vars/r/sql_warnings_basic.result
index 762182336c3..f9cae0c7f7a 100644
--- a/mysql-test/suite/sys_vars/r/sql_warnings_basic.result
+++ b/mysql-test/suite/sys_vars/r/sql_warnings_basic.result
@@ -46,8 +46,8 @@ SET @@session.sql_warnings = TRÜE;
ERROR 42000: Variable 'sql_warnings' can't be set to the value of 'TRÜE'
SET @@session.sql_warnings = ÕN;
ERROR 42000: Variable 'sql_warnings' can't be set to the value of 'ÕN'
-SET @@session.sql_warnings = OF;
-ERROR 42000: Variable 'sql_warnings' can't be set to the value of 'OF'
+SET @@session.sql_warnings = OFFF;
+ERROR 42000: Variable 'sql_warnings' can't be set to the value of 'OFFF'
SET @@session.sql_warnings = ÓFF;
ERROR 42000: Variable 'sql_warnings' can't be set to the value of 'ÓFF'
SET @@session.sql_warnings = '¹';
diff --git a/mysql-test/suite/sys_vars/r/tx_read_only_basic.result b/mysql-test/suite/sys_vars/r/tx_read_only_basic.result
index 3750145083f..e8f5da31c5a 100644
--- a/mysql-test/suite/sys_vars/r/tx_read_only_basic.result
+++ b/mysql-test/suite/sys_vars/r/tx_read_only_basic.result
@@ -102,8 +102,8 @@ SET @@session.tx_read_only = ONN;
ERROR 42000: Variable 'tx_read_only' can't be set to the value of 'ONN'
SET @@session.tx_read_only = ONF;
ERROR 42000: Variable 'tx_read_only' can't be set to the value of 'ONF'
-SET @@session.tx_read_only = OF;
-ERROR 42000: Variable 'tx_read_only' can't be set to the value of 'OF'
+SET @@session.tx_read_only = OFFF;
+ERROR 42000: Variable 'tx_read_only' can't be set to the value of 'OFFF'
SET @@session.tx_read_only = 'OFN';
ERROR 42000: Variable 'tx_read_only' can't be set to the value of 'OFN'
SET @@session.tx_read_only = -2;
diff --git a/mysql-test/suite/sys_vars/t/delay_key_write_basic.test b/mysql-test/suite/sys_vars/t/delay_key_write_basic.test
index 25176879eb1..2856993cb6c 100644
--- a/mysql-test/suite/sys_vars/t/delay_key_write_basic.test
+++ b/mysql-test/suite/sys_vars/t/delay_key_write_basic.test
@@ -90,7 +90,7 @@ SET @@global.delay_key_write = FALSE0;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@global.delay_key_write = ONN;
--Error ER_WRONG_VALUE_FOR_VAR
-SET @@global.delay_key_write = OF;
+SET @@global.delay_key_write = OFFF;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@global.delay_key_write = ' ';
diff --git a/mysql-test/suite/sys_vars/t/foreign_key_checks_basic.test b/mysql-test/suite/sys_vars/t/foreign_key_checks_basic.test
index 8a327ab699b..b1fc9997cfa 100644
--- a/mysql-test/suite/sys_vars/t/foreign_key_checks_basic.test
+++ b/mysql-test/suite/sys_vars/t/foreign_key_checks_basic.test
@@ -94,7 +94,7 @@ SET @@session.foreign_key_checks = TRÜE;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@session.foreign_key_checks = ÕN;
--Error ER_WRONG_VALUE_FOR_VAR
-SET @@session.foreign_key_checks = OF;
+SET @@session.foreign_key_checks = OFFF;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@session.foreign_key_checks = ÓFF;
--Error ER_WRONG_VALUE_FOR_VAR
diff --git a/mysql-test/suite/sys_vars/t/innodb_support_xa_basic.test b/mysql-test/suite/sys_vars/t/innodb_support_xa_basic.test
new file mode 100644
index 00000000000..f8ce5852769
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/innodb_support_xa_basic.test
@@ -0,0 +1,240 @@
+################# mysql-test\t\innodb_support_xa_basic.test ###################
+# #
+# Variable Name: innodb_support_xa #
+# Scope: GLOBAL | SESSION #
+# Access Type: Dynamic #
+# Data Type: boolean #
+# Default Value: 1 #
+# Range: 0,1 #
+# #
+# #
+# Creation Date: 2008-02-20 #
+# Author: Rizwan #
+# #
+# Description: Test Cases of Dynamic System Variable innodb_support_xa #
+# that checks the behavior of this variable in the following ways#
+# * Default Value #
+# * Valid & Invalid values #
+# * Scope & Access method #
+# * Data Integrity #
+# #
+# Reference: http://dev.mysql.com/doc/refman/5.1/en/ #
+# server-system-variables.html #
+# #
+###############################################################################
+
+--source include/have_innodb.inc
+--source include/load_sysvars.inc
+
+########################################################################
+# START OF innodb_support_xa TESTS #
+########################################################################
+
+
+################################################################################
+# Saving initial value of innodb_support_xa in a temporary variable #
+################################################################################
+
+
+SET @session_start_value = @@session.innodb_support_xa;
+SELECT @session_start_value;
+
+
+SET @global_start_value = @@global.innodb_support_xa;
+SELECT @global_start_value;
+
+
+
+--echo '#--------------------FN_DYNVARS_046_01------------------------#'
+########################################################################
+# Display the DEFAULT value of innodb_support_xa #
+########################################################################
+
+SET @@session.innodb_support_xa = 0;
+SET @@session.innodb_support_xa = DEFAULT;
+SELECT @@session.innodb_support_xa;
+
+SET @@global.innodb_support_xa = 0;
+SET @@global.innodb_support_xa = DEFAULT;
+SELECT @@global.innodb_support_xa;
+
+--echo '#---------------------FN_DYNVARS_046_02-------------------------#'
+##########################################################################
+# Check if innodb_support_xa can be accessed with and without @@ sign #
+##########################################################################
+
+SET innodb_support_xa = 1;
+SELECT @@innodb_support_xa;
+
+--Error ER_UNKNOWN_TABLE
+SELECT session.innodb_support_xa;
+
+--Error ER_UNKNOWN_TABLE
+SELECT local.innodb_support_xa;
+
+--Error ER_UNKNOWN_TABLE
+SELECT global.innodb_support_xa;
+#using another syntax for accessing system variables
+SET session innodb_support_xa = 0;
+SELECT @@session.innodb_support_xa;
+
+SET global innodb_support_xa = 0;
+SELECT @@global.innodb_support_xa;
+
+
+--echo '#--------------------FN_DYNVARS_046_03------------------------#'
+##########################################################################
+# change the value of innodb_support_xa to a valid value #
+##########################################################################
+# for session
+SET @@session.innodb_support_xa = 0;
+SELECT @@session.innodb_support_xa;
+SET @@session.innodb_support_xa = 1;
+SELECT @@session.innodb_support_xa;
+
+# for global
+SET @@global.innodb_support_xa = 0;
+SELECT @@global.innodb_support_xa;
+SET @@global.innodb_support_xa = 1;
+SELECT @@global.innodb_support_xa;
+
+
+--echo '#--------------------FN_DYNVARS_046_04-------------------------#'
+###########################################################################
+# Change the value of innodb_support_xa to invalid value #
+###########################################################################
+
+# for session
+--Error ER_WRONG_TYPE_FOR_VAR
+SET @@session.innodb_support_xa = -0.6;
+--Error ER_WRONG_TYPE_FOR_VAR
+SET @@session.innodb_support_xa = 1.6;
+--Error ER_WRONG_VALUE_FOR_VAR
+SET @@session.innodb_support_xa = "T";
+--Error ER_WRONG_VALUE_FOR_VAR
+SET @@session.innodb_support_xa = "Y";
+--Error ER_WRONG_VALUE_FOR_VAR
+SET @@session.innodb_support_xa = TRÜE;
+--Error ER_WRONG_VALUE_FOR_VAR
+SET @@session.innodb_support_xa = ÕN;
+
+SET @@session.innodb_support_xa = OFF;
+SELECT @@session.innodb_support_xa;
+
+--Error ER_WRONG_VALUE_FOR_VAR
+SET @@session.innodb_support_xa = ÓFF;
+
+# for global
+
+
+--Error ER_WRONG_VALUE_FOR_VAR
+SET @@global.innodb_support_xa = -1;
+SELECT @@global.innodb_support_xa;
+
+--Error ER_WRONG_VALUE_FOR_VAR
+SET @@global.innodb_support_xa = 2;
+--Error ER_WRONG_VALUE_FOR_VAR
+SET @@global.innodb_support_xa = "T";
+--Error ER_WRONG_VALUE_FOR_VAR
+SET @@global.innodb_support_xa = "Y";
+--Error ER_WRONG_VALUE_FOR_VAR
+SET @@global.innodb_support_xa = TRÜE;
+--Error ER_WRONG_VALUE_FOR_VAR
+SET @@global.innodb_support_xa = ÕN;
+
+SET @@global.innodb_support_xa = OFF;
+SELECT @@global.innodb_support_xa;
+
+--Error ER_WRONG_VALUE_FOR_VAR
+SET @@global.innodb_support_xa = ÓFF;
+
+
+--echo '#-------------------FN_DYNVARS_046_05----------------------------#'
+###########################################################################
+# Test if changing global variable effects session and vice versa #
+###########################################################################
+
+SET @@global.innodb_support_xa = 0;
+SET @@session.innodb_support_xa = 1;
+SELECT @@global.innodb_support_xa AS res_is_0;
+
+SET @@global.innodb_support_xa = 0;
+SELECT @@session.innodb_support_xa AS res_is_1;
+
+--echo '#----------------------FN_DYNVARS_046_06------------------------#'
+#########################################################################
+# Check if the value in GLOBAL Table matches value in variable #
+#########################################################################
+
+--disable_warnings
+SELECT IF(@@global.innodb_support_xa, "ON", "OFF") =
+ VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
+ WHERE VARIABLE_NAME='innodb_support_xa';
+--enable_warnings
+SELECT @@global.innodb_support_xa;
+--disable_warnings
+SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
+ WHERE VARIABLE_NAME='innodb_support_xa';
+--enable_warnings
+
+
+--echo '#----------------------FN_DYNVARS_046_07------------------------#'
+#########################################################################
+# Check if the value in SESSION Table matches value in variable #
+#########################################################################
+
+--disable_warnings
+SELECT IF(@@session.innodb_support_xa, "ON", "OFF") =
+ VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_VARIABLES
+ WHERE VARIABLE_NAME='innodb_support_xa';
+--enable_warnings
+SELECT @@session.innodb_support_xa;
+--disable_warnings
+SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_VARIABLES
+ WHERE VARIABLE_NAME='innodb_support_xa';
+--enable_warnings
+
+
+--echo '#---------------------FN_DYNVARS_046_08-------------------------#'
+###################################################################
+# Check if ON and OFF values can be used on variable #
+###################################################################
+
+SET @@session.innodb_support_xa = OFF;
+SELECT @@session.innodb_support_xa;
+SET @@session.innodb_support_xa = ON;
+SELECT @@session.innodb_support_xa;
+
+SET @@global.innodb_support_xa = OFF;
+SELECT @@global.innodb_support_xa;
+SET @@global.innodb_support_xa = ON;
+SELECT @@global.innodb_support_xa;
+
+--echo '#---------------------FN_DYNVARS_046_09----------------------#'
+###################################################################
+# Check if TRUE and FALSE values can be used on variable #
+###################################################################
+
+SET @@session.innodb_support_xa = TRUE;
+SELECT @@session.innodb_support_xa;
+SET @@session.innodb_support_xa = FALSE;
+SELECT @@session.innodb_support_xa;
+
+SET @@global.innodb_support_xa = TRUE;
+SELECT @@global.innodb_support_xa;
+SET @@global.innodb_support_xa = FALSE;
+SELECT @@global.innodb_support_xa;
+
+##############################
+# Restore initial value #
+##############################
+
+SET @@session.innodb_support_xa = @session_start_value;
+SELECT @@session.innodb_support_xa;
+
+SET @@global.innodb_support_xa = @global_start_value;
+SELECT @@global.innodb_support_xa;
+
+###############################################################
+# END OF innodb_support_xa TESTS #
+###############################################################
diff --git a/mysql-test/suite/sys_vars/t/innodb_table_locks_basic.test b/mysql-test/suite/sys_vars/t/innodb_table_locks_basic.test
index e3e4bda345e..25be5daa552 100644
--- a/mysql-test/suite/sys_vars/t/innodb_table_locks_basic.test
+++ b/mysql-test/suite/sys_vars/t/innodb_table_locks_basic.test
@@ -119,7 +119,7 @@ SET @@session.innodb_table_locks = TRÜE;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@session.innodb_table_locks = ÕN;
-SET @@session.innodb_table_locks = OF;
+SET @@session.innodb_table_locks = OFF;
SELECT @@session.innodb_table_locks;
--Error ER_WRONG_VALUE_FOR_VAR
@@ -141,7 +141,7 @@ SET @@global.innodb_table_locks = TRÜE;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@global.innodb_table_locks = QN;
-SET @@global.innodb_table_locks = OF;
+SET @@global.innodb_table_locks = OFF;
SELECT @@global.innodb_table_locks;
--Error ER_WRONG_TYPE_FOR_VAR
diff --git a/mysql-test/suite/sys_vars/t/keep_files_on_create_basic.test b/mysql-test/suite/sys_vars/t/keep_files_on_create_basic.test
index e6141af4bbe..cfa50e72146 100644
--- a/mysql-test/suite/sys_vars/t/keep_files_on_create_basic.test
+++ b/mysql-test/suite/sys_vars/t/keep_files_on_create_basic.test
@@ -132,7 +132,7 @@ SET @@session.keep_files_on_create = ONN;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@session.keep_files_on_create = ONF;
--Error ER_WRONG_VALUE_FOR_VAR
-SET @@session.keep_files_on_create = OF;
+SET @@session.keep_files_on_create = OFFF;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@session.keep_files_on_create = 'OFN';
--Error ER_WRONG_VALUE_FOR_VAR
diff --git a/mysql-test/suite/sys_vars/t/log_bin_trust_function_creators_basic.test b/mysql-test/suite/sys_vars/t/log_bin_trust_function_creators_basic.test
index 15ffad2742a..1db6bf41e6f 100644
--- a/mysql-test/suite/sys_vars/t/log_bin_trust_function_creators_basic.test
+++ b/mysql-test/suite/sys_vars/t/log_bin_trust_function_creators_basic.test
@@ -96,7 +96,7 @@ SET @@global.log_bin_trust_function_creators = 'ONN';
--Error ER_WRONG_VALUE_FOR_VAR
SET @@global.log_bin_trust_function_creators = "OFFF";
--Error ER_WRONG_VALUE_FOR_VAR
-SET @@global.log_bin_trust_function_creators = OF;
+SET @@global.log_bin_trust_function_creators = OFFF;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@global.log_bin_trust_function_creators = TTRUE;
--Error ER_WRONG_VALUE_FOR_VAR
diff --git a/mysql-test/suite/sys_vars/t/low_priority_updates_basic.test b/mysql-test/suite/sys_vars/t/low_priority_updates_basic.test
index e00688ef974..703036b8e36 100644
--- a/mysql-test/suite/sys_vars/t/low_priority_updates_basic.test
+++ b/mysql-test/suite/sys_vars/t/low_priority_updates_basic.test
@@ -132,7 +132,7 @@ SET @@session.low_priority_updates = ONN;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@session.low_priority_updates = ONF;
--Error ER_WRONG_VALUE_FOR_VAR
-SET @@session.low_priority_updates = OF;
+SET @@session.low_priority_updates = OFFF;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@session.low_priority_updates = 'OFN';
--Error ER_WRONG_VALUE_FOR_VAR
diff --git a/mysql-test/suite/sys_vars/t/old_passwords_basic.test b/mysql-test/suite/sys_vars/t/old_passwords_basic.test
index f4965ad7528..038a77edf8f 100644
--- a/mysql-test/suite/sys_vars/t/old_passwords_basic.test
+++ b/mysql-test/suite/sys_vars/t/old_passwords_basic.test
@@ -131,7 +131,7 @@ SET @@session.old_passwords = ONN;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@session.old_passwords = ONF;
--Error ER_WRONG_VALUE_FOR_VAR
-SET @@session.old_passwords = OF;
+SET @@session.old_passwords = OFFF;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@session.old_passwords = 'OFN';
--Error ER_WRONG_VALUE_FOR_VAR
diff --git a/mysql-test/suite/sys_vars/t/optimizer_prune_level_basic.test b/mysql-test/suite/sys_vars/t/optimizer_prune_level_basic.test
index 1e3a8bc3d7f..374be2db6ae 100644
--- a/mysql-test/suite/sys_vars/t/optimizer_prune_level_basic.test
+++ b/mysql-test/suite/sys_vars/t/optimizer_prune_level_basic.test
@@ -140,7 +140,7 @@ SET @@session.optimizer_prune_level = ONF;
--Error ER_WRONG_TYPE_FOR_VAR
SET @@session.optimizer_prune_level = ON;
--Error ER_WRONG_TYPE_FOR_VAR
-SET @@session.optimizer_prune_level = OF;
+SET @@session.optimizer_prune_level = OFFF;
--Error ER_WRONG_TYPE_FOR_VAR
SET @@session.optimizer_prune_level = 'OFN';
diff --git a/mysql-test/suite/sys_vars/t/pseudo_slave_mode_basic.test b/mysql-test/suite/sys_vars/t/pseudo_slave_mode_basic.test
index 3ef39bb8667..6d1dca299c6 100644
--- a/mysql-test/suite/sys_vars/t/pseudo_slave_mode_basic.test
+++ b/mysql-test/suite/sys_vars/t/pseudo_slave_mode_basic.test
@@ -97,7 +97,7 @@ SET @@session.pseudo_slave_mode = TRÜE;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@session.pseudo_slave_mode = ÕN;
--Error ER_WRONG_VALUE_FOR_VAR
-SET @@session.pseudo_slave_mode = OF;
+SET @@session.pseudo_slave_mode = OFFF;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@session.pseudo_slave_mode = ÓFF;
--Error ER_WRONG_VALUE_FOR_VAR
diff --git a/mysql-test/suite/sys_vars/t/query_cache_wlock_invalidate_basic.test b/mysql-test/suite/sys_vars/t/query_cache_wlock_invalidate_basic.test
index 055c3629d15..c883d9b789a 100644
--- a/mysql-test/suite/sys_vars/t/query_cache_wlock_invalidate_basic.test
+++ b/mysql-test/suite/sys_vars/t/query_cache_wlock_invalidate_basic.test
@@ -116,7 +116,7 @@ SET @@session.query_cache_wlock_invalidate = TRÜE;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@session.query_cache_wlock_invalidate = ÕN;
--Error ER_WRONG_VALUE_FOR_VAR
-SET @@session.query_cache_wlock_invalidate = OF;
+SET @@session.query_cache_wlock_invalidate = OFFF;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@session.query_cache_wlock_invalidate = ÓFF;
@@ -135,7 +135,7 @@ SET @@global.query_cache_wlock_invalidate = TRÜE;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@global.query_cache_wlock_invalidate = ÕN;
--Error ER_WRONG_VALUE_FOR_VAR
-SET @@global.query_cache_wlock_invalidate = OF;
+SET @@global.query_cache_wlock_invalidate = OFFF;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@global.query_cache_wlock_invalidate = ÓFF;
diff --git a/mysql-test/suite/sys_vars/t/sql_big_selects_basic.test b/mysql-test/suite/sys_vars/t/sql_big_selects_basic.test
index 42331d766be..52345b71144 100644
--- a/mysql-test/suite/sys_vars/t/sql_big_selects_basic.test
+++ b/mysql-test/suite/sys_vars/t/sql_big_selects_basic.test
@@ -94,7 +94,7 @@ SET @@session.sql_big_selects = TRÜE;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@session.sql_big_selects = ÕN;
--Error ER_WRONG_VALUE_FOR_VAR
-SET @@session.sql_big_selects = OF;
+SET @@session.sql_big_selects = OFFF;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@session.sql_big_selects = ÓFF;
--Error ER_WRONG_VALUE_FOR_VAR
diff --git a/mysql-test/suite/sys_vars/t/sql_buffer_result_basic.test b/mysql-test/suite/sys_vars/t/sql_buffer_result_basic.test
index f5f99efeb0a..2475bd9cd8a 100644
--- a/mysql-test/suite/sys_vars/t/sql_buffer_result_basic.test
+++ b/mysql-test/suite/sys_vars/t/sql_buffer_result_basic.test
@@ -100,7 +100,7 @@ SET @@session.sql_buffer_result = TRÜE;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@session.sql_buffer_result = ÕN;
--Error ER_WRONG_VALUE_FOR_VAR
-SET @@session.sql_buffer_result = OF;
+SET @@session.sql_buffer_result = OFFF;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@session.sql_buffer_result = ÓFF;
--Error ER_WRONG_VALUE_FOR_VAR
diff --git a/mysql-test/suite/sys_vars/t/sql_log_bin_basic.test b/mysql-test/suite/sys_vars/t/sql_log_bin_basic.test
index 5f5e3920862..7e133200d5f 100644
--- a/mysql-test/suite/sys_vars/t/sql_log_bin_basic.test
+++ b/mysql-test/suite/sys_vars/t/sql_log_bin_basic.test
@@ -98,7 +98,7 @@ SET @@session.sql_log_bin = TRÜE;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@session.sql_log_bin = ÕN;
--Error ER_WRONG_VALUE_FOR_VAR
-SET @@session.sql_log_bin = OF;
+SET @@session.sql_log_bin = OFFF;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@session.sql_log_bin = ÓFF;
--Error ER_WRONG_VALUE_FOR_VAR
diff --git a/mysql-test/suite/sys_vars/t/sql_log_off_basic.test b/mysql-test/suite/sys_vars/t/sql_log_off_basic.test
index 38549ac35d2..a48d3bbfda6 100644
--- a/mysql-test/suite/sys_vars/t/sql_log_off_basic.test
+++ b/mysql-test/suite/sys_vars/t/sql_log_off_basic.test
@@ -97,7 +97,7 @@ SET @@session.sql_log_off = TRÜE;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@session.sql_log_off = ÕN;
--Error ER_WRONG_VALUE_FOR_VAR
-SET @@session.sql_log_off = OF;
+SET @@session.sql_log_off = OFFF;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@session.sql_log_off = ÓFF;
--Error ER_WRONG_VALUE_FOR_VAR
diff --git a/mysql-test/suite/sys_vars/t/sql_notes_basic.test b/mysql-test/suite/sys_vars/t/sql_notes_basic.test
index 9af5fa35ea2..204ebe3fe84 100644
--- a/mysql-test/suite/sys_vars/t/sql_notes_basic.test
+++ b/mysql-test/suite/sys_vars/t/sql_notes_basic.test
@@ -99,7 +99,7 @@ SET @@session.sql_notes = TRÜE;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@session.sql_notes = ÕN;
--Error ER_WRONG_VALUE_FOR_VAR
-SET @@session.sql_notes = OF;
+SET @@session.sql_notes = OFFF;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@session.sql_notes = ÓFF;
--Error ER_WRONG_VALUE_FOR_VAR
diff --git a/mysql-test/suite/sys_vars/t/sql_quote_show_create_basic.test b/mysql-test/suite/sys_vars/t/sql_quote_show_create_basic.test
index 020b5f51e9f..8e8118b998b 100644
--- a/mysql-test/suite/sys_vars/t/sql_quote_show_create_basic.test
+++ b/mysql-test/suite/sys_vars/t/sql_quote_show_create_basic.test
@@ -98,7 +98,7 @@ SET @@session.sql_quote_show_create = TRÜE;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@session.sql_quote_show_create = ÕN;
--Error ER_WRONG_VALUE_FOR_VAR
-SET @@session.sql_quote_show_create = OF;
+SET @@session.sql_quote_show_create = OFFF;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@session.sql_quote_show_create = ÓFF;
--Error ER_WRONG_VALUE_FOR_VAR
diff --git a/mysql-test/suite/sys_vars/t/sql_safe_updates_basic.test b/mysql-test/suite/sys_vars/t/sql_safe_updates_basic.test
index 66148b65aaf..89208cae0ef 100644
--- a/mysql-test/suite/sys_vars/t/sql_safe_updates_basic.test
+++ b/mysql-test/suite/sys_vars/t/sql_safe_updates_basic.test
@@ -97,7 +97,7 @@ SET @@session.sql_safe_updates = TRÜE;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@session.sql_safe_updates = ÕN;
--Error ER_WRONG_VALUE_FOR_VAR
-SET @@session.sql_safe_updates = OF;
+SET @@session.sql_safe_updates = OFFF;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@session.sql_safe_updates = ÓFF;
--Error ER_WRONG_VALUE_FOR_VAR
diff --git a/mysql-test/suite/sys_vars/t/sql_warnings_basic.test b/mysql-test/suite/sys_vars/t/sql_warnings_basic.test
index ced58f96e15..f32b6f33f89 100644
--- a/mysql-test/suite/sys_vars/t/sql_warnings_basic.test
+++ b/mysql-test/suite/sys_vars/t/sql_warnings_basic.test
@@ -98,7 +98,7 @@ SET @@session.sql_warnings = TRÜE;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@session.sql_warnings = ÕN;
--Error ER_WRONG_VALUE_FOR_VAR
-SET @@session.sql_warnings = OF;
+SET @@session.sql_warnings = OFFF;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@session.sql_warnings = ÓFF;
--Error ER_WRONG_VALUE_FOR_VAR
diff --git a/mysql-test/suite/sys_vars/t/tx_read_only_basic.test b/mysql-test/suite/sys_vars/t/tx_read_only_basic.test
index 0ebfcc31a89..8c6ab0e3d59 100644
--- a/mysql-test/suite/sys_vars/t/tx_read_only_basic.test
+++ b/mysql-test/suite/sys_vars/t/tx_read_only_basic.test
@@ -116,7 +116,7 @@ SET @@session.tx_read_only = ONN;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@session.tx_read_only = ONF;
--Error ER_WRONG_VALUE_FOR_VAR
-SET @@session.tx_read_only = OF;
+SET @@session.tx_read_only = OFFF;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@session.tx_read_only = 'OFN';
--Error ER_WRONG_VALUE_FOR_VAR
diff --git a/mysql-test/t/auto_increment.test b/mysql-test/t/auto_increment.test
index 7f0ab5dc169..dca4b026c80 100644
--- a/mysql-test/t/auto_increment.test
+++ b/mysql-test/t/auto_increment.test
@@ -397,3 +397,37 @@ insert into t1 values(null);
select last_insert_id();
select * from t1;
drop table t1;
+
+--echo #
+--echo # System Versioning Support
+--echo #
+--echo #
+CREATE TABLE t1(id INT UNSIGNED AUTO_INCREMENT, x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end), PRIMARY KEY (id)) WITH SYSTEM VERSIONING;
+CREATE TABLE T1(id INT UNSIGNED AUTO_INCREMENT, x INT UNSIGNED, y INT UNSIGNED, PRIMARY KEY (id));
+INSERT INTO t1(x, y) VALUES(1, 11);
+INSERT INTO T1(x, y) VALUES(1, 11);
+INSERT INTO t1(x, y) VALUES(2, 12);
+INSERT INTO T1(x, y) VALUES(2, 12);
+INSERT INTO t1(x, y) VALUES(3, 13);
+INSERT INTO T1(x, y) VALUES(3, 13);
+INSERT INTO t1(x, y) VALUES(4, 14);
+INSERT INTO T1(x, y) VALUES(4, 14);
+INSERT INTO t1(x, y) VALUES(5, 15);
+INSERT INTO T1(x, y) VALUES(5, 15);
+INSERT INTO t1(x, y) VALUES(6, 16);
+INSERT INTO T1(x, y) VALUES(6, 16);
+INSERT INTO t1(x, y) VALUES(7, 17);
+INSERT INTO T1(x, y) VALUES(7, 17);
+INSERT INTO t1(x, y) VALUES(8, 18);
+INSERT INTO T1(x, y) VALUES(8, 18);
+INSERT INTO t1(x, y) VALUES(9, 19);
+INSERT INTO T1(x, y) VALUES(9, 19);
+SELECT t1.x = T1.x AND t1.y = T1.y, t1.x, t1.y, T1.x, T1.y FROM t1 INNER JOIN T1 ON(t1.id = T1.id);
+DELETE FROM t1 WHERE x=2;
+DELETE FROM T1 WHERE x=2;
+SELECT t1.x = T1.x AND t1.y = T1.y, t1.x, t1.y, T1.x, T1.y FROM t1 INNER JOIN T1 ON(t1.id = T1.id);
+DELETE FROM t1 WHERE x>7;
+DELETE FROM T1 WHERE x>7;
+SELECT t1.x = T1.x AND t1.y = T1.y, t1.x, t1.y, T1.x, T1.y FROM t1 INNER JOIN T1 ON(t1.id = T1.id);
+DROP TABLE t1;
+DROP TABLE T1;
diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test
index 6461204f06e..5e5c5008d8e 100644
--- a/mysql-test/t/create.test
+++ b/mysql-test/t/create.test
@@ -1781,3 +1781,101 @@ create table t1;
#
create table t1 (i int, j int, key(i), key(i)) as select 1 as i, 2 as j;
drop table t1;
+
+#
+# Create table SYSTEM VERSIONING
+#
+--echo #
+--echo # Test for SYSTEM VERSIONING CREATE
+--echo #
+
+create table t1 (
+ XNo INT UNSIGNED,
+ Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START,
+ Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END,
+ PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)
+) WITH SYSTEM VERSIONING;
+SHOW CREATE TABLE t1;
+
+drop table if exists t1;
+
+--error ER_SYS_START_MORE_THAN_ONCE
+create table t1 (
+ XNo INT UNSIGNED,
+ Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START,
+ Sys_start2 TIMESTAMP(6) GENERATED ALWAYS AS ROW START,
+ Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END,
+ PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)
+) WITH SYSTEM VERSIONING;
+
+--error ER_PERIOD_FOR_SYSTEM_TIME_CONTAINS_WRONG_END_COLUMN
+create table t1 (
+ XNo INT UNSIGNED,
+ Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START,
+ Sys_end2 TIMESTAMP(6) GENERATED ALWAYS AS ROW END,
+ PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)
+) WITH SYSTEM VERSIONING;
+
+--error ER_SYS_END_MORE_THAN_ONCE
+create table t1 (
+ XNo INT UNSIGNED,
+ Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START,
+ Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END,
+ Sys_end2 TIMESTAMP(6) GENERATED ALWAYS AS ROW END,
+ PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)
+) WITH SYSTEM VERSIONING;
+
+--error ER_SYS_START_NOT_SPECIFIED
+create table t1 (
+ XNo INT UNSIGNED,
+ PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)
+) WITH SYSTEM VERSIONING;
+
+--error ER_SYS_END_MORE_THAN_ONCE
+create table t1 (
+ XNo INT UNSIGNED,
+ Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START,
+ Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END,
+ Sys_end2 TIMESTAMP(6) GENERATED ALWAYS AS ROW END,
+ PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)
+);
+
+--error ER_PERIOD_FOR_SYSTEM_TIME_CONTAINS_WRONG_START_COLUMN
+create table t1 (
+ XNo INT UNSIGNED,
+ Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START,
+ Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END,
+ PERIOD FOR SYSTEM_TIME (Sys_insert, Sys_remove)
+) WITH SYSTEM VERSIONING;
+
+--error ER_MISSING_WITH_SYSTEM_VERSIONING
+create table t1 (
+ XNo INT UNSIGNED,
+ Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START,
+ Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END,
+ PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)
+);
+
+--error ER_SYS_START_AND_SYS_END_SAME
+create table t1 (
+ XNo INT UNSIGNED,
+ Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START,
+ Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END,
+ PERIOD FOR SYSTEM_TIME (Sys_start, Sys_start)
+);
+
+--error ER_SYS_START_FIELD_MUST_BE_TIMESTAMP
+create table t1 (
+ XNo INT UNSIGNED,
+ Sys_start INT GENERATED ALWAYS AS ROW START,
+ Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END,
+ PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)
+) WITH SYSTEM VERSIONING;
+
+--error ER_SYS_END_FIELD_MUST_BE_TIMESTAMP
+create table t1 (
+ XNo INT UNSIGNED,
+ Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START,
+ Sys_end INT GENERATED ALWAYS AS ROW END,
+ PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)
+) WITH SYSTEM VERSIONING;
diff --git a/mysql-test/t/delete.test b/mysql-test/t/delete.test
index c82420640c2..a91e6ddf82e 100644
--- a/mysql-test/t/delete.test
+++ b/mysql-test/t/delete.test
@@ -582,3 +582,47 @@ DELETE v2 FROM v2;
DROP VIEW v2, v1;
DROP TABLE t1, t2;
+
+#
+# SQL DELETE for SYSTEM VERSIONING
+#
+--echo #
+--echo # Test for SYSTEM VERSIONING
+--echo #
+
+SET @@session.time_zone='+00:00';
+
+create table t1 (
+ XNo INT UNSIGNED,
+ Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START,
+ Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END,
+ PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)
+) WITH SYSTEM VERSIONING;
+
+INSERT INTO t1(XNo) VALUES(0);
+INSERT INTO t1(XNo) VALUES(1);
+INSERT INTO t1(XNo) VALUES(2);
+INSERT INTO t1(XNo) VALUES(3);
+INSERT INTO t1(XNo) VALUES(4);
+INSERT INTO t1(XNo) VALUES(5);
+INSERT INTO t1(XNo) VALUES(6);
+INSERT INTO t1(XNo) VALUES(7);
+INSERT INTO t1(XNo) VALUES(8);
+INSERT INTO t1(XNo) VALUES(9);
+
+SELECT XNo, Sys_end < '2038-01-19 03:14:07' FROM t1 FOR SYSTEM_TIME BETWEEN TIMESTAMP '0000-0-0 0:0:0' AND TIMESTAMP '2038-01-19 04:14:07';
+DELETE FROM t1 WHERE XNo = 0;
+SELECT XNo, Sys_end < '2038-01-19 03:14:07' FROM t1 FOR SYSTEM_TIME BETWEEN TIMESTAMP '0000-0-0 0:0:0' AND TIMESTAMP '2038-01-19 04:14:07';
+DELETE FROM t1 WHERE XNo = 1;
+SELECT XNo, Sys_end < '2038-01-19 03:14:07' FROM t1 FOR SYSTEM_TIME BETWEEN TIMESTAMP '0000-0-0 0:0:0' AND TIMESTAMP '2038-01-19 04:14:07';
+DELETE FROM t1 WHERE XNo > 5;
+
+CREATE VIEW vt1 AS SELECT XNo FROM t1;
+
+SELECT XNo FROM vt1;
+DELETE FROM vt1 WHERE XNo = 3;
+SELECT XNo FROM vt1;
+SELECT XNo, Sys_end < '2038-01-19 03:14:07' FROM t1 FOR SYSTEM_TIME BETWEEN TIMESTAMP '0000-0-0 0:0:0' AND TIMESTAMP '2038-01-19 04:14:07';
+
+DROP VIEW vt1;
+DROP TABLE t1;
diff --git a/mysql-test/t/insert.test b/mysql-test/t/insert.test
index 206c5553100..7a4523a3f49 100644
--- a/mysql-test/t/insert.test
+++ b/mysql-test/t/insert.test
@@ -573,3 +573,76 @@ insert ignore into t1 values (1,12) on duplicate key update f2=13;
set @@old_mode="";
insert ignore into t1 values (1,12);
DROP TABLE t1;
+
+--echo #
+--echo # System Versioning Support
+--echo #
+--echo #
+
+-- source include/have_innodb.inc
+
+SET @@session.time_zone='+00:00';
+
+CREATE TABLE t1(x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)) WITH SYSTEM VERSIONING;
+INSERT INTO t1(x, y) VALUES(3, 4);
+INSERT INTO t1(x, y) VALUES(2, 3);
+INSERT INTO t1 VALUES(40, 33);
+SELECT x, y, Sys_end FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1(x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)) WITH SYSTEM VERSIONING ENGINE=InnoDB;
+INSERT INTO t1(x, y) VALUES(3, 4);
+INSERT INTO t1(x, y) VALUES(2, 3);
+INSERT INTO t1 VALUES(40, 33);
+SELECT x, y, Sys_end FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1(id INT UNSIGNED NOT NULL AUTO_INCREMENT, x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end), PRIMARY KEY(id)) WITH SYSTEM VERSIONING;
+INSERT INTO t1(x, y) VALUES(33, 44);
+INSERT INTO t1(id, x, y) VALUES(20, 33, 44);
+INSERT INTO t1 VALUES(40, 33, 44);
+SELECT id, x, y, Sys_end FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1(id INT UNSIGNED NOT NULL AUTO_INCREMENT, x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end), PRIMARY KEY(id)) WITH SYSTEM VERSIONING ENGINE=InnoDB;
+INSERT INTO t1(x, y) VALUES(33, 44);
+INSERT INTO t1(id, x, y) VALUES(20, 33, 44);
+INSERT INTO t1 VALUES(40, 33, 44);
+SELECT id, x, y, Sys_end FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1(x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)) WITH SYSTEM VERSIONING;
+CREATE VIEW vt1_1 AS SELECT x, y FROM t1;
+CREATE VIEW vt1_2 AS SELECT x, y, Sys_end FROM t1;
+INSERT INTO t1(x, y) VALUES(8001, 9001);
+--error ER_GENERATED_FIELD_CANNOT_BE_SET_BY_USER
+INSERT INTO t1(x, y, Sys_end) VALUES(8001, 9001, '2015-1-1 0:0:0');
+INSERT INTO vt1_1(x, y) VALUES(1001, 2001);
+INSERT INTO vt1_1 VALUES(1002, 2002);
+INSERT INTO vt1_2(x, y) VALUES(3001, 4001);
+--error ER_GENERATED_FIELD_CANNOT_BE_SET_BY_USER
+INSERT INTO vt1_2 VALUES(3002, 4002, '2015-1-1 0:0:0');
+SELECT x, y, Sys_end FROM t1;
+SELECT x, y FROM vt1_1;
+SELECT x, y, Sys_end FROM vt1_2;
+DROP TABLE t1;
+DROP VIEW vt1_1;
+DROP VIEW vt1_2;
+
+CREATE TABLE t1(x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)) WITH SYSTEM VERSIONING ENGINE=InnoDB;
+CREATE VIEW vt1_1 AS SELECT x, y FROM t1;
+CREATE VIEW vt1_2 AS SELECT x, y, Sys_end FROM t1;
+INSERT INTO t1(x, y) VALUES(8001, 9001);
+--error ER_GENERATED_FIELD_CANNOT_BE_SET_BY_USER
+INSERT INTO t1(x, y, Sys_end) VALUES(8001, 9001, '2015-1-1 0:0:0');
+INSERT INTO vt1_1(x, y) VALUES(1001, 2001);
+INSERT INTO vt1_1 VALUES(1002, 2002);
+INSERT INTO vt1_2(x, y) VALUES(3001, 4001);
+--error ER_GENERATED_FIELD_CANNOT_BE_SET_BY_USER
+INSERT INTO vt1_2 VALUES(3002, 4002, '2015-1-1 0:0:0');
+SELECT x, y, Sys_end FROM t1;
+SELECT x, y FROM vt1_1;
+SELECT x, y, Sys_end FROM vt1_2;
+DROP TABLE t1;
+DROP VIEW vt1_1;
+DROP VIEW vt1_2;
diff --git a/mysql-test/t/insert_select.test b/mysql-test/t/insert_select.test
index fda89f18d99..11dca894117 100644
--- a/mysql-test/t/insert_select.test
+++ b/mysql-test/t/insert_select.test
@@ -425,3 +425,68 @@ SET GLOBAL myisam_data_pointer_size = @old_myisam_data_pointer_size;
DROP TABLE t1;
--echo End of 5.1 tests
+
+--echo #
+--echo # System Versioning Support
+--echo #
+--echo #
+
+-- source include/have_innodb.inc
+
+CREATE TABLE t1(x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)) WITH SYSTEM VERSIONING ENGINE=MyISAM;
+CREATE TABLE t2(x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)) WITH SYSTEM VERSIONING ENGINE=MyISAM;
+INSERT INTO t1(x, y) VALUES
+ (1, 1000),
+ (2, 2000),
+ (3, 3000),
+ (4, 4000),
+ (5, 5000),
+ (6, 6000),
+ (7, 7000),
+ (8, 8000),
+ (9, 9000);
+DELETE FROM t1 WHERE x >= 1;
+INSERT INTO t1(x, y) VALUES
+ (1, 1001),
+ (2, 2001),
+ (3, 3001),
+ (4, 4001),
+ (5, 5001),
+ (6, 6001),
+ (7, 7001),
+ (8, 8001),
+ (9, 9001);
+INSERT INTO t2 SELECT x, y FROM t1 FOR SYSTEM_TIME BETWEEN TIMESTAMP '0000-0-0 0:0:0' AND TIMESTAMP '9999-1-1 0:0:0';
+SELECT x, y FROM t1;
+SELECT x, y FROM t2;
+DROP TABLE t1;
+DROP TABLE t2;
+
+CREATE TABLE t1(x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)) WITH SYSTEM VERSIONING ENGINE=InnoDB;
+CREATE TABLE t2(x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)) WITH SYSTEM VERSIONING ENGINE=InnoDB;
+INSERT INTO t1(x, y) VALUES
+ (1, 1000),
+ (2, 2000),
+ (3, 3000),
+ (4, 4000),
+ (5, 5000),
+ (6, 6000),
+ (7, 7000),
+ (8, 8000),
+ (9, 9000);
+DELETE FROM t1 WHERE x >= 1;
+INSERT INTO t1(x, y) VALUES
+ (1, 1001),
+ (2, 2001),
+ (3, 3001),
+ (4, 4001),
+ (5, 5001),
+ (6, 6001),
+ (7, 7001),
+ (8, 8001),
+ (9, 9001);
+INSERT INTO t2 SELECT x, y FROM t1 FOR SYSTEM_TIME BETWEEN TIMESTAMP '0000-0-0 0:0:0' AND TIMESTAMP '9999-1-1 0:0:0';
+SELECT x, y FROM t1;
+SELECT x, y FROM t2;
+DROP TABLE t1;
+DROP TABLE t2;
diff --git a/mysql-test/t/insert_update.test b/mysql-test/t/insert_update.test
index 7234973eeb8..518fea8d2a1 100644
--- a/mysql-test/t/insert_update.test
+++ b/mysql-test/t/insert_update.test
@@ -311,3 +311,48 @@ insert into t1(f1) values(1) on duplicate key update f1=1;
select @stamp2:=f2 from t1;
select if( @stamp1 = @stamp2, "correct", "wrong");
drop table t1;
+
+--echo #
+--echo # System Versioning Support
+--echo #
+--echo #
+
+-- source include/have_innodb.inc
+
+CREATE TABLE t1(x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end), PRIMARY KEY(x, y)) WITH SYSTEM VERSIONING;
+INSERT INTO t1(x, y) VALUES
+ (1, 1000),
+ (2, 2000),
+ (3, 3000),
+ (4, 4000),
+ (5, 5000),
+ (6, 6000),
+ (7, 7000),
+ (8, 8000),
+ (9, 9000);
+INSERT INTO t1(x, y) VALUES(3, 3000) ON DUPLICATE KEY UPDATE y = y+1;
+INSERT INTO t1(x, y) VALUES(4, 4000) ON DUPLICATE KEY UPDATE y = y+1;
+INSERT INTO t1(x, y) VALUES(4, 4001) ON DUPLICATE KEY UPDATE y = y+1;
+INSERT INTO t1(x, y) VALUES(4, 4444) ON DUPLICATE KEY UPDATE y = y+1;
+SELECT x, y FROM t1 FOR SYSTEM_TIME BETWEEN TIMESTAMP '0-0-0 0:0:0' AND TIMESTAMP '9999-1-1 0:0:0';
+SELECT x, y FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1(x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end), PRIMARY KEY(x, y)) WITH SYSTEM VERSIONING ENGINE=InnoDB;
+INSERT INTO t1(x, y) VALUES
+ (1, 1000),
+ (2, 2000),
+ (3, 3000),
+ (4, 4000),
+ (5, 5000),
+ (6, 6000),
+ (7, 7000),
+ (8, 8000),
+ (9, 9000);
+INSERT INTO t1(x, y) VALUES(3, 3000) ON DUPLICATE KEY UPDATE y = y+1;
+INSERT INTO t1(x, y) VALUES(4, 4000) ON DUPLICATE KEY UPDATE y = y+1;
+INSERT INTO t1(x, y) VALUES(4, 4001) ON DUPLICATE KEY UPDATE y = y+1;
+INSERT INTO t1(x, y) VALUES(4, 4444) ON DUPLICATE KEY UPDATE y = y+1;
+SELECT x, y FROM t1 FOR SYSTEM_TIME BETWEEN TIMESTAMP '0-0-0 0:0:0' AND TIMESTAMP '9999-1-1 0:0:0';
+SELECT x, y FROM t1;
+DROP TABLE t1;
diff --git a/mysql-test/t/multi_update.test b/mysql-test/t/multi_update.test
index 64e61f7c0b5..a5a9ca4943e 100644
--- a/mysql-test/t/multi_update.test
+++ b/mysql-test/t/multi_update.test
@@ -984,3 +984,119 @@ deallocate prepare stmt1;
drop view v3,v2,v1;
drop table t1,t2,t3;
--echo end of 5.5 tests
+
+
+--source include/have_xtradb.inc
+
+--echo
+--echo # Bug mdev-5970
+--echo # Bug#13256831 - ERROR 1032 (HY000): CAN'T FIND RECORD
+--echo
+
+CREATE TABLE t1 (f1 INT PRIMARY KEY, f2 INT) ENGINE=InnoDB;
+CREATE TABLE t2 (f1 INT PRIMARY KEY, f2 INT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (5, 7);
+INSERT INTO t2 VALUES (6, 97);
+
+CREATE ALGORITHM = MERGE VIEW v1 AS
+SELECT a2.f1 AS f1, a2.f2 AS f2
+FROM t1 AS a1 JOIN t2 AS a2 ON a1.f2 > a2.f1
+WITH LOCAL CHECK OPTION;
+
+SELECT * FROM v1;
+UPDATE v1 SET f1 = 1;
+SELECT * FROM v1;
+
+DROP TABLE t1, t2;
+DROP VIEW v1;
+
+--echo #
+--echo # MDEV-5973: MySQL Bug#11757486:49539: NON-DESCRIPTIVE ERR (ERROR 0
+--echo # FROM STORAGE ENGINE) WITH MULTI-TABLE UPDATE
+--echo #
+
+CREATE TABLE table_11757486 (field1 tinyint) ENGINE=INNODB;
+INSERT INTO table_11757486 VALUES (0),(0);
+SET SESSION SQL_MODE='STRICT_ALL_TABLES';
+UPDATE IGNORE (SELECT 128 as col1) x, table_11757486 SET field1=x.col1;
+UPDATE IGNORE table_11757486 SET field1=128;
+
+--error ER_WARN_DATA_OUT_OF_RANGE
+UPDATE (SELECT 128 as col1) x, table_11757486 SET field1=x.col1;
+--error ER_WARN_DATA_OUT_OF_RANGE
+UPDATE table_11757486 SET field1=128;
+
+SET SESSION SQL_MODE='';
+UPDATE IGNORE (SELECT 128 as col1) x, table_11757486 SET field1=x.col1;
+UPDATE IGNORE table_11757486 SET field1=128;
+
+DROP TABLE table_11757486;
+
+SET SESSION SQL_MODE=default;
+
+--echo end of 10.0 tests
+
+--echo #
+--echo # System Versioning Support
+--echo #
+--echo #
+
+CREATE TABLE t1(x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)) WITH SYSTEM VERSIONING;
+CREATE TABLE t2(x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)) WITH SYSTEM VERSIONING;
+INSERT INTO t1(x, y) VALUES
+ (1, 1000),
+ (2, 2000),
+ (3, 3000),
+ (4, 4000),
+ (5, 5000),
+ (6, 6000),
+ (7, 7000),
+ (8, 8000),
+ (9, 9000);
+INSERT INTO t2(x, y) VALUES
+ (1, 1010),
+ (2, 2010),
+ (3, 3010),
+ (4, 4010),
+ (5, 5010),
+ (6, 6010),
+ (7, 7010),
+ (8, 8010),
+ (9, 9010);
+UPDATE t1, t2 SET t1.y = t1.x + t1.y, t2.y = t2.x + t2.y WHERE t1.x > 7 AND t2.x < 7;
+SELECT x, y FROM t1 FOR SYSTEM_TIME BETWEEN TIMESTAMP '0-0-0 0:0:0' AND TIMESTAMP '9999-1-1 0:0:0';
+SELECT x, y FROM t1;
+SELECT x, y FROM t2 FOR SYSTEM_TIME BETWEEN TIMESTAMP '0-0-0 0:0:0' AND TIMESTAMP '9999-1-1 0:0:0';
+SELECT x, y FROM t2;
+DROP TABLE t1;
+DROP TABLE t2;
+
+CREATE TABLE t1(x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)) WITH SYSTEM VERSIONING ENGINE=InnoDB;
+CREATE TABLE t2(x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)) WITH SYSTEM VERSIONING ENGINE=InnoDB;
+INSERT INTO t1(x, y) VALUES
+ (1, 1000),
+ (2, 2000),
+ (3, 3000),
+ (4, 4000),
+ (5, 5000),
+ (6, 6000),
+ (7, 7000),
+ (8, 8000),
+ (9, 9000);
+INSERT INTO t2(x, y) VALUES
+ (1, 1010),
+ (2, 2010),
+ (3, 3010),
+ (4, 4010),
+ (5, 5010),
+ (6, 6010),
+ (7, 7010),
+ (8, 8010),
+ (9, 9010);
+UPDATE t1, t2 SET t1.y = t1.x + t1.y, t2.y = t2.x + t2.y WHERE t1.x > 7 AND t2.x < 7;
+SELECT x, y FROM t1 FOR SYSTEM_TIME BETWEEN TIMESTAMP '0-0-0 0:0:0' AND TIMESTAMP '9999-1-1 0:0:0';
+SELECT x, y FROM t1;
+SELECT x, y FROM t2 FOR SYSTEM_TIME BETWEEN TIMESTAMP '0-0-0 0:0:0' AND TIMESTAMP '9999-1-1 0:0:0';
+SELECT x, y FROM t2;
+DROP TABLE t1;
+DROP TABLE t2;
diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test
index e8d5f9fa445..3d2c689591e 100644
--- a/mysql-test/t/select.test
+++ b/mysql-test/t/select.test
@@ -25,13 +25,13 @@ if (`select @join_cache_level_for_select_test is not null`)
}
CREATE TABLE t1 (
- Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
+ Period_ smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL
);
INSERT INTO t1 VALUES (9410,9412);
-select period from t1;
+select period_ from t1;
select * from t1;
select t1.* from t1;
@@ -1361,7 +1361,7 @@ select fld1,fld3 from t2 where fld1 like "25050_";
select distinct companynr from t2;
select distinct companynr from t2 order by companynr;
select distinct companynr from t2 order by companynr desc;
-select distinct t2.fld3,period from t2,t1 where companynr=37 and fld3 like "O%";
+select distinct t2.fld3,period_ from t2,t1 where companynr=37 and fld3 like "O%";
select distinct fld3 from t2 where companynr = 34 order by fld3;
select distinct fld3 from t2 limit 10;
@@ -1374,26 +1374,26 @@ select distinct substring(fld3,1,3) as a from t2 having a like "A%" limit 10;
# make a big table.
create table t3 (
- period int not null,
+ period_ int not null,
name char(32) not null,
companynr int not null,
price double(11,0),
price2 double(11,0),
- key (period),
+ key (period_),
key (name)
);
--disable_query_log
-INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1001,"Iranizes",37,5987435,234724);
-INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1002,"violinist",37,28357832,8723648);
-INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1003,"extramarital",37,39654943,235872);
-INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1004,"spates",78,726498,72987523);
-INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1005,"cloakroom",78,98439034,823742);
-INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1006,"gazer",101,834598,27348324);
-INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1007,"hand",154,983543950,29837423);
-INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1008,"tucked",311,234298,3275892);
-INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1009,"gems",447,2374834,9872392);
-INSERT INTO t3 (period,name,companynr,price,price2) VALUES (1010,"clinker",512,786542,76234234);
+INSERT INTO t3 (period_,name,companynr,price,price2) VALUES (1001,"Iranizes",37,5987435,234724);
+INSERT INTO t3 (period_,name,companynr,price,price2) VALUES (1002,"violinist",37,28357832,8723648);
+INSERT INTO t3 (period_,name,companynr,price,price2) VALUES (1003,"extramarital",37,39654943,235872);
+INSERT INTO t3 (period_,name,companynr,price,price2) VALUES (1004,"spates",78,726498,72987523);
+INSERT INTO t3 (period_,name,companynr,price,price2) VALUES (1005,"cloakroom",78,98439034,823742);
+INSERT INTO t3 (period_,name,companynr,price,price2) VALUES (1006,"gazer",101,834598,27348324);
+INSERT INTO t3 (period_,name,companynr,price,price2) VALUES (1007,"hand",154,983543950,29837423);
+INSERT INTO t3 (period_,name,companynr,price,price2) VALUES (1008,"tucked",311,234298,3275892);
+INSERT INTO t3 (period_,name,companynr,price,price2) VALUES (1009,"gems",447,2374834,9872392);
+INSERT INTO t3 (period_,name,companynr,price,price2) VALUES (1010,"clinker",512,786542,76234234);
--enable_query_log
create temporary table tmp engine = myisam select * from t3;
@@ -1462,39 +1462,39 @@ explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2
# Some test with ORDER BY and limit
#
-explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period;
-explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10;
-explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10;
+explain select * from t3 as t1,t3 where t1.period_=t3.period_ order by t3.period_;
+explain select * from t3 as t1,t3 where t1.period_=t3.period_ order by t3.period_ limit 10;
+explain select * from t3 as t1,t3 where t1.period_=t3.period_ order by t1.period_ limit 10;
#
# Search with a constant table.
#
-select period from t1;
-select period from t1 where period=1900;
-select fld3,period from t1,t2 where fld1 = 011401 order by period;
+select period_ from t1;
+select period_ from t1 where period_=1900;
+select fld3,period_ from t1,t2 where fld1 = 011401 order by period_;
#
# Search with a constant table and several keyparts. (Rows are read only once
# in the beginning of the search)
#
-select fld3,period from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.period=1001;
+select fld3,period_ from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.period_=1001;
-explain select fld3,period from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period;
+explain select fld3,period_ from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period_;
#
# Search with a constant table and several rows from another table
#
-select fld3,period from t2,t1 where companynr*10 = 37*10;
+select fld3,period_ from t2,t1 where companynr*10 = 37*10;
#
# Search with a table reference and without a key.
# t3 will be the main table.
#
-select fld3,period,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period >= 1001 and period <= 1002 and t2.companynr = 37 order by fld3,period, price;
+select fld3,period_,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period_ >= 1001 and period_ <= 1002 and t2.companynr = 37 order by fld3,period_, price;
#
# Search with an interval on a table with full key on reference table.
@@ -1502,7 +1502,7 @@ select fld3,period,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period >= 1
# t2nr will be checked.
#
-select t2.fld1,fld3,period,price,price2 from t2,t3 where t2.fld1>= 18201 and t2.fld1 <= 18811 and t2.fld1=t3.t2nr and period = 1001 and t2.companynr = 37;
+select t2.fld1,fld3,period_,price,price2 from t2,t3 where t2.fld1>= 18201 and t2.fld1 <= 18811 and t2.fld1=t3.t2nr and period_ = 1001 and t2.companynr = 37;
#
# We need another table for join stuff..
@@ -1594,18 +1594,18 @@ explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=
# each record
#
-select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008;
+select t2.fld1,t2.companynr,fld3,period_ from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period_ = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period_ = 1008;
-select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t2.fld1 = 38208 or t2.fld1 = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009;
+select t2.fld1,t2.companynr,fld3,period_ from t3,t2 where (t2.fld1 = 38208 or t2.fld1 = 38008) and t2.fld1=t3.t2nr and period_>=1008 and period_<=1009;
-select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t3.t2nr = 38208 or t3.t2nr = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009;
+select t2.fld1,t2.companynr,fld3,period_ from t3,t2 where (t3.t2nr = 38208 or t3.t2nr = 38008) and t2.fld1=t3.t2nr and period_>=1008 and period_<=1009;
#
# Test of many parenthesis levels
#
-select period from t1 where (((period > 0) or period < 10000 or (period = 1900)) and (period=1900 and period <= 1901) or (period=1903 and (period=1903)) and period>=1902) or ((period=1904 or period=1905) or (period=1906 or period>1907)) or (period=1908 and period = 1909);
-select period from t1 where ((period > 0 and period < 1) or (((period > 0 and period < 100) and (period > 10)) or (period > 10)) or (period > 0 and (period > 5 or period > 6)));
+select period_ from t1 where (((period_ > 0) or period_ < 10000 or (period_ = 1900)) and (period_=1900 and period_ <= 1901) or (period_=1903 and (period_=1903)) and period_>=1902) or ((period_=1904 or period_=1905) or (period_=1906 or period_>1907)) or (period_=1908 and period_ = 1909);
+select period_ from t1 where ((period_ > 0 and period_ < 1) or (((period_ > 0 and period_ < 100) and (period_ > 10)) or (period_ > 10)) or (period_ > 0 and (period_ > 5 or period_ > 6)));
select a.fld1 from t2 as a,t2 b where ((a.fld1 = 250501 and a.fld1=b.fld1) or a.fld1=250502 or a.fld1=250503 or (a.fld1=250505 and a.fld1<=b.fld1 and b.fld1>=a.fld1)) and a.fld1=b.fld1;
@@ -1663,7 +1663,7 @@ select t2.fld1,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 grou
# Calculation with group functions
#
-select sum(Period)/count(*) from t1;
+select sum(Period_)/count(*) from t1;
select companynr,count(price) as "count",sum(price) as "sum" ,abs(sum(price)/count(price)-avg(price)) as "diff",(0+count(price))*companynr as func from t3 group by companynr;
select companynr,sum(price)/count(price) as avg from t3 group by companynr having avg > 70000000 order by avg;
@@ -1753,13 +1753,13 @@ select max(t2nr) from t3 where price=983543950;
# Test of alias
#
-select t1.period from t3 = t1 limit 1;
-select t1.period from t1 as t1 limit 1;
-select t1.period as "Nuvarande period" from t1 as t1 limit 1;
-select period as ok_period from t1 limit 1;
-select period as ok_period from t1 group by ok_period limit 1;
+select t1.period_ from t3 = t1 limit 1;
+select t1.period_ from t1 as t1 limit 1;
+select t1.period_ as "Nuvarande period_" from t1 as t1 limit 1;
+select period_ as ok_period from t1 limit 1;
+select period_ as ok_period from t1 group by ok_period limit 1;
select 1+1 as summa from t1 group by summa limit 1;
-select period as "Nuvarande period" from t1 group by "Nuvarande period" limit 1;
+select period_ as "Nuvarande period_" from t1 group by "Nuvarande period_" limit 1;
#
# Some simple show commands
@@ -4671,3 +4671,37 @@ select (SELECT name FROM t1 WHERE name='tom' AND pw=PASSWORD(@undefined));
drop table t1;
--echo End of 10.0 tests
+
+--echo #
+--echo # System Versioning Support
+--echo #
+--echo #
+CREATE TABLE t1( x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)) WITH SYSTEM VERSIONING;
+INSERT INTO t1(x, y) VALUES
+ (0, 100),
+ (1, 101),
+ (2, 102),
+ (3, 103),
+ (4, 104),
+ (5, 105),
+ (6, 106),
+ (7, 107),
+ (8, 108),
+ (9, 109);
+DELETE FROM t1 WHERE x = 3;
+DELETE FROM t1 WHERE x > 7;
+--real_sleep 1
+INSERT INTO t1(x, y) VALUES(3, 33);
+--replace_column 1 Sys_start
+SELECT @time := Sys_start FROM t1 FOR SYSTEM_TIME BETWEEN TIMESTAMP '0-0-0 0:0:0' AND TIMESTAMP '2038-01-19 04:14:07' WHERE x = 3 AND y = 33;
+SELECT x, y FROM t1;
+SET @query=CONCAT('SELECT x, y FROM t1 FOR SYSTEM_TIME FROM TIMESTAMP \'0-0-0 0:0:0\' TO TIMESTAMP \'', @time, '\'');
+PREPARE stmt_t1 FROM @query;
+EXECUTE stmt_t1;
+SET @query=CONCAT('SELECT x, y FROM t1 FOR SYSTEM_TIME BETWEEN TIMESTAMP \'0-0-0 0:0:0\' AND TIMESTAMP \'', @time, '\'');
+PREPARE stmt_t1 FROM @query;
+EXECUTE stmt_t1;
+SET @time=NULL;
+SET @query=NULL;
+DEALLOCATE PREPARE stmt_t1;
+DROP TABLE t1;
diff --git a/mysql-test/t/update.test b/mysql-test/t/update.test
index e5ef0b11127..5dfc623acc8 100644
--- a/mysql-test/t/update.test
+++ b/mysql-test/t/update.test
@@ -654,3 +654,42 @@ show status like 'Handler_read%';
drop table t1, t2;
--echo # End of MariaDB 10.0 tests
+
+--echo #
+--echo # System Versioning Support
+--echo #
+--echo #
+
+CREATE TABLE t1(x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)) WITH SYSTEM VERSIONING;
+INSERT INTO t1(x, y) VALUES
+ (1, 1000),
+ (2, 2000),
+ (3, 3000),
+ (4, 4000),
+ (5, 5000),
+ (6, 6000),
+ (7, 7000),
+ (8, 8000),
+ (9, 9000);
+SELECT x, y FROM t1;
+UPDATE t1 SET y = y + 1 WHERE x > 7;
+SELECT x, y FROM t1;
+SELECT x, y FROM t1 FOR SYSTEM_TIME BETWEEN TIMESTAMP '0000-0-0 0:0:0' AND TIMESTAMP '2038-01-19 04:14:07';
+DROP TABLE t1;
+
+CREATE TABLE t1(x INT UNSIGNED, y INT UNSIGNED, Sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, Sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (Sys_start, Sys_end)) WITH SYSTEM VERSIONING ENGINE=InnoDB;
+INSERT INTO t1(x, y) VALUES
+ (1, 1000),
+ (2, 2000),
+ (3, 3000),
+ (4, 4000),
+ (5, 5000),
+ (6, 6000),
+ (7, 7000),
+ (8, 8000),
+ (9, 9000);
+SELECT x, y FROM t1;
+UPDATE t1 SET y = y + 1 WHERE x > 7;
+SELECT x, y FROM t1;
+SELECT x, y FROM t1 FOR SYSTEM_TIME BETWEEN TIMESTAMP '0000-0-0 0:0:0' AND TIMESTAMP '2038-01-19 04:14:07';
+DROP TABLE t1;
diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test
index 1ba20f0ac9e..1f65956f8ad 100644
--- a/mysql-test/t/variables.test
+++ b/mysql-test/t/variables.test
@@ -1295,166 +1295,6 @@ DROP TABLE t1;
--echo End of 5.1 tests
-###########################################################################
-
---echo
---echo #
---echo # Bug#34828: OF is taken as OFF and a value of 0 is set for variable SQL_notes.
---echo #
---echo
-
---echo # Checking sql_notes...
-SET @sql_notes_saved = @@sql_notes;
-
---echo
-SET @@sql_notes = ON;
-SELECT @@sql_notes;
-
---echo
---error ER_WRONG_VALUE_FOR_VAR
-SET @@sql_notes = OF;
-SELECT @@sql_notes;
-
---echo
-SET @@sql_notes = OFF;
-SELECT @@sql_notes;
-
---echo
-SET @@sql_notes = @sql_notes_saved;
-
---echo
---echo # Checking delay_key_write...
-SET @delay_key_write_saved = @@delay_key_write;
-
---echo
-SET GLOBAL delay_key_write = ON;
-SELECT @@delay_key_write;
-
---echo
---error ER_WRONG_VALUE_FOR_VAR
-SET GLOBAL delay_key_write = OF;
-SELECT @@delay_key_write;
-
---echo
---error ER_WRONG_VALUE_FOR_VAR
-SET GLOBAL delay_key_write = AL;
-SELECT @@delay_key_write;
-
---echo
-SET GLOBAL delay_key_write = OFF;
-SELECT @@delay_key_write;
-
---echo
-SET GLOBAL delay_key_write = ALL;
-SELECT @@delay_key_write;
-
---echo
-SET GLOBAL delay_key_write = @delay_key_write_saved;
-
---echo
---echo # Checking sql_safe_updates...
-SET @sql_safe_updates_saved = @@sql_safe_updates;
-
---echo
-SET @@sql_safe_updates = ON;
-SELECT @@sql_safe_updates;
-
---echo
---error ER_WRONG_VALUE_FOR_VAR
-SET @@sql_safe_updates = OF;
-SELECT @@sql_safe_updates;
-
---echo
-SET @@sql_safe_updates = OFF;
-SELECT @@sql_safe_updates;
-
---echo
-SET @@sql_safe_updates = @sql_safe_updates_saved;
-
---echo
---echo # Checking foreign_key_checks...
-SET @foreign_key_checks_saved = @@foreign_key_checks;
-
---echo
-SET @@foreign_key_checks = ON;
-SELECT @@foreign_key_checks;
-
---echo
---error ER_WRONG_VALUE_FOR_VAR
-SET @@foreign_key_checks = OF;
-SELECT @@foreign_key_checks;
-
---echo
-SET @@foreign_key_checks = OFF;
-SELECT @@foreign_key_checks;
-
---echo
-SET @@foreign_key_checks = @foreign_key_checks_saved;
-
---echo
---echo # Checking unique_checks...
-SET @unique_checks_saved = @@unique_checks;
-
---echo
-SET @@unique_checks = ON;
-SELECT @@unique_checks;
-
---echo
---error ER_WRONG_VALUE_FOR_VAR
-SET @@unique_checks = OF;
-SELECT @@unique_checks;
-
---echo
-SET @@unique_checks = OFF;
-SELECT @@unique_checks;
-
---echo
-SET @@unique_checks = @unique_checks_saved;
-
---echo
---echo # Checking sql_buffer_result...
-SET @sql_buffer_result_saved = @@sql_buffer_result;
-
---echo
-SET @@sql_buffer_result = ON;
-SELECT @@sql_buffer_result;
-
---echo
---error ER_WRONG_VALUE_FOR_VAR
-SET @@sql_buffer_result = OF;
-SELECT @@sql_buffer_result;
-
---echo
-SET @@sql_buffer_result = OFF;
-SELECT @@sql_buffer_result;
-
---echo
-SET @@sql_buffer_result = @sql_buffer_result_saved;
-
---echo
---echo # Checking sql_quote_show_create...
-SET @sql_quote_show_create_saved = @@sql_quote_show_create;
-
---echo
-SET @@sql_quote_show_create = ON;
-SELECT @@sql_quote_show_create;
-
---echo
---error ER_WRONG_VALUE_FOR_VAR
-SET @@sql_quote_show_create = OF;
-SELECT @@sql_quote_show_create;
-
---echo
-SET @@sql_quote_show_create = OFF;
-SELECT @@sql_quote_show_create;
-
---echo
-SET @@sql_quote_show_create = @sql_quote_show_create_saved;
-
---echo
---echo # End of Bug#34828.
---echo
-
--echo # Make sure we can manipulate with autocommit in the
--echo # along with other variables.
diff --git a/sql/field.cc b/sql/field.cc
index 812c4dbb639..cb91e93ec5e 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -5423,6 +5423,22 @@ void Field_timestampf::store_TIME(my_time_t timestamp, ulong sec_part)
my_timestamp_to_binary(&tm, ptr, dec);
}
+bool Field_timestampf::set_max_timestamp()
+{
+ DBUG_ENTER("Field_timestampf::set_max_timestamp");
+
+ mi_int4store(ptr, 0x7fffffff);
+ memset(ptr + 4, 0x0, value_length() - 4);
+
+ DBUG_RETURN(FALSE);
+}
+
+bool Field_timestampf::is_max_timestamp()
+{
+ DBUG_ENTER("Field_timestampf::is_max_timestamp");
+
+ DBUG_RETURN(mi_sint4korr(ptr) == 0x7fffffff);
+}
my_time_t Field_timestampf::get_timestamp(const uchar *pos,
ulong *sec_part) const
diff --git a/sql/field.h b/sql/field.h
index 9559ba789b1..3513a773ef4 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -33,6 +33,8 @@
#include "compat56.h"
#include "sql_type.h" /* Type_std_attributes */
+#include <limits>
+
class Send_field;
class Copy_field;
class Protocol;
@@ -674,6 +676,19 @@ public:
static void operator delete(void *ptr, MEM_ROOT *mem_root)
{ DBUG_ASSERT(0); }
+ /**
+ Is used by System Versioning.
+ */
+ virtual bool set_max_timestamp() {
+ return true;
+ }
+ /**
+ Is used by System Versioning.
+ */
+ virtual bool is_max_timestamp() {
+ return false;
+ }
+
uchar *ptr; // Position to field in record
/**
Byte where the @c NULL bit is stored inside a record. If this Field is a
@@ -1392,6 +1407,56 @@ public:
}
/*
+ System versioning support.
+ */
+
+ bool is_generated()
+ {
+ return flags & (GENERATED_ROW_START_FLAG | GENERATED_ROW_END_FLAG);
+ }
+
+ bool is_generated_row_start()
+ {
+ return flags & GENERATED_ROW_START_FLAG;
+ }
+
+ bool is_generated_row_end()
+ {
+ return flags & GENERATED_ROW_END_FLAG;
+ }
+
+ bool is_versioning_disabled()
+ {
+ return flags & WITHOUT_SYSTEM_VERSIONING_FLAG;
+ }
+
+ /* Mark a field as auto-generated row start column. */
+ void set_generated_row_start()
+ {
+ //DBUG_ASSERT((flags & GENERATED_ROW_END_FLAG) == 0);
+ flags |= GENERATED_ROW_START_FLAG;
+ }
+
+ /* Mark a field as auto-generated row start column. */
+ void set_generated_row_end()
+ {
+ //DBUG_ASSERT((flags & GENERATED_ROW_START_FLAG) == 0);
+ flags |= GENERATED_ROW_END_FLAG;
+ }
+
+ /* Disable a field versioning for a versioned table. */
+ void disable_versioning()
+ {
+ flags |= WITHOUT_SYSTEM_VERSIONING_FLAG;
+ }
+
+ /* Inherit a field versioning status from the table. */
+ void inherit_versioning()
+ {
+ flags &= ~WITHOUT_SYSTEM_VERSIONING_FLAG;
+ }
+
+ /*
Validate a non-null field value stored in the given record
according to the current thread settings, e.g. sql_mode.
@param thd - the thread
@@ -2517,6 +2582,8 @@ public:
{
return memcmp(a_ptr, b_ptr, pack_length());
}
+ virtual bool set_max_timestamp();
+ virtual bool is_max_timestamp();
void store_TIME(my_time_t timestamp, ulong sec_part);
my_time_t get_timestamp(const uchar *pos, ulong *sec_part) const;
uint size_of() const { return sizeof(*this); }
diff --git a/sql/handler.h b/sql/handler.h
index e6615695ce7..2b911cd94c5 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -1660,6 +1660,36 @@ struct Schema_specification_st
};
+struct System_versioning_info
+{
+ struct
+ {
+ String *start, *end;
+ } period_for_system_time;
+
+ struct
+ {
+ String *start;
+ String *end;
+ } generated_as_row;
+
+ void set_period_for_system_time(String *start, String *end)
+ {
+ period_for_system_time.start = start;
+ period_for_system_time.end = end;
+ }
+ void set_period_for_system_time()
+ {
+ set_period_for_system_time(NULL, NULL);
+ }
+
+ /** User has added 'WITH SYSTEM VERSIONING' to table definition */
+ bool declared_system_versioning;
+
+ /** Table described by this structure have enabled system versioning */
+ bool versioned;
+};
+
/**
A helper struct for table DDL statements, e.g.:
CREATE [OR REPLACE] [TEMPORARY]
@@ -1734,6 +1764,8 @@ struct Table_scope_and_contents_source_st
bool table_was_deleted;
sequence_definition *seq_create_info;
+ System_versioning_info system_versioning_info;
+
void init()
{
bzero(this, sizeof(*this));
@@ -1744,6 +1776,17 @@ struct Table_scope_and_contents_source_st
db_type= tmp_table() ? ha_default_tmp_handlerton(thd)
: ha_default_handlerton(thd);
}
+
+ bool versioned()
+ {
+ return system_versioning_info.versioned;
+ }
+ const System_versioning_info *get_system_versioning_info()
+ {
+ if (!versioned())
+ return NULL;
+ return &system_versioning_info;
+ }
};
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index 174f8ffb9fa..a1a9ca5c8ae 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -1702,6 +1702,15 @@ void Item_func_curtime_utc::store_now_in_TIME(THD *thd, MYSQL_TIME *now_time)
*/
}
+
+Item_func_now::Item_func_now(THD *thd, uint dec) :
+ Item_datetimefunc(thd, new (thd->mem_root) Item_decimal(thd, dec, TRUE)),
+ last_query_id(0)
+{
+ decimals = dec;
+}
+
+
bool Item_func_now::fix_fields(THD *thd, Item **items)
{
if (decimals > TIME_SECOND_PART_DIGITS)
diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h
index 6ee565236c3..f1a719fb775 100644
--- a/sql/item_timefunc.h
+++ b/sql/item_timefunc.h
@@ -718,8 +718,7 @@ class Item_func_now :public Item_datetimefunc
MYSQL_TIME ltime;
query_id_t last_query_id;
public:
- Item_func_now(THD *thd, uint dec): Item_datetimefunc(thd), last_query_id(0)
- { decimals= dec; }
+ Item_func_now(THD *thd, uint dec);
bool fix_fields(THD *, Item **);
bool get_date(MYSQL_TIME *res, ulonglong fuzzy_date);
virtual void store_now_in_TIME(THD *thd, MYSQL_TIME *now_time)=0;
diff --git a/sql/lex.h b/sql/lex.h
index bb6ab1ca34d..da5a288be99 100644
--- a/sql/lex.h
+++ b/sql/lex.h
@@ -458,6 +458,7 @@ static SYMBOL symbols[] = {
{ "PAGE_CHECKSUM", SYM(PAGE_CHECKSUM_SYM)},
{ "PARSER", SYM(PARSER_SYM)},
{ "PARSE_VCOL_EXPR", SYM(PARSE_VCOL_EXPR_SYM)},
+ { "PERIOD", SYM(PERIOD_SYM)},
{ "PARTIAL", SYM(PARTIAL)},
{ "PARTITION", SYM(PARTITION_SYM)},
{ "PARTITIONING", SYM(PARTITIONING_SYM)},
@@ -625,6 +626,8 @@ static SYMBOL symbols[] = {
{ "SUSPEND", SYM(SUSPEND_SYM)},
{ "SWAPS", SYM(SWAPS_SYM)},
{ "SWITCHES", SYM(SWITCHES_SYM)},
+ { "SYSTEM", SYM(SYSTEM)},
+ { "SYSTEM_TIME", SYM(SYSTEM_TIME_SYM)},
{ "TABLE", SYM(TABLE_SYM)},
{ "TABLE_NAME", SYM(TABLE_NAME_SYM)},
{ "TABLES", SYM(TABLES)},
@@ -690,6 +693,7 @@ static SYMBOL symbols[] = {
{ "VIA", SYM(VIA_SYM)},
{ "VIEW", SYM(VIEW_SYM)},
{ "VIRTUAL", SYM(VIRTUAL_SYM)},
+ { "VERSIONING", SYM(VERSIONING)},
{ "WAIT", SYM(WAIT_SYM)},
{ "WARNINGS", SYM(WARNINGS)},
{ "WEEK", SYM(WEEK_SYM)},
diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt
index 562d0acdd19..380d992a89b 100644
--- a/sql/share/errmsg-utf8.txt
+++ b/sql/share/errmsg-utf8.txt
@@ -7484,3 +7484,50 @@ ER_UNKNOWN_SEQUENCES 42S02
eng "Unknown SEQUENCE: '%-.300s'"
ER_UNKNOWN_VIEW 42S02
eng "Unknown VIEW: '%-.300s'"
+
+# MariaDB error numbers related to System Versioning
+
+ER_SYS_START_NOT_SPECIFIED
+ eng "'Generated as row start' not specified"
+
+ER_SYS_END_NOT_SPECIFIED
+ eng "'Generated as row end' not specified"
+
+ER_SYS_START_MORE_THAN_ONCE
+ eng "'Generated as row start' specified more than once"
+
+ER_SYS_END_MORE_THAN_ONCE
+ eng "Generated as row end specified more than once"
+
+ER_MISSING_PERIOD_FOR_SYSTEM_TIME
+ eng "'Period for system time' is missing"
+
+ER_TABLE_DOESNT_SUPPORT_SYSTEM_VERSIONING
+ eng "Table '%s' doesn't support system versioning"
+
+ER_MISSING_WITH_SYSTEM_VERSIONING
+ eng "'With system versioning' is missing"
+
+ER_PERIOD_FOR_SYSTEM_TIME_CONTAINS_WRONG_START_COLUMN
+ eng "First column in 'period for system time' must be equal to 'generated as row start' column"
+
+ER_PERIOD_FOR_SYSTEM_TIME_CONTAINS_WRONG_END_COLUMN
+ eng "Second column in 'period for system time' must be equal to 'generated as row end' column"
+
+ER_SYS_START_AND_SYS_END_SAME
+ eng "'Period for system_time' must contain two different columns"
+
+ER_GENERATED_FIELD_CANNOT_BE_SET_BY_USER
+ eng "Generated field for System Versioning cannot be set by user"
+
+ER_FOREIGN_KEY_ON_SYSTEM_VERSIONED
+ eng "Foreign key clause is not yet supported in conjunction with system versioning"
+
+ER_UPDATE_INFO_WITH_SYSTEM_VERSIONING
+ eng "Rows matched: %ld Changed: %ld Inserted: %ld Warnings: %ld"
+
+ER_SYS_START_FIELD_MUST_BE_TIMESTAMP
+ eng "System start field must be of type TIMESTAMP"
+
+ER_SYS_END_FIELD_MUST_BE_TIMESTAMP
+ eng "System end field must be of type TIMESTAMP"
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 5f9c6ceabc7..1af45c12331 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -7071,7 +7071,7 @@ bool setup_fields(THD *thd, Ref_ptr_array ref_pointer_array,
thd->lex->current_select->is_item_list_lookup= 0;
/*
- To prevent fail on forward lookup we fill it with zerows,
+ To prevent fail on forward lookup we fill it with zeroes,
then if we got pointer on zero after find_item_in_list we will know
that it is forward lookup.
@@ -7962,6 +7962,13 @@ fill_record(THD *thd, TABLE *table_arg, List<Item> &fields, List<Item> &values,
ER_THD(thd, ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN),
rfield->field_name, table->s->table_name.str);
}
+ if (table->versioned() && rfield->is_generated() &&
+ !ignore_errors)
+ {
+ my_error(ER_GENERATED_FIELD_CANNOT_BE_SET_BY_USER, MYF(0));
+ goto err;
+ }
+
if (rfield->stored_in_db() &&
(value->save_in_field(rfield, 0)) < 0 && !ignore_errors)
{
@@ -8002,7 +8009,7 @@ void switch_to_nullable_trigger_fields(List<Item> &items, TABLE *table)
Field** field= table->field_to_fill();
/* True if we have NOT NULL fields and BEFORE triggers */
- if (field != table->field)
+ if (field != table->field && field != table->non_generated_field)
{
List_iterator_fast<Item> it(items);
Item *item;
@@ -8209,6 +8216,13 @@ fill_record(THD *thd, TABLE *table, Field **ptr, List<Item> &values,
}
}
+ if (table->versioned() && field->is_generated() &&
+ !ignore_errors)
+ {
+ my_error(ER_GENERATED_FIELD_CANNOT_BE_SET_BY_USER, MYF(0));
+ goto err;
+ }
+
if (use_value)
value->save_val(field);
else
@@ -8460,7 +8474,6 @@ int init_ftfuncs(THD *thd, SELECT_LEX *select_lex, bool no_order)
{
List_iterator<Item_func_match> li(*(select_lex->ftfunc_list));
Item_func_match *ifm;
- DBUG_PRINT("info",("Performing FULLTEXT search"));
while ((ifm=li++))
ifm->init_search(thd, no_order);
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 62974bb021e..82d538b07fd 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -3906,7 +3906,12 @@ public:
Lex_input_stream *lip= &m_parser_state->m_lip;
if (!yytext)
{
- if (!(yytext= lip->get_tok_start()))
+ if (lip->lookahead_token >= 0)
+ yytext= lip->get_tok_start_prev();
+ else
+ yytext= lip->get_tok_start();
+
+ if (!yytext)
yytext= "";
}
/* Push an error into the error stack */
@@ -5516,6 +5521,10 @@ class multi_update :public select_result_interceptor
/* Need this to protect against multiple prepare() calls */
bool prepared;
+
+ // For System Versioning (may need to insert new fields to a table).
+ ha_rows updated_sys_ver;
+
public:
multi_update(THD *thd_arg, TABLE_LIST *ut, List<TABLE_LIST> *leaves_list,
List<Item> *fields, List<Item> *values,
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index eb5f0d7a477..4983aafe9e9 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -343,7 +343,8 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
*/
if (!with_select && !using_limit && const_cond_result &&
(!thd->is_current_stmt_binlog_format_row() &&
- !(table->triggers && table->triggers->has_delete_triggers())))
+ !(table->triggers && table->triggers->has_delete_triggers()))
+ && !table->versioned())
{
/* Update the table->file->stats.records number */
table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
@@ -559,6 +560,12 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
while (!(error=info.read_record(&info)) && !thd->killed &&
! thd->is_error())
{
+ if (table->versioned() &&
+ !table->vers_end_field()->is_max_timestamp())
+ {
+ continue;
+ }
+
explain->tracker.on_record_read();
thd->inc_examined_row_count(1);
if (table->vfield)
@@ -580,7 +587,16 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
break;
}
- if (!(error= table->file->ha_delete_row(table->record[0])))
+ if (!table->versioned())
+ error= table->file->ha_delete_row(table->record[0]);
+ else
+ {
+ store_record(table,record[1]);
+ table->vers_end_field()->set_time();
+ error= table->file->ha_update_row(table->record[1],
+ table->record[0]);
+ }
+ if (!error)
{
deleted++;
if (table->triggers &&
@@ -1052,6 +1068,12 @@ int multi_delete::send_data(List<Item> &values)
if (table->status & (STATUS_NULL_ROW | STATUS_DELETED))
continue;
+ if (table->versioned() &&
+ !table->vers_end_field()->is_max_timestamp())
+ {
+ continue;
+ }
+
table->file->position(table->record[0]);
found++;
@@ -1064,7 +1086,16 @@ int multi_delete::send_data(List<Item> &values)
TRG_ACTION_BEFORE, FALSE))
DBUG_RETURN(1);
table->status|= STATUS_DELETED;
- if (!(error=table->file->ha_delete_row(table->record[0])))
+ if (!table->versioned())
+ error= table->file->ha_delete_row(table->record[0]);
+ else
+ {
+ store_record(table,record[1]);
+ table->vers_end_field()->set_time();
+ error= table->file->ha_update_row(table->record[1],
+ table->record[0]);
+ }
+ if (!error)
{
deleted++;
if (!table->file->has_transactions())
@@ -1243,8 +1274,16 @@ int multi_delete::do_table_deletes(TABLE *table, SORT_INFO *sort_info,
local_error= 1;
break;
}
-
- local_error= table->file->ha_delete_row(table->record[0]);
+
+ if (!table->versioned())
+ local_error= table->file->ha_delete_row(table->record[0]);
+ else
+ {
+ store_record(table,record[1]);
+ table->vers_end_field()->set_time();
+ local_error= table->file->ha_update_row(table->record[1],
+ table->record[0]);
+ }
if (local_error && !ignore)
{
table->file->print_error(local_error, MYF(0));
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index f97732860ad..4787356c8b6 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -222,7 +222,7 @@ static int check_insert_fields(THD *thd, TABLE_LIST *table_list,
table_list->view_db.str, table_list->view_name.str);
DBUG_RETURN(-1);
}
- if (values.elements != table->s->fields)
+ if (values.elements != table->user_fields())
{
my_error(ER_WRONG_VALUE_COUNT_ON_ROW, MYF(0), 1L);
DBUG_RETURN(-1);
@@ -1029,6 +1029,13 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
}
}
+ if (table->versioned() &&
+ table->vers_update_fields())
+ {
+ error= 1;
+ break;
+ }
+
if ((res= table_list->view_check_option(thd,
(values_list.elements == 1 ?
0 :
@@ -1555,6 +1562,13 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list,
if (!table)
table= table_list->table;
+ if (table->versioned() && duplic == DUP_REPLACE)
+ {
+ // Additional memory may be required to create historical items.
+ if (table_list->set_insert_values(thd->mem_root))
+ DBUG_RETURN(TRUE);
+ }
+
if (!select_insert)
{
Item *fake_conds= 0;
@@ -1606,6 +1620,31 @@ static int last_uniq_key(TABLE *table,uint keynr)
/*
+ Inserts one historical row to a table.
+
+ Copies content of the row from table->record[1] to table->record[0],
+ sets Sys_end to now() and calls ha_write_row() .
+*/
+
+int vers_insert_history_row(TABLE *table, ha_rows *inserted)
+{
+ DBUG_ASSERT(table->versioned());
+ restore_record(table,record[1]);
+
+ // Set Sys_end to now()
+ if (table->vers_end_field()->set_time())
+ {
+ return 1;
+ }
+
+ const int error= table->file->ha_write_row(table->record[0]);
+ if (!error)
+ ++*inserted;
+
+ return error;
+}
+
+/*
Write a record to table with optional deleting of conflicting records,
invoke proper triggers if needed.
@@ -1809,7 +1848,12 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info)
}
if (error != HA_ERR_RECORD_IS_THE_SAME)
+ {
info->updated++;
+ if (table->versioned() &&
+ (error=vers_insert_history_row(table, &info->copied)))
+ goto err;
+ }
else
error= 0;
/*
@@ -1861,13 +1905,16 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info)
tables which have ON UPDATE but have no ON DELETE triggers,
we just should not expose this fact to users by invoking
ON UPDATE triggers.
- */
- if (last_uniq_key(table,key_nr) &&
- !table->file->referenced_by_foreign_key() &&
- (!table->triggers || !table->triggers->has_delete_triggers()))
+ For system versioning wa also use path through delete since we would
+ save nothing through this cheating.
+ */
+ if (last_uniq_key(table,key_nr) &&
+ !table->file->referenced_by_foreign_key() &&
+ (!table->triggers || !table->triggers->has_delete_triggers()) &&
+ !table->versioned())
{
if ((error=table->file->ha_update_row(table->record[1],
- table->record[0])) &&
+ table->record[0])) &&
error != HA_ERR_RECORD_IS_THE_SAME)
goto err;
if (error != HA_ERR_RECORD_IS_THE_SAME)
@@ -1887,9 +1934,29 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info)
table->triggers->process_triggers(thd, TRG_EVENT_DELETE,
TRG_ACTION_BEFORE, TRUE))
goto before_trg_err;
- if ((error=table->file->ha_delete_row(table->record[1])))
+
+ if (!table->versioned())
+ error= table->file->ha_delete_row(table->record[1]);
+ else
+ {
+ DBUG_ASSERT(table->insert_values);
+ store_record(table,insert_values);
+ restore_record(table,record[1]);
+ if (table->vers_end_field()->set_time())
+ {
+ error= 1;
+ goto err;
+ }
+ error= table->file->ha_update_row(table->record[1],
+ table->record[0]);
+ restore_record(table,insert_values);
+ }
+ if (error)
goto err;
- info->deleted++;
+ if (!table->versioned())
+ info->deleted++;
+ else
+ info->updated++;
if (!table->file->has_transactions())
thd->transaction.stmt.modified_non_trans_table= TRUE;
if (table->triggers &&
@@ -3732,6 +3799,9 @@ int select_insert::send_data(List<Item> &values)
DBUG_RETURN(0);
thd->count_cuted_fields= CHECK_FIELD_WARN; // Calculate cuted fields
+ if (table->versioned() &&
+ table->vers_update_fields())
+ DBUG_RETURN(1);
store_values(values);
if (table->default_field && table->update_default_fields(0, info.ignore))
DBUG_RETURN(1);
@@ -3793,12 +3863,16 @@ int select_insert::send_data(List<Item> &values)
void select_insert::store_values(List<Item> &values)
{
+ DBUG_ENTER("select_insert::store_values");
+
if (fields->elements)
fill_record_n_invoke_before_triggers(thd, table, *fields, values, 1,
TRG_EVENT_INSERT);
else
fill_record_n_invoke_before_triggers(thd, table, table->field_to_fill(),
values, 1, TRG_EVENT_INSERT);
+
+ DBUG_VOID_RETURN;
}
bool select_insert::prepare_eof()
diff --git a/sql/sql_insert.h b/sql/sql_insert.h
index aea0dac6b0d..a8794e7414b 100644
--- a/sql/sql_insert.h
+++ b/sql/sql_insert.h
@@ -37,6 +37,7 @@ void upgrade_lock_type_for_insert(THD *thd, thr_lock_type *lock_type,
bool is_multi_insert);
int check_that_all_fields_are_given_values(THD *thd, TABLE *entry,
TABLE_LIST *table_list);
+int vers_insert_history_row(TABLE *table, ha_rows *inserted);
int write_record(THD *thd, TABLE *table, COPY_INFO *info);
void kill_delayed_threads(void);
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index a6796dcb901..c1281a2e022 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -1343,6 +1343,27 @@ int MYSQLlex(YYSTYPE *yylval, THD *thd)
return WITH;
}
break;
+ case FOR_SYM:
+ /*
+ * Additional look-ahead to resolve doubtful cases like:
+ * SELECT ... FOR UPDATE
+ * SELECT ... FOR SYSTEM_TIME ... .
+ */
+ token= lex_one_token(yylval, thd);
+ lip->add_digest_token(token, yylval);
+ switch(token) {
+ case SYSTEM_TIME_SYM:
+ return FOR_SYSTEM_TIME_SYM;
+ default:
+ /*
+ Save the token following 'FOR_SYM'
+ */
+ lip->lookahead_yylval= lip->yylval;
+ lip->yylval= NULL;
+ lip->lookahead_token= token;
+ return FOR_SYM;
+ }
+ break;
default:
break;
}
@@ -2998,8 +3019,7 @@ void Query_tables_list::destroy_query_tables_list()
*/
LEX::LEX()
- : explain(NULL),
- result(0), arena_for_set_stmt(0), mem_root_for_set_stmt(0),
+ : explain(NULL), result(0), arena_for_set_stmt(0), mem_root_for_set_stmt(0),
option_type(OPT_DEFAULT), context_analysis_only(0), sphead(0),
is_lex_started(0), limit_rows_examined_cnt(ULONGLONG_MAX)
{
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index 4257e77e2e8..a7fe77ca5a7 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -3560,6 +3560,12 @@ public:
SELECT_LEX *exclude_last_select();
bool add_unit_in_brackets(SELECT_LEX *nselect);
void check_automatic_up(enum sub_select_type type);
+
+ System_versioning_info *vers_get_info()
+ {
+ create_info.system_versioning_info.versioned = true;
+ return &create_info.system_versioning_info;
+ }
};
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 077c57a953e..5484467509a 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -138,6 +138,7 @@ static void sql_kill_user(THD *thd, LEX_USER *user, killed_state state);
static bool lock_tables_precheck(THD *thd, TABLE_LIST *tables);
static bool execute_show_status(THD *, TABLE_LIST *);
static bool check_rename_table(THD *, TABLE_LIST *, TABLE_LIST *);
+static bool check_system_versioning(Table_scope_and_contents_source_st *);
const char *any_db="*any*"; // Special symbol for check_access
@@ -3849,6 +3850,9 @@ mysql_execute_command(THD *thd)
*/
Alter_info alter_info(lex->alter_info, thd->mem_root);
+ if (check_system_versioning(&create_info))
+ goto end_with_restore_list;
+
if (thd->is_fatal_error)
{
/* If out of memory when creating a copy of alter_info. */
@@ -7319,6 +7323,66 @@ bool check_fk_parent_table_access(THD *thd,
}
+
+/****************************************************************************
+ Checks related to system versioning
+****************************************************************************/
+
+static bool check_system_versioning(Table_scope_and_contents_source_st *create_info)
+{
+ const System_versioning_info *versioning_info = &create_info->system_versioning_info;
+
+ if (!versioning_info->versioned)
+ return false;
+
+ bool r = false;
+
+ if (!versioning_info->declared_system_versioning)
+ {
+ r = true;
+ my_error(ER_MISSING_WITH_SYSTEM_VERSIONING, MYF(0));
+ }
+
+ if (!versioning_info->generated_as_row.start)
+ {
+ r = true;
+ my_error(ER_SYS_START_NOT_SPECIFIED, MYF(0));
+ }
+
+ if (!versioning_info->generated_as_row.end)
+ {
+ r = true;
+ my_error(ER_SYS_END_NOT_SPECIFIED, MYF(0));
+ }
+
+ if (!versioning_info->period_for_system_time.start || !versioning_info->period_for_system_time.end)
+ {
+ r = true;
+ my_error(ER_MISSING_PERIOD_FOR_SYSTEM_TIME, MYF(0));
+ }
+
+ if (!r)
+ {
+ if (my_strcasecmp(system_charset_info,
+ versioning_info->generated_as_row.start->c_ptr(),
+ versioning_info->period_for_system_time.start->c_ptr()))
+ {
+ r = true;
+ my_error(ER_PERIOD_FOR_SYSTEM_TIME_CONTAINS_WRONG_START_COLUMN, MYF(0));
+ }
+
+ if (my_strcasecmp(system_charset_info,
+ versioning_info->generated_as_row.end->c_ptr(),
+ versioning_info->period_for_system_time.end->c_ptr()))
+ {
+ r = true;
+ my_error(ER_PERIOD_FOR_SYSTEM_TIME_CONTAINS_WRONG_END_COLUMN, MYF(0));
+ }
+ }
+
+ return r; // false means no error
+}
+
/****************************************************************************
Check stack size; Send error if there isn't enough stack to continue
****************************************************************************/
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index a2e3d68e5dd..17e36390146 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -588,7 +588,7 @@ void remove_redundant_subquery_clauses(st_select_lex *subq_select_lex)
subq_select_lex->group_list.empty();
DBUG_PRINT("info", ("GROUP BY removed"));
}
-
+
/*
TODO: This would prevent processing quries with ORDER BY ... LIMIT
therefore we disable this optimization for now.
@@ -666,6 +666,77 @@ setup_without_group(THD *thd, Ref_ptr_array ref_pointer_array,
DBUG_RETURN(res);
}
+static int
+setup_for_system_time(THD *thd, TABLE_LIST *tables, COND **conds, SELECT_LEX *select_lex)
+{
+ DBUG_ENTER("setup_for_system_time");
+
+ TABLE_LIST *table;
+ int versioned_tables= 0;
+
+ for (table= tables; table; table= table->next_local)
+ {
+ if (table->table && table->table->versioned())
+ versioned_tables++;
+ else if (table->system_versioning.type != FOR_SYSTEM_TIME_UNSPECIFIED)
+ {
+ my_error(ER_TABLE_DOESNT_SUPPORT_SYSTEM_VERSIONING, MYF(0), table->table_name);
+ DBUG_RETURN(-1);
+ }
+ }
+
+ if (versioned_tables == 0)
+ DBUG_RETURN(0);
+
+ for (table= tables; table; table= table->next_local)
+ {
+ if (table->table && table->table->versioned())
+ {
+ Field *fstart= table->table->vers_start_field();
+ Field *fend= table->table->vers_end_field();
+ Item *istart= new (thd->mem_root) Item_field(thd, fstart);
+ Item *iend= new (thd->mem_root) Item_field(thd, fend);
+ Item *cond1= 0, *cond2= 0, *curr = 0;
+ switch (table->system_versioning.type)
+ {
+ case FOR_SYSTEM_TIME_UNSPECIFIED:
+ curr= new (thd->mem_root) Item_func_now_local(thd, 6);
+ cond1= new (thd->mem_root) Item_func_le(thd, istart, curr);
+ cond2= new (thd->mem_root) Item_func_gt(thd, iend, curr);
+ break;
+ case FOR_SYSTEM_TIME_AS_OF:
+ cond1= new (thd->mem_root) Item_func_le(thd, istart,
+ table->system_versioning.start);
+ cond2= new (thd->mem_root) Item_func_gt(thd, iend,
+ table->system_versioning.start);
+ break;
+ case FOR_SYSTEM_TIME_FROM_TO:
+ cond1= new (thd->mem_root) Item_func_lt(thd, istart,
+ table->system_versioning.end);
+ cond2= new (thd->mem_root) Item_func_ge(thd, iend,
+ table->system_versioning.start);
+ break;
+ case FOR_SYSTEM_TIME_BETWEEN:
+ cond1= new (thd->mem_root) Item_func_le(thd, istart,
+ table->system_versioning.end);
+ cond2= new (thd->mem_root) Item_func_ge(thd, iend,
+ table->system_versioning.start);
+ break;
+ default:
+ DBUG_ASSERT(0);
+ }
+ if (cond1 && cond2)
+ {
+ COND *system_time_cond= new (thd->mem_root) Item_cond_and(thd, cond1, cond2);
+ thd->change_item_tree(conds, and_items(thd, *conds, system_time_cond));
+ table->system_versioning.is_moved_to_where= true;
+ }
+ }
+ }
+
+ DBUG_RETURN(0);
+}
+
/*****************************************************************************
Check fields, find best join, do the select and output fields.
mysql_select assumes that all tables are already opened
@@ -740,7 +811,11 @@ JOIN::prepare(TABLE_LIST *tables_init,
{
remove_redundant_subquery_clauses(select_lex);
}
-
+
+ /* Handle FOR SYSTEM_TIME clause. */
+ if (setup_for_system_time(thd, tables_list, &conds, select_lex) < 0)
+ DBUG_RETURN(-1);
+
/*
TRUE if the SELECT list mixes elements with and without grouping,
and there is no GROUP BY clause. Mixing non-aggregated fields with
@@ -24784,6 +24859,38 @@ bool mysql_explain_union(THD *thd, SELECT_LEX_UNIT *unit, select_result *result)
DBUG_RETURN(res || thd->is_error());
}
+void TABLE_LIST::print_system_versioning(THD *thd, table_map eliminated_tables,
+ String *str, enum_query_type query_type)
+{
+ if (system_versioning.is_moved_to_where)
+ return;
+
+ // system versioning
+ if (system_versioning.type != FOR_SYSTEM_TIME_UNSPECIFIED)
+ {
+ switch (system_versioning.type)
+ {
+ case FOR_SYSTEM_TIME_AS_OF:
+ str->append(STRING_WITH_LEN(" for system_time as of "));
+ system_versioning.start->print(str, query_type);
+ break;
+ case FOR_SYSTEM_TIME_FROM_TO:
+ str->append(STRING_WITH_LEN(" for system_time from timestamp "));
+ system_versioning.start->print(str, query_type);
+ str->append(STRING_WITH_LEN(" to "));
+ system_versioning.end->print(str, query_type);
+ break;
+ case FOR_SYSTEM_TIME_BETWEEN:
+ str->append(STRING_WITH_LEN(" for system_time between timestamp "));
+ system_versioning.start->print(str, query_type);
+ str->append(STRING_WITH_LEN(" and "));
+ system_versioning.end->print(str, query_type);
+ break;
+ default:
+ DBUG_ASSERT(0);
+ }
+ }
+}
static void print_table_array(THD *thd,
table_map eliminated_tables,
@@ -25119,6 +25226,8 @@ void TABLE_LIST::print(THD *thd, table_map eliminated_tables, String *str,
append_identifier(thd, str, t_alias, strlen(t_alias));
}
+ print_system_versioning(thd, eliminated_tables, str, query_type);
+
if (index_hints)
{
List_iterator<Index_hint> it(*index_hints);
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 01f474a73fb..e3613c1e0e7 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -1666,6 +1666,7 @@ static bool get_field_default_value(THD *thd, Field *field, String *def_value,
has_default= (field->default_value ||
(!(field->flags & NO_DEFAULT_VALUE_FLAG) &&
+ !field->is_generated() &&
field->unireg_check != Field::NEXT_NUMBER));
def_value->length(0);
@@ -2123,6 +2124,14 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
packet->append(STRING_WITH_LEN(" DEFAULT "));
packet->append(def_value.ptr(), def_value.length(), system_charset_info);
}
+ else if (field->is_generated_row_start())
+ {
+ packet->append(STRING_WITH_LEN(" GENERATED AS ROW START"));
+ }
+ else if (field->is_generated_row_end())
+ {
+ packet->append(STRING_WITH_LEN(" GENERATED AS ROW END"));
+ }
if (!limited_mysql_mode &&
print_on_update_clause(field, &def_value, false))
@@ -2215,6 +2224,17 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
hton->index_options);
}
+ if (table->versioned())
+ {
+ const Field *fs = table->vers_start_field();
+ const Field *fe = table->vers_end_field();
+ packet->append(STRING_WITH_LEN(",\n PERIOD FOR SYSTEM_TIME ("));
+ append_identifier(thd,packet,fs->field_name, strlen(fs->field_name));
+ packet->append(STRING_WITH_LEN(", "));
+ append_identifier(thd,packet,fe->field_name, strlen(fe->field_name));
+ packet->append(STRING_WITH_LEN(")"));
+ }
+
/*
Get possible foreign key definitions stored in InnoDB and append them
to the CREATE TABLE statement
@@ -2253,6 +2273,11 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
add_table_options(thd, table, create_info_arg,
table_list->schema_table != 0, 0, packet);
+ if (table->versioned())
+ {
+ packet->append(STRING_WITH_LEN(" WITH SYSTEM VERSIONING"));
+ }
+
#ifdef WITH_PARTITION_STORAGE_ENGINE
{
if (table->part_info &&
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index bfc198a1a68..3913b14ccc8 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -3046,10 +3046,12 @@ void promote_first_timestamp_column(List<Create_field> *column_definitions)
if (is_timestamp_type(column_definition->sql_type) || // TIMESTAMP
column_definition->unireg_check == Field::TIMESTAMP_OLD_FIELD) // Legacy
{
+ DBUG_PRINT("info", ("field-ptr:%p", column_definition->field));
if ((column_definition->flags & NOT_NULL_FLAG) != 0 && // NOT NULL,
column_definition->default_value == NULL && // no constant default,
column_definition->unireg_check == Field::NONE && // no function default
- column_definition->vcol_info == NULL)
+ column_definition->vcol_info == NULL &&
+ !(column_definition->flags & (GENERATED_ROW_START_FLAG | GENERATED_ROW_END_FLAG))) // column isn't generated
{
DBUG_PRINT("info", ("First TIMESTAMP column '%s' was promoted to "
"DEFAULT CURRENT_TIMESTAMP ON UPDATE "
@@ -3144,6 +3146,39 @@ static void check_duplicate_key(THD *thd, Key *key, KEY *key_info,
}
}
+static void
+copy_info_about_generated_fields(Alter_info *dst_alter_info,
+ HA_CREATE_INFO *src_create_info)
+{
+ if (!src_create_info->versioned())
+ return;
+
+ const System_versioning_info *versioning_info =
+ src_create_info->get_system_versioning_info();
+ DBUG_ASSERT(versioning_info);
+ const char *row_start_field = versioning_info->generated_as_row.start->c_ptr();
+ DBUG_ASSERT(row_start_field);
+ const char *row_end_field = versioning_info->generated_as_row.end->c_ptr();
+ DBUG_ASSERT(row_end_field);
+
+ List_iterator<Create_field> it(dst_alter_info->create_list);
+ Create_field *column_definition = NULL;
+ while ( (column_definition = it++) )
+ {
+ if (!my_strcasecmp(system_charset_info,
+ row_start_field,
+ column_definition->field_name))
+ {
+ column_definition->flags |= GENERATED_ROW_START_FLAG;
+ }
+ else if (!my_strcasecmp(system_charset_info,
+ row_end_field,
+ column_definition->field_name))
+ {
+ column_definition->flags |= GENERATED_ROW_END_FLAG;
+ }
+ }
+}
/*
Preparation for table creation
@@ -3212,6 +3247,9 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
}
select_field_pos= alter_info->create_list.elements - select_field_count;
+ const System_versioning_info *versioning_info =
+ create_info->get_system_versioning_info();
+
for (field_no=0; (sql_field=it++) ; field_no++)
{
CHARSET_INFO *save_cs;
@@ -3437,6 +3475,23 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
*/
if (sql_field->stored_in_db())
record_offset+= sql_field->pack_length;
+
+ if (versioning_info)
+ {
+ const bool is_generated_as_row_start =
+ !my_strcasecmp(system_charset_info,
+ versioning_info->generated_as_row.start->c_ptr(),
+ sql_field->field_name);
+ const bool is_generated_as_row_end =
+ !my_strcasecmp(system_charset_info,
+ versioning_info->generated_as_row.end->c_ptr(),
+ sql_field->field_name);
+ if (is_generated_as_row_start && is_generated_as_row_end)
+ {
+ my_error(ER_SYS_START_AND_SYS_END_SAME, MYF(0), sql_field->field_name);
+ DBUG_RETURN(TRUE);
+ }
+ }
}
/* Update virtual fields' offset*/
it.rewind();
@@ -4285,6 +4340,58 @@ bool Column_definition::sp_prepare_create_field(THD *thd, MEM_ROOT *mem_root)
}
+static bool
+prepare_keys_for_sys_ver(THD *thd,
+ HA_CREATE_INFO *create_info,
+ Alter_info *alter_info,
+ KEY **key_info,
+ uint key_count)
+{
+ if (!create_info->versioned())
+ return false;
+
+ const System_versioning_info *versioning_info=
+ create_info->get_system_versioning_info();
+
+ DBUG_ASSERT(versioning_info);
+ const char *row_start_field= versioning_info->generated_as_row.start->c_ptr();
+ DBUG_ASSERT(row_start_field);
+ const char *row_end_field= versioning_info->generated_as_row.end->c_ptr();
+ DBUG_ASSERT(row_end_field);
+
+ List_iterator<Key> key_it(alter_info->key_list);
+ Key *key= NULL;
+ while ((key=key_it++))
+ {
+ if (key->type != Key::PRIMARY && key->type != Key::UNIQUE)
+ continue;
+
+ Key_part_spec *key_part= NULL;
+ List_iterator<Key_part_spec> part_it(key->columns);
+ while ((key_part=part_it++))
+ {
+ if (!my_strcasecmp(system_charset_info,
+ row_start_field,
+ key_part->field_name.str) ||
+
+ !my_strcasecmp(system_charset_info,
+ row_end_field,
+ key_part->field_name.str))
+ break;
+ }
+ if (key_part)
+ continue; // Key already contains Sys_start or Sys_end
+
+ const LEX_STRING &lex_sys_end=
+ versioning_info->generated_as_row.end->lex_string();
+ Key_part_spec *key_part_sys_end_col=
+ new(thd->mem_root) Key_part_spec(lex_sys_end, 0);
+ key->columns.push_back(key_part_sys_end_col);
+ }
+
+ return false;
+}
+
handler *mysql_create_frm_image(THD *thd,
const char *db, const char *table_name,
HA_CREATE_INFO *create_info,
@@ -4522,6 +4629,27 @@ handler *mysql_create_frm_image(THD *thd,
}
#endif
+ if (create_info->versioned())
+ {
+ // FIXME: This test doesn't detect foreign key relationship on the side of
+ // parent table and System Time support will not work correctly for such
+ // table either. But this cannot be implemented without changes to innodb
+ // that are postponed for later time.
+ List_iterator_fast<Key> key_iterator(alter_info->key_list);
+ Key *key;
+ while ((key= key_iterator++))
+ {
+ if (key->type == Key::FOREIGN_KEY)
+ {
+ my_error(ER_FOREIGN_KEY_ON_SYSTEM_VERSIONED, MYF(0));
+ goto err;
+ }
+ }
+ if(prepare_keys_for_sys_ver(thd, create_info, alter_info, key_info,
+ *key_count))
+ goto err;
+ }
+
if (mysql_prepare_create_table(thd, create_info, alter_info, &db_options,
file, key_info, key_count,
create_table_mode))
@@ -4952,6 +5080,8 @@ bool mysql_create_table(THD *thd, TABLE_LIST *create_table,
else
create_table_mode= C_ASSISTED_DISCOVERY;
+ copy_info_about_generated_fields(alter_info, create_info);
+
if (!opt_explicit_defaults_for_timestamp)
promote_first_timestamp_column(&alter_info->create_list);
diff --git a/sql/sql_trigger.h b/sql/sql_trigger.h
index 9d1c79cc7cf..f1e2135ce93 100644
--- a/sql/sql_trigger.h
+++ b/sql/sql_trigger.h
@@ -309,7 +309,7 @@ private:
inline Field **TABLE::field_to_fill()
{
return triggers && triggers->nullable_fields() ? triggers->nullable_fields()
- : field;
+ : non_generated_field ? non_generated_field : field;
}
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index 35e1fe24b97..79cabf180a9 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -44,6 +44,9 @@
// mysql_derived_filling
+#include "sql_insert.h" // For vers_insert_history_row() that may be
+ // needed for System Versioning.
+
/**
True if the table's input and output record buffers are comparable using
compare_record(TABLE*).
@@ -280,6 +283,10 @@ int mysql_update(THD *thd,
Explain_update *explain;
query_plan.index= MAX_KEY;
query_plan.using_filesort= FALSE;
+
+ // For System Versioning (may need to insert new fields to a table).
+ ha_rows updated_sys_ver= 0;
+
DBUG_ENTER("mysql_update");
create_explain_query(thd->lex, thd->mem_root);
@@ -354,6 +361,9 @@ int mysql_update(THD *thd,
DBUG_RETURN(1);
}
+ if (table->default_field)
+ table->mark_default_fields_for_write(false);
+
#ifndef NO_EMBEDDED_ACCESS_CHECKS
/* Check values */
table_list->grant.want_privilege= table->grant.want_privilege=
@@ -734,6 +744,11 @@ int mysql_update(THD *thd,
while (!(error=info.read_record(&info)) && !thd->killed)
{
+ if (table->versioned() && !table->vers_end_field()->is_max_timestamp())
+ {
+ continue;
+ }
+
explain->tracker.on_record_read();
thd->inc_examined_row_count(1);
if (!select || select->skip_record(thd) > 0)
@@ -743,10 +758,17 @@ int mysql_update(THD *thd,
explain->tracker.on_record_after_where();
store_record(table,record[1]);
+
if (fill_record_n_invoke_before_triggers(thd, table, fields, values, 0,
TRG_EVENT_UPDATE))
break; /* purecov: inspected */
+ if (table->versioned() && table->vers_update_fields())
+ {
+ error= 1;
+ break;
+ }
+
found++;
if (!can_compare_record || compare_record(table))
@@ -805,19 +827,29 @@ int mysql_update(THD *thd,
else
{
/* Non-batched update */
- error= table->file->ha_update_row(table->record[1],
+ error= table->file->ha_update_row(table->record[1],
table->record[0]);
}
- if (!error || error == HA_ERR_RECORD_IS_THE_SAME)
- {
- if (error != HA_ERR_RECORD_IS_THE_SAME)
- updated++;
- else
- error= 0;
- }
- else if (!ignore ||
+ if (error == HA_ERR_RECORD_IS_THE_SAME)
+ {
+ error= 0;
+ }
+ else if (!error)
+ {
+ updated++;
+
+ if (table->versioned())
+ {
+ store_record(table, record[2]);
+ if ((error = vers_insert_history_row(table, &updated_sys_ver)))
+ break;
+
+ restore_record(table, record[2]);
+ }
+ }
+ else if (!ignore ||
table->file->is_fatal_error(error, HA_CHECK_ALL))
- {
+ {
/*
If (ignore && error is ignorable) we don't have to
do anything; otherwise...
@@ -1007,9 +1039,15 @@ int mysql_update(THD *thd,
if (error < 0 && !thd->lex->analyze_stmt)
{
char buff[MYSQL_ERRMSG_SIZE];
- my_snprintf(buff, sizeof(buff), ER_THD(thd, ER_UPDATE_INFO), (ulong) found,
- (ulong) updated,
- (ulong) thd->get_stmt_da()->current_statement_warn_count());
+ if (!table->versioned())
+ my_snprintf(buff, sizeof(buff), ER_THD(thd, ER_UPDATE_INFO), (ulong) found,
+ (ulong) updated,
+ (ulong) thd->get_stmt_da()->current_statement_warn_count());
+ else
+ my_snprintf(buff, sizeof(buff),
+ ER_THD(thd, ER_UPDATE_INFO_WITH_SYSTEM_VERSIONING),
+ (ulong) found, (ulong) updated, (ulong) updated_sys_ver,
+ (ulong) thd->get_stmt_da()->current_statement_warn_count());
my_ok(thd, (thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated,
id, buff);
DBUG_PRINT("info",("%ld records updated", (long) updated));
@@ -1627,8 +1665,10 @@ multi_update::multi_update(THD *thd_arg, TABLE_LIST *table_list,
tmp_tables(0), updated(0), found(0), fields(field_list),
values(value_list), table_count(0), copy_field(0),
handle_duplicates(handle_duplicates_arg), do_update(1), trans_safe(1),
- transactional_tables(0), ignore(ignore_arg), error_handled(0), prepared(0)
-{}
+ transactional_tables(0), ignore(ignore_arg), error_handled(0), prepared(0),
+ updated_sys_ver(0)
+{
+}
/*
@@ -1877,7 +1917,7 @@ static bool safe_update_on_fly(THD *thd, JOIN_TAB *join_tab,
return !is_key_used(table, table->s->primary_key, table->write_set);
return TRUE;
default:
- break; // Avoid compler warning
+ break; // Avoid compiler warning
}
return FALSE;
@@ -2097,6 +2137,11 @@ int multi_update::send_data(List<Item> &not_used_values)
if (table->status & (STATUS_NULL_ROW | STATUS_UPDATED))
continue;
+ if (table->versioned() && !table->vers_end_field()->is_max_timestamp())
+ {
+ continue;
+ }
+
if (table == table_to_update)
{
/*
@@ -2109,6 +2154,7 @@ int multi_update::send_data(List<Item> &not_used_values)
table->status|= STATUS_UPDATED;
store_record(table,record[1]);
+
if (fill_record_n_invoke_before_triggers(thd, table,
*fields_for_table[offset],
*values_for_table[offset], 0,
@@ -2127,6 +2173,13 @@ int multi_update::send_data(List<Item> &not_used_values)
if (table->default_field && table->update_default_fields(1, ignore))
DBUG_RETURN(1);
+ if (table->versioned() &&
+ table->vers_update_fields())
+ {
+ error= 1;
+ break;
+ }
+
if ((error= cur_table->view_check_option(thd, ignore)) !=
VIEW_CHECK_OK)
{
@@ -2174,6 +2227,23 @@ int multi_update::send_data(List<Item> &not_used_values)
error= 0;
updated--;
}
+ else if (table->versioned())
+ {
+ restore_record(table,record[1]);
+
+ // Set end time to now()
+ if (table->vers_end_field()->set_time())
+ {
+ error= 1;
+ break;
+ }
+
+ if ( (error= vers_insert_history_row(table, &updated_sys_ver)) )
+ {
+ error= 1;
+ break;
+ }
+ }
/* non-transactional or transactional table got modified */
/* either multi_update class' flag is raised in its branch */
if (table->file->has_transactions())
@@ -2200,6 +2270,7 @@ int multi_update::send_data(List<Item> &not_used_values)
*/
uint field_num= 0;
List_iterator_fast<TABLE> tbl_it(unupdated_check_opt_tables);
+ /* Set first tbl = table and then tbl to tables from tbl_it */
TABLE *tbl= table;
do
{
@@ -2262,10 +2333,6 @@ void multi_update::abort_result_set()
if (do_update && table_count > 1)
{
/* Add warning here */
- /*
- todo/fixme: do_update() is never called with the arg 1.
- should it change the signature to become argless?
- */
(void) do_updates();
}
}
@@ -2447,19 +2514,44 @@ int multi_update::do_updates()
goto err2;
}
}
- if ((local_error=table->file->ha_update_row(table->record[1],
- table->record[0])) &&
+ if (table->versioned() &&
+ table->vers_update_fields())
+ {
+ goto err2;
+ }
+
+ if ((local_error=table->file->ha_update_row(table->record[1],
+ table->record[0])) &&
local_error != HA_ERR_RECORD_IS_THE_SAME)
{
if (!ignore ||
table->file->is_fatal_error(local_error, HA_CHECK_ALL))
{
err_table= table;
- goto err;
+ goto err;
}
- }
+ }
if (local_error != HA_ERR_RECORD_IS_THE_SAME)
+ {
updated++;
+
+ if (table->versioned())
+ {
+ restore_record(table,record[1]);
+
+ // Set end time to now()
+ if (table->vers_end_field()->set_time())
+ {
+ goto err2;
+ }
+
+ if ( (local_error= vers_insert_history_row(table, &updated_sys_ver)) )
+ {
+ err_table = table;
+ goto err;
+ }
+ }
+ }
else
local_error= 0;
}
diff --git a/sql/sql_view.cc b/sql/sql_view.cc
index fb4c2c3d835..08f42e9ce70 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -2010,7 +2010,7 @@ bool check_key_in_view(THD *thd, TABLE_LIST *view)
RETURN
FALSE OK
- TRUE error (is not sent to cliet)
+ TRUE error (is not sent to client)
*/
bool insert_view_fields(THD *thd, List<Item> *list, TABLE_LIST *view)
@@ -2038,7 +2038,7 @@ bool insert_view_fields(THD *thd, List<Item> *list, TABLE_LIST *view)
}
/*
- checking view md5 check suum
+ checking view md5 check sum
SINOPSYS
view_checksum()
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 47c3882bba1..6b09055e323 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -758,6 +758,7 @@ Virtual_column_info *add_virtual_expression(THD *thd, Item *expr)
uint sp_instr_addr;
/* structs */
+ system_versioning_for_select system_versioning;
LEX_STRING lex_str;
LEX_SYMBOL symbol;
Lex_string_with_metadata_st lex_string_with_metadata;
@@ -859,10 +860,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%parse-param { THD *thd }
%lex-param { THD *thd }
/*
- Currently there are 103 shift/reduce conflicts.
+ Currently there are 106 shift/reduce conflicts.
We should not introduce new conflicts any more.
*/
-%expect 103
+%expect 106
/*
Comments for TOKENS.
@@ -878,6 +879,9 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
INTERNAL : Not a real token, lex optimization
OPERATOR : SQL operator
FUTURE-USE : Reserved for future use
+ 32N2439 : Reserver keywords per ISO/IEC PDTR 19075-2,
+ http://jtc1sc32.org/doc/N2401-2450/32N2439-text_for_ballot-PDTR_19075-2.pdf
+ System Versioned Tables
This makes the code grep-able, and helps maintenance.
*/
@@ -1090,6 +1094,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token FORCE_SYM
%token FOREIGN /* SQL-2003-R */
%token FOR_SYM /* SQL-2003-R */
+%token FOR_SYSTEM_TIME_SYM /* internal */
%token FORMAT_SYM
%token FOUND_SYM /* SQL-2003-R */
%token FROM
@@ -1320,6 +1325,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token PARTITIONING_SYM
%token PASSWORD_SYM
%token PERCENT_RANK_SYM
+%token PERIOD_SYM /* 32N2439 */
%token PERSISTENT_SYM
%token PHASE_SYM
%token PLUGINS_SYM
@@ -1484,6 +1490,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token SWAPS_SYM
%token SWITCHES_SYM
%token SYSDATE
+%token SYSTEM /* 32N2439 */
+%token SYSTEM_TIME_SYM /* 32N2439 */
%token TABLES
%token TABLESPACE
%token TABLE_REF_PRIORITY
@@ -1552,6 +1560,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token VARIANCE_SYM
%token VARYING /* SQL-2003-R */
%token VAR_SAMP_SYM
+%token VERSIONING /* 32N2439 */
%token VIA_SYM
%token VIEW_SYM /* SQL-2003-N */
%token VIRTUAL_SYM
@@ -1638,6 +1647,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%type <string>
text_string hex_or_bin_String opt_gconcat_separator
+ period_for_system_time_column_id
%type <field_type> int_type real_type
@@ -1885,6 +1895,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
keep_gcc_happy
key_using_alg
part_column_list
+ period_for_system_time
server_def server_options_list server_option
definer_opt no_definer definer get_diagnostics
parse_vcol_expr vcol_opt_specifier vcol_opt_attribute
@@ -1908,6 +1919,7 @@ END_OF_INPUT
%type <num> sp_decl_idents sp_decl_idents_init_vars
%type <num> sp_handler_type sp_hcond_list
+%type <num> start_or_end
%type <spcondvalue> sp_cond sp_hcond sqlstate signal_value opt_signal_value
%type <spblock> sp_decls sp_decl sp_decl_body sp_decl_variable_list
%type <spname> sp_name
@@ -1942,7 +1954,7 @@ END_OF_INPUT
%type <NONE> window_frame_extent;
%type <frame_exclusion> opt_window_frame_exclusion;
%type <window_frame_bound> window_frame_start window_frame_bound;
-
+%type <system_versioning> opt_for_system_time_clause;
%type <NONE>
'-' '+' '*' '/' '%' '(' ')'
@@ -5837,6 +5849,13 @@ create_table_option:
{
Lex->create_info.used_fields|= HA_CREATE_USED_SEQUENCE;
Lex->create_info.sequence= $3;
+ }
+ | WITH SYSTEM VERSIONING
+ {
+ System_versioning_info *info = Lex->vers_get_info();
+ if (!info)
+ MYSQL_YYABORT;
+ info->declared_system_versioning = true;
}
;
@@ -5937,6 +5956,7 @@ field_list_item:
column_def { }
| key_def
| constraint_def
+ | period_for_system_time
;
column_def:
@@ -6036,6 +6056,22 @@ constraint_def:
}
;
+period_for_system_time:
+ // If FOR_SYM is followed by SYSTEM_TIME_SYM then they are merged to: FOR_SYSTEM_TIME_SYM .
+ PERIOD_SYM FOR_SYSTEM_TIME_SYM '(' period_for_system_time_column_id ',' period_for_system_time_column_id ')'
+ {
+ System_versioning_info *info = Lex->vers_get_info();
+ if (!info)
+ MYSQL_YYABORT;
+ if (!my_strcasecmp(system_charset_info, $4->c_ptr(), $6->c_ptr()))
+ {
+ my_error(ER_SYS_START_AND_SYS_END_SAME, MYF(0), $4->c_ptr());
+ MYSQL_YYABORT;
+ }
+ info->set_period_for_system_time($4, $6);
+ }
+ ;
+
opt_check_constraint:
/* empty */ { $$= (Virtual_column_info*) 0; }
| check_constraint { $$= $1;}
@@ -6130,6 +6166,46 @@ field_def:
Lex->last_field->flags&= ~NOT_NULL_FLAG; // undo automatic NOT NULL for timestamps
}
vcol_opt_specifier vcol_opt_attribute
+ | opt_generated_always AS ROW_SYM start_or_end
+ {
+ System_versioning_info *info =
+ Lex->vers_get_info();
+ if (!info)
+ MYSQL_YYABORT;
+ String *field_name = new (thd->mem_root)
+ String((const char*)Lex->last_field->field_name, system_charset_info);
+ if (!field_name)
+ MYSQL_YYABORT;
+
+ String **p = NULL;
+ int err_nr = 0;
+ switch ($4)
+ {
+ case 1:
+ p = &info->generated_as_row.start;
+ err_nr = ER_SYS_START_MORE_THAN_ONCE;
+ break;
+ case 0:
+ p = &info->generated_as_row.end;
+ err_nr = ER_SYS_END_MORE_THAN_ONCE;
+ break;
+ default:
+ /* Not Reachable */
+ MYSQL_YYABORT;
+ break;
+ }
+ if (*p)
+ {
+ my_error(err_nr, MYF(0), field_name->c_ptr());
+ MYSQL_YYABORT;
+ }
+ *p = field_name;
+ }
+ ;
+
+start_or_end:
+ START_SYM { $$ = 1; }
+ | END { $$ = 0; }
;
opt_generated_always:
@@ -7535,6 +7611,9 @@ alter_list_item:
Lex->create_last_non_select_table= Lex->last_table();
Lex->alter_info.flags|= Alter_info::ALTER_ADD_INDEX;
}
+ | ADD period_for_system_time
+ {
+ }
| add_column '(' create_field_list ')'
{
Lex->alter_info.flags|= Alter_info::ALTER_ADD_COLUMN |
@@ -8587,6 +8666,60 @@ select_options:
}
;
+opt_for_system_time_clause:
+ /* empty */
+ {
+ $$.init();
+ }
+ | FOR_SYSTEM_TIME_SYM
+ AS OF_SYM
+ TIMESTAMP TEXT_STRING
+ {
+ Item *item= create_temporal_literal(thd, $5.str, $5.length, YYCSCL,
+ MYSQL_TYPE_DATETIME, true);
+ if (item == NULL)
+ MYSQL_YYABORT;
+ $$.init(FOR_SYSTEM_TIME_AS_OF, item);
+ }
+ | FOR_SYSTEM_TIME_SYM
+ AS OF_SYM
+ NOW_SYM
+ {
+ Item *item= new (thd->mem_root) Item_func_now_local(thd, 6);
+ if (item == NULL)
+ MYSQL_YYABORT;
+ $$.init(FOR_SYSTEM_TIME_AS_OF, item);
+ }
+ | FOR_SYSTEM_TIME_SYM
+ FROM
+ TIMESTAMP TEXT_STRING
+ TO_SYM
+ TIMESTAMP TEXT_STRING
+ {
+ Item *item1= create_temporal_literal(thd, $4.str, $4.length, YYCSCL,
+ MYSQL_TYPE_DATETIME, true);
+ Item *item2= create_temporal_literal(thd, $7.str, $7.length, YYCSCL,
+ MYSQL_TYPE_DATETIME, true);
+ if (item1 == NULL || item2 == NULL)
+ MYSQL_YYABORT;
+ $$.init(FOR_SYSTEM_TIME_FROM_TO, item1, item2);
+ }
+ | FOR_SYSTEM_TIME_SYM
+ BETWEEN_SYM
+ TIMESTAMP TEXT_STRING
+ AND_SYM
+ TIMESTAMP TEXT_STRING
+ {
+ Item *item1= create_temporal_literal(thd, $4.str, $4.length, YYCSCL,
+ MYSQL_TYPE_DATETIME, true);
+ Item *item2= create_temporal_literal(thd, $7.str, $7.length, YYCSCL,
+ MYSQL_TYPE_DATETIME, true);
+ if (item1 == NULL || item2 == NULL)
+ MYSQL_YYABORT;
+ $$.init(FOR_SYSTEM_TIME_BETWEEN, item1, item2);
+ }
+ ;
+
select_option_list:
select_option_list select_option
| select_option
@@ -10994,7 +11127,7 @@ table_primary_ident:
SELECT_LEX *sel= Select;
sel->table_join_options= 0;
}
- table_ident opt_use_partition opt_table_alias opt_key_definition
+ table_ident opt_use_partition opt_table_alias opt_key_definition opt_for_system_time_clause
{
if (!($$= Select->add_table_to_list(thd, $2, $4,
Select->get_table_join_options(),
@@ -11004,6 +11137,7 @@ table_primary_ident:
$3)))
MYSQL_YYABORT;
Select->add_joined_table($$);
+ $$->system_versioning= $6;
}
;
@@ -15891,6 +16025,16 @@ column_list:
| column_list_id
;
+period_for_system_time_column_id:
+ ident
+ {
+ String *new_str= new (thd->mem_root) String((const char*) $1.str,$1.length,system_charset_info);
+ if (new_str == NULL)
+ MYSQL_YYABORT;
+ $$= new_str;
+ }
+ ;
+
column_list_id:
ident
{
@@ -16537,7 +16681,12 @@ trigger_tail:
FOR_SYM
remember_name /* $13 */
{ /* $14 */
- Lex->raw_trg_on_table_name_end= YYLIP->get_tok_start();
+ /*
+ FOR token is already passed through (see 'case FOR_SYM' in sql_lex.cc),
+ so we use _prev() to get it back.
+ */
+ DBUG_ASSERT(YYLIP->lookahead_token >= 0);
+ Lex->raw_trg_on_table_name_end= YYLIP->get_tok_start_prev();
}
EACH_SYM
ROW_SYM
diff --git a/sql/table.cc b/sql/table.cc
index fae17fd8f20..742fad71134 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -1197,6 +1197,8 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
uint len;
uint ext_key_parts= 0;
plugin_ref se_plugin= 0;
+ const uchar *system_period = 0;
+
MEM_ROOT *old_root= thd->mem_root;
Virtual_column_info **table_check_constraints;
DBUG_ENTER("TABLE_SHARE::init_from_binary_frm_image");
@@ -1290,6 +1292,11 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
}
#endif /*HAVE_SPATIAL*/
break;
+ case EXTRA2_PERIOD_FOR_SYSTEM_TIME:
+ if (system_period || length != 2 * sizeof(uint16))
+ goto err;
+ system_period = extra2;
+ break;
default:
/* abort frm parsing if it's an unknown but important extra2 value */
if (type >= EXTRA2_ENGINE_IMPORTANT)
@@ -2470,6 +2477,35 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
}
}
+ /* Set system versioning information. */
+ if (system_period == NULL)
+ {
+ share->disable_system_versioning();
+ }
+ else
+ {
+ DBUG_PRINT("info", ("Setting system versioning informations"));
+ uint16 row_start = uint2korr(system_period);
+ uint16 row_end = uint2korr(system_period + sizeof(uint16));
+ if (row_start >= share->fields || row_end >= share->fields)
+ goto err;
+ DBUG_PRINT("info", ("Columns with system versioning: [%d, %d]", row_start, row_end));
+ share->enable_system_versioning(row_start, row_end);
+ vers_start_field()->set_generated_row_start();
+ vers_end_field()->set_generated_row_end();
+
+ if (vers_start_field()->type() != MYSQL_TYPE_TIMESTAMP)
+ {
+ my_error(ER_SYS_START_FIELD_MUST_BE_TIMESTAMP, MYF(0), share->table_name);
+ goto err;
+ }
+ if (vers_end_field()->type() != MYSQL_TYPE_TIMESTAMP)
+ {
+ my_error(ER_SYS_END_FIELD_MUST_BE_TIMESTAMP, MYF(0), share->table_name);
+ goto err;
+ }
+ }
+
/*
the correct null_bytes can now be set, since bitfields have been taken
into account
@@ -3013,25 +3049,30 @@ enum open_frm_error open_table_from_share(THD *thd, TABLE_SHARE *share,
records=0;
if ((db_stat & HA_OPEN_KEYFILE) || (prgflag & DELAYED_OPEN))
records=1;
- if (prgflag & (READ_ALL+EXTRA_RECORD))
+ if (prgflag & (READ_ALL + EXTRA_RECORD))
+ {
records++;
-
- if (!(record= (uchar*) alloc_root(&outparam->mem_root,
- share->rec_buff_length * records)))
- goto err; /* purecov: inspected */
+ if (share->versioned)
+ records++;
+ }
if (records == 0)
{
/* We are probably in hard repair, and the buffers should not be used */
- outparam->record[0]= outparam->record[1]= share->default_values;
+ record= share->default_values;
}
else
{
- outparam->record[0]= record;
- if (records > 1)
- outparam->record[1]= record+ share->rec_buff_length;
- else
- outparam->record[1]= outparam->record[0]; // Safety
+ if (!(record= (uchar*) alloc_root(&outparam->mem_root,
+ share->rec_buff_length * records)))
+ goto err; /* purecov: inspected */
+ }
+
+ for (i= 0; i < 3;)
+ {
+ outparam->record[i]= record;
+ if (++i < records)
+ record+= share->rec_buff_length;
}
if (!(field_ptr = (Field **) alloc_root(&outparam->mem_root,
@@ -3056,6 +3097,26 @@ enum open_frm_error open_table_from_share(THD *thd, TABLE_SHARE *share,
}
(*field_ptr)= 0; // End marker
+ if (share->versioned)
+ {
+ Field **fptr = NULL;
+ if (!(fptr = (Field **) alloc_root(&outparam->mem_root,
+ (uint) ((share->fields+1)*
+ sizeof(Field*)))))
+ goto err;
+
+ outparam->non_generated_field = fptr;
+ for (i=0 ; i < share->fields; i++)
+ {
+ if (outparam->field[i]->is_generated())
+ continue;
+ *fptr++ = outparam->field[i];
+ }
+ (*fptr)= 0; // End marker
+ }
+ else
+ outparam->non_generated_field= NULL;
+
if (share->found_next_number_field)
outparam->found_next_number_field=
outparam->field[(uint) (share->found_next_number_field - share->field)];
@@ -6225,6 +6286,15 @@ void TABLE::mark_columns_needed_for_delete()
if (need_signal)
file->column_bitmaps_signal();
+
+ /*
+ For System Versioning we have to write and read Sys_end.
+ */
+ if (s->versioned)
+ {
+ bitmap_set_bit(read_set, s->vers_end_field()->field_index);
+ bitmap_set_bit(write_set, s->vers_end_field()->field_index);
+ }
}
@@ -6301,6 +6371,15 @@ void TABLE::mark_columns_needed_for_update()
need_signal= true;
}
}
+ /*
+ For System Versioning we have to read all columns since we will store
+ a copy of previous row with modified Sys_end column back to a table.
+ */
+ if (s->versioned)
+ {
+ // We will copy old columns to a new row.
+ use_all_columns();
+ }
if (check_constraints)
{
mark_check_constraint_columns_for_read();
@@ -7485,6 +7564,29 @@ int TABLE::update_default_fields(bool update_command, bool ignore_errors)
DBUG_RETURN(res);
}
+bool TABLE::vers_update_fields()
+{
+ DBUG_ENTER("vers_update_fields");
+
+ if (!versioned())
+ DBUG_RETURN(FALSE);
+
+ if (vers_start_field()->set_time())
+ {
+ DBUG_RETURN(TRUE);
+ }
+
+ if (vers_end_field()->set_max_timestamp())
+ {
+ DBUG_RETURN(TRUE);
+ }
+
+ bitmap_set_bit(write_set, vers_start_field()->field_index);
+ bitmap_set_bit(write_set, vers_end_field()->field_index);
+
+ DBUG_RETURN(FALSE);
+}
+
/**
Reset markers that fields are being updated
*/
diff --git a/sql/table.h b/sql/table.h
index f4ef2f05a9b..0e746d6c5fb 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -742,6 +742,38 @@ struct TABLE_SHARE
#endif
/**
+ System versioning support.
+ */
+
+ bool versioned;
+ uint16 row_start_field;
+ uint16 row_end_field;
+
+ void enable_system_versioning(uint16 row_start, uint row_end)
+ {
+ versioned = true;
+ row_start_field = row_start;
+ row_end_field = row_end;
+ }
+
+ void disable_system_versioning()
+ {
+ versioned = false;
+ row_start_field = 0;
+ row_end_field = 0;
+ }
+
+ Field *vers_start_field()
+ {
+ return field[row_start_field];
+ }
+
+ Field *vers_end_field()
+ {
+ return field[row_end_field];
+ }
+
+ /**
Cache the checked structure of this table.
The pointer data is used to describe the structure that
@@ -1051,7 +1083,7 @@ public:
uint32 instance; /** Table cache instance this TABLE is belonging to */
THD *in_use; /* Which thread uses this */
- uchar *record[2]; /* Pointer to records */
+ uchar *record[3]; /* Pointer to records */
uchar *write_row_record; /* Used as optimisation in
THD::write_row */
uchar *insert_values; /* used by INSERT ... UPDATE */
@@ -1084,6 +1116,8 @@ public:
Field **default_field; /* Fields with non-constant DEFAULT */
Field *next_number_field; /* Set if next_number is activated */
Field *found_next_number_field; /* Set on open */
+ Field **non_generated_field; /* Like **field but without generated
+ fields */
Virtual_column_info **check_constraints;
/* Table's triggers, 0 if there are no of them */
@@ -1431,6 +1465,7 @@ public:
int update_virtual_field(Field *vf);
int update_virtual_fields(handler *h, enum_vcol_update_mode update_mode);
int update_default_fields(bool update, bool ignore_errors);
+ bool vers_update_fields();
void reset_default_fields();
inline ha_rows stat_records() { return used_stat_records; }
@@ -1447,6 +1482,37 @@ public:
bool with_cleanup);
Field *find_field_by_name(const char *str) const;
bool export_structure(THD *thd, class Row_definition_list *defs);
+
+ /**
+ System versioning support.
+ */
+
+ bool versioned() const
+ {
+ return s->versioned;
+ }
+
+ Field *vers_start_field() const
+ {
+ DBUG_ASSERT(versioned());
+ return field[s->row_start_field];
+ }
+
+ Field *vers_end_field() const
+ {
+ DBUG_ASSERT(versioned());
+ return field[s->row_end_field];
+ }
+
+/** Number of additional fields used in versioned tables */
+#define VERSIONING_FIELDS 2
+
+ uint user_fields() const
+ {
+ return versioned() ?
+ s->fields - VERSIONING_FIELDS :
+ s->fields;
+ }
};
@@ -1737,6 +1803,31 @@ class Item_in_subselect;
4) jtbm semi-join (jtbm_subselect != NULL)
*/
+enum for_system_time_type
+{
+ FOR_SYSTEM_TIME_UNSPECIFIED, FOR_SYSTEM_TIME_AS_OF,
+ FOR_SYSTEM_TIME_FROM_TO, FOR_SYSTEM_TIME_BETWEEN
+};
+
+/** System versioning support. */
+struct system_versioning_for_select
+{
+ enum for_system_time_type type;
+ Item *start, *end;
+ bool is_moved_to_where;
+
+ void init(
+ const enum for_system_time_type t=FOR_SYSTEM_TIME_UNSPECIFIED,
+ Item * const s=NULL,
+ Item * const e=NULL)
+ {
+ type= t;
+ start= s;
+ end= e;
+ is_moved_to_where= false;
+ }
+};
+
struct LEX;
class Index_hint;
struct TABLE_LIST
@@ -2192,6 +2283,10 @@ struct TABLE_LIST
TABLE_LIST *find_underlying_table(TABLE *table);
TABLE_LIST *first_leaf_for_name_resolution();
TABLE_LIST *last_leaf_for_name_resolution();
+
+ /** System versioning support. */
+ system_versioning_for_select system_versioning;
+
/**
@brief
Find the bottom in the chain of embedded table VIEWs.
@@ -2390,6 +2485,9 @@ struct TABLE_LIST
void check_pushable_cond_for_table(Item *cond);
Item *build_pushable_cond_for_table(THD *thd, Item *cond);
+ void print_system_versioning(THD *thd, table_map eliminated_tables,
+ String *str, enum_query_type query_type);
+
private:
bool prep_check_option(THD *thd, uint8 check_opt_type);
bool prep_where(THD *thd, Item **conds, bool no_where_clause);
diff --git a/sql/unireg.cc b/sql/unireg.cc
index 0bb8a4e77c6..0465626c132 100644
--- a/sql/unireg.cc
+++ b/sql/unireg.cc
@@ -87,6 +87,72 @@ static uchar *extra2_write(uchar *pos, enum extra2_frm_value_type type,
return extra2_write(pos, type, reinterpret_cast<LEX_STRING *>(str));
}
+static bool
+versioned(HA_CREATE_INFO *create_info)
+{
+ return create_info->versioned();
+}
+
+static uint16
+get_row_start_field(HA_CREATE_INFO *create_info, List<Create_field> &create_fields)
+{
+ DBUG_ASSERT(versioned(create_info));
+
+ List_iterator<Create_field> it(create_fields);
+ Create_field*sql_field = NULL;
+
+ const System_versioning_info *versioning_info =
+ create_info->get_system_versioning_info();
+ DBUG_ASSERT(versioning_info);
+
+ const char *row_start_field = versioning_info->generated_as_row.start->c_ptr();
+ DBUG_ASSERT(row_start_field);
+
+ for (unsigned field_no = 0; (sql_field = it++); ++field_no)
+ {
+ if (!my_strcasecmp(system_charset_info,
+ row_start_field,
+ sql_field->field_name))
+ {
+ DBUG_ASSERT(field_no <= uint16(~0U));
+ return uint16(field_no);
+ }
+ }
+
+ DBUG_ASSERT(0); /* Not Reachable */
+ return 0;
+}
+
+static uint16
+get_row_end_field(HA_CREATE_INFO *create_info, List<Create_field> &create_fields)
+{
+ DBUG_ASSERT(versioned(create_info));
+
+ List_iterator<Create_field> it(create_fields);
+ Create_field*sql_field = NULL;
+
+ const System_versioning_info *versioning_info =
+ create_info->get_system_versioning_info();
+ DBUG_ASSERT(versioning_info);
+
+ const char *row_end_field = versioning_info->generated_as_row.end->c_ptr();
+ DBUG_ASSERT(row_end_field);
+
+ for (unsigned field_no = 0; (sql_field = it++); ++field_no)
+ {
+ if (!my_strcasecmp(system_charset_info,
+ row_end_field,
+ sql_field->field_name))
+ {
+ DBUG_ASSERT(field_no <= uint16(~0U));
+ return uint16(field_no);
+ }
+ }
+
+ DBUG_ASSERT(0); /* Not Reachable */
+ return 0;
+}
+
/**
Create a frm (table definition) file
@@ -219,6 +285,10 @@ LEX_CUSTRING build_frm_image(THD *thd, const char *table,
if (gis_extra2_len)
extra2_size+= 1 + (gis_extra2_len > 255 ? 3 : 1) + gis_extra2_len;
+ if (versioned(create_info))
+ {
+ extra2_size+= 1 + 1 + 2 * sizeof(uint16);
+ }
key_buff_length= uint4korr(fileinfo+47);
@@ -275,6 +345,16 @@ LEX_CUSTRING build_frm_image(THD *thd, const char *table,
}
#endif /*HAVE_SPATIAL*/
+ if (versioned(create_info))
+ {
+ *pos++= EXTRA2_PERIOD_FOR_SYSTEM_TIME;
+ *pos++= 2 * sizeof(uint16);
+ int2store(pos, get_row_start_field(create_info, create_fields));
+ pos+= sizeof(uint16);
+ int2store(pos, get_row_end_field(create_info, create_fields));
+ pos+= sizeof(uint16);
+ }
+
int4store(pos, filepos); // end of the extra2 segment
pos+= 4;
diff --git a/sql/unireg.h b/sql/unireg.h
index b1cab841092..475945311e4 100644
--- a/sql/unireg.h
+++ b/sql/unireg.h
@@ -172,6 +172,7 @@ enum extra2_frm_value_type {
EXTRA2_TABLEDEF_VERSION=0,
EXTRA2_DEFAULT_PART_ENGINE=1,
EXTRA2_GIS=2,
+ EXTRA2_PERIOD_FOR_SYSTEM_TIME=4,
#define EXTRA2_ENGINE_IMPORTANT 128
diff --git a/storage/tokudb/mysql-test/tokudb/r/tokudb_support_xa.result b/storage/tokudb/mysql-test/tokudb/r/tokudb_support_xa.result
index 120e8de7c7f..fd32fa031c7 100644
--- a/storage/tokudb/mysql-test/tokudb/r/tokudb_support_xa.result
+++ b/storage/tokudb/mysql-test/tokudb/r/tokudb_support_xa.result
@@ -43,7 +43,7 @@ SET @@session.tokudb_support_xa = "T";
ERROR 42000: Variable 'tokudb_support_xa' can't be set to the value of 'T'
SET @@session.tokudb_support_xa = "Y";
ERROR 42000: Variable 'tokudb_support_xa' can't be set to the value of 'Y'
-SET @@session.tokudb_support_xa = OF;
+SET @@session.tokudb_support_xa = OFF;
SELECT @@session.tokudb_support_xa;
@@session.tokudb_support_xa
0
diff --git a/storage/tokudb/mysql-test/tokudb/t/tokudb_support_xa.test b/storage/tokudb/mysql-test/tokudb/t/tokudb_support_xa.test
index f0ad03b91ee..fa1efde7cf7 100644
--- a/storage/tokudb/mysql-test/tokudb/t/tokudb_support_xa.test
+++ b/storage/tokudb/mysql-test/tokudb/t/tokudb_support_xa.test
@@ -39,7 +39,7 @@ SET @@session.tokudb_support_xa = 1.6;
SET @@session.tokudb_support_xa = "T";
--Error ER_WRONG_VALUE_FOR_VAR
SET @@session.tokudb_support_xa = "Y";
-SET @@session.tokudb_support_xa = OF;
+SET @@session.tokudb_support_xa = OFF;
SELECT @@session.tokudb_support_xa;
# for global