Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perl-5.8.0 / man / man3 / DBD::mysql.3
.\" Automatically generated by Pod::Man v1.34, Pod::Parser v1.13
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sh \" Subsection heading
.br
.if t .Sp
.ne 5
.PP
\fB\\$1\fR
.PP
..
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. | will give a
.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
.\" expand to `' in nroff, nothing in troff, for use with C<>.
.tr \(*W-|\(bv\*(Tr
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
'br\}
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. nr % 0
. rr F
.\}
.\"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.hy 0
.if n .na
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff
.if n \{\
. ds #H 0
. ds #V .8m
. ds #F .3m
. ds #[ \f1
. ds #] \fP
.\}
.if t \{\
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. ds #V .6m
. ds #F 0
. ds #[ \&
. ds #] \&
.\}
. \" simple accents for nroff and troff
.if n \{\
. ds ' \&
. ds ` \&
. ds ^ \&
. ds , \&
. ds ~ ~
. ds /
.\}
.if t \{\
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
. ds : e
. ds 8 ss
. ds o a
. ds d- d\h'-1'\(ga
. ds D- D\h'-1'\(hy
. ds th \o'bp'
. ds Th \o'LP'
. ds ae ae
. ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "DBD::mysql 3"
.TH DBD::mysql 3 "2002-10-01" "perl v5.8.0" "User Contributed Perl Documentation"
.SH "NAME"
DBD::mSQL / DBD::mysql \- mSQL and mysql drivers for the Perl5 Database
Interface (DBI)
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 1
\& use DBI;
.Ve
.PP
.Vb 2
\& $driver = "mSQL"; # or "mSQL1";
\& $dsn = "DBI:$driver:database=$database;host=$hostname";
.Ve
.PP
.Vb 1
\& $dbh = DBI->connect($dsn, undef, undef);
.Ve
.PP
.Vb 1
\& or
.Ve
.PP
.Vb 2
\& $driver = "mysql";
\& $dsn = "DBI:$driver:database=$database;host=$hostname;port=$port";
.Ve
.PP
.Vb 1
\& $dbh = DBI->connect($dsn, $user, $password);
.Ve
.PP
.Vb 3
\& $drh = DBI->install_driver("mysql");
\& @databases = $drh->func($host, $port, '_ListDBs');
\& @tables = $dbh->func( '_ListTables' );
.Ve
.PP
.Vb 9
\& $sth = $dbh->prepare("SELECT * FROM foo WHERE bla");
\& or
\& $sth = $dbh->prepare("LISTFIELDS $table");
\& or
\& $sth = $dbh->prepare("LISTINDEX $table $index");
\& $sth->execute;
\& $numRows = $sth->rows;
\& $numFields = $sth->{'NUM_OF_FIELDS'};
\& $sth->finish;
.Ve
.PP
.Vb 4
\& $rc = $drh->func('createdb', $database, $host, $user, $password, 'admin');
\& $rc = $drh->func('dropdb', $database, $host, $user, $password, 'admin');
\& $rc = $drh->func('shutdown', $host, $user, $password, 'admin');
\& $rc = $drh->func('reload', $host, $user, $password, 'admin');
.Ve
.PP
.Vb 4
\& $rc = $dbh->func('createdb', $database, 'admin');
\& $rc = $dbh->func('dropdb', $database, 'admin');
\& $rc = $dbh->func('shutdown', 'admin');
\& $rc = $dbh->func('reload', 'admin');
.Ve
.SH "EXAMPLE"
.IX Header "EXAMPLE"
.Vb 1
\& #!/usr/bin/perl
.Ve
.PP
.Vb 2
\& use strict;
\& use DBI();
.Ve
.PP
.Vb 4
\& # Connect to the database.
\& my $dbh = DBI->connect("DBI:mysql:database=test;host=localhost",
\& "joe", "joe's password",
\& {'RaiseError' => 1});
.Ve
.PP
.Vb 4
\& # Drop table 'foo'. This may fail, if 'foo' doesn't exist.
\& # Thus we put an eval around it.
\& eval { $dbh->do("DROP TABLE foo") };
\& print "Dropping foo failed: $@\en" if $@;
.Ve
.PP
.Vb 3
\& # Create a new table 'foo'. This must not fail, thus we don't
\& # catch errors.
\& $dbh->do("CREATE TABLE foo (id INTEGER, name VARCHAR(20))");
.Ve
.PP
.Vb 3
\& # INSERT some data into 'foo'. We are using $dbh->quote() for
\& # quoting the name.
\& $dbh->do("INSERT INTO foo VALUES (1, " . $dbh->quote("Tim") . ")");
.Ve
.PP
.Vb 2
\& # Same thing, but using placeholders
\& $dbh->do("INSERT INTO foo VALUES (?, ?)", undef, 2, "Jochen");
.Ve
.PP
.Vb 7
\& # Now retrieve data from the table.
\& my $sth = $dbh->prepare("SELECT * FROM foo");
\& $sth->execute();
\& while (my $ref = $sth->fetchrow_hashref()) {
\& print "Found a row: id = $ref->{'id'}, name = $ref->{'name'}\en";
\& }
\& $sth->finish();
.Ve
.PP
.Vb 2
\& # Disconnect from the database.
\& $dbh->disconnect();
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
\&\fBDBD::mysql\fR and \fBDBD::mSQL\fR are the Perl5 Database Interface drivers
for the mysql, mSQL 1.\fIx\fR and mSQL 2.\fIx\fR databases. The drivers are part
of the \fIMsql-Mysql-modules\fR package.
.PP
In other words: DBD::mSQL and DBD::mysql are an interface between the Perl
programming language and the mSQL or mysql programming \s-1API\s0 that come with
the mSQL any mysql relational database management systems. Most functions
provided by the respective programming \s-1API\s0's are supported. Some
rarely used functions are missing, mainly because noone ever requested
them. :\-)
.PP
In what follows we first discuss the use of DBD::mysql and DBD::mSQL,
because this is what you will need the most. For installation, see the
sections on \s-1INSTALLATION\s0, \*(L"\s-1WIN32\s0 \s-1INSTALLATION\s0\*(R", \*(L"\s-1KNOWN\s0 \s-1PROBLEMS\s0\*(R"
and \*(L"\s-1KNOWN\s0 \s-1BUGS\s0\*(R" below. See \s-1EXAMPLE\s0 for a simple example above.
.PP
From perl you activate the interface with the statement
.PP
.Vb 1
\& use DBI;
.Ve
.PP
After that you can connect to multiple mSQL or MySQL database servers
and send multiple queries to any of them via a simple object oriented
interface. Two types of objects are available: database handles and
statement handles. Perl returns a database handle to the connect
method like so:
.PP
.Vb 2
\& $dbh = DBI->connect("DBI:mSQL:database=$db;host=$host",
\& undef, undef, {RaiseError => 1});
.Ve
.PP
or
.PP
.Vb 2
\& $dbh = DBI->connect("DBI:mysql:database=$db;host=$host",
\& $user, $password, {RaiseError => 1});
.Ve
.PP
Once you have connected to a database, you can can execute \s-1SQL\s0
statements with:
.PP
.Vb 3
\& my $query = sprintf("INSERT INTO foo VALUES (%d, %s)",
\& $number, $dbh->quote("name"));
\& $dbh->do($query);
.Ve
.PP
See \s-1\fIDBI\s0\fR\|(3) for details on the quote and do methods. An alternative
approach is
.PP
.Vb 2
\& $dbh->do("INSERT INTO foo VALUES (?, ?)", undef,
\& $number, $name);
.Ve
.PP
in which case the quote method is executed automatically. See also
the bind_param method in \s-1\fIDBI\s0\fR\|(3). See \*(L"\s-1DATABASE\s0 \s-1HANDLES\s0\*(R" below
for more details on database handles.
.PP
If you want to retrieve results, you need to create a so-called
statement handle with:
.PP
.Vb 2
\& $sth = $dbh->prepare("SELECT * FROM $table");
\& $sth->execute();
.Ve
.PP
This statement handle can be used for multiple things. First of all
you can retreive a row of data:
.PP
.Vb 1
\& my $row = $sth->fetchow_hashref();
.Ve
.PP
If your table has columns \s-1ID\s0 and \s-1NAME\s0, then \f(CW$row\fR will be hash ref with
keys \s-1ID\s0 and \s-1NAME\s0. See \*(L"\s-1STATEMENT\s0 \s-1HANDLES\s0\*(R" below for more details on
statement handles.
.PP
But now for a more formal approach:
.Sh "Class Methods"
.IX Subsection "Class Methods"
.IP "\fBconnect\fR" 4
.IX Item "connect"
.Vb 1
\& use DBI;
.Ve
.Sp
.Vb 3
\& $driver = "mSQL"; # or "mSQL1"
\& $dsn = "DBI:$driver:$database";
\& $dsn = "DBI:$driver:database=$database;host=$hostname";
.Ve
.Sp
.Vb 1
\& $dbh = DBI->connect($dsn, undef, undef);
.Ve
.Sp
.Vb 1
\& or
.Ve
.Sp
.Vb 3
\& $dsn = "DBI:mysql:$database";
\& $dsn = "DBI:mysql:database=$database;host=$hostname";
\& $dsn = "DBI:mysql:database=$database;host=$hostname;port=$port";
.Ve
.Sp
.Vb 1
\& $dbh = DBI->connect($dsn, $user, $password);
.Ve
.Sp
A \f(CW\*(C`database\*(C'\fR must always be specified.
.RS 4
.IP "host" 8
.IX Item "host"
.PD 0
.IP "port" 8
.IX Item "port"
.PD
The hostname, if not specified or specified as '', will default to an
mysql or mSQL daemon running on the local machine on the default port
for the \s-1UNIX\s0 socket.
.Sp
Should the mysql or mSQL daemon be running on a non-standard port number,
you may explicitly state the port number to connect to in the \f(CW\*(C`hostname\*(C'\fR
argument, by concatenating the \fIhostname\fR and \fIport number\fR together
separated by a colon ( \f(CW\*(C`:\*(C'\fR ) character or by using the \f(CW\*(C`port\*(C'\fR argument.
This doesn't work for mSQL 2: You have to create an alternative config
file and load it using the msql_configfile attribute, see below.
.IP "mysql_client_found_rows" 8
.IX Item "mysql_client_found_rows"
Enables (\s-1TRUE\s0 value) or disables (\s-1FALSE\s0 value) the flag \s-1CLIENT_FOUND_ROWS\s0
while connecting to the MySQL server. This has a somewhat funny effect:
Without mysql_client_found_rows, if you perform a query like
.Sp
.Vb 1
\& UPDATE $table SET id = 1 WHERE id = 1
.Ve
.Sp
then the MySQL engine will always return 0, because no rows have changed.
With mysql_client_found_rows however, it will return the number of rows
that have an id 1, as some people are expecting. (At least for compatibility
to other engines.)
.Sp
By default this flag is disabled. However, you can enable it by default,
when installing the Msql-Mysql-modules with
.Sp
.Vb 3
\& perl Makefile.PL --config --mysql-use-client-found-rows
\& make
\& make install
.Ve
.IP "mysql_compression" 8
.IX Item "mysql_compression"
As of MySQL 3.22.3, a new feature is supported: If your \s-1DSN\s0 contains
the option \*(L"mysql_compression=1\*(R", then the communication between client
and server will be compressed.
.IP "mysql_connect_timeout" 8
.IX Item "mysql_connect_timeout"
If your \s-1DSN\s0 contains the option \*(L"mysql_connect_timeout=##\*(R", the connect
request to the server will timeout if it has not been successful after
the given number of seconds.
.IP "mysql_read_default_file" 8
.IX Item "mysql_read_default_file"
.PD 0
.IP "mysql_read_default_group" 8
.IX Item "mysql_read_default_group"
.PD
These options can be used to read a config file like /etc/my.cnf or
~/.my.cnf. By default MySQL's C client library doesn't use any config
files unlike the client programs (mysql, mysqladmin, ...) that do, but
outside of the C client library. Thus you need to explicitly request
reading a config file, as in
.Sp
.Vb 2
\& $dsn = "DBI:mysql:test;mysql_read_default_file=/home/joe/my.cnf";
\& $dbh = DBI->connect($dsn, $user, $password)
.Ve
.Sp
The option mysql_read_default_group can be used to specify the default
group in the config file: Usually this is the \fIclient\fR group, but
see the following example:
.Sp
.Vb 2
\& [perl]
\& host=perlhost
.Ve
.Sp
.Vb 2
\& [client]
\& host=localhost
.Ve
.Sp
If you read this config file, then you'll be typically connected to
\&\fIlocalhost\fR. However, by using
.Sp
.Vb 3
\& $dsn = "DBI:mysql:test;mysql_read_default_group=perl;"
\& . "mysql_read_default_file=/home/joe/my.cnf";
\& $dbh = DBI->connect($dsn, $user, $password);
.Ve
.Sp
you'll be connected to \fIperlhost\fR. Note that if you specify a
default group and do not specify a file, then the default config
files will all be read. See the (missing :\-) documentation of
the C function \fImysql_options()\fR for details.
.IP "mysql_socket" 8
.IX Item "mysql_socket"
As of MySQL 3.21.15, it is possible to choose the Unix socket that is
used for connecting to the server. This is done, for example, with
.Sp
.Vb 1
\& mysql_socket=/dev/mysql
.Ve
.Sp
Usually there's no need for this option, unless you are using another
location for the socket than that built into the client.
.RE
.RS 4
.RE
.Sh "Private MetaData Methods"
.IX Subsection "Private MetaData Methods"
.IP "\fBListDBs\fR" 4
.IX Item "ListDBs"
.Vb 4
\& my $drh = DBI->install_driver("mysql");
\& @dbs = $drh->func("$hostname:$port", '_ListDBs');
\& @dbs = $drh->func($hostname, $port, '_ListDBs');
\& @dbs = $dbh->func('_ListDBs');
.Ve
.Sp
Returns a list of all databases managed by the mysql daemon or
mSQL daemon running on \f(CW$hostname\fR, port \f(CW$port\fR. This method
is rarely needed for databases running on \f(CW\*(C`localhost\*(C'\fR: You should
use the portable method
.Sp
.Vb 1
\& @dbs = DBI->data_sources("mysql");
.Ve
.Sp
.Vb 1
\& or
.Ve
.Sp
.Vb 1
\& @dbs = DBI->data_sources("mSQL");
.Ve
.Sp
whenever possible. It is a design problem of this method, that there's
no way of supplying a host name or port number to \f(CW\*(C`data_sources\*(C'\fR, that's
the only reason why we still support \f(CW\*(C`ListDBs\*(C'\fR. :\-(
.IP "\fBListTables\fR" 4
.IX Item "ListTables"
*WARNING*: This method is obsolete due to \s-1DBI\s0's \f(CW$dbh\fR\->\fItable_info()\fR.
.Sp
.Vb 1
\& @tables = $dbh->func('_ListTables');
.Ve
.Sp
Once connected to the desired database on the desired mysql or mSQL
mSQL daemon with the \f(CW\*(C`DBI\-\*(C'\fR\fIconnect()\fR> method, we may extract a list
of the tables that have been created within that database.
.Sp
\&\f(CW\*(C`ListTables\*(C'\fR returns an array containing the names of all the tables
present within the selected database. If no tables have been created,
an empty list is returned.
.Sp
.Vb 4
\& @tables = $dbh->func( '_ListTables' );
\& foreach $table ( @tables ) {
\& print "Table: $table\en";
\& }
.Ve
.Sh "Server Administration"
.IX Subsection "Server Administration"
.RS 4
.IP "admin" 4
.IX Item "admin"
.Vb 4
\& $rc = $drh->func("createdb", $dbname, [host, user, password,], 'admin');
\& $rc = $drh->func("dropdb", $dbname, [host, user, password,], 'admin');
\& $rc = $drh->func("shutdown", [host, user, password,], 'admin');
\& $rc = $drh->func("reload", [host, user, password,], 'admin');
.Ve
.Sp
.Vb 1
\& or
.Ve
.Sp
.Vb 4
\& $rc = $dbh->func("createdb", $dbname, 'admin');
\& $rc = $dbh->func("dropdb", $dbname, 'admin');
\& $rc = $dbh->func("shutdown", 'admin');
\& $rc = $dbh->func("reload", 'admin');
.Ve
.Sp
For server administration you need a server connection. For obtaining
this connection you have two options: Either use a driver handle (drh)
and supply the appropriate arguments (host, defaults localhost, user,
defaults to '' and password, defaults to ''). A driver handle can be
obtained with
.Sp
.Vb 1
\& $drh = DBI->install_driver('mysql');
.Ve
.Sp
Otherwise reuse the existing connection of a database handle (dbh).
.Sp
There's only one function available for administrative purposes, comparable
to the m(y)sqladmin programs. The command being execute depends on the
first argument:
.RS 4
.IP "createdb" 8
.IX Item "createdb"
Creates the database \f(CW$dbname\fR. Equivalent to \*(L"m(y)sqladmin create \f(CW$dbname\fR\*(R".
.IP "dropdb" 8
.IX Item "dropdb"
Drops the database \f(CW$dbname\fR. Equivalent to \*(L"m(y)sqladmin drop \f(CW$dbname\fR\*(R".
.Sp
It should be noted that database deletion is
\&\fInot prompted for\fR in any way. Nor is it undo-able from \s-1DBI\s0.
.Sp
.Vb 1
\& Once you issue the dropDB() method, the database will be gone!
.Ve
.Sp
These method should be used at your own risk.
.IP "shutdown" 8
.IX Item "shutdown"
Silently shuts down the database engine. (Without prompting!)
Equivalent to \*(L"m(y)sqladmin shutdown\*(R".
.IP "reload" 8
.IX Item "reload"
Reloads the servers configuration files and/or tables. This can be particularly
important if you modify access privileges or create new users.
.RE
.RS 4
.RE
.RE
.RS 4
.SH "DATABASE HANDLES"
.IX Header "DATABASE HANDLES"
The DBD::mysql driver supports the following attributes of database
handles (read only):
.Sp
.Vb 3
\& $infoString = $dbh->{'info'};
\& $threadId = $dbh->{'thread_id'};
\& $insertId = $dbh->{'mysql_insertid'}
.Ve
.Sp
These correspond to \fImysql_info()\fR, \fImysql_thread_id()\fR and \fImysql_insertid()\fR,
respectively.
.SH "STATEMENT HANDLES"
.IX Header "STATEMENT HANDLES"
The statement handles of DBD::mysql and DBD::mSQL support a number
of attributes. You access these by using, for example,
.Sp
.Vb 1
\& my $numFields = $sth->{'NUM_OF_FIELDS'};
.Ve
.Sp
Note, that most attributes are valid only after a successfull \fIexecute\fR.
An \f(CW\*(C`undef\*(C'\fR value will returned in that case. The most important exception
is the \f(CW\*(C`mysql_use_result\*(C'\fR attribute: This forces the driver to use
mysql_use_result rather than mysql_store_result. The former is faster
and less memory consuming, but tends to block other processes. (That's why
mysql_store_result is the default.)
.Sp
To set the \f(CW\*(C`mysql_use_result\*(C'\fR attribute, use either of the following:
.Sp
.Vb 1
\& my $sth = $dbh->prepare("QUERY", { "mysql_use_result" => 1});
.Ve
.Sp
or
.Sp
.Vb 2
\& my $sth = $dbh->prepare("QUERY");
\& $sth->{"mysql_use_result"} = 1;
.Ve
.Sp
Column dependent attributes, for example \fI\s-1NAME\s0\fR, the column names,
are returned as a reference to an array. The array indices are
corresponding to the indices of the arrays returned by \fIfetchrow\fR
and similar methods. For example the following code will print a
header of table names together with all rows:
.Sp
.Vb 19
\& my $sth = $dbh->prepare("SELECT * FROM $table");
\& if (!$sth) {
\& die "Error:" . $dbh->errstr . "\en";
\& }
\& if (!$sth->execute) {
\& die "Error:" . $sth->errstr . "\en";
\& }
\& my $names = $sth->{'NAME'};
\& my $numFields = $sth->{'NUM_OF_FIELDS'};
\& for (my $i = 0; $i < $numFields; $i++) {
\& printf("%s%s", $$names[$i], $i ? "," : "");
\& }
\& print "\en";
\& while (my $ref = $sth->fetchrow_arrayref) {
\& for (my $i = 0; $i < $numFields; $i++) {
\& printf("%s%s", $$ref[$i], $i ? "," : "");
\& }
\& print "\en";
\& }
.Ve
.Sp
For portable applications you should restrict yourself to attributes with
capitalized or mixed case names. Lower case attribute names are private
to DBD::mSQL and DBD::mysql. The attribute list includes:
.IP "ChopBlanks" 4
.IX Item "ChopBlanks"
this attribute determines whether a \fIfetchrow\fR will chop preceding
and trailing blanks off the column values. Chopping blanks does not
have impact on the \fImax_length\fR attribute.
.IP "mysql_insertid" 4
.IX Item "mysql_insertid"
MySQL has the ability to choose unique key values automatically. If this
happened, the new \s-1ID\s0 will be stored in this attribute. This attribute
is not valid for DBD::mSQL. An alternative way for accessing this attribute
is via \f(CW$dbh\fR\->{'mysql_insertid'}. (Note we are using the \f(CW$dbh\fR in this case!)
.IP "mysql_is_blob" 4
.IX Item "mysql_is_blob"
Reference to an array of boolean values; \s-1TRUE\s0 indicates, that the
respective column is a blob. This attribute is valid for MySQL only.
.IP "mysql_is_key" 4
.IX Item "mysql_is_key"
Reference to an array of boolean values; \s-1TRUE\s0 indicates, that the
respective column is a key. This is valid for MySQL only.
.IP "mysql_is_num" 4
.IX Item "mysql_is_num"
Reference to an array of boolean values; \s-1TRUE\s0 indicates, that the
respective column contains numeric values.
.IP "mysql_is_pri_key" 4
.IX Item "mysql_is_pri_key"
Reference to an array of boolean values; \s-1TRUE\s0 indicates, that the
respective column is a primary key. This is only valid for MySQL
and mSQL 1.0.x: mSQL 2.x uses indices.
.IP "mysql_length" 4
.IX Item "mysql_length"
.PD 0
.IP "mysql_max_length" 4
.IX Item "mysql_max_length"
.PD
A reference to an array of maximum column sizes. The \fImax_length\fR is
the maximum physically present in the result table, \fIlength\fR gives
the theoretically possible maximum. \fImax_length\fR is valid for MySQL
only.
.IP "\s-1NAME\s0" 4
.IX Item "NAME"
A reference to an array of column names.
.IP "\s-1NULLABLE\s0" 4
.IX Item "NULLABLE"
A reference to an array of boolean values; \s-1TRUE\s0 indicates that this column
may contain \s-1NULL\s0's.
.IP "\s-1NUM_OF_FIELDS\s0" 4
.IX Item "NUM_OF_FIELDS"
Number of fields returned by a \fI\s-1SELECT\s0\fR or \fI\s-1LISTFIELDS\s0\fR statement.
You may use this for checking whether a statement returned a result:
A zero value indicates a non-SELECT statement like \fI\s-1INSERT\s0\fR,
\&\fI\s-1DELETE\s0\fR or \fI\s-1UPDATE\s0\fR.
.IP "mysql_table" 4
.IX Item "mysql_table"
A reference to an array of table names, useful in a \fI\s-1JOIN\s0\fR result.
.IP "\s-1TYPE\s0" 4
.IX Item "TYPE"
A reference to an array of column types. The engine's native column
types are mapped to portable types like \s-1\fIDBI::SQL_INTEGER\s0()\fR or
\&\s-1\fIDBI::SQL_VARCHAR\s0()\fR, as good as possible. Not all native types have
a meaningfull equivalent, for example \fIDBD::mSQL::IDX_TYPE()\fR or
DBD::mysql::FIELD_TYPE_INTERVAL are mapped to \s-1\fIDBI::SQL_VARCHAR\s0()\fR.
If you need the native column types, use \fImysql_type\fR or \fImsql_type\fR,
respectively. See below.
.IP "mysql_type" 4
.IX Item "mysql_type"
A reference to an array of MySQL's native column types, for example
\&\fIDBD::mysql::FIELD_TYPE_SHORT()\fR or \fIDBD::mysql::FIELD_TYPE_STRING()\fR.
Use the \fI\s-1TYPE\s0\fR attribute, if you want portable types like
\&\s-1\fIDBI::SQL_SMALLINT\s0()\fR or \s-1\fIDBI::SQL_VARCHAR\s0()\fR.
.IP "mysql_type_name" 4
.IX Item "mysql_type_name"
Similar to mysql, but type names and not numbers are returned.
Whenever possible, the \s-1ANSI\s0 \s-1SQL\s0 name is preferred.
.RE
.RS 4
.SH "TRANSACTION SUPPORT"
.IX Header "TRANSACTION SUPPORT"
Beginning with Msql-Mysql-modules 1.2216, transactions are supported
by DBD::mysql. The transaction support works as follows:
.IP "\(bu" 4
By default AutoCommit mode is on, following the \s-1DBI\s0 specifications.
.IP "\(bu" 4
If you execute
.Sp
.Vb 1
\& $dbh-E<gt>{'AutoCommit'} = 0;
.Ve
.Sp
or
.Sp
.Vb 1
\& $dbh-E<gt>{'AutoCommit'} = 1;
.Ve
.Sp
then the driver will set the MySQL server variable autocommit to 0 or
1, respectively. Switching from 0 to 1 will also issue a \s-1COMMIT\s0,
following the \s-1DBI\s0 specifications.
.IP "\(bu" 4
The methods
.Sp
.Vb 2
\& $dbh-E<gt>rollback();
\& $dbh-E<gt>commit();
.Ve
.Sp
will issue the commands \s-1COMMIT\s0 and \s-1ROLLBACK\s0, respectively. A
\&\s-1ROLLBACK\s0 will also be issued if AutoCommit mode is off and the
database handles \s-1DESTROY\s0 method is called. Again, this is following
the \s-1DBI\s0 specifications.
.RE
.RS 4
.Sp
Given the above, you should note the following:
.IP "\(bu" 4
You should never change the server variable autocommit manually,
unless you are ignoring \s-1DBI\s0's transaction support.
.IP "\(bu" 4
Switching AutoCommit mode from on to off or vice versa may fail.
You should always check for errors, when changing AutoCommit mode.
The suggested way of doing so is using the \s-1DBI\s0 flag RaiseError.
If you don't like RaiseError, you have to use code like the
following:
.Sp
.Vb 4
\& $dbh->{'AutoCommit'} = 0;
\& if ($dbh->{'AutoCommit'}) {
\& # An error occurred!
\& }
.Ve
.IP "\(bu" 4
If you detect an error while changing the AutoCommit mode, you
should no longer use the database handle. In other words, you
should disconnect and reconnect again, because the transaction
mode is unpredictable. Alternatively you may verify the transaction
mode by checking the value of the server variable autocommit.
However, such behaviour isn't portable.
.RE
.RS 4
.SH "SQL EXTENSIONS"
.IX Header "SQL EXTENSIONS"
Certain metadata functions of mSQL and mysql that are available on the
C \s-1API\s0 level, haven't been implemented here. Instead they are implemented
as \*(L"\s-1SQL\s0 extensions\*(R" because they return in fact nothing else but the
equivalent of a statement handle. These are:
.ie n .IP "\s-1LISTFIELDS\s0 $table" 4
.el .IP "\s-1LISTFIELDS\s0 \f(CW$table\fR" 4
.IX Item "LISTFIELDS $table"
Returns a statement handle that describes the columns of \f(CW$table\fR.
Ses the docs of msqlListFields or mysql_list_fields (C \s-1API\s0) for
details.
.ie n .IP "\s-1LISTINDEX\s0 $table\fR \f(CW$index" 4
.el .IP "\s-1LISTINDEX\s0 \f(CW$table\fR \f(CW$index\fR" 4
.IX Item "LISTINDEX $table $index"
mSQL only; returns a statement handle that describes the index \f(CW$index\fR
of table \f(CW$table\fR. See the docs of msqlListIndex for details.
.RE
.RS 4
.SH "COMPATIBILITY ALERT"
.IX Header "COMPATIBILITY ALERT"
The statement attribute \fI\s-1TYPE\s0\fR has changed its meaning, as of
Msql-Mysql-modules 1.19_19. Formerly it used to be the an array
of native engine's column types, but it is now an array of
portable \s-1SQL\s0 column types. The old attribute is still available
as \fImysql_type\fR or \fImsql_type\fR, respectively.
.Sp
The Msql-Mysql-modules are a moving target, due to a number of reasons:
.IP "\-" 8
Of course they have to conform the \s-1DBI\s0 guidelines and developments.
.IP "\-" 8
They have to keep track with the latest MySQL developments.
.IP "\-" 8
And, surprisingly, they have to be as close to \s-1ODBC\s0 as possible: This is
due to the current direction of \s-1DBI\s0.
.IP "\-" 8
And, last not least, as any tool they have a little bit of own life.
.RE
.RS 4
.Sp
This means that a lot of things had to and have to be changed. As I am not
interested in maintaining a lot of compatibility kludges, which only
increase the drivers code without being really usefull, I did and will
remove some features, methods or attributes.
.Sp
To ensure a smooth upgrade, the following policy will be applied:
.IP "Obsolete features" 8
.IX Item "Obsolete features"
The first step is to declare something obsolete. This means, that no code
is changed, but the feature appears in the list of obsolete features. See
\&\*(L"Obsolete Features\*(R" below.
.IP "Deprecated features" 8
.IX Item "Deprecated features"
If the feature has been obsolete for quite some time, typically in the
next major stable release, warnings will be inserted in the code. You
can suppress these warnings by setting
.Sp
.Vb 1
\& $DBD::mysql = 1;
.Ve
.Sp
In the docs the feature will be moved from the list of obsolete features
to the list of deprecated features. See \*(L"Deprecated Features\*(R" below.
.IP "Removing features" 8
.IX Item "Removing features"
Finally features will be removed silently in the next major stable
release. The feature will be shown in the list of historic features.
See \*(L"Historic Features\*(R" below.
.RE
.RS 4
.Sp
Example: The statement handle attribute
.Sp
.Vb 1
\& $sth->{'LENGTH'}
.Ve
.Sp
was declared obsolete in Msql-Mysql-modules 1.18xy. It is considered
deprecated in Msql-Mysql-modules 1.20xy (current as of this writing)
and will finally be removed in Msql-Mysql-modules 1.22xy.
.RE
.Sh "Obsolete Features"
.IX Subsection "Obsolete Features"
.IP "_ListTables" 8
.IX Item "_ListTables"
This method is obsoleted by \s-1DBI\s0's new method
.Sp
.Vb 1
\& $dbh->tables()
.Ve
.Sp
See also \f(CW$dbh\fR\->\fItable_info()\fR. Portable applications will prefer
.Sp
.Vb 1
\& @tables = map { $_ =~ s/.*\e.//; $_ } $dbh->tables()
.Ve
.Sp
because, depending on the engine, the string \*(L"user.table\*(R" will be
returned, user being the table owner. The method will be deprecated
in 1.23_xy and 1.24xy and removed in 1.25_xy and 1.26xy.
.Sh "Deprecated Features"
.IX Subsection "Deprecated Features"
.IP "_InsertID" 8
.IX Item "_InsertID"
The method
.Sp
.Vb 1
\& $dbh->func('_InsertID');
.Ve
.Sp
can be replaced with
.Sp
.Vb 1
\& $dbh->{'mysql_insertid'};
.Ve
.Sp
The method is deprecated as of 1.21_xy, thus it will be removed in
1.23_xy and 1.24xy.
.IP "Statement handle attributes:" 8
.IX Item "Statement handle attributes:"
.RS 8
.PD 0
.IP "affected_rows" 12
.IX Item "affected_rows"
.IP "\s-1IS_PRI_KEY\s0" 12
.IX Item "IS_PRI_KEY"
.IP "is_pri_key" 12
.IX Item "is_pri_key"
.IP "\s-1IS_NOT_NULL\s0" 12
.IX Item "IS_NOT_NULL"
.IP "is_not_null" 12
.IX Item "is_not_null"
.IP "\s-1IS_KEY\s0" 12
.IX Item "IS_KEY"
.IP "is_key" 12
.IX Item "is_key"
.IP "\s-1IS_BLOB\s0" 12
.IX Item "IS_BLOB"
.IP "is_blob" 12
.IX Item "is_blob"
.IP "\s-1IS_NUM\s0" 12
.IX Item "IS_NUM"
.IP "is_num" 12
.IX Item "is_num"
.IP "\s-1LENGTH\s0" 12
.IX Item "LENGTH"
.IP "length" 12
.IX Item "length"
.IP "\s-1MAXLENGTH\s0" 12
.IX Item "MAXLENGTH"
.IP "maxlength" 12
.IX Item "maxlength"
.IP "\s-1NUMROWS\s0" 12
.IX Item "NUMROWS"
.IP "numrows" 12
.IX Item "numrows"
.IP "\s-1NUMFIELDS\s0" 12
.IX Item "NUMFIELDS"
.IP "numfields" 12
.IX Item "numfields"
.IP "\s-1RESULT\s0" 12
.IX Item "RESULT"
.IP "result" 12
.IX Item "result"
.IP "\s-1TABLE\s0" 12
.IX Item "TABLE"
.IP "table" 12
.IX Item "table"
.IP "format_max_size" 12
.IX Item "format_max_size"
.IP "format_default_size" 12
.IX Item "format_default_size"
.IP "format_type_name" 12
.IX Item "format_type_name"
.RE
.RS 8
.PD
.Sp
All of the above statement handle attributes are not conforming to \s-1DBI\s0's
naming conventions, thus they have been declared deprecated in 1.20xy.
However, I forgot to insert warnings in the driver. These warnings have
been inserted in 1.21_07, thus the attributes will be removed in 1.23_xy
and 1.24xy.
.Sp
In most of the above cases the driver name has been added and the resulting
name was lowercased. For example, you use
.Sp
.Vb 1
\& $sth->{'mysql_is_num'};
.Ve
.Sp
now. \s-1IS_NOT_NULL\s0 can be replaced with \s-1NULLABLE\s0 (note you need to invert
the logical value!), \s-1LENGTH\s0, format_max_size and format_default_size will
be dropped in favour of \s-1PRECISION\s0, affected_rows and \s-1NUMROWS\s0 are identical
with
.Sp
.Vb 1
\& $sth->rows();
.Ve
.Sp
and \s-1NUMFIELDS\s0 is the same as \s-1NUM_OF_FIELDS\s0. Finally format_right_justify
is the same as mysql_type_name.
.RE
.Sh "Historic Features"
.IX Subsection "Historic Features"
.IP "_CreateDB" 8
.IX Item "_CreateDB"
.PD 0
.IP "_DropDB" 8
.IX Item "_DropDB"
.PD
The methods
.Sp
.Vb 2
\& $dbh->func($db, '_CreateDB');
\& $dbh->func($db, '_DropDB');
.Ve
.Sp
have been used for creating or dropping databases. They have been removed
in 1.21_07 in favour of
.Sp
.Vb 2
\& $drh->func("createdb", $dbname, $host, "admin")
\& $drh->func("dropdb", $dbname, $host, "admin")
.Ve
.IP "_ListFields" 8
.IX Item "_ListFields"
The method
.Sp
.Vb 1
\& $sth = $dbh->func($table, '_ListFields');
.Ve
.Sp
has been used to list a tables columns names, types and other attributes.
This method has been removed in 1.21_07 in favour of
.Sp
.Vb 1
\& $sth = $dbh->prepare("LISTFIELDS $table");
.Ve
.IP "_ListSelectedFields" 8
.IX Item "_ListSelectedFields"
The method
.Sp
.Vb 1
\& $sth->func('_ListSelectedFields');
.Ve
.Sp
use to return a hash ref of attributes like '\s-1IS_NUM\s0', '\s-1IS_KEY\s0' and so
on. These attributes are now accessible via
.Sp
.Vb 2
\& $sth->{'mysql_is_num'};
\& $sth->{'mysql_is_key'};
.Ve
.Sp
and so on. Thus the method has been removed in 1.21_07.
.IP "_NumRows" 8
.IX Item "_NumRows"
The method
.Sp
.Vb 1
\& $sth->func('_NumRows');
.Ve
.Sp
used to be equivalent to
.Sp
.Vb 1
\& $sth->rows();
.Ve
.Sp
and has been removed in 1.21_07.
.SH "MULTITHREADING"
.IX Header "MULTITHREADING"
The multithreading capabilities of the Msql-Mysql-modules depend completely
on the underlying C libraries: The modules are working with handle data
only, no global variables are accessed or (to the best of my knowledge)
thread unsafe functions are called. Thus DBD::mSQL and DBD::mysql are
completely thread safe, if the C libraries thread safe and you don't
share handles among threads.
.PP
The obvious questions is: Are the C libraries thread safe? In the case of
mSQL the answer is definitely \*(L"no\*(R". The C library has a concept of one
single active connection at a time and that is not what threads like.
.PP
In the case of MySQL the answer is \*(L"mostly\*(R" and, in theory, you should
be able to get a \*(L"yes\*(R", if the C library is compiled for being thread
safe (By default it isn't.) by passing the option \-with\-thread\-safe\-client
to configure. See the section on \fIHow to make a threadsafe client\fR in
the manual.
.SH "INSTALLATION"
.IX Header "INSTALLATION"
Windows users may skip this section and pass over to \*(L"\s-1WIN32\s0 \s-1INSTALLATION\s0\*(R" below. Others, go on reading.
.PP
First of all, you do not need an installed MySQL server for installing
DBD::mSQL and/or DBD::mysql. However, you need at least the client
libraries and possibly the header files, if you are compiling DBD::mysql
or DBD::mSQL from source. In the case of MySQL you can create a
client-only version by using the configure option \-\-without\-server.
If you are using precompiled binaries, then it may be possible to
use just selected \s-1RPM\s0's like MySQL-client and MySQL-devel or something
similar, depending on the distribution.
.PP
First you need to install the \s-1DBI\s0 module. For using \fIdbimon\fR, a
simple \s-1DBI\s0 shell it is recommended to install Data::ShowTable another
Perl module.
.PP
I recommend trying automatic installation via the \s-1CPAN\s0 module. Try
.PP
.Vb 1
\& perl -MCPAN -e shell
.Ve
.PP
If you are using the \s-1CPAN\s0 module for the first time, it will prompt
you a lot of questions. If you finally receive the \s-1CPAN\s0 prompt, enter
.PP
.Vb 1
\& install Bundle::DBD::mSQL
.Ve
.PP
or
.PP
.Vb 1
\& install Bundle::DBD::mysql
.Ve
.PP
If this fails (which may be the case for a number of reasons, for
example because you are behind a firewall or don't have network
access), you need to do a manual installation. First of all you
need to fetch the archives from any \s-1CPAN\s0 mirror, for example
.PP
.Vb 1
\& ftp://ftp.funet.fi/pub/languages/perl/CPAN/modules/by-module
.Ve
.PP
The following archives are required (version numbers may have
changed, I choose those which are current as of this writing):
.PP
.Vb 3
\& DBI/DBI-1.13.tar.gz
\& Data/Data-ShowTable-3.3.tar.gz
\& DBD/Msql-Mysql-modules-1.2217.tar.gz
.Ve
.PP
Then enter the following commands:
.PP
.Vb 6
\& gzip -cd DBI-1.13.tar.gz | tar xf -
\& cd DBI-1.13
\& perl Makefile.PL
\& make
\& make test
\& make install
.Ve
.PP
.Vb 6
\& cd ..
\& gzip -cd Data-ShowTable-3.3.tar.gz | tar xf -
\& cd Data-ShowTable-3.3
\& perl Makefile.PL
\& make
\& make install # Don't try make test, the test suite is broken
.Ve
.PP
.Vb 7
\& cd ..
\& gzip -cd Msql-Mysql-modules-1.2217.tar.gz | tar xf -
\& cd Msql-Mysql-modules-1.2217
\& perl Makefile.PL
\& make
\& make test
\& make install
.Ve
.PP
During \*(L"perl Makefile.PL\*(R" you will be prompted some questions. In
particular you have to choose the installed drivers (MySQL, mSQL2
and/or mSQL1). The MySQL driver will be called DBD::mysql, a single
mSQL driver will be called DBD::mSQL. If you want to support both
mSQL1 and mSQL2, they former will be DBD::mSQL1.
.PP
Other questions are the directories with header files and libraries.
For example, of your file \fImysql.h\fR is in \fI/usr/include/mysql/mysql.h\fR,
then enter the header directory \fI/usr\fR, likewise for
\&\fI/usr/lib/mysql/libmysqlclient.a\fR or \fI/usr/lib/libmysqlclient.so\fR.
For mSQL go looking for \fImsql.h\fR (typically in \fI/usr/include/msql.h\fR
and \fIlibmsql.a\fR (probably in \fI/usr/lib/libmsql.a\fR).
.PP
See the \*(L"\s-1KNOWN\s0 \s-1PROBLEMS\s0\*(R" section below if you encounter any problems
within \*(L"make\*(R" or \*(L"make test\*(R".
.SH "WIN32 INSTALLATION"
.IX Header "WIN32 INSTALLATION"
I have never attempted to install DBD::mSQL under Win32, so this is only
for MySQL. If anyone succeeds, please let me know what you did.
.PP
If you are using ActivePerl, you may use ppm to install DBD\-mysql.
For Perl 5.6, upgrade to Build 623 or later, then it is sufficient
to run
.PP
.Vb 2
\& ppm install DBI
\& ppm install DBD::mysql
.Ve
.PP
The same applied to Perl 5.005.
.PP
Otherwise you definitely *need* a C compiler. And it *must* be the same
compiler that was being used for compiling Perl itself. If you don't
have a C compiler, the file \s-1README\s0.win32 from the Perl source
distribution tells you where to obtain freely distributable C compilers
like egcs or gcc. The Perl sources are available on any \s-1CPAN\s0 mirror in
the src directory, for example
.PP
.Vb 1
\& ftp://ftp.funet.fi/pub/languages/perl/CPAN/src/latest.tar.gz
.Ve
.PP
I recommend using the win32clients package for installing DBD::mysql
under Win32, available for download on www.tcx.se. The following steps
have been required for me:
.IP "\-" 8
The current Perl versions (5.6, as of this writing) do have a problem
with detecting the C libraries. I recommend to apply the following
patch:
.Sp
.Vb 7
\& *** c:\ePerl\elib\eExtUtils\eLiblist.pm.orig Sat Apr 15 20:03:40 2000
\& --- c:\ePerl\elib\eExtUtils\eLiblist.pm Sat Apr 15 20:03:45 2000
\& ***************
\& *** 230,235 ****
\& --- 230,239 ----
\& # add "$Config{installarchlib}/CORE" to default search path
\& push @libpath, "$Config{installarchlib}/CORE";
.Ve
.Sp
.Vb 5
\& + if ($VC and exists($ENV{LIB}) and defined($ENV{LIB})) {
\& + push(@libpath, split(/;/, $ENV{LIB}));
\& + }
\& +
\& foreach (Text::ParseWords::quotewords('\es+', 0, $potential_libs)){
.Ve
.Sp
.Vb 1
\& $thislib = $_;
.Ve
.IP "\-" 8
Extract sources into \fIC:\e\fR. This will create a directory \fIC:\emysql\fR
with subdirectories include and lib.
.Sp
\&\s-1IMPORTANT:\s0 Make sure this subdirectory is not shared by other \s-1TCX\s0
files! In particular do *not* store the MySQL server in the same
directory. If the server is already installed in \fIC:\emysql\fR,
choose a location like \fIC:\etmp\fR, extract the win32clients there.
Note that you can remove this directory entirely once you have
installed the Msql\-Mysql\-modules.
.IP "\-" 8
Extract the Msql-Mysql-modules sources into another directory, for
example \fIC:\esrc\esiteperl\fR
.IP "\-" 8
Open a \s-1DOS\s0 shell and change directory to \fIC:\esrc\esiteperl\fR.
.IP "\-" 8
The next step is only required if you repeat building the modules: Make
sure that you have a clean build tree by running
.Sp
.Vb 1
\& nmake realclean
.Ve
.Sp
If you don't have \s-1VC++\s0, replace nmake with your flavour of make. If
error messages are reported in this step, you may safely ignore them.
.IP "\-" 8
Run
.Sp
.Vb 1
\& perl Makefile.PL
.Ve
.Sp
which will prompt you for some settings. The really important ones are:
.Sp
.Vb 1
\& Which DBMS do you want to use?
.Ve
.Sp
enter a 1 here (MySQL only), and
.Sp
.Vb 2
\& Where is your mysql installed? Please tell me the directory that
\& contains the subdir include.
.Ve
.Sp
where you have to enter the win32clients directory, for example
\&\fIC:\emysql\fR or \fIC:\etmp\emysql\fR.
.IP "\-" 8
Continued in the usual way:
.Sp
.Vb 2
\& nmake
\& nmake install
.Ve
.PP
See the first section of \*(L"\s-1KNOWN\s0 \s-1PROBLEMS\s0\*(R" below.
.PP
If you want to create a \s-1PPM\s0 package for the ActiveState Perl version, then
modify the above steps as follows: Run
.PP
.Vb 3
\& perl Makefile.PL NAME=DBD-mysql BINARY_LOCATION=DBD-mysql.tar.gz
\& nmake ppd
\& nmake
.Ve
.PP
Once that is done, use tar and gzip (for example those from the CygWin32
distribution) to create an archive:
.PP
.Vb 3
\& mkdir x86
\& tar cf x86/DBD-mysql.tar blib
\& gzip x86/DBD-mysql.tar
.Ve
.PP
Put the files x86/DBD\-mysql.tar.gz and DBD\-mysql.ppd onto some \s-1WWW\s0 server
and install them by typing
.PP
.Vb 1
\& install http://your.server.name/your/directory/DBD-mysql.ppd
.Ve
.PP
in the \s-1PPM\s0 program.
.SH "KNOWN PROBLEMS"
.IX Header "KNOWN PROBLEMS"
.IP "1.)" 8
.IX Item "1.)"
If the MySQL binaries are compiled with gcc or egcs (as the precompiled
binaries are), but your Perl is using another compiler, it is likely that
you receive an error message like the following when running \*(L"make test\*(R":
.Sp
.Vb 5
\& t/00base............install_driver(mysql) failed: Can't load
\& '../blib/arch/auto/DBD/mysql/mysql.so' for module DBD::mysql:
\& ../blib/arch/auto/DBD/mysql/mysql.so: undefined symbol: _umoddi3
\& at /usr/local/perl-5.005/lib/5.005/i586-linux-thread/DynaLoader.pm
\& line 168.
.Ve
.Sp
This means, that your linker doesn't include libgcc.a. You have the
following options:
.RS 8
.IP "a)" 12
Either recompile Perl or Mysql, it doesn't matter which. The important
thing is that you use the same compiler for both. This is definitely
the recommended solution in the long term.
.IP "b)" 12
A simple workaround is to include libgcc.a manually. Do a \*(L"make clean\*(R"
and \*(L"make\*(R" and in the output wait for a line like
.Sp
.Vb 4
\& LD_RUN_PATH="/usr/lib/mysql:/lib" egcs -o
\& ../blib/arch/auto/DBD/mysql/mysql.so -shared -L/usr/local/lib
\& dbdimp.o mysql.o -L/usr/lib/mysql -L/usr/lib/mysql -lmysqlclient
\& -lm
.Ve
.Sp
Repeat the same line in the shell by adding
.Sp
.Vb 1
\& -L/usr/lib/gcc-lib/i386-redhat-linux/gcc-2.7.2.3 -lgcc
.Ve
.Sp
where the directory is the location of libgcc.a. The best choice
for locating this file is executing
.Sp
.Vb 1
\& gcc --print-libgcc-file
.Ve
.Sp
or
.Sp
.Vb 1
\& gcc -v
.Ve
.RE
.RS 8
.RE
.IP "2.)" 8
.IX Item "2.)"
There are known problems with shared versions of libmysqlclient, at
least on some Linux boxes. If you receive an error message similar to
.Sp
.Vb 4
\& install_driver(mysql) failed: Can't load
\& '/usr/lib/perl5/site_perl/i586-linux/auto/DBD/mysql/mysql.so'
\& for module DBD::mysql: File not found at
\& /usr/lib/perl5/i586-linux/5.00404/DynaLoader.pm line 166
.Ve
.Sp
then this error message can be misleading: It's not mysql.so that fails
being loaded, but libmysqlclient.so!
.Sp
As a workaround, recompile the Msql-Mysql-modules with
.Sp
.Vb 4
\& perl Makefile.PL --static --config
\& make
\& make test
\& make install
.Ve
.Sp
This option forces linkage against the static libmysqlclient.a.
.IP "3.)" 8
.IX Item "3.)"
By default mSQL2 is installed to allow local access only. This can break
the test scripts akmisc.t, msql1.t and msql2.t. You might notice a message
like
.Sp
.Vb 8
\& t/akmisc............Can't connect to MSQL server on localhost at
\& t/akmisc.t line 131
\& Cannot connect: Can't connect to MSQL server on localhost
\& It looks as if your server (on localhost) is not up and running.
\& This test requires a running server.
\& Please make sure your server is running and retry.
\& dubious
\& Test returned status 10 (wstat 2560, 0xa00)
.Ve
.Sp
If this is the case, try to change the value of \*(L"Remote_Access\*(R" in
your \fImsql.conf\fR file to \*(L"True\*(R". If the value was set intentionally,
you might restore the old value after the tests ran ok.
.IP "4.)" 8
.IX Item "4.)"
If linking fails under Win32 because of a missing symbol
pthread_cond_init, apply the following patch to dbd/dbdimp.c:
.Sp
.Vb 15
\& *** dbd/dbdimp.c.orig Wed Sep 23 14:39:33 1998
\& --- dbd/dbdimp.c Fri Oct 02 10:37:16 1998
\& ***************
\& *** 1708,1712 ****
\& --- 1709,1720 ----
\& }
\& return TRUE;
\& }
\& +
\& + #if !defined(_UNIX_) && defined(WIN32)
\& + int pthread_cond_init()
\& + {
\& + return 0;
\& + }
\& + #endif
.Ve
.Sp
.Vb 1
\& #endif
.Ve
.Sp
(I could make this part of the source distribution, but I think this is an
ugly hack and hopefully Monty will fix the missing symbol in the next
release of MyODBC.)
.IP "5.)" 8
.IX Item "5.)"
mSQL 2.0.4 had a bug, that caused the test t/40bindparam.t to fail.
This bug is fixed in later versions, 2.0.6 and higher.
.IP "6.)" 8
.IX Item "6.)"
From time to time compiling DBD::mSQL fails with messages like
.Sp
.Vb 10
\& In file included from ../dbd/myMsql.h:55,
\& from ../dbd/dbdimp.h:32,
\& from dbdimp.c:29:
\& /usr/local/Hughes/include/common/portability.h:74:
\& redefinition of `u_int'
\& /usr/include/sys/types.h:52: `u_int' previously declared here
\& /usr/local/Hughes/include/common/portability.h:78: redefinition of
\& `ssize_t'
\& /usr/include/sys/types.h:116: `ssize_t' previously declared here
\& *** Error code 1
.Ve
.Sp
A workaroud is using
.Sp
.Vb 1
\& perl Makefile.PL --config DEFINE="-DHAVE_SSIZE_T -DHAVE_U_INT"
.Ve
.SH "KNOWN BUGS"
.IX Header "KNOWN BUGS"
The \fIport\fR part of the first argument to the connect call is
implemented in an unsafe way when using mSQL. In fact it is just
setting the environment variable \s-1MSQL_TCP_PORT\s0 during the connect
call. If another connect call uses another port and the handles
are used simultaneously, they will interfere. I doubt that this
will ever change.
.SH "AUTHORS"
.IX Header "AUTHORS"
The current versions of \fBDBD::mSQL\fR and \fBDBD::mysql\fR is almost
completely written by Jochen Wiedmann (\fIjoe@ispsoft.de\fR). The
first version's author was Alligator Descartes(\fIdescarte@symbolstone.org\fR),
who has been aided and abetted by Gary Shea, Andreas König and Tim Bunce
amongst others.
.PP
The \fBMsql\fR and \fBMysql\fR modules have originally been written by
Andreas König <koenig@kulturbox.de>. The current version, mainly
an emulation layer, is from Jochen Wiedmann.
.SH "COPYRIGHT"
.IX Header "COPYRIGHT"
This module is Copyright (c) 1997\-1999 Jochen Wiedmann, with code
portions Copyright (c)1994\-1997 their original authors. This module is
released under the same license as Perl itself. See the Perl \s-1README\s0
for details.
.SH "MAILING LIST SUPPORT"
.IX Header "MAILING LIST SUPPORT"
.SH "MAILING LIST SUPPORT"
.IX Header "MAILING LIST SUPPORT"
This module is maintained and supported on a mailing list,
.PP
.Vb 1
\& msql-mysql-modules@lists.mysql.com
.Ve
.PP
To subscribe to this list, send a mail to
.PP
.Vb 1
\& msql-mysql-modules-subscribe@lists.mysql.com
.Ve
.PP
or
.PP
.Vb 1
\& msql-mysql-modules-digest-subscribe@lists.mysql.com
.Ve
.PP
Mailing list archives are available at
.PP
.Vb 1
\& http://www.progressive-comp.com/Lists/?l=msql-mysql-modules
.Ve
.PP
Additionally you might try the dbi-user mailing list for questions about
\&\s-1DBI\s0 and its modules in general. Subscribe via
.PP
.Vb 1
\& http://www.fugue.com/dbi
.Ve
.PP
Mailing list archives are at
.PP
.Vb 3
\& http://www.rosat.mpe-garching.mpg.de/mailing-lists/PerlDB-Interest/
\& http://outside.organic.com/mail-archives/dbi-users/
\& http://www.coe.missouri.edu/~faq/lists/dbi.html
.Ve
.SH "ADDITIONAL DBI INFORMATION"
.IX Header "ADDITIONAL DBI INFORMATION"
Additional information on the \s-1DBI\s0 project can be found on the World
Wide Web at the following \s-1URL:\s0
.PP
.Vb 1
\& http://www.symbolstone.org/technology/perl/DBI
.Ve
.PP
where documentation, pointers to the mailing lists and mailing list
archives and pointers to the most current versions of the modules can
be used.
.PP
Information on the \s-1DBI\s0 interface itself can be gained by typing:
.PP
.Vb 1
\& perldoc DBI
.Ve
.PP
right now!