Skip to content

Commit 3c4b25c

Browse files
committed
Merge pull request #133
Fix some tests
2 parents 9c0a139 + 30f8655 commit 3c4b25c

File tree

3 files changed

+22
-25
lines changed

3 files changed

+22
-25
lines changed

t/29warnings.t

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ use vars qw($test_dsn $test_user $test_password);
1212
my $dbh = DbiTestConnect($test_dsn, $test_user, $test_password,
1313
{ RaiseError => 1, PrintError => 0, AutoCommit => 0 });
1414

15-
my $expected_warnings = 2;
16-
if ($dbh->{mariadb_serverversion} >= 50000 && $dbh->{mariadb_serverversion} < 50500) {
17-
$expected_warnings = 1;
18-
}
19-
2015
plan tests => 14;
2116

2217
ok(defined $dbh, "Connected to database");
@@ -43,15 +38,14 @@ ok($sth->execute());
4338

4439
is($sth->{'mariadb_warning_count'}, 2 );
4540

46-
# $dbh->{mariadb_info} actually uses mysql_info()
47-
my $str = $dbh->{mariadb_info};
48-
my $numwarn;
49-
if ( $str =~ /Warnings:\s(\d+)$/ ) {
50-
$numwarn = $1;
51-
}
52-
5341
# this test passes on mysql 5.5.x and fails on 5.1.x
54-
# but I'm not sure which versions, so I'll just disable it for now
55-
is($numwarn, $expected_warnings);
42+
# so change number of expected warnings from mysql_info()
43+
my $expected_warnings = 2;
44+
if ($dbh->{mariadb_serverversion} >= 50000 && $dbh->{mariadb_serverversion} < 50500) {
45+
$expected_warnings = 1;
46+
}
47+
# $dbh->{mariadb_info} actually uses mysql_info()
48+
my $info = $dbh->{mariadb_info};
49+
like($info, qr/Warnings:\s\Q$expected_warnings\E$/);
5650

5751
ok($dbh->disconnect);

t/41int_min_max.t

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ if ($dbh->{mariadb_serverversion} < 50002) {
1717
"SKIP TEST: You must have MySQL version 5.0.2 and greater for this test to run";
1818
}
1919
# nostrict tests + strict tests + init/tear down commands
20-
plan tests => (19*8 + 19*8 + 4) * 2;
20+
plan tests => (19*8 + 19*8 + 3) * 2;
2121

2222
my $table = 'dbd_mysql_t41minmax'; # name of the table we will be using
2323
my $mode; # 'strict' or 'nostrict' corresponds to strict SQL mode
@@ -26,9 +26,8 @@ sub test_int_type ($$$$) {
2626
my ($perl_type, $mariadb_type, $min, $max) = @_;
2727

2828
# Create the table
29-
ok($dbh->do(qq{DROP TABLE IF EXISTS $table}), "removing $table");
3029
ok($dbh->do(qq{
31-
CREATE TABLE `$table` (
30+
CREATE TEMPORARY TABLE `$table` (
3231
`id` int not null auto_increment,
3332
`val` $mariadb_type,
3433
primary key (id)
@@ -38,7 +37,7 @@ sub test_int_type ($$$$) {
3837
my ($store, $retrieve); # statements
3938
my $read_value; # retrieved value
4039
ok($store = $dbh->prepare("INSERT INTO $table (val) VALUES (?)"));
41-
ok($retrieve = $dbh->prepare("SELECT val from $table where id=(SELECT MAX(id) FROM $table)"));
40+
ok($retrieve = $dbh->prepare("SELECT val from $table ORDER BY id DESC LIMIT 1"));
4241

4342
########################################
4443
# Insert allowed min value
@@ -107,6 +106,8 @@ sub test_int_type ($$$$) {
107106
($read_value) = $retrieve->fetchrow_array();
108107
cmp_ok($read_value, 'eq', $max, "retrieved maximal value for type $mariadb_type, mode=$mode");
109108
};
109+
110+
ok($dbh->do(qq{DROP TEMPORARY TABLE `$table`}), "removing $table");
110111
}
111112

112113
$dbh->disconnect;
@@ -141,7 +142,5 @@ test_int_type(DBI::SQL_INTEGER, 'int unsigned', 0, 2**32-1);
141142
test_int_type(DBI::SQL_BIGINT, 'bigint signed', -2**63, 2**63-1);
142143
test_int_type(DBI::SQL_BIGINT, 'bigint unsigned', 0, 2**64-1);
143144

144-
ok ($dbh->do("DROP TABLE $table"));
145-
146145
ok $dbh->disconnect;
147146
}

t/50commit.t

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,11 @@ sub num_rows($$$) {
3939

4040
my $engines = $dbh->selectall_hashref('SHOW ENGINES', 'Engine');
4141
my $have_innodb = exists $engines->{InnoDB} && $engines->{InnoDB}->{Support} ne 'NO';
42+
my $have_myisam = exists $engines->{MyISAM} && $engines->{MyISAM}->{Support} ne 'NO';
43+
44+
plan tests => 1 + ($have_myisam ? 12 : 0) + ($have_innodb ? 22 : 0);
4245

4346
if ($have_innodb) {
44-
plan tests => 22;
4547

4648
ok $dbh->do("DROP TABLE IF EXISTS dbd_mysql_t50commit"), "drop table if exists dbd_mysql_t50commit";
4749
my $create =<<EOT;
@@ -100,15 +102,15 @@ EOT
100102
ok $dbh->do("DROP TABLE dbd_mysql_t50commit");
101103

102104
}
103-
else {
104-
plan tests => 13;
105+
106+
if ($have_myisam) {
105107

106108
ok $dbh->do("DROP TABLE IF EXISTS dbd_mysql_t50commit"), "drop table if exists dbd_mysql_t50commit";
107109
my $create =<<EOT;
108110
CREATE TABLE dbd_mysql_t50commit (
109111
id INT(4) NOT NULL default 0,
110112
name VARCHAR(64) NOT NULL default ''
111-
)
113+
) ENGINE=MyISAM
112114
EOT
113115

114116
ok $dbh->do($create), 'create dbd_mysql_t50commit';
@@ -154,5 +156,7 @@ EOT
154156
ok $got_warning, "Should be warning defined upon rollback of non-trx table";
155157

156158
ok $dbh->do("DROP TABLE dbd_mysql_t50commit");
157-
ok $dbh->disconnect();
159+
158160
}
161+
162+
ok $dbh->disconnect();

0 commit comments

Comments
 (0)