| 1 |
########### suite/sysschema/t/pr_create_synonym_db.test ############# |
| 2 |
# # |
| 3 |
# Testing of of the sys.pr_create_synonym_db() procedure # |
| 4 |
# # |
| 5 |
# Creation: # |
| 6 |
# 2016-05-23 jkrogh Implement this test as part of bug 22011361 # |
| 7 |
# # |
| 8 |
##################################################################### |
| 9 |
|
| 10 |
# Create a couple of tables and a view |
| 11 |
CREATE TABLE t1 (t1_id int PRIMARY KEY, t1_val varchar(10)); |
| 12 |
CREATE TABLE t2 (t2_id int PRIMARY KEY, t1_id int, t2_val int, INDEX (t1_id)); |
| 13 |
CREATE TABLE `is` (t1_id int PRIMARY KEY, t1_val varchar(10)); |
| 14 |
CREATE TABLE `ab``c` (t1_id int PRIMARY KEY, t1_val varchar(10)); |
| 15 |
CREATE SQL SECURITY INVOKER VIEW myview AS SELECT * FROM t1 NATURAL JOIN t2; |
| 16 |
|
| 17 |
# Make synonym db of test into test1 |
| 18 |
CALL sys.create_synonym_db('test', 'test1'); |
| 19 |
# Verify there's one view in test1 per table and view in test |
| 20 |
SELECT TABLE_NAME, SECURITY_TYPE FROM information_schema.VIEWS WHERE TABLE_SCHEMA = 'test1' ORDER BY TABLE_NAME; |
| 21 |
# Try again (should fail) |
| 22 |
-- error ER_SIGNAL_EXCEPTION |
| 23 |
CALL sys.create_synonym_db('test', 'test1'); |
| 24 |
|
| 25 |
# Try to make the synonym db for an existing empty schema |
| 26 |
CREATE SCHEMA test2; |
| 27 |
-- error ER_SIGNAL_EXCEPTION |
| 28 |
CALL sys.create_synonym_db('test', 'test2'); |
| 29 |
# Ensure test2 is still empty |
| 30 |
SELECT COUNT(*) FROM information_schema.TABLES WHERE TABLE_SCHEMA = 'test2'; |
| 31 |
|
| 32 |
# Use a reserved identifer, Bug #22011361 |
| 33 |
CALL sys.create_synonym_db('test', 'is'); |
| 34 |
# Verify there's one view in is per table and view in test |
| 35 |
SELECT TABLE_NAME, SECURITY_TYPE FROM information_schema.VIEWS WHERE TABLE_SCHEMA = 'is' ORDER BY TABLE_NAME; |
| 36 |
|
| 37 |
# Copy the is schema to i`s schema: |
| 38 |
CALL sys.create_synonym_db('is', 'i`s'); |
| 39 |
# Verify there's one view in i`s per table and view in is |
| 40 |
SELECT TABLE_NAME, SECURITY_TYPE FROM information_schema.VIEWS WHERE TABLE_SCHEMA = 'i`s' ORDER BY TABLE_NAME; |
| 41 |
|
| 42 |
# Clean up |
| 43 |
DROP SCHEMA test1; |
| 44 |
DROP SCHEMA test2; |
| 45 |
DROP SCHEMA `is`; |
| 46 |
DROP SCHEMA `i``s`; |
| 47 |
DROP VIEW test.myview; |
| 48 |
DROP TABLE test.t1; |
| 49 |
DROP TABLE test.t2; |
| 50 |
DROP TABLE `is`; |
| 51 |
DROP TABLE `ab``c`; |