File: drop_table_consistency.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (136 lines) | stat: -rw-r--r-- 3,181 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#
# Check the behavior when a table is dropped from NDB using
# 'ndb_drop_table' and there's a subsequent attempt to drop
# the table using an SQL command i.e. DROP TABLE or DROP
# DATABASE. This test checks if
# - The table is removed on all the participants
# - Table events (if any) have been removed in such cases
#

# Connect to all MySQL Servers
--source connect.inc

# Create a normal user table in NDB. Such tables always have an
# associated event created
CREATE TABLE t1 (
  a int PRIMARY KEY,
  b varchar(255)
) ENGINE NDB;
# Check that CREATE TABLE has been distributed
--let $counter = 1
while ($counter <= 6)
{
  --let $mysqld_name = mysqld$counter
  --connection $mysqld_name
  SHOW TABLES;
  --inc $counter
}

--echo Drop the table using ndb_drop_table
--exec $NDB_DROP_TABLE -d test t1 >> $NDB_TOOLS_OUTPUT

--error ER_TABLE_DEF_CHANGED
SHOW CREATE TABLE t1;
SHOW WARNINGS;
DROP TABLE t1;
# Check that DROP TABLE has been distributed
--let $counter = 1
while ($counter <= 6)
{

  --let $mysqld_name = mysqld$counter
  --connection $mysqld_name
  SHOW TABLES;
  --inc $counter
}

# Check that event has been dropped
let $check_event_dbname = test;
let $check_event_tabname = t1;
--source check_event_for_table.inc

--connection mysqld2
# Create a table with hidden PK. Such tables don't have events
CREATE TABLE t1 (
  a int,
  b varchar(255)
) ENGINE NDB;
# Check that CREATE TABLE has been distributed
--let $counter = 1
while ($counter <= 6)
{
  --let $mysqld_name = mysqld$counter
  --connection $mysqld_name
  SHOW TABLES;
  --inc $counter
}

--echo Drop the table using ndb_drop_table
--exec $NDB_DROP_TABLE -d test t1 >> $NDB_TOOLS_OUTPUT

--disable_query_log ONCE
call mtr.add_suppression("Incorrect information in file");
--error ER_TABLE_DEF_CHANGED
SHOW CREATE TABLE t1;
SHOW WARNINGS;
DROP TABLE t1;
# Check that DROP TABLE has been distributed
--let $counter = 1
while ($counter <= 6)
{

  --let $mysqld_name = mysqld$counter
  --connection $mysqld_name
  SHOW TABLES;
  --inc $counter
}

--connection mysqld3
# Create 1 database and 2 tables
CREATE DATABASE ndb_ddl_test3;
USE ndb_ddl_test3;
CREATE TABLE t1 (
  a int PRIMARY KEY,
  b varchar(255)
) ENGINE NDB;
CREATE TABLE t2 (
  a int PRIMARY KEY,
  b varchar(255)
) ENGINE NDB;

# Check that CREATE TABLE has been distributed
--let $counter = 1
while ($counter <= 6)
{
  --let $mysqld_name = mysqld$counter
  --connection $mysqld_name
  SHOW TABLES IN ndb_ddl_test3;
  --inc $counter
}

--connection mysqld3
--echo Drop the table using ndb_drop_table
--exec $NDB_DROP_TABLE -d ndb_ddl_test3 t1 >> $NDB_TOOLS_OUTPUT

DROP DATABASE ndb_ddl_test3;

# Check that event has been dropped
let $check_event_dbname = ndb_ddl_test3;
let $check_event_tabname = t1;
--source check_event_for_table.inc
let $check_event_dbname = ndb_ddl_test3;
let $check_event_tabname = t2;
--source check_event_for_table.inc

--connection mysqld4
# Now we check if the table has been removed on a participant by creating
# the same table again
CREATE DATABASE ndb_ddl_test3;
USE ndb_ddl_test3;
CREATE TABLE t1 (
  a int PRIMARY KEY,
  b varchar(255)
) ENGINE NDB;
DROP DATABASE ndb_ddl_test3;

--remove_file $NDB_TOOLS_OUTPUT