diff options
author | Michael Widenius <monty@mariadb.org> | 2018-03-09 14:05:35 +0200 |
---|---|---|
committer | Monty <monty@mariadb.org> | 2018-03-29 13:59:44 +0300 |
commit | a7abddeffa6a760ce948c2dfb007cdf3f1a369d5 (patch) | |
tree | 70eb743fa965a17380bbc0ac88ae79ca1075b896 /mysql-test/main/default_session.test | |
parent | ab1941266c59a19703a74b5593cf3f508a5752d7 (diff) | |
download | mariadb-git-a7abddeffa6a760ce948c2dfb007cdf3f1a369d5.tar.gz |
Create 'main' test directory and move 't' and 'r' there
Diffstat (limited to 'mysql-test/main/default_session.test')
-rw-r--r-- | mysql-test/main/default_session.test | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/mysql-test/main/default_session.test b/mysql-test/main/default_session.test new file mode 100644 index 00000000000..7796354ffd4 --- /dev/null +++ b/mysql-test/main/default_session.test @@ -0,0 +1,82 @@ +# +# DEFAULT clause with functions that depend on the current session state +# + +source include/not_embedded.inc; + +create database mysqltest1; + +create user ''@localhost; +create user foo@localhost; +create role bar; +grant select on *.* to ''@localhost; +grant select,insert on *.* to foo@localhost; +grant select,insert on *.* to bar; +grant bar to ''@localhost; + +create table t1 (n varchar(100), + u varchar(100) default user(), + cu varchar(100) default current_user(), + cr varchar(100) default current_role(), + d varchar(100) default database()); + +create definer=foo@localhost view mysqltest1.v1 as select * from t1; +create definer=bar view v2 as select * from t1; +create view v3 as select * from v2; + +create definer=foo@localhost view mysqltest1.v4 as select default(n),default(u),default(cu),default(cr), default(d) from t1; +create definer=bar view v5 as select default(n),default(u),default(cu),default(cr), default(d) from t1; +create view v6 as select * from v5; + +insert t1 (n) values ('t1'); +insert mysqltest1.v1 (n) values ('v1'); +insert v2 (n) values ('v2'); +insert v3 (n) values ('v3'); + +select default(n),default(u),default(cu),default(cr), default(d) from t1 limit 1; +select * from mysqltest1.v4 limit 1; +select * from v5 limit 1; +select * from v6 limit 1; + +connect (conn,localhost,conn,,mysqltest1); +set role bar; +insert test.t1 (n) values ('t1'); +insert v1 (n) values ('v1'); +insert test.v2 (n) values ('v2'); +insert test.v3 (n) values ('v3'); + +select default(n),default(u),default(cu),default(cr), default(d) from test.t1 limit 1; +select * from v4 limit 1; +select * from test.v5 limit 1; +select * from test.v6 limit 1; +connection default; +disconnect conn; + +select * from t1; +drop database mysqltest1; +drop view v2, v3, v5, v6; +drop table t1; +drop user ''@localhost; +drop user foo@localhost; +drop role bar; + +create table t1 (a date, + mn varchar(100) default monthname(a), + dn varchar(100) default dayname(a), + df varchar(100) default date_format(a, "%a, %b")); + +insert t1 (a) values ('2010-12-2'); +set lc_time_names=de_DE; +insert t1 (a) values ('2010-12-2'); +set lc_time_names=default; + +select * from t1; +drop table t1; + +create table t1 (a varchar(100) default @@sql_mode); +insert t1 () values (); +set sql_mode=ansi; +insert t1 () values (); +set sql_mode=default; +select * from t1; +drop table t1; |