mariadb/mysql-test/suite/sysschema/r/pr_create_synonym_db.result
anel c1063a1bed MDEV-28342: sys.create_synonym_db fails when a temporary table masks a base table
- This commit rely on MDEV-28391
- When temporary table shadows the base table, error is raised (it can be changed if needed),
  since the procedure is relying on creating the views and view cannot be created from the temporary table.

- Reviewed by: <wlad@mariadb.com>
2022-05-12 10:28:13 -05:00

66 lines
2 KiB
Text

CREATE TABLE t1 (t1_id int PRIMARY KEY, t1_val varchar(10));
CREATE TABLE t2 (t2_id int PRIMARY KEY, t1_id int, t2_val int, INDEX (t1_id));
CREATE TABLE `is` (t1_id int PRIMARY KEY, t1_val varchar(10));
CREATE TABLE `ab``c` (t1_id int PRIMARY KEY, t1_val varchar(10));
CREATE SQL SECURITY INVOKER VIEW myview AS SELECT * FROM t1 NATURAL JOIN t2;
CALL sys.create_synonym_db('test', 'test1');
summary
Created 5 views in the `test1` database
SELECT TABLE_NAME, SECURITY_TYPE FROM information_schema.VIEWS WHERE TABLE_SCHEMA = 'test1' ORDER BY TABLE_NAME;
TABLE_NAME SECURITY_TYPE
ab`c INVOKER
is INVOKER
myview INVOKER
t1 INVOKER
t2 INVOKER
CALL sys.create_synonym_db('test', 'test1');
ERROR HY000: Can't create database test1; database exists
CREATE SCHEMA test2;
CALL sys.create_synonym_db('test', 'test2');
ERROR HY000: Can't create database test2; database exists
SELECT COUNT(*) FROM information_schema.TABLES WHERE TABLE_SCHEMA = 'test2';
COUNT(*)
0
CALL sys.create_synonym_db('test', 'is');
summary
Created 5 views in the `is` database
SELECT TABLE_NAME, SECURITY_TYPE FROM information_schema.VIEWS WHERE TABLE_SCHEMA = 'is' ORDER BY TABLE_NAME;
TABLE_NAME SECURITY_TYPE
ab`c INVOKER
is INVOKER
myview INVOKER
t1 INVOKER
t2 INVOKER
CALL sys.create_synonym_db('is', 'i`s');
summary
Created 5 views in the `i``s` database
SELECT TABLE_NAME, SECURITY_TYPE FROM information_schema.VIEWS WHERE TABLE_SCHEMA = 'i`s' ORDER BY TABLE_NAME;
TABLE_NAME SECURITY_TYPE
ab`c INVOKER
is INVOKER
myview INVOKER
t1 INVOKER
t2 INVOKER
DROP SCHEMA test1;
DROP SCHEMA test2;
DROP SCHEMA `is`;
DROP SCHEMA `i``s`;
DROP VIEW test.myview;
DROP TABLE test.t1;
DROP TABLE test.t2;
DROP TABLE `is`;
DROP TABLE `ab``c`;
#
# MDEV-28342: sys.create_synonym_db fails
# when a temporary table masks a base table
#
create database db;
use db;
create table a(a int);
create table t (b int);
create table b(a int);
create temporary table b (a int);
call sys.create_synonym_db('db','db_copy');
ERROR HY000: Table`db`.`b`shadows base table. View cannot be created! Terminating!
drop database db;
drop database db_copy;