line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DBIx::Version; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
18851
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
40
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
44
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
require Exporter; |
7
|
1
|
|
|
1
|
|
1219
|
use AutoLoader qw(AUTOLOAD); |
|
1
|
|
|
|
|
2291
|
|
|
1
|
|
|
|
|
6
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Items to export into callers namespace by default. Note: do not export |
12
|
|
|
|
|
|
|
# names by default without a very good reason. Use EXPORT_OK instead. |
13
|
|
|
|
|
|
|
# Do not simply export all your public functions/methods/constants. |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# This allows declaration use DBIx::Version ':all'; |
16
|
|
|
|
|
|
|
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK |
17
|
|
|
|
|
|
|
# will save memory. |
18
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ qw( |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
) ] ); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
our @EXPORT = qw( |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# Preloaded methods go here. |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub Version { |
32
|
1
|
|
|
1
|
1
|
114
|
my $dbh = shift; |
33
|
|
|
|
|
|
|
|
34
|
1
|
50
|
|
|
|
6
|
return (undef, undef, undef) if not defined $dbh; |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
my $version; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# look for MontySQL |
39
|
0
|
0
|
|
|
|
|
if (exists $dbh->{'mysql_serverinfo'}) { |
40
|
0
|
|
|
|
|
|
$version = $dbh->{'mysql_serverinfo'}; |
41
|
0
|
0
|
|
|
|
|
if ($version =~ /^(\d{1,2}\.\d{1,2}\.\d{1,2}-)/) { |
42
|
|
|
|
|
|
|
# 4.0.17-standard-log |
43
|
0
|
|
|
|
|
|
return ('mysql', $1, $version); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
else { |
46
|
0
|
|
|
|
|
|
return (undef, undef, undef); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# look for PostgreSQL |
51
|
0
|
|
|
|
|
|
eval { |
52
|
0
|
|
|
|
|
|
my $sql = q{select version()}; |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
my $sth = $dbh->prepare($sql); |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
my $rv = $sth->execute(); |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
($version) = $sth->fetchrow_array(); |
59
|
0
|
|
|
|
|
|
$sth->finish(); |
60
|
|
|
|
|
|
|
}; |
61
|
0
|
0
|
|
|
|
|
if ($@) { # prolly not valid query for this database |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
else { |
64
|
0
|
0
|
|
|
|
|
if ($version =~ /^PostgreSQL (\d{1,2}\.\d{1,2}\.\d{1,2}) /) { |
65
|
|
|
|
|
|
|
# PostgreSQL 7.4.1 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.3.2 20031107 (Red Hat Linux 3.3.2-2) |
66
|
0
|
|
|
|
|
|
return ('postgresql', $1, $version); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
else { |
69
|
0
|
|
|
|
|
|
return (undef, undef, undef); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# look for Oracle |
74
|
|
|
|
|
|
|
# alternately, $dbh->get_info(18); # SQL_DBMS_VER |
75
|
0
|
|
|
|
|
|
eval { |
76
|
0
|
|
|
|
|
|
my $sql = q{SELECT version FROM V$INSTANCE}; |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
my $sth = $dbh->prepare($sql); |
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
my $rv = $sth->execute(); |
81
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
($version) = $sth->fetchrow_array(); |
83
|
0
|
|
|
|
|
|
$sth->finish(); |
84
|
|
|
|
|
|
|
}; |
85
|
0
|
0
|
|
|
|
|
if ($@) { # prolly not valid query for this database |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
else { |
88
|
0
|
|
|
|
|
|
return ('oracle', $version, $version); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# look for Microsoft SQL Server or Sybase |
92
|
0
|
|
|
|
|
|
eval { |
93
|
0
|
|
|
|
|
|
my $sql = q{SELECT @@version}; |
94
|
|
|
|
|
|
|
|
95
|
0
|
|
|
|
|
|
my $sth = $dbh->prepare($sql); |
96
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
my $rv = $sth->execute(); |
98
|
|
|
|
|
|
|
|
99
|
0
|
|
|
|
|
|
($version) = $sth->fetchrow_array(); |
100
|
0
|
|
|
|
|
|
$sth->finish(); |
101
|
|
|
|
|
|
|
}; |
102
|
0
|
0
|
|
|
|
|
if ($@) { # prolly not valid query for this database |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
else { |
105
|
0
|
0
|
|
|
|
|
if ($version =~ / - (\d{1,2}\.\d{1,2}\.\d{3}) /) { |
|
|
0
|
|
|
|
|
|
106
|
0
|
|
|
|
|
|
return ('sqlserver', $1, $version); |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
elsif ($version =~ m|/(\d{1,2}\.\d{1,2}\.\d{1,2}\.\d{1,2})/| ) { |
109
|
|
|
|
|
|
|
# Adaptive Server Enterprise/12.5.0.1/SWR 9982 |
110
|
0
|
|
|
|
|
|
return ('sqlserver', $1, $version); |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
else { |
113
|
0
|
|
|
|
|
|
return (undef, undef, undef); |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
# Autoload methods go after =cut, and are processed by the autosplit program. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
1; |
121
|
|
|
|
|
|
|
__END__ |