| 1 | .\" Automatically generated by Pod::Man v1.34, Pod::Parser v1.13 |
| 2 | .\" |
| 3 | .\" Standard preamble: |
| 4 | .\" ======================================================================== |
| 5 | .de Sh \" Subsection heading |
| 6 | .br |
| 7 | .if t .Sp |
| 8 | .ne 5 |
| 9 | .PP |
| 10 | \fB\\$1\fR |
| 11 | .PP |
| 12 | .. |
| 13 | .de Sp \" Vertical space (when we can't use .PP) |
| 14 | .if t .sp .5v |
| 15 | .if n .sp |
| 16 | .. |
| 17 | .de Vb \" Begin verbatim text |
| 18 | .ft CW |
| 19 | .nf |
| 20 | .ne \\$1 |
| 21 | .. |
| 22 | .de Ve \" End verbatim text |
| 23 | .ft R |
| 24 | .fi |
| 25 | .. |
| 26 | .\" Set up some character translations and predefined strings. \*(-- will |
| 27 | .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left |
| 28 | .\" double quote, and \*(R" will give a right double quote. | will give a |
| 29 | .\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to |
| 30 | .\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C' |
| 31 | .\" expand to `' in nroff, nothing in troff, for use with C<>. |
| 32 | .tr \(*W-|\(bv\*(Tr |
| 33 | .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' |
| 34 | .ie n \{\ |
| 35 | . ds -- \(*W- |
| 36 | . ds PI pi |
| 37 | . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch |
| 38 | . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch |
| 39 | . ds L" "" |
| 40 | . ds R" "" |
| 41 | . ds C` "" |
| 42 | . ds C' "" |
| 43 | 'br\} |
| 44 | .el\{\ |
| 45 | . ds -- \|\(em\| |
| 46 | . ds PI \(*p |
| 47 | . ds L" `` |
| 48 | . ds R" '' |
| 49 | 'br\} |
| 50 | .\" |
| 51 | .\" If the F register is turned on, we'll generate index entries on stderr for |
| 52 | .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index |
| 53 | .\" entries marked with X<> in POD. Of course, you'll have to process the |
| 54 | .\" output yourself in some meaningful fashion. |
| 55 | .if \nF \{\ |
| 56 | . de IX |
| 57 | . tm Index:\\$1\t\\n%\t"\\$2" |
| 58 | .. |
| 59 | . nr % 0 |
| 60 | . rr F |
| 61 | .\} |
| 62 | .\" |
| 63 | .\" For nroff, turn off justification. Always turn off hyphenation; it makes |
| 64 | .\" way too many mistakes in technical documents. |
| 65 | .hy 0 |
| 66 | .if n .na |
| 67 | .\" |
| 68 | .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). |
| 69 | .\" Fear. Run. Save yourself. No user-serviceable parts. |
| 70 | . \" fudge factors for nroff and troff |
| 71 | .if n \{\ |
| 72 | . ds #H 0 |
| 73 | . ds #V .8m |
| 74 | . ds #F .3m |
| 75 | . ds #[ \f1 |
| 76 | . ds #] \fP |
| 77 | .\} |
| 78 | .if t \{\ |
| 79 | . ds #H ((1u-(\\\\n(.fu%2u))*.13m) |
| 80 | . ds #V .6m |
| 81 | . ds #F 0 |
| 82 | . ds #[ \& |
| 83 | . ds #] \& |
| 84 | .\} |
| 85 | . \" simple accents for nroff and troff |
| 86 | .if n \{\ |
| 87 | . ds ' \& |
| 88 | . ds ` \& |
| 89 | . ds ^ \& |
| 90 | . ds , \& |
| 91 | . ds ~ ~ |
| 92 | . ds / |
| 93 | .\} |
| 94 | .if t \{\ |
| 95 | . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" |
| 96 | . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' |
| 97 | . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' |
| 98 | . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' |
| 99 | . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' |
| 100 | . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' |
| 101 | .\} |
| 102 | . \" troff and (daisy-wheel) nroff accents |
| 103 | .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' |
| 104 | .ds 8 \h'\*(#H'\(*b\h'-\*(#H' |
| 105 | .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] |
| 106 | .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' |
| 107 | .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' |
| 108 | .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] |
| 109 | .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] |
| 110 | .ds ae a\h'-(\w'a'u*4/10)'e |
| 111 | .ds Ae A\h'-(\w'A'u*4/10)'E |
| 112 | . \" corrections for vroff |
| 113 | .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' |
| 114 | .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' |
| 115 | . \" for low resolution devices (crt and lpr) |
| 116 | .if \n(.H>23 .if \n(.V>19 \ |
| 117 | \{\ |
| 118 | . ds : e |
| 119 | . ds 8 ss |
| 120 | . ds o a |
| 121 | . ds d- d\h'-1'\(ga |
| 122 | . ds D- D\h'-1'\(hy |
| 123 | . ds th \o'bp' |
| 124 | . ds Th \o'LP' |
| 125 | . ds ae ae |
| 126 | . ds Ae AE |
| 127 | .\} |
| 128 | .rm #[ #] #H #V #F C |
| 129 | .\" ======================================================================== |
| 130 | .\" |
| 131 | .IX Title "DBD::mysql 3" |
| 132 | .TH DBD::mysql 3 "2002-10-01" "perl v5.8.0" "User Contributed Perl Documentation" |
| 133 | .SH "NAME" |
| 134 | DBD::mSQL / DBD::mysql \- mSQL and mysql drivers for the Perl5 Database |
| 135 | Interface (DBI) |
| 136 | .SH "SYNOPSIS" |
| 137 | .IX Header "SYNOPSIS" |
| 138 | .Vb 1 |
| 139 | \& use DBI; |
| 140 | .Ve |
| 141 | .PP |
| 142 | .Vb 2 |
| 143 | \& $driver = "mSQL"; # or "mSQL1"; |
| 144 | \& $dsn = "DBI:$driver:database=$database;host=$hostname"; |
| 145 | .Ve |
| 146 | .PP |
| 147 | .Vb 1 |
| 148 | \& $dbh = DBI->connect($dsn, undef, undef); |
| 149 | .Ve |
| 150 | .PP |
| 151 | .Vb 1 |
| 152 | \& or |
| 153 | .Ve |
| 154 | .PP |
| 155 | .Vb 2 |
| 156 | \& $driver = "mysql"; |
| 157 | \& $dsn = "DBI:$driver:database=$database;host=$hostname;port=$port"; |
| 158 | .Ve |
| 159 | .PP |
| 160 | .Vb 1 |
| 161 | \& $dbh = DBI->connect($dsn, $user, $password); |
| 162 | .Ve |
| 163 | .PP |
| 164 | .Vb 3 |
| 165 | \& $drh = DBI->install_driver("mysql"); |
| 166 | \& @databases = $drh->func($host, $port, '_ListDBs'); |
| 167 | \& @tables = $dbh->func( '_ListTables' ); |
| 168 | .Ve |
| 169 | .PP |
| 170 | .Vb 9 |
| 171 | \& $sth = $dbh->prepare("SELECT * FROM foo WHERE bla"); |
| 172 | \& or |
| 173 | \& $sth = $dbh->prepare("LISTFIELDS $table"); |
| 174 | \& or |
| 175 | \& $sth = $dbh->prepare("LISTINDEX $table $index"); |
| 176 | \& $sth->execute; |
| 177 | \& $numRows = $sth->rows; |
| 178 | \& $numFields = $sth->{'NUM_OF_FIELDS'}; |
| 179 | \& $sth->finish; |
| 180 | .Ve |
| 181 | .PP |
| 182 | .Vb 4 |
| 183 | \& $rc = $drh->func('createdb', $database, $host, $user, $password, 'admin'); |
| 184 | \& $rc = $drh->func('dropdb', $database, $host, $user, $password, 'admin'); |
| 185 | \& $rc = $drh->func('shutdown', $host, $user, $password, 'admin'); |
| 186 | \& $rc = $drh->func('reload', $host, $user, $password, 'admin'); |
| 187 | .Ve |
| 188 | .PP |
| 189 | .Vb 4 |
| 190 | \& $rc = $dbh->func('createdb', $database, 'admin'); |
| 191 | \& $rc = $dbh->func('dropdb', $database, 'admin'); |
| 192 | \& $rc = $dbh->func('shutdown', 'admin'); |
| 193 | \& $rc = $dbh->func('reload', 'admin'); |
| 194 | .Ve |
| 195 | .SH "EXAMPLE" |
| 196 | .IX Header "EXAMPLE" |
| 197 | .Vb 1 |
| 198 | \& #!/usr/bin/perl |
| 199 | .Ve |
| 200 | .PP |
| 201 | .Vb 2 |
| 202 | \& use strict; |
| 203 | \& use DBI(); |
| 204 | .Ve |
| 205 | .PP |
| 206 | .Vb 4 |
| 207 | \& # Connect to the database. |
| 208 | \& my $dbh = DBI->connect("DBI:mysql:database=test;host=localhost", |
| 209 | \& "joe", "joe's password", |
| 210 | \& {'RaiseError' => 1}); |
| 211 | .Ve |
| 212 | .PP |
| 213 | .Vb 4 |
| 214 | \& # Drop table 'foo'. This may fail, if 'foo' doesn't exist. |
| 215 | \& # Thus we put an eval around it. |
| 216 | \& eval { $dbh->do("DROP TABLE foo") }; |
| 217 | \& print "Dropping foo failed: $@\en" if $@; |
| 218 | .Ve |
| 219 | .PP |
| 220 | .Vb 3 |
| 221 | \& # Create a new table 'foo'. This must not fail, thus we don't |
| 222 | \& # catch errors. |
| 223 | \& $dbh->do("CREATE TABLE foo (id INTEGER, name VARCHAR(20))"); |
| 224 | .Ve |
| 225 | .PP |
| 226 | .Vb 3 |
| 227 | \& # INSERT some data into 'foo'. We are using $dbh->quote() for |
| 228 | \& # quoting the name. |
| 229 | \& $dbh->do("INSERT INTO foo VALUES (1, " . $dbh->quote("Tim") . ")"); |
| 230 | .Ve |
| 231 | .PP |
| 232 | .Vb 2 |
| 233 | \& # Same thing, but using placeholders |
| 234 | \& $dbh->do("INSERT INTO foo VALUES (?, ?)", undef, 2, "Jochen"); |
| 235 | .Ve |
| 236 | .PP |
| 237 | .Vb 7 |
| 238 | \& # Now retrieve data from the table. |
| 239 | \& my $sth = $dbh->prepare("SELECT * FROM foo"); |
| 240 | \& $sth->execute(); |
| 241 | \& while (my $ref = $sth->fetchrow_hashref()) { |
| 242 | \& print "Found a row: id = $ref->{'id'}, name = $ref->{'name'}\en"; |
| 243 | \& } |
| 244 | \& $sth->finish(); |
| 245 | .Ve |
| 246 | .PP |
| 247 | .Vb 2 |
| 248 | \& # Disconnect from the database. |
| 249 | \& $dbh->disconnect(); |
| 250 | .Ve |
| 251 | .SH "DESCRIPTION" |
| 252 | .IX Header "DESCRIPTION" |
| 253 | \&\fBDBD::mysql\fR and \fBDBD::mSQL\fR are the Perl5 Database Interface drivers |
| 254 | for the mysql, mSQL 1.\fIx\fR and mSQL 2.\fIx\fR databases. The drivers are part |
| 255 | of the \fIMsql-Mysql-modules\fR package. |
| 256 | .PP |
| 257 | In other words: DBD::mSQL and DBD::mysql are an interface between the Perl |
| 258 | programming language and the mSQL or mysql programming \s-1API\s0 that come with |
| 259 | the mSQL any mysql relational database management systems. Most functions |
| 260 | provided by the respective programming \s-1API\s0's are supported. Some |
| 261 | rarely used functions are missing, mainly because noone ever requested |
| 262 | them. :\-) |
| 263 | .PP |
| 264 | In what follows we first discuss the use of DBD::mysql and DBD::mSQL, |
| 265 | because this is what you will need the most. For installation, see the |
| 266 | sections on \s-1INSTALLATION\s0, \*(L"\s-1WIN32\s0 \s-1INSTALLATION\s0\*(R", \*(L"\s-1KNOWN\s0 \s-1PROBLEMS\s0\*(R" |
| 267 | and \*(L"\s-1KNOWN\s0 \s-1BUGS\s0\*(R" below. See \s-1EXAMPLE\s0 for a simple example above. |
| 268 | .PP |
| 269 | From perl you activate the interface with the statement |
| 270 | .PP |
| 271 | .Vb 1 |
| 272 | \& use DBI; |
| 273 | .Ve |
| 274 | .PP |
| 275 | After that you can connect to multiple mSQL or MySQL database servers |
| 276 | and send multiple queries to any of them via a simple object oriented |
| 277 | interface. Two types of objects are available: database handles and |
| 278 | statement handles. Perl returns a database handle to the connect |
| 279 | method like so: |
| 280 | .PP |
| 281 | .Vb 2 |
| 282 | \& $dbh = DBI->connect("DBI:mSQL:database=$db;host=$host", |
| 283 | \& undef, undef, {RaiseError => 1}); |
| 284 | .Ve |
| 285 | .PP |
| 286 | or |
| 287 | .PP |
| 288 | .Vb 2 |
| 289 | \& $dbh = DBI->connect("DBI:mysql:database=$db;host=$host", |
| 290 | \& $user, $password, {RaiseError => 1}); |
| 291 | .Ve |
| 292 | .PP |
| 293 | Once you have connected to a database, you can can execute \s-1SQL\s0 |
| 294 | statements with: |
| 295 | .PP |
| 296 | .Vb 3 |
| 297 | \& my $query = sprintf("INSERT INTO foo VALUES (%d, %s)", |
| 298 | \& $number, $dbh->quote("name")); |
| 299 | \& $dbh->do($query); |
| 300 | .Ve |
| 301 | .PP |
| 302 | See \s-1\fIDBI\s0\fR\|(3) for details on the quote and do methods. An alternative |
| 303 | approach is |
| 304 | .PP |
| 305 | .Vb 2 |
| 306 | \& $dbh->do("INSERT INTO foo VALUES (?, ?)", undef, |
| 307 | \& $number, $name); |
| 308 | .Ve |
| 309 | .PP |
| 310 | in which case the quote method is executed automatically. See also |
| 311 | the bind_param method in \s-1\fIDBI\s0\fR\|(3). See \*(L"\s-1DATABASE\s0 \s-1HANDLES\s0\*(R" below |
| 312 | for more details on database handles. |
| 313 | .PP |
| 314 | If you want to retrieve results, you need to create a so-called |
| 315 | statement handle with: |
| 316 | .PP |
| 317 | .Vb 2 |
| 318 | \& $sth = $dbh->prepare("SELECT * FROM $table"); |
| 319 | \& $sth->execute(); |
| 320 | .Ve |
| 321 | .PP |
| 322 | This statement handle can be used for multiple things. First of all |
| 323 | you can retreive a row of data: |
| 324 | .PP |
| 325 | .Vb 1 |
| 326 | \& my $row = $sth->fetchow_hashref(); |
| 327 | .Ve |
| 328 | .PP |
| 329 | If your table has columns \s-1ID\s0 and \s-1NAME\s0, then \f(CW$row\fR will be hash ref with |
| 330 | keys \s-1ID\s0 and \s-1NAME\s0. See \*(L"\s-1STATEMENT\s0 \s-1HANDLES\s0\*(R" below for more details on |
| 331 | statement handles. |
| 332 | .PP |
| 333 | But now for a more formal approach: |
| 334 | .Sh "Class Methods" |
| 335 | .IX Subsection "Class Methods" |
| 336 | .IP "\fBconnect\fR" 4 |
| 337 | .IX Item "connect" |
| 338 | .Vb 1 |
| 339 | \& use DBI; |
| 340 | .Ve |
| 341 | .Sp |
| 342 | .Vb 3 |
| 343 | \& $driver = "mSQL"; # or "mSQL1" |
| 344 | \& $dsn = "DBI:$driver:$database"; |
| 345 | \& $dsn = "DBI:$driver:database=$database;host=$hostname"; |
| 346 | .Ve |
| 347 | .Sp |
| 348 | .Vb 1 |
| 349 | \& $dbh = DBI->connect($dsn, undef, undef); |
| 350 | .Ve |
| 351 | .Sp |
| 352 | .Vb 1 |
| 353 | \& or |
| 354 | .Ve |
| 355 | .Sp |
| 356 | .Vb 3 |
| 357 | \& $dsn = "DBI:mysql:$database"; |
| 358 | \& $dsn = "DBI:mysql:database=$database;host=$hostname"; |
| 359 | \& $dsn = "DBI:mysql:database=$database;host=$hostname;port=$port"; |
| 360 | .Ve |
| 361 | .Sp |
| 362 | .Vb 1 |
| 363 | \& $dbh = DBI->connect($dsn, $user, $password); |
| 364 | .Ve |
| 365 | .Sp |
| 366 | A \f(CW\*(C`database\*(C'\fR must always be specified. |
| 367 | .RS 4 |
| 368 | .IP "host" 8 |
| 369 | .IX Item "host" |
| 370 | .PD 0 |
| 371 | .IP "port" 8 |
| 372 | .IX Item "port" |
| 373 | .PD |
| 374 | The hostname, if not specified or specified as '', will default to an |
| 375 | mysql or mSQL daemon running on the local machine on the default port |
| 376 | for the \s-1UNIX\s0 socket. |
| 377 | .Sp |
| 378 | Should the mysql or mSQL daemon be running on a non-standard port number, |
| 379 | you may explicitly state the port number to connect to in the \f(CW\*(C`hostname\*(C'\fR |
| 380 | argument, by concatenating the \fIhostname\fR and \fIport number\fR together |
| 381 | separated by a colon ( \f(CW\*(C`:\*(C'\fR ) character or by using the \f(CW\*(C`port\*(C'\fR argument. |
| 382 | This doesn't work for mSQL 2: You have to create an alternative config |
| 383 | file and load it using the msql_configfile attribute, see below. |
| 384 | .IP "mysql_client_found_rows" 8 |
| 385 | .IX Item "mysql_client_found_rows" |
| 386 | Enables (\s-1TRUE\s0 value) or disables (\s-1FALSE\s0 value) the flag \s-1CLIENT_FOUND_ROWS\s0 |
| 387 | while connecting to the MySQL server. This has a somewhat funny effect: |
| 388 | Without mysql_client_found_rows, if you perform a query like |
| 389 | .Sp |
| 390 | .Vb 1 |
| 391 | \& UPDATE $table SET id = 1 WHERE id = 1 |
| 392 | .Ve |
| 393 | .Sp |
| 394 | then the MySQL engine will always return 0, because no rows have changed. |
| 395 | With mysql_client_found_rows however, it will return the number of rows |
| 396 | that have an id 1, as some people are expecting. (At least for compatibility |
| 397 | to other engines.) |
| 398 | .Sp |
| 399 | By default this flag is disabled. However, you can enable it by default, |
| 400 | when installing the Msql-Mysql-modules with |
| 401 | .Sp |
| 402 | .Vb 3 |
| 403 | \& perl Makefile.PL --config --mysql-use-client-found-rows |
| 404 | \& make |
| 405 | \& make install |
| 406 | .Ve |
| 407 | .IP "mysql_compression" 8 |
| 408 | .IX Item "mysql_compression" |
| 409 | As of MySQL 3.22.3, a new feature is supported: If your \s-1DSN\s0 contains |
| 410 | the option \*(L"mysql_compression=1\*(R", then the communication between client |
| 411 | and server will be compressed. |
| 412 | .IP "mysql_connect_timeout" 8 |
| 413 | .IX Item "mysql_connect_timeout" |
| 414 | If your \s-1DSN\s0 contains the option \*(L"mysql_connect_timeout=##\*(R", the connect |
| 415 | request to the server will timeout if it has not been successful after |
| 416 | the given number of seconds. |
| 417 | .IP "mysql_read_default_file" 8 |
| 418 | .IX Item "mysql_read_default_file" |
| 419 | .PD 0 |
| 420 | .IP "mysql_read_default_group" 8 |
| 421 | .IX Item "mysql_read_default_group" |
| 422 | .PD |
| 423 | These options can be used to read a config file like /etc/my.cnf or |
| 424 | ~/.my.cnf. By default MySQL's C client library doesn't use any config |
| 425 | files unlike the client programs (mysql, mysqladmin, ...) that do, but |
| 426 | outside of the C client library. Thus you need to explicitly request |
| 427 | reading a config file, as in |
| 428 | .Sp |
| 429 | .Vb 2 |
| 430 | \& $dsn = "DBI:mysql:test;mysql_read_default_file=/home/joe/my.cnf"; |
| 431 | \& $dbh = DBI->connect($dsn, $user, $password) |
| 432 | .Ve |
| 433 | .Sp |
| 434 | The option mysql_read_default_group can be used to specify the default |
| 435 | group in the config file: Usually this is the \fIclient\fR group, but |
| 436 | see the following example: |
| 437 | .Sp |
| 438 | .Vb 2 |
| 439 | \& [perl] |
| 440 | \& host=perlhost |
| 441 | .Ve |
| 442 | .Sp |
| 443 | .Vb 2 |
| 444 | \& [client] |
| 445 | \& host=localhost |
| 446 | .Ve |
| 447 | .Sp |
| 448 | If you read this config file, then you'll be typically connected to |
| 449 | \&\fIlocalhost\fR. However, by using |
| 450 | .Sp |
| 451 | .Vb 3 |
| 452 | \& $dsn = "DBI:mysql:test;mysql_read_default_group=perl;" |
| 453 | \& . "mysql_read_default_file=/home/joe/my.cnf"; |
| 454 | \& $dbh = DBI->connect($dsn, $user, $password); |
| 455 | .Ve |
| 456 | .Sp |
| 457 | you'll be connected to \fIperlhost\fR. Note that if you specify a |
| 458 | default group and do not specify a file, then the default config |
| 459 | files will all be read. See the (missing :\-) documentation of |
| 460 | the C function \fImysql_options()\fR for details. |
| 461 | .IP "mysql_socket" 8 |
| 462 | .IX Item "mysql_socket" |
| 463 | As of MySQL 3.21.15, it is possible to choose the Unix socket that is |
| 464 | used for connecting to the server. This is done, for example, with |
| 465 | .Sp |
| 466 | .Vb 1 |
| 467 | \& mysql_socket=/dev/mysql |
| 468 | .Ve |
| 469 | .Sp |
| 470 | Usually there's no need for this option, unless you are using another |
| 471 | location for the socket than that built into the client. |
| 472 | .RE |
| 473 | .RS 4 |
| 474 | .RE |
| 475 | .Sh "Private MetaData Methods" |
| 476 | .IX Subsection "Private MetaData Methods" |
| 477 | .IP "\fBListDBs\fR" 4 |
| 478 | .IX Item "ListDBs" |
| 479 | .Vb 4 |
| 480 | \& my $drh = DBI->install_driver("mysql"); |
| 481 | \& @dbs = $drh->func("$hostname:$port", '_ListDBs'); |
| 482 | \& @dbs = $drh->func($hostname, $port, '_ListDBs'); |
| 483 | \& @dbs = $dbh->func('_ListDBs'); |
| 484 | .Ve |
| 485 | .Sp |
| 486 | Returns a list of all databases managed by the mysql daemon or |
| 487 | mSQL daemon running on \f(CW$hostname\fR, port \f(CW$port\fR. This method |
| 488 | is rarely needed for databases running on \f(CW\*(C`localhost\*(C'\fR: You should |
| 489 | use the portable method |
| 490 | .Sp |
| 491 | .Vb 1 |
| 492 | \& @dbs = DBI->data_sources("mysql"); |
| 493 | .Ve |
| 494 | .Sp |
| 495 | .Vb 1 |
| 496 | \& or |
| 497 | .Ve |
| 498 | .Sp |
| 499 | .Vb 1 |
| 500 | \& @dbs = DBI->data_sources("mSQL"); |
| 501 | .Ve |
| 502 | .Sp |
| 503 | whenever possible. It is a design problem of this method, that there's |
| 504 | no way of supplying a host name or port number to \f(CW\*(C`data_sources\*(C'\fR, that's |
| 505 | the only reason why we still support \f(CW\*(C`ListDBs\*(C'\fR. :\-( |
| 506 | .IP "\fBListTables\fR" 4 |
| 507 | .IX Item "ListTables" |
| 508 | *WARNING*: This method is obsolete due to \s-1DBI\s0's \f(CW$dbh\fR\->\fItable_info()\fR. |
| 509 | .Sp |
| 510 | .Vb 1 |
| 511 | \& @tables = $dbh->func('_ListTables'); |
| 512 | .Ve |
| 513 | .Sp |
| 514 | Once connected to the desired database on the desired mysql or mSQL |
| 515 | mSQL daemon with the \f(CW\*(C`DBI\-\*(C'\fR\fIconnect()\fR> method, we may extract a list |
| 516 | of the tables that have been created within that database. |
| 517 | .Sp |
| 518 | \&\f(CW\*(C`ListTables\*(C'\fR returns an array containing the names of all the tables |
| 519 | present within the selected database. If no tables have been created, |
| 520 | an empty list is returned. |
| 521 | .Sp |
| 522 | .Vb 4 |
| 523 | \& @tables = $dbh->func( '_ListTables' ); |
| 524 | \& foreach $table ( @tables ) { |
| 525 | \& print "Table: $table\en"; |
| 526 | \& } |
| 527 | .Ve |
| 528 | .Sh "Server Administration" |
| 529 | .IX Subsection "Server Administration" |
| 530 | .RS 4 |
| 531 | .IP "admin" 4 |
| 532 | .IX Item "admin" |
| 533 | .Vb 4 |
| 534 | \& $rc = $drh->func("createdb", $dbname, [host, user, password,], 'admin'); |
| 535 | \& $rc = $drh->func("dropdb", $dbname, [host, user, password,], 'admin'); |
| 536 | \& $rc = $drh->func("shutdown", [host, user, password,], 'admin'); |
| 537 | \& $rc = $drh->func("reload", [host, user, password,], 'admin'); |
| 538 | .Ve |
| 539 | .Sp |
| 540 | .Vb 1 |
| 541 | \& or |
| 542 | .Ve |
| 543 | .Sp |
| 544 | .Vb 4 |
| 545 | \& $rc = $dbh->func("createdb", $dbname, 'admin'); |
| 546 | \& $rc = $dbh->func("dropdb", $dbname, 'admin'); |
| 547 | \& $rc = $dbh->func("shutdown", 'admin'); |
| 548 | \& $rc = $dbh->func("reload", 'admin'); |
| 549 | .Ve |
| 550 | .Sp |
| 551 | For server administration you need a server connection. For obtaining |
| 552 | this connection you have two options: Either use a driver handle (drh) |
| 553 | and supply the appropriate arguments (host, defaults localhost, user, |
| 554 | defaults to '' and password, defaults to ''). A driver handle can be |
| 555 | obtained with |
| 556 | .Sp |
| 557 | .Vb 1 |
| 558 | \& $drh = DBI->install_driver('mysql'); |
| 559 | .Ve |
| 560 | .Sp |
| 561 | Otherwise reuse the existing connection of a database handle (dbh). |
| 562 | .Sp |
| 563 | There's only one function available for administrative purposes, comparable |
| 564 | to the m(y)sqladmin programs. The command being execute depends on the |
| 565 | first argument: |
| 566 | .RS 4 |
| 567 | .IP "createdb" 8 |
| 568 | .IX Item "createdb" |
| 569 | Creates the database \f(CW$dbname\fR. Equivalent to \*(L"m(y)sqladmin create \f(CW$dbname\fR\*(R". |
| 570 | .IP "dropdb" 8 |
| 571 | .IX Item "dropdb" |
| 572 | Drops the database \f(CW$dbname\fR. Equivalent to \*(L"m(y)sqladmin drop \f(CW$dbname\fR\*(R". |
| 573 | .Sp |
| 574 | It should be noted that database deletion is |
| 575 | \&\fInot prompted for\fR in any way. Nor is it undo-able from \s-1DBI\s0. |
| 576 | .Sp |
| 577 | .Vb 1 |
| 578 | \& Once you issue the dropDB() method, the database will be gone! |
| 579 | .Ve |
| 580 | .Sp |
| 581 | These method should be used at your own risk. |
| 582 | .IP "shutdown" 8 |
| 583 | .IX Item "shutdown" |
| 584 | Silently shuts down the database engine. (Without prompting!) |
| 585 | Equivalent to \*(L"m(y)sqladmin shutdown\*(R". |
| 586 | .IP "reload" 8 |
| 587 | .IX Item "reload" |
| 588 | Reloads the servers configuration files and/or tables. This can be particularly |
| 589 | important if you modify access privileges or create new users. |
| 590 | .RE |
| 591 | .RS 4 |
| 592 | .RE |
| 593 | .RE |
| 594 | .RS 4 |
| 595 | .SH "DATABASE HANDLES" |
| 596 | .IX Header "DATABASE HANDLES" |
| 597 | The DBD::mysql driver supports the following attributes of database |
| 598 | handles (read only): |
| 599 | .Sp |
| 600 | .Vb 3 |
| 601 | \& $infoString = $dbh->{'info'}; |
| 602 | \& $threadId = $dbh->{'thread_id'}; |
| 603 | \& $insertId = $dbh->{'mysql_insertid'} |
| 604 | .Ve |
| 605 | .Sp |
| 606 | These correspond to \fImysql_info()\fR, \fImysql_thread_id()\fR and \fImysql_insertid()\fR, |
| 607 | respectively. |
| 608 | .SH "STATEMENT HANDLES" |
| 609 | .IX Header "STATEMENT HANDLES" |
| 610 | The statement handles of DBD::mysql and DBD::mSQL support a number |
| 611 | of attributes. You access these by using, for example, |
| 612 | .Sp |
| 613 | .Vb 1 |
| 614 | \& my $numFields = $sth->{'NUM_OF_FIELDS'}; |
| 615 | .Ve |
| 616 | .Sp |
| 617 | Note, that most attributes are valid only after a successfull \fIexecute\fR. |
| 618 | An \f(CW\*(C`undef\*(C'\fR value will returned in that case. The most important exception |
| 619 | is the \f(CW\*(C`mysql_use_result\*(C'\fR attribute: This forces the driver to use |
| 620 | mysql_use_result rather than mysql_store_result. The former is faster |
| 621 | and less memory consuming, but tends to block other processes. (That's why |
| 622 | mysql_store_result is the default.) |
| 623 | .Sp |
| 624 | To set the \f(CW\*(C`mysql_use_result\*(C'\fR attribute, use either of the following: |
| 625 | .Sp |
| 626 | .Vb 1 |
| 627 | \& my $sth = $dbh->prepare("QUERY", { "mysql_use_result" => 1}); |
| 628 | .Ve |
| 629 | .Sp |
| 630 | or |
| 631 | .Sp |
| 632 | .Vb 2 |
| 633 | \& my $sth = $dbh->prepare("QUERY"); |
| 634 | \& $sth->{"mysql_use_result"} = 1; |
| 635 | .Ve |
| 636 | .Sp |
| 637 | Column dependent attributes, for example \fI\s-1NAME\s0\fR, the column names, |
| 638 | are returned as a reference to an array. The array indices are |
| 639 | corresponding to the indices of the arrays returned by \fIfetchrow\fR |
| 640 | and similar methods. For example the following code will print a |
| 641 | header of table names together with all rows: |
| 642 | .Sp |
| 643 | .Vb 19 |
| 644 | \& my $sth = $dbh->prepare("SELECT * FROM $table"); |
| 645 | \& if (!$sth) { |
| 646 | \& die "Error:" . $dbh->errstr . "\en"; |
| 647 | \& } |
| 648 | \& if (!$sth->execute) { |
| 649 | \& die "Error:" . $sth->errstr . "\en"; |
| 650 | \& } |
| 651 | \& my $names = $sth->{'NAME'}; |
| 652 | \& my $numFields = $sth->{'NUM_OF_FIELDS'}; |
| 653 | \& for (my $i = 0; $i < $numFields; $i++) { |
| 654 | \& printf("%s%s", $$names[$i], $i ? "," : ""); |
| 655 | \& } |
| 656 | \& print "\en"; |
| 657 | \& while (my $ref = $sth->fetchrow_arrayref) { |
| 658 | \& for (my $i = 0; $i < $numFields; $i++) { |
| 659 | \& printf("%s%s", $$ref[$i], $i ? "," : ""); |
| 660 | \& } |
| 661 | \& print "\en"; |
| 662 | \& } |
| 663 | .Ve |
| 664 | .Sp |
| 665 | For portable applications you should restrict yourself to attributes with |
| 666 | capitalized or mixed case names. Lower case attribute names are private |
| 667 | to DBD::mSQL and DBD::mysql. The attribute list includes: |
| 668 | .IP "ChopBlanks" 4 |
| 669 | .IX Item "ChopBlanks" |
| 670 | this attribute determines whether a \fIfetchrow\fR will chop preceding |
| 671 | and trailing blanks off the column values. Chopping blanks does not |
| 672 | have impact on the \fImax_length\fR attribute. |
| 673 | .IP "mysql_insertid" 4 |
| 674 | .IX Item "mysql_insertid" |
| 675 | MySQL has the ability to choose unique key values automatically. If this |
| 676 | happened, the new \s-1ID\s0 will be stored in this attribute. This attribute |
| 677 | is not valid for DBD::mSQL. An alternative way for accessing this attribute |
| 678 | is via \f(CW$dbh\fR\->{'mysql_insertid'}. (Note we are using the \f(CW$dbh\fR in this case!) |
| 679 | .IP "mysql_is_blob" 4 |
| 680 | .IX Item "mysql_is_blob" |
| 681 | Reference to an array of boolean values; \s-1TRUE\s0 indicates, that the |
| 682 | respective column is a blob. This attribute is valid for MySQL only. |
| 683 | .IP "mysql_is_key" 4 |
| 684 | .IX Item "mysql_is_key" |
| 685 | Reference to an array of boolean values; \s-1TRUE\s0 indicates, that the |
| 686 | respective column is a key. This is valid for MySQL only. |
| 687 | .IP "mysql_is_num" 4 |
| 688 | .IX Item "mysql_is_num" |
| 689 | Reference to an array of boolean values; \s-1TRUE\s0 indicates, that the |
| 690 | respective column contains numeric values. |
| 691 | .IP "mysql_is_pri_key" 4 |
| 692 | .IX Item "mysql_is_pri_key" |
| 693 | Reference to an array of boolean values; \s-1TRUE\s0 indicates, that the |
| 694 | respective column is a primary key. This is only valid for MySQL |
| 695 | and mSQL 1.0.x: mSQL 2.x uses indices. |
| 696 | .IP "mysql_length" 4 |
| 697 | .IX Item "mysql_length" |
| 698 | .PD 0 |
| 699 | .IP "mysql_max_length" 4 |
| 700 | .IX Item "mysql_max_length" |
| 701 | .PD |
| 702 | A reference to an array of maximum column sizes. The \fImax_length\fR is |
| 703 | the maximum physically present in the result table, \fIlength\fR gives |
| 704 | the theoretically possible maximum. \fImax_length\fR is valid for MySQL |
| 705 | only. |
| 706 | .IP "\s-1NAME\s0" 4 |
| 707 | .IX Item "NAME" |
| 708 | A reference to an array of column names. |
| 709 | .IP "\s-1NULLABLE\s0" 4 |
| 710 | .IX Item "NULLABLE" |
| 711 | A reference to an array of boolean values; \s-1TRUE\s0 indicates that this column |
| 712 | may contain \s-1NULL\s0's. |
| 713 | .IP "\s-1NUM_OF_FIELDS\s0" 4 |
| 714 | .IX Item "NUM_OF_FIELDS" |
| 715 | Number of fields returned by a \fI\s-1SELECT\s0\fR or \fI\s-1LISTFIELDS\s0\fR statement. |
| 716 | You may use this for checking whether a statement returned a result: |
| 717 | A zero value indicates a non-SELECT statement like \fI\s-1INSERT\s0\fR, |
| 718 | \&\fI\s-1DELETE\s0\fR or \fI\s-1UPDATE\s0\fR. |
| 719 | .IP "mysql_table" 4 |
| 720 | .IX Item "mysql_table" |
| 721 | A reference to an array of table names, useful in a \fI\s-1JOIN\s0\fR result. |
| 722 | .IP "\s-1TYPE\s0" 4 |
| 723 | .IX Item "TYPE" |
| 724 | A reference to an array of column types. The engine's native column |
| 725 | types are mapped to portable types like \s-1\fIDBI::SQL_INTEGER\s0()\fR or |
| 726 | \&\s-1\fIDBI::SQL_VARCHAR\s0()\fR, as good as possible. Not all native types have |
| 727 | a meaningfull equivalent, for example \fIDBD::mSQL::IDX_TYPE()\fR or |
| 728 | DBD::mysql::FIELD_TYPE_INTERVAL are mapped to \s-1\fIDBI::SQL_VARCHAR\s0()\fR. |
| 729 | If you need the native column types, use \fImysql_type\fR or \fImsql_type\fR, |
| 730 | respectively. See below. |
| 731 | .IP "mysql_type" 4 |
| 732 | .IX Item "mysql_type" |
| 733 | A reference to an array of MySQL's native column types, for example |
| 734 | \&\fIDBD::mysql::FIELD_TYPE_SHORT()\fR or \fIDBD::mysql::FIELD_TYPE_STRING()\fR. |
| 735 | Use the \fI\s-1TYPE\s0\fR attribute, if you want portable types like |
| 736 | \&\s-1\fIDBI::SQL_SMALLINT\s0()\fR or \s-1\fIDBI::SQL_VARCHAR\s0()\fR. |
| 737 | .IP "mysql_type_name" 4 |
| 738 | .IX Item "mysql_type_name" |
| 739 | Similar to mysql, but type names and not numbers are returned. |
| 740 | Whenever possible, the \s-1ANSI\s0 \s-1SQL\s0 name is preferred. |
| 741 | .RE |
| 742 | .RS 4 |
| 743 | .SH "TRANSACTION SUPPORT" |
| 744 | .IX Header "TRANSACTION SUPPORT" |
| 745 | Beginning with Msql-Mysql-modules 1.2216, transactions are supported |
| 746 | by DBD::mysql. The transaction support works as follows: |
| 747 | .IP "\(bu" 4 |
| 748 | By default AutoCommit mode is on, following the \s-1DBI\s0 specifications. |
| 749 | .IP "\(bu" 4 |
| 750 | If you execute |
| 751 | .Sp |
| 752 | .Vb 1 |
| 753 | \& $dbh-E<gt>{'AutoCommit'} = 0; |
| 754 | .Ve |
| 755 | .Sp |
| 756 | or |
| 757 | .Sp |
| 758 | .Vb 1 |
| 759 | \& $dbh-E<gt>{'AutoCommit'} = 1; |
| 760 | .Ve |
| 761 | .Sp |
| 762 | then the driver will set the MySQL server variable autocommit to 0 or |
| 763 | 1, respectively. Switching from 0 to 1 will also issue a \s-1COMMIT\s0, |
| 764 | following the \s-1DBI\s0 specifications. |
| 765 | .IP "\(bu" 4 |
| 766 | The methods |
| 767 | .Sp |
| 768 | .Vb 2 |
| 769 | \& $dbh-E<gt>rollback(); |
| 770 | \& $dbh-E<gt>commit(); |
| 771 | .Ve |
| 772 | .Sp |
| 773 | will issue the commands \s-1COMMIT\s0 and \s-1ROLLBACK\s0, respectively. A |
| 774 | \&\s-1ROLLBACK\s0 will also be issued if AutoCommit mode is off and the |
| 775 | database handles \s-1DESTROY\s0 method is called. Again, this is following |
| 776 | the \s-1DBI\s0 specifications. |
| 777 | .RE |
| 778 | .RS 4 |
| 779 | .Sp |
| 780 | Given the above, you should note the following: |
| 781 | .IP "\(bu" 4 |
| 782 | You should never change the server variable autocommit manually, |
| 783 | unless you are ignoring \s-1DBI\s0's transaction support. |
| 784 | .IP "\(bu" 4 |
| 785 | Switching AutoCommit mode from on to off or vice versa may fail. |
| 786 | You should always check for errors, when changing AutoCommit mode. |
| 787 | The suggested way of doing so is using the \s-1DBI\s0 flag RaiseError. |
| 788 | If you don't like RaiseError, you have to use code like the |
| 789 | following: |
| 790 | .Sp |
| 791 | .Vb 4 |
| 792 | \& $dbh->{'AutoCommit'} = 0; |
| 793 | \& if ($dbh->{'AutoCommit'}) { |
| 794 | \& # An error occurred! |
| 795 | \& } |
| 796 | .Ve |
| 797 | .IP "\(bu" 4 |
| 798 | If you detect an error while changing the AutoCommit mode, you |
| 799 | should no longer use the database handle. In other words, you |
| 800 | should disconnect and reconnect again, because the transaction |
| 801 | mode is unpredictable. Alternatively you may verify the transaction |
| 802 | mode by checking the value of the server variable autocommit. |
| 803 | However, such behaviour isn't portable. |
| 804 | .RE |
| 805 | .RS 4 |
| 806 | .SH "SQL EXTENSIONS" |
| 807 | .IX Header "SQL EXTENSIONS" |
| 808 | Certain metadata functions of mSQL and mysql that are available on the |
| 809 | C \s-1API\s0 level, haven't been implemented here. Instead they are implemented |
| 810 | as \*(L"\s-1SQL\s0 extensions\*(R" because they return in fact nothing else but the |
| 811 | equivalent of a statement handle. These are: |
| 812 | .ie n .IP "\s-1LISTFIELDS\s0 $table" 4 |
| 813 | .el .IP "\s-1LISTFIELDS\s0 \f(CW$table\fR" 4 |
| 814 | .IX Item "LISTFIELDS $table" |
| 815 | Returns a statement handle that describes the columns of \f(CW$table\fR. |
| 816 | Ses the docs of msqlListFields or mysql_list_fields (C \s-1API\s0) for |
| 817 | details. |
| 818 | .ie n .IP "\s-1LISTINDEX\s0 $table\fR \f(CW$index" 4 |
| 819 | .el .IP "\s-1LISTINDEX\s0 \f(CW$table\fR \f(CW$index\fR" 4 |
| 820 | .IX Item "LISTINDEX $table $index" |
| 821 | mSQL only; returns a statement handle that describes the index \f(CW$index\fR |
| 822 | of table \f(CW$table\fR. See the docs of msqlListIndex for details. |
| 823 | .RE |
| 824 | .RS 4 |
| 825 | .SH "COMPATIBILITY ALERT" |
| 826 | .IX Header "COMPATIBILITY ALERT" |
| 827 | The statement attribute \fI\s-1TYPE\s0\fR has changed its meaning, as of |
| 828 | Msql-Mysql-modules 1.19_19. Formerly it used to be the an array |
| 829 | of native engine's column types, but it is now an array of |
| 830 | portable \s-1SQL\s0 column types. The old attribute is still available |
| 831 | as \fImysql_type\fR or \fImsql_type\fR, respectively. |
| 832 | .Sp |
| 833 | The Msql-Mysql-modules are a moving target, due to a number of reasons: |
| 834 | .IP "\-" 8 |
| 835 | Of course they have to conform the \s-1DBI\s0 guidelines and developments. |
| 836 | .IP "\-" 8 |
| 837 | They have to keep track with the latest MySQL developments. |
| 838 | .IP "\-" 8 |
| 839 | And, surprisingly, they have to be as close to \s-1ODBC\s0 as possible: This is |
| 840 | due to the current direction of \s-1DBI\s0. |
| 841 | .IP "\-" 8 |
| 842 | And, last not least, as any tool they have a little bit of own life. |
| 843 | .RE |
| 844 | .RS 4 |
| 845 | .Sp |
| 846 | This means that a lot of things had to and have to be changed. As I am not |
| 847 | interested in maintaining a lot of compatibility kludges, which only |
| 848 | increase the drivers code without being really usefull, I did and will |
| 849 | remove some features, methods or attributes. |
| 850 | .Sp |
| 851 | To ensure a smooth upgrade, the following policy will be applied: |
| 852 | .IP "Obsolete features" 8 |
| 853 | .IX Item "Obsolete features" |
| 854 | The first step is to declare something obsolete. This means, that no code |
| 855 | is changed, but the feature appears in the list of obsolete features. See |
| 856 | \&\*(L"Obsolete Features\*(R" below. |
| 857 | .IP "Deprecated features" 8 |
| 858 | .IX Item "Deprecated features" |
| 859 | If the feature has been obsolete for quite some time, typically in the |
| 860 | next major stable release, warnings will be inserted in the code. You |
| 861 | can suppress these warnings by setting |
| 862 | .Sp |
| 863 | .Vb 1 |
| 864 | \& $DBD::mysql = 1; |
| 865 | .Ve |
| 866 | .Sp |
| 867 | In the docs the feature will be moved from the list of obsolete features |
| 868 | to the list of deprecated features. See \*(L"Deprecated Features\*(R" below. |
| 869 | .IP "Removing features" 8 |
| 870 | .IX Item "Removing features" |
| 871 | Finally features will be removed silently in the next major stable |
| 872 | release. The feature will be shown in the list of historic features. |
| 873 | See \*(L"Historic Features\*(R" below. |
| 874 | .RE |
| 875 | .RS 4 |
| 876 | .Sp |
| 877 | Example: The statement handle attribute |
| 878 | .Sp |
| 879 | .Vb 1 |
| 880 | \& $sth->{'LENGTH'} |
| 881 | .Ve |
| 882 | .Sp |
| 883 | was declared obsolete in Msql-Mysql-modules 1.18xy. It is considered |
| 884 | deprecated in Msql-Mysql-modules 1.20xy (current as of this writing) |
| 885 | and will finally be removed in Msql-Mysql-modules 1.22xy. |
| 886 | .RE |
| 887 | .Sh "Obsolete Features" |
| 888 | .IX Subsection "Obsolete Features" |
| 889 | .IP "_ListTables" 8 |
| 890 | .IX Item "_ListTables" |
| 891 | This method is obsoleted by \s-1DBI\s0's new method |
| 892 | .Sp |
| 893 | .Vb 1 |
| 894 | \& $dbh->tables() |
| 895 | .Ve |
| 896 | .Sp |
| 897 | See also \f(CW$dbh\fR\->\fItable_info()\fR. Portable applications will prefer |
| 898 | .Sp |
| 899 | .Vb 1 |
| 900 | \& @tables = map { $_ =~ s/.*\e.//; $_ } $dbh->tables() |
| 901 | .Ve |
| 902 | .Sp |
| 903 | because, depending on the engine, the string \*(L"user.table\*(R" will be |
| 904 | returned, user being the table owner. The method will be deprecated |
| 905 | in 1.23_xy and 1.24xy and removed in 1.25_xy and 1.26xy. |
| 906 | .Sh "Deprecated Features" |
| 907 | .IX Subsection "Deprecated Features" |
| 908 | .IP "_InsertID" 8 |
| 909 | .IX Item "_InsertID" |
| 910 | The method |
| 911 | .Sp |
| 912 | .Vb 1 |
| 913 | \& $dbh->func('_InsertID'); |
| 914 | .Ve |
| 915 | .Sp |
| 916 | can be replaced with |
| 917 | .Sp |
| 918 | .Vb 1 |
| 919 | \& $dbh->{'mysql_insertid'}; |
| 920 | .Ve |
| 921 | .Sp |
| 922 | The method is deprecated as of 1.21_xy, thus it will be removed in |
| 923 | 1.23_xy and 1.24xy. |
| 924 | .IP "Statement handle attributes:" 8 |
| 925 | .IX Item "Statement handle attributes:" |
| 926 | .RS 8 |
| 927 | .PD 0 |
| 928 | .IP "affected_rows" 12 |
| 929 | .IX Item "affected_rows" |
| 930 | .IP "\s-1IS_PRI_KEY\s0" 12 |
| 931 | .IX Item "IS_PRI_KEY" |
| 932 | .IP "is_pri_key" 12 |
| 933 | .IX Item "is_pri_key" |
| 934 | .IP "\s-1IS_NOT_NULL\s0" 12 |
| 935 | .IX Item "IS_NOT_NULL" |
| 936 | .IP "is_not_null" 12 |
| 937 | .IX Item "is_not_null" |
| 938 | .IP "\s-1IS_KEY\s0" 12 |
| 939 | .IX Item "IS_KEY" |
| 940 | .IP "is_key" 12 |
| 941 | .IX Item "is_key" |
| 942 | .IP "\s-1IS_BLOB\s0" 12 |
| 943 | .IX Item "IS_BLOB" |
| 944 | .IP "is_blob" 12 |
| 945 | .IX Item "is_blob" |
| 946 | .IP "\s-1IS_NUM\s0" 12 |
| 947 | .IX Item "IS_NUM" |
| 948 | .IP "is_num" 12 |
| 949 | .IX Item "is_num" |
| 950 | .IP "\s-1LENGTH\s0" 12 |
| 951 | .IX Item "LENGTH" |
| 952 | .IP "length" 12 |
| 953 | .IX Item "length" |
| 954 | .IP "\s-1MAXLENGTH\s0" 12 |
| 955 | .IX Item "MAXLENGTH" |
| 956 | .IP "maxlength" 12 |
| 957 | .IX Item "maxlength" |
| 958 | .IP "\s-1NUMROWS\s0" 12 |
| 959 | .IX Item "NUMROWS" |
| 960 | .IP "numrows" 12 |
| 961 | .IX Item "numrows" |
| 962 | .IP "\s-1NUMFIELDS\s0" 12 |
| 963 | .IX Item "NUMFIELDS" |
| 964 | .IP "numfields" 12 |
| 965 | .IX Item "numfields" |
| 966 | .IP "\s-1RESULT\s0" 12 |
| 967 | .IX Item "RESULT" |
| 968 | .IP "result" 12 |
| 969 | .IX Item "result" |
| 970 | .IP "\s-1TABLE\s0" 12 |
| 971 | .IX Item "TABLE" |
| 972 | .IP "table" 12 |
| 973 | .IX Item "table" |
| 974 | .IP "format_max_size" 12 |
| 975 | .IX Item "format_max_size" |
| 976 | .IP "format_default_size" 12 |
| 977 | .IX Item "format_default_size" |
| 978 | .IP "format_type_name" 12 |
| 979 | .IX Item "format_type_name" |
| 980 | .RE |
| 981 | .RS 8 |
| 982 | .PD |
| 983 | .Sp |
| 984 | All of the above statement handle attributes are not conforming to \s-1DBI\s0's |
| 985 | naming conventions, thus they have been declared deprecated in 1.20xy. |
| 986 | However, I forgot to insert warnings in the driver. These warnings have |
| 987 | been inserted in 1.21_07, thus the attributes will be removed in 1.23_xy |
| 988 | and 1.24xy. |
| 989 | .Sp |
| 990 | In most of the above cases the driver name has been added and the resulting |
| 991 | name was lowercased. For example, you use |
| 992 | .Sp |
| 993 | .Vb 1 |
| 994 | \& $sth->{'mysql_is_num'}; |
| 995 | .Ve |
| 996 | .Sp |
| 997 | now. \s-1IS_NOT_NULL\s0 can be replaced with \s-1NULLABLE\s0 (note you need to invert |
| 998 | the logical value!), \s-1LENGTH\s0, format_max_size and format_default_size will |
| 999 | be dropped in favour of \s-1PRECISION\s0, affected_rows and \s-1NUMROWS\s0 are identical |
| 1000 | with |
| 1001 | .Sp |
| 1002 | .Vb 1 |
| 1003 | \& $sth->rows(); |
| 1004 | .Ve |
| 1005 | .Sp |
| 1006 | and \s-1NUMFIELDS\s0 is the same as \s-1NUM_OF_FIELDS\s0. Finally format_right_justify |
| 1007 | is the same as mysql_type_name. |
| 1008 | .RE |
| 1009 | .Sh "Historic Features" |
| 1010 | .IX Subsection "Historic Features" |
| 1011 | .IP "_CreateDB" 8 |
| 1012 | .IX Item "_CreateDB" |
| 1013 | .PD 0 |
| 1014 | .IP "_DropDB" 8 |
| 1015 | .IX Item "_DropDB" |
| 1016 | .PD |
| 1017 | The methods |
| 1018 | .Sp |
| 1019 | .Vb 2 |
| 1020 | \& $dbh->func($db, '_CreateDB'); |
| 1021 | \& $dbh->func($db, '_DropDB'); |
| 1022 | .Ve |
| 1023 | .Sp |
| 1024 | have been used for creating or dropping databases. They have been removed |
| 1025 | in 1.21_07 in favour of |
| 1026 | .Sp |
| 1027 | .Vb 2 |
| 1028 | \& $drh->func("createdb", $dbname, $host, "admin") |
| 1029 | \& $drh->func("dropdb", $dbname, $host, "admin") |
| 1030 | .Ve |
| 1031 | .IP "_ListFields" 8 |
| 1032 | .IX Item "_ListFields" |
| 1033 | The method |
| 1034 | .Sp |
| 1035 | .Vb 1 |
| 1036 | \& $sth = $dbh->func($table, '_ListFields'); |
| 1037 | .Ve |
| 1038 | .Sp |
| 1039 | has been used to list a tables columns names, types and other attributes. |
| 1040 | This method has been removed in 1.21_07 in favour of |
| 1041 | .Sp |
| 1042 | .Vb 1 |
| 1043 | \& $sth = $dbh->prepare("LISTFIELDS $table"); |
| 1044 | .Ve |
| 1045 | .IP "_ListSelectedFields" 8 |
| 1046 | .IX Item "_ListSelectedFields" |
| 1047 | The method |
| 1048 | .Sp |
| 1049 | .Vb 1 |
| 1050 | \& $sth->func('_ListSelectedFields'); |
| 1051 | .Ve |
| 1052 | .Sp |
| 1053 | use to return a hash ref of attributes like '\s-1IS_NUM\s0', '\s-1IS_KEY\s0' and so |
| 1054 | on. These attributes are now accessible via |
| 1055 | .Sp |
| 1056 | .Vb 2 |
| 1057 | \& $sth->{'mysql_is_num'}; |
| 1058 | \& $sth->{'mysql_is_key'}; |
| 1059 | .Ve |
| 1060 | .Sp |
| 1061 | and so on. Thus the method has been removed in 1.21_07. |
| 1062 | .IP "_NumRows" 8 |
| 1063 | .IX Item "_NumRows" |
| 1064 | The method |
| 1065 | .Sp |
| 1066 | .Vb 1 |
| 1067 | \& $sth->func('_NumRows'); |
| 1068 | .Ve |
| 1069 | .Sp |
| 1070 | used to be equivalent to |
| 1071 | .Sp |
| 1072 | .Vb 1 |
| 1073 | \& $sth->rows(); |
| 1074 | .Ve |
| 1075 | .Sp |
| 1076 | and has been removed in 1.21_07. |
| 1077 | .SH "MULTITHREADING" |
| 1078 | .IX Header "MULTITHREADING" |
| 1079 | The multithreading capabilities of the Msql-Mysql-modules depend completely |
| 1080 | on the underlying C libraries: The modules are working with handle data |
| 1081 | only, no global variables are accessed or (to the best of my knowledge) |
| 1082 | thread unsafe functions are called. Thus DBD::mSQL and DBD::mysql are |
| 1083 | completely thread safe, if the C libraries thread safe and you don't |
| 1084 | share handles among threads. |
| 1085 | .PP |
| 1086 | The obvious questions is: Are the C libraries thread safe? In the case of |
| 1087 | mSQL the answer is definitely \*(L"no\*(R". The C library has a concept of one |
| 1088 | single active connection at a time and that is not what threads like. |
| 1089 | .PP |
| 1090 | In the case of MySQL the answer is \*(L"mostly\*(R" and, in theory, you should |
| 1091 | be able to get a \*(L"yes\*(R", if the C library is compiled for being thread |
| 1092 | safe (By default it isn't.) by passing the option \-with\-thread\-safe\-client |
| 1093 | to configure. See the section on \fIHow to make a threadsafe client\fR in |
| 1094 | the manual. |
| 1095 | .SH "INSTALLATION" |
| 1096 | .IX Header "INSTALLATION" |
| 1097 | Windows users may skip this section and pass over to \*(L"\s-1WIN32\s0 \s-1INSTALLATION\s0\*(R" below. Others, go on reading. |
| 1098 | .PP |
| 1099 | First of all, you do not need an installed MySQL server for installing |
| 1100 | DBD::mSQL and/or DBD::mysql. However, you need at least the client |
| 1101 | libraries and possibly the header files, if you are compiling DBD::mysql |
| 1102 | or DBD::mSQL from source. In the case of MySQL you can create a |
| 1103 | client-only version by using the configure option \-\-without\-server. |
| 1104 | If you are using precompiled binaries, then it may be possible to |
| 1105 | use just selected \s-1RPM\s0's like MySQL-client and MySQL-devel or something |
| 1106 | similar, depending on the distribution. |
| 1107 | .PP |
| 1108 | First you need to install the \s-1DBI\s0 module. For using \fIdbimon\fR, a |
| 1109 | simple \s-1DBI\s0 shell it is recommended to install Data::ShowTable another |
| 1110 | Perl module. |
| 1111 | .PP |
| 1112 | I recommend trying automatic installation via the \s-1CPAN\s0 module. Try |
| 1113 | .PP |
| 1114 | .Vb 1 |
| 1115 | \& perl -MCPAN -e shell |
| 1116 | .Ve |
| 1117 | .PP |
| 1118 | If you are using the \s-1CPAN\s0 module for the first time, it will prompt |
| 1119 | you a lot of questions. If you finally receive the \s-1CPAN\s0 prompt, enter |
| 1120 | .PP |
| 1121 | .Vb 1 |
| 1122 | \& install Bundle::DBD::mSQL |
| 1123 | .Ve |
| 1124 | .PP |
| 1125 | or |
| 1126 | .PP |
| 1127 | .Vb 1 |
| 1128 | \& install Bundle::DBD::mysql |
| 1129 | .Ve |
| 1130 | .PP |
| 1131 | If this fails (which may be the case for a number of reasons, for |
| 1132 | example because you are behind a firewall or don't have network |
| 1133 | access), you need to do a manual installation. First of all you |
| 1134 | need to fetch the archives from any \s-1CPAN\s0 mirror, for example |
| 1135 | .PP |
| 1136 | .Vb 1 |
| 1137 | \& ftp://ftp.funet.fi/pub/languages/perl/CPAN/modules/by-module |
| 1138 | .Ve |
| 1139 | .PP |
| 1140 | The following archives are required (version numbers may have |
| 1141 | changed, I choose those which are current as of this writing): |
| 1142 | .PP |
| 1143 | .Vb 3 |
| 1144 | \& DBI/DBI-1.13.tar.gz |
| 1145 | \& Data/Data-ShowTable-3.3.tar.gz |
| 1146 | \& DBD/Msql-Mysql-modules-1.2217.tar.gz |
| 1147 | .Ve |
| 1148 | .PP |
| 1149 | Then enter the following commands: |
| 1150 | .PP |
| 1151 | .Vb 6 |
| 1152 | \& gzip -cd DBI-1.13.tar.gz | tar xf - |
| 1153 | \& cd DBI-1.13 |
| 1154 | \& perl Makefile.PL |
| 1155 | \& make |
| 1156 | \& make test |
| 1157 | \& make install |
| 1158 | .Ve |
| 1159 | .PP |
| 1160 | .Vb 6 |
| 1161 | \& cd .. |
| 1162 | \& gzip -cd Data-ShowTable-3.3.tar.gz | tar xf - |
| 1163 | \& cd Data-ShowTable-3.3 |
| 1164 | \& perl Makefile.PL |
| 1165 | \& make |
| 1166 | \& make install # Don't try make test, the test suite is broken |
| 1167 | .Ve |
| 1168 | .PP |
| 1169 | .Vb 7 |
| 1170 | \& cd .. |
| 1171 | \& gzip -cd Msql-Mysql-modules-1.2217.tar.gz | tar xf - |
| 1172 | \& cd Msql-Mysql-modules-1.2217 |
| 1173 | \& perl Makefile.PL |
| 1174 | \& make |
| 1175 | \& make test |
| 1176 | \& make install |
| 1177 | .Ve |
| 1178 | .PP |
| 1179 | During \*(L"perl Makefile.PL\*(R" you will be prompted some questions. In |
| 1180 | particular you have to choose the installed drivers (MySQL, mSQL2 |
| 1181 | and/or mSQL1). The MySQL driver will be called DBD::mysql, a single |
| 1182 | mSQL driver will be called DBD::mSQL. If you want to support both |
| 1183 | mSQL1 and mSQL2, they former will be DBD::mSQL1. |
| 1184 | .PP |
| 1185 | Other questions are the directories with header files and libraries. |
| 1186 | For example, of your file \fImysql.h\fR is in \fI/usr/include/mysql/mysql.h\fR, |
| 1187 | then enter the header directory \fI/usr\fR, likewise for |
| 1188 | \&\fI/usr/lib/mysql/libmysqlclient.a\fR or \fI/usr/lib/libmysqlclient.so\fR. |
| 1189 | For mSQL go looking for \fImsql.h\fR (typically in \fI/usr/include/msql.h\fR |
| 1190 | and \fIlibmsql.a\fR (probably in \fI/usr/lib/libmsql.a\fR). |
| 1191 | .PP |
| 1192 | See the \*(L"\s-1KNOWN\s0 \s-1PROBLEMS\s0\*(R" section below if you encounter any problems |
| 1193 | within \*(L"make\*(R" or \*(L"make test\*(R". |
| 1194 | .SH "WIN32 INSTALLATION" |
| 1195 | .IX Header "WIN32 INSTALLATION" |
| 1196 | I have never attempted to install DBD::mSQL under Win32, so this is only |
| 1197 | for MySQL. If anyone succeeds, please let me know what you did. |
| 1198 | .PP |
| 1199 | If you are using ActivePerl, you may use ppm to install DBD\-mysql. |
| 1200 | For Perl 5.6, upgrade to Build 623 or later, then it is sufficient |
| 1201 | to run |
| 1202 | .PP |
| 1203 | .Vb 2 |
| 1204 | \& ppm install DBI |
| 1205 | \& ppm install DBD::mysql |
| 1206 | .Ve |
| 1207 | .PP |
| 1208 | The same applied to Perl 5.005. |
| 1209 | .PP |
| 1210 | Otherwise you definitely *need* a C compiler. And it *must* be the same |
| 1211 | compiler that was being used for compiling Perl itself. If you don't |
| 1212 | have a C compiler, the file \s-1README\s0.win32 from the Perl source |
| 1213 | distribution tells you where to obtain freely distributable C compilers |
| 1214 | like egcs or gcc. The Perl sources are available on any \s-1CPAN\s0 mirror in |
| 1215 | the src directory, for example |
| 1216 | .PP |
| 1217 | .Vb 1 |
| 1218 | \& ftp://ftp.funet.fi/pub/languages/perl/CPAN/src/latest.tar.gz |
| 1219 | .Ve |
| 1220 | .PP |
| 1221 | I recommend using the win32clients package for installing DBD::mysql |
| 1222 | under Win32, available for download on www.tcx.se. The following steps |
| 1223 | have been required for me: |
| 1224 | .IP "\-" 8 |
| 1225 | The current Perl versions (5.6, as of this writing) do have a problem |
| 1226 | with detecting the C libraries. I recommend to apply the following |
| 1227 | patch: |
| 1228 | .Sp |
| 1229 | .Vb 7 |
| 1230 | \& *** c:\ePerl\elib\eExtUtils\eLiblist.pm.orig Sat Apr 15 20:03:40 2000 |
| 1231 | \& --- c:\ePerl\elib\eExtUtils\eLiblist.pm Sat Apr 15 20:03:45 2000 |
| 1232 | \& *************** |
| 1233 | \& *** 230,235 **** |
| 1234 | \& --- 230,239 ---- |
| 1235 | \& # add "$Config{installarchlib}/CORE" to default search path |
| 1236 | \& push @libpath, "$Config{installarchlib}/CORE"; |
| 1237 | .Ve |
| 1238 | .Sp |
| 1239 | .Vb 5 |
| 1240 | \& + if ($VC and exists($ENV{LIB}) and defined($ENV{LIB})) { |
| 1241 | \& + push(@libpath, split(/;/, $ENV{LIB})); |
| 1242 | \& + } |
| 1243 | \& + |
| 1244 | \& foreach (Text::ParseWords::quotewords('\es+', 0, $potential_libs)){ |
| 1245 | .Ve |
| 1246 | .Sp |
| 1247 | .Vb 1 |
| 1248 | \& $thislib = $_; |
| 1249 | .Ve |
| 1250 | .IP "\-" 8 |
| 1251 | Extract sources into \fIC:\e\fR. This will create a directory \fIC:\emysql\fR |
| 1252 | with subdirectories include and lib. |
| 1253 | .Sp |
| 1254 | \&\s-1IMPORTANT:\s0 Make sure this subdirectory is not shared by other \s-1TCX\s0 |
| 1255 | files! In particular do *not* store the MySQL server in the same |
| 1256 | directory. If the server is already installed in \fIC:\emysql\fR, |
| 1257 | choose a location like \fIC:\etmp\fR, extract the win32clients there. |
| 1258 | Note that you can remove this directory entirely once you have |
| 1259 | installed the Msql\-Mysql\-modules. |
| 1260 | .IP "\-" 8 |
| 1261 | Extract the Msql-Mysql-modules sources into another directory, for |
| 1262 | example \fIC:\esrc\esiteperl\fR |
| 1263 | .IP "\-" 8 |
| 1264 | Open a \s-1DOS\s0 shell and change directory to \fIC:\esrc\esiteperl\fR. |
| 1265 | .IP "\-" 8 |
| 1266 | The next step is only required if you repeat building the modules: Make |
| 1267 | sure that you have a clean build tree by running |
| 1268 | .Sp |
| 1269 | .Vb 1 |
| 1270 | \& nmake realclean |
| 1271 | .Ve |
| 1272 | .Sp |
| 1273 | If you don't have \s-1VC++\s0, replace nmake with your flavour of make. If |
| 1274 | error messages are reported in this step, you may safely ignore them. |
| 1275 | .IP "\-" 8 |
| 1276 | Run |
| 1277 | .Sp |
| 1278 | .Vb 1 |
| 1279 | \& perl Makefile.PL |
| 1280 | .Ve |
| 1281 | .Sp |
| 1282 | which will prompt you for some settings. The really important ones are: |
| 1283 | .Sp |
| 1284 | .Vb 1 |
| 1285 | \& Which DBMS do you want to use? |
| 1286 | .Ve |
| 1287 | .Sp |
| 1288 | enter a 1 here (MySQL only), and |
| 1289 | .Sp |
| 1290 | .Vb 2 |
| 1291 | \& Where is your mysql installed? Please tell me the directory that |
| 1292 | \& contains the subdir include. |
| 1293 | .Ve |
| 1294 | .Sp |
| 1295 | where you have to enter the win32clients directory, for example |
| 1296 | \&\fIC:\emysql\fR or \fIC:\etmp\emysql\fR. |
| 1297 | .IP "\-" 8 |
| 1298 | Continued in the usual way: |
| 1299 | .Sp |
| 1300 | .Vb 2 |
| 1301 | \& nmake |
| 1302 | \& nmake install |
| 1303 | .Ve |
| 1304 | .PP |
| 1305 | See the first section of \*(L"\s-1KNOWN\s0 \s-1PROBLEMS\s0\*(R" below. |
| 1306 | .PP |
| 1307 | If you want to create a \s-1PPM\s0 package for the ActiveState Perl version, then |
| 1308 | modify the above steps as follows: Run |
| 1309 | .PP |
| 1310 | .Vb 3 |
| 1311 | \& perl Makefile.PL NAME=DBD-mysql BINARY_LOCATION=DBD-mysql.tar.gz |
| 1312 | \& nmake ppd |
| 1313 | \& nmake |
| 1314 | .Ve |
| 1315 | .PP |
| 1316 | Once that is done, use tar and gzip (for example those from the CygWin32 |
| 1317 | distribution) to create an archive: |
| 1318 | .PP |
| 1319 | .Vb 3 |
| 1320 | \& mkdir x86 |
| 1321 | \& tar cf x86/DBD-mysql.tar blib |
| 1322 | \& gzip x86/DBD-mysql.tar |
| 1323 | .Ve |
| 1324 | .PP |
| 1325 | Put the files x86/DBD\-mysql.tar.gz and DBD\-mysql.ppd onto some \s-1WWW\s0 server |
| 1326 | and install them by typing |
| 1327 | .PP |
| 1328 | .Vb 1 |
| 1329 | \& install http://your.server.name/your/directory/DBD-mysql.ppd |
| 1330 | .Ve |
| 1331 | .PP |
| 1332 | in the \s-1PPM\s0 program. |
| 1333 | .SH "KNOWN PROBLEMS" |
| 1334 | .IX Header "KNOWN PROBLEMS" |
| 1335 | .IP "1.)" 8 |
| 1336 | .IX Item "1.)" |
| 1337 | If the MySQL binaries are compiled with gcc or egcs (as the precompiled |
| 1338 | binaries are), but your Perl is using another compiler, it is likely that |
| 1339 | you receive an error message like the following when running \*(L"make test\*(R": |
| 1340 | .Sp |
| 1341 | .Vb 5 |
| 1342 | \& t/00base............install_driver(mysql) failed: Can't load |
| 1343 | \& '../blib/arch/auto/DBD/mysql/mysql.so' for module DBD::mysql: |
| 1344 | \& ../blib/arch/auto/DBD/mysql/mysql.so: undefined symbol: _umoddi3 |
| 1345 | \& at /usr/local/perl-5.005/lib/5.005/i586-linux-thread/DynaLoader.pm |
| 1346 | \& line 168. |
| 1347 | .Ve |
| 1348 | .Sp |
| 1349 | This means, that your linker doesn't include libgcc.a. You have the |
| 1350 | following options: |
| 1351 | .RS 8 |
| 1352 | .IP "a)" 12 |
| 1353 | Either recompile Perl or Mysql, it doesn't matter which. The important |
| 1354 | thing is that you use the same compiler for both. This is definitely |
| 1355 | the recommended solution in the long term. |
| 1356 | .IP "b)" 12 |
| 1357 | A simple workaround is to include libgcc.a manually. Do a \*(L"make clean\*(R" |
| 1358 | and \*(L"make\*(R" and in the output wait for a line like |
| 1359 | .Sp |
| 1360 | .Vb 4 |
| 1361 | \& LD_RUN_PATH="/usr/lib/mysql:/lib" egcs -o |
| 1362 | \& ../blib/arch/auto/DBD/mysql/mysql.so -shared -L/usr/local/lib |
| 1363 | \& dbdimp.o mysql.o -L/usr/lib/mysql -L/usr/lib/mysql -lmysqlclient |
| 1364 | \& -lm |
| 1365 | .Ve |
| 1366 | .Sp |
| 1367 | Repeat the same line in the shell by adding |
| 1368 | .Sp |
| 1369 | .Vb 1 |
| 1370 | \& -L/usr/lib/gcc-lib/i386-redhat-linux/gcc-2.7.2.3 -lgcc |
| 1371 | .Ve |
| 1372 | .Sp |
| 1373 | where the directory is the location of libgcc.a. The best choice |
| 1374 | for locating this file is executing |
| 1375 | .Sp |
| 1376 | .Vb 1 |
| 1377 | \& gcc --print-libgcc-file |
| 1378 | .Ve |
| 1379 | .Sp |
| 1380 | or |
| 1381 | .Sp |
| 1382 | .Vb 1 |
| 1383 | \& gcc -v |
| 1384 | .Ve |
| 1385 | .RE |
| 1386 | .RS 8 |
| 1387 | .RE |
| 1388 | .IP "2.)" 8 |
| 1389 | .IX Item "2.)" |
| 1390 | There are known problems with shared versions of libmysqlclient, at |
| 1391 | least on some Linux boxes. If you receive an error message similar to |
| 1392 | .Sp |
| 1393 | .Vb 4 |
| 1394 | \& install_driver(mysql) failed: Can't load |
| 1395 | \& '/usr/lib/perl5/site_perl/i586-linux/auto/DBD/mysql/mysql.so' |
| 1396 | \& for module DBD::mysql: File not found at |
| 1397 | \& /usr/lib/perl5/i586-linux/5.00404/DynaLoader.pm line 166 |
| 1398 | .Ve |
| 1399 | .Sp |
| 1400 | then this error message can be misleading: It's not mysql.so that fails |
| 1401 | being loaded, but libmysqlclient.so! |
| 1402 | .Sp |
| 1403 | As a workaround, recompile the Msql-Mysql-modules with |
| 1404 | .Sp |
| 1405 | .Vb 4 |
| 1406 | \& perl Makefile.PL --static --config |
| 1407 | \& make |
| 1408 | \& make test |
| 1409 | \& make install |
| 1410 | .Ve |
| 1411 | .Sp |
| 1412 | This option forces linkage against the static libmysqlclient.a. |
| 1413 | .IP "3.)" 8 |
| 1414 | .IX Item "3.)" |
| 1415 | By default mSQL2 is installed to allow local access only. This can break |
| 1416 | the test scripts akmisc.t, msql1.t and msql2.t. You might notice a message |
| 1417 | like |
| 1418 | .Sp |
| 1419 | .Vb 8 |
| 1420 | \& t/akmisc............Can't connect to MSQL server on localhost at |
| 1421 | \& t/akmisc.t line 131 |
| 1422 | \& Cannot connect: Can't connect to MSQL server on localhost |
| 1423 | \& It looks as if your server (on localhost) is not up and running. |
| 1424 | \& This test requires a running server. |
| 1425 | \& Please make sure your server is running and retry. |
| 1426 | \& dubious |
| 1427 | \& Test returned status 10 (wstat 2560, 0xa00) |
| 1428 | .Ve |
| 1429 | .Sp |
| 1430 | If this is the case, try to change the value of \*(L"Remote_Access\*(R" in |
| 1431 | your \fImsql.conf\fR file to \*(L"True\*(R". If the value was set intentionally, |
| 1432 | you might restore the old value after the tests ran ok. |
| 1433 | .IP "4.)" 8 |
| 1434 | .IX Item "4.)" |
| 1435 | If linking fails under Win32 because of a missing symbol |
| 1436 | pthread_cond_init, apply the following patch to dbd/dbdimp.c: |
| 1437 | .Sp |
| 1438 | .Vb 15 |
| 1439 | \& *** dbd/dbdimp.c.orig Wed Sep 23 14:39:33 1998 |
| 1440 | \& --- dbd/dbdimp.c Fri Oct 02 10:37:16 1998 |
| 1441 | \& *************** |
| 1442 | \& *** 1708,1712 **** |
| 1443 | \& --- 1709,1720 ---- |
| 1444 | \& } |
| 1445 | \& return TRUE; |
| 1446 | \& } |
| 1447 | \& + |
| 1448 | \& + #if !defined(_UNIX_) && defined(WIN32) |
| 1449 | \& + int pthread_cond_init() |
| 1450 | \& + { |
| 1451 | \& + return 0; |
| 1452 | \& + } |
| 1453 | \& + #endif |
| 1454 | .Ve |
| 1455 | .Sp |
| 1456 | .Vb 1 |
| 1457 | \& #endif |
| 1458 | .Ve |
| 1459 | .Sp |
| 1460 | (I could make this part of the source distribution, but I think this is an |
| 1461 | ugly hack and hopefully Monty will fix the missing symbol in the next |
| 1462 | release of MyODBC.) |
| 1463 | .IP "5.)" 8 |
| 1464 | .IX Item "5.)" |
| 1465 | mSQL 2.0.4 had a bug, that caused the test t/40bindparam.t to fail. |
| 1466 | This bug is fixed in later versions, 2.0.6 and higher. |
| 1467 | .IP "6.)" 8 |
| 1468 | .IX Item "6.)" |
| 1469 | From time to time compiling DBD::mSQL fails with messages like |
| 1470 | .Sp |
| 1471 | .Vb 10 |
| 1472 | \& In file included from ../dbd/myMsql.h:55, |
| 1473 | \& from ../dbd/dbdimp.h:32, |
| 1474 | \& from dbdimp.c:29: |
| 1475 | \& /usr/local/Hughes/include/common/portability.h:74: |
| 1476 | \& redefinition of `u_int' |
| 1477 | \& /usr/include/sys/types.h:52: `u_int' previously declared here |
| 1478 | \& /usr/local/Hughes/include/common/portability.h:78: redefinition of |
| 1479 | \& `ssize_t' |
| 1480 | \& /usr/include/sys/types.h:116: `ssize_t' previously declared here |
| 1481 | \& *** Error code 1 |
| 1482 | .Ve |
| 1483 | .Sp |
| 1484 | A workaroud is using |
| 1485 | .Sp |
| 1486 | .Vb 1 |
| 1487 | \& perl Makefile.PL --config DEFINE="-DHAVE_SSIZE_T -DHAVE_U_INT" |
| 1488 | .Ve |
| 1489 | .SH "KNOWN BUGS" |
| 1490 | .IX Header "KNOWN BUGS" |
| 1491 | The \fIport\fR part of the first argument to the connect call is |
| 1492 | implemented in an unsafe way when using mSQL. In fact it is just |
| 1493 | setting the environment variable \s-1MSQL_TCP_PORT\s0 during the connect |
| 1494 | call. If another connect call uses another port and the handles |
| 1495 | are used simultaneously, they will interfere. I doubt that this |
| 1496 | will ever change. |
| 1497 | .SH "AUTHORS" |
| 1498 | .IX Header "AUTHORS" |
| 1499 | The current versions of \fBDBD::mSQL\fR and \fBDBD::mysql\fR is almost |
| 1500 | completely written by Jochen Wiedmann (\fIjoe@ispsoft.de\fR). The |
| 1501 | first version's author was Alligator Descartes(\fIdescarte@symbolstone.org\fR), |
| 1502 |