| 1 |
|
| 2 |
# Pipeline allows clients to send a batch of commands to the server all at once |
| 3 |
# and read their responses also all at once, minimizing the number of network |
| 4 |
# roundtrips and allowing for better performance, specially when network |
| 5 |
# latency is a bottleneck. |
| 6 |
|
| 7 |
## Preamble |
| 8 |
--source include/xplugin_preamble.inc |
| 9 |
--source include/xplugin_create_user.inc |
| 10 |
DROP DATABASE IF EXISTS xplugintest; |
| 11 |
CREATE DATABASE xplugintest; |
| 12 |
USE xplugintest; |
| 13 |
CREATE TABLE test.counttest1 ( i INT ); |
| 14 |
|
| 15 |
|
| 16 |
# Send xmessage in group and do -->recvresult |
| 17 |
--write_file $MYSQL_TMP_DIR/stmtexecute_select.xpl |
| 18 |
-->echo Send SELECT SLEEP (?) |
| 19 |
#-- Select with sleep.Make server wait for 5 sec so other messages can be queued |
| 20 |
Mysqlx.Sql.StmtExecute { |
| 21 |
stmt: " SELECT SLEEP (?) " |
| 22 |
args { |
| 23 |
type: SCALAR |
| 24 |
scalar { |
| 25 |
type: V_UINT |
| 26 |
v_unsigned_int: 5 |
| 27 |
} |
| 28 |
} |
| 29 |
} |
| 30 |
#-- Create table2 |
| 31 |
-->stmtadmin create_collection {"schema":"xplugintest","name":"table2"} |
| 32 |
|
| 33 |
#-- Select |
| 34 |
-->echo send SELECT (100+?) |
| 35 |
Mysqlx.Sql.StmtExecute { |
| 36 |
stmt: "SELECT (100+?) " |
| 37 |
args { |
| 38 |
type: SCALAR |
| 39 |
scalar { |
| 40 |
type: V_UINT |
| 41 |
v_unsigned_int: 10 |
| 42 |
} |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
-->echo retrive result of send message at once |
| 49 |
-->recvresult |
| 50 |
-->recvresult |
| 51 |
-->recvresult |
| 52 |
|
| 53 |
-->echo send Insert |
| 54 |
Mysqlx.Crud.Insert { |
| 55 |
collection { |
| 56 |
name: "table2" |
| 57 |
schema: "xplugintest" |
| 58 |
} |
| 59 |
data_model: DOCUMENT |
| 60 |
row { |
| 61 |
field { |
| 62 |
type: LITERAL |
| 63 |
literal { |
| 64 |
type: V_STRING |
| 65 |
v_string { |
| 66 |
value: "\n{\n \"_id\": \"1\",\n \"name\": \"Omar Bras\", \"id\": \"1\"\n}" |
| 67 |
} |
| 68 |
} |
| 69 |
}} |
| 70 |
row { |
| 71 |
field { |
| 72 |
type: LITERAL |
| 73 |
literal { |
| 74 |
type: V_STRING |
| 75 |
v_string { |
| 76 |
value: "\n{\n \"_id\": \"2\",\n \"name\": \"Omar Mex\", \"id\": \"2\"\n}" |
| 77 |
} |
| 78 |
}} |
| 79 |
} |
| 80 |
} |
| 81 |
|
| 82 |
|
| 83 |
-->echo Send SELECT SLEEP (?) |
| 84 |
Mysqlx.Sql.StmtExecute { |
| 85 |
stmt: " SELECT SLEEP (?) " |
| 86 |
args { |
| 87 |
type: SCALAR |
| 88 |
scalar { |
| 89 |
type: V_UINT |
| 90 |
v_unsigned_int: 2 |
| 91 |
} |
| 92 |
} |
| 93 |
} |
| 94 |
|
| 95 |
-->echo Send SELECT FROM table2 |
| 96 |
Mysqlx.Sql.StmtExecute { |
| 97 |
stmt: " SELECT doc FROM xplugintest.table2" |
| 98 |
} |
| 99 |
|
| 100 |
-->echo Send SELECT FROM table2 |
| 101 |
Mysqlx.Sql.StmtExecute { |
| 102 |
stmt: " DROP DATABASE xplugintest" |
| 103 |
} |
| 104 |
|
| 105 |
-->echo retrive result of send message at once |
| 106 |
-->recvresult |
| 107 |
-->recvresult |
| 108 |
-->recvresult |
| 109 |
-->recvresult |
| 110 |
EOF |
| 111 |
|
| 112 |
--exec $MYSQLXTEST -ux_root --password='' --file=$MYSQL_TMP_DIR/stmtexecute_select.xpl 2>&1 |
| 113 |
--remove_file $MYSQL_TMP_DIR/stmtexecute_select.xpl |
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
# Send 100 select command and retrive result at the end |
| 118 |
perl; |
| 119 |
my $dir = $ENV{'MYSQL_TMP_DIR'}; |
| 120 |
open ( OUTPUT, ">$dir/mysqlx-in.xpl") ; |
| 121 |
$message = <<"END_MESSAGE"; |
| 122 |
Mysqlx.Sql.StmtExecute { |
| 123 |
stmt: "SELECT (100+?) " |
| 124 |
args { |
| 125 |
type: SCALAR |
| 126 |
scalar { |
| 127 |
type: V_UINT |
| 128 |
v_unsigned_int: -1 |
| 129 |
} |
| 130 |
} |
| 131 |
} |
| 132 |
END_MESSAGE |
| 133 |
|
| 134 |
for ($i=1;$i<=100;$i++) { |
| 135 |
if ($i%20==0) { |
| 136 |
print OUTPUT "\nMysqlx.Sql.StmtExecute { \n stmt: \" SELECT SLEEP (1) \"\n}\n"; |
| 137 |
# send invalid request |
| 138 |
print OUTPUT "\nMysqlx.Sql.StmtExecute { \n stmt: \" SELECT * FROM INVALID_TABLE \"\n}\n"; |
| 139 |
}else{ |
| 140 |
$str = $message; |
| 141 |
$replace = $i; |
| 142 |
$find = -1; |
| 143 |
$str =~ s/$find/$replace/g; |
| 144 |
print OUTPUT "$str\n"; |
| 145 |
} |
| 146 |
} |
| 147 |
for ($i=1;$i<=100;$i++) { |
| 148 |
print OUTPUT "\n-->recvresult\n"; |
| 149 |
if ($i%20==0) { |
| 150 |
print OUTPUT "\n-->expecterror 1046\n"; |
| 151 |
print OUTPUT "\n-->recvresult\n"; |
| 152 |
} |
| 153 |
} |
| 154 |
print OUTPUT "\n-->sql\n"; |
| 155 |
print OUTPUT "\nINSERT INTO test.counttest1 VALUES (1);\n"; |
| 156 |
print OUTPUT "\n-->endsql\n"; |
| 157 |
close(OUTPUT); |
| 158 |
EOF |
| 159 |
|
| 160 |
--exec $MYSQLXTEST -ux_root --password='' --file=$MYSQL_TMP_DIR/mysqlx-in.xpl >$MYSQL_TMP_DIR/mysqlx-out1.xpl 2>&1 & |
| 161 |
--exec $MYSQLXTEST -ux_root --password='' --file=$MYSQL_TMP_DIR/mysqlx-in.xpl >$MYSQL_TMP_DIR/mysqlx-out2.xpl 2>&1 |
| 162 |
let $wait_timeout= 90; |
| 163 |
let $wait_condition= select count(*)=2 from test.counttest1; |
| 164 |
--source include/wait_condition.inc |
| 165 |
--sleep 1 |
| 166 |
|
| 167 |
## Cleanup |
| 168 |
DROP TABLE test.counttest1; |
| 169 |
--source ../include/xplugin_cleanup.inc |