| 1 |
## Resets the session to clear the session state |
| 2 |
|
| 3 |
--source include/no_ps_protocol.inc |
| 4 |
--source include/xplugin_preamble.inc |
| 5 |
--source include/xplugin_create_user.inc |
| 6 |
|
| 7 |
# Reset session test scenarios: |
| 8 |
# 1. Basic reset scenario |
| 9 |
# 2. Reset session variable |
| 10 |
# 3. Reset user variable |
| 11 |
# 4. Reset table lock |
| 12 |
# 5. Reset prepare statments |
| 13 |
# 6. Expect block is not reset |
| 14 |
# 7. Reset global variable |
| 15 |
|
| 16 |
|
| 17 |
## Test starts here |
| 18 |
--write_file $MYSQL_TMP_DIR/session_reset_keep_open.xpl |
| 19 |
-->import assert_select.macro |
| 20 |
-->import assert_variable.macro |
| 21 |
|
| 22 |
## MACROS |
| 23 |
|
| 24 |
-->macro Assert_session_id %EXPECT_ID% |
| 25 |
-->stmtadmin list_clients |
| 26 |
-->recvtovar %CURRENT_ID% sql_session |
| 27 |
-->assert_eq %EXPECT_ID% %CURRENT_ID% |
| 28 |
-->endmacro |
| 29 |
|
| 30 |
-->macro Assert_client_id %EXPECT_ID% |
| 31 |
-->stmtadmin list_clients |
| 32 |
-->recvtovar %CURRENT_ID% client_id |
| 33 |
-->assert_eq %EXPECT_ID% %CURRENT_ID% |
| 34 |
-->endmacro |
| 35 |
|
| 36 |
-->stmtadmin list_clients |
| 37 |
-->recvtovar %EXPECT_SESSION_ID% sql_session |
| 38 |
-->stmtadmin list_clients |
| 39 |
-->recvtovar %EXPECT_CLIENT_ID% client_id |
| 40 |
|
| 41 |
## TESTS |
| 42 |
|
| 43 |
-->title -Basic reset scenario |
| 44 |
Mysqlx.Session.Reset { |
| 45 |
keep_open:true |
| 46 |
} |
| 47 |
-->recvok |
| 48 |
-->callmacro Assert_session_id %EXPECT_SESSION_ID% |
| 49 |
-->callmacro Assert_client_id %EXPECT_CLIENT_ID% |
| 50 |
|
| 51 |
|
| 52 |
-->title -Check the pipelining |
| 53 |
-->stmtsql select 2.1 as value |
| 54 |
-->stmtsql select 2.2 as value |
| 55 |
Mysqlx.Session.Reset { |
| 56 |
keep_open:true |
| 57 |
} |
| 58 |
-->recvresult |
| 59 |
-->recvresult |
| 60 |
-->recvok |
| 61 |
-->callmacro Assert_session_id %EXPECT_SESSION_ID% |
| 62 |
-->callmacro Assert_client_id %EXPECT_CLIENT_ID% |
| 63 |
|
| 64 |
|
| 65 |
-->title -Reset session variable |
| 66 |
-->sql |
| 67 |
set lc_messages= pl_PL; |
| 68 |
-->endsql |
| 69 |
Mysqlx.Session.Reset { |
| 70 |
keep_open:true |
| 71 |
} |
| 72 |
-->recvok |
| 73 |
-->callmacro Assert_select result OK SELECT IF(@@lc_messages NOT LIKE 'pl_PL', 'OK', 'FAIL') AS result; |
| 74 |
-->callmacro Assert_session_id %EXPECT_SESSION_ID% |
| 75 |
-->callmacro Assert_client_id %EXPECT_CLIENT_ID% |
| 76 |
|
| 77 |
|
| 78 |
-->title -Reset user variable |
| 79 |
-->sql |
| 80 |
set @secret = 12345; |
| 81 |
-->endsql |
| 82 |
Mysqlx.Session.Reset { |
| 83 |
keep_open:true |
| 84 |
} |
| 85 |
-->recvok |
| 86 |
-->callmacro Assert_select result OK SELECT IF(@secret IS NULL, 'OK', 'FAIL') AS result; |
| 87 |
-->callmacro Assert_session_id %EXPECT_SESSION_ID% |
| 88 |
-->callmacro Assert_client_id %EXPECT_CLIENT_ID% |
| 89 |
|
| 90 |
|
| 91 |
-->title -Reset prepare statments |
| 92 |
Mysqlx.Prepare.Prepare { |
| 93 |
stmt_id: 123 |
| 94 |
stmt: { |
| 95 |
type: STMT |
| 96 |
stmt_execute: { |
| 97 |
stmt: "select 2.3" |
| 98 |
} |
| 99 |
} |
| 100 |
} |
| 101 |
-->recvok |
| 102 |
-->callmacro Assert_status_variable Prepared_stmt_count 1 |
| 103 |
Mysqlx.Session.Reset { |
| 104 |
keep_open:true |
| 105 |
} |
| 106 |
-->recvok |
| 107 |
Mysqlx.Prepare.Execute { |
| 108 |
stmt_id: 123 |
| 109 |
} |
| 110 |
-->recverror ER_X_BAD_STATEMENT_ID |
| 111 |
-->callmacro Assert_status_variable Prepared_stmt_count 0 |
| 112 |
-->callmacro Assert_session_id %EXPECT_SESSION_ID% |
| 113 |
-->callmacro Assert_client_id %EXPECT_CLIENT_ID% |
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
-->title -Reset table lock |
| 118 |
-->sql |
| 119 |
CREATE TABLE test.example1(value INT); |
| 120 |
CREATE TABLE test.example2(value INT); |
| 121 |
LOCK TABLES test.example2 READ; |
| 122 |
SELECT COUNT(*) FROM test.example2; |
| 123 |
-->endsql |
| 124 |
-->stmtsql SELECT COUNT(*) FROM test.example1; |
| 125 |
-->recverror ER_TABLE_NOT_LOCKED |
| 126 |
Mysqlx.Session.Reset { |
| 127 |
keep_open:true |
| 128 |
} |
| 129 |
-->recvok |
| 130 |
-->sql |
| 131 |
SELECT COUNT(*) FROM test.example1; |
| 132 |
SELECT COUNT(*) FROM test.example2; |
| 133 |
DROP TABLE test.example1; |
| 134 |
DROP TABLE test.example2; |
| 135 |
-->endsql |
| 136 |
-->callmacro Assert_session_id %EXPECT_SESSION_ID% |
| 137 |
-->callmacro Assert_client_id %EXPECT_CLIENT_ID% |
| 138 |
|
| 139 |
|
| 140 |
-->title -Expect block is not reset |
| 141 |
Mysqlx.Expect.Open { |
| 142 |
cond { |
| 143 |
condition_key: 1 |
| 144 |
} |
| 145 |
} |
| 146 |
-->recvok |
| 147 |
Mysqlx.Session.Reset { |
| 148 |
keep_open:true |
| 149 |
} |
| 150 |
-->recvok |
| 151 |
Mysqlx.Expect.Close { |
| 152 |
} |
| 153 |
-->recvok |
| 154 |
-->callmacro Assert_session_id %EXPECT_SESSION_ID% |
| 155 |
-->callmacro Assert_client_id %EXPECT_CLIENT_ID% |
| 156 |
|
| 157 |
-->title -Reset global variable |
| 158 |
-->sql |
| 159 |
set global max_connections = 1234; |
| 160 |
-->endsql |
| 161 |
Mysqlx.Session.Reset { |
| 162 |
keep_open:true |
| 163 |
} |
| 164 |
-->recvok |
| 165 |
-->callmacro Assert_select result OK SELECT IF(@@global.max_connections = 1234, 'OK', 'FAIL') AS result; |
| 166 |
-->callmacro Assert_session_id %EXPECT_SESSION_ID% |
| 167 |
-->callmacro Assert_client_id %EXPECT_CLIENT_ID% |
| 168 |
EOF |
| 169 |
|
| 170 |
exec $MYSQLXTEST |
| 171 |
-ux_root --password='' |
| 172 |
--file=$MYSQL_TMP_DIR/session_reset_keep_open.xpl 2>&1; |
| 173 |
|
| 174 |
|
| 175 |
## Cleanup |
| 176 |
set @@global.max_connections = default; |
| 177 |
--source ../include/xplugin_cleanup.inc |