1use strict;
2use warnings;
3
4# database specific definitions for a 'mysql' database
5
6my $have_transactions;
7
8
9#
10#   This function generates a list of tables associated to a
11#   given DSN.
12#
13sub ListTables(@) {
14    my($dbh) = shift;
15    my(@tables);
16
17    @tables = $dbh->func('_ListTables');
18    if ($dbh->errstr) {
19	die "Cannot create table list: " . $dbh->errstr;
20    }
21    @tables;
22}
23
24
25#
26#   This function is called by DBD::pNET; given a hostname and a
27#   dsn without hostname, return a dsn for connecting to dsn at
28#   host.
29sub HostDsn ($$) {
30    my($hostname, $dsn) = @_;
31    "$dsn:$hostname";
32}
33
34#
35#   Return TRUE, if database supports transactions
36#
37sub have_transactions () {
38    my ($dbh) = @_;
39    return 1 unless $dbh;
40    if (!defined($have_transactions)) {
41        $have_transactions = "";
42        my $sth = $dbh->prepare("SHOW VARIABLES");
43        $sth->execute();
44        while (my $row = $sth->fetchrow_hashref()) {
45            if ($row->{'Variable_name'} eq 'have_bdb'  &&
46                $row->{'Value'} eq 'YES') {
47                $have_transactions = "bdb";
48                last;
49            }
50            if ($row->{'Variable_name'} eq 'have_innodb'  &&
51                $row->{'Value'} eq 'YES') {
52                $have_transactions = "innodb";
53                last;
54            }
55            if ($row->{'Variable_name'} eq 'have_gemini'  &&
56                $row->{'Value'} eq 'YES') {
57                $have_transactions = "gemini";
58                last;
59            }
60        }
61    }
62    return $have_transactions;
63}
64
65
661;
67