2 '\" Generated from file 'mysqltcl.man' by tcllib/doctools with format 'nroff'
4 '\" The definitions below are for supplemental macros used in Tcl/Tk
7 '\" .AP type name in/out ?indent?
8 '\" Start paragraph describing an argument to a library procedure.
9 '\" type is type of argument (int, etc.), in/out is either "in", "out",
10 '\" or "in/out" to describe whether procedure reads or modifies arg,
11 '\" and indent is equivalent to second arg of .IP (shouldn't ever be
12 '\" needed; use .AS below instead)
15 '\" Give maximum sizes of arguments for setting tab stops. Type and
16 '\" name are examples of largest possible arguments that will be passed
17 '\" to .AP later. If args are omitted, default tab stops are used.
20 '\" Start box enclosure. From here until next .BE, everything will be
21 '\" enclosed in one large box.
24 '\" End of box enclosure.
27 '\" Begin code excerpt.
32 '\" .VS ?version? ?br?
33 '\" Begin vertical sidebar, for use in marking newly-changed parts
34 '\" of man pages. The first argument is ignored and used for recording
35 '\" the version when the .VS was added, so that the sidebars can be
36 '\" found and removed when they reach a certain age. If another argument
37 '\" is present, then a line break is forced before starting the sidebar.
40 '\" End of vertical sidebar.
43 '\" Begin an indented unfilled display.
46 '\" End of indented unfilled display.
49 '\" Start of list of standard options for a Tk widget. The
50 '\" options follow on successive lines, in four columns separated
54 '\" End of list of standard options for a Tk widget.
56 '\" .OP cmdName dbName dbClass
57 '\" Start of description of a specific option. cmdName gives the
58 '\" option's name as specified in the class command, dbName gives
59 '\" the option's name in the option database, and dbClass gives
60 '\" the option's class in the option database.
63 '\" Print arg1 underlined, then print arg2 normally.
67 '\" # Set up traps and other miscellaneous stuff for Tcl/Tk man pages.
71 '\" # Start an argument description
75 . ie !"\\$2"" .TP \\n()Cu
80 \&\\$1 \\fI\\$2\\fP (\\$3)
93 '\" # define tabbing values for .AP
96 .if !"\\$1"" .nr )A \\w'\\$1'u+3n
99 .if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n
100 .nr )C \\n()Bu+\\w'(in/out)'u+2n
102 .AS Tcl_Interp Tcl_CreateInterp in/out
103 '\" # BS - start boxed text
104 '\" # ^y = starting y location
112 .if n \l'\\n(.lu\(ul'
115 '\" # BE - end boxed text (draw box now)
120 .ie n \l'\\n(^lu\(ul'
122 .\" Draw four-sided box normally, but don't draw top of
123 .\" box if the box started on an earlier page.
125 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
128 \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
135 '\" # VS - start vertical sidebar
136 '\" # ^Y = starting y location
137 '\" # ^v = 1 (for troff; for nroff this doesn't matter)
141 .ie n 'mc \s12\(br\s0
144 '\" # VE - end of vertical sidebar
152 \h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n'
159 '\" # Special macro to handle page bottom: finish off current
160 '\" # box/sidebar if in box/sidebar mode, then invoked standard
161 '\" # page bottom macro.
168 .\" Draw three-sided box if this is the box's first page,
169 .\" draw two sides but no top otherwise.
170 .ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
171 .el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
174 .nr ^x \\n(^tu+1v-\\n(^Yu
175 \kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c
188 '\" # DS - begin display
194 '\" # DE - end display
200 '\" # SO - start of list of standard options
202 .SH "STANDARD OPTIONS"
208 '\" # SE - end of list of standard options
213 See the \\fBoptions\\fR manual entry for details on the standard options.
215 '\" # OP - start of full description for a single option
220 Command-Line Name: \\fB\\$1\\fR
221 Database Name: \\fB\\$2\\fR
222 Database Class: \\fB\\$3\\fR
226 '\" # CS - begin code excerpt
232 '\" # CE - end code excerpt
240 .TH "mysqltcl" n 3.0 ""
243 mysqltcl \- MySQL server access commands for Tcl
245 package require \fBTcl 8.4\fR
247 package require \fBmysqltcl 3.0\fR
249 \fB::mysql::connect\fR ?\fIoption value\fR...?
251 \fB::mysql::use\fR \fIhandle\fR \fIdatabase\fR
253 \fB::mysql::sel\fR \fIhandle\fR \fIsql-statement\fR ?\fI-list|-flatlist\fR?
255 \fB::mysql::fetch\fR \fIhandle\fR
257 \fB::mysql::exec\fR \fIhandle\fR \fIsql-statement\fR
259 \fB::mysql::query\fR \fIhandle\fR \fIsql-select-statement\fR
261 \fB::mysql::endquery\fR \fIquery-handle\fR
263 \fB::mysql::map\fR \fIhandle\fR \fIbinding-list\fR \fIscript\fR
265 \fB::mysql::receive\fR \fIhandle\fR \fIsql-statment\fR \fIbinding-list\fR \fIscript\fR
267 \fB::mysql::seek\fR \fIhandle\fR \fIrow-index\fR
269 \fB::mysql::col\fR \fIhandle\fR \fItable-name\fR \fIoption\fR
271 \fB::mysql::col\fR \fIhandle\fR \fItable-name\fR \fIoptionkist\fR
273 \fB::mysql::col\fR \fIhandle\fR ?\fIoption\fR...?
275 \fB::mysql::info\fR \fIhandle\fR \fIoption\fR
277 \fB::mysql::baseinfo\fR \fIoption\fR
279 \fB::mysql::ping\fR \fIhandle\fR
281 \fB::mysql::changeuser\fR \fIuser\fR \fIpassword\fR ?\fIdatabase\fR?
283 \fB::mysql::result\fR \fIhandle\fR \fIoption\fR
285 \fB::mysql::state\fR \fIhandle\fR ?\fI-numeric\fR?
287 \fB::mysql::close\fR ?\fIhandle\fR?
289 \fB::mysql::insertid\fR \fIhandle\fR
291 \fB::mysql::escape\fR ?\fIhandle\fR? \fIstring\fR
293 \fB::mysql::autocommit\fR \fIhandle\fR \fIboolean\fR
295 \fB::mysql::commit\fR \fIhandle\fR
297 \fB::mysql::rollback\fR \fIhandle\fR
299 \fB::mysql::nextresult\fR \fIhandle\fR
301 \fB::mysql::moreresult\fR \fIhandle\fR
303 \fB::mysql::warningcount\fR \fIhandle\fR
305 \fB::mysql::isnull\fR \fIvalue\fR
307 \fB::mysql::newnull\fR
309 \fB::mysql::setserveroption\fR \fIhandle\fR \fIoption\fR
311 \fB::mysql::shutdown\fR \fIhandle\fR
313 \fB::mysql::encoding\fR \fIhandle\fR ?encoding?
317 MySQLTcl is a collection of Tcl commands and a Tcl global array that
318 provide access to MySQL database servers.
320 MySQLTcl is nothing more than a patched version of a patched version
321 of Hakan Soderstrom's patch of Tom Poindexter's Sybtcl.
323 Mysqltcl is binary Tcl library (extension) written in C language that use direkt
324 official MySQL C-API. Almost all Tcl commands correspond to MySQL C-API functions.
325 For detail documentation see official MySQL C-API manual.
326 .SH "MYSQLTCL COMMANDS"
328 \fB::mysql::connect\fR ?\fIoption value\fR...?
329 Connect to a MySQL server.
330 A handle is returned which should be used in other mysqltcl
331 commands using this connection.
332 ::mysql::connect raises a Tcl error if the connection fails.
333 ::mysql::connect read first the options from my.cnf file group mysqltcl.
334 See MySQL documentation chapter "options files".
335 Possible connection options are:
338 \fB-host\fR \fIhostname\fR
339 The host on which the server is located. The local host is used by default.
341 \fB-user\fR \fIuser\fR
342 The user whose name is used for the connection.
343 The current Unix user-name is used by default.
345 \fB-password\fR \fIpassword\fR
346 The password that must be used for the connection.
347 If it is not present, the connection is possible only for users with
348 no password on the server.
351 If this option is present, \fIdb\fR is used as current database, with no need
352 for a call to \fImysql::use\fR.
354 \fB-port\fR \fIport\fR
355 The port number for the TCP/IP connection, if it's different from the default.
357 \fB-socket\fR \fIsocket\fR
358 The socket or named pipe for the connection.
360 \fB-encoding\fR \fIencodingname\fR
361 The option works similar to -encoding option in fconfigure. It support also
362 special encoding name binary. By option -binary no converting will be done be reading or writing to/from MySQL.
363 If option is not set the system encoding (see utf-8) is used.
364 Please test all input and outputs with another program to check that all
365 is the way you expect it. If option binary is not used the system procedures
366 Tcl_ExternalToUtfDString (writing) and Tcl_ExternalToUtf (reading) will be used
367 by option binary the function Tcl_GetByteArrayFromObj and Tcl_NewByteArrayObj are used.
368 If you want to manipulate binary date use -encoding binary. By handling textes set your
369 special encoding that you want to use in your database. Consider what another system access the
370 database and what encoding they expect. It can useful
371 to use -encoding utf-8. That is standard encoding in some linux distributions and newer systems.
373 \fB-compress\fR \fIboolean\fR
374 Use compression protocol. Default is false
376 \fB-odbc\fR \fIboolean\fR
377 The client is an ODBC client. This changes mysqld to be more ODBC-friendly. Default is false
379 \fB-noschema\fR \fIboolean\fR
380 Don't allow the db_name.tbl_name.col_name syntax. This is for ODBC. It causes the parser to generate an error if you use that syntax, which is useful for trapping bugs in some ODBC programs. This changes mysqld to be more ODBC-friendly. Default is false
382 \fB-multistatement\fR \fIboolean\fR
383 Tell the server that the client may send multiple-row-queries (separated by `;').
384 If this flag is not set, multiple-row-queries are disabled. Default is false.
386 \fB-multiresult\fR \fIboolean\fR
387 Tell the server that the client can handle multiple-result sets from multi-queries or stored procedures.
388 This is automatically set if CLIENT_MULTI_STATEMENTS is set.
390 \fB-localfiles\fR \fIboolean\fR
391 Enable LOAD DATA LOCAL handling. Default is false.
393 \fB-foundrows\fR \fIboolean\fR
394 Return the number of found (matched) rows, not the number of affected rows.
397 \fB-interactive\fR \fIboolean\fR
398 Allow interactive_timeout seconds (instead of wait_timeout seconds) of inactivity before closing the connection.
399 The client's session wait_timeout variable will be set to the value of the session interactive_timeout variable.
402 \fB-ssl\fR \fIboolean\fR
403 Switch to SSL after handshake. Default is false
405 \fB-sslkey\fR \fIstring\fR
406 is the pathname to the key file.
409 \fB-sslcert\fR \fIstring\fR
410 is the pathname to the certificate file.
413 \fB-sslca\fR \fIstring\fR
414 is the pathname to the certificate authority file.
417 \fB-sslcapath\fR \fIstring\fR
418 is the pathname to a directory that contains trusted SSL CA certificates in pem format.
421 \fB-sslcipher\fR \fIstring\fR
422 is a list of allowable ciphers to use for SSL encryption.
425 \fB-reconnect\fR \fIboolean\fR
429 \fB::mysql::use\fR \fIhandle\fR \fIdatabase\fR
430 Associate a connected handle with a particular database.
431 \fIhandle\fR must be a valid handle previously obtained from ::mysql::connect.
432 mysql::use raises a Tcl error if the handle is not valid or
433 if the database name specified could not be used.
435 Consider you can use mysqltcl without to specify the database, in this case
436 you must use explizit schema notation to specify the table in sql.
439 ::mysql::sel $handle {select * from uni.student}
442 with option connection \fI-noschema\fR you can prohibit such syntax.
444 \fB::mysql::sel\fR \fIhandle\fR \fIsql-statement\fR ?\fI-list|-flatlist\fR?
445 Send \fIsql-statement\fR to the server.
447 If \fIsql-statement\fR is a SELECT statement and no \fI-list\fR or
448 \fI-flatlist\fR option is specified, the command returns the
449 number of rows returned as the result of the query.
450 The rows can be obtained by the \fI::mysql::fetch\fR and/or the
451 \fI::mysql::map\fR commands.
452 The resulting rows are called the \fIpending result\fR.
454 If \fIsql-statement\fR is a SELECT statement and \fI-list\fR or \fI-flatlist\fR
455 is specified, the command returns the full list of rows returned as
456 the result of the query in one of two possible formats:
460 generates a list of lists, in which each element is a row of the result.
463 generates the concatenation of all rows in a single list, which
464 is useful for scanning with a single \fIforeach\fR.
469 % ::mysql::sel $db "SELECT ID, NAME FROM FRIENDS" -list
470 {1 Joe} {2 Phil} {3 John}
471 % ::mysql::sel $db "SELECT ID, NAME FROM FRIENDS" -flatlist
472 {1 Joe 2 Phil 3 John}
475 Note that both list syntaxes are faster than something like
478 % ::mysql::sel $db "SELECT ID, NAME FROM FRIENDS"
479 % ::mysql::map $db {id name} {lappend result $id $name}
481 {1 Joe 2 Phil 3 John}
484 If \fIsql-statement\fR is a valid MySQL statement, but not a SELECT
485 statement, the command returns -1 after executing the statement, or an empty
486 string if \fI-list\fR or \fI-flatlist\fR is specified.
487 There is no pending result in this case.
489 In any case ::mysql::sel implicitly cancels any previous result still
490 pending for the handle.
492 \fB::mysql::fetch\fR \fIhandle\fR
493 Returns the next row from result set as Tcl list.
494 mysql::fetch raises a Tcl error if there is no pending result for \fIhandle\fR.
495 mysql::fetch was former named mysqlnext.
497 \fB::mysql::exec\fR \fIhandle\fR \fIsql-statement\fR
498 Send \fIsql-statement\fR, a MySQL non-SELECT statement, to the server.
499 The \fIhandle\fR must be in use (through ::mysql::connect and ::mysql::use).
501 ::mysql::exec implicitly cancels any previous result pending for the handle.
503 If \fIsql-statement\fR is a valid MySQL SELECT statement, the statement
504 is executed, but the result is discarded.
505 No Tcl error is generated.
506 This amounts to a (potentially costly) no-op.
507 Use the ::mysql::sel command for SELECT statements.
509 ::mysql::exec returns the number of affected rows (DELETE, UPDATE).
510 In case of multiple statement ::mysql::exec returns a list of number of affected rows.
513 \fB::mysql::query\fR \fIhandle\fR \fIsql-select-statement\fR
514 Send \fIsql-select-statement\fR to the server.
516 \fImysql::query\fR allow to send multiple nested queries on one handle (without need to build
517 new handle or caching results).
518 mysql::query return a query handle that can be used as handle in commands as (mysql::fetch,
519 ::mysql::map, mysql::seek, mysql::col, mysql::result).
520 After result proceeding all query must be
521 freed with \fI::mysql::endquery query-hanlde\fR command.
526 set query1 [::mysql::query $db {SELECT ID, NAME FROM FRIENDS}\\]
527 while {[set row [::mysql::fetch $query1]]!=""} {
528 set id [lindex $row 0]
529 set query2 [::mysql::query $db "SELECT ADDRESS FROM ADDRESS WHERE FRIENDID=$ID"]
530 ::mysql::map $query2 address { puts "address = $address" }
531 ::mysql::endquery $query2
533 ::mysql::endquery $query1
536 In most cases one should use sql-joins and avoid nested queries.
537 SQL-sever can optimize such queries.
538 But in some applications (GUI-Forms) where the results are used long time the inner
539 query is not known before.
541 \fB::mysql::endquery\fR \fIquery-handle\fR
542 free result memory after \fI::mysql::query\fR command.
543 You must invoke ::mysql::endquery after each mysqlquery to not cause memory leaks. See mysqlquery command.
545 Using \fI::mysql::endquery\fR on db-handle will free also memory (pending result) after \fI::mysql::sel\fR command.
548 \fB::mysql::map\fR \fIhandle\fR \fIbinding-list\fR \fIscript\fR
549 Iterate a script over the rows of the pending result.
550 ::mysql::map may consume all rows or only some of the rows of the pending
552 Any remaining rows may be obtained by further ::mysql::fetch or ::mysql::map
555 \fIhandle\fR must be a handle with a pending result from a previous
556 ::mysql::sel command.
557 \fIbinding-list\fR must be a list of one or more variable names.
558 \fIscript\fR must be a Tcl script.
559 It may be empty, but usually it contains one or more commands.
561 ::mysql::map processes one row at a time from the pending result.
562 For each row the column values are bound to the variables in the
563 binding list, then the script is executed.
564 Binding is strictly positional.
565 The first variable in the binding list is bound to the first column of
567 The variables are created in the current context (if they do not
569 A variable name begining with a hyphen is not bound; it serves as a
570 placeholder in the binding list.
571 If there are more columns than variables the extra columns are
574 The ::mysql::map command is similar to an ordinary \fIforeach\fR.
575 A \fIforeach\fR iterates over the elements of a list, ::mysql::map
576 iterates over the rows of a pending result.
577 In both cases iteration is affected by \fIbreak\fR and \fIcontinue\fR
579 The binding list variables retain their last values after the command
582 A simple example follows.
583 Assume $db is a handle in use.
587 select lname, fname, area, phone from friends order by lname, fname
589 ::mysql::map $db {ln fn - phone} {
590 if {$phone == {}} continue
591 puts [format "%16s %-8s %s" $ln $fn $phone]
595 The ::mysql::sel command gets and sorts all rows from table friends.
596 The ::mysql::map command is used to format and print the result in a way
597 suitable for a phone list.
598 For demonstration purposes one of the columns (area) is not used.
599 The script begins by skipping over rows which have no phone number.
600 The second command in the script formats and prints values from the row.
602 ::mysql::map raises a Tcl error if there is no pending result for
603 \fIhandle\fR, or if \fIbinding-list\fR contains more variables than
604 there are columns in the pending result.
607 \fB::mysql::receive\fR \fIhandle\fR \fIsql-statment\fR \fIbinding-list\fR \fIscript\fR
608 This command works the same way as the command mysqtclmap but
609 it do not need leading ::mysql::sel command.
610 The main difference is internal using of MySQL client library.
611 This command use mysql_use_result from C-API that do not
612 store result on client but try to receive the rows directly
614 There is also no client cache.
615 This command can be faster as using of ::mysql::sel and by
616 very big resultset will not overload client machine.
617 The scipt should process the result immadiatly because
618 it can block table (or tables) for another clients.
619 If performance matter please test all alternatives separatly.
620 You must consider two aspects: memory consumption and performance.
622 \fB::mysql::seek\fR \fIhandle\fR \fIrow-index\fR
623 Moves the current position among the rows in the pending result.
624 This may cause \fI::mysql::fetch\fR and \fI::mysql::map\fR to re-read rows, or to
627 Row index 0 is the position just before the first row in the pending result;
628 row index 1 is the position just before the second row, and so
630 You may specify a negative row index.
631 Row index -1 is the position just before the last row;
632 row index -2 is the position just before the second last row,
634 An out-of-bounds row index will cause ::mysql::seek to set the new current
635 position either just before the first row (if the index is too negative),
636 or just after the last row (if the index exceeds the number of rows).
637 This is not an error condition.
639 ::mysql::seek returns the number of rows that can be read sequentially from
640 the new current position.
641 ::mysql::seek raises a Tcl error if there is no pending result for \fIhandle\fR.
643 Portability note: The functionality of \fI::mysql::seek\fR is frequently
644 absent in other Tcl extensions for SQL.
645 That is because MySQL C-API client library ofers own result set caching functionality
646 that lacks another SQL-APIs.
647 That increase the performance because all rows are received at once and the query does
648 not block the server for another clienst , on the other
649 hand you works on the cached data can use a lot of memory and are up to date only in the moment
650 of query but not fetch.
653 \fB::mysql::col\fR \fIhandle\fR \fItable-name\fR \fIoption\fR
655 \fB::mysql::col\fR \fIhandle\fR \fItable-name\fR \fIoptionkist\fR
657 \fB::mysql::col\fR \fIhandle\fR ?\fIoption\fR...?
658 Return information about the columns of a table.
659 \fIhandle\fR must be in use.
660 \fItable-name\fR must be the name of a table; it may be a table name
661 or \fI-current\fR if there is a pending result.
662 One or more options control what information to return.
663 Each option must be one of the following keywords.
666 \fBname\fR Return the name of a column.
669 Return the type of a column; one of the strings \fIdecimal\fR,
670 \fItiny\fR, \fIshort\fR, \fIlong\fR, \fIfloat\fR, \fIdouble\fR,
671 \fInull\fR, \fItimestamp\fR, \fIlong long\fR, \fIint24\fR, \fIdate\fR,
672 \fItime\fR, \fIdate time\fR, \fIyear\fR, \fInew date\fR, \fIenum\fR,
673 \fIset\fR, \fItiny blob\fR, \fImedium blob\fR, \fIlong blob\fR,
674 \fIblob\fR, \fIvar string\fR, or \fIstring\fR.
675 Note that a column of type \fIchar\fR will return tiny, while they are
678 \fBlength\fR Return the length of a column in bytes.
680 \fBtable\fR Return the name of the table in which this column occurs.
682 \fBnon_null\fR Return the string "1" if the column is non-null; otherwise "0".
684 \fBprim_key\fR Return the string "1" if the column is part of the primary key;
687 \fBnumeric\fR Return the string "1" if the column is numeric; otherwise "0".
689 \fBdecimals\fR Return the string "1" if the column is non-null; otherwise "0".
691 The three forms of this command generate their result in a
695 If a single option is present the result is a simple list of
696 values; one for each column.
698 If the options are given in the form of an option list the
699 result is a list of lists.
700 Each sublist corresponds to a column and contains the information
701 specified by the options.
703 If several options are given, but not in a list, the result is also
705 In this case each sublist corresponds to an option and contains one
706 value for each column.
708 The following is a sample interactive session containing all forms of
709 the ::mysql::col command and their results.
710 The last command uses the \fI-current\fR option.
711 It could alternatively specify the table name explicitly.
714 %::mysql::col $db friends name
715 name lname area phone
716 % ::mysql::col $db friends {name type length}
717 {fname char 12} {lname char 20} {area char 5} {phone char 12}
718 % ::mysql::sel $db {select * from friends}
719 % ::mysql::col $db -current name type length
720 {fname lname area phone} {char char char char} {12 20 5 12}]
724 \fB::mysql::info\fR \fIhandle\fR \fIoption\fR
725 Return various database information depending on the \fIoption\fR.
726 The option must be one of the following keywords.
730 Return a String with information about last operation.
731 "Records: 3 Duplicates: 0 Warnings: 0" by INSERT or
732 "Rows matched: 40 Changed: 40 Warnings: 0" by UPDATE statements
733 (read the manual for mysql_info in MySQL C API documentation)
736 Return a list of all database names known to the server.
737 The handle must be connected.
740 Return the name of the database with which the handle is associated.
741 The handle must be in use.
744 Return the name of the database with which the handle is associated;
745 an empty string if the handle is connected, but not in use.
748 Return the name of the host to which the handle is connected.
749 The handle must be connected.
752 Return the name of the host to which the handle is connected; an empty
753 string if the handle is not valid.
756 Return a list of all table names in the database with which the handle
758 The handle must be in use.
761 Returns the version number of the server as a string.
763 \fBserverversionid\fR
764 Returns the version number of the server as an integer.
767 Returns a string containing the SQLSTATE error code for the last error.
768 The error code consists of five characters. '00000' means ``no error.''
769 The values are specified by ANSI SQL and ODBC.
770 Note that not all MySQL errors are yet mapped to SQLSTATE's.
771 The value 'HY000' (general error) is used for unmapped errors.
774 Returns a character string containing information similar to that provided by the mysqladmin status command.
775 This includes uptime in seconds and the number of running threads, questions, reloads, and open tables.
778 \fB::mysql::baseinfo\fR \fIoption\fR
779 return information information that do not need handle.
782 \fBconnectparameters\fR
783 return all supported connecting options
786 return the version of underlying MYSQL C-API library
789 \fB::mysql::ping\fR \fIhandle\fR
790 Checks whether the connection to the server is working. If it has gone down, an automatic reconnection is attempted.
792 This function can be used by clients that remain idle for a long while, to check whether the server has closed the connection and reconnect if necessary.
794 Return True if server is alive
796 \fB::mysql::changeuser\fR \fIuser\fR \fIpassword\fR ?\fIdatabase\fR?
797 Changes the user and causes the database specified by database to become the default (current) database on the connection specified by MySQL. In subsequent queries, this database is the default for table references that do not include an explicit database specifier.
799 ::mysql::changeuser fails unless the connected user can be authenticated or if he doesn't have permission to use the database. In this case the user and database are not changed
801 if database parameter may be set were is no default database.
803 Cause Error if operation is not succesed
805 \fB::mysql::result\fR \fIhandle\fR \fIoption\fR
806 Return information about the pending result.
807 Note that a result is pending until canceled by a ::mysql::exec command,
808 even if no rows remain to be read.
809 \fIOption\fR must be one of the following keywords.
813 Return the number of columns in the pending result.
814 There must be a pending result.
817 Return the number of columns in the pending result; an empty string if
818 no result is pending.
821 Return the current position in the pending result; a non-negative integer.
822 This value can be used as \fIrow-index\fR in the ::mysql::seek command.
823 An error is raised if there is no pending result.
826 As above, but returns an empty string if there is no pending result.
829 Return the number of rows that can be read sequentially from the
830 current position in the pending result.
831 There must be a pending result.
834 Return the number of rows that can be read sequentially from the
835 current position in the pending result; an empty string if no result
838 [::mysql::result $db current] + [::mysql::result $db rows]
839 always equals the total number of rows in the pending result.
842 \fB::mysql::state\fR \fIhandle\fR ?\fI-numeric\fR?
843 Return the state of a handle as a string or in numeric form.
844 There is no requirement on \fIhandle\fR; it may be any string.
845 The return value is one of the following strings, or the corresponding
846 numeric value if \fI-numeric\fR is specified.
847 The states form a progression where each state builds on the previous.
850 \fBNOT_A_HANDLE (0)\fR
851 The string supplied for \fIhandle\fR is not a mysqltcl handle at all.
853 \fBUNCONNECTED (1)\fR
854 The string supplied for \fIhandle\fR is one of the possible mysqltcl
855 handles, but it is not valid to any server.
858 The handle is connected to a server, but not associated with a database.
861 The handle is connected and associated with a database, but there is
864 \fBRESULT_PENDING (4)\fR
865 The handle is connected, associated with a database, and there is a
869 \fB::mysql::close\fR ?\fIhandle\fR?
870 Closes the server connection associated with \fIhandle\fR, causing it
871 to go back to the unconnected state.
872 Closes all connections if \fIhandle\fR is omitted.
873 Returns an empty string.
874 ::mysql::close raises a Tcl error if a handle is specified which is not
877 \fB::mysql::insertid\fR \fIhandle\fR
878 Returns the auto increment id of the last INSERT statement.
880 \fB::mysql::escape\fR ?\fIhandle\fR? \fIstring\fR
881 Returns the content of \fIstring\fR, with all special characters escaped,
882 so that it is suitable for use in an SQL statement. This is simpler (faster)
883 than using a general \fIregexp\fR or string map.
884 If handle is specified C-API function mysql_real_escape_string is used.
885 This is the recommended usage because in this case current character set is respected.
887 \fB::mysql::autocommit\fR \fIhandle\fR \fIboolean\fR
888 Sets autocommit mode on if mode is 1, off if mode is 0.
890 \fB::mysql::commit\fR \fIhandle\fR
891 Commits the current transaction.
893 \fB::mysql::rollback\fR \fIhandle\fR
894 Rollback the current transaction.
896 \fB::mysql::nextresult\fR \fIhandle\fR
897 If more query results exist, mysql::nextresult() reads the next query results and returns the status back to application.
898 returns -1 if no result or number of rows in the result set.
900 \fB::mysql::moreresult\fR \fIhandle\fR
901 Returns true if more results exist from the currently executed query, and the application must call mysql::result to fetch the results.
903 \fB::mysql::warningcount\fR \fIhandle\fR
904 Returns the number of warnings generated during execution of the previous SQL statement.
906 \fB::mysql::isnull\fR \fIvalue\fR
907 Null handling is a known problem with Tcl, especially with DB interaction.
908 The mysql "varchar" type has two valid blank values, NULL and an empty
909 string. This is where the problem arises; Tcl is not able to differentiate
910 between the two because of the way it handles strings.
911 Mysql has new internal Tcl type for null that string representation is stored
912 in global array mysqltcl(nullvalue) and as default empty string.
913 mysql::isnull can be used for safe check for null value.
914 Warning mysql::isnull works only reliable if there are no type conversation on
916 Consider row is always Tcl list even when there are only one column in the row.
919 set row [::mysql::next $handle]
920 if {[mysql::isnull [lindex $row 1]]} {
921 puts "2. column of $row is null"
923 if {[mysql::isnull $row]} {
924 puts "this does not work, because of type conversation list to string"
929 \fB::mysql::newnull\fR
930 create new null object. It can be used to simulate returned row contents.
932 \fB::mysql::setserveroption\fR \fIhandle\fR \fIoption\fR
933 there are only 2 options now: -multi_statment_on and -multi_statment_off
935 \fB::mysql::shutdown\fR \fIhandle\fR
936 Asks the database server to shut down. The connected user must have SHUTDOWN privileges.
938 \fB::mysql::encoding\fR \fIhandle\fR ?encoding?
939 Ask or change a encoding of connection.
940 There are special encoding "binary" for binary data transfers.
942 .SH "STATUS INFORMATION"
943 Mysqltcl creates and maintains a Tcl global array to provide status
945 Its name is \fImysqlstatus\fR.
947 Mysqlstatus elements:
950 A numeric conflict code set after every mysqltcl command.
951 Zero means no conflict; non-zero means some kind of conflict.
952 All conflicts also generate a Tcl error.
954 All MySQL server conflicts set mysqlstatus(code) to the numeric
955 code of the MySQL error.
957 Any other conflict sets mysqlstatus(code) to -1.
960 The last failing mysqltcl command.
961 Not updated for successful commands.
964 Message string for the last conflict detected.
965 The same string is returned as the result of the failing mysqltcl
967 Not updated for successful commands.
970 The string to use in query results to represent the SQL null value.
971 The empty string is used initially.
972 You may set it to another value.
974 .SH "Backward compatibility"
975 Up from version 3.0 all mysql commands are declared in ::mysql namespace.
976 All names for example mysqlconnect are also aviable but deprecated.
977 All old commands have the name pattern mysql{name} and the most of them are now mysql::{name}.
978 The exception is mysqlnext, which was renamed to mysql::fetch.
979 .SH "BUGS & POSSIBLE MISFEATURES"
980 Deleting any of the mysqltcl commands closes all connections.
987 Artur Trzewik (mail@xdobry.de) - active maintainer
989 MySQLTcl is derived from a patch of msql by Hakan Soderstrom, Soderstrom Programvaruverkstad,
990 S-12242 Enskede, Sweden.
991 msql is derived from Sybtcl by Tom Poindexter.
992 There are many contributors and bug reporter that are not mentioned.
993 If you have contributed to mysqltcl and wants to be on the list contact Artur Trzewik.