Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perl-5.8.0 / man / man3 / Mysql.3
CommitLineData
86530b38
AT
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 "Mysql 3"
132.TH Mysql 3 "2002-10-01" "perl v5.8.0" "User Contributed Perl Documentation"
133.SH "NAME"
134Msql / Mysql \- Perl interfaces to the mSQL and mysql databases
135.SH "SYNOPSIS"
136.IX Header "SYNOPSIS"
137.Vb 1
138\& use Msql;
139.Ve
140.PP
141.Vb 2
142\& $dbh = Msql->connect($host);
143\& $dbh = Msql->connect($host, $database);
144.Ve
145.PP
146.Vb 1
147\& or
148.Ve
149.PP
150.Vb 1
151\& use Mysql;
152.Ve
153.PP
154.Vb 2
155\& $dbh = Mysql->connect(undef, $database, $user, $password);
156\& $dbh = Mysql->connect($host, $database, $user, $password);
157.Ve
158.PP
159.Vb 1
160\& or
161.Ve
162.PP
163.Vb 2
164\& $dbh = Msql1->connect($host);
165\& $dbh = Msql1->connect($host, $database);
166.Ve
167.PP
168.Vb 1
169\& $dbh->selectdb($database);
170.Ve
171.PP
172.Vb 2
173\& @arr = $dbh->listdbs;
174\& @arr = $dbh->listtables;
175.Ve
176.PP
177.Vb 3
178\& $quoted_string = $dbh->quote($unquoted_string);
179\& $error_message = $dbh->errmsg;
180\& $error_number = $dbh->errno; # MySQL only
181.Ve
182.PP
183.Vb 2
184\& $sth = $dbh->listfields($table);
185\& $sth = $dbh->query($sql_statement);
186.Ve
187.PP
188.Vb 4
189\& @arr = $sth->fetchrow; # Array context
190\& $firstcol = $sth->fetchrow; # Scalar context
191\& @arr = $sth->fetchcol($col_number);
192\& %hash = $sth->fetchhash;
193.Ve
194.PP
195.Vb 1
196\& $sth->dataseek($row_number);
197.Ve
198.PP
199.Vb 1
200\& $sth->as_string;
201.Ve
202.PP
203.Vb 3
204\& @indices = $sth->listindices # only in mSQL 2.0
205\& @arr = $dbh->listindex($table,$index) # only in mSQL 2.0
206\& ($step,$value) = $dbh->getsequenceinfo($table) # only in mSQL 2.0
207.Ve
208.PP
209.Vb 3
210\& $rc = $dbh->shutdown();
211\& $rc = $dbh->createdb($database);
212\& $rc = $dbh->dropdb($database);
213.Ve
214.SH "OBSOLETE SOFTWARE"
215.IX Header "OBSOLETE SOFTWARE"
216As of Msql-Mysql-modules 1.19_10 M(y)sqlPerl is no longer a separate module.
217Instead it is emulated using the \s-1DBI\s0 drivers. You are strongly encouraged
218to implement new code with \s-1DBI\s0 directly. See \*(L"\s-1COMPATIBILITY\s0 \s-1NOTES\s0\*(R"
219below.
220.SH "DESCRIPTION"
221.IX Header "DESCRIPTION"
222This package is designed as close as possible to its C \s-1API\s0
223counterpart. The manual that comes with mSQL or MySQL describes most things
224you need. Due to popular demand it was decided though, that this interface
225does not use StudlyCaps (see below).
226.PP
227As of March 1998, the Msql and Mysql modules are obsoleted by the
228\&\s-1DBI\s0 drivers DBD::mSQL and DBD::mysql, respectively. You are strongly
229encouraged to implement new code with the \s-1DBI\s0 drivers. In fact,
230Msql and Mysql are currently implemented as emulations on top of
231the \s-1DBI\s0 drivers.
232.PP
233Internally you are dealing with the two classes \f(CW\*(C`Msql\*(C'\fR and
234\&\f(CW\*(C`Msql::Statement\*(C'\fR or \f(CW\*(C`Mysql\*(C'\fR and \f(CW\*(C`Mysql::Statement\*(C'\fR, respectively.
235You will never see the latter, because you reach
236it through a statement handle returned by a query or a listfields
237statement. The only class you name explicitly is Msql or Mysql. They
238offer you the connect command:
239.PP
240.Vb 2
241\& $dbh = Msql->connect($host);
242\& $dbh = Msql->connect($host, $database);
243.Ve
244.PP
245.Vb 1
246\& or
247.Ve
248.PP
249.Vb 2
250\& $dbh = Mysql->connect($host, undef, $user, $password);
251\& $dbh = Mysql->connect($host, $database, $user, $password);
252.Ve
253.PP
254.Vb 1
255\& or
256.Ve
257.PP
258.Vb 2
259\& $dbh = Msql1->connect($host);
260\& $dbh = Msql1->connect($host, $database);
261.Ve
262.PP
263This connects you with the desired host/database. With no argument or
264with an empty string as the first argument it connects to the \s-1UNIX\s0
265socket, which has a much better performance than
266the \s-1TCP\s0 counterpart. A database name as the second argument selects
267the chosen database within the connection. The return value is a
268database handle if the connect succeeds, otherwise the return value is
269undef.
270.PP
271You will need this handle to gain further access to the database.
272.PP
273.Vb 1
274\& $dbh->selectdb($database);
275.Ve
276.PP
277If you have not chosen a database with the \f(CW\*(C`connect\*(C'\fR command, or if
278you want to change the connection to a different database using a
279database handle you have got from a previous \f(CW\*(C`connect\*(C'\fR, then use
280selectdb.
281.PP
282.Vb 2
283\& $sth = $dbh->listfields($table);
284\& $sth = $dbh->query($sql_statement);
285.Ve
286.PP
287These two work rather similar as descibed in the mSQL or MySQL manual. They
288return a statement handle which lets you further explore what the
289server has to tell you. On error the return value is undef. The object
290returned by listfields will not know about the size of the table, so a
291\&\fInumrows()\fR on it will return the string \*(L"N/A\*(R";
292.PP
293.Vb 2
294\& @arr = $dbh->listdbs();
295\& @arr = $dbh->listtables;
296.Ve
297.PP
298An array is returned that contains the requested names without any
299further information.
300.PP
301.Vb 1
302\& @arr = $sth->fetchrow;
303.Ve
304.PP
305returns an array of the values of the next row fetched from the
306server. Be carefull with context here! In scalar context the method
307behaves different than expected and returns the first column:
308.PP
309.Vb 1
310\& $firstcol = $sth->fetchrow; # Scalar context!
311.Ve
312.PP
313Similar does
314.PP
315.Vb 1
316\& %hash = $sth->fetchhash;
317.Ve
318.PP
319return a complete hash. The keys in this hash are the column names of
320the table, the values are the table values. Be aware, that when you
321have a table with two identical column names, you will not be able to
322use this method without trashing one column. In such a case, you
323should use the fetchrow method.
324.PP
325.Vb 1
326\& @arr = $sth->fetchcol($colnum);
327.Ve
328.PP
329returns an array of the values of each row for column \f(CW$colnum\fR. Note that
330this reads the entire table and leaves the row offset at the end of the
331table; be sure to use \f(CW$sth\fR\->\fIdataseek()\fR to reset it if you want to
332re-examine the table.
333.PP
334.Vb 1
335\& $sth->dataseek($row_number);
336.Ve
337.PP
338lets you specify a certain offset of the data associated with the
339statement handle. The next fetchrow will then return the appropriate
340row (first row being 0).
341.Sh "No close statement"
342.IX Subsection "No close statement"
343Whenever the scalar that holds a database or statement handle loses
344its value, Msql chooses the appropriate action (frees the result or
345closes the database connection). So if you want to free the result or
346close the connection, choose to do one of the following:
347.IP "undef the handle" 4
348.IX Item "undef the handle"
349.PD 0
350.IP "use the handle for another purpose" 4
351.IX Item "use the handle for another purpose"
352.IP "let the handle run out of scope" 4
353.IX Item "let the handle run out of scope"
354.IP "exit the program." 4
355.IX Item "exit the program."
356.PD
357.Sh "Error messages"
358.IX Subsection "Error messages"
359Both drivers, Msql and Mysql implement a method \->\fIerrmsg()\fR, which
360returns a textual error message. Mysql additionally supports a method
361\&\->errno returning the corresponding error number.
362.PP
363Usually you do fetch error messages with
364.PP
365.Vb 1
366\& $errmsg = $dbh->errmsg();
367.Ve
368.PP
369In situations where a \f(CW$dbh\fR is not available (for example when
370\&\fIconnect()\fR failed) you may instead do a
371.PP
372.Vb 5
373\& $errmsg = Msql->errmsg();
374\& or
375\& $errmsg = Mysql->errmsg();
376\& or
377\& $errmsg = Msql1->errmsg();
378.Ve
379.ie n .Sh "The ""\-w"" switch"
380.el .Sh "The \f(CW\-w\fP switch"
381.IX Subsection "The -w switch"
382With Msql and Mysql the \f(CW\*(C`\-w\*(C'\fR switch is your friend! If you call your perl
383program with the \f(CW\*(C`\-w\*(C'\fR switch you get the warnings from \->errmsg on
384\&\s-1STDERR\s0. This is a handy method to get the error messages from the msql
385server without coding it into your program.
386.PP
387If you want to know in greater detail what's going on, set the
388environment variables that are described in David's manual. David's
389debugging aid is excellent, there's nothing to be added.
390.PP
391By default errors are printed as warnings. You can suppress this
392behaviour by using the PrintError attribute of the respective handles:
393.PP
394.Vb 1
395\& $dbh->{'dbh'}->{'PrintError'} = 0;
396.Ve
397.ie n .Sh "\->quote($str [, $length])"
398.el .Sh "\->quote($str [, \f(CW$length\fP])"
399.IX Subsection "->quote($str [, $length])"
400returns the argument enclosed in single ticks ('') with any special
401character escaped according to the needs of the \s-1API\s0.
402.PP
403For mSQL this means, any single tick within the string is escaped with
404a backslash and backslashes are doubled. Currently (as of msql\-1.0.16)
405the \s-1API\s0 does not allow to insert \s-1NUL\s0's (\s-1ASCII\s0 0) into tables. The quote
406method does not fix this deficiency.
407.PP
408MySQL allows \s-1NUL\s0's or any other kind of binary data in strings. Thus
409the quote method will additionally escape \s-1NUL\s0's as \e0.
410.PP
411If you pass undefined values to the quote method, it returns the
412string \f(CW\*(C`NULL\*(C'\fR.
413.PP
414If a second parameter is passed to \f(CW\*(C`quote\*(C'\fR, the result is truncated
415to that many characters.
416.Sh "\s-1NULL\s0 fields"
417.IX Subsection "NULL fields"
418\&\s-1NULL\s0 fields in tables are returned to perl as undefined values.
419.Sh "Metadata"
420.IX Subsection "Metadata"
421Now lets reconsider the above methods with regard to metadata.
422.Sh "Database Handle"
423.IX Subsection "Database Handle"
424As said above you get a database handle with the \fIconnect()\fR method.
425The database handle knows about the socket, the host, and the database
426it is connected to.
427.PP
428You get at the three values with the methods
429.PP
430.Vb 3
431\& $scalar = $dbh->sock;
432\& $scalar = $dbh->host;
433\& $scalar = $dbh->database;
434.Ve
435.PP
436Mysql additionally supports
437.PP
438.Vb 2
439\& $scalar = $dbh->user;
440\& $scalar = $dbh->sockfd;
441.Ve
442.PP
443where the latter is the file descriptor of the socket used by the
444database connection. This is the same as \f(CW$dbh\fR\->sock for mSQL.
445.Sh "Statement Handle"
446.IX Subsection "Statement Handle"
447Two constructor methods return a statement handle:
448.PP
449.Vb 2
450\& $sth = $dbh->listfields($table);
451\& $sth = $dbh->query($sql_statement);
452.Ve
453.PP
454$sth knows about all metadata that are provided by the \s-1API:\s0
455.PP
456.Vb 2
457\& $scalar = $sth->numrows;
458\& $scalar = $sth->numfields;
459.Ve
460.PP
461.Vb 18
462\& @arr = $sth->table; the names of the tables of each column
463\& @arr = $sth->name; the names of the columns
464\& @arr = $sth->type; the type of each column, defined in msql.h
465\& and accessible via Msql::CHAR_TYPE,
466\& &Msql::INT_TYPE, &Msql::REAL_TYPE or
467\& &Mysql::FIELD_TYPE_STRING,
468\& &Mysql::FIELD_TYPE_LONG, ...
469\& @arr = $sth->isnotnull; array of boolean
470\& @arr = $sth->isprikey; array of boolean
471\& @arr = $sth->isnum; array of boolean
472\& @arr = $sth->length; array of the possibble maximum length of each
473\& field in bytes
474\& @arr = $sth->maxlength; array of the actual maximum length of each field
475\& in bytes. Be careful when using this attribute
476\& under MsqlPerl: The server doesn't offer this
477\& attribute, thus it is calculated by fetching
478\& all rows. This might take a long time and you
479\& might need to call $sth->dataseek.
480.Ve
481.PP
482Mysql additionally supports
483.PP
484.Vb 4
485\& $scalar = $sth->affectedrows number of rows in database affected by query
486\& $scalar = $sth->insertid the unique id given to a auto_increment field.
487\& $string = $sth->info() more info from some queries (ALTER TABLE...)
488\& $arrref = $sth->isblob; array of boolean
489.Ve
490.PP
491The array methods (table, name, type, is_not_null, is_pri_key, length,
492affected_rows, is_num and blob) return an array in array context and
493an array reference (see perlref and perlldsc for details) when
494called in a scalar context. The scalar context is useful, if you need
495only the name of one column, e.g.
496.PP
497.Vb 1
498\& $name_of_third_column = $sth->name->[2]
499.Ve
500.PP
501which is equivalent to
502.PP
503.Vb 2
504\& @all_column_names = $sth->name;
505\& $name_of_third_column = $all_column_names[2];
506.Ve
507.Sh "New in mSQL 2.0"
508.IX Subsection "New in mSQL 2.0"
509The \fIquery()\fR function in the \s-1API\s0 returns the number of rows affected by
510a query. To cite the mSQL \s-1API\s0 manual, this means...
511.PP
512.Vb 4
513\& If the return code is greater than 0, not only does it imply
514\& success, it also indicates the number of rows "touched" by the query
515\& (i.e. the number of rows returned by a SELECT, the number of rows
516\& modified by an update, or the number of rows removed by a delete).
517.Ve
518.PP
519As we are returning a statement handle on selects, we can easily check
520the number of rows returned. For non-selects we behave just the same
521as mSQL\-2.
522.PP
523To find all indices associated with a table you can call the
524\&\f(CW\*(C`listindices()\*(C'\fR method on a statement handle. To find out the columns
525included in an index, you can call the \f(CW\*(C`listindex($table,$index)\*(C'\fR
526method on a database handle.
527.PP
528There are a few new column types in mSQL 2. You can access their
529numeric value with these functions defined in the Msql package:
530\&\s-1IDENT_TYPE\s0, \s-1NULL_TYPE\s0, \s-1TEXT_TYPE\s0, \s-1DATE_TYPE\s0, \s-1UINT_TYPE\s0, \s-1MONEY_TYPE\s0,
531\&\s-1TIME_TYPE\s0, \s-1IDX_TYPE\s0, \s-1SYSVAR_TYPE\s0.
532.PP
533You cannot talk to a 1.0 server with a 2.0 client.
534.PP
535You cannot link to a 1.0 library \fIand\fR to a 2.0 library \fIat the same
536time\fR. So you may want to build two different Msql modules at a time,
537one for 1.0, another for 2.0, and load whichever you need. Check out
538what the \f(CW\*(C`\-I\*(C'\fR switch in perl is for.
539.PP
540Everything else seems to remain backwards compatible.
541.Sh "@EXPORT"
542.IX Subsection "@EXPORT"
543For historical reasons the constants \s-1CHAR_TYPE\s0, \s-1INT_TYPE\s0, and
544\&\s-1REAL_TYPE\s0 are in \f(CW@EXPORT\fR instead of \f(CW@EXPORT_OK\fR. This means, that you
545always have them imported into your namespace. I consider it a bug,
546but not such a serious one, that I intend to break old programs by
547moving them into \s-1EXPORT_OK\s0.
548.Sh "Displaying whole tables in one go"
549.IX Subsection "Displaying whole tables in one go"
550A handy method to show the complete contents of a statement handle is
551the as_string method. This works similar to the msql monitor with a
552few exceptions:
553.IP "the width of a column" 2
554.IX Item "the width of a column"
555is calculated by examining the width of all entries in that column
556.IP "control characters" 2
557.IX Item "control characters"
558are mapped into their backslashed octal representation
559.IP "backslashes" 2
560.IX Item "backslashes"
561are doubled (\f(CW\*(C`\e\e instead of \e\*(C'\fR)
562.IP "numeric values" 2
563.IX Item "numeric values"
564are adjusted right (both integer and floating point values)
565.PP
566The differences are illustrated by the following table:
567.PP
568Input to msql (a real carriage return here replaced with ^M):
569.PP
570.Vb 4
571\& CREATE TABLE demo (
572\& first_field CHAR(10),
573\& second_field INT
574\& ) \eg
575.Ve
576.PP
577.Vb 5
578\& INSERT INTO demo VALUES ('new
579\& line',2)\eg
580\& INSERT INTO demo VALUES ('back\e\eslash',1)\eg
581\& INSERT INTO demo VALUES ('cr^Mcrnl
582\& nl',3)\eg
583.Ve
584.PP
585Output of msql:
586.PP
587.Vb 9
588\& +-------------+--------------+
589\& | first_field | second_field |
590\& +-------------+--------------+
591\& | new
592\& line | 2 |
593\& | back\eslash | 1 |
594\& crnlr
595\& nl | 3 |
596\& +-------------+--------------+
597.Ve
598.PP
599Output of pmsql:
600.PP
601.Vb 7
602\& +----------------+------------+
603\& |first_field |second_field|
604\& +----------------+------------+
605\& |new\e012line | 2|
606\& |back\e\eslash | 1|
607\& |cr\e015crnl\e012nl| 3|
608\& +----------------+------------+
609.Ve
610.Sh "Version information"
611.IX Subsection "Version information"
612The version of Msql and Mysql is always stored in \f(CW$Msql::VERSION\fR or
613\&\f(CW$Mysql::VERSION\fR as it is perl standard.
614.PP
615The mSQL \s-1API\s0 implements methods to access some internal configuration
616parameters: gethostinfo, getserverinfo, and getprotoinfo. All three
617are available both as class methods or via a database handle. But
618under no circumstances they are associated with a database handle. All
619three return global variables that reflect the \fBlast\fR \fIconnect()\fR
620command within the current program. This means, that all three return
621empty strings or zero \fIbefore\fR the first call to \fIconnect()\fR.
622.PP
623This situation is better with MySQL: The methods are valid only
624in connection with a database handle.
625.Sh "Administration"
626.IX Subsection "Administration"
627shutdown, createdb, dropdb, reloadacls are all accessible via a
628database handle and implement the corresponding methods to what
629msqladmin does.
630.PP
631The mSQL and MySQL engines do not permit that these commands are invoked by
632users without sufficient privileges. So please make sure
633to check the return and error code when you issue one of them.
634.PP
635.Vb 3
636\& $rc = $dbh->shutdown();
637\& $rc = $dbh->createdb($database);
638\& $rc = $dbh->dropdb($database);
639.Ve
640.PP
641It should be noted that database deletion is \fInot prompted for\fR in
642any way. Nor is it undo-able from within Perl.
643.PP
644.Vb 1
645\& B<Once you issue the dropdb() method, the database will be gone!>
646.Ve
647.PP
648These methods should be used at your own risk.
649.Sh "StudlyCaps"
650.IX Subsection "StudlyCaps"
651Real Perl Programmers (C) usually don't like to type \fIListTables\fR but
652prefer \fIlist_tables\fR or \fIlisttables\fR. The mSQL \s-1API\s0 uses StudlyCaps
653everywhere and so did early versions of MsqlPerl. Beginning with
654\&\f(CW$VERSION\fR 1.06 all methods are internally in lowercase, but may be
655written however you please. Case is ignored and you may use the
656underline to improve readability.
657.PP
658The price for using different method names is neglectible. Any method
659name you use that can be transformed into a known one, will only be
660defined once within a program and will remain an alias until the
661program terminates. So feel free to run fetch_row or connecT or
662ListDBs as in your old programs. These, of course, will continue to
663work.
664.SH "PREREQUISITES"
665.IX Header "PREREQUISITES"
666mSQL is a database server and an \s-1API\s0 library written by David
667Hughes. To use the adaptor you definitely have to install these first.
668.PP
669MySQL is a libmysqlclient.a library written by Michael Widenius
670This was originally inspired by MySQL.
671.SH "COMPATIBILITY NOTES"
672.IX Header "COMPATIBILITY NOTES"
673M(y)sql used to be a separate module written in C. This is no longer
674the case, instead the old modules are emulated by their corresponding
675\&\s-1DBI\s0 drivers. I did my best to remove any incompatibilities, but the
676following problems are known to remain:
677.IP "Static methods" 4
678.IX Item "Static methods"
679For whatever reason, mSQL implements some functions independent from
680the respective database connection that really depend on it. This
681made it possible to implement
682.Sp
683.Vb 1
684\& Msql->errmsg
685.Ve
686.Sp
687or
688.Sp
689.Vb 1
690\& Msql->getserverinfo
691.Ve
692.Sp
693as static methods. This is no longer the case, it never was for
694MysqlPerl. Instead you have to use
695.Sp
696.Vb 1
697\& $dbh->errmsg
698.Ve
699.Sp
700or
701.Sp
702.Vb 1
703\& $dbh->getserverinfo
704.Ve
705.IP "$M(Y)SQL::QUIET" 4
706.IX Item "$M(Y)SQL::QUIET"
707This variable used to turn off the printing of error messages. Unfortunately
708\&\s-1DBI\s0 uses a completely different mechanism for that: The \f(CW\*(C`PrintError\*(C'\fR
709attribute of the database and/or statement handles. We try to emulate
710the old behaviour by setting the \f(CW\*(C`PrintError\*(C'\fR attribute to the current
711value of $M(Y)SQL::QUIET when a handle is created, that is when
712M(y)sql\->connect or \f(CW$dbh\fR\->\fIquery()\fR are called.
713.Sp
714You can overwrite this by using something like
715.Sp
716.Vb 1
717\& $dbh->{'dbh'}->{'PrintError'} = 1;
718.Ve
719.Sp
720or
721.Sp
722.Vb 1
723\& $sth->{'PrintError'} = 0;
724.Ve
725.SH "AUTHORS"
726.IX Header "AUTHORS"
727Andreas Koenig \f(CW\*(C`koenig@franz.ww.TU\-Berlin.DE\*(C'\fR wrote the original
728MsqlPerl. Jochen Wiedmann \f(CW\*(C`joe@ispsoft.de\*(C'\fR wrote the M(y)sqlPerl
729emulation using \s-1DBI\s0.
730.SH "SEE ALSO"
731.IX Header "SEE ALSO"
732Alligator Descartes wrote a database driver for Tim Bunce's \s-1DBI\s0. I
733recommend anybody to carefully watch the development of this module
734(\f(CW\*(C`DBD::mSQL\*(C'\fR). Msql is a simple, stable, and fast module, and it will
735be supported for a long time. But it's a dead end. I expect in the
736medium term, that the \s-1DBI\s0 efforts result in a richer module family
737with better support and more functionality. Alligator maintains an
738interesting page on the \s-1DBI\s0 development:
739.PP
740.Vb 1
741\& http://www.symbolstone.org/technology/perl/DBI
742.Ve