@@ -9,17 +9,18 @@ use lib 't', '.';
9
9
require ' lib.pl' ;
10
10
11
11
my $dbh = DbiTestConnect($test_dsn , $test_user , $test_password ,
12
- { RaiseError => 0, PrintError => 0, AutoCommit => 0 });
13
- plan tests => 8 ;
12
+ { RaiseError => 0, PrintError => 0, AutoCommit => 0, mariadb_multi_statements => 1 });
13
+ plan tests => 45 ;
14
14
15
15
$dbh -> do(<<SQL );
16
16
CREATE TEMPORARY TABLE async_test (
17
- value INTEGER
17
+ value INTEGER AUTO_INCREMENT PRIMARY KEY
18
18
);
19
19
SQL
20
20
21
- my $sth0 = $dbh -> prepare(' INSERT INTO async_test VALUES(0)' , { mariadb_async => 1 });
22
- my $sth1 = $dbh -> prepare(' INSERT INTO async_test VALUES(1)' , { mariadb_async => 1 });
21
+ my $sth0 = $dbh -> prepare(' INSERT INTO async_test VALUES(1)' , { mariadb_async => 1 });
22
+ my $sth1 = $dbh -> prepare(' INSERT INTO async_test VALUES(2)' , { mariadb_async => 1 });
23
+ my $sth2 = $dbh -> prepare(' INSERT INTO async_test VALUES(3); INSERT INTO async_test VALUES(4);' , { mariadb_async => 1 });
23
24
24
25
$sth0 -> execute;
25
26
ok !defined ($sth1 -> mariadb_async_ready);
@@ -32,7 +33,63 @@ ok !$sth1->errstr;
32
33
ok defined ($sth0 -> mariadb_async_result);
33
34
ok !$sth1 -> errstr;
34
35
36
+ is($sth0 -> last_insert_id(), 1);
37
+ is($dbh -> last_insert_id(undef , undef , undef , undef ), 1);
38
+
39
+ $sth2 -> execute;
40
+ ok !defined ($sth1 -> mariadb_async_ready);
41
+ ok $sth1 -> err;
42
+ ok !defined ($sth1 -> mariadb_async_result);
43
+ ok $sth1 -> err;
44
+
45
+ is($sth0 -> last_insert_id(), 1);
46
+ is($dbh -> last_insert_id(undef , undef , undef , undef ), 1);
47
+
48
+ ok defined ($sth2 -> mariadb_async_ready);
49
+ ok !$sth2 -> err;
50
+
51
+ is($sth0 -> last_insert_id(), 1);
52
+ is($dbh -> last_insert_id(undef , undef , undef , undef ), 1);
53
+
54
+ ok defined ($sth2 -> mariadb_async_result);
55
+ ok !$sth2 -> err;
56
+
57
+ is($sth0 -> last_insert_id(), 1);
58
+ is($sth2 -> last_insert_id(), 3);
59
+ is($dbh -> last_insert_id(undef , undef , undef , undef ), 3);
60
+
61
+ ok $sth2 -> more_results;
62
+ ok defined ($sth2 -> mariadb_async_result);
63
+ ok !$sth2 -> err;
64
+
65
+ is($sth0 -> last_insert_id(), 1);
66
+ is($sth2 -> last_insert_id(), 4);
67
+ is($dbh -> last_insert_id(undef , undef , undef , undef ), 4);
68
+
69
+ ok !$sth2 -> more_results;
70
+
71
+ $dbh -> do(' INSERT INTO async_test VALUES(5)' , { mariadb_async => 1 });
72
+
73
+ is($sth0 -> last_insert_id(), 1);
74
+ is($sth2 -> last_insert_id(), 4);
75
+ is($dbh -> last_insert_id(undef , undef , undef , undef ), 4);
76
+
77
+ ok defined ($dbh -> mariadb_async_ready);
78
+ ok !$dbh -> err;
79
+
80
+ is($sth0 -> last_insert_id(), 1);
81
+ is($sth2 -> last_insert_id(), 4);
82
+ is($dbh -> last_insert_id(undef , undef , undef , undef ), 4);
83
+
84
+ ok defined ($dbh -> mariadb_async_result);
85
+ ok !$sth2 -> err;
86
+
87
+ is($sth0 -> last_insert_id(), 1);
88
+ is($sth2 -> last_insert_id(), 4);
89
+ is($dbh -> last_insert_id(undef , undef , undef , undef ), 5);
90
+
35
91
undef $sth0 ;
36
92
undef $sth1 ;
93
+ undef $sth2 ;
37
94
38
95
$dbh -> disconnect;
0 commit comments