mariadb/mysql-test/suite/sysschema/r/pr_create_synonym_db.result
Anel Husakovic 1fb4828b28 MDEV-28343: sys.create_synonym_db fails with ER_VIEW_SELECT_TMPTABLE when schema contains temporary tables
- MDEV-28342 raised the error in case temporary table shadows base table
- Now we are allowed to shadow base tables with temporary tables and
`sys.create_synonym_db()` can easily check for existance of temporary table and
ignore view creation, since it is not supported to create view from
temporary table.

Reviewed-by: <monty@mariadb.org>,
             <vicentiu@mariadb.org>
2023-08-11 19:36:21 +02:00

97 lines
2.7 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');
summary
Created 2 views in the `db_copy` database
use db_copy;
show tables;
Tables_in_db_copy
a
t
drop database db;
drop database db_copy;
# MDEV-28343: sys.create_synonym_db fails with ER_VIEW_SELECT_TMPTABLE
# when schema contains temporary tables
#
create database mytestdb;
use mytestdb;
create table t (b int);
create temporary table tmp (a int);
call sys.create_synonym_db('mytestdb','db_syn1');
summary
Created 1 view in the `db_syn1` database
use db_syn1;
show tables;
Tables_in_db_syn1
t
drop database db_syn1;
use mytestdb;
create temporary table t (b int);
call sys.create_synonym_db('mytestdb','db_syn1');
summary
Created 0 views in the `db_syn1` database
use db_syn1;
show tables;
Tables_in_db_syn1
drop database mytestdb;
drop database db_syn1;