| 1 |
CREATE SCHEMA IF NOT EXISTS xtest; |
| 2 |
USE xtest; |
| 3 |
CREATE TABLE t1 (phrase VARCHAR(30)); |
| 4 |
INSERT INTO t1 (phrase) VALUES ('Alice has a cat'); |
| 5 |
INSERT INTO t1 (phrase) VALUES ('Bob has a dog'); |
| 6 |
CREATE TABLE t2 (x INT, y FLOAT, z TINYINT); |
| 7 |
INSERT INTO t2 VALUES (1, 1.1, 11); |
| 8 |
INSERT INTO t2 VALUES (2, 2.22, 22); |
| 9 |
INSERT INTO t2 VALUES (3, 3.0, 33); |
| 10 |
send Mysqlx.Prepare.Prepare { |
| 11 |
stmt_id: 1 |
| 12 |
stmt { |
| 13 |
type: STMT |
| 14 |
stmt_execute { |
| 15 |
stmt: "SELECT * FROM xtest.t1" |
| 16 |
} |
| 17 |
} |
| 18 |
} |
| 19 |
|
| 20 |
RUN recvok |
| 21 |
send Mysqlx.Prepare.Prepare { |
| 22 |
stmt_id: 2 |
| 23 |
stmt { |
| 24 |
type: STMT |
| 25 |
stmt_execute { |
| 26 |
stmt: "SELECT * FROM xtest.t2" |
| 27 |
} |
| 28 |
} |
| 29 |
} |
| 30 |
|
| 31 |
RUN recvok |
| 32 |
|
| 33 |
Fetch all rows in Cursor.Open |
| 34 |
============================== |
| 35 |
send Mysqlx.Cursor.Open { |
| 36 |
cursor_id: 1 |
| 37 |
stmt { |
| 38 |
type: PREPARE_EXECUTE |
| 39 |
prepare_execute { |
| 40 |
stmt_id: 1 |
| 41 |
} |
| 42 |
} |
| 43 |
fetch_rows: 3 |
| 44 |
} |
| 45 |
|
| 46 |
phrase |
| 47 |
Alice has a cat |
| 48 |
Bob has a dog |
| 49 |
0 rows affected |
| 50 |
send Mysqlx.Cursor.Fetch { |
| 51 |
cursor_id: 1 |
| 52 |
fetch_rows: 2 |
| 53 |
} |
| 54 |
|
| 55 |
Got expected error: |
| 56 |
Mysqlx.Error { |
| 57 |
severity: ERROR |
| 58 |
code: 5123 |
| 59 |
msg: "No more data in cursor (cursor id:1)" |
| 60 |
sql_state: "HY000" |
| 61 |
} |
| 62 |
|
| 63 |
|
| 64 |
Fetch no rows in Cursor.Open |
| 65 |
============================= |
| 66 |
send Mysqlx.Cursor.Open { |
| 67 |
cursor_id: 2 |
| 68 |
stmt { |
| 69 |
type: PREPARE_EXECUTE |
| 70 |
prepare_execute { |
| 71 |
stmt_id: 1 |
| 72 |
} |
| 73 |
} |
| 74 |
fetch_rows: 0 |
| 75 |
} |
| 76 |
|
| 77 |
phrase |
| 78 |
command ok |
| 79 |
send Mysqlx.Cursor.Fetch { |
| 80 |
cursor_id: 2 |
| 81 |
fetch_rows: 3 |
| 82 |
} |
| 83 |
|
| 84 |
phrase |
| 85 |
Alice has a cat |
| 86 |
Bob has a dog |
| 87 |
0 rows affected |
| 88 |
|
| 89 |
Fetch part of rows in Cursor.Open |
| 90 |
================================== |
| 91 |
send Mysqlx.Cursor.Open { |
| 92 |
cursor_id: 2 |
| 93 |
stmt { |
| 94 |
type: PREPARE_EXECUTE |
| 95 |
prepare_execute { |
| 96 |
stmt_id: 1 |
| 97 |
} |
| 98 |
} |
| 99 |
fetch_rows: 1 |
| 100 |
} |
| 101 |
|
| 102 |
phrase |
| 103 |
Alice has a cat |
| 104 |
command ok |
| 105 |
send Mysqlx.Cursor.Fetch { |
| 106 |
cursor_id: 2 |
| 107 |
fetch_rows: 2 |
| 108 |
} |
| 109 |
|
| 110 |
phrase |
| 111 |
Bob has a dog |
| 112 |
0 rows affected |
| 113 |
|
| 114 |
Multiple cursor fetch messages |
| 115 |
=============================== |
| 116 |
send Mysqlx.Cursor.Open { |
| 117 |
cursor_id: 2 |
| 118 |
stmt { |
| 119 |
type: PREPARE_EXECUTE |
| 120 |
prepare_execute { |
| 121 |
stmt_id: 1 |
| 122 |
} |
| 123 |
} |
| 124 |
fetch_rows: 0 |
| 125 |
} |
| 126 |
|
| 127 |
phrase |
| 128 |
command ok |
| 129 |
send Mysqlx.Cursor.Fetch { |
| 130 |
cursor_id: 2 |
| 131 |
fetch_rows: 1 |
| 132 |
} |
| 133 |
|
| 134 |
phrase |
| 135 |
Alice has a cat |
| 136 |
command ok |
| 137 |
send Mysqlx.Cursor.Fetch { |
| 138 |
cursor_id: 2 |
| 139 |
fetch_rows: 1 |
| 140 |
} |
| 141 |
|
| 142 |
phrase |
| 143 |
Bob has a dog |
| 144 |
command ok |
| 145 |
send Mysqlx.Cursor.Fetch { |
| 146 |
cursor_id: 2 |
| 147 |
fetch_rows: 1 |
| 148 |
} |
| 149 |
|
| 150 |
phrase |
| 151 |
0 rows affected |
| 152 |
|
| 153 |
Fetch more results than available in one fetch |
| 154 |
=============================================== |
| 155 |
send Mysqlx.Cursor.Open { |
| 156 |
cursor_id: 2 |
| 157 |
stmt { |
| 158 |
type: PREPARE_EXECUTE |
| 159 |
prepare_execute { |
| 160 |
stmt_id: 1 |
| 161 |
} |
| 162 |
} |
| 163 |
fetch_rows: 0 |
| 164 |
} |
| 165 |
|
| 166 |
phrase |
| 167 |
command ok |
| 168 |
send Mysqlx.Cursor.Fetch { |
| 169 |
cursor_id: 2 |
| 170 |
fetch_rows: 8 |
| 171 |
} |
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
0 rows affected |
| 177 |
|
| 178 |
Fetch more results than available in multiple fetches |
| 179 |
====================================================== |
| 180 |
send Mysqlx.Cursor.Open { |
| 181 |
cursor_id: 2 |
| 182 |
stmt { |
| 183 |
type: PREPARE_EXECUTE |
| 184 |
prepare_execute { |
| 185 |
stmt_id: 1 |
| 186 |
} |
| 187 |
} |
| 188 |
fetch_rows: 0 |
| 189 |
} |
| 190 |
|
| 191 |
phrase |
| 192 |
command ok |
| 193 |
send Mysqlx.Cursor.Fetch { |
| 194 |
cursor_id: 2 |
| 195 |
fetch_rows: 1 |
| 196 |
} |
| 197 |
|
| 198 |
phrase |
| 199 |
Alice has a cat |
| 200 |
command ok |
| 201 |
send Mysqlx.Cursor.Fetch { |
| 202 |
cursor_id: 2 |
| 203 |
fetch_rows: 1 |
| 204 |
} |
| 205 |
|
| 206 |
phrase |
| 207 |
Bob has a dog |
| 208 |
command ok |
| 209 |
send Mysqlx.Cursor.Fetch { |
| 210 |
cursor_id: 2 |
| 211 |
fetch_rows: 1 |
| 212 |
} |
| 213 |
|
| 214 |
phrase |
| 215 |
0 rows affected |
| 216 |
send Mysqlx.Cursor.Fetch { |
| 217 |
cursor_id: 2 |
| 218 |
fetch_rows: 1 |
| 219 |
} |
| 220 |
|
| 221 |
Got expected error: |
| 222 |
Mysqlx.Error { |
| 223 |
severity: ERROR |
| 224 |
code: 5123 |
| 225 |
msg: "No more data in cursor (cursor id:2)" |
| 226 |
sql_state: "HY000" |
| 227 |
} |
| 228 |
|
| 229 |
|
| 230 |
Fetch result with multiple column metadata |
| 231 |
=========================================== |
| 232 |
send Mysqlx.Cursor.Open { |
| 233 |
cursor_id: 2 |
| 234 |
stmt { |
| 235 |
type: PREPARE_EXECUTE |
| 236 |
prepare_execute { |
| 237 |
stmt_id: 2 |
| 238 |
} |
| 239 |
} |
| 240 |
fetch_rows: 0 |
| 241 |
} |
| 242 |
|
| 243 |
x y z |
| 244 |
command ok |
| 245 |
send Mysqlx.Cursor.Fetch { |
| 246 |
cursor_id: 2 |
| 247 |
fetch_rows: 3 |
| 248 |
} |
| 249 |
|
| 250 |
x y z |
| 251 |
1 1.1 11 |
| 252 |
2 2.22 22 |
| 253 |
3 3 33 |
| 254 |
command ok |
| 255 |
|
| 256 |
Alternating cursor fetch |
| 257 |
========================= |
| 258 |
send Mysqlx.Cursor.Open { |
| 259 |
cursor_id: 1 |
| 260 |
stmt { |
| 261 |
type: PREPARE_EXECUTE |
| 262 |
prepare_execute { |
| 263 |
stmt_id: 1 |
| 264 |
} |
| 265 |
} |
| 266 |
fetch_rows: 0 |
| 267 |
} |
| 268 |
|
| 269 |
phrase |
| 270 |
command ok |
| 271 |
send Mysqlx.Cursor.Open { |
| 272 |
cursor_id: 2 |
| 273 |
stmt { |
| 274 |
type: PREPARE_EXECUTE |
| 275 |
prepare_execute { |
| 276 |
stmt_id: 2 |
| 277 |
} |
| 278 |
} |
| 279 |
fetch_rows: 0 |
| 280 |
} |
| 281 |
|
| 282 |
x y z |
| 283 |
command ok |
| 284 |
send Mysqlx.Cursor.Fetch { |
| 285 |
cursor_id: 1 |
| 286 |
fetch_rows: 1 |
| 287 |
} |
| 288 |
|
| 289 |
phrase |
| 290 |
Alice has a cat |
| 291 |
command ok |
| 292 |
send Mysqlx.Cursor.Fetch { |
| 293 |
cursor_id: 2 |
| 294 |
fetch_rows: 2 |
| 295 |
} |
| 296 |
|
| 297 |
x y z |
| 298 |
1 1.1 11 |
| 299 |
2 2.22 22 |
| 300 |
command ok |
| 301 |
send Mysqlx.Cursor.Fetch { |
| 302 |
cursor_id: 1 |
| 303 |
fetch_rows: 1 |
| 304 |
} |
| 305 |
|
| 306 |
phrase |
| 307 |
Bob has a dog |
| 308 |
command ok |
| 309 |
send Mysqlx.Cursor.Fetch { |
| 310 |
cursor_id: 2 |
| 311 |
fetch_rows: 2 |
| 312 |
} |
| 313 |
|
| 314 |
x y z |
| 315 |
3 3 33 |
| 316 |
0 rows affected |
| 317 |
Mysqlx.Ok { |
| 318 |
msg: "bye!" |
| 319 |
} |
| 320 |
ok |