File: gtid_disconnect_drop_temporary_table.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 (125 lines) | stat: -rw-r--r-- 3,192 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
# ==== Purpose ====
#
# When a client disconnects, temporary tables created by the client
# are dropped.  This test verifies that this works regardless of what
# GTID_NEXT has been set to.
#
# The following are tested:
#
# - GTID_NEXT is set and no transaction started.
# - GTID_NEXT is set and transaction started but not ended.
# - GTID_NEXT is set and transaction committed.
# - GTID_NEXT is set and transaction rolled back.
#
# The test is run both with gtid_mode=on and gtid_mode=off. If
# gtid_mode=on, it sets gtid_next='UUID:NUMBER'. If gtid_mode=off, it
# sets gtid_next='ANONYMOUS'.
#
# ==== Implementation ====
#
# The core of the logic is: Create a connection. Create a temporary
# table on the connection. Set GTID_NEXT. Disconnect.
#
# The test does this four times, each time doing something different
# between set gtid_next and disconnect.
#
# The test uses include/set_gtid_next_gtid_mode_agnostic.inc to set
# gtid_next to 'UUID:NUMBER' if gtid_mode=on and 'ANONYMOUS' if
# gtid_mode=off.

--source include/not_group_replication_plugin.inc
--let $rpl_gtid_utils= 1
--source include/master-slave.inc

--let $i= 1

CREATE TABLE t (a INT);

while ($i <= 4)
{
  if ($i == 1)
  {
    --echo ---- 1. Disconnect after SET GTID_NEXT ----
  }
  if ($i == 2)
  {
    --echo ---- 2. Disconnect in the middle of transaction ----
  }
  if ($i == 3)
  {
    --echo ---- 3. Disconnect after COMMIT ----
  }
  if ($i == 4)
  {
    --echo ---- 4. Disconnect after ROLLBACK ----
  }

  # Create con1.
  --let $rpl_connection_name= con1
  --let $rpl_server_number= 1
  --source include/rpl_connect.inc

  --let $rpl_connection_name= con1
  --source include/rpl_connection.inc

  # Create temp table.
  CREATE TEMPORARY TABLE tt (a INT);

  # Set gtid_next
  --source include/set_gtid_next_gtid_mode_agnostic.inc

  # Execute (partial) transaction
  if ($i >= 2)
  {
    BEGIN;
    INSERT INTO t VALUES (1);

    if ($i == 3)
    {
      COMMIT;
    }
    if ($i == 4)
    {
      ROLLBACK;
    }
  }

  --connection master
  --source include/save_binlog_position.inc
  --source include/gtid_step_reset.inc

  # Disconnect
  --echo # Disconnecting.
  --disconnect con1

  if (`SELECT @@GLOBAL.binlog_format = 'STATEMENT'`)
  {
    # Verify that the binlog contains the expected events.
    --let $event_sequence= (Anonymous_)?Gtid # !Q(DROP.*TEMPORARY.*)
    --let $wait_for_binlog_events= 1
    --source include/assert_binlog_events.inc
  }

  # Sync with slave and assert slave has dropped the temp table.
  --source include/sync_slave_sql_with_master.inc
  --let $assert_text= Slave should not have any open temporary tables.
  --let $assert_cond= VARIABLE_VALUE = 0 FROM performance_schema.global_status WHERE VARIABLE_NAME = "REPLICA_OPEN_TEMP_TABLES"
  --source include/assert.inc
  # Verify that one gtid was added if gtid_mode=on
  --connection master
  --let $gtid_step_gtid_mode_agnostic= 1
  --let $gtid_step_count= 0
  if (`SELECT @@GLOBAL.binlog_format = 'STATEMENT'`)
  {
    --let $gtid_step_count= 1
  }
  --source include/gtid_step_assert.inc

  --inc $i
}

--echo ---- Clean up ----

DROP TABLE t;
--source include/sync_slave_sql_with_master.inc
--source include/rpl_end.inc