diff options
author | Vicențiu Ciorbaru <vicentiu@mariadb.org> | 2017-06-21 16:19:43 +0300 |
---|---|---|
committer | Vicențiu Ciorbaru <vicentiu@mariadb.org> | 2017-06-21 16:19:43 +0300 |
commit | 2e335a471ced0d86716f8c657f4d67f510712a30 (patch) | |
tree | 6fa56f9d9083007e874449b9c2b27579f718ed94 /mysql-test/t/view.test | |
parent | 472c2d9b2fbb262665bdd08338ea902e8398010d (diff) | |
parent | 8baf9b0c469e2845d15cc1181bc6b101cdfba087 (diff) | |
download | mariadb-git-2e335a471ced0d86716f8c657f4d67f510712a30.tar.gz |
Merge remote-tracking branch '10.0' 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 7a935838216..ce2ceaab292 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 # ----------------------------------------------------------------- |