Skip to content

Commit b31707d

Browse files
committed
tests: Remove have_transactions usage from 50commit.t
1 parent 7e1ce07 commit b31707d

File tree

2 files changed

+38
-168
lines changed

2 files changed

+38
-168
lines changed

t/50commit.t

Lines changed: 38 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use Test::More;
66
use lib 't', '.';
77
require 'lib.pl';
88

9-
use vars qw($have_transactions $got_warning $test_dsn $test_user $test_password);
9+
use vars qw($got_warning $test_dsn $test_user $test_password);
1010

1111
my $dbh;
1212
eval {$dbh= DBI->connect($test_dsn, $test_user, $test_password,
@@ -41,124 +41,60 @@ sub num_rows($$$) {
4141
return '';
4242
}
4343

44-
$have_transactions = have_transactions($dbh);
45-
my $engine= $have_transactions ? 'InnoDB' : 'MyISAM';
44+
plan tests => 22;
4645

47-
if ($have_transactions) {
48-
plan tests => 22;
49-
50-
ok $dbh->do("DROP TABLE IF EXISTS dbd_mysql_t50commit"), "drop table if exists dbd_mysql_t50commit";
51-
my $create =<<EOT;
46+
ok $dbh->do("DROP TABLE IF EXISTS dbd_mysql_t50commit"), "drop table if exists dbd_mysql_t50commit";
47+
my $create =<<EOT;
5248
CREATE TABLE dbd_mysql_t50commit (
53-
id INT(4) NOT NULL default 0,
54-
name VARCHAR(64) NOT NULL default ''
55-
) ENGINE=$engine
56-
EOT
57-
58-
ok $dbh->do($create), 'create dbd_mysql_t50commit';
59-
60-
ok !$dbh->{AutoCommit}, "\$dbh->{AutoCommit} not defined |$dbh->{AutoCommit}|";
61-
62-
$dbh->{AutoCommit} = 0;
63-
ok !$dbh->err;
64-
ok !$dbh->errstr;
65-
ok !$dbh->{AutoCommit};
66-
67-
ok $dbh->do("INSERT INTO dbd_mysql_t50commit VALUES (1, 'Jochen')"),
68-
"insert into dbd_mysql_t50commit (1, 'Jochen')";
69-
70-
my $msg;
71-
$msg = num_rows($dbh, 'dbd_mysql_t50commit', 1);
72-
ok !$msg;
73-
74-
ok $dbh->rollback, 'rollback';
75-
76-
$msg = num_rows($dbh, 'dbd_mysql_t50commit', 0);
77-
ok !$msg;
78-
79-
ok $dbh->do("DELETE FROM dbd_mysql_t50commit WHERE id = 1"), "delete from dbd_mysql_t50commit where id = 1";
80-
81-
$msg = num_rows($dbh, 'dbd_mysql_t50commit', 0);
82-
ok !$msg;
83-
ok $dbh->commit, 'commit';
84-
85-
$msg = num_rows($dbh, 'dbd_mysql_t50commit', 0);
86-
ok !$msg;
87-
88-
# Check auto rollback after disconnect
89-
ok $dbh->do("INSERT INTO dbd_mysql_t50commit VALUES (1, 'Jochen')");
90-
91-
$msg = num_rows($dbh, 'dbd_mysql_t50commit', 1);
92-
ok !$msg;
93-
94-
ok $dbh->disconnect;
95-
96-
ok ($dbh = DBI->connect($test_dsn, $test_user, $test_password));
97-
98-
ok $dbh, "connected";
99-
100-
$msg = num_rows($dbh, 'dbd_mysql_t50commit', 0);
101-
ok !$msg;
102-
103-
ok $dbh->{AutoCommit}, "\$dbh->{AutoCommit} $dbh->{AutoCommit}";
104-
ok $dbh->do("DROP TABLE dbd_mysql_t50commit");
105-
106-
}
107-
else {
108-
plan tests => 13;
109-
110-
ok $dbh->do("DROP TABLE IF EXISTS dbd_mysql_t50commit"), "drop table if exists dbd_mysql_t50commit";
111-
my $create =<<EOT;
112-
CREATE TABLE dbd_mysql_t50commit (
113-
id INT(4) NOT NULL default 0,
114-
name VARCHAR(64) NOT NULL default ''
115-
) ENGINE=$engine
49+
id INT(4) NOT NULL default 0,
50+
name VARCHAR(64) NOT NULL default ''
51+
) ENGINE=InnoDB
11652
EOT
11753

118-
ok $dbh->do($create), 'create dbd_mysql_t50commit';
54+
ok $dbh->do($create), 'create dbd_mysql_t50commit';
11955

120-
# Tests for databases that don't support transactions
121-
# Check whether AutoCommit mode works.
56+
ok !$dbh->{AutoCommit}, "\$dbh->{AutoCommit} not defined |$dbh->{AutoCommit}|";
12257

123-
ok $dbh->do("INSERT INTO dbd_mysql_t50commit VALUES (1, 'Jochen')");
124-
my $msg = num_rows($dbh, 'dbd_mysql_t50commit', 1);
125-
ok !$msg;
58+
$dbh->{AutoCommit} = 0;
59+
ok !$dbh->err;
60+
ok !$dbh->errstr;
61+
ok !$dbh->{AutoCommit};
12662

127-
ok $dbh->disconnect;
63+
ok $dbh->do("INSERT INTO dbd_mysql_t50commit VALUES (1, 'Jochen')"),
64+
"insert into dbd_mysql_t50commit (1, 'Jochen')";
12865

129-
ok ($dbh = DBI->connect($test_dsn, $test_user, $test_password));
66+
my $msg;
67+
$msg = num_rows($dbh, 'dbd_mysql_t50commit', 1);
68+
ok !$msg;
13069

131-
$msg = num_rows($dbh, 'dbd_mysql_t50commit', 1);
132-
ok !$msg;
70+
ok $dbh->rollback, 'rollback';
13371

134-
ok $dbh->do("INSERT INTO dbd_mysql_t50commit VALUES (2, 'Tim')");
72+
$msg = num_rows($dbh, 'dbd_mysql_t50commit', 0);
73+
ok !$msg;
13574

136-
my $result;
137-
$@ = '';
75+
ok $dbh->do("DELETE FROM dbd_mysql_t50commit WHERE id = 1"), "delete from dbd_mysql_t50commit where id = 1";
13876

139-
$SIG{__WARN__} = \&catch_warning;
77+
$msg = num_rows($dbh, 'dbd_mysql_t50commit', 0);
78+
ok !$msg;
79+
ok $dbh->commit, 'commit';
14080

141-
$got_warning = 0;
81+
$msg = num_rows($dbh, 'dbd_mysql_t50commit', 0);
82+
ok !$msg;
14283

143-
eval { $result = $dbh->commit; };
84+
# Check auto rollback after disconnect
85+
ok $dbh->do("INSERT INTO dbd_mysql_t50commit VALUES (1, 'Jochen')");
14486

145-
$SIG{__WARN__} = 'DEFAULT';
87+
$msg = num_rows($dbh, 'dbd_mysql_t50commit', 1);
88+
ok !$msg;
14689

147-
ok $got_warning;
90+
ok $dbh->disconnect;
14891

149-
# Check whether rollback issues a warning in AutoCommit mode
150-
# We accept error messages as being legal, because the DBI
151-
# requirement of just issuing a warning seems scary.
152-
ok $dbh->do("INSERT INTO dbd_mysql_t50commit VALUES (3, 'Alligator')");
92+
ok ($dbh = DBI->connect($test_dsn, $test_user, $test_password));
15393

154-
$@ = '';
155-
$SIG{__WARN__} = \&catch_warning;
156-
$got_warning = 0;
157-
eval { $result = $dbh->rollback; };
158-
$SIG{__WARN__} = 'DEFAULT';
94+
ok $dbh, "connected";
15995

160-
ok $got_warning, "Should be warning defined upon rollback of non-trx table";
96+
$msg = num_rows($dbh, 'dbd_mysql_t50commit', 0);
97+
ok !$msg;
16198

162-
ok $dbh->do("DROP TABLE dbd_mysql_t50commit");
163-
ok $dbh->disconnect();
164-
}
99+
ok $dbh->{AutoCommit}, "\$dbh->{AutoCommit} $dbh->{AutoCommit}";
100+
ok $dbh->do("DROP TABLE dbd_mysql_t50commit");

t/mysql.dbtest

Lines changed: 0 additions & 66 deletions
This file was deleted.

0 commit comments

Comments
 (0)