File: galera_create_table_like.test

package info (click to toggle)
mariadb-10.1 10.1.45-0%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 476,916 kB
  • sloc: cpp: 1,124,656; ansic: 871,843; perl: 52,917; sh: 40,078; pascal: 35,370; javascript: 15,555; yacc: 14,728; ruby: 8,684; xml: 5,377; sql: 3,490; makefile: 2,934; python: 1,970; java: 1,691; asm: 837; lex: 757; php: 22; sed: 16
file content (50 lines) | stat: -rw-r--r-- 2,176 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
--source include/galera_cluster.inc
--source include/have_innodb.inc

#
# Test the various forms of CREATE TABLE LIKE ... , since Galera has special handling
# for them, especially when one of the tables is a temporary one.
#

CREATE SCHEMA schema1;
CREATE SCHEMA schema2;

USE schema1;
CREATE TABLE real_table (f1 INTEGER) ENGINE=InnoDB;
CREATE TEMPORARY TABLE temp_table (f1 INTEGER) ENGINE=InnoDB;
CREATE TABLE myisam_table (f1 INTEGER) ENGINE=MyISAM;

USE schema2;
CREATE TABLE real_table1 LIKE schema1.real_table;
CREATE TABLE real_table2 LIKE schema1.temp_table;
CREATE TABLE real_table3 LIKE schema1.myisam_table;

CREATE TEMPORARY TABLE temp_table1 LIKE schema1.real_table;
CREATE TEMPORARY TABLE temp_table2 LIKE schema1.temp_table;
CREATE TEMPORARY TABLE temp_table3 LIKE schema1.myisam_table;

--connection node_2
# Only the non-temporary tables are replicated, regardless of the type of table they are based on

SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'real_table' AND TABLE_SCHEMA = 'schema1';
SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'myisam_table' AND TABLE_SCHEMA = 'schema1';
SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'temp_table' AND TABLE_SCHEMA = 'schema1';

SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'real_table1' AND TABLE_SCHEMA = 'schema2';
SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'real_table2' AND TABLE_SCHEMA = 'schema2';
SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'real_table3' AND TABLE_SCHEMA = 'schema2';

SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'temp_table1' AND TABLE_SCHEMA = 'schema2';
SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'temp_table2' AND TABLE_SCHEMA = 'schema2';
SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'temp_table3' AND TABLE_SCHEMA = 'schema2';

--connection node_1
DROP TABLE schema1.real_table;
DROP TABLE schema1.myisam_table;

DROP TABLE schema2.real_table1;
DROP TABLE schema2.real_table2;
DROP TABLE schema2.real_table3;

DROP SCHEMA schema1;
DROP SCHEMA schema2;