File: 99_bug_server_prepare_blob_null.t

package info (click to toggle)
libdbd-mysql-perl 4.028-2%2Bdeb8u2
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 1,312 kB
  • ctags: 584
  • sloc: perl: 4,425; ansic: 4,259; makefile: 26
file content (63 lines) | stat: -rw-r--r-- 1,316 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/perl

use strict;
use warnings;

use DBI;
use Carp qw(croak);
use Test::More;
use vars qw($table $test_dsn $test_user $test_password);
use vars qw($COL_NULLABLE $COL_KEY);
use lib 't', '.';
require 'lib.pl';

my $dbh;
$test_dsn .= ';mysql_server_prepare=1';
eval {$dbh= DBI->connect($test_dsn, $test_user, $test_password,
                      { RaiseError => 1, PrintError => 1, AutoCommit => 0 });};
if ($@) {
    plan skip_all => "ERROR: $@. Can't continue test";
}

#
# DROP/CREATE PROCEDURE will give syntax error for these versions
#
if (!MinimumVersion($dbh, '5.0')) {
    plan skip_all =>
        "SKIP TEST: You must have MySQL version 5.0 and greater for this test to run";
}

plan tests => 11;

ok $dbh->do("DROP TABLE IF EXISTS $table");

my $create =<<EOT;
CREATE TABLE $table (
    data LONGBLOB
)
EOT

ok $dbh->do($create);

$dbh->do("insert into $table (data) values(null)");

my $sth = $dbh->prepare("select data from $table");
ok $sth->execute;
my $row = $sth->fetch;
is $row->[0] => undef;

ok $sth->finish;

$dbh->do("insert into $table (data) values('a')");
$sth = $dbh->prepare("select data from $table");
ok $sth->execute;
$row = $sth->fetch;
is $row->[0] => undef;
$row = $sth->fetch;
is $row->[0] => 'a';

ok $sth->finish;

ok $dbh->do("DROP TABLE $table");

ok $dbh->disconnect;