diff options
author | Vicențiu Ciorbaru <vicentiu@mariadb.org> | 2017-06-27 16:34:36 +0300 |
---|---|---|
committer | Vicențiu Ciorbaru <vicentiu@mariadb.org> | 2017-06-27 16:34:36 +0300 |
commit | 330792f3c3c5007dd92912b9d1d32da178b5b9fd (patch) | |
tree | 2137a9bab3d0cf21d771c298379694e504745288 /mysql-test/r/view.result | |
parent | 3125ba891292ff16186c105b6780fbadc74421e9 (diff) | |
parent | 32659db8644504940f8d34835fde8f7b6535f1ee (diff) | |
download | mariadb-git-330792f3c3c5007dd92912b9d1d32da178b5b9fd.tar.gz |
Merge branch 'bb-10.1-vicentiu' into 10.1
Diffstat (limited to 'mysql-test/r/view.result')
-rw-r--r-- | mysql-test/r/view.result | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 0ded1dd4cb3..cf1ad1053f1 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -5976,6 +5976,68 @@ use_case_id InitialDeadline 10 2015-12-18 drop view v1; drop table t1; +# +# MDEV-12666: CURRENT_ROLE() and DATABASE() does not work in a view +# +# DATABASE() fails only when the initial view creation features a NULL +# default database. +# +# CREATE, USE and DROP database so that we have no "default" database. +# +CREATE DATABASE temporary; +USE temporary; +DROP DATABASE temporary; +SELECT DATABASE(); +DATABASE() +NULL +CREATE VIEW test.v_no_db AS SELECT DATABASE() = 'temporary_two'; +SHOW CREATE VIEW test.v_no_db; +View Create View character_set_client collation_connection +v_no_db CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `test`.`v_no_db` AS select (database() = 'temporary_two') AS `DATABASE() = 'temporary_two'` latin1 latin1_swedish_ci +PREPARE prepared_no_database FROM "SELECT DATABASE() = 'temporary_two'"; +# +# All statements should return NULL +# +EXECUTE prepared_no_database; +DATABASE() = 'temporary_two' +NULL +SELECT DATABASE() = 'temporary_two'; +DATABASE() = 'temporary_two' +NULL +SELECT * FROM test.v_no_db; +DATABASE() = 'temporary_two' +NULL +CREATE DATABASE temporary_two; +USE temporary_two; +CREATE VIEW test.v_with_db AS SELECT DATABASE() = 'temporary_two'; +PREPARE prepared_with_database FROM "SELECT DATABASE() = 'temporary_two'"; +# +# All statements should return 1; +# +SELECT DATABASE() = 'temporary_two'; +DATABASE() = 'temporary_two' +1 +SELECT * FROM test.v_no_db; +DATABASE() = 'temporary_two' +1 +SELECT * FROM test.v_with_db; +DATABASE() = 'temporary_two' +1 +EXECUTE prepared_with_database; +DATABASE() = 'temporary_two' +1 +# +# Prepared statements maintain default database to be the same +# during on creation so this should return NULL still. +# See MySQL bug #25843 +# +EXECUTE prepared_no_database; +DATABASE() = 'temporary_two' +NULL +DROP DATABASE temporary_two; +DROP VIEW test.v_no_db; +DROP VIEW test.v_with_db; +USE test; # ----------------------------------------------------------------- # -- End of 10.0 tests. # ----------------------------------------------------------------- |