| 1 |
########### ../t/connection_unixsocket_rpl.test ######### |
| 2 |
## WL#9306 # |
| 3 |
## This test aims to run crud message on replication setup. # |
| 4 |
## Test runs following message on master and checks data on slave # |
| 5 |
## - create_collection message # |
| 6 |
## - Insert message # |
| 7 |
## - create_collection_index # |
| 8 |
## - update message # |
| 9 |
## - delete message # |
| 10 |
####################################################################### |
| 11 |
|
| 12 |
--source include/not_windows.inc |
| 13 |
--source include/master-slave.inc |
| 14 |
--source include/count_sessions.inc |
| 15 |
--source ../include/have_performance_schema_threads.inc |
| 16 |
|
| 17 |
|
| 18 |
# Use master connection |
| 19 |
--connection master |
| 20 |
|
| 21 |
--source include/xplugin_preamble.inc |
| 22 |
call mtr.add_suppression("Error parsing message of type 12: args"); |
| 23 |
call mtr.add_suppression("Error handling message: args"); |
| 24 |
|
| 25 |
CREATE USER user_localhost@localhost IDENTIFIED WITH 'mysql_native_password' BY ''; |
| 26 |
GRANT ALL ON *.* TO user_localhost@localhost; |
| 27 |
|
| 28 |
## Test starts here |
| 29 |
--write_file $MYSQL_TMP_DIR/mysqlx-in.tmp |
| 30 |
## Checking connection type |
| 31 |
-->stmtsql SELECT CONNECTION_TYPE from performance_schema.threads where processlist_command='Query'; |
| 32 |
-->recvresult |
| 33 |
-->sql |
| 34 |
#-- "Creating database for testcase" |
| 35 |
DROP DATABASE IF EXISTS xplugintest; |
| 36 |
CREATE DATABASE xplugintest; |
| 37 |
USE xplugintest; |
| 38 |
CREATE TABLE table1 ( _id INT PRIMARY KEY, doc JSON ) ; |
| 39 |
-->endsql |
| 40 |
|
| 41 |
#-- "Create table table2 in xplugintest " |
| 42 |
|
| 43 |
-->stmtadmin create_collection {"schema":"xplugintest","name":"table2"} |
| 44 |
-->recvresult |
| 45 |
|
| 46 |
-->echo Insert multiple rows into a Document column |
| 47 |
Mysqlx.Crud.Insert { |
| 48 |
collection { |
| 49 |
name: "table2" |
| 50 |
schema: "xplugintest" |
| 51 |
} |
| 52 |
data_model: DOCUMENT |
| 53 |
row { |
| 54 |
field { |
| 55 |
type: LITERAL |
| 56 |
literal { |
| 57 |
type: V_STRING |
| 58 |
v_string { |
| 59 |
value: "\n{\n \"_id\": \"1\",\n \"name\": \"Omar Bras\", \"id\": \"1\"\n}" |
| 60 |
} |
| 61 |
} |
| 62 |
} |
| 63 |
} |
| 64 |
row { |
| 65 |
field { |
| 66 |
type: LITERAL |
| 67 |
literal { |
| 68 |
type: V_STRING |
| 69 |
v_string { |
| 70 |
value: "\n{\n \"_id\": \"2\",\n \"name\": \"Omar Mex\", \"id\": \"2\"\n}" |
| 71 |
} |
| 72 |
} |
| 73 |
} |
| 74 |
} |
| 75 |
} |
| 76 |
-->recvresult |
| 77 |
-->sql |
| 78 |
SELECT * FROM xplugintest.table2; |
| 79 |
-->endsql |
| 80 |
|
| 81 |
|
| 82 |
#-- "Index with unique(true), index column NOT NULL (true)" |
| 83 |
-->stmtadmin create_collection_index {"schema":"xplugintest", "collection":"table2", "name":"name_index", "unique":true, "fields":{"field":"$.name", "type":"TEXT(50)","required":true}} |
| 84 |
-->recvresult |
| 85 |
-->sql |
| 86 |
SHOW CREATE TABLE xplugintest.table2; |
| 87 |
SELECT * FROM xplugintest.table2; |
| 88 |
-->endsql |
| 89 |
|
| 90 |
|
| 91 |
-->echo Update decimal value with a corner value plus 1 |
| 92 |
Mysqlx.Crud.Update { |
| 93 |
collection { |
| 94 |
name: "table2" |
| 95 |
schema: "xplugintest" |
| 96 |
} |
| 97 |
data_model: DOCUMENT |
| 98 |
criteria { |
| 99 |
type: OPERATOR |
| 100 |
operator { |
| 101 |
name: "==" |
| 102 |
param { |
| 103 |
type: IDENT identifier { name: "_id" } |
| 104 |
} |
| 105 |
param { |
| 106 |
type: LITERAL |
| 107 |
literal { |
| 108 |
type: V_SINT |
| 109 |
v_signed_int: 2 |
| 110 |
} |
| 111 |
} |
| 112 |
} |
| 113 |
} |
| 114 |
operation { |
| 115 |
source { |
| 116 |
document_path { |
| 117 |
type: MEMBER |
| 118 |
value: "name" |
| 119 |
} |
| 120 |
} |
| 121 |
operation: ITEM_SET |
| 122 |
value { |
| 123 |
type: LITERAL |
| 124 |
literal { |
| 125 |
type: V_STRING |
| 126 |
v_string { |
| 127 |
value: "\"Omar Argentina\"" |
| 128 |
} |
| 129 |
} |
| 130 |
} |
| 131 |
} |
| 132 |
} |
| 133 |
-->recvresult |
| 134 |
|
| 135 |
|
| 136 |
-->sql |
| 137 |
SHOW CREATE TABLE xplugintest.table2; |
| 138 |
SELECT JSON_EXTRACT(doc,'$.name') FROM xplugintest.table2; |
| 139 |
SELECT * FROM xplugintest.table2; |
| 140 |
-->endsql |
| 141 |
|
| 142 |
-->echo Delete with == operator |
| 143 |
Mysqlx.Crud.Delete { |
| 144 |
collection { |
| 145 |
name: "table2" |
| 146 |
schema: "xplugintest" |
| 147 |
} |
| 148 |
data_model: DOCUMENT |
| 149 |
criteria { |
| 150 |
type: OPERATOR |
| 151 |
operator { |
| 152 |
name: "==" |
| 153 |
param { |
| 154 |
type: IDENT identifier { name: "_id" } |
| 155 |
} |
| 156 |
param { |
| 157 |
type: LITERAL |
| 158 |
literal { |
| 159 |
type: V_SINT |
| 160 |
v_signed_int: 2 |
| 161 |
} |
| 162 |
} |
| 163 |
} |
| 164 |
} |
| 165 |
} |
| 166 |
-->recvresult |
| 167 |
|
| 168 |
-->sql |
| 169 |
SELECT JSON_EXTRACT(doc,'$.name') FROM xplugintest.table2; |
| 170 |
SELECT * FROM xplugintest.table2; |
| 171 |
-->endsql |
| 172 |
|
| 173 |
|
| 174 |
Mysqlx.Crud.Insert { |
| 175 |
collection { |
| 176 |
name: "table2" |
| 177 |
schema: "xplugintest" |
| 178 |
} |
| 179 |
data_model: DOCUMENT |
| 180 |
row { |
| 181 |
field { |
| 182 |
type: LITERAL |
| 183 |
literal { |
| 184 |
type: V_STRING |
| 185 |
v_string { |
| 186 |
value: "\n{\n \"_id\": \"3\",\n \"name\": \"Omar Peru\", \"id\": \"3\"\n}" |
| 187 |
} |
| 188 |
} |
| 189 |
} |
| 190 |
} |
| 191 |
} |
| 192 |
-->recvresult |
| 193 |
|
| 194 |
# Insert fail due to non unique _id doc member |
| 195 |
Mysqlx.Crud.Insert { |
| 196 |
collection { |
| 197 |
name: "table2" |
| 198 |
schema: "xplugintest" |
| 199 |
} |
| 200 |
data_model: DOCUMENT |
| 201 |
row { |
| 202 |
field { |
| 203 |
type: LITERAL |
| 204 |
literal { |
| 205 |
type: V_STRING |
| 206 |
v_string { |
| 207 |
value: "\n{\n \"_id\": \"1\",\n \"name\": \"Omar Colombia\", \"id\": \"3\"\n}" |
| 208 |
} |
| 209 |
} |
| 210 |
} |
| 211 |
} |
| 212 |
} |
| 213 |
# Error |
| 214 |
-->expecterror 5116 |
| 215 |
-->recvresult |
| 216 |
|
| 217 |
-->sql |
| 218 |
SELECT * FROM xplugintest.table2; |
| 219 |
-->endsql |
| 220 |
|
| 221 |
# Insert into table1 |
| 222 |
-->sql |
| 223 |
INSERT INTO xplugintest.table1 VALUES (1,'{"a":["x", "y"]}'), (2,'{"b":["x", "y"]}'); |
| 224 |
-->endsql |
| 225 |
-->expecterror 1062 |
| 226 |
-->sql |
| 227 |
INSERT INTO xplugintest.table1 VALUES (3,'{"c":["x", "y"]}'), (2,'{"d":["x", "y"]}'); |
| 228 |
SELECT * FROM xplugintest.table1 ; |
| 229 |
UPDATE xplugintest.table1 SET doc= '{"m":["x", "y"]}' WHERE _id=1; |
| 230 |
SELECT * FROM xplugintest.table1 ; |
| 231 |
-->endsql |
| 232 |
|
| 233 |
EOF |
| 234 |
|
| 235 |
--exec $MYSQLXTEST --socket=$MASTER_X_MYSOCK -u user_localhost -h localhost --password='' --file=$MYSQL_TMP_DIR/mysqlx-in.tmp 2>&1 |
| 236 |
--remove_file $MYSQL_TMP_DIR/mysqlx-in.tmp |
| 237 |
|
| 238 |
--source include/sync_slave_sql_with_master.inc |
| 239 |
#-- connection slave |
| 240 |
--echo # Connection:slave - Row with value 2 is expected on slave. |
| 241 |
USE xplugintest; |
| 242 |
SHOW CREATE TABLE xplugintest.table2; |
| 243 |
SELECT * FROM xplugintest.table2; |
| 244 |
SELECT * FROM xplugintest.table1; |
| 245 |
--let $diff_tables= master:xplugintest.table1, slave:xplugintest.table1 |
| 246 |
--source include/diff_tables.inc |
| 247 |
--let $diff_tables= master:xplugintest.table2, slave:xplugintest.table2 |
| 248 |
--source include/diff_tables.inc |
| 249 |
|
| 250 |
## Cleanup |
| 251 |
-- connection master |
| 252 |
DROP DATABASE IF EXISTS xplugintest; |
| 253 |
DROP USER IF EXISTS user_localhost@localhost; |
| 254 |
|
| 255 |
--source include/wait_until_count_sessions.inc |
| 256 |
--source include/sync_slave_sql_with_master.inc |
| 257 |
--source include/rpl_end.inc |
| 258 |
|