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/t/view.test | |
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/t/view.test')
-rw-r--r-- | mysql-test/t/view.test | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index 3ad7b9483ac..48ff2285341 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -5826,6 +5826,55 @@ SELECT * FROM v1 where use_case_id = 10; drop view v1; drop table t1; +--echo # +--echo # MDEV-12666: CURRENT_ROLE() and DATABASE() does not work in a view +--echo # +--echo # DATABASE() fails only when the initial view creation features a NULL +--echo # default database. +--echo # +--echo # CREATE, USE and DROP database so that we have no "default" database. +--echo # +CREATE DATABASE temporary; +USE temporary; +DROP DATABASE temporary; +SELECT DATABASE(); + +CREATE VIEW test.v_no_db AS SELECT DATABASE() = 'temporary_two'; +SHOW CREATE VIEW test.v_no_db; +PREPARE prepared_no_database FROM "SELECT DATABASE() = 'temporary_two'"; + +--echo # +--echo # All statements should return NULL +--echo # +EXECUTE prepared_no_database; +SELECT DATABASE() = 'temporary_two'; +SELECT * FROM test.v_no_db; + +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'"; + +--echo # +--echo # All statements should return 1; +--echo # +SELECT DATABASE() = 'temporary_two'; +SELECT * FROM test.v_no_db; +SELECT * FROM test.v_with_db; +EXECUTE prepared_with_database; + +--echo # +--echo # Prepared statements maintain default database to be the same +--echo # during on creation so this should return NULL still. +--echo # See MySQL bug #25843 +--echo # +EXECUTE prepared_no_database; + +DROP DATABASE temporary_two; +DROP VIEW test.v_no_db; +DROP VIEW test.v_with_db; +USE test; + --echo # ----------------------------------------------------------------- --echo # -- End of 10.0 tests. --echo # ----------------------------------------------------------------- |