@@ -16,7 +16,7 @@ my $dbh = DbiTestConnect($test_dsn, $test_user, $test_password,
16
16
if ($dbh -> {mariadb_serverversion } < 50012) {
17
17
plan skip_all => " Servers < 5.0.12 do not support SLEEP()" ;
18
18
}
19
- plan tests => 96 ;
19
+ plan tests => 137 ;
20
20
21
21
is $dbh -> get_info($GetInfoType {' SQL_ASYNC_MODE' }), 2; # statement-level async
22
22
is $dbh -> get_info($GetInfoType {' SQL_MAX_ASYNC_CONCURRENT_STATEMENTS' }), 1;
@@ -93,23 +93,31 @@ is $b, 1;
93
93
is $c , 2;
94
94
95
95
$sth = $dbh -> prepare(' SELECT SLEEP(2)' );
96
+ ok !$sth -> {Active };
96
97
ok !defined ($sth -> mariadb_async_ready);
97
98
$start = Time::HiRes::gettimeofday();
98
99
ok $sth -> execute;
99
100
$end = Time::HiRes::gettimeofday();
100
101
cmp_ok(($end - $start ), ' >=' , 1.9);
102
+ ok $sth -> {Active };
103
+ ok $sth -> finish;
104
+ ok !$sth -> {Active };
101
105
102
106
$sth = $dbh -> prepare(' SELECT SLEEP(2)' , { mariadb_async => 1 });
107
+ ok !$sth -> {Active };
103
108
ok !defined ($sth -> mariadb_async_ready);
104
109
$start = Time::HiRes::gettimeofday();
105
110
ok $sth -> execute;
106
111
ok defined ($sth -> mariadb_async_ready);
107
112
$end = Time::HiRes::gettimeofday();
108
113
cmp_ok(($end - $start ), ' <' , 2);
114
+ ok $sth -> {Active };
109
115
110
116
sleep 1 until $sth -> mariadb_async_ready;
111
117
118
+ ok $sth -> {Active };
112
119
my $row = $sth -> fetch;
120
+ ok !$sth -> {Active };
113
121
$end = Time::HiRes::gettimeofday();
114
122
ok $row ;
115
123
is $row -> [0], 0;
@@ -126,16 +134,19 @@ ok $dbh->errstr;
126
134
$dbh -> do(' DELETE FROM async_test' );
127
135
128
136
$sth = $dbh -> prepare(' INSERT INTO async_test VALUES(SLEEP(2), ?, ?)' , { mariadb_async => 1 });
137
+ ok !$sth -> {Active };
129
138
$start = Time::HiRes::gettimeofday();
130
139
$rows = $sth -> execute(1, 2);
131
140
$end = Time::HiRes::gettimeofday();
132
141
cmp_ok(($end - $start ), ' <' , 2);
142
+ ok $sth -> {Active };
133
143
ok $rows ;
134
144
is $rows , ' 0E0' ;
135
145
136
146
$rows = $sth -> mariadb_async_result;
137
147
$end = Time::HiRes::gettimeofday();
138
148
cmp_ok(($end - $start ), ' >=' , 1.9);
149
+ ok !$sth -> {Active };
139
150
is $rows , 1;
140
151
141
152
( $a , $b , $c ) = $dbh -> selectrow_array(' SELECT * FROM async_test' );
@@ -164,10 +175,13 @@ ok $rows;
164
175
is $rows , ' 0E0' ;
165
176
166
177
$sth = $dbh -> prepare(' UPDATE async_test SET value0 = 0 WHERE value0 = 999' , { mariadb_async => 1 });
178
+ ok !$sth -> {Active };
167
179
$rows = $sth -> execute;
180
+ ok $sth -> {Active };
168
181
ok $rows ;
169
182
is $rows , ' 0E0' ;
170
183
$rows = $sth -> mariadb_async_result;
184
+ ok !$sth -> {Active };
171
185
ok $rows ;
172
186
is $rows , ' 0E0' ;
173
187
@@ -179,7 +193,9 @@ $rows = $dbh->do('INSERT INTO async_test VALUES(1, 2, 3)');
179
193
is $rows , 1;
180
194
181
195
$sth = $dbh -> prepare(' SELECT 1, value0, value1, value2 FROM async_test WHERE value0 = ?' , { mariadb_async => 1 });
196
+ ok !$sth -> {Active };
182
197
$sth -> execute(1);
198
+ ok $sth -> {Active };
183
199
is $sth -> {' NUM_OF_FIELDS' }, undef ;
184
200
is $sth -> {' NUM_OF_PARAMS' }, 1;
185
201
is $sth -> {' NAME' }, undef ;
@@ -195,6 +211,7 @@ is $sth->{'NULLABLE'}, undef;
195
211
is $sth -> {' Database' }, $dbh ;
196
212
is $sth -> {' Statement' }, ' SELECT 1, value0, value1, value2 FROM async_test WHERE value0 = ?' ;
197
213
$sth -> mariadb_async_result;
214
+ ok $sth -> {Active };
198
215
is $sth -> {' NUM_OF_FIELDS' }, 4;
199
216
is $sth -> {' NUM_OF_PARAMS' }, 1;
200
217
cmp_bag $sth -> {' NAME' }, [qw/ 1 value0 value1 value2/ ];
@@ -210,31 +227,60 @@ is ref($sth->{'NULLABLE'}), 'ARRAY';
210
227
is $sth -> {' Database' }, $dbh ;
211
228
is $sth -> {' Statement' }, ' SELECT 1, value0, value1, value2 FROM async_test WHERE value0 = ?' ;
212
229
$sth -> finish;
230
+ ok !$sth -> {Active };
213
231
214
232
$sth -> execute(1);
233
+ ok $sth -> {Active };
215
234
$row = $sth -> fetch;
235
+ ok !$sth -> {Active };
236
+ is_deeply $row , [1, 1, 2, 3];
237
+ is $sth -> rows, 1;
238
+
239
+ $sth -> execute(1);
240
+ ok $sth -> {Active };
241
+ $sth -> mariadb_async_result;
242
+ ok $sth -> {Active };
243
+ $row = $sth -> fetch;
244
+ ok !$sth -> {Active };
216
245
is_deeply $row , [1, 1, 2, 3];
217
246
is $sth -> rows, 1;
218
- $sth -> finish;
219
247
220
248
$sth -> execute(1);
249
+ ok $sth -> {Active };
221
250
$row = $sth -> fetchrow_arrayref;
251
+ ok !$sth -> {Active };
222
252
is_deeply $row , [1, 1, 2, 3];
223
253
is $sth -> rows, 1;
224
- $sth -> finish;
225
254
226
255
$sth -> execute(1);
256
+ ok $sth -> {Active };
227
257
my @row = $sth -> fetchrow_array;
258
+ ok !$sth -> {Active };
228
259
is_deeply \@row , [1, 1, 2, 3];
229
260
is $sth -> rows, 1;
230
- $sth -> finish;
231
261
232
262
$sth -> execute(1);
263
+ ok $sth -> {Active };
233
264
$row = $sth -> fetchrow_hashref;
265
+ ok !$sth -> {Active };
234
266
cmp_bag [ keys %$row ], [qw/ 1 value0 value1 value2/ ];
235
267
cmp_bag [ values %$row ], [1, 1, 2, 3];
236
268
is $sth -> rows, 1;
237
- $sth -> finish;
238
269
239
- undef $sth ;
270
+ $sth = $dbh -> prepare(' UPDATE async_test SET value0 = 2 WHERE value0 = 1' , { mariadb_async => 1 });
271
+ ok !$sth -> {Active };
272
+ ok $sth -> execute();
273
+ ok $sth -> {Active };
274
+ ok $sth -> mariadb_async_result;
275
+ ok !$sth -> {Active };
276
+
277
+ $sth = $dbh -> prepare(' SYNTAX ERROR' , { mariadb_async => 1 });
278
+ ok !$sth -> {Active };
279
+ ok $sth -> execute();
280
+ ok $sth -> {Active };
281
+ ok !$sth -> mariadb_async_result;
282
+ ok !$sth -> {Active };
283
+
284
+ local $SIG {__WARN__ } = sub { die @_ };
285
+
240
286
ok $dbh -> disconnect;
0 commit comments