home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 January / Chip_2001-01_cd1.bin / tema / mysql / mysql-3.23.28g-win.exe / DATA1.CAB / Help_Files / Docs / manual.txt < prev    next >
Text File  |  2000-11-22  |  2MB  |  38,060 lines

  1. START-INFO-DIR-ENTRY
  2. * mysql: (mysql).               *MySQL* documentation.
  3. END-INFO-DIR-ENTRY
  4.  
  5. This is a manual for *MySQL*. This version is about the 3.23.22-beta
  6. version of *MySQL*. For a *3.20* version see the relevant distribution.
  7.  
  8. General Information about MySQL
  9. *******************************
  10.  
  11. This is the *MySQL* reference manual; it documents *MySQL* version
  12. 3.23.22-beta. As *MySQL* is work in progress, the manual gets updated
  13. frequently. So there is a very good chance that this version is out of
  14. date, unless you are looking at it on-line. The most recent version of
  15. this manual is available at `http://www.mysql.com/documentation/' in
  16. many different formats. If you have a hard time finding the information
  17. in the manual, you can try its searchable PHP version at
  18. `http://www.mysql.com/documentation/manual.php' .
  19.  
  20. *MySQL* is a very fast, multi-threaded, multi-user and robust SQL
  21. (Structured Query Language) database server.
  22.  
  23. *MySQL* is free software. It is licensed with the *GNU GENERAL PUBLIC
  24. LICENSE* `http://www.gnu.org/'. *Note Licensing and Support::.
  25.  
  26. The *MySQL* home page (http://www.mysql.com/) provides the latest
  27. information about *MySQL*.
  28.  
  29. The following list describes some useful sections of the manual:
  30.  
  31.    * For a discussion of *MySQL*'s capabilities, see *Note Features::.
  32.  
  33.    * For installation instructions, see *Note Installing::. For tips on
  34.      porting *MySQL* to new machines or operating systems, see *Note
  35.      Porting::.
  36.  
  37.    * For information about upgrading from a 3.21 release, see *Note
  38.      Upgrading-from-3.21::.
  39.  
  40.    * For a tutorial introduction to *MySQL*, see *Note Tutorial::.
  41.  
  42.    * For examples of SQL and benchmarking information, see the
  43.      benchmarking directory (`sql-bench' in the distribution).
  44.  
  45.    * For a history of new features and bug fixes, see *Note News::.
  46.  
  47.    * For a list of currently known bugs and misfeatures, see *Note
  48.      Bugs::.
  49.  
  50.    * For future plans, see *Note TODO::.
  51.  
  52.    * For a list of all the contributors to this project, see *Note
  53.      Credits::.
  54.  
  55. *IMPORTANT:*
  56.  
  57. Reports of errors (often called bugs), as well as questions and comments
  58. should be sent to the mailing list at <mysql@lists.mysql.com>.  *Note
  59. Bug reports::.  The `mysqlbug' script should be used to generate bug
  60. reports.  For source distributions, the `mysqlbug' script can be found
  61. in the `scripts' directory.  For binary distributions, `mysqlbug' can
  62. be found in the `bin' directory.
  63.  
  64. If you have any suggestions concerning additions or corrections to this
  65. manual, please send them to the manual team at (<docs@mysql.com>).
  66.  
  67. What is MySQL
  68. =============
  69.  
  70. *MySQL* is a database management system.
  71.      A database is a structured collection of data. It may be anything
  72.      from a simple shopping list to a picture gallery or the vast
  73.      amounts of information in a corporate network. To add, access and
  74.      process data stored in a computer database, you need a database
  75.      management system such as *MySQL*. Since computers are very good
  76.      at handling large amounts of data, database management plays a
  77.      central role in computing, as stand-alone utilities or as parts of
  78.      other applications.
  79.  
  80. *MySQL* is a relational database management system.
  81.      A relational database stores data in separate tables rather than
  82.      putting all the data in one big storeroom. This adds speed and
  83.      flexibility. The tables are linked by defined relations making it
  84.      possible to combine data from several tables on request. The SQL
  85.      part of *MySQL* stands for "Structured Query Language" - the most
  86.      common standardized language used to access databases.
  87.  
  88. *MySQL* is Open Source Software
  89.      Open source means that it┤s possible to use and modify for anyone.
  90.      Anybody can download *MySQL* from the Internet and use it without
  91.      paying anything. Anybody so inclined can study the source code and
  92.      change it to fit their needs. *MySQL* uses the GPL (GNU General
  93.      Public License) `http://www.gnu.org', to define what You may and
  94.      may not do with the software in different situations. If you feel
  95.      uncomfortable with the GPL or need to embed *MySQL* into a
  96.      commercial application you can buy a commercially licensed version
  97.      from us.
  98.  
  99. Why use *MySQL*?
  100.      *MySQL* is very fast, reliable and easy to use. If that┤s what
  101.      You┤re looking for you should give it a try. *MySQL* also has a
  102.      very practical set of features developed in very close cooperation
  103.      with our users. You can find a performance comparison of *MySQL*
  104.      to some other database managers on our benchmark page. *Note
  105.      Benchmarks::.
  106.  
  107.      *MySQL* was originally developed to handle very large databases
  108.      much faster than existing solutions and has been successfully used
  109.      in highly demanding production environments for several years.
  110.      Though under constant development, *MySQL* today offers a rich and
  111.      very useful set of functions. The connectivity, speed and security
  112.      makes *MySQL* highly suited for accessing databases on the
  113.      Internet.
  114.  
  115. The technical features of *MySQL*
  116.      For advanced technical information, *Note Reference::.  *MySQL* is
  117.      a client/server system that consists of an multi-threaded SQL
  118.      server that supports different backends, several different client
  119.      programs and libraries, administrative tools and a programming
  120.      interface.
  121.  
  122. *MySQL* has a lot of contributed software available.
  123.      This makes it much more likely that you will find that your
  124.      favorite application/language already supports *MySQL*.
  125.  
  126. The official way to pronounce *MySQL* is "My Ess Que Ell" (not
  127. MY-SEQUEL). But we try to avoid correcting people who say MY-SEQUEL
  128.  
  129. *MySQL* core values
  130.  
  131. We want *MySQL* to be
  132.  
  133.    * The best and the most used database in the world
  134.  
  135.    * Available to all and affordable for all
  136.  
  137.    * Easy to use
  138.  
  139.    * Continuously improved while remaining fast and safe
  140.  
  141.    * Fun to use and fun to improve
  142.  
  143.    * Free from bugs
  144.  
  145. *MySQL AB* and the people of *MySQL AB*
  146.  
  147.    * Promote Open Source Philosophy and support the Open Source
  148.      Community
  149.  
  150.    * Aims to be good citizens
  151.  
  152.    * Prefer partners that share our values and mind-set
  153.  
  154.    * Answer mail and give support
  155.  
  156.    * Is a virtual company networking with others
  157.  
  158.    * Work against software patents
  159.  
  160. About this manual
  161. =================
  162.  
  163. This manual is currently available in Texinfo, plain text, Info, HTML,
  164. PostScript and PDF versions.  Because of their size, PostScript and PDF
  165. versions are not included with the main *MySQL* distribution, but are
  166. available for separate download at `http://www.mysql.com/'.
  167.  
  168. The primary document is the Texinfo file. The HTML version is produced
  169. automatically using a modified version of `texi2html'. The plain text
  170. and Info versions are produced with `makeinfo'. The Postscript version
  171. is produced using `texi2dvi' and `dvips'. The PDF version is produced
  172. with `pdftex'.
  173.  
  174. This manual is written and maintained by David Axmark, Michael (Monty)
  175. Widenius and Paul DuBois. For other contributors, see *Note Credits::.
  176.  
  177. Conventions used in this manual
  178. -------------------------------
  179.  
  180. This manual uses certain typographical conventions:
  181.  
  182. `constant'
  183.      Constant-width font is used for command names and options; SQL
  184.      statements; database, table and column names; C and Perl code; and
  185.      environment variables.  Example: "To see how `mysqladmin' works,
  186.      invoke it with the `--help' option."
  187.  
  188. `filename'
  189.      Constant-width font with surrounding quotes is used for filenames
  190.      and pathnames.  Example: "The distribution is installed under the
  191.      `/usr/local/' directory."
  192.  
  193. `c'
  194.      Constant-width font with surrounding quotes is also used to
  195.      indicate character sequences.  Example: "To specify a wildcard,
  196.      use the `%' character."
  197.  
  198. _italic_
  199.      Italic font is used for emphasis, _like this_.
  200.  
  201. *boldface*
  202.      Boldface font is used for access privilege names (e.g., "do not
  203.      grant the *process* privilege lightly") and occasionally to convey
  204.      *especially strong emphasis*.
  205.  
  206. When commands are shown that are meant to be executed by a particular
  207. program, the program is indicated by the prompt shown with the command.
  208. For example, `shell>' indicates a command that you execute from your
  209. login shell, and `mysql>' indicates a command that you execute from the
  210. `mysql' client program:
  211.  
  212.      shell> type a shell command here
  213.      mysql> type a mysql command here
  214.  
  215. Shell commands are shown using Bourne shell syntax.  If you are using a
  216. `csh'-style shell, you may need to issue commands slightly differently.
  217. For example, the sequence to set an environment variable and run a
  218. command looks like this in Bourne shell syntax:
  219.  
  220.      shell> VARNAME=value some_command
  221.  
  222. For `csh', you would execute the sequence like this:
  223.  
  224.      shell> setenv VARNAME value
  225.      shell> some_command
  226.  
  227. Database, table and column names often must be substituted into
  228. commands.  To indicate that such substitution is necessary, this manual
  229. uses `db_name', `tbl_name' and `col_name'.  For example, you might see
  230. a statement like this:
  231.  
  232.      mysql> SELECT col_name FROM db_name.tbl_name;
  233.  
  234. This means that if you were to enter a similar statement, you would
  235. supply your own database, table and column names, perhaps like this:
  236.  
  237.      mysql> SELECT author_name FROM biblio_db.author_list;
  238.  
  239. SQL statements may be written in uppercase or lowercase.  When this
  240. manual shows a SQL statement, uppercase is used for particular keywords
  241. if those keywords are under discussion (to emphasize them) and
  242. lowercase is used for the rest of the statement.  For example, you
  243. might see the following in a discussion of the `SELECT' statement:
  244.  
  245.      mysql> SELECT count(*) FROM tbl_name;
  246.  
  247. On the other hand, in a discussion of the `COUNT()' function, the same
  248. statement would be written like this:
  249.  
  250.      mysql> select COUNT(*) from tbl_name;
  251.  
  252. If no particular emphasis is intended, all keywords are written
  253. uniformly in uppercase.
  254.  
  255. In syntax descriptions, square brackets (`[' and `]') are used to
  256. indicate optional words or clauses:
  257.  
  258.      DROP TABLE [IF EXISTS] tbl_name
  259.  
  260. When a syntax element consists of a number of alternatives, the
  261. alternatives are separated by vertical bars (`|').  When one member
  262. from a set of choices may be chosen, the alternatives are listed within
  263. square brackets (`[' and `]'):
  264.  
  265.      TRIM([[BOTH | LEADING | TRAILING] [remstr] FROM] str)
  266.  
  267. When one member from a set of choices must be chosen, the alternatives
  268. are listed within braces (`{' and `}'):
  269.  
  270.      {DESCRIBE | DESC} tbl_name {col_name | wild}
  271.  
  272. History of MySQL
  273. ================
  274.  
  275. We once started out with the intention of using `mSQL' to connect to our
  276. tables using our own fast low-level (ISAM) routines. However, after some
  277. testing we came to the conclusion that `mSQL' was not fast enough or
  278. flexible enough for our needs. This resulted in a new SQL interface to
  279. our database but with almost the same API interface as `mSQL'. This API
  280. was chosen to ease porting of third-party code.
  281.  
  282. The derivation of the name *MySQL* is not perfectly clear.  Our base
  283. directory and a large number of our libraries and tools have had the
  284. prefix "my" for well over 10 years. However, Monty's daughter (some
  285. years younger) is also named My. So which of the two gave its name to
  286. *MySQL* is still a mystery, even for us.
  287.  
  288. Books about MySQL
  289. =================
  290.  
  291. While this manual is still the right place for up to date techical
  292. information, its primary goal is to contain everything there is to know
  293. about *MySQL*. And it is sometimes nice to have a bound book to read in
  294. bed or while you travel. Here is a list of books about *MySQL* (in
  295. English).
  296.  
  297. Title                  MySQL
  298.                        (http://www2.newriders.com/cfm/prod_book.cfm?RecordID=584)
  299. Publisher              New Riders
  300. Author                 Paul DuBois
  301. Pub Date               1st Edition December 1999
  302. ISBN                   0735709211
  303. Pages                  800
  304. Price                  $49.99 US
  305. Downloadable examples  `samp_db.tar.gz'
  306.                        (http://www.mysql.com/Contrib/Examples/samp_db.tar.gz)
  307. Errata                 are available here
  308.                        (http://www.mysql.com/documentation/pauls-mysql-book-errata.html)
  309. Foreword by Michael "Monty" Widenius, *MySQL* Moderator
  310.  
  311. In *MySQL*, Paul DuBois provides you with a comprehensive guide to one
  312. of the most popular relational database systems. Paul has contributed
  313. to the online documentation for *MySQL*, and is an active member of the
  314. *MySQL* community. The principal *MySQL* developer, Monty Widenius, and
  315. a network of his fellow developers reviewed the manuscript, providing
  316. Paul with the kind of insight no one else could supply.
  317.  
  318. Instead of merely giving you a general overview of *MySQL*, Paul
  319. teaches you how to make the most of its capabilities. Through two
  320. sample database applications that run throughout the book, he gives you
  321. solutions to problems you're sure to face. He helps you integrate
  322. *MySQL* efficiently with third-party tools, such as PHP and Perl,
  323. enabling you to generate dynamic Web pages through database queries. He
  324. teaches you to write programs that access *MySQL* databases, and also
  325. provides a comprehensive set of references to column types, operators,
  326. functions, SQL syntax, *MySQL* programming, C API, Perl `DBI', and PHP
  327. API.  *MySQL* simply gives you the kind of information you won't find
  328. anywhere else.
  329.  
  330. If you use *MySQL*, this book provides you with:
  331.    * An introduction to *MySQL* and SQL
  332.  
  333.    * Coverage of *MySQL*'s data types and how to use them
  334.  
  335.    * Thorough treatment of how to write client programs in C
  336.  
  337.    * A guide to using the Perl `DBI' and PHP APIs for developing
  338.      command-line and Web-based applications
  339.  
  340.    * Tips on administrative issues such as user accounts, backup, crash
  341.      recovery, and security
  342.  
  343.    * Help in choosing an ISP for *MySQL* access
  344.  
  345.    * A comprehensive reference for *MySQL*'s data types, operators,
  346.      functions, and SQL statements and utilities
  347.  
  348.    * Complete reference guides for *MySQL*'s C API, the Perl `DBI' API,
  349.      and PHP's *MySQL*-related functions
  350.  
  351. Title                  MySQL & mSQL
  352.                        (http://www.oreilly.com/catalog/msql/noframes.html)
  353. Publisher              O'Reilly
  354. Authors                Randy Jay Yarger, George Reese & Tim King
  355. Pub Date               1st Edition July 1999
  356. ISBN                   1-56592-434-7, Order Number: 4347
  357. Pages                  506
  358. Price                  $34.95
  359.  
  360. This book teaches you how to use *MySQL* and `mSQL', two popular and
  361. robust database products that support key subsets of SQL on both Linux
  362. and UNIX systems. Anyone who knows basic C, Java, Perl, or Python can
  363. write a program to interact with a database, either as a stand-alone
  364. application or through a Web page. This book takes you through the
  365. whole process, from installation and configuration to programming
  366. interfaces and basic administration.  Includes ample tutorial material.
  367.  
  368. Title                  Sams Teach Yourself MySQL in 21 Days
  369.                        (http://shop.barnesandnoble.com/bookSearch/isbnInquiry.asp?isbn=0672319144)
  370. Publisher              Sams
  371. Authors                Mark Maslakowski and Tony Butcher
  372. Pub Date               June 2000
  373. ISBN                   0672319144
  374. Pages                  N/A
  375. Price                  $39.99
  376.  
  377. Sams Teach Yourself *MySQL* in 21 Days is for intermediate Linux users
  378. who want to move into databases.  A large share of the audience to be
  379. web developers needing a database to store large amounts of information
  380. that can be retrieved via the Web. Sams Teach Yourself *MySQL* in 21
  381. Days is a practical, step-by-step tutorial.  The reader will learn to
  382. design and employ this open source database technology into his/her web
  383. site using practical, hands-on examples to follow.
  384.  
  385. Title                  E-Commerce Solutions with MySQL
  386.                        (http://shop.barnesandnoble.com/bookSearch/isbnInquiry.asp?isbn=0761524452)
  387. Publisher              Prima
  388. Authors                N/A
  389. Pub Date               September 2000
  390. ISBN                   0761524452
  391. Pages                  500
  392. Price                  $39.99
  393.  
  394. No description available.
  395.  
  396. Title                  Professional MySQL Programming
  397.                        (http://shop.barnesandnoble.com/bookSearch/isbnInquiry.asp?isbn=1861004281)
  398. Publisher              Wrox
  399. Authors                N/A
  400. Pub Date               July 2000
  401. ISBN                   1861004281
  402. Pages                  1000
  403. Price                  $49.99
  404.  
  405. No description available.
  406.  
  407. Title                  PHP3 and MySQL Web Development
  408.                        (http://shop.barnesandnoble.com/bookSearch/isbnInquiry.asp?isbn=0672317842)
  409. Publisher              N/A
  410. Authors                William Jason Gilmore
  411. Pub Date               October 2000
  412. ISBN                   672317842
  413. Pages                  N/A
  414. Price                  $39.99
  415.  
  416. No description available.
  417.  
  418. The main features of MySQL
  419. ==========================
  420.  
  421. The following list describes some of the important characteristics of
  422. *MySQL*:
  423.  
  424.    * Fully multi-threaded using kernel threads. That means it easily can
  425.      use multiple CPUs if available.
  426.  
  427.    * C, C++, Eiffel, Java, Perl, PHP, Python and Tcl APIs. *Note
  428.      Clients::.
  429.  
  430.    * Works on many different platforms. *Note Which OS::.
  431.  
  432.    * Many column types: signed/unsigned integers 1, 2, 3, 4 and 8 bytes
  433.      long, `FLOAT', `DOUBLE', `CHAR', `VARCHAR', `TEXT', `BLOB',
  434.      `DATE', `TIME', `DATETIME', `TIMESTAMP', `YEAR', `SET' and `ENUM'
  435.      types. *Note Column types::.
  436.  
  437.    * Very fast joins using an optimized one-sweep multi-join.
  438.  
  439.    * Full operator and function support in the `SELECT' and `WHERE'
  440.      parts of queries. Example:
  441.           mysql> SELECT CONCAT(first_name, " ", last_name) FROM tbl_name
  442.                      WHERE income/dependents > 10000 AND age > 30;
  443.  
  444.    * SQL functions are implemented through a highly-optimized class
  445.      library and should be as fast as they can get! Usually there
  446.      shouldn't be any memory allocation at all after query
  447.      initialization.
  448.  
  449.    * Full support for SQL `GROUP BY' and `ORDER BY' clauses. Support
  450.      for group functions (`COUNT()', `COUNT(DISTINCT)', `AVG()',
  451.      `STD()', `SUM()', `MAX()' and `MIN()').
  452.  
  453.    * Support for `LEFT OUTER JOIN' with ANSI SQL and ODBC syntax.
  454.  
  455.    * You can mix tables from different databases in the same query (as
  456.      of version 3.22).
  457.  
  458.    * A privilege and password system which is very flexible and secure,
  459.      and which allows host-based verification.  Passwords are secure
  460.      because all password traffic when connecting to a server is
  461.      encrypted.
  462.  
  463.    * ODBC (Open-DataBase-Connectivity) support for Windows95 (with
  464.      source). All ODBC 2.5 functions and many others.  For example, you
  465.      can use Access to connect to your *MySQL* server. *Note ODBC::.
  466.  
  467.    * Very fast B-tree disk tables with index compression.
  468.  
  469.    * 16 indexes per table are allowed. Each index may consist of 1 to
  470.      16 columns or parts of columns. The maximum index length is 256
  471.      bytes (this may be changed when compiling *MySQL*). An index may
  472.      use a prefix of a `CHAR' or `VARCHAR' field.
  473.  
  474.    * Fixed-length and variable-length records.
  475.  
  476.    * In-memory hash tables which are used as temporary tables.
  477.  
  478.    * Handles large databases.  We are using *MySQL* with some databases
  479.      that contain 50,000,000 records.
  480.  
  481.    * All columns have default values.  You can use `INSERT' to insert a
  482.      subset of a table's columns; those columns that are not explicitly
  483.      given values are set to their default values.
  484.  
  485.    * Uses GNU Automake, Autoconf, and `libtool' for portability.
  486.  
  487.    * Written in C and C++. Tested with a broad range of different
  488.      compilers.
  489.  
  490.    * A very fast thread-based memory allocation system.
  491.  
  492.    * No memory leaks. Tested with a commercial memory leakage detector
  493.      (`purify').
  494.  
  495.    * Includes `myisamchk', a very fast utility for table checking,
  496.      optimization and repair.  *Note Maintenance::.
  497.  
  498.    * Full support for several different character sets, including
  499.      ISO-8859-1 (Latin1), big5, ujis, and more. For example, the
  500.      Scandinavian characters `a*', `a"' and `o"' are allowed in table
  501.      and column names.
  502.  
  503.    * All data are saved in the chosen character set. All comparisons
  504.      for normal string columns are case insensitive.
  505.  
  506.    * Sorting is done according to the chosen character set (the Swedish
  507.      way by default). It is possible to change this when the *MySQL*
  508.      server is started up.  To see an example of very advanced sorting,
  509.      look at the Czech sorting code. *MySQL* supports many different
  510.      character sets that can be specified at compile and run time.
  511.  
  512.    * Aliases on tables and columns are allowed as in the SQL92 standard.
  513.  
  514.    * `DELETE', `INSERT', `REPLACE', and `UPDATE' return how many rows
  515.      were changed (affected). It is possible to return the number of
  516.      rows matched instead by setting a flag when connecting to the
  517.      server.
  518.  
  519.    * Function names do not clash with table or column names. For
  520.      example, `ABS' is a valid column name. The only restriction is
  521.      that for a function call, no spaces are allowed between the
  522.      function name and the `(' that follows it.  *Note Reserved words::.
  523.  
  524.    * All *MySQL* programs can be invoked with the `--help' or `-?'
  525.      options to obtain online assistance.
  526.  
  527.    * The server can provide error messages to clients in many
  528.      languages. *Note Languages::.
  529.  
  530.    * Clients may connect to the *MySQL* server using TCP/IP connections
  531.      or Unix sockets, or named pipes under NT.
  532.  
  533.    * The *MySQL*-specific `SHOW' command can be used to retrieve
  534.      information about databases, tables and indexes. The `EXPLAIN'
  535.      command can be used to determine how the optimizer resolves a
  536.      query.
  537.  
  538. How stable is MySQL?
  539. ====================
  540.  
  541. This section addresses the questions, "How stable is *MySQL*?" and,
  542. "Can I depend on *MySQL* in this project?"  Here we will try to clarify
  543. some issues and to answer some of the more important questions that
  544. seem to concern many people.  This section has been put together from
  545. information gathered from the mailing list (which is very active in
  546. reporting bugs).
  547.  
  548. At TcX, *MySQL* has worked without any problems in our projects since
  549. mid-1996. When *MySQL* was released to a wider public, we noticed that
  550. there were some pieces of "untested code" that were quickly found by the
  551. new users who made queries in a manner different than our own.  Each new
  552. release has had fewer portability problems than the previous one (even
  553. though each has had many new features), and we hope that it will be
  554. possible to label one of the next releases "stable".
  555.  
  556. Each release of *MySQL* has been usable and there have been problems
  557. only when users start to use code from "the gray zones". Naturally,
  558. outside users can't know what the gray zones are; this section attempts
  559. to indicate those that are currently known.  The descriptions deal with
  560. the 3.22.x version of *MySQL*. All known and reported bugs are fixed in
  561. the latest version, with the exception of the bugs listed in the bugs
  562. section, which are things that are "design"-related.  *Note Bugs::.
  563.  
  564. *MySQL* is written in multiple layers and different independent
  565. modules.  These modules are listed below with an indication of how
  566. well-tested each of them is:
  567.  
  568. *The ISAM table handler -- Stable*
  569.      This manages storage and retrieval of all data in *MySQL* 3.22 and
  570.      earlier versions. In all *MySQL* releases there hasn't been a
  571.      single (reported) bug in this code. The only known way to get a
  572.      corrupted table is to kill the server in the middle of an update.
  573.      Even that is unlikely to destroy any data beyond rescue, because
  574.      all data are flushed to disk between each query.  There hasn't
  575.      been a single bug report about lost data because of bugs in
  576.      *MySQL*, either.
  577.  
  578. *The MyISAM table handler -- Beta*
  579.      This is new in *MySQL* 3.23. It's largely based on the ISAM table
  580.      code but has a lot of new very useful features.
  581.  
  582. *The parser and lexical analyser -- Stable*
  583.      There hasn't been a single reported bug in this system for a long
  584.      time.
  585.  
  586. *The C client code -- Stable*
  587.      No known problems. In early 3.20 releases, there were some
  588.      limitations in the send/receive buffer size. As of 3.21.x, the
  589.      buffer size is now dynamic up to a default of 24M.
  590.  
  591. *Standard client programs -- Stable*
  592.      These include `mysql', `mysqladmin' and `mysqlshow', `mysqldump',
  593.      and `mysqlimport'.
  594.  
  595. *Basic SQL -- Stable*
  596.      The basic SQL function system and string classes and dynamic memory
  597.      handling. Not a single reported bug in this system.
  598.  
  599. *Query optimizer -- Stable*
  600.  
  601. *Range optimizer -- Gamma*
  602.  
  603. *Join optimizer -- Stable*
  604.  
  605. *Locking -- Gamma*
  606.      This is very system-dependent. On some systems there are big
  607.      problems using standard OS locking (`fcntl()').  In these cases,
  608.      you should run the *MySQL* daemon with the `--skip-locking' flag.
  609.      Problems are known to occur on some Linux systems and on SunOS
  610.      when using NFS-mounted file systems.
  611.  
  612. *Linux threads -- Gamma*
  613.      The major problem found has been with the `fcntl()' call, which is
  614.      fixed by using the `--skip-locking' option to `mysqld'. Some
  615.      people have reported lockup problems with the 0.5 release.
  616.      LinuxThreads will need to be recompiled if you plan to use 1000+
  617.      concurrent connections. Although it is possible to run that many
  618.      connections with the default LinuxThreads ( however, you will
  619.      never go above 1021 ), the default stack spacing of 2 MB makes the
  620.      application unstable, and we have been able to reproduce a
  621.      coredump after creating 1021 idle connections. See Linux Notes for
  622.      more details.
  623.  
  624. *Solaris 2.5+ pthreads -- Stable*
  625.      We use this for all our production work.
  626.  
  627. *MIT-pthreads (Other systems) -- Gamma*
  628.      There have been no reported bugs since 3.20.15 and no known bugs
  629.      since 3.20.16. On some systems, there is a "misfeature" where some
  630.      operations are quite slow (a 1/20 second sleep is done between
  631.      each query). Of course, MIT-pthreads may slow down everything a
  632.      bit, but index-based `SELECT' statements are usually done in one
  633.      time frame so there shouldn't be a mutex locking/thread juggling.
  634.  
  635. *Other thread implementions -- Alpha - Beta*
  636.      The ports to other systems are still very new and may have bugs,
  637.      possibly in *MySQL*, but most often in the thread implementation
  638.      itself.
  639.  
  640. *`LOAD DATA ...', `INSERT ... SELECT' -- Stable*
  641.      Some people have thought they have found bugs here, but these
  642.      usually have turned out to be misunderstandings. Please check the
  643.      manual before reporting problems!
  644.  
  645. *`ALTER TABLE' -- Stable*
  646.      Small changes in 3.22.12.
  647.  
  648. *DBD -- Stable*
  649.      Now maintained by Jochen Wiedmann <wiedmann@neckar-alb.de>. Thanks!
  650.  
  651. *`mysqlaccess' -- Stable*
  652.      Written and maintained by Yves Carlier <Yves.Carlier@rug.ac.be>.
  653.      Thanks!
  654.  
  655. *`GRANT' -- Gamma*
  656.      Big changes made in *MySQL* 3.22.12.
  657.  
  658. **MyODBC* (uses ODBC SDK 2.5) -- Gamma*
  659.      It seems to work well with some programs.
  660.  
  661. MySQL AB provides email support for paying customers, but the *MySQL*
  662. mailing list usually provides answers to common questions. Bugs are
  663. usually fixed right away with a patch; for serious bugs, there is almost
  664. always a new release.
  665.  
  666. Year 2000 compliance
  667. ====================
  668.  
  669. *MySQL* itself has no problems with Year 2000 (Y2K) compliance:
  670.  
  671.    * *MySQL* uses Unix time functions and has no problems with dates
  672.      until `2069'; all 2-digit years are regarded to be in the range
  673.      `1970' to `2069', which means that if you store `01' in a `year'
  674.      column, *MySQL* treats it as `2001'.
  675.  
  676.    * All *MySQL* date functions are stored in one file `sql/time.cc'
  677.      and coded very carefully to be year 2000-safe.
  678.  
  679.    * In *MySQL* 3.22 and later versions, the new `YEAR' column type can
  680.      store years `0' and `1901' to `2155' in 1 byte and display them
  681.      using 2 or 4 digits.
  682.  
  683. You may run into problems with applications that use *MySQL* in a way
  684. that is not Y2K-safe.  For example, many old applications store or
  685. manipulate years using 2-digit values (which are ambiguous) rather than
  686. 4-digit values.  This problem may be compounded by applications that use
  687. values such as `00' or `99' as "missing" value indicators.
  688.  
  689. Unfortunately, these problems may be difficult to fix, because different
  690. applications may be written by different programmers, each of whom may
  691. use a different set of conventions and date-handling functions.
  692.  
  693. Here is a simple demonstration illustrating that *MySQL* doesn't have
  694. any problems with dates until the year 2030!
  695.  
  696.      mysql> DROP TABLE IF EXISTS y2k;
  697.      mysql> CREATE TABLE y2k (date date, date_time datetime, time_stamp timestamp);
  698.      mysql> INSERT INTO y2k VALUES ("1998-12-31","1998-12-31 23:59:59",19981231235959);
  699.      mysql> INSERT INTO y2k VALUES ("1999-01-01","1999-01-01 00:00:00",19990101000000);
  700.      mysql> INSERT INTO y2k VALUES ("1999-09-09","1999-09-09 23:59:59",19990909235959);
  701.      mysql> INSERT INTO y2k VALUES ("2000-01-01","2000-01-01 00:00:00",20000101000000);
  702.      mysql> INSERT INTO y2k VALUES ("2000-02-28","2000-02-28 00:00:00",20000228000000);
  703.      mysql> INSERT INTO y2k VALUES ("2000-02-29","2000-02-29 00:00:00",20000229000000);
  704.      mysql> INSERT INTO y2k VALUES ("2000-03-01","2000-03-01 00:00:00",20000301000000);
  705.      mysql> INSERT INTO y2k VALUES ("2000-12-31","2000-12-31 23:59:59",20001231235959);
  706.      mysql> INSERT INTO y2k VALUES ("2001-01-01","2001-01-01 00:00:00",20010101000000);
  707.      mysql> INSERT INTO y2k VALUES ("2004-12-31","2004-12-31 23:59:59",20041231235959);
  708.      mysql> INSERT INTO y2k VALUES ("2005-01-01","2005-01-01 00:00:00",20050101000000);
  709.      mysql> INSERT INTO y2k VALUES ("2030-01-01","2030-01-01 00:00:00",20300101000000);
  710.      mysql> INSERT INTO y2k VALUES ("2050-01-01","2050-01-01 00:00:00",20500101000000);
  711.      mysql> SELECT * FROM y2k;
  712.      +------------+---------------------+----------------+
  713.      | date       | date_time           | time_stamp     |
  714.      +------------+---------------------+----------------+
  715.      | 1998-12-31 | 1998-12-31 23:59:59 | 19981231235959 |
  716.      | 1999-01-01 | 1999-01-01 00:00:00 | 19990101000000 |
  717.      | 1999-09-09 | 1999-09-09 23:59:59 | 19990909235959 |
  718.      | 2000-01-01 | 2000-01-01 00:00:00 | 20000101000000 |
  719.      | 2000-02-28 | 2000-02-28 00:00:00 | 20000228000000 |
  720.      | 2000-02-29 | 2000-02-29 00:00:00 | 20000229000000 |
  721.      | 2000-03-01 | 2000-03-01 00:00:00 | 20000301000000 |
  722.      | 2000-12-31 | 2000-12-31 23:59:59 | 20001231235959 |
  723.      | 2001-01-01 | 2001-01-01 00:00:00 | 20010101000000 |
  724.      | 2004-12-31 | 2004-12-31 23:59:59 | 20041231235959 |
  725.      | 2005-01-01 | 2005-01-01 00:00:00 | 20050101000000 |
  726.      | 2030-01-01 | 2030-01-01 00:00:00 | 20300101000000 |
  727.      | 2050-01-01 | 2050-01-01 00:00:00 | 00000000000000 |
  728.      +------------+---------------------+----------------+
  729.      
  730.      13 rows in set (0.00 sec)
  731.  
  732. This shows that the `DATE' and `DATETIME' types are will not give any
  733. problems with future dates (they handle dates until the year 9999).
  734.  
  735. The `TIMESTAMP' type, that is used to store the current time, has a
  736. range up to only `2030-01-01'. `TIMESTAMP' has a range of `1970' to
  737. `2030' on 32-bit machines (signed value). On 64-bit machines it handles
  738. times up to `2106' (unsigned value).
  739.  
  740. Even though *MySQL* is Y2K-compliant, it is your responsibility to
  741. provide unambiguous input.  See *Note Y2K issues:: for *MySQL*'s rules
  742. for dealing with ambiguous date input data (data containing 2-digit year
  743. values).
  744.  
  745. General SQL information and tutorials
  746. =====================================
  747.  
  748. This book has been recommended by a several people on the *MySQL*
  749. mailing list:
  750.  
  751.      Judith S. Bowman, Sandra L. Emerson and Marcy Darnovsky
  752.      The Practical SQL Handbook: Using Structured Query Language
  753.      Second Edition
  754.      Addison-Wesley
  755.      ISBN 0-201-62623-3
  756.      http://www.awl.com
  757.  
  758. This book has also received some recommendations by *MySQL* users:
  759.  
  760.      Martin Gruber
  761.      Understanding SQL
  762.      ISBN 0-89588-644-8
  763.      Publisher Sybex 510 523 8233
  764.      Alameda, CA USA
  765.  
  766. A SQL tutorial is available on the net at
  767. http://www.geocities.com/SiliconValley/Vista/2207/sql1.html
  768.  
  769. SQL in 21 Tagen (online book in German language):
  770. http://www.mut.de/leseecke/buecher/sql/inhalt.htm
  771.  
  772. Useful MySQL-related links
  773. ==========================
  774.  
  775. Apart from the following links, you can find and download a lot of
  776. *MySQL* programs, tools and APIs from the Contrib directory
  777. (http://www.mysql.com/Contrib/).
  778.  
  779. Tutorials
  780. ---------
  781.  
  782.    * A beginner's tutorial of how to start using *MySQL*
  783.      (http://www.devshed.com/resource/advanced/mysql/index.html)
  784.  
  785.    * `http://www.analysisandsolutions.com/code/mybasic.htm' Beginners
  786.      *MySQL* Tutorial on how to install and set up *MySQL* on a Windows
  787.      machine.
  788.  
  789.    * A lot of *MySQL* tutorials
  790.      (http://www.devshed.com/Server_Side/MySQL/)
  791.  
  792.    * Setting Up a *MySQL*-Based Website
  793.      (http://www.linuxplanet.com/linuxplanet/tutorials/1046/1/)
  794.  
  795.    * *MySQL*-Perl tutorial
  796.      (http://www.hotwired.com/webmonkey/backend/tutorials/tutorial1.html)
  797.  
  798.    * Installing new Perl modules that require locally installed modules
  799.      (http://www.iserver.com/support/contrib/perl5/modules.html)
  800.  
  801.    * PHP/*MySQL* Tutorial
  802.      (http://www.hotwired.com/webmonkey/databases/tutorials/tutorial4.html)
  803.  
  804.    * Hands on tutorial for *MySQL* (http://www.useractive.com/)
  805.  
  806. Porting MySQL / Using MySQL on different systems
  807. ------------------------------------------------
  808.  
  809.    * The MacOS Xclave (http://xclave.macnn.com/MySQL/).  Running
  810.      *MySQL* on MacOSX
  811.  
  812.    * MySql for MacOSX Server (http://www.prnet.de/RegEx/mysql.html)
  813.  
  814.    * Client libraries for the Macintosh (http://www.lilback.com/macsql/)
  815.  
  816. Perl related links
  817. ------------------
  818.  
  819.    * Perl DBI with *MySQL* FAQ (http://haven.e-cactus.com/dbi_mysql)
  820.  
  821. MySQL discussion forums
  822. -----------------------
  823.  
  824.    * Examples using *MySQL*; (check Top 20) (http://www.weberdev.com/)
  825.  
  826.    * FutureForum Web Discussion Software
  827.      (http://futurerealm.com/forum/futureforum.htm)
  828.  
  829. Commercial applications that support MySQL
  830. ------------------------------------------
  831.  
  832.    * SupportWizard; Interactive helpdesk on the web (This product
  833.      includes a licensed copy of *MySQL*)
  834.      (http://www.supportwizard.com/)
  835.  
  836.    * StWeb (http://www.stweb.org/) StWeb - Stratos Web and Application
  837.      server - an easy-to-use, cross platform, Internet/Intranet
  838.      development and deployment system for development of web-enabled
  839.      applications. The standard version of StWeb has a native interface
  840.      to *MySQL* database.
  841.  
  842.    * Right Now Web; Web automation for customer service
  843.      (http://www.rightnowtech.com/)
  844.  
  845.    * Bazaar; Interactive Discussion Forums with web interface
  846.      (http://www.icaap.org/Bazaar/)
  847.  
  848.    * PhoneSweepT (http://www.phonesweep.com/) is the world's first
  849.      commercial Telephone Scanner. Many break-ins in recent years have
  850.      come not through the Internet, but through unauthorized dial-up
  851.      modems. PhoneSweep lets you find these modems by repeatedly placing
  852.      phone calls to every phone number that your organization controls.
  853.      PhoneSweep has a built-in expert system that can recognize more
  854.      than 250 different kinds of remote-access programs, including
  855.      Carbon Copy(TM), pcANYWHERE(TM), and Windows NT RAS. All
  856.      information is stored in the SQL database. It then generates a
  857.      comprehensive report detailing which services were discovered on
  858.      which dial-up numbers in your organization.
  859.  
  860. SQL Clients/Report writers
  861. --------------------------
  862.  
  863.    * *MySQL* Editor/Utility for MS Windows Platforms.
  864.      (http://www.urbanresearch.com/software/utils/urbsql/index.html)
  865.  
  866.    * KDE *MySQL* client (http://www.xnot.com/kmysql)
  867.  
  868.    * KMySQL (http://www.penguinpowered.com/~kmysql) KMySQL is a
  869.      database client for KDE that primarily supports *MySQL*.
  870.  
  871.    * Win32 GUI client (http://www.ecker-software.de) A Win32 GUI client
  872.      by David Ecker.
  873.  
  874.    * Kiosk; a *MySQL* client for database management
  875.      (http://www.icaap.org/software/kiosk/). Written in Perl. Will be a
  876.      part of Bazaar.
  877.  
  878.    * A free report writer in Java
  879.      (http://www.geocities.com/SiliconValley/Ridge/4280/GenericReportWriter/grwhome.html)
  880.  
  881.    * MySQLExport (http://www.javaframework.de) Export of *MySQL* create
  882.      statements and data in a lot of different formats (SQL, HTML, CVS,
  883.      text, ZIP, GZIP...)
  884.  
  885. Distributions that include MySQL
  886. --------------------------------
  887.  
  888.    * SuSE Linux (Suse 6.1 and above) (http://www.suse.com/)
  889.  
  890. Web development tools that support *MySQL*
  891. ------------------------------------------
  892.  
  893.    * PHP: A server-side HTML-embedded scripting language
  894.      (http://www.php.net/)
  895.  
  896.    * The Midgard Application Server; a powerful Web development
  897.      environment based on *MySQL* and PHP
  898.      (http://www.midgard-project.org)
  899.  
  900.    * SmartWorker is a platform for web application development
  901.      (http://www.smartworker.org)
  902.  
  903.    * XSP: e(X)tendible (S)erver (P)ages and is a HTML embedded tag
  904.      language written in Java (previously known as XTAGS)
  905.      (http://xsp.lentus.se/)
  906.  
  907.    * dbServ (http://www.dbServ.de/) is an extension to a web server to
  908.      integrate databases output into your HTML code. You may use any
  909.      HTML function in your output. Only the client will stop you. It
  910.      works as standalone server or as JAVA servlet.
  911.  
  912.    * Platform independent ASP from Chili!Soft
  913.      (http://www.chilisoft.com/)
  914.  
  915.    * *MySQL* + PHP demos (http://www.wernhart.priv.at/php/)
  916.  
  917.    * ForwardSQL: HTML interface to manipulate *MySQL* databases
  918.      (http://www.dbwww.com/)
  919.  
  920.    * WWW-SQL: Display database information
  921.      (http://www.daa.com.au/~james/www-sql/)
  922.  
  923.    * Minivend: A Web shopping cart (http://www.minivend.com/minivend/)
  924.  
  925.    * HeiTML: A server-side extension of HTML and a 4GL language at the
  926.      same time (http://www.heitml.com/)
  927.  
  928.    * Metahtml: A Dynamic Programming Language for WWW Applications
  929.      (http://www.metahtml.com/)
  930.  
  931.    * VelocityGen for Perl and Tcl (http://www.binevolve.com/)
  932.  
  933.    * Hawkeye Internet Server Suite (http://hawkeye.net/)
  934.  
  935.    * Network Database Connection For Linux (http://www.fastflow.com/)
  936.  
  937.    * WDBI: Web browser as a universal front end to databases which
  938.      supports *MySQL* well. (http://www.wdbi.net/)
  939.  
  940.    * WebGroove Script: HTML compiler and server-side scripting language
  941.      (http://www.webgroove.com/)
  942.  
  943.    * A server-side web site scripting language (http://www.ihtml.com/)
  944.  
  945.    * How to use *MySQL* with ColdFusion on Solaris
  946.      (ftp://ftp.igc.apc.org/pub/myodbc/README)
  947.  
  948.    * Calistra's ODBC *MySQL* Administrator (http://calistra.com/MySQL/)
  949.  
  950.    * Webmerger (http://www.webmerger.com) This CGI tool interprets
  951.      files and generates dynamic output based on a set of simple tags.
  952.      Ready-to-run drivers for *MySQL* and PostgreSQL through ODBC.
  953.  
  954.    * PHPclub (http://phpclub.unet.ru/index_e.php3). Tips and tricks for
  955.      PHP
  956.  
  957.    * *MySQL* and Perl Scripts (http://www.penguinservices.com/scripts)
  958.  
  959.    * The Widgetchuck; Web Site Tools and Gadgets
  960.      (http://www.widgetchuck.com)
  961.  
  962.    * AdCycle (http://www.adcycle.com/) advertising management software
  963.  
  964.    * pwPage (http://www.bidsystems.com/pwPage) provides an extremely
  965.      fast and simple approach to the creation of database forms.  That
  966.      is, if a database table exists and an HTML page has been
  967.      constructed using a few simple guidelines, pwPage can be
  968.      immediately used for table data selections, insertions, updates,
  969.      deletions and selectable table content reviewing.
  970.  
  971.    * OMNIS (http://www.omnis-software.com/products/studio/studio.html)
  972.      OMNIS Studio is a rapid application development (RAD) tool.
  973.  
  974. Database design tools with MySQL support
  975. ----------------------------------------
  976.  
  977.    * "DeZign for databases" is a database development tool using an
  978.      entity relationship diagram (ERD).
  979.      (http://www.mysql.com/dezign/index.html)
  980.  
  981. Web servers with *MySQL* tools
  982. ------------------------------
  983.  
  984.    * An Apache authentication module
  985.      (http://bourbon.netvision.net.il/mysql/mod_auth_mysql/)
  986.  
  987.    * The Roxen Challenger Web server (http://www.roxen.com/)
  988.  
  989. Extensions for other programs
  990. -----------------------------
  991.  
  992.    * *MySQL* support for BIND (The Internet Domain Name Server)
  993.      (http://www.seawood.org/msql_bind/)
  994.  
  995.    * *MySQL* support for Sendmail and Procmail
  996.      (http://www.inet-interactive.com/sendmail)
  997.  
  998. Using `MySQL' with other programs
  999. ---------------------------------
  1000.  
  1001.    * Using *MySQL* with Access
  1002.      (http://www.iserver.com/support/addonhelp/database/mysql/msaccess.html)
  1003.  
  1004.    * Installing new Perl modules that require locally installed modules
  1005.      (http://www.iserver.com/support/contrib/perl5/modules.html)
  1006.  
  1007. ODBC related links
  1008. ------------------
  1009.  
  1010.    * Popular iODBC Driver Manager (libiodbc) now available in Open
  1011.      Source format (http://www.iodbc.org/)
  1012.  
  1013.    * The FreeODBC Pages (http://users.ids.net/~bjepson/freeODBC/)
  1014.  
  1015.    * unixodbc (http:/http://genix.net/unixODBC/) The unixODBC Project
  1016.      goals are to develop and promote unixODBC to be the definitive
  1017.      standard for ODBC on the Linux platform.  This is to include GUI
  1018.      support for KDE.
  1019.  
  1020.    * `http://www.sw-soft.com/products/BtrieveODBC/' A *MySQL*-based
  1021.      ODBC drivers for Btrieve
  1022.  
  1023. *API* related links
  1024. -------------------
  1025.  
  1026.    * MySQL COM extension (http://www.amedea.cz/mysqlx/index.html) With
  1027.      this COM objects You can use MySQL also on Windows platform with
  1028.      ASP pages or Delphi, Visual Basic, Visual C++, ... languages.
  1029.  
  1030.    * www.jppp.com (http://www.jppp.com) Partially implemented
  1031.      TDataset-compatible components for *MySQL*.
  1032.  
  1033.    * qpopmysql (http://www.riverstyx.net/qpopmysql/) A patch to allow
  1034.      POP3 authentication from a *MySQL* database.  There's also a link
  1035.      to Paul Khavkine's patch for Procmail to allow any MTA to deliver
  1036.      to users in a *MySQL* database.
  1037.  
  1038.    * Visual Basic class generator for Active X
  1039.      (http://www.pbc.ottawa.on.ca)
  1040.  
  1041.    * Client libraries for the Macintosh (http://www.lilback.com/macsql/)
  1042.  
  1043.    * SCMDB (http://www.dedecker.net/jessie/scmdb/).  SCMDB is an add-on
  1044.      for SCM that ports the mysql C library to scheme (SCM).  With this
  1045.      library scheme developers can make connections to a mySQL database
  1046.      and use embedded SQL in their programs.
  1047.  
  1048. Other *MySQL*-related links
  1049. ---------------------------
  1050.  
  1051.    * Registry of Web providers who support *MySQL*
  1052.      (http://www.wix.com/mysql-hosting)
  1053.  
  1054.    * Links about using *MySQL* in Japan/Asia
  1055.      (http://www.softagency.co.jp/mysql/index.en.phtml)
  1056.  
  1057.    * Commercial Web defect tracking system
  1058.      (http://www.open.com.au/products.html)
  1059.  
  1060.    * PTS: Project Tracking System (http://www.stonekeep.com/pts/)
  1061.  
  1062.    * Job and software tracking system
  1063.      (http://tomato.nvgc.vt.edu/~hroberts/mot)
  1064.  
  1065.    * ExportSQL: A script to export data from Access95+
  1066.      (http://www.cynergi.net/non-secure/exportsql/)
  1067.  
  1068.    * SAL (Scientific Applications on Linux) *MySQL* entry
  1069.      (http://SAL.KachinaTech.COM/H/1/MYSQL.html)
  1070.  
  1071.    * A consulting company which mentions *MySQL* in the right company
  1072.      (http://www.infotech-nj.com/itech/index.shtml)
  1073.  
  1074.    * PMP Computer Solutions. Database developers using *MySQL* and
  1075.      `mSQL' (http://www.pmpcs.com/)
  1076.  
  1077.    * Airborne Early Warning Association (http://www.aewa.org)
  1078.  
  1079.    * *MySQL* UDF Registry
  1080.      (http://abattoir.cc.ndsu.nodak.edu/~nem/mysql/udf/)
  1081.  
  1082.    * Y2K tester (http://21ccs.com/~gboersm/y2kmatrix/)
  1083.  
  1084. SQL and database interfaces
  1085. ---------------------------
  1086.  
  1087.    * The JDBC database access API (http://java.sun.com/products/jdbc/)
  1088.  
  1089.    * Patch for `mSQL' Tcl (http://www.gagme.com/mysql)
  1090.  
  1091.    * EasySQL: An ODBC-like driver manager
  1092.      (http://www.amsoft.ru/easysql/)
  1093.  
  1094.    * A REXX interface to SQL databases
  1095.      (http://www.lightlink.com/hessling/rexxsql.html)
  1096.  
  1097.    * Tcl interface (http://www.binevolve.com/~tdarugar/tcl-sql)
  1098.  
  1099. Examples of MySQL use
  1100. ---------------------
  1101.  
  1102.    * Little6 Inc (http://www.little6.com/about/linux/) An online
  1103.      contract and job finding site that is powered by *MySQL*, PHP3 and
  1104.      Linux.
  1105.  
  1106.    * DELECis
  1107.      (http://www.delec.com/is/products/prep/examples/BookShelf/index.html)
  1108.      A tool which makes it very easy to create an automatically
  1109.      generated table documentation. They have used *MySQL* as an
  1110.      example.
  1111.  
  1112.    * World Records (http://www.worldrecords.com) A search engine for
  1113.      information about music that uses *MySQL* and PHP.
  1114.  
  1115.    * A Contact Database using *MySQL* and PHP
  1116.      (http://www.webtechniques.com/archives/1998/01/note/)
  1117.  
  1118.    * Web based interface and Community Calender with PHP
  1119.      (http://modems.rosenet.net/mysql/)
  1120.  
  1121.    * Perl package to generate html from a SQL table structure and for
  1122.      generating SQL statements from an html form.
  1123.      (http://www.odbsoft.com/cook/sources.htm)
  1124.  
  1125.    * Basic telephone database using `DBI'/`DBD'
  1126.      (http://www.gusnet.cx/proj/telsql/).
  1127.  
  1128.    * JDBC examples by Daniel K. Schneider
  1129.      (http://tecfa.unige.ch/guides/java/staf2x/ex/jdbc/coffee-break)
  1130.  
  1131.    * SQL BNF (http://www.spade.com/linux/howto/PostgreSQL-HOWTO-41.html)
  1132.  
  1133.    * Object Oriented Concepts Inc; CORBA applications with examples in
  1134.      source (http://www.ooc.com/)
  1135.  
  1136.    * DBWiz; Includes an example of how to manage own cursors in VB
  1137.      (http://www.pbc.ottawa.on.ca/)
  1138.  
  1139.    * Pluribus (http://keilor.cs.umass.edu/pluribus/) Pluribus, is a
  1140.      free search engine that learns to improve the quality of its
  1141.      results over time. Pluribus works by recording which pages a user
  1142.      prefers among those returned for a query. A user votes for a page
  1143.      by selecting it; Pluribus then uses that knowledge to improve the
  1144.      quality of the results when someone else submits the same (or
  1145.      similar) query. Uses PHP and *MySQL*.
  1146.  
  1147.    * Stopbit (http://www.stopbit.com/) A technology news site using
  1148.      *MySQL* and PHP
  1149.  
  1150.    * Example scripts at Jokes2000 (http://www.jokes2000.com/scripts/)
  1151.  
  1152.    * `http://www.linuxsupportline.com/~kalendar/ KDE based calendar
  1153.      manager' The calendar manager has both single user (file based)
  1154.      and multi user (*MySQL* database) support.
  1155.  
  1156.    * Example of storing/retrieving images with *MySQL* and CGI
  1157.      (http://tim.desert.net/~tim/imger/)
  1158.  
  1159.    * Online shopping cart system
  1160.      (http://www.penguinservices.com/scripts)
  1161.  
  1162.    * Old Photo Album (http://www.city-gallery.com/album/) The album is
  1163.      a collaborative popular history of photography project that
  1164.      generates all pages from data stored in a *MySQL* database. Pages
  1165.      are dynamically generated through a php3 interface to the database
  1166.      content.  Users contribute images and descriptions. Contributed
  1167.      images are stored on the web server to avoid storing them in the
  1168.      database as BLOBs. All other information is stored in on the
  1169.      shared *MySQL* server.
  1170.  
  1171. General database links
  1172. ----------------------
  1173.  
  1174.    * Database Jump Site (http://www.pcslink.com/~ej/dbweb.html)
  1175.  
  1176.    * Homepage of the webdb-l (Web Databases) mailing list.
  1177.      (http://black.hole-in-the.net/guy/webdb/)
  1178.  
  1179.    * Perl `DBI'/`DBD' modules homepage
  1180.      (http://www.symbolstone.org/technology/perl/DBI/index.html)
  1181.  
  1182.    * Cygwin tools. UNIX on top of Windows
  1183.      (http://www.student.uni-koeln.de/cygwin/)
  1184.  
  1185.    * dbasecentral.com; Development and distribution of powerful and
  1186.      easy-to-use database applications and systems.
  1187.      (http://dbasecentral.com/)
  1188.  
  1189.    * Tek-Tips Forums (http://www.Tek-Tips.com) Tek-Tips Forums are 800+
  1190.      independent peer-to-peer non-commercial support forums for Computer
  1191.      Professionals.  Features include automatic e-mail notification of
  1192.      responses, a links library, and member confidentiality guaranteed.
  1193.  
  1194. There are also many web pages that use *MySQL*. *Note Users::. Send any
  1195. additions to this list to <webmaster@mysql.com>. We now require that
  1196. you show a *MySQL* logo somewhere (It is okay to have it on a "used
  1197. tools" page or something similar) to be added.
  1198.  
  1199. MySQL mailing lists and how to ask questions or report errors (bugs)
  1200. ********************************************************************
  1201.  
  1202. The MySQL mailing lists
  1203. =======================
  1204.  
  1205. To subscribe to the main *MySQL* mailing list, send a message to the
  1206. electronic mail address <mysql-subscribe@lists.mysql.com>.
  1207.  
  1208. To unsubscribe from the main *MySQL* mailing list, send a message to
  1209. the electronic mail address <mysql-unsubscribe@lists.mysql.com>.
  1210.  
  1211. Only the address to which you send your messages is significant.  The
  1212. subject line and the body of the message are ignored.
  1213.  
  1214. If your reply address is not valid, you can specify your address
  1215. explicitly.  Adding a hyphen to the subscribe or unsubscribe command
  1216. word, followed by your address with the `@' character in your address
  1217. replaced by a `='.  For example, to subscribe `john@host.domain', send
  1218. a message to `mysql-subscribe-john=host.domain@lists.mysql.com'.
  1219.  
  1220. Mail to <mysql-subscribe@lists.mysql.com> or
  1221. <mysql-unsubscribe@lists.mysql.com> is handled automatically by the
  1222. ezmlm mailing list processor.  Information about ezmlm is available at
  1223. The ezmlm Website (http://www.ezmlm.org).
  1224.  
  1225. To post a message to the list itself, send your message to
  1226. `mysql@lists.mysql.com'.  However, please _do not_ send mail about
  1227. subscribing or unsubscribing to <mysql@lists.mysql.com>, because any
  1228. mail sent to that address is distributed automatically to thousands of
  1229. other users.
  1230.  
  1231. Your local site may have many subscribers to <mysql@lists.mysql.com>.
  1232. If so, it may have a local mailing list, so that messages sent from
  1233. `lists.mysql.com' to your site are propagated to the local list. In such
  1234. cases, please contact your system administrator to be added to or
  1235. dropped from the local *MySQL* list.
  1236.  
  1237. The following *MySQL* mailing lists exist:
  1238.  
  1239. `announce'
  1240.      This is for announcement of new versions of *MySQL* and related
  1241.      programs. This is a low volume list that we think all *MySQL*
  1242.      users should be on.
  1243.  
  1244. `mysql'
  1245.      The main list for general *MySQL* discussion. Please note that some
  1246.      topics are better discussed on the more-specialized lists. If you
  1247.      post to the wrong list, you may not get an answer!
  1248.  
  1249. `mysql-digest'
  1250.      The `mysql' list in digest form. That means you get all individual
  1251.      messages, sent as one large mail message once a day.
  1252.  
  1253. `bugs'
  1254.      On this list you should only post a full, repeatable bug report,
  1255.      using the `mysqlbug' script (if you are running on Windows, you
  1256.      should include a description of the operating system and the
  1257.      *MySQL* version).  Preferably, you should test the problem using
  1258.      the latest stable or development version of *MySQL* before posting!
  1259.      Anyone should be able to repeat the bug by just using 'mysql test <
  1260.      script' on the included test case.  All bugs posted on this list
  1261.      will be corrected or documented in the next *MySQL* release!  If
  1262.      there are only small code changes involved, we will also post a
  1263.      patch that fixes the problem.
  1264.  
  1265. `bugs-digest'
  1266.      The `bugs' list in digest form
  1267.  
  1268. `developer'
  1269.      A list for people who work on the *MySQL* code. On this list one
  1270.      can also discuss *MySQL* development and post patches.
  1271.  
  1272. `developer-digest'
  1273.      A digest version of the `developer' list.
  1274.  
  1275. `java'
  1276.      Discussion about *MySQL* and Java. Mostly about the JDBC drivers.
  1277.  
  1278. `java-digest'
  1279.      A digest version of the `java' list.
  1280.  
  1281. `win32'
  1282.      All things concerning *MySQL* on Microsoft operating systems such
  1283.      as Windows NT.
  1284.  
  1285. `win32-digest'
  1286.      A digest version of the `win32' list.
  1287.  
  1288. `myodbc'
  1289.      All things concerning connecting to *MySQL* with ODBC.
  1290.  
  1291. `myodbc-digest'
  1292.      A digest version of the `myodbc' list.
  1293.  
  1294. `plusplus'
  1295.      All things concerning programming with the C++ API to *MySQL*.
  1296.  
  1297. `plusplus-digest'
  1298.      A digest version of the `plusplus' list.
  1299.  
  1300. `msql-mysql-modules'
  1301.      A list about the Perl support in *MySQL*.
  1302.  
  1303. `msql-mysql-modules-digest'
  1304.      A digest version of the `msql-mysql-modules' list.
  1305.  
  1306. You subscribe or unsubscribe to all lists in the same way as described
  1307. above.  In your subscribe or unsubscribe message, just put the
  1308. appropriate mailing list name rather than `mysql'.  For example, to
  1309. subscribe to or unsubscribe from the `myodbc' list, send a message to
  1310. <myodbc-subscribe@lists.mysql.com> or
  1311. <myodbc-unsubscribe@lists.mysql.com>.
  1312.  
  1313. Asking questions or reporting bugs
  1314. ==================================
  1315.  
  1316. Before posting a bug report or question, please do the following:
  1317.  
  1318.    * Start by searching the *MySQL* online manual at:
  1319.  
  1320.           `http://www.mysql.com/documentation/manual.php'
  1321.  
  1322.      We try to keep the manual up to date by updating it frequently
  1323.      with solutions to newly found problems!
  1324.  
  1325.    * Search the *MySQL* mailing list archives:
  1326.  
  1327.           `http://www.mysql.com/documentation/'
  1328.  
  1329.    * You can also use `http://www.mysql.com/search.html' to search all
  1330.      the web pages (including the manual) that are located at
  1331.      `http://www.mysql.com/'.
  1332.  
  1333. If you can't find an answer in the manual or the archives, check with
  1334. your local *MySQL* expert. If you still can't find an answer to your
  1335. question, go ahead and read the next section about how to send mail to
  1336. <mysql@lists.mysql.com>.
  1337.  
  1338. How to report bugs or problems
  1339. ==============================
  1340.  
  1341. Writing a good bug report takes patience, but doing it right the first
  1342. time saves time for us and for you. A good bug report containing a full
  1343. test case for the bug will make it very likely that we will fix it in
  1344. the next release. This section will help you write your report correctly
  1345. so that you don't waste your time doing things that may not help us much
  1346. or at all.
  1347.  
  1348. We encourage everyone to use the `mysqlbug' script to generate a bug
  1349. report (or a report about any problem), if possible.  `mysqlbug' can be
  1350. found in the `scripts' directory in the source distribution, or, for a
  1351. binary distribution, in the `bin' directory under your *MySQL*
  1352. installation directory.  If you are unable to use `mysqlbug', you should
  1353. still include all the necessary information listed in this section.
  1354.  
  1355. The `mysqlbug' script helps you generate a report by determining much
  1356. of the following information automatically, but if something important
  1357. is missing, please include it with your message! Please read this
  1358. section carefully and make sure that all the information described here
  1359. is included in your report.
  1360.  
  1361. If you can make a test case which clearly shows the bug, you should post
  1362. it to the <bugs@list.mysql.com> list. Note that on this list you should
  1363. only post a full, repeatable bug report, using the `mysqlbug' script
  1364. (if you are running on Windows, you should include a description of the
  1365. operating system and the *MySQL* version).  Preferably, you should test
  1366. the problem using the latest stable or development version of *MySQL*
  1367. before posting!  Anyone should be able to repeat the bug by just using
  1368. 'mysql test < script' on the included test case or run the shell / perl
  1369. script that is included in the bug report.  All bugs posted on this
  1370. list will be corrected or documented in the next *MySQL* release!  If
  1371. there are only small code changes involved, to correct this problem, we
  1372. will also post a patch that fixes the problem.
  1373.  
  1374. Remember that it is possible to respond to a message containing too much
  1375. information, but not to one containing too little.  Often people omit
  1376. facts because they think they know the cause of a problem and assume
  1377. that some details don't matter.  A good principle is: if you are in
  1378. doubt about stating something, state it!  It is a thousand times faster
  1379. and less troublesome to write a couple of lines more in your report
  1380. than to be forced to ask again and wait for the answer because you
  1381. didn't include enough information the first time.
  1382.  
  1383. The most common errors are that people don't indicate the version
  1384. number of the *MySQL* distribution they are using, or don't indicate
  1385. what platform they have *MySQL* installed on (including the platform
  1386. version number).  This is highly relevant information and in 99 cases
  1387. out of 100 the bug report is useless without it!  Very often we get
  1388. questions like "Why doesn't this work for me?"  and then we find that
  1389. the feature requested wasn't implemented in that *MySQL* version, or
  1390. that a bug described in a report has been fixed already in newer *MySQL*
  1391. versions.  Sometimes the error is platform dependent; in such cases, it
  1392. is next to impossible to fix anything without knowing the operating
  1393. system and the version number of the platform.
  1394.  
  1395. Remember also to provide information about your compiler, if it is
  1396. related to the problem.  Often people find bugs in compilers and think
  1397. the problem is *MySQL* related. Most compilers are under development
  1398. all the time and become better version by version, too.  To determine
  1399. whether or not your problem depends on your compiler, we need to know
  1400. what compiler is used.  Note that every compiling problem should be
  1401. regarded as a bug report and reported accordingly.
  1402.  
  1403. It is most helpful when a good description of the problem is included
  1404. in the bug report.  That is, a good example of all the things you did
  1405. that led to the problem and the problem itself exactly described.  The
  1406. best reports are those that include a full example showing how to
  1407. reproduce the bug or problem.
  1408.  
  1409. If a program produces an error message, it is very important to include
  1410. the message in your report! If we try to search for something from the
  1411. archives using programs, it is better that the error message reported
  1412. exactly matches the one that the program produces.  (Even the case
  1413. sensitivity should be observed!) You should never try to remember what
  1414. the error message was; instead, copy and paste the entire message into
  1415. your report!
  1416.  
  1417. If you have a problem with MyODBC, you should try to genereate a MyODBC
  1418. trace file. *Note MyODBC bug report::.
  1419.  
  1420. Please remember that many of the people who will read your report will
  1421. do so using an 80-column display.  When generating reports or examples
  1422. using the `mysql' command line tool, you should therefore use the
  1423. `--vertical' option (or the `\G' statement terminator) for output which
  1424. would exceed the available width for such a display (for example, with
  1425. the `EXPLAIN SELECT' statement; see the example below).
  1426.  
  1427. Please include the following information in your report:
  1428.  
  1429.    * The version number of the *MySQL* distribution you are using (for
  1430.      example, *MySQL* 3.22.22). You can find out which version you are
  1431.      running by executing `mysqladmin version'. `mysqladmin' can be
  1432.      found in the `bin' directory under your *MySQL* installation
  1433.      directory.
  1434.  
  1435.    * The manufacturer and model of the machine you are working on.
  1436.  
  1437.    * The operating system name and version. For most operating systems,
  1438.      you can get this information by executing the Unix command `uname
  1439.      -a'.
  1440.  
  1441.    * Sometimes the amount of memory (real and virtual) is relevant.  If
  1442.      in doubt, include these values.
  1443.  
  1444.    * If you are using a source distribution of *MySQL*, the name and
  1445.      version number of the compiler used is needed.  If you have a
  1446.      binary distribution, the distribution name is needed.
  1447.  
  1448.    * If the problem occurs during compilation, include the exact error
  1449.      message(s) and also a few lines of context around the offending
  1450.      code in the file where the error occurred.
  1451.  
  1452.    * If any database table is related to the problem, include the
  1453.      output from `mysqldump --no-data db_name tbl_name1 tbl_name2 ...'
  1454.      This is very easy to do and is a powerful way to get information
  1455.      about any table in a database that will help us create a situation
  1456.      matching the one you have.
  1457.  
  1458.    * For speed-related bugs or problems with `SELECT' statements, you
  1459.      should always include the output of `EXPLAIN SELECT ...', and at
  1460.      least the number of rows that the `SELECT' statement produces.
  1461.      The more information you give about your situation, the more
  1462.      likely it is that someone can help you!  For example, the
  1463.      following is an example of a very good bug report (it should of
  1464.      course be posted with the `mysqlbug' script):
  1465.  
  1466.      Example run using the `mysql' command line tool (note the use of
  1467.      the `\G' statement terminator for statements whose output width
  1468.      would otherwise exceed that of an 80-column display device):
  1469.  
  1470.           mysql> SHOW VARIABLES;
  1471.           mysql> SHOW COLUMNS FROM ...\G
  1472.                  <output-from-SHOW-COLUMNS>
  1473.           mysql> EXPLAIN SELECT ...\G
  1474.                  <output-from-EXPLAIN>
  1475.           mysql> FLUSH STATUS;
  1476.           mysql> SELECT ...;
  1477.                  <A short version of the output from SELECT,
  1478.                  including the time taken to run the query>
  1479.           mysql> SHOW STATUS;
  1480.                  <output from SHOW STATUS>
  1481.  
  1482.    * If a bug or problem occurs while running *MySQL*, try to provide an
  1483.      input script that will reproduce the anomaly. This script should
  1484.      include any necessary source files. The more closely the script
  1485.      can reproduce your situation, the better.
  1486.  
  1487.      If you can't provide a script, you should at least include the
  1488.      output from `mysqladmin variables extended-status processlist' in
  1489.      your mail to provide some information of how your system is
  1490.      performing!
  1491.  
  1492.    * If you think that *MySQL* produces a strange result from a query,
  1493.      include not only the result, but also your opinion of what the
  1494.      result should be and an account describing the basis for your
  1495.      opinion.
  1496.  
  1497.    * When giving an example of the problem, it's better to use the
  1498.      variable names, table names, etc., that exist in your actual
  1499.      situation than to come up with new names. The problem could be
  1500.      related to the name of a variable, table, etc.!  These cases are
  1501.      rare, perhaps, but it is better to be safe than sorry.  After all,
  1502.      it should be easier for you to provide an example that uses your
  1503.      actual situation and it is by all means better for us.  In case you
  1504.      have data you don't want to show to others, you can use `ftp' to
  1505.      transfer it to `ftp://support.mysql.com/pub/mysql/secret/'.  If
  1506.      the data are really top secret and you don't want to show them
  1507.      even to us, then go ahead and provide an example using other
  1508.      names, but please regard this as the last choice.
  1509.  
  1510.    * Include all the options given to the relevant programs, if
  1511.      possible.  For example, indicate the options that you use when you
  1512.      start the `mysqld' daemon and that you use to run any *MySQL*
  1513.      client programs.  The options to programs like `mysqld' and
  1514.      `mysql', and to the `configure' script are often keys to answers
  1515.      and very relevant!  It is never a bad idea to include them anyway!
  1516.      If you use any modules, such as Perl or PHP, please include the
  1517.      version number(s) of those as well.
  1518.  
  1519.    * If you can't produce a test case in a few rows, or if the test
  1520.      table is too big to be mailed to the mailing list (more than 10
  1521.      rows), you should dump your tables using `mysqldump' and create a
  1522.      `README' file that describes your problem.
  1523.  
  1524.      Create a compressed archive of your files using `tar' and `gzip'
  1525.      or `zip', and use `ftp' to transfer the archive to
  1526.      `ftp://support.mysql.com/pub/mysql/secret/'.  Then send a short
  1527.      description of the problem to <mysql@lists.mysql.com>.
  1528.  
  1529.    * If your question is related to the privilege system, please
  1530.      include the output of `mysqlaccess', the output of `mysqladmin
  1531.      reload' and all the error messages you get when trying to connect!
  1532.      When you test your privileges, you should first run
  1533.      `mysqlaccess'. After this, execute `mysqladmin reload version',
  1534.      and last you should try to connect with the program that gives you
  1535.      trouble.  `mysqlaccess' can be found in the `bin' directory under
  1536.      your *MySQL* installation directory.
  1537.  
  1538.    * If you have a patch for a bug, that is good, but don't assume the
  1539.      patch is all we need, or that we will use it even if you don't
  1540.      provide some necessary information such as test cases showing the
  1541.      bug that your patch fixes.  We might find problems with your patch
  1542.      or we might not understand it at all; if so, we can't use it.
  1543.  
  1544.      If we can't verify exactly what the patch is meant for, we won't
  1545.      use it.  Test cases will help us here.  Show that the patch will
  1546.      handle all the situations that may occur. If we find a borderline
  1547.      case (even a rare one) where the patch won't work, the patch may
  1548.      be useless.
  1549.  
  1550.    * Guesses about what the bug is, why it occurs, or what it depends
  1551.      on, are usually wrong. Even we can't guess such things without
  1552.      first using a debugger to determine the real cause of a bug.
  1553.  
  1554.    * Indicate in your mail message that you have checked the reference
  1555.      manual and mail archive so others know that you have tried to
  1556.      solve your problem yourself.
  1557.  
  1558.    * If you get a `parse error', please check your syntax closely! If
  1559.      you can't find something wrong with it, it's extremely likely that
  1560.      your current version of *MySQL* doesn't support the query you are
  1561.      using.  If you are using the current version and the manual at
  1562.      `http://www.mysql.com/documentation/manual.php' doesn't cover the
  1563.      syntax you are using, *MySQL* doesn't support your query.  In this
  1564.      case, your only options are to implement the syntax yourself or
  1565.      email <mysql-licensing@mysql.com> and ask for an offer to
  1566.      implement it!
  1567.  
  1568.      If the manual covers the syntax you are using, but you have an
  1569.      older version of *MySQL*, you should check the *MySQL* change
  1570.      history to see when the syntax was implemented.  *Note News::.  In
  1571.      this case, you have the option of upgrading to a newer version of
  1572.      *MySQL*.
  1573.  
  1574.    * If you have a problem such that your data appears corrupt or you
  1575.      get errors when you access some particular table, you should first
  1576.      check and then try repairing your tables with `myisamchk'.  *Note
  1577.      Maintenance::.
  1578.  
  1579.    * If you often get corrupted tables you should try to find out when
  1580.      and why this happens!  In this case, the
  1581.      `mysql-data-directory/'hostname'.err' file may contain some
  1582.      information about what happened.  Please include any relevant
  1583.      information from this file in your bug report!  Normally `mysqld'
  1584.      should *NEVER* crash a table if nothing killed it in the middle of
  1585.      an update!  If you can find the source of why `mysqld' dies, it's
  1586.      much easier for us to provide you with a fix for the problem!
  1587.      *Note What is crashing::.
  1588.  
  1589.    * If possible, download the most recent version of *MySQL* and check
  1590.      whether or not it solves your problem.  All versions of *MySQL* are
  1591.      thoroughly tested and should work without problems!  We believe in
  1592.      making everything as backward compatible as possible and you
  1593.      should be able to switch *MySQL* versions in minutes!  *Note Which
  1594.      version::.
  1595.  
  1596. If you are a support customer, please cross-post the bug report to
  1597. <mysql-support@mysql.com> for higher priority treatment, as well as to
  1598. the appropriate mailing list to see if someone else has experienced (and
  1599. perhaps solved) the problem.
  1600.  
  1601. For information on reporting bugs in *MyODBC*, see *Note ODBC
  1602. Problems::.
  1603.  
  1604. For solutions to some common problems, see *Note Problems::.
  1605.  
  1606. When answers are sent to you individually and not to the mailing list,
  1607. it is considered good etiquette to summarize the answers and send the
  1608. summary to the mailing list so that others may have the benefit of
  1609. responses you received that helped you solve your problem!
  1610.  
  1611. Guidelines for answering questions on the mailing list
  1612. ======================================================
  1613.  
  1614. If you consider your answer to have broad interest, you may want to
  1615. post it to the mailing list instead of replying directly to the
  1616. individual who asked.  Try to make your answer general enough that
  1617. people other than the original poster may benefit from it.  When you
  1618. post to the list, please make sure that your answer is not a
  1619. duplication of a previous answer.
  1620.  
  1621. Try to summarize the essential part of the question in your reply;
  1622. don't feel obliged to quote the entire original message.
  1623.  
  1624. Please don't post mail messages from your browser with HTML mode turned
  1625. on!  Many users don't read mail with a browser!
  1626.  
  1627. MySQL licensing and support
  1628. ***************************
  1629.  
  1630. This chapter describes *MySQL* support and licensing arrangements:
  1631.  
  1632.    * The copyrights under which *MySQL* is distributed (*note
  1633.      Copyright::)
  1634.  
  1635.    * Sample situations illustrating when a license is required (*note
  1636.      Licensing examples::)
  1637.  
  1638.    * Support costs (*note Cost::), and support benefits (*note
  1639.      Support::)
  1640.  
  1641.    * Commercial licensing costs
  1642.  
  1643. MySQL licensing policy
  1644. ======================
  1645.  
  1646. The formal terms of the GPL license can be found at *Note GPL license::.
  1647. Basically, our licensing policy and intepretation of the GPL is as
  1648. follows:
  1649.  
  1650. Note that older versions of *MySQL* are still using a more strict
  1651. license. See the documentation for that version for more information.
  1652. If you need a commercial *MySQL* license, because the GPL license
  1653. doesn't suit your application, you can buy one at
  1654. https://order.mysql.com/license.htmy.
  1655.  
  1656. For normal internal use, *MySQL* costs nothing.  You do not have to pay
  1657. us if you do not want to.
  1658.  
  1659. A license is required if:
  1660. =========================
  1661.  
  1662.    - You link a part of the of *MySQL* that has a GPL Copyright to a
  1663.      program which is not free software (embedded usage of the *MySQL*
  1664.      server).  In this case your application would also become GPL
  1665.      through the clause in the GPL license that acts as a virus. By
  1666.      licensing *MySQL* from us under a commercial license you will
  1667.      avoid this problem.
  1668.  
  1669.    - You have a commercial application that ONLY works with *MySQL* and
  1670.      ships the application with the *MySQL* server. This is because we
  1671.      view this a linking even if it is done over the network.
  1672.  
  1673.    - You have a distribute `MySQL' and you don't provide the source
  1674.      code for your copy of the *MySQL* server, as defined in the GPL
  1675.      license.
  1676.  
  1677. A license is *NOT* required if:
  1678. ===============================
  1679.  
  1680.    - You do not need a license to include the client code in commercial
  1681.      programs.  The client access part of *MySQL* licensed with the
  1682.      LGPL `GNU Library General Public License'. The `mysql' command
  1683.      line client includes code from the `readline' library that is under
  1684.      the `GPL'.
  1685.  
  1686.    - If your use of *MySQL* does not require a license, but you like
  1687.      *MySQL* and want to encourage further development, you are
  1688.      certainly welcome to purchase a license or *MySQL* support anyway.
  1689.  
  1690.    - If you use *MySQL* in a commercial context such that you profit by
  1691.      its use, we ask that you further the development of *MySQL* by
  1692.      purchasing some level of support.  We feel that if *MySQL* helps
  1693.      your business, it is reasonable to ask that you help *MySQL*.
  1694.      (Otherwise, if you ask us support questions, you are not only
  1695.      using for free something into which we've put a lot a work, you're
  1696.      asking us to provide free support, too.)
  1697.  
  1698. For circumstances under which a *MySQL* license is required, you need a
  1699. license per machine that runs the `mysqld' server.  However, a
  1700. multiple-CPU machine counts as a single machine, and there is no
  1701. restriction on the number of *MySQL* servers that run on one machine,
  1702. or on the number of clients concurrently connected to a server running
  1703. on that machine!
  1704.  
  1705. If you have any questions as to whether or not a license is required for
  1706. your particular use of *MySQL*, please read this again and then contact
  1707. us. *Note Contact information::.
  1708.  
  1709. If you require a *MySQL* license, the easiest way to pay for it is to
  1710. use the license form on *MySQL*'s secure server at
  1711. https://order.mysql.com/license.htmy. Other forms of payment are
  1712. discussed in *Note Payment information::.
  1713.  
  1714. Copyrights used by MySQL
  1715. ========================
  1716.  
  1717. There are several different copyrights on the *MySQL* distribution:
  1718.  
  1719.   1. The *MySQL*-specific source needed to build the `mysqlclient'
  1720.      library is licensed under the `LGPL' and programs in the `client'
  1721.      directory is GPL. Each file has a header that shows which
  1722.      copyright is used for that file.
  1723.  
  1724.   2. The client library and the (GNU `getopt') library are covered by
  1725.      the "GNU LIBRARY LIBRARY GENERAL PUBLIC LICENSE".
  1726.  
  1727.   3. Some parts of the source (the `regexp' library) are covered by a
  1728.      Berkeley style copyright.
  1729.  
  1730.   4. All the source in the server and the (GNU `readline') library is
  1731.      covered by the "GNU GENERAL PUBLIC LICENSE". *Note GPL license::.
  1732.      This is also available as the file `COPYING' in the distributions.
  1733.  
  1734.  
  1735. One goal with this is that the SQL client library should be free enough
  1736. so that it is possible to add *MySQL* support in commercial products
  1737. without any license. So in this case we choose the LGPL license.
  1738.  
  1739. This means that you can use *MySQL* for free with any program that uses
  1740. any of the free software licences.  *MySQL* is also free for any end
  1741. user for his own/company usage.
  1742.  
  1743. But if you use *MySQL* for something important to you, you may want to
  1744. help secure its development by purchasing licenses or a support
  1745. contract, *Note Support::.
  1746.  
  1747. Copyright changes
  1748. -----------------
  1749.  
  1750. The stable versions are of *MySQL* are still using a more strict
  1751. license. See the documatation for that version for more information.
  1752.  
  1753. Example licensing situations
  1754. ============================
  1755.  
  1756. This section describes some situations illustrating whether or not you
  1757. must license the *MySQL* server.  Generally these examples involve
  1758. providing *MySQL* as a integrated part of a product.
  1759.  
  1760. Note that a single *MySQL* license covers any number of CPUs and
  1761. `mysqld' servers on a machine! It also has not limit on the number of
  1762. clients that connect to one server in any way.
  1763.  
  1764. Selling products that use *MySQL*
  1765. ---------------------------------
  1766.  
  1767. To determine whether or not you need a *MySQL* license when selling
  1768. your application, you should ask whether the proper functioning of your
  1769. application is depentent on the use of *MySQL* and whether you include
  1770. the *MySQL* server with your product.  There are several cases to
  1771. consider:
  1772.  
  1773.    * Does your application require *MySQL* to function properly?
  1774.  
  1775.      If your product requires *MySQL*, you need a license for any
  1776.      machine that runs the `mysqld' server.  For example, if you've
  1777.      designed your application around *MySQL*, then you've really made
  1778.      a commercial product that requires the engine, so you need a
  1779.      license.
  1780.  
  1781.      If your application does not require *MySQL*, you need not obtain
  1782.      a license.  For example, if *MySQL* just added some new optional
  1783.      features to your product (such as adding logging to a database if
  1784.      *MySQL* is used rather than logging to a text file), it should
  1785.      fall within normal use, and a license would not be required.
  1786.  
  1787.      In other words, you need a license if you sell a product designed
  1788.      specifically for use with *MySQL* or that requires the *MySQL*
  1789.      server to function at all.  This is true whether or not you
  1790.      provide *MySQL* for your client as part of your product
  1791.      distribution.
  1792.  
  1793.      It also depends on what you're doing for the client.  Do you plan
  1794.      to provide your client with detailed instructions on installing
  1795.      *MySQL* with your software?  Then your product may be contingent
  1796.      on the use of *MySQL*; if so, you need to buy a license.  If you
  1797.      are simply tying into a database that you expect already to have
  1798.      been installed by the time your software is purchased, then you
  1799.      probably don't need a license.
  1800.  
  1801.  
  1802. ISP *MySQL* services
  1803. --------------------
  1804.  
  1805. Internet Service Providers (ISPs) often host *MySQL* servers for their
  1806. customers. With the GPL license this does not require a license.
  1807.  
  1808. On the other hand, we do encourage people to use ISP:s that has *MySQL*
  1809. support as this will give them the confidence that if they get some
  1810. problem with their *MySQL* installation, their ISP will be able to
  1811. solve the problem for them (in some cases with the help from the
  1812. *MySQL* development team).
  1813.  
  1814. All `ISPs' that wants to keep themself up to date should subscribe to
  1815. our announce mailing list so that they can be aware of fatal issues
  1816. that may be relevant for their `MySQL' installations.
  1817.  
  1818. Note that if the `ISP' doesn't have a license for `MySQL', they should
  1819. give their customers at least read access to the source of the `MySQL'
  1820. installation so that their customer can verify that it's patched
  1821. correctly.
  1822.  
  1823. Running a web server using *MySQL*
  1824. ----------------------------------
  1825.  
  1826. If you use *MySQL* in conjunction with a web server on Unix, you don't
  1827. have to pay for a license.
  1828.  
  1829. This is true even if you run a commercial web server that uses *MySQL*,
  1830. because you are not selling an embedded *MySQL* version yourself.
  1831. However, in this case we would like you to purchase *MySQL* support,
  1832. because *MySQL* is helping your enterprise.
  1833.  
  1834. *MySQL* licensing and support costs
  1835. ===================================
  1836.  
  1837. Our current license prices are shown below. These prices are now under
  1838. review because of the change to a GPL copyright. New prices and terms
  1839. will be posted on the *MySQL* web site `http://www.mysql.com/' as soon
  1840. as they are ready.
  1841.  
  1842. All prices are in US Dollars. If you pay by credit card, the currency is
  1843. EURO (European Union Euro) so the prices will differ slightly.
  1844.  
  1845. *Number of         *Price per     *Total*
  1846. licenses*          copy*          
  1847. 1                  US $200        US $200
  1848. 10 pack            US $150        US $1500
  1849. 50 pack            US $120        US $6000
  1850.  
  1851. For high volume (OEM) purchases, the following prices apply:
  1852.  
  1853. *Number of         *Price per     *Minimum at one time*  *Minimum payment*
  1854. licenses*          copy*                                 
  1855. 100-999            US $40         100                    US $4000
  1856. 1000-2499          US $25         200                    US $5000
  1857. 2500-4999          US $20         400                    US $8000
  1858.  
  1859. For OEM purchases, you must act as the middle-man for eventual problems
  1860. or extension requests from your users. We also require that OEM
  1861. customers have at least an extended email support contract.  Note that
  1862. OEM licenses only apply for products where the user doesn't have direct
  1863. access to the *MySQL* server (embedded system). In other words: The
  1864. *MySQL* server should only be used with the application that was
  1865. supplied you.
  1866.  
  1867. If you have a low-margin high-volume product, you can always talk to us
  1868. about other terms (for example, a percent of the sale price). If you do,
  1869. please be informative about your product, pricing, market and any other
  1870. information that may be relevant.
  1871.  
  1872. A full-price license is not a support agreement and includes very
  1873. minimal support. This means that we try to answer any relevant
  1874. question. If the answer is in the documentation, we will direct you to
  1875. the appropriate section. If you have not purchased a license or
  1876. support, we probably will not answer at all.
  1877.  
  1878. If you discover what we consider a real bug, we are likely to fix it in
  1879. any case. But if you pay for support we will notify you about the fix
  1880. status instead of just fixing it in a later release.
  1881.  
  1882. More comprehensive support is sold separately.  Descriptions of what
  1883. each level of support includes are given in *Note Support::.  Costs for
  1884. the various types of commercial support are shown below.  Support level
  1885. prices are in EURO (European Union Euro). One EURO is about 1.17 USD.
  1886.  
  1887. *Type of support*      *Cost per year*
  1888. Basic email support    EURO 170
  1889. Extended email         EURO 1000
  1890. support                
  1891. Login support          EURO 2000
  1892. Extended login         EURO 5000
  1893. support                
  1894.  
  1895. You may upgrade from any lower level of support to a higher level of
  1896. support for the difference between the prices of the two support levels.
  1897.  
  1898. Payment information
  1899. -------------------
  1900.  
  1901. Currently we can take SWIFT payments, cheques or credit cards.
  1902.  
  1903. Payment should be made to:
  1904.      Postgirot Bank AB
  1905.      105 06 STOCKHOLM, SWEDEN
  1906.      
  1907.      TCX DataKonsult AB
  1908.      BOX 6434
  1909.      11382 STOCKHOLM, SWEDEN
  1910.      
  1911.      SWIFT address: PGSI SESS
  1912.      Account number: 96 77 06 - 3
  1913.  
  1914. Specify: license and/or support and your name and email address.
  1915.  
  1916. In Europe and Japan you can use EuroGiro (that should be less
  1917. expensive) to the same account.
  1918.  
  1919. If you want to pay by cheque, make it payable to "MySQL Finland AB" and
  1920. mail it to the address below:
  1921.  
  1922.      TCX DataKonsult AB
  1923.      BOX 6434, Torsgatan 21
  1924.      11382 STOCKHOLM, SWEDEN
  1925.  
  1926. If you want to pay by credit card over the Internet, you can use MySQL
  1927. AB's secure license form (https://order.mysql.com/license.htmy).
  1928.  
  1929. You can also print a copy of the license form, fill it in and send it
  1930. by fax to:
  1931.  
  1932. +46-8-729 69 05
  1933.  
  1934. If you want us to bill you, you can use the license form and write "bill
  1935. us" in the comment field.  You can also mail a message to
  1936. <sales@mysql.com> (*not* <mysql@lists.mysql.com>!)  with your company
  1937. information and ask us to bill you.
  1938.  
  1939. Contact information
  1940. -------------------
  1941.  
  1942. For commercial licensing, or if you have any questions about any of the
  1943. information in this section, please contact the *MySQL* licensing team.
  1944. The much preferred method is by E-Mail to <mysql-licensing@mysql.com>.
  1945. Fax is also possible but handling of these may take much longer (Fax
  1946. +46-8-729 69 05).
  1947.  
  1948.      David Axmark
  1949.      Detron HB
  1950.      Kungsgatan 65 B
  1951.      753 21 UPPSALA
  1952.      SWEDEN
  1953.      Voice Phone +46-18-10 22 80
  1954.      (Timezone GMT+1. Swedish and English spoken)
  1955.  
  1956. Types of commercial support
  1957. ===========================
  1958.  
  1959. Basic email support
  1960. -------------------
  1961.  
  1962. Basic email support is a very inexpensive support option and should be
  1963. thought of more as a way to support our development of *MySQL* than as
  1964. a real support option.  We at *MySQL* do give a lot of free support in
  1965. all the different *MySQL* lists and the money we get from basic eamil
  1966. support is largely used to make this possible.
  1967.  
  1968. At this support level, the *MySQL* mailing lists are the preferred
  1969. means of communication.  Questions normally should be mailed to the
  1970. primary mailing list (<mysql@lists.mysql.com>) or one of the other
  1971. regular lists (for example, <win32@lists.mysql.com> for Windows-related
  1972. *MySQL* questions), as someone else already may have experienced and
  1973. solved the problem you have.  *Note Asking questions::.
  1974.  
  1975. However, by purchasing basic email support, you also have access to the
  1976. support address <mysql-support@mysql.com>, which is not available as
  1977. part of the minimal support that you get by purchasing a *MySQL*
  1978. license.  This means that for especially critical questions, you can
  1979. cross-post your message to <mysql-support@mysql.com>.  (If the message
  1980. contains sensitive data, you should post only to
  1981. <mysql-support@mysql.com>.)
  1982.  
  1983. _REMEMBER!_ to ALWAYS include your registration number and expiration
  1984. date when you send a message to <mysql-support@mysql.com>.
  1985.  
  1986. Note that if you have encountered a critical repeatable bug and follow
  1987. the rules outlined in the manual section of how to report bugs and send
  1988. it to <bugs@lists.mysql.com> we promise to try to fix this as soon as
  1989. possible, independent of your support level! *Note Bug reports::.
  1990.  
  1991. Basic email support includes the following types of service:
  1992.  
  1993.    * If your question is already answered in the manual, we will inform
  1994.      you of the correct section in which you can find the answer.  If
  1995.      the answer is not in the manual, we will point you in the right
  1996.      direction to solve your problem.
  1997.  
  1998.    * We guarantee a timely answer for your email messages.  We can't
  1999.      guarantee that we can solve any problem, but at least you will
  2000.      receive an answer if we can contact you by email.
  2001.  
  2002.    * We will help with unexpected problems when you install *MySQL*
  2003.      from a binary distribution on supported platforms.  This level of
  2004.      support does not cover installing *MySQL* from a source
  2005.      distribution.  "Supported" platforms are those for which *MySQL*
  2006.      is known to work.  *Note Which OS::.
  2007.  
  2008.    * We will help you with bugs and missing features. Any bugs that are
  2009.      found are fixed for the next *MySQL* release. If the bug is
  2010.      critical for you, we will mail you a patch for it as soon the bug
  2011.      is fixed.  Critical bugs always have the highest priority for us,
  2012.      to ensure that they are fixed as soon as possible.
  2013.  
  2014.    * Your suggestions for the further development of *MySQL* will be
  2015.      taken into consideration. By taking email support you have already
  2016.      helped the further development of *MySQL*. If you want to have
  2017.      more input, upgrade to a higher level of support.
  2018.  
  2019.    * If you want us to help optimize your system, you must upgrade to a
  2020.      higher level of support.
  2021.  
  2022.    * We include a binary version of the `myisampack' packing tool for
  2023.      creating fast compressed read-only databases. The current server
  2024.      includes support for reading such databases but not the packing
  2025.      tool used to create them.
  2026.  
  2027. Extended email support
  2028. ----------------------
  2029.  
  2030. Extended email support includes everything in basic email support with
  2031. these additions:
  2032.  
  2033.    * Your email will be dealt with before mail from basic email support
  2034.      users and non-registered users.
  2035.  
  2036.    * Your suggestions for the further development of *MySQL* will
  2037.      receive strong consideration. Simple extensions that suit the basic
  2038.      goals of *MySQL* are implemented in a matter of days. By taking
  2039.      extended email support you have already helped the further
  2040.      development of *MySQL*.
  2041.  
  2042.    * Typical questions that are covered by extended email support are:
  2043.  
  2044.         - We will answer and (within reason) solve questions that
  2045.           relate to possible bugs in *MySQL*.  As soon as the bug is
  2046.           found and corrected, we will mail a patch for it.
  2047.  
  2048.         - We will help with unexpected problems when you install
  2049.           *MySQL* from a source or binary distribution on supported
  2050.           platforms.
  2051.  
  2052.         - We will answer questions about missing features and offer
  2053.           hints how to work around them.
  2054.  
  2055.         - We will provide hints on optimizing `mysqld' for your
  2056.           situation.
  2057.  
  2058.    * You are allowed to influence the priority of items on the *MySQL*
  2059.      TODO. This will ensure that the features you really need will be
  2060.      implemented sooner than they might be otherwise.
  2061.  
  2062. Login support
  2063. -------------
  2064.  
  2065. Login support includes everything in extended email support with these
  2066. additions:
  2067.  
  2068.    * Your email will be dealt with even before mail from extended email
  2069.      support users.
  2070.  
  2071.    * Your suggestions for the further development of *MySQL* will be
  2072.      taken into very high consideration.  Realistic extensions that can
  2073.      be implemented in a couple of hours and that suit the basic goals
  2074.      of *MySQL* will be implemented as soon as possible.
  2075.  
  2076.    * If you have a very specific problem, we can try to log in on your
  2077.      system to solve the problem "in place."
  2078.  
  2079.    * Like any database vendor, we can't guarantee that we can rescue
  2080.      any data from crashed tables, but if the worst happens we will
  2081.      help you rescue as much as possible. *MySQL* has proven itself
  2082.      very reliable, but anything is possible due to circumstances
  2083.      beyond our control (for example, if your system crashes or someone
  2084.      kills the server by executing a `kill -9' command).
  2085.  
  2086.    * We will provide hints on optimizing your system and your queries.
  2087.  
  2088.    * You are allowed to call a *MySQL* developer (in moderation) and
  2089.      discuss your *MySQL*-related problems.
  2090.  
  2091. Extended login support
  2092. ----------------------
  2093.  
  2094. Extended login support includes everything in login support with these
  2095. additions:
  2096.  
  2097.    * Your email has the highest possible priority.
  2098.  
  2099.    * We will actively examine your system and help you optimize it and
  2100.      your queries. We may also optimize and/or extend *MySQL* to better
  2101.      suit your needs.
  2102.  
  2103.    * You may also request special extensions just for you. For example:
  2104.           mysql> select MY_FUNC(col1,col2) from table;
  2105.  
  2106.    * We will provide a binary distribution of all important *MySQL*
  2107.      releases for your system, as long as we can get an account on a
  2108.      similar system. In the worst case, we may require access to your
  2109.      system to be able to create a binary distribution.
  2110.  
  2111.    * If you can provide accommodations and pay for traveler fares, you
  2112.      can even get a *MySQL* developer to visit you and offer you help
  2113.      with your troubles. Extended login support entitles you to one
  2114.      personal encounter per year, but we are as always very flexible
  2115.      towards our customers!
  2116.  
  2117. Installing MySQL
  2118. ****************
  2119.  
  2120. This chapter describes how to obtain and install *MySQL*:
  2121.  
  2122.    * For a list of sites from which you can obtain *MySQL*, see *Note
  2123.      Getting *MySQL*: Getting MySQL.
  2124.  
  2125.    * To see which platforms are supported, see *Note Which OS::.
  2126.  
  2127.    * Several versions of *MySQL* are available, in both binary and
  2128.      source distributions.  To determine which version and type of
  2129.      distribution you should use, see *Note Many versions::.
  2130.  
  2131.    * Installation instructions for binary and source distributions are
  2132.      described in *Note Installing binary::, and *Note Installing
  2133.      source::.  Each set of instructions includes a section on
  2134.      system-specific problems you may run into.
  2135.  
  2136.    * For post-installation procedures, see *Note Post-installation::.
  2137.      These procedures apply whether you install *MySQL* using a binary
  2138.      or source distribution.
  2139.  
  2140. How to get MySQL
  2141. ================
  2142.  
  2143. Check the *MySQL* home page (http://www.mysql.com/) for information
  2144. about the current version and for downloading instructions.
  2145.  
  2146. If you have problems downloading from our main site, try using on of the
  2147. mirrors listed below.
  2148.  
  2149. Please report bad or out of date mirrors to <webmaster@mysql.com>.
  2150.  
  2151. *Europe:*
  2152.  
  2153.    *  Austria [Univ. of Technology/Vienna]   WWW
  2154.      (http://gd.tuwien.ac.at/db/mysql/) FTP
  2155.      (ftp://gd.tuwien.ac.at/db/mysql/)
  2156.  
  2157.    *  Bulgaria [Naturella]   WWW
  2158.      (http://archive.nat.bg/pub/mirror/mysql/) FTP
  2159.      (ftp://ftp.ntrl.net/pub/mirror/mysql/)
  2160.  
  2161.    *  Croatia [HULK]   WWW (http://ftp.linux.hr/pub/mysql/) FTP
  2162.      (ftp://ftp.linux.hr/pub/mysql/)
  2163.  
  2164.    *  Czech Republic [Masaryk University in Brno]   WWW
  2165.      (http://mysql.linux.cz/index.html) FTP
  2166.      (ftp://ftp.fi.muni.cz/pub/mysql/)
  2167.  
  2168.    *  Czech Republic [www.sopik.cz]   WWW (http://www.mysql.cz/)
  2169.  
  2170.    *  Czech Republic [www.gin.cz]  WWW (http://mysql.gin.cz/) FTP
  2171.      (ftp://ftp.gin.cz/pub/MIRRORS/www.mysql.com/)
  2172.  
  2173.    *  Denmark [Borsen]   WWW (http://mysql.borsen.dk/)
  2174.  
  2175.    *  Denmark [SunSITE]   WWW (http://SunSITE.auc.dk/mysql/) FTP
  2176.      (ftp://SunSITE.auc.dk/pub/databases/mysql/)
  2177.  
  2178.    *  Estonia [OKinteractive]   WWW (http://mysql.mirror.ok.ee)
  2179.  
  2180.    *  France [minet]   WWW (http://www.minet.net/devel/mysql/)
  2181.  
  2182.    *  Finland [EUnet]  WWW (http://mysql.eunet.fi/)
  2183.  
  2184.    *  Finland [clinet]  FTP
  2185.      (ftp://ftp.clinet.fi/mirrors/ftp.mysql.org/pub/mysql/)
  2186.  
  2187.    *  Germany [Bonn University, Bonn]   WWW
  2188.      (http://www.wipol.uni-bonn.de/MySQL//) FTP
  2189.      (ftp://ftp.wipol.uni-bonn.de/pub/mirror/MySQL/)
  2190.  
  2191.    *  Germany [Wolfenbuettel]   WWW
  2192.      (http://www.fh-wolfenbuettel.de/ftp/pub/database/mysql/) FTP
  2193.      (ftp://ftp.fh-wolfenbuettel.de/pub/database/mysql/)
  2194.  
  2195.    *  Germany [Staufen]   WWW (http://mysql.staufen.de/)
  2196.  
  2197.    *  Germany [Cable & Wireless]   FTP
  2198.      (ftp://ftp.ecrc.net/pub/database/mysql/)
  2199.  
  2200.    *  Greece [NTUA, Athens]   WWW (http://www.ntua.gr/mysql/) FTP
  2201.      (ftp://ftp.ntua.gr/pub/databases/mysql/)
  2202.  
  2203.    *  Island [GM]   WWW (http://mysql.gm.is/) WWW
  2204.      (ftp://ftp.gm.is/pub/mysql)
  2205.  
  2206.    *  Italy [Teta Srl]   WWW (http://www.teta.it/mysql/)
  2207.  
  2208.    *  Ireland [Ireland On-Line/Dublin]   WWW (http://mysql.iol.ie) FTP
  2209.      (ftp://ftp.iol.ie/pub/mysql)
  2210.  
  2211.    *  Poland [Sunsite]   WWW (http://sunsite.icm.edu.pl/mysql/) FTP
  2212.      (ftp://sunsite.icm.edu.pl/pub/unix/mysql/)
  2213.  
  2214.    *  Portugal [lerianet]   WWW (http://mysql.leirianet.pt) FTP
  2215.      (ftp://ftp.leirianet.pt/pub/mysql/)
  2216.  
  2217.    *  Russia [DirectNet]   WWW (http://mysql.directnet.ru) FTP
  2218.      (ftp://ftp.dn.ru/pub/MySQL)
  2219.  
  2220.    *  Russia [IZHCOM]   WWW (http://mysql.udm.net/) FTP
  2221.      (ftp://ftp.izhcom.ru/pub/mysql/)
  2222.  
  2223.    *  Russia [Scientific Center/Chernogolovka]   FTP
  2224.      (ftp://ftp.chg.ru/pub/databases/mysql/)
  2225.  
  2226.    *  Romania [Timisoara]   WWW (http://www.dnttm.ro/mysql) FTP
  2227.      (ftp://ftp.dnttm.ro/pub/mysql)
  2228.  
  2229.    *  Romania [Bucharest]   WWW (http://www.lbi.ro/MySQL) FTP
  2230.      (ftp://ftp.lbi.ro/mirrors/ftp.tcx.se)
  2231.  
  2232.    *  Sweden [Sunet]   WWW
  2233.      (http://ftp.sunet.se/pub/unix/databases/relational/mysql/) FTP
  2234.      (ftp://ftp.sunet.se/pub/unix/databases/relational/mysql/)
  2235.  
  2236.    *  Switzerland [Sunsite]   WWW
  2237.      (http://sunsite.cnlab-switch.ch/ftp/mirror/mysql/) FTP
  2238.      (ftp://sunsite.cnlab-switch.ch/mirror/mysql/)
  2239.  
  2240.    *  UK [Omnipotent/UK]   WWW (http://mysql.omnipotent.net/) FTP
  2241.      (ftp://mysql.omnipotent.net/)
  2242.  
  2243.    *  UK [PLiG/UK]   WWW (http://ftp.plig.org/pub/mysql/) FTP
  2244.      (ftp://ftp.plig.org/pub/mysql/)
  2245.  
  2246.    *  UK [SunSITE]  WWW (http://sunsite.org.uk/packages/mysql/) FTP
  2247.      (ftp://sunsite.org.uk/packages/mysql/)
  2248.  
  2249.    *  Ukraine [PACO]  WWW (http://mysql.paco.net.ua) FTP
  2250.      (ftp://mysql.paco.net.ua/)
  2251.  
  2252.  
  2253. *North America:*
  2254.  
  2255.    *  Canada [Tryc]   WWW (http://web.tryc.on.ca/mysql/)
  2256.  
  2257.    *  Canada [Cyberus]   WWW (http://mysql.cyberus.ca/) FTP
  2258.      (ftp://mysql.cyberus.ca/)
  2259.  
  2260.    *  USA [Hurricane Electric/San Jose]   WWW (http://mysql.he.net)
  2261.  
  2262.    *  USA [Meltzer/New York State]   FTP
  2263.      (ftp://ftp.meltzer.org/pub/mysql/)
  2264.  
  2265.    *  USA [Circle Net/North Carolina]   WWW (http://www.mysql.net)
  2266.  
  2267.    *  USA [Gina net/Florida]   WWW (http://www.gina.net/mysql/)
  2268.  
  2269.    *  USA [Wisconsin University/Wisconsin]  WWW
  2270.      (http://mirror.sit.wisc.edu/mysql/) FTP
  2271.      (ftp://mirror.sit.wisc.edu/mirrors/mysql/)
  2272.  
  2273.    *  USA [DIGEX]   FTP
  2274.      (ftp://ftp.digex.net/pub/packages/database/mysql/)
  2275.  
  2276.    *  USA [LinuxWired/Scottsdale, AZ]  WWW
  2277.      (http://mysql.linuxwired.net/) FTP
  2278.      (ftp://ftp.linuxwired.net/pub/mirrors/mysql/)
  2279.  
  2280.  
  2281. *South America:*
  2282.  
  2283.    *  Brazil [Matrix]   WWW (http://mysql.matrix.com.br)
  2284.  
  2285.    *  Chile [Vision]   WWW (http://mysql.vision.cl/)
  2286.  
  2287.  
  2288. *Asia:*
  2289.  
  2290.    *  China [Freecode]   WWW (http://mysql.freecode.com.cn)
  2291.  
  2292.    *  China [Hong Kong]  WWW (http://mysql.islnet.net)
  2293.  
  2294.    *  China [Netfirm]   WWW (http://mysql.netfirm.net)
  2295.  
  2296.    *  Korea [KREONet]   WWW (http://linux.kreonet.re.kr/mysql/)
  2297.  
  2298.    *  Japan [Soft Agency]   WWW (http://www.softagency.co.jp/MySQL)
  2299.  
  2300.    *  Japan [Nagoya Syouka University]   WWW
  2301.      (http://mirror.nucba.ac.jp/mirror/mysql) FTP
  2302.      (ftp://mirror.nucba.ac.jp/mirror/mysql)
  2303.  
  2304.    *  Singapore [HJC]  WWW (http://mysql.hjc.edu.sg) FTP
  2305.      (ftp://ftp.hjc.edu.sg/mysql)
  2306.  
  2307.    *  Taiwan [HT]   WWW (http://mysql.ht.net.tw)
  2308.  
  2309.    *  Taiwan [TTN]   WWW (http://mysql.ttn.net)
  2310.  
  2311.  
  2312. *Australia:*
  2313.  
  2314.    *  Australia [AARNet/Queensland]   WWW
  2315.      (http://mirror.aarnet.edu.au/mysql) FTP
  2316.      (ftp://mirror.aarnet.edu.au/pub/mysql)
  2317.  
  2318.    *  Australia [Blue Planet/Melbourne]   WWW (http://mysql.bluep.com/)
  2319.  
  2320.    *  Australia [ITworks Consulting/Victoria]   WWW
  2321.      (http://mysql.itworks.com.au)
  2322.  
  2323.  
  2324. *Africa:*
  2325.  
  2326.    *  South-Africa [Mweb/]   WWW (http://www.mysql.mweb.co.za)
  2327.  
  2328.    *  South-Africa [The Internet Solution/Johannesburg]   FTP
  2329.      (ftp://ftp.is.co.za/linux/mysql/)
  2330.  
  2331.  
  2332. Operating systems supported by MySQL
  2333. ====================================
  2334.  
  2335. We use GNU Autoconf so it is possible to port *MySQL* to all modern
  2336. systems with working Posix threads and a C++ compiler. (To compile only
  2337. the client code, a C++ compiler is required but not threads.)  We use
  2338. and develop the software ourselves primarily on Sun Solaris (versions
  2339. 2.5 & 2.6) and to a lesser extent on RedHat Linux 5.0.
  2340.  
  2341. *MySQL* has been reported to compile sucessfully on the following
  2342. operating system/thread package combinations.  Note that for many
  2343. operating systems, the native thread support works only in the latest
  2344. versions.
  2345.  
  2346.    * AIX 4.x with native threads. *Note IBM-AIX::.
  2347.  
  2348.    * BSDI 2.x with the included MIT-pthreads package. *Note BSDI::.
  2349.  
  2350.    * BSDI 3.0, 3.1 and 4.x with native threads. *Note BSDI::.
  2351.  
  2352.    * DEC UNIX 4.x with native threads. *Note Alpha-DEC-Unix::.
  2353.  
  2354.    * FreeBSD 2.x with the included MIT-pthreads package. *Note
  2355.      FreeBSD::.
  2356.  
  2357.    * FreeBSD 3.x with native threads. *Note BSDI::.
  2358.  
  2359.    * HP-UX 10.20 with the included MIT-pthreads package. *Note HP-UX
  2360.      10.20::.
  2361.  
  2362.    * HP-UX 11.x with the native threads. *Note HP-UX 11.x::.
  2363.  
  2364.    * Linux 2.0+ with LinuxThreads 0.7.1 or `glibc' 2.0.7 . *Note
  2365.      Linux::.
  2366.  
  2367.    * MacOS X Server. *Note MacOSX::.
  2368.  
  2369.    * NetBSD 1.3/1.4 Intel and NetBSD 1.3 Alpha (Requires GNU make).
  2370.      *Note NetBSD::.
  2371.  
  2372.    * OpenBSD > 2.5 with native therads. OpenBSD < 2.5 with the included
  2373.      MIT-pthreads package. *Note OpenBSD::.
  2374.  
  2375.    * OS/2 Warp 3, FixPack 29 and OS/2 Warp 4, FixPack 4. *Note OS/2::.
  2376.  
  2377.    * SGI Irix 6.x with native threads. *Note SGI-Irix::.
  2378.  
  2379.    * Solaris 2.5 and above with native threads on SPARC and x86. *Note
  2380.      Solaris::.
  2381.  
  2382.    * SunOS 4.x with the included MIT-pthreads package. *Note Solaris::.
  2383.  
  2384.    * SCO OpenServer with a recent port of the FSU Pthreads package.
  2385.      *Note SCO::.
  2386.  
  2387.    * SCO UnixWare 7.0.1. *Note SCO Unixware::.
  2388.  
  2389.    * Tru64 Unix
  2390.  
  2391.    * Win95, Win98, NT and Win2000. *Note Win32::.
  2392.  
  2393. Which MySQL version to use
  2394. ==========================
  2395.  
  2396. The first decision to make is whether you want to use the latest
  2397. development release or the last stable release:
  2398.  
  2399.    * Normally, if you are beginning to use *MySQL* for the first time
  2400.      or trying to port it to some system for which there is no binary
  2401.      distribution, we recommend going with the development release
  2402.      (currently 3.23.22-beta. This is because there are usually no
  2403.      really serious bugs in the development release, and you can easily
  2404.      test it on your machine with the `crash-me' and benchmark tests.
  2405.      *Note Benchmarks::.  Note that all *MySQL* releases are checked
  2406.      with the *MySQL* benchmarks and an extensive test suite before
  2407.      each release.
  2408.  
  2409.    * Otherwise, if you are running an old system and want to upgrade,
  2410.      but don't want to take chances with the development version, you
  2411.      should upgrade to the latest in the same branch you are using
  2412.      (where only the last version number is newer than yours).  We have
  2413.      tried to fix only fatal bugs and make small, relatively safe
  2414.      changes to that version.
  2415.  
  2416. The second decision to make is whether you want to use a source
  2417. distribution or a binary distribution:
  2418.  
  2419.    * If you want to run *MySQL* on a platform for which a current binary
  2420.      distribution exists, use that.  Generally, it will be easier to
  2421.      install than a source distribution.
  2422.  
  2423.    * If you want to read (and/or modify) the C and C++ code that makes
  2424.      up *MySQL*, you should get a source distribution. The source code
  2425.      is always the ultimate manual. Source distributions also contain
  2426.      more tests and examples than binary distributions.
  2427.  
  2428. The *MySQL* naming scheme uses release numbers that consist of three
  2429. numbers and a suffix.  For example, a release name like
  2430. `mysql-3.21.17-beta' is interpreted like this:
  2431.  
  2432.    * The first number (`3') describes the file format.  All version 3
  2433.      releases have the same file format. When a version 4 appears, every
  2434.      table will have to be converted to the new format (nice tools for
  2435.      this will be included, of course).
  2436.  
  2437.    * The second number (`21') is the release level. Normally there are
  2438.      two to choose from. One is the release/stable branch (currently
  2439.      `22') and the other is the development branch (currently `23') .
  2440.      Normally both are stable, but the development version may have
  2441.      quirks, missing documentation on new features or may fail to
  2442.      compile on some systems.
  2443.  
  2444.    * The third number (`17') is the version number within the release
  2445.      level. This is incremented for each new distribution. Usually you
  2446.      want the latest version for the release level you have choosen.
  2447.  
  2448.    * The suffix (`beta') indicates the stability level of the release.
  2449.      The possible suffixes are:
  2450.  
  2451.         - `alpha' indicates that the release contains some large
  2452.           section of new code that hasn't been 100% tested.  Known bugs
  2453.           (usually there are none) should be documented in the News
  2454.           section.  *Note News::.  There are also new commands and
  2455.           extensions in most alpha releases.  Active development that
  2456.           may involve major code changes can occur on an alpha release,
  2457.           but everything will be tested before doing a release.  There
  2458.           should be no known bugs in any `MySQL' release.
  2459.  
  2460.         - `beta' means that all new code has been tested. No major new
  2461.           features that could cause corruption on old code are added.
  2462.           There should be no known bugs.  A version changes from alpha
  2463.           to beta when there haven't been any reported fatal bugs
  2464.           within an alpha version for at least a month and we don't
  2465.           plan to add any features that could make any old command more
  2466.           unreliable.
  2467.  
  2468.         - `gamma' is a beta that has been around a while and seems to
  2469.           work fine.  Only minor fixes are added. This is what many
  2470.           other companies call a release.
  2471.  
  2472.         - If there is no suffix, it means that the version has been run
  2473.           for a while at many different sites with no reports of bugs
  2474.           other than platform-specific bugs.  Only critical bug fixes
  2475.           are applied to the release. This is what we call a stable
  2476.           release.
  2477.  
  2478. All versions of *MySQL* are run through our standard tests and
  2479. benchmarks to ensure that they are relatively safe to use.  Because the
  2480. standard tests are extended over time to check for all previously found
  2481. bugs, the test suite keeps getting better.
  2482.  
  2483. Note that all releases have been tested at least with:
  2484.  
  2485. An internal test suite
  2486.      This is part of a production system for a customer. It has many
  2487.      tables with hundreds of megabytes of data.
  2488.  
  2489. The *MySQL* benchmark suite
  2490.      This runs a range of common queries. It is also a test to see
  2491.      whether the latest batch of optimizations actually made the code
  2492.      faster.  *Note Benchmarks::.
  2493.  
  2494. The `crash-me' test
  2495.      This tries to determine what features the database supports and
  2496.      what its capabilities and limitations are.  *Note Benchmarks::.
  2497.  
  2498. Another test is that we use the newest *MySQL* version in our internal
  2499. production environment, on at least one machine.  We have more than 100
  2500. gigabytes of data to work with.
  2501.  
  2502. How and when updates are released
  2503. =================================
  2504.  
  2505. *MySQL* is evolving quite rapidly here at MySQL AB and we want to share
  2506. this with other *MySQL* users. We try to make a release when we have
  2507. very useful features that others seem to have a need for.
  2508.  
  2509. We also try to help out users who request features that are easy to
  2510. implement. We also take note of what our licensed users want to have and
  2511. we especially take note of what our extended email supported customers
  2512. want and try to help them out.
  2513.  
  2514. No one has to download a new release. The News section will tell you if
  2515. the new release has something you really want. *Note News::.
  2516.  
  2517. We use the following policy when updating *MySQL*:
  2518.  
  2519.    * For each minor update, the last number in the version string is
  2520.      incremented.  When there are major new features or minor
  2521.      incompatibilities with previous versions, the second number in the
  2522.      version string is incremented. When the file format changes, the
  2523.      first number is increased.
  2524.  
  2525.    * Stable tested releases are meant to appear about 1-2 times a year,
  2526.      but if small bugs are found, a release with only bug-fixes will be
  2527.      released.
  2528.  
  2529.    * Working releases are meant to appear about every 1-8 weeks.
  2530.  
  2531.    * Binary distributions for some platforms will be made by us for
  2532.      major releases.  Other people may make binary distributions for
  2533.      other systems but probably less frequently.
  2534.  
  2535.    * We usually make patches available as soon as we have located and
  2536.      fixed small bugs.
  2537.  
  2538.    * For non-critical but annoying bugs, we will make patches available
  2539.      if they are sent to us. Otherwise we will combine many of them
  2540.      into a larger patch.
  2541.  
  2542.    * If there is, by any chance, a fatal bug in a release we will make
  2543.      a new release as soon as possible. We would like other companies
  2544.      to do this, too. :)
  2545.  
  2546. The current stable release is 3.22; We have already moved active
  2547. development to 3.23. Bugs will still be fixed in the stable version. We
  2548. don't believe in a complete freeze, as this also leaves out bug fixes
  2549. and things that "must be done". "Somewhat frozen" means that we may add
  2550. small things that "almost surely will not affect anything that's
  2551. already working".
  2552.  
  2553. Installation layouts
  2554. ====================
  2555.  
  2556. This section describes the default layout of the directories created by
  2557. installing binary and source distributions.
  2558.  
  2559. A binary distribution is installed by unpacking it at the installation
  2560. location you choose (typically `/usr/local/mysql') and creates the
  2561. following directories in that location:
  2562.  
  2563. *Directory*            *Contents of directory*
  2564. `bin'                  Client programs and the `mysqld' server
  2565. `data'                 Log files, databases
  2566. `include'              Include (header) files
  2567. `lib'                  Libraries
  2568. `scripts'              `mysql_install_db'
  2569. `share/mysql'          Error message files
  2570. `sql-bench'            Benchmarks
  2571.  
  2572. A source distribution is installed after you configure and compile it.
  2573. By default, the installation step installs files under `/usr/local', in
  2574. the following subdirectories:
  2575.  
  2576. *Directory*            *Contents of directory*
  2577. `bin'                  Client programs and scripts
  2578. `include/mysql'        Include (header) files
  2579. `info'                 Documentation in Info format
  2580. `lib/mysql'            Libraries
  2581. `libexec'              The `mysqld' server
  2582. `share/mysql'          Error message files
  2583. `sql-bench'            Benchmarks and `crash-me' test
  2584. `var'                  Databases and log files.
  2585.  
  2586. Within an installation directory, the layout of a source installation
  2587. differs from that of a binary installation in the following ways:
  2588.  
  2589.    * The `mysqld' server is installed in the `libexec' directory rather
  2590.      than in the `bin' directory.
  2591.  
  2592.    * The data directory is `var' rather than `data'.
  2593.  
  2594.    * `mysql_install_db' is installed in the `/usr/local/bin' directory
  2595.      rather than in `/usr/local/mysql/scripts'.
  2596.  
  2597.    * The header file and library directories are `include/mysql' and
  2598.      `lib/mysql' rather than `include' and `lib'.
  2599.  
  2600. You can create your own binary installation from a compiled source
  2601. distribution, by executing the script
  2602. `scripts/make_binary_distribution'.
  2603.  
  2604. Installing a MySQL binary distribution
  2605. ======================================
  2606.  
  2607. You need the following tools to install a *MySQL* binary distribution:
  2608.  
  2609.    * GNU `gunzip' to uncompress the distribution.
  2610.  
  2611.    * A reasonable `tar' to unpack the distribution. GNU `tar' is known
  2612.      to work.
  2613.  
  2614. An alternative installation method under Linux is to use RPM (RedHat
  2615. Package Manager) distributions. *Note Linux-RPM::.
  2616.  
  2617. If you run into problems, *PLEASE ALWAYS USE* `mysqlbug' when posting
  2618. questions to <mysql@lists.mysql.com>.  Even if the problem isn't a bug,
  2619. `mysqlbug' gathers system information that will help others solve your
  2620. problem.  By not using `mysqlbug', you lessen the likelihood of getting
  2621. a solution to your problem!  You will find `mysqlbug' in the `bin'
  2622. directory after you unpack the distribution.  *Note Bug reports::.
  2623.  
  2624. The basic commands you must execute to install and use a *MySQL* binary
  2625. distribution are:
  2626.  
  2627.      shell> gunzip < mysql-VERSION-OS.tar.gz | tar xvf -
  2628.      shell> ln -s mysql-VERSION-OS mysql
  2629.      shell> cd mysql
  2630.      shell> scripts/mysql_install_db
  2631.      shell> bin/safe_mysqld &
  2632.  
  2633. You can add new users using the `bin/mysql_setpermission' script if you
  2634. install the `DBI' and `Msql-Mysql-modules' Perl modules.
  2635.  
  2636. Here follows a more detailed description:
  2637.  
  2638. To install a binary distribution, follow the steps below, then proceed
  2639. to *Note Post-installation::, for post-installation setup and testing:
  2640.  
  2641.   1. Pick the directory under which you want to unpack the
  2642.      distribution, and move into it.  In the example below, we unpack
  2643.      the distribution under `/usr/local' and create a directory
  2644.      `/usr/local/mysql' into which *MySQL* is installed.  (The
  2645.      following instructions therefore assume you have permission to
  2646.      create files in `/usr/local'.  If that directory is protected, you
  2647.      will need to perform the installation as `root'.)
  2648.  
  2649.   2. Obtain a distribution file from one of the sites listed in *Note
  2650.      Getting *MySQL*: Getting MySQL.
  2651.  
  2652.      *MySQL* binary distributions are provided as compressed `tar'
  2653.      archives and have names like `mysql-VERSION-OS.tar.gz', where
  2654.      `VERSION' is a number (e.g., `3.21.15'), and `OS' indicates the
  2655.      type of operating system for which the distribution is intended
  2656.      (e.g., `pc-linux-gnu-i586').
  2657.  
  2658.   3. Unpack the distribution and create the installation directory:
  2659.  
  2660.           shell> gunzip < mysql-VERSION-OS.tar.gz | tar xvf -
  2661.           shell> ln -s mysql-VERSION-OS mysql
  2662.  
  2663.      The first command creates a directory named `mysql-VERSION-OS'.
  2664.      The second command makes a symbolic link to that directory.  This
  2665.      lets you refer more easily to the installation directory as
  2666.      `/usr/local/mysql'.
  2667.  
  2668.   4. Change into the installation directory:
  2669.  
  2670.           shell> cd mysql
  2671.  
  2672.      You will find several files and subdirectories in the `mysql'
  2673.      directory.  The most important for installation purposes are the
  2674.      `bin' and `scripts' subdirectories.
  2675.  
  2676.     `bin'
  2677.           This directory contains client programs and the server You
  2678.           should add the full pathname of this directory to your `PATH'
  2679.           environment variable so that your shell finds the *MySQL*
  2680.           programs properly. *Note Environment variables::.
  2681.  
  2682.     `scripts'
  2683.           This directory contains the `mysql_install_db' script used to
  2684.           initialize the server access permissions.
  2685.  
  2686.   5. If you would like to use `mysqlaccess' and have the *MySQL*
  2687.      distribution in some nonstandard place, you must change the
  2688.      location where `mysqlaccess' expects to find the `mysql' client.
  2689.      Edit the `bin/mysqlaccess' script at approximately line 18. Search
  2690.      for a line that looks like this:
  2691.  
  2692.           $MYSQL     = '/usr/local/bin/mysql';    # path to mysql executable
  2693.  
  2694.      Change the path to reflect the location where `mysql' actually is
  2695.      stored on your system.  If you do not do this, you will get a
  2696.      `broken pipe' error when you run `mysqlaccess'.
  2697.  
  2698.   6. Create the *MySQL* grant tables (necessary only if you haven't
  2699.      installed *MySQL* before):
  2700.           shell> scripts/mysql_install_db
  2701.  
  2702.      Note that *MySQL* versions older than 3.22.10 started the *MySQL*
  2703.      server when you run `mysql_install_db'.  This is no longer true!
  2704.  
  2705.   7. If you want to install support for the Perl `DBI'/`DBD' interface,
  2706.      see *Note Perl support::.
  2707.  
  2708.   8. If you would like *MySQL* to start automatically when you boot your
  2709.      machine, you can copy `support-files/mysql.server' to the location
  2710.      where your system has its startup files. More information can be
  2711.      found in the `support-files/mysql.server' script itself, and in
  2712.      *Note Automatic start::.
  2713.  
  2714.  
  2715. After everything has been unpacked and installed, you should initialize
  2716. and test your distribution.
  2717.  
  2718. You can start the *MySQL* server with the following command:
  2719.  
  2720.      shell> bin/safe_mysqld &
  2721.  
  2722. *Note Post-installation::.
  2723.  
  2724. Linux RPM notes
  2725. ---------------
  2726.  
  2727. The recommended way to install *MySQL* on Linux is by using an RPM
  2728. file. The *MySQL* RPMs are currently being built on a RedHat 5.2 system
  2729. but should work on other versions of Linux that support `rpm' and use
  2730. `glibc'.
  2731.  
  2732. If you have problems with an RPM file, for example `Sorry, the host
  2733. 'xxxx' could not be looked up', see *Note Binary notes-Linux::.
  2734.  
  2735. The RPM files you may want to use are:
  2736.  
  2737.    * `MySQL-VERSION.i386.rpm'
  2738.  
  2739.      The *MySQL* server.  You will need this unless you only want to
  2740.      connect to another *MySQL* server running on another machine.
  2741.  
  2742.    * `MySQL-client-VERSION.i386.rpm'
  2743.  
  2744.      The standard *MySQL* client programs. You probably always want to
  2745.      install this package.
  2746.  
  2747.    * `MySQL-bench-VERSION.i386.rpm'
  2748.  
  2749.      Tests and benchmarks. Requires Perl and msql-mysql-modules RPMs.
  2750.  
  2751.    * `MySQL-devel-VERSION.i386.rpm'
  2752.  
  2753.      Libraries and include files needed if you want to compile other
  2754.      *MySQL* clients, such as the Perl modules.
  2755.  
  2756.    * `MySQL-VERSION.src.rpm'
  2757.  
  2758.      This contains the source code for all of the above packages. It
  2759.      can also be used to try to build RPMs for other architectures (for
  2760.      example, Alpha or SPARC).
  2761.  
  2762. To see all files in an RPM package:
  2763.      shell> rpm -qpl MySQL-VERSION.i386.rpm
  2764.  
  2765. To perform a standard minimal installation, run this command:
  2766.  
  2767.      shell> rpm -i MySQL-VERSION.i386.rpm MySQL-client-VERSION.i386.rpm
  2768.  
  2769. To install just the client package:
  2770.  
  2771.      shell> rpm -i MySQL-client-VERSION.i386.rpm
  2772.  
  2773. The RPM places data in `/var/lib/mysql'. The RPM also creates the
  2774. appropriate entries in `/etc/rc.d/' to start the server automatically
  2775. at boot time.  (This means that if you have performed a previous
  2776. installation, you may want to make a copy of your previously-installed
  2777. *MySQL* startup file if you made any changes to it, so you don't lose
  2778. your changes.)
  2779.  
  2780. After installing the RPM file(s), the `mysqld' daemon should be running
  2781. and you should now be able to start using *MySQL*.  *Note
  2782. Post-installation::.
  2783.  
  2784. If something goes wrong, can find more information in the binary
  2785. installation chapter. *Note Installing binary::.
  2786.  
  2787. Building client programs
  2788. ------------------------
  2789.  
  2790. If you compile *MySQL* clients that you've written yourself or that you
  2791. obtain from a third party, they must be linked using the
  2792. `-lmysqlclient' option on the link command.  You may also need to
  2793. specify a `-L' option to tell the linker where to find the library.  For
  2794. example, if the library is installed in `/usr/local/mysql/lib', use
  2795. `-L/usr/local/mysql/lib -lmysqlclient' on the link command.
  2796.  
  2797. For clients that use *MySQL* header files, you may need to specify a
  2798. `-I' option when you compile them (for example,
  2799. `-I/usr/local/mysql/include'), so the compiler can find the header
  2800. files.
  2801.  
  2802. System-specific issues
  2803. ----------------------
  2804.  
  2805. The following sections indicate some of the issues that have been
  2806. observed on particular systems when installing *MySQL* from a binary
  2807. distribution.
  2808.  
  2809. Linux notes
  2810. ...........
  2811.  
  2812. *MySQL* needs at least Linux 2.0.
  2813.  
  2814. The binary release is linked with `-static', which means you not
  2815. normally need not worry about which version of the system libraries you
  2816. have. You need not install LinuxThreads, either.  A program linked with
  2817. `-static' is slightly bigger than a dynamically-linked program but also
  2818. slightly faster (3-5%).  One problem however is that you can't use user
  2819. definable functions (UDFs) with a statically-linked program.  If you
  2820. are going to write or use UDF functions (this is something only for C
  2821. or C++ programmers) you must compile *MySQL* yourself, using dynamic
  2822. linking.
  2823.  
  2824. If you are using a `libc'-based system (instead of a `glibc2' system),
  2825. you will probably get some problems with hostname resolving and
  2826. getpwnam() with the binary release. (This is because `glibc'
  2827. unfortunately depends on some external libraries to resolve hostnames
  2828. and getwpent() , even when compiled with `-static'). In this case you
  2829. probably get the following error message when you run
  2830. `mysql_install_db':
  2831.  
  2832.      Sorry, the host 'xxxx' could not be looked up
  2833.  
  2834. or the following error when you try to run mysqld with the `--user'
  2835. option:
  2836.  
  2837.      getpwnam: No such file or directory
  2838.  
  2839. You can solve this problem one of the following ways:
  2840.  
  2841.    * Get a *MySQL* source distribution (an RPM or the `tar'
  2842.      distribution) and install this instead.
  2843.  
  2844.    * Execute `mysql_install_db --force'; This will not execute the
  2845.      `resolveip' test in `mysql_install_db'.  The downside is that you
  2846.      can't use host names in the grant tables; you must use IP numbers
  2847.      instead (except for `localhost').  If you are using an old *MySQL*
  2848.      release that doesn't support `--force' you have to remove the
  2849.      `resolveip' test in `mysql_install' with an editor.
  2850.  
  2851.    * Start mysqld with `su' instead of using `--user'.
  2852.  
  2853. The Linux-Intel binary and RPM releases of *MySQL* are configured for
  2854. the highest possible speed. We are always trying to use the fastest
  2855. stable compiler available.
  2856.  
  2857. *MySQL* Perl support requires Perl 5.004_03 or newer.
  2858.  
  2859. HP-UX notes
  2860. ...........
  2861.  
  2862. Some of the binary distributions of *MySQL* for HP-UX is distributed as
  2863. an HP depot file and as a tar file.  To use the depot file you must be
  2864. running at least HP-UX 10.x to have access to HP's software depot tools.
  2865.  
  2866. The HP version of *MySQL* was compiled on an HP 9000/8xx server under
  2867. HP-UX 10.20, and uses MIT-pthreads. It is known to work well under this
  2868. configuration.  *MySQL* 3.22.26 and newer can also be built with HP's
  2869. native thread package.
  2870.  
  2871. Other configurations that may work:
  2872.  
  2873.    * HP 9000/7xx running HP-UX 10.20+
  2874.  
  2875.    * HP 9000/8xx running HP-UX 10.30
  2876.  
  2877. The following configurations almost definitely won't work:
  2878.  
  2879.    * HP 9000/7xx or 8xx running HP-UX 10.x where x < 2
  2880.  
  2881.    * HP 9000/7xx or 8xx running HP-UX 9.x
  2882.  
  2883. To install the distribution, use one of the commands below, where
  2884. `/path/to/depot' is the full pathname of the depot file:
  2885.  
  2886.    * To install everything, including the server, client and
  2887.      development tools:
  2888.  
  2889.           shell> /usr/sbin/swinstall -s /path/to/depot mysql.full
  2890.  
  2891.    * To install only the server:
  2892.  
  2893.           shell> /usr/sbin/swinstall -s /path/to/depot mysql.server
  2894.  
  2895.    * To install only the client package:
  2896.  
  2897.           shell> /usr/sbin/swinstall -s /path/to/depot mysql.client
  2898.  
  2899.    * To install only the development tools:
  2900.  
  2901.           shell> /usr/sbin/swinstall -s /path/to/depot mysql.developer
  2902.  
  2903. The depot places binaries and libraries in `/opt/mysql' and data in
  2904. `/var/opt/mysql'. The depot also creates the appropriate entries in
  2905. `/sbin/init.d' and `/sbin/rc2.d' to start the server automatically at
  2906. boot time. Obviously, this entails being `root' to install.
  2907.  
  2908. To install the HP-UX tar distribution, you must have a copy of GNU
  2909. `tar'.
  2910.  
  2911. Installing a MySQL source distribution
  2912. ======================================
  2913.  
  2914. You need the following tools to build and install *MySQL* from source:
  2915.  
  2916.    * GNU `gunzip' to uncompress the distribution.
  2917.  
  2918.    * A reasonable `tar' to unpack the distribution. GNU `tar' is known
  2919.      to work.
  2920.  
  2921.    * A working ANSI C++ compiler. `gcc' >= 2.8.1, `egcs' >= 1.0.2, SGI
  2922.      C++ and SunPro C++ are some of the compilers that are known to
  2923.      work.  `libg++' is not needed when using `gcc'.  `gcc' 2.7.x has a
  2924.      bug that makes it impossible to compile some perfectly legal C++
  2925.      files, such as `sql/sql_base.cc'. If you only have `gcc' 2.7.x,
  2926.      you must upgrade your `gcc' to be able to compile *MySQL*.
  2927.  
  2928.    * A good `make' program.  GNU `make' is always recommended and is
  2929.      sometimes required.  If you have problems, we recommend trying GNU
  2930.      `make' 3.75 or newer.
  2931.  
  2932. If you run into problems, *PLEASE ALWAYS USE `mysqlbug'* when posting
  2933. questions to <mysql@lists.mysql.com>.  Even if the problem isn't a bug,
  2934. `mysqlbug' gathers system information that will help others solve your
  2935. problem.  By not using `mysqlbug', you lessen the likelihood of getting
  2936. a solution to your problem!  You will find `mysqlbug' in the `scripts'
  2937. directory after you unpack the distribution.  *Note Bug reports::.
  2938.  
  2939. Quick installation overview
  2940. ---------------------------
  2941.  
  2942. The basic commands you must execute to install a *MySQL* source
  2943. distribution are (from an unpacked `tar' file):
  2944.  
  2945.      shell> configure
  2946.      shell> make
  2947.      shell> make install
  2948.      shell> scripts/mysql_install_db
  2949.      shell> /usr/local/mysql/bin/safe_mysqld &
  2950.  
  2951. If you start from a source RPM, then do the following.
  2952.  
  2953.      shell> rpm --rebuild MySQL-VERSION.src.rpm
  2954.  
  2955. This will make a binary RPM that you can install.
  2956.  
  2957. You can add new users using the `bin/mysql_setpermission' script if you
  2958. install the `DBI' and `Msql-Mysql-modules' Perl modules.
  2959.  
  2960. Here follows a more detailed description:
  2961.  
  2962. To install a source distribution, follow the steps below, then proceed
  2963. to *Note Post-installation::, for post-installation initialization and
  2964. testing.
  2965.  
  2966.   1. Pick the directory under which you want to unpack the
  2967.      distribution, and move into it.
  2968.  
  2969.   2. Obtain a distribution file from one of the sites listed in *Note
  2970.      Getting *MySQL*: Getting MySQL.
  2971.  
  2972.      *MySQL* source distributions are provided as compressed `tar'
  2973.      archives and have names like `mysql-VERSION.tar.gz', where
  2974.      `VERSION' is a number like 3.23.22-beta.
  2975.  
  2976.   3. Unpack the distribution into the current directory:
  2977.           shell> gunzip < mysql-VERSION.tar.gz | tar xvf -
  2978.      This command creates a directory named `mysql-VERSION'.
  2979.  
  2980.   4. Change into the top-level directory of the unpacked distribution:
  2981.           shell> cd mysql-VERSION
  2982.  
  2983.   5. Configure the release and compile everything:
  2984.           shell> ./configure --prefix=/usr/local/mysql
  2985.           shell> make
  2986.      When you run `configure', you might want to specify some options.
  2987.      Run `./configure --help' for a list of options.  *Note `configure'
  2988.      options: configure options, discusses some of the more useful
  2989.      options.
  2990.  
  2991.      If `configure' fails, and you are going to send mail to
  2992.      <mysql@lists.mysql.com> to ask for assistance, please include any
  2993.      lines from `config.log' that you think can help solve the problem.
  2994.      Also include the last couple of lines of output from `configure'
  2995.      if `configure' aborts. Post the bug report using the `mysqlbug'
  2996.      script.  *Note Bug reports::.
  2997.  
  2998.      If the compile fails, see *Note Compilation problems::, for help
  2999.      with a number of common problems.
  3000.  
  3001.   6. Install everything:
  3002.           shell> make install
  3003.      You might need to run this command as `root'.
  3004.  
  3005.   7. Create the *MySQL* grant tables (necessary only if you haven't
  3006.      installed *MySQL* before):
  3007.           shell> scripts/mysql_install_db
  3008.  
  3009.      Note that *MySQL* versions older than 3.22.10 started the *MySQL*
  3010.      server when you run `mysql_install_db'.  This is no longer true!
  3011.  
  3012.   8. If you want to install support for the Perl `DBI'/`DBD' interface,
  3013.      see *Note Perl support::.
  3014.  
  3015.   9. If you would like *MySQL* to start automatically when you boot your
  3016.      machine, you can copy `support-files/mysql.server' to the location
  3017.      where your system has its startup files. More information can be
  3018.      found in the `support-files/mysql.server' script itself, and in
  3019.      *Note Automatic start::.
  3020.  
  3021. After everything has been installed, you should initialize and test your
  3022. distribution.
  3023.  
  3024. You can start the *MySQL* server with the following command, where
  3025. `BINDIR' is the directory in which `safe_mysqld' is installed
  3026. (`/usr/local/bin' by default):
  3027.  
  3028.      shell> BINDIR/safe_mysqld &
  3029.  
  3030. If that command fails immediately with `mysqld daemon ended' then you
  3031. can find some information in the file
  3032. `mysql-data-directory/'hostname'.err'.  The likely reason is that you
  3033. already have another `mysqld' server running.  *Note Multiple servers::.
  3034.  
  3035. *Note Post-installation::.
  3036.  
  3037. Applying patches
  3038. ----------------
  3039.  
  3040. Sometimes patches appear on the mailing list or are placed in the
  3041. patches area (http://www.mysql.com/Downloads/Patches) of the *MySQL*
  3042. Web site.
  3043.  
  3044. To apply a patch from the mailing list, save the message in which the
  3045. patch appears in a file, change into the top-level directory of your
  3046. *MySQL* source tree and run these commands:
  3047.  
  3048.      shell> patch -p1 < patch-file-name
  3049.      shell> rm config.cache
  3050.      shell> make clean
  3051.  
  3052. Patches from the FTP site are distributed as plain text files or as
  3053. files compressed with `gzip'.  Apply a plain patch as shown above for
  3054. mailing list patches.  To apply a compressed patch, change into the
  3055. top-level directory of your *MySQL* source tree and run these commands:
  3056.  
  3057.      shell> gunzip < patch-file-name.gz | patch -p1
  3058.      shell> rm config.cache
  3059.      shell> make clean
  3060.  
  3061. After applying a patch, follow the instructions for a normal source
  3062. install, beginning with the `./configure' step.  After running the `make
  3063. install' step, restart your *MySQL* server.
  3064.  
  3065. You may need to bring down any currently running server before you run
  3066. `make install'.  (Use `mysqladmin shutdown' to do this.)  Some systems
  3067. do not allow you to install a new version of a program if it replaces
  3068. the version that is currently executing.
  3069.  
  3070. Typical `configure' options
  3071. ---------------------------
  3072.  
  3073. The `configure' script gives you a great deal of control over how you
  3074. configure your *MySQL* distribution.  Typically you do this using
  3075. options on the `configure' command line.  You can also affect
  3076. `configure' using certain environment variables.  *Note Environment
  3077. variables::. For a list of options supported by `configure', run this
  3078. command:
  3079.  
  3080.      shell> ./configure --help
  3081.  
  3082. Some of the more commonly-used `configure' options are described below:
  3083.  
  3084.    * To compile just the *MySQL* client libraries and client programs
  3085.      and not the server, use the `--without-server' option:
  3086.  
  3087.           shell> ./configure --without-server
  3088.  
  3089.      If you don't have a C++ compiler, `mysql' will not compile (it is
  3090.      the one client program that requires C++).  In this case, you can
  3091.      remove the code in `configure' that tests for the C++ compiler and
  3092.      then run `./configure' with the `--without-server' option. The
  3093.      compile step will still try to build `mysql', but you can ignore
  3094.      any warnings about `mysql.cc'.  (If `make' stops, try `make -k' to
  3095.      tell it to continue with the rest of the build even if errors
  3096.      occur.)
  3097.  
  3098.    * If you don't want your log files and database directories located
  3099.      under `/usr/local/var', use a `configure' command something like
  3100.      one of these:
  3101.           shell> ./configure --prefix=/usr/local/mysql
  3102.           shell> ./configure --prefix=/usr/local \
  3103.                      --localstatedir=/usr/local/mysql/data
  3104.      The first command changes the installation prefix so that
  3105.      everything is installed under `/usr/local/mysql' rather than the
  3106.      default of `/usr/local'.  The second command preserves the default
  3107.      installation prefix, but overrides the default location for
  3108.      database directories (normally `/usr/local/var') and changes it to
  3109.      `/usr/local/mysql/data'.
  3110.  
  3111.    * If you are using Unix and you want the *MySQL* socket located
  3112.      somewhere other than the default location (normally in the
  3113.      directory `/tmp' or `/var/run', use a `configure' command like
  3114.      this:
  3115.           shell> ./configure --with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock
  3116.      Note that the given file must be an absolute pathname!
  3117.  
  3118.    * If you want to compile statically-linked programs (e.g., to make a
  3119.      binary distribution, to get more speed or to work around problems
  3120.      with some RedHat distributions), run `configure' like this:
  3121.  
  3122.           shell> ./configure --with-client-ldflags=-all-static \
  3123.                      --with-mysqld-ldflags=-all-static
  3124.  
  3125.    * If you are using `gcc' and don't have `libg++' or `libstdc++'
  3126.      installed, you can tell `configure' to use `gcc' as your C++
  3127.      compiler:
  3128.  
  3129.           shell> CC=gcc CXX=gcc ./configure
  3130.  
  3131.      When you use `gcc' as your C++ compiler, it will not attempt to
  3132.      link in `libg++' or `libstdc++'.
  3133.  
  3134.      If the build fails and produces errors about your compiler or
  3135.      linker not being able to create the shared library
  3136.      `libmysqlclient.so.#' (`#' is a version number), you can work
  3137.      around this problem by giving the `--disable-shared' option to
  3138.      `configure'.  In this case, `configure' will not build a shared
  3139.      `libmysqlclient.so.#' library.
  3140.  
  3141.    * You can configure *MySQL* not to use `DEFAULT' column values for
  3142.      non-`NULL' columns (i.e., columns that are not allowed to be
  3143.      `NULL').  This causes `INSERT' statements to generate an error
  3144.      unless you explicitly specify values for all columns that require a
  3145.      non-`NULL' value.  To suppress use of default values, run
  3146.      `configure' like this:
  3147.  
  3148.           shell> CXXFLAGS=-DDONT_USE_DEFAULT_FIELDS ./configure
  3149.  
  3150.    * By default, *MySQL* uses the ISO-8859-1 (Latin1) character set. To
  3151.      change the default set, use the `--with-charset' option:
  3152.           shell> ./configure --with-charset=CHARSET
  3153.      `CHARSET' may be one of `big5', `cp1251', `cp1257', `czech',
  3154.      `danish',`dec8', `dos', `euc_kr', `gb2312', `gbk', `german1',
  3155.      `hebrew', `hp8', `hungarian', `koi8_ru', `koi8_ukr', `latin1',
  3156.      `latin2', `sjis', `swe7', `tis620', `ujis', `usa7', `win1251' or
  3157.      `win1251ukr'.  *Note Character sets::.
  3158.  
  3159.      If you want to convert characters between the server and the
  3160.      client, you should take a look at the `SET OPTION CHARACTER SET'
  3161.      command.  *Note `SET OPTION': SET OPTION.
  3162.  
  3163.      *Warning:* If you change character sets after having created any
  3164.      tables, you will have to run `myisamchk -r -q' on every table. Your
  3165.      indexes may be sorted incorrectly otherwise.  (This can happen if
  3166.      you install *MySQL*, create some tables, then reconfigure *MySQL*
  3167.      to use a different character set and reinstall it.)
  3168.  
  3169.    * To configure *MySQL* with debugging code, use the `--with-debug'
  3170.      option:
  3171.           shell> ./configure --with-debug
  3172.      This causes a safe memory allocator to be included that can find
  3173.      some errors and that provides output about what is happening.
  3174.      *Note Debugging server::.
  3175.  
  3176.    * If your client programs are using threads, you need to compile the
  3177.      *MySQL* client library to be thread safe with
  3178.      `--with-thread-safe-client'; this forces the library to use thread
  3179.      safe functions calls for some functions that are not thread safe by
  3180.      default. You pay a very small performance penalty by doing this,
  3181.      but generally it's quite safe to use this option.
  3182.  
  3183.    * Options that pertain to particular systems can be found in the
  3184.      system-specific sections later in this chapter.  *Note Source
  3185.      install system issues::.
  3186.  
  3187. Problems compiling?
  3188. ===================
  3189.  
  3190. All *MySQL* programs compile cleanly for us with no warnings on Solaris
  3191. using `gcc'. On other systems, warnings may occur due to differences in
  3192. system include files. See *Note MIT-pthreads::, for warnings that may
  3193. occur when using MIT-pthreads.  For other problems, check the list
  3194. below.
  3195.  
  3196. The solution to many problems involves reconfiguring.  If you do need to
  3197. reconfigure, take note of the following:
  3198.  
  3199.    * If `configure' is run after it already has been run, it may use
  3200.      information that was gathered during its previous invocation.  This
  3201.      information is stored in `config.cache'.  When `configure' starts
  3202.      up, it looks for that file and reads its contents if it exists, on
  3203.      the assumption that the information is still correct.  That
  3204.      assumption is invalid when you reconfigure.
  3205.  
  3206.    * Each time you run `configure', you must run `make' again to
  3207.      recompile.  However, you may want to remove old object files from
  3208.      previous builds first, because they were compiled using different
  3209.      configuration options.
  3210.  
  3211. To prevent old configuration information or object files from being
  3212. used, run these commands before rerunning `configure':
  3213.  
  3214.      shell> rm config.cache
  3215.      shell> make clean
  3216.  
  3217. Alternatively, you can run `make distclean'.
  3218.  
  3219. The list below describes some of the problems compiling *MySQL* that
  3220. have been found to occur most often:
  3221.  
  3222.    * If you get errors when compiling `sql_yacc.cc' such as the ones
  3223.      shown below, you have probably run out of memory or swap space:
  3224.  
  3225.           Internal compiler error: program cc1plus got fatal signal 11
  3226.             or
  3227.           Out of virtual memory
  3228.             or
  3229.           Virtual memory exhausted
  3230.  
  3231.      The problem is that `gcc' requires huge amounts of memory to
  3232.      compile `sql_yacc.cc' with inline functions.  Try running
  3233.      `configure' with the `--with-low-memory' option:
  3234.  
  3235.           shell> ./configure --with-low-memory
  3236.  
  3237.      This option causes `-fno-inline' to be added to the compile line
  3238.      if you are using `gcc' and `-O0' if you are using something else.
  3239.      You should try the `--with-low-memory' option even if you have so
  3240.      much memory and swap space that you think you can't possibly have
  3241.      run out.  This problem has been observed to occur even on systems
  3242.      with generous hardware configurations, and the `--with-low-memory'
  3243.      option usually fixes it.
  3244.  
  3245.    * By default, `configure' picks `c++' as the compiler name and GNU
  3246.      `c++' links with `-lg++'.  If you are using `gcc', that behavior
  3247.      can cause problems during configuration such as this:
  3248.  
  3249.           configure: error: installation or configuration problem:
  3250.           C++ compiler cannot create executables.
  3251.  
  3252.      You might also observe problems during compilation related to
  3253.      `g++', `libg++' or `libstdc++'.
  3254.  
  3255.      One cause of these problems is that you may not have `g++', or you
  3256.      may have `g++' but not `libg++' or `libstdc++'.  Take a look at
  3257.      the `config.log' file.  It should contain the exact reason why
  3258.      your c++ compiler didn't work!  To work around these problems, you
  3259.      can use `gcc' as your C++ compiler.  Try setting the environment
  3260.      variable `CXX' to `"gcc -O3"'.  For example:
  3261.  
  3262.           shell> CXX="gcc -O3" ./configure
  3263.  
  3264.      This works because `gcc' compiles C++ sources as well as `g++'
  3265.      does, but does not link in `libg++' or `libstdc++' by default.
  3266.  
  3267.      Another way to fix these problems, of course, is to install `g++',
  3268.      `libg++' and `libstdc++'.
  3269.  
  3270.    * If your compile fails with errors such as any of the following,
  3271.      you must upgrade your version of `make' to GNU `make':
  3272.  
  3273.           making all in mit-pthreads
  3274.           make: Fatal error in reader: Makefile, line 18:
  3275.           Badly formed macro assignment
  3276.             or
  3277.           make: file `Makefile' line 18: Must be a separator (:
  3278.             or
  3279.           pthread.h: No such file or directory
  3280.  
  3281.      Solaris and FreeBSD are known to have troublesome `make' programs.
  3282.  
  3283.      GNU `make' version 3.75 is known to work.
  3284.  
  3285.    * If you want to define flags to be used by your C or C++ compilers,
  3286.      do so by adding the flags to the `CFLAGS' and `CXXFLAGS'
  3287.      environment variables.  You can also specify the compiler names
  3288.      this way using `CC' and `CXX'.  For example:
  3289.  
  3290.           shell> CC=gcc
  3291.           shell> CFLAGS=-O6
  3292.           shell> CXX=gcc
  3293.           shell> CXXFLAGS=-O6
  3294.           shell> export CC CFLAGS CXX CXXFLAGS
  3295.  
  3296.      See *Note MySQL binaries::, for a list of flag definitions that
  3297.      have been found to be useful on various systems.
  3298.  
  3299.    * If you get an error message like this, you need to upgrade your
  3300.      `gcc' compiler:
  3301.  
  3302.           client/libmysql.c:273: parse error before `__attribute__'
  3303.  
  3304.      `gcc' 2.8.1 is known to work, but we recommend using `gcc' 2.95.2
  3305.      or `egcs' 1.0.3a instead.
  3306.  
  3307.    * If you get errors such as those shown below when compiling
  3308.      `mysqld', `configure' didn't correctly detect the type of the last
  3309.      argument to `accept()', `getsockname()' or `getpeername()':
  3310.  
  3311.           cxx: Error: mysqld.cc, line 645: In this statement, the referenced
  3312.                type of the pointer value "&length" is "unsigned long", which
  3313.                is not compatible with "int".
  3314.           new_sock = accept(sock, (struct sockaddr *)&cAddr, &length);
  3315.  
  3316.      To fix this, edit the `config.h' file (which is generated by
  3317.      `configure').  Look for these lines:
  3318.  
  3319.           /* Define as the base type of the last arg to accept */
  3320.           #define SOCKET_SIZE_TYPE XXX
  3321.  
  3322.      Change `XXX' to `size_t' or `int', depending on your operating
  3323.      system.  (Note that you will have to do this each time you run
  3324.      `configure', because `configure' regenerates `config.h'.)
  3325.  
  3326.    * The `sql_yacc.cc' file is generated from `sql_yacc.yy'.  Normally
  3327.      the build process doesn't need to create `sql_yacc.cc', because
  3328.      *MySQL* comes with an already-generated copy.  However, if you do
  3329.      need to recreate it, you might encounter this error:
  3330.  
  3331.           "sql_yacc.yy", line xxx fatal: default action causes potential...
  3332.  
  3333.      This is a sign that your version of `yacc' is deficient.  You
  3334.      probably need to install `bison' (the GNU version of `yacc') and
  3335.      use that instead.
  3336.  
  3337.    * If you need to debug `mysqld' or a *MySQL* client, run `configure'
  3338.      with the `--with-debug' option, then recompile and link your
  3339.      clients with the new client library.  *Note Debugging client::.
  3340.  
  3341. MIT-pthreads notes
  3342. ==================
  3343.  
  3344. This section describes some of the issues involved in using
  3345. MIT-pthreads.
  3346.  
  3347. Note that on Linux you should NOT use MIT-pthreads but install
  3348. LinuxThreads!  *Note Linux::.
  3349.  
  3350. If your system does not provide native thread support, you will need to
  3351. build *MySQL* using the MIT-pthreads package.  This includes most
  3352. FreeBSD systems, SunOS 4.x, Solaris 2.4 and earlier, and some others.
  3353. *Note Which OS::.
  3354.  
  3355.    * On most systems, you can force MIT-pthreads to be used by running
  3356.      `configure' with the `--with-mit-threads' option:
  3357.  
  3358.           shell> ./configure --with-mit-threads
  3359.  
  3360.      Building in a non-source directory is not supported when using
  3361.      MIT-pthreads, because we want to minimize our changes to this code.
  3362.  
  3363.    * MIT-pthreads doesn't support the `AF_UNIX' protocol used to
  3364.      implement Unix sockets.  This means that if you compile using
  3365.      MIT-pthreads, all connections must be made using TCP/IP (which is
  3366.      a little slower).  If you find after building *MySQL* that you
  3367.      cannot connect to the local server, it may be that your client is
  3368.      attempting to connect to `localhost' using a Unix socket as the
  3369.      default. Try making a TCP/IP connection with `mysql' by using a
  3370.      host option (`-h' or `--host') to specify the local host name
  3371.      explicitly.
  3372.  
  3373.    * The checks that determine whether or not to use MIT-pthreads occur
  3374.      only during the part of the configuration process that deals with
  3375.      the server code.  If you have configured the distribution using
  3376.      `--without-server' to build only the client code, clients will not
  3377.      know whether or not MIT-pthreads is being used and will use Unix
  3378.      socket connections by default.  Because Unix sockets do not work
  3379.      under MIT-pthreads, this means you will need to use `-h' or
  3380.      `--host' when you run client programs.
  3381.  
  3382.    * When *MySQL* is compiled using MIT-pthreads, system locking is
  3383.      disabled by default for performance reasons. You can tell the
  3384.      server to use system locking with the `--use-locking' option.
  3385.  
  3386.    * Sometimes the pthread `bind()' command fails to bind to a socket
  3387.      without any error message (at least on Solaris). The result is
  3388.      that all connections to the server fail.  For example:
  3389.  
  3390.           shell> mysqladmin version
  3391.           mysqladmin: connect to server at '' failed;
  3392.           error: 'Can't connect to mysql server on localhost (146)'
  3393.  
  3394.      The solution to this is to kill the `mysqld' server and restart it.
  3395.      This has only happened to us when we have forced the server down
  3396.      and done a restart immediately.
  3397.  
  3398.    * With MIT-pthreads, the `sleep()' system call isn't interruptible
  3399.      with `SIGINT' (break). This is only noticeable when you run
  3400.      `mysqladmin --sleep'.  You must wait for the `sleep()' call to
  3401.      terminate before the interrupt is served and the process stops.
  3402.  
  3403.    * When linking you may receive warning messages like these (at least
  3404.      on Solaris); they can be ignored:
  3405.  
  3406.           ld: warning: symbol `_iob' has differing sizes:
  3407.               (file /my/local/pthreads/lib/libpthread.a(findfp.o) value=0x4;
  3408.           file /usr/lib/libc.so value=0x140);
  3409.               /my/local/pthreads/lib/libpthread.a(findfp.o) definition taken
  3410.           ld: warning: symbol `__iob' has differing sizes:
  3411.               (file /my/local/pthreads/lib/libpthread.a(findfp.o) value=0x4;
  3412.           file /usr/lib/libc.so value=0x140);
  3413.               /my/local/pthreads/lib/libpthread.a(findfp.o) definition taken
  3414.  
  3415.    * Some other warnings also can be ignored:
  3416.  
  3417.           implicit declaration of function `int strtoll(...)'
  3418.           implicit declaration of function `int strtoul(...)'
  3419.  
  3420.    * We haven't gotten `readline' to work with MIT-pthreads. (This isn't
  3421.      needed, but may be interesting for someone.)
  3422.  
  3423. Perl installation comments
  3424. ==========================
  3425.  
  3426. Installing Perl on Unix
  3427. -----------------------
  3428.  
  3429. Perl support for *MySQL* is provided by means of the `DBI'/`DBD' client
  3430. interface.  *Note Perl::.  The Perl `DBD'/`DBI' client code requires
  3431. Perl 5.004 or later.  The interface _will not work_ if you have an
  3432. older version of Perl.
  3433.  
  3434. *MySQL* Perl support also requires that you've installed *MySQL* client
  3435. programming support.  If you installed *MySQL* from RPM files, client
  3436. programs are in the client RPM, but client programming support is in
  3437. the developer RPM.  Make sure you've installed the latter RPM.
  3438.  
  3439. As of release 3.22.8, Perl support is distributed separately from the
  3440. main *MySQL* distribution.  If you want to install Perl support, the
  3441. files you will need can be obtained from
  3442. `http://www.mysql.com/Downloads/Contrib/'.
  3443.  
  3444. The Perl distributions are provided as compressed `tar' archives and
  3445. have names like `MODULE-VERSION.tar.gz', where `MODULE' is the module
  3446. name and `VERSION' is the version number.  You should get the
  3447. `Data-Dumper', `DBI', and `Msql-Mysql-modules' distributions and
  3448. install them in that order.  The installation procedure is shown below.
  3449. The example shown is for the `Data-Dumper' module, but the procedure is
  3450. the same for all three distributions.
  3451.  
  3452.   1. Unpack the distribution into the current directory:
  3453.           shell> gunzip < Data-Dumper-VERSION.tar.gz | tar xvf -
  3454.      This command creates a directory named `Data-Dumper-VERSION'.
  3455.  
  3456.   2. Change into the top-level directory of the unpacked distribution:
  3457.           shell> cd Data-Dumper-VERSION
  3458.  
  3459.   3. Build the distribution and compile everything:
  3460.           shell> perl Makefile.PL
  3461.           shell> make
  3462.           shell> make test
  3463.           shell> make install
  3464.  
  3465. The `make test' command is important, because it verifies that the
  3466. module is working.  Note that when you run that command during the
  3467. `Msql-Mysql-modules' installation to exercise the interface code, the
  3468. *MySQL* server must be running or the test will fail.
  3469.  
  3470. It is a good idea to rebuild and reinstall the `Msql-Mysql-modules'
  3471. distribution whenever you install a new release of *MySQL*,
  3472. particularly if you notice symptoms such as all your `DBI' scripts
  3473. dumping core after you upgrade *MySQL*.
  3474.  
  3475. If you don't have the right to install Perl modules in the system
  3476. directory or if you to install local Perl modules, the following
  3477. reference may help you:
  3478.  
  3479.      `http://www.iserver.com/support/contrib/perl5/modules.html'
  3480.  
  3481. Look under the heading `Installing New Modules that Require Locally
  3482. Installed Modules'.
  3483.  
  3484. Installing ActiveState Perl on Win32
  3485. ------------------------------------
  3486.  
  3487. To install the *MySQL* `DBD' module with ActiveState Perl on Win32, you
  3488. should do the following:
  3489.  
  3490.    * Open a DOS shell.
  3491.  
  3492.    * If required, set the HTTP_proxy variable. For example, you might
  3493.      try: `set HTTP_proxy=my.proxy.com:3128'
  3494.  
  3495.    * Start the PPM program: `C:\perl\bin\ppm.pl'
  3496.  
  3497.    * If you have not already done so, install `DBI': `install DBI'
  3498.  
  3499.    * If this succeeds, install
  3500.      `ftp://ftp.de.uu.net/pub/CPAN/authors/id/JWIED/DBD-mysql-1.2212.x86.ppd'
  3501.  
  3502. The above should work at least with ActiveState Perl 5.6.
  3503.  
  3504. If you can't get the above to work, you should instead install the
  3505. *MyODBC* driver and connect to *MySQL* server through ODBC.
  3506.  
  3507.      use DBI;
  3508.      $dbh= DBI->connect("DBI:ODBC:$dsn","$user","$password") ||
  3509.        die "Got error $DBI::errstr when connecting to $dsn\n";
  3510.  
  3511. Installing the MySQL Perl distribution on Win32
  3512. -----------------------------------------------
  3513.  
  3514. The *MySQL* Perl distribution contains `DBI', `DBD:MySQL' and
  3515. `DBD:ODBC'.
  3516.  
  3517.    * Get the Perl distribution for Win32 from
  3518.      `http://www.mysql.com/download.html'.
  3519.  
  3520.    * Unzip the distribution in `C:' so that you get a `C:\PERL'
  3521.      directory.
  3522.  
  3523.    * Add the directory `C:\PERL\BIN' to your path.
  3524.  
  3525.    * Add the directory `C:\PERL\BIN\MSWin32-x86-thread' or
  3526.      `C:\PERL\BIN\MSWin32-x86' to your path.
  3527.  
  3528.    * Test that `perl' works by executing `perl -v' in a DOS shell.
  3529.  
  3530. Problems using the Perl `DBI'/`DBD' interface
  3531. ---------------------------------------------
  3532.  
  3533. If Perl reports that it can't find the `../mysql/mysql.so' module, then
  3534. the problem is probably that Perl can't locate the shared library
  3535. `libmysqlclient.so'.
  3536.  
  3537. You can fix this by any of the following methods:
  3538.  
  3539.    * Compile the `Msql-Mysql-modules' distribution with `perl
  3540.      Makefile.PL -static -config' rather than `perl Makefile.PL'
  3541.  
  3542.    * Copy `libmysqlclient.so' to the directory where your other shared
  3543.      libraries are located (probably `/usr/lib' or `/lib').
  3544.  
  3545.    * On `Linux' you can add the pathname of the directory where
  3546.      `libmysqlclient.so' is located to the `/etc/ld.so.conf' file.
  3547.  
  3548.    * Add the pathname of the directory where `libmysqlclient.so' is
  3549.      located to the `LD_RUN_PATH' environment variable.
  3550.  
  3551. If you get the following errors from `DBD-mysql', you are probably
  3552. using `gcc' (or using an old binary compiled with `gcc'):
  3553.  
  3554.      /usr/bin/perl: can't resolve symbol '__moddi3'
  3555.      /usr/bin/perl: can't resolve symbol '__divdi3'
  3556.  
  3557. Add `-L/usr/lib/gcc-lib/... -lgcc' to the link command when the
  3558. `mysql.so' library gets built (check the output from `make' for
  3559. `mysql.so' when you compile the Perl client).  The `-L' option should
  3560. specify the pathname of the directory where `libgcc.a' is located on
  3561. your system.
  3562.  
  3563. Another cause of this problem may be that Perl and *MySQL* aren't both
  3564. compiled with `gcc'.  In this case, you can solve the mismatch by
  3565. compiling both with `gcc'.
  3566.  
  3567. If you want to use the Perl module on a system that doesn't support
  3568. dynamic linking (like SCO) you can generate a static version of Perl
  3569. that includes `DBI' and `DBD-mysql'.  The way this works is that you
  3570. generate a version of Perl with the `DBI' code linked in and install it
  3571. on top of your current Perl.  Then you use that to build a version of
  3572. Perl that additionally has the `DBD' code linked in, and install that.
  3573.  
  3574. On SCO, you must have the following environment variables set:
  3575.  
  3576.      shell> LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib:/usr/progressive/lib
  3577.      or
  3578.      shell> LD_LIBRARY_PATH=/usr/lib:/lib:/usr/local/lib:/usr/ccs/lib:/usr/progressive/lib:/usr/skunk/lib
  3579.      shell> LIBPATH=/usr/lib:/lib:/usr/local/lib:/usr/ccs/lib:/usr/progressive/lib:/usr/skunk/lib
  3580.      shell> MANPATH=scohelp:/usr/man:/usr/local1/man:/usr/local/man:/usr/skunk/man:
  3581.  
  3582. First, create a Perl that includes a statically-linked `DBI' by running
  3583. these commands in the directory where your `DBI' distribution is
  3584. located:
  3585.  
  3586.      shell> perl Makefile.PL -static -config
  3587.      shell> make
  3588.      shell> make install
  3589.      shell> make perl
  3590.  
  3591. Then you must install the new Perl. The output of `make perl' will
  3592. indicate the exact `make' command you will need to execute to perform
  3593. the installation.  On SCO, this is `make -f Makefile.aperl inst_perl
  3594. MAP_TARGET=perl'.
  3595.  
  3596. Next, use the just-created Perl to create another Perl that also
  3597. includes a statically-linked `DBD::mysql' by running these commands in
  3598. the directory where your `Msql-Mysql-modules' distribution is located:
  3599.  
  3600.      shell> perl Makefile.PL -static -config
  3601.      shell> make
  3602.      shell> make install
  3603.      shell> make perl
  3604.  
  3605. Finally, you should install this new Perl.  Again, the output of `make
  3606. perl' indicates the command to use.
  3607.  
  3608. System-specific issues
  3609. ======================
  3610.  
  3611. The following sections indicate some of the issues that have been
  3612. observed to occur on particular systems when installing *MySQL* from a
  3613. source distribution.
  3614.  
  3615. Solaris notes
  3616. -------------
  3617.  
  3618. On Solaris, you may run into trouble even before you get the *MySQL*
  3619. distribution unpacked!  Solaris `tar' can't handle long file names, so
  3620. you may see an error like this when you unpack *MySQL*:
  3621.  
  3622.      x mysql-3.22.12-beta/bench/Results/ATIS-mysql_odbc-NT_4.0-cmp-db2,informix,ms-sql,mysql,oracle,solid,sybase, 0 bytes, 0 tape blocks
  3623.      tar: directory checksum error
  3624.  
  3625. In this case, you must use GNU `tar' (`gtar') to unpack the
  3626. distribution.  You can find a precompiled copy for Solaris at
  3627. `http://www.mysql.com/Downloads/'.
  3628.  
  3629. Sun native threads work only on Solaris 2.5 and higher. For 2.4 and
  3630. earlier versions, *MySQL* will automatically use MIT-pthreads. *Note
  3631. MIT-pthreads::.
  3632.  
  3633. If you get the following error from configure:
  3634.  
  3635.      checking for restartable system calls... configure: error can not run test
  3636.      programs while cross compiling
  3637.  
  3638. This means that you have something wrong with your compiler
  3639. installation!  In this case you should upgrade your compiler to a newer
  3640. version.  You may also be able to solve this problem by inserting the
  3641. following row into the `config.cache' file:
  3642.  
  3643.      ac_cv_sys_restartable_syscalls=${ac_cv_sys_restartable_syscalls='no'}
  3644.  
  3645. If you are using Solaris on a SPARC, the recommended compiler is `gcc'
  3646. 2.95.2.  You can find this at `http://gcc.gnu.org/'.  Note that `egs'
  3647. 1.1.1 and `gcc' 2.8.1 don't work reliably on SPARC!
  3648.  
  3649. The recommended `configure' line when using `gcc' 2.95.2 is:
  3650.  
  3651.      shell> CC=gcc CFLAGS="-O6" \
  3652.             CXX=gcc CXXFLAGS="-O6 -felide-constructors -fno-exceptions -fno-rtti" \
  3653.             ./configure --prefix=/usr/local/mysql --with-low-memory
  3654.  
  3655. If you have the Sun Workshop 4.2 compiler, you can run `configure' like
  3656. this:
  3657.  
  3658. CC=cc CFLAGS="-xstrconst -Xa -xO4 -native -mt" CXX=CC CXXFLAGS="-xO4
  3659. -native -noex -mt" ./configure -prefix=/usr/local/mysql
  3660.  
  3661.      shell> CC=cc CFLAGS="-Xa -fast -xO4 -native -xstrconst -mt" \
  3662.             CXX=CC CXXFLAGS="-noex -XO4 -mt" \
  3663.             ./configure
  3664.  
  3665. You may also have to edit the `configure' script to change this line:
  3666.  
  3667.      #if !defined(__STDC__) || __STDC__ != 1
  3668.  
  3669. to this:
  3670.  
  3671.      #if !defined(__STDC__)
  3672.  
  3673. If you turn on `__STDC__' with the `-Xc' option, the Sun compiler can't
  3674. compile with the Solaris `pthread.h' header file. This is a Sun bug
  3675. (broken compiler or broken include file).
  3676.  
  3677. If `mysqld' issues the error message shown below when you run it, you
  3678. have tried to compile *MySQL* with the Sun compiler without enabling the
  3679. multi-thread option (`-mt'):
  3680.  
  3681.      libc internal error: _rmutex_unlock: rmutex not held
  3682.  
  3683. Add `-mt' to `CFLAGS' and `CXXFLAGS' and try again.
  3684.  
  3685. If you get the following error when compiling *MySQL* with `gcc', it
  3686. means that your `gcc' is not configured for your version of Solaris!
  3687.  
  3688.      shell> gcc -O3 -g -O2 -DDBUG_OFF  -o thr_alarm ...
  3689.      ./thr_alarm.c: In function `signal_hand':
  3690.      ./thr_alarm.c:556: too many arguments to function `sigwait'
  3691.  
  3692. The proper thing to do in this case is to get the newest version of
  3693. `gcc' and compile it with your current `gcc' compiler!  At least for
  3694. Solaris 2.5, almost all binary versions of `gcc' have old, unusable
  3695. include files that will break all programs that use threads (and
  3696. possibly other programs)!
  3697.  
  3698. Solaris doesn't provide static versions of all system libraries
  3699. (`libpthreads' and `libdl'), so you can't compile *MySQL* with
  3700. `--static'.  If you try to do so, you will get the error:
  3701.  
  3702.      ld: fatal: library -ldl: not found
  3703.  
  3704. If too many processes try to connect very rapidly to `mysqld', you will
  3705. see this error in the *MySQL* log:
  3706.  
  3707.      Error in accept: Protocol error
  3708.  
  3709. You might try starting the server with the `--set-variable back_log=50'
  3710. option as a workaround for this. *Note Command-line options::.
  3711.  
  3712. If you are linking your own *MySQL* client, you might get the following
  3713. error when you try to execute it:
  3714.  
  3715.      ld.so.1: ./my: fatal: libmysqlclient.so.#: open failed: No such file or directory
  3716.  
  3717. The problem can be avoided by one of the following methods:
  3718.  
  3719.    * Link the client with the following flag (instead of `-Lpath'):
  3720.      `-Wl,r/full-path-to-libmysqlclient.so'.
  3721.  
  3722.    * Copy `libmysqclient.so' to `/usr/lib'.
  3723.  
  3724.    * Add the pathname of the directory where `libmysqlclient.so' is
  3725.      located to the `LD_RUN_PATH' environment variable before running
  3726.      your client.
  3727.  
  3728. When using the `--with-libwrap' configure option, you must also include
  3729. the libraries that `libwrap.a' needs:
  3730.  
  3731.      --with-libwrap="/opt/NUtcpwrapper-7.6/lib/libwrap.a -lnsl -lsocket
  3732.  
  3733. If you have problems with that configure or *MySQL* tries to link with
  3734. `-lz' and you don't have this installed, you have two options:
  3735.  
  3736.    * If you want to be able to use the compressed communication
  3737.      protocol, you need to get and install zlib from ftp.gnu.org.
  3738.  
  3739.    * Configure with `--with-named-z-libs=no'
  3740.  
  3741. If you are using gcc and have problems with loading `UDF' functions
  3742. into `MySQL', try adding `-lgcc' to the link line for the `UDF'
  3743. function.
  3744.  
  3745. Solaris 2.7 / 2.8 notes
  3746. -----------------------
  3747.  
  3748. You can normally use a Solaris 2.6 binary on Solaris 2.7 and 2.8.  Most
  3749. of the Solaris 2.6 issues also apply for Solaris 2.7 and 2.8.
  3750.  
  3751. Note that *MySQL* 3.23.4 and above should be able to autodetect new
  3752. versions of Solaris and enable workarounds for the following problems!
  3753.  
  3754. Solaris 2.7 / 2.8 has some bugs in the include files. You may see the
  3755. following error when you use `gcc':
  3756.  
  3757.      /usr/include/widec.h:42: warning: `getwc' redefined
  3758.      /usr/include/wchar.h:326: warning: this is the location of the previous
  3759.      definition
  3760.  
  3761. If this occurs, you can do the following to fix the problem:
  3762.  
  3763. Copy `/usr/include/widec.h' to `.../lib/gcc-lib/os/gcc-version/include'
  3764. and change line 41 from:
  3765.  
  3766.      #if     !defined(lint) && !defined(__lint)
  3767.      
  3768.      to
  3769.      
  3770.      #if     !defined(lint) && !defined(__lint) && !defined(getwc)
  3771.  
  3772. Alternatively, you can edit `/usr/include/widec.h' directly.  Either
  3773. way, after you make the fix, you should remove `config.cache' and run
  3774. `configure' again!
  3775.  
  3776. If you get errors like this when you run `make', it's because
  3777. `configure' didn't detect the `curses.h' file (probably because of the
  3778. error in `/usr/include/widec.h':
  3779.  
  3780.      In file included from mysql.cc:50:
  3781.      /usr/include/term.h:1060: syntax error before `,'
  3782.      /usr/include/term.h:1081: syntax error before `;'
  3783.  
  3784. The solution to this is to do one of the following steps:
  3785.  
  3786.    * Edit `/usr/include/widec.h' as indicted above and rerun configure
  3787.  
  3788.    * Remove the `#define HAVE_TERM' line from `config.h' file and run
  3789.      `make' again.
  3790.  
  3791.    * Configure with `CFLAGS=-DHAVE_CURSES CXXFLAGS=-DHAVE_CURSES
  3792.      ./configure'
  3793.  
  3794. Solaris x86 notes
  3795. -----------------
  3796.  
  3797. If you are using `gcc' or `egcs' on Solaris x86 and you experience
  3798. problems with core dumps under load, you should use the following
  3799. `configure' command:
  3800.  
  3801.      shell> CC=gcc CFLAGS="-O6 -fomit-frame-pointer" \
  3802.             CXX=gcc \
  3803.             CXXFLAGS="-O6 -fomit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti" \
  3804.             ./configure --prefix=/usr/local/mysql
  3805.  
  3806. This will avoid problems with the `libstdc++' library and with C++
  3807. exceptions.
  3808.  
  3809. If this doesn't help, you should compile a debug version and run it
  3810. with a trace file or under `gdb'.  *Note Debugging server::.
  3811.  
  3812. SunOS 4 notes
  3813. -------------
  3814.  
  3815. On SunOS 4, MIT-pthreads is needed to compile *MySQL*, which in turn
  3816. means you will need GNU `make'.
  3817.  
  3818. Some SunOS 4 systems have problems with dynamic libraries and
  3819. `libtool'. You can use the following `configure' line to avoid this
  3820. problem:
  3821.  
  3822.      shell> ./configure --disable-shared --with-mysqld-ldflags=-all-static
  3823.  
  3824. When compiling `readline', you may get warnings about duplicate defines.
  3825. These may be ignored.
  3826.  
  3827. When compiling `mysqld', there will be some `implicit declaration of
  3828. function' warnings. These may be ignored.
  3829.  
  3830. Linux notes (all Linux versions)
  3831. --------------------------------
  3832.  
  3833. *MySQL* uses LinuxThreads on Linux.  If you are using an old Linux
  3834. version that doesn't have `glibc2', you must install LinuxThreads before
  3835. trying to compile *MySQL*. `http://www.mysql.com/Downloads/Linux'
  3836.  
  3837. Note that `glibc' versions before and including 2.1.1 has a fatal bug
  3838. in `pthread_mutex_timedwait' handling, which is used when you do
  3839. `INSERT DELAYED'. If you are using `INSERT DELAYED', you *MUST* add the
  3840. following patch to your glibc library:
  3841. `http://www.mysql.com/Downloads/Patches/glibc-pthread_cond_timedwait.patch'.
  3842. *MySQL* 3.23.7 and the *MySQL* 3.22.32 contains a temporary workaround
  3843. for this bug.
  3844.  
  3845. If you plan to have 1000+ concurrent connections, you will need to make
  3846. some changes to LinuxThreads, recompile it, and re-link MySQL against
  3847. the new libpthread.a . Increase PTHREAD_THREADS_MAX in
  3848. sysdeps/unix/sysv/linux/bits/local_lim.h to 4096 and decrease STACK_SIZE
  3849. in internals.h to 256 KB . Note that MySQL will not be stable with
  3850. around 1000 connections if STACK_SIZE is the default of 2 MB.
  3851.  
  3852. If you have glibc 2.1.3-65 or newer, you don't have to increase
  3853. STACK_SIZE; You can instead just change the `thread_stack' value for
  3854. `mysqld'.
  3855.  
  3856. If you use a lot of concurrent connections, you may suffer from a 2.2
  3857. kernel "feature" that penalizes a process for forking or cloning a child
  3858. in an attempt to prevent a fork bomb attack. This will cause MySQL not
  3859. to scale well as you increase the number of concurrent clients. On
  3860. single CPU systems, we have seen this manifested in a very slow thread
  3861. creation - which means it may take a long time to connect to MySQL ( as
  3862. long as 1 minute), and it may take just as long to shut it down. On
  3863. multiple CPU systems, we have observed a gradual drop in query speed as
  3864. the number of clients increases. In the process of trying to find a
  3865. solution, we have received a kernel patch from one of our users, who
  3866. claimed it made a lot of difference for his site. We have done some
  3867. limited testing in which the patch greatly improved the scalabitility of
  3868. MySQL. The patch is available here
  3869. (http://www.mysql.com/Downloads/Patches/linux-fork.patch) - be warned,
  3870. though, that we assume no reponsibility for any damage that this patch
  3871. could do - use at your own risk. We have also been told by the Linux
  3872. kernel developers that this problem is fixed in 2.4, although we have
  3873. not yet done any testing.
  3874.  
  3875. If you can't start `mysqld' or if `mysql_install_db' doesn't work,
  3876. please continue reading!  This only happens on Linux system with
  3877. problems in the LinuxThreads or `libc'/`glibc' libraries. There are a
  3878. lot of simple workarounds to get *MySQL* to work!  The simplest is to
  3879. use the binary version of *MySQL* (not the RPM) for Linux x86.  One nice
  3880. aspect of this version is that it's probably 10% faster than any
  3881. version you would compile yourself!  *Note Compile and link options::.
  3882.  
  3883. One known problem with the binary distribution is that with older Linux
  3884. systems that use `libc' (like RedHat 4.x or Slackware), you will get
  3885. some non-fatal problems with hostname resolution *Note Binary
  3886. notes-Linux::.
  3887.  
  3888. `myisamchk' hangs with `libc.so.5.3.12'. Upgrading to the newest `libc'
  3889. fixes this problem.
  3890.  
  3891. When using LinuxThreads you will see a minimum of three processes
  3892. running. These are in fact threads. There will be one thread for the
  3893. LinuxThreads manager, one thread to handle connections, and one thread
  3894. to handle alarms and signals.
  3895.  
  3896. Note that the linux kernel and the linuxthread library can by default
  3897. only have 1024 threads.  This means that you can only have up to 1021
  3898. connections to MySQL on a unpatched system.  The page
  3899. `http://www.volano.com/linuxnotes.html' contains information how to go
  3900. around this limit.
  3901.  
  3902. If you see a dead `mysqld' daemon process with `ps', this usually means
  3903. that you have found a bug in *MySQL* or you have got a corrupted table.
  3904. *Note Crashing::.
  3905.  
  3906. If you are using LinuxThreads and `mysqladmin shutdown' doesn't work,
  3907. you must upgrade to LinuxThreads 0.7.1 or newer.
  3908.  
  3909. If you are using RedHat, you might get errors like this:
  3910.  
  3911.      /usr/bin/perl is needed...
  3912.      /usr/sh is needed...
  3913.      /usr/sh is needed...
  3914.  
  3915. If so, you should upgrade your version of `rpm' to
  3916. `rpm-2.4.11-1.i386.rpm' and `rpm-devel-2.4.11-1.i386.rpm' (or later).
  3917.  
  3918. You can get the upgrades of libraries to RedHat 4.2 from
  3919. `ftp://ftp.redhat.com/updates/4.2/i386'. Or
  3920. `http://www.sunsite.unc.edu/pub/Linux/distributions/redhat/code/rpm/'
  3921. for other distributions.
  3922.  
  3923. If you are linking your own *MySQL* client and get the error:
  3924.  
  3925.      ld.so.1: ./my: fatal: libmysqlclient.so.4: open failed: No such file or directory
  3926.  
  3927. when executing them, the problem can be avoided by one of the following
  3928. methods:
  3929.  
  3930.    * Link the client with the following flag (instead of `-Lpath'):
  3931.      `-Wl,r/path-libmysqlclient.so'.
  3932.  
  3933.    * Copy `libmysqclient.so' to `/usr/lib'.
  3934.  
  3935.    * Add the pathname of the directory where `libmysqlclient.so' is
  3936.      located to the `LD_RUN_PATH' environment variable before running
  3937.      your client.
  3938.  
  3939. If you are using the Fujitsu compiler `(fcc / FCC)' you will have some
  3940. problems compiling *MySQL* because the Linux header files are very
  3941. `gcc' oriented.
  3942.  
  3943. The following `configure' line should work with `fcc/FCC':
  3944.  
  3945.      CC=fcc CFLAGS="-O -K fast -K lib -K omitfp -Kpreex -D_GNU_SOURCE -DCONST=const -DNO_STRTOLL_PROTO" CXX=FCC CXXFLAGS="-O -K fast -K lib  -K omitfp -K preex --no_exceptions --no_rtti -D_GNU_SOURCE -DCONST=const -Dalloca=__builtin_alloca -DNO_STRTOLL_PROTO '-D_EXTERN_INLINE=static __inline'" ./configure --prefix=/usr/local/mysql --enable-assembler --with-mysqld-ldflags=-all-static --disable-shared --with-low-memory
  3946.  
  3947. Linux-x86 notes
  3948. ...............
  3949.  
  3950. *MySQL* requires `libc' version 5.4.12 or newer. It's known to work
  3951. with `libc' 5.4.46. `glibc' version 2.0.6 and later should also work.
  3952. There have been some problems with the `glibc' RPMs from RedHat so if
  3953. you have problems, check whether or not there are any updates!  The
  3954. `glibc' 2.0.7-19 and 2.0.7-29 RPMs are known to work.
  3955.  
  3956. On some older Linux distributions, `configure' may produce an error
  3957. like this:
  3958.  
  3959.      Syntax error in sched.h. Change _P to __P in the /usr/include/sched.h file.
  3960.      See the Installation chapter in the Reference Manual.
  3961.  
  3962. Just do what the error message says and add an extra underscore to the
  3963. `_P' macro that has only one underscore, then try again.
  3964.  
  3965. You may get some warnings when compiling; those shown below can be
  3966. ignored:
  3967.  
  3968.      mysqld.cc -o objs-thread/mysqld.o
  3969.      mysqld.cc: In function `void init_signals()':
  3970.      mysqld.cc:315: warning: assignment of negative value `-1' to `long unsigned int'
  3971.      mysqld.cc: In function `void * signal_hand(void *)':
  3972.      mysqld.cc:346: warning: assignment of negative value `-1' to `long unsigned int'
  3973.  
  3974. In Debian GNU/Linux, if you want *MySQL* to start automatically when
  3975. the system boots, do the following:
  3976.  
  3977.      shell> cp support-files/mysql.server /etc/init.d/mysql.server
  3978.      shell> /usr/sbin/update-rc.d mysql.server defaults 99
  3979.  
  3980. `mysql.server' can be found in the `share/mysql' directory under the
  3981. *MySQL* installation directory, or in the `support-files' directory of
  3982. the *MySQL* source tree.
  3983.  
  3984. If `mysqld' always core dumps when it starts up, the problem may be that
  3985. you have an old `/lib/libc.a'.  Try renaming it, then remove
  3986. `sql/mysqld' and do a new `make install' and try again.  This problem
  3987. has been reported on some Slackware installations. RedHat 5.0 has also
  3988. a similar problem with some new `glibc' versions.  *Note
  3989. Linux-RedHat50::.
  3990.  
  3991. If you get the following error when linking `mysqld', it means that
  3992. your `libg++.a' is not installed correctly:
  3993.  
  3994.      /usr/lib/libc.a(putc.o): In function `_IO_putc':
  3995.      putc.o(.text+0x0): multiple definition of `_IO_putc'
  3996.  
  3997. You can avoid using `libg++.a' by running `configure' like this:
  3998.  
  3999.      shell> CXX=gcc ./configure
  4000.  
  4001. RedHat 5.0 notes
  4002. ................
  4003.  
  4004. If you have any problems with *MySQL* on RedHat, you should start by
  4005. upgrading `glibc' to the newest possible version!
  4006.  
  4007. If you install all the official RedHat patches (including
  4008. `glibc-2.0.7-19' and `glibc-devel-2.0.7-19'), both the binary and
  4009. source distributions of *MySQL* should work without any trouble!
  4010.  
  4011. The updates are needed because there is a bug in `glibc' 2.0.5 in how
  4012. `pthread_key_create' variables are freed. With `glibc' 2.0.5, you must
  4013. use a statically-linked *MySQL* binary distribution. If you want to
  4014. compile from source, you must install the corrected version of
  4015. LinuxThreads from `http://www.mysql.com/Downloads/Linux' or upgrade your
  4016. `glibc'.
  4017.  
  4018. If you have an incorrect version of `glibc' or LinuxThreads, the symptom
  4019. is that `mysqld' crashes after each connection. For example,
  4020. `mysqladmin version' will crash `mysqld' when it finishes!
  4021.  
  4022. Another symptom of incorrect libraries is that `mysqld' crashes at once
  4023. when it starts. On some Linux systems, this can be fixed by configuring
  4024. like this:
  4025.  
  4026.      shell> ./configure --with-mysqld-ldflags=-all-static
  4027.  
  4028. On Redhat 5.0, the easy way out is to install the `glibc' 2.0.7-19 RPM
  4029. and run `configure' *without* the `--with-mysqld-ldflags=-all-static'
  4030. option.
  4031.  
  4032. For the source distribution of `glibc' 2.0.7, a patch that is easy to
  4033. apply and is tested with *MySQL* may be found at:
  4034.      `http://www.mysql.com/Download/Linux/glibc-2.0.7-total-patch.tar.gz'
  4035.  
  4036. If you experience crashes like these when you build *MySQL*, you can
  4037. always download the newest binary version of *MySQL*.  This is
  4038. statically-linked to avoid library conflicts and should work on all
  4039. Linux systems!
  4040.  
  4041. *MySQL* comes with an internal debugger that can generate trace files
  4042. with a lot of information that can be used to find and solve a wide
  4043. range of different problems.  *Note Debugging server::.
  4044.  
  4045. RedHat 5.1 notes
  4046. ................
  4047.  
  4048. The `glibc' of RedHat 5.1 (`glibc' 2.0.7-13) has a memory leak, so to
  4049. get a stable *MySQL* version, you must upgrade `glibc' to 2.0.7-19,
  4050. downgrade `glibc' or use a binary version of `mysqld'. If you don't do
  4051. this, you will encounter memory problems (out of memory, etc., etc.).
  4052. The most common error in this case is:
  4053.  
  4054.      Can't create a new thread (errno 11). If you are not out of available
  4055.      memory, you can consult the manual for any possible OS dependent bug
  4056.  
  4057. After you have upgraded to `glibc' 2.0.7-19, you can configure *MySQL*
  4058. with dynamic linking (the default), but you *cannot* run `configure'
  4059. with the `--with-mysqld-ldflags=-all-static' option until you have
  4060. installed `glibc' 2.0.7-19 from source!
  4061.  
  4062. You can check which version of `glibc' you have with `rpm -q glibc'.
  4063.  
  4064. Linux-SPARC notes
  4065. .................
  4066.  
  4067. In some implementations, `readdir_r()' is broken.  The symptom is that
  4068. `SHOW DATABASES' always returns an empty set.  This can be fixed by
  4069. removing `HAVE_READDIR_R' from `config.h' after configuring and before
  4070. compiling.
  4071.  
  4072. Some problems will require patching your Linux installation.  The patch
  4073. can be found at
  4074. `http://www.mysql.com/Downloads/patches/Linux-sparc-2.0.30.diff'. This
  4075. patch is against the Linux distribution `sparclinux-2.0.30.tar.gz' that
  4076. is available at `vger.rutgers.edu' (a version of Linux that was never
  4077. merged with the official 2.0.30).  You must also install LinuxThreads
  4078. 0.6 or newer.
  4079.  
  4080. Thanks to <jacques@solucorp.qc.ca> for this information.
  4081.  
  4082. Linux-Alpha notes
  4083. .................
  4084.  
  4085. *MySQL* 3.23.12 is the first *MySQL* version that is tested on
  4086. Linux-Alpha.  If you plan to use *MySQL* on Linux-Alpha, you should
  4087. ensure that you have this version or newer.
  4088.  
  4089. We have tested *MySQL* on Alpha with our benchmarks + test suite and it
  4090. appears to work nicely.  The main thing we haven't yet had time to test
  4091. is how things works with many concurrent users.
  4092.  
  4093. When we compiled *MySQL* we where using SuSE 6.3, kernel 2.2.13-SMP,
  4094. egcs 1.1.2 and libc-2.1.2-28.
  4095.  
  4096. We used the following configure line:
  4097.  
  4098.      CFLAGS="-O6 -fomit-frame-pointer" CXX=gcc CXXFLAGS="-O6 -fomit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local/mysql --disable-shared
  4099.  
  4100. If you have access to Compaq's C compiler, the following configure line
  4101. will give you about 9 % more performance:
  4102.      CC=ccc CFLAGS="-fast -O3 -fomit-frame-pointer" CXX=gcc CXXFLAGS="-O6 -fomit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti -mcpu=ev6 -Wa,-mev6" CXXLDFLAGS='/usr/lib/compaq/libots-2.2.7/libots.so /usr/lib/compaq/cpml-5.0.0/libcpml_ev6.a' ./configure --prefix=/usr/local/mysql --disable-shared
  4103.  
  4104. Note that the last example assumes your are using an Alpha EV6
  4105. processor.
  4106.  
  4107. Some known problems when running *MySQL* on Linux-Alpha:
  4108.  
  4109.    * If you create many files ( > 10000) in one directory (as done by
  4110.      the `test-create' in the *MySQL* benchmarks, mysqld may report the
  4111.      error `Can't create/write to file '...' (Errcode: 12)'. This is
  4112.      probably a bug in the Linux-Alpha kernel.
  4113.  
  4114.    * Debugging threaded applications like *MySQL* will not work with
  4115.      `gdb 4.18'.  You should download and use gdb 5.0 instead!
  4116.  
  4117.    * If you try linking mysqld staticly, the resulting image will core
  4118.      dump at start.  In other words, *DON'T* use
  4119.      `--with-mysqld-ldflags=-all-static'
  4120.  
  4121. We don't yet know if the following old information is still relevant,
  4122. so we leave this here until we have had time to test Linux-Alpha
  4123. properly.
  4124.  
  4125. If you have problems with signals (*MySQL* dies unexpectedly under high
  4126. load) you may have found an OS bug with threads and signals. In this
  4127. case you can tell *MySQL* not to use signals by configuring with:
  4128.  
  4129.      shell> CFLAGS=-DDONT_USE_THR_ALARM \
  4130.             CXXFLAGS=-DDONT_USE_THR_ALARM \
  4131.             ./configure ...
  4132.  
  4133. This doesn't affect the performance of *MySQL*, but has the side effect
  4134. that you can't kill clients that are "sleeping" on a connection with
  4135. `mysqladmin kill' or `mysqladmin shutdown'.  Instead, the client will
  4136. die when it issues its next command.
  4137.  
  4138. MkLinux notes
  4139. .............
  4140.  
  4141. *MySQL* should work on MkLinux with the newest `glibc' package (tested
  4142. with `glibc' 2.0.7).
  4143.  
  4144. Qube2 Linux notes
  4145. .................
  4146.  
  4147. To get *MySQL* to work on Qube2, (Linux Mips), you need the newest
  4148. `glibc' libraries (`glibc-2.0.7-29C2' is known to work). You must also
  4149. use the `egcs' C++ compiler (`egcs-1.0.2-9', `gcc 2.95.2' or newer).
  4150.  
  4151. Alpha-DEC-Unix notes
  4152. --------------------
  4153.  
  4154. When compiling threaded programs under Digital UNIX, the documentation
  4155. recommends using the `-pthread' option for `cc' and `cxx' and the
  4156. libraries `-lmach -lexc' (in addition to `-lpthread').  You should run
  4157. `configure' something like this:
  4158.  
  4159.      shell> CC="cc -pthread" CXX="cxx -pthread -O" \
  4160.             ./configure --with-named-thread-libs="-lpthread -lmach -lexc -lc"
  4161.  
  4162. When compiling `mysqld', you may see a couple of warnings like this:
  4163.  
  4164.      mysqld.cc: In function void handle_connections()':
  4165.      mysqld.cc:626: passing long unsigned int *' as argument 3 of
  4166.      accept(int,sockadddr *, int *)'
  4167.  
  4168. You can safely ignore these warnings. They occur because `configure'
  4169. can detect only errors, not warnings.
  4170.  
  4171. If you start the server directly from the command line, you may have
  4172. problems with it dying when you log out.  (When you log out, your
  4173. outstanding processes receive a `SIGHUP' signal.)  If so, try starting
  4174. the server like this:
  4175.  
  4176.      shell> nohup mysqld [options] &
  4177.  
  4178. `nohup' causes the command following it to ignore any `SIGHUP' signal
  4179. sent from the terminal.  Alternatively, start the server by running
  4180. `safe_mysqld', which invokes `mysqld' using `nohup' for you.
  4181.  
  4182. Alpha-DEC-OSF1 notes
  4183. --------------------
  4184.  
  4185. If you have problems compiling and have DEC `CC' and `gcc' installed,
  4186. try running `configure' like this:
  4187.  
  4188.      shell> CC=cc CFLAGS=-O CXX=gcc CXXFLAGS=-O3 \
  4189.             ./configure --prefix=/usr/local/mysql
  4190.  
  4191. If you get problems with the `c_asm.h' file, you can create and use a
  4192. 'dummy' `c_asm.h' file with:
  4193.  
  4194.      shell> touch include/c_asm.h
  4195.      shell> CC=gcc CFLAGS=-I./include \
  4196.             CXX=gcc CXXFLAGS=-O3 \
  4197.             ./configure --prefix=/usr/local/mysql
  4198.  
  4199. Note that the following problems with the `ld' program can be fixed by
  4200. downloading the latest DEC (Compaq) patch kit from:
  4201. `http://ftp.support.compaq.com/public/unix/'.
  4202.  
  4203. On OSF1 V4.0D and compiler "DEC C V5.6-071 on Digital UNIX V4.0 (Rev.
  4204. 878)" the compiler had some strange behavior (undefined `asm' symbols).
  4205. `/bin/ld' also appears to be broken (problems with `_exit undefined'
  4206. errors occuring while linking `mysqld').  On this system, we have
  4207. managed to compile *MySQL* with the following `configure' line, after
  4208. replacing `/bin/ld' with the version from OSF 4.0C:
  4209.  
  4210.      shell> CC=gcc CXX=gcc CXXFLAGS=-O3 ./configure --prefix=/usr/local/mysql
  4211.  
  4212. With the Digital compiler "C++ V6.1-029", the following should work:
  4213.  
  4214.      CC=cc -pthread
  4215.      CFLAGS=-O4 -ansi_alias -ansi_args -fast -inline speed -speculate all -arch host
  4216.      CXX=cxx -pthread
  4217.      CXXFLAGS=-O4 -ansi_alias -ansi_args -fast -inline speed -speculate all -arch host
  4218.      export CC CFLAGS CXX CXXFLAGS
  4219.      ./configure --prefix=/usr/mysql/mysql --with-low-memory --enable-large-files --with-mysqld-ldflags=-all-static --disable-shared --with-named-thread-libs="-lmach -lexc -lc"
  4220.  
  4221. In some versions of OSF1, the `alloca()' function is broken. Fix this
  4222. by removing the line in `config.h' that defines `'HAVE_ALLOCA''.
  4223.  
  4224. The `alloca()' function also may have an incorrect prototype in
  4225. `/usr/include/alloca.h'.  This warning resulting from this can be
  4226. ignored.
  4227.  
  4228. `configure' will use the following thread libraries automatically:
  4229. `--with-named-thread-libs="-lpthread -lmach -lexc -lc"'.
  4230.  
  4231. When using `gcc', you can also try running `configure' like this:
  4232.  
  4233.      shell> CFLAGS=-D_PTHREAD_USE_D4 CXX=gcc CXXFLAGS=-O3 ./configure ....
  4234.  
  4235. If you have problems with signals (*MySQL* dies unexpectedly under high
  4236. load) you may have found an OS bug with threads and signals. In this
  4237. case you can tell *MySQL* not to use signals by configuring with:
  4238.  
  4239.      shell> CFLAGS=-DDONT_USE_THR_ALARM \
  4240.             CXXFLAGS=-DDONT_USE_THR_ALARM \
  4241.             ./configure ...
  4242.  
  4243. This doesn't affect the performance of *MySQL*, but has the side effect
  4244. that you can't kill clients that are "sleeping" on a connection with
  4245. `mysqladmin kill' or `mysqladmin shutdown'.  Instead, the client will
  4246. die when it issues its next command.
  4247.  
  4248. With `gcc' 2.95.2, you will probably run into the following compile
  4249. error:
  4250.  
  4251.      sql_acl.cc:1456: Internal compiler error in `scan_region', at except.c:2566
  4252.      Please submit a full bug report.
  4253.  
  4254. To fix this you should change to the `sql' directory and do a 'cut and
  4255. paste' of the last `gcc' line, but change `-O3' to `-O0' (or add `-O0'
  4256. immediately after `gcc' if you don't have any `-O' option on your
  4257. compile line. After this is done you can just change back to the top
  4258. level directly and run `make' again.
  4259.  
  4260. SGI-Irix notes
  4261. --------------
  4262.  
  4263. If you are using Irix 6.5.3 or newer `mysqld' will only be able to
  4264. create threads if you run it as a user with `CAP_SCHED_MGT' privileges
  4265. (like `root') or give the `mysqld' server this privilege with the
  4266. following shell command:
  4267.  
  4268.      shell> chcap "CAP_SCHED_MGT+epi" /opt/mysql/libexec/mysqld
  4269.  
  4270. You may have to undefine some things in `config.h' after running
  4271. `configure' and before compiling.
  4272.  
  4273. In some Irix implementations, the `alloca()' function is broken. If the
  4274. `mysqld' server dies on some `SELECT' statements, remove the lines from
  4275. `config.h' that define `HAVE_ALLOC' and `HAVE_ALLOCA_H'.  If
  4276. `mysqladmin create' doesn't work, remove the line from `config.h' that
  4277. defines `HAVE_READDIR_R'. You may have to remove the `HAVE_TERM_H' line
  4278. as well.
  4279.  
  4280. SGI recommends that you install all of the patches on this page as a
  4281. set:
  4282. http://support.sgi.com/surfzone/patches/patchset/6.2_indigo.rps.html
  4283.  
  4284. At the very minimum, you should install the latest kernel rollup, the
  4285. latest `rld' rollup, and the latest `libc' rollup.
  4286.  
  4287. You definately need all the POSIX patches on this page, for pthreads
  4288. support:
  4289.  
  4290. http://support.sgi.com/surfzone/patches/patchset/6.2_posix.rps.html
  4291.  
  4292. If you get the something like the following error when compiling
  4293. `mysql.cc':
  4294.  
  4295.      "/usr/include/curses.h", line 82: error(1084): invalid combination of type
  4296.  
  4297. Then type the following in the top-level directory of your *MySQL*
  4298. source tree:
  4299.  
  4300.      shell> extra/replace bool curses_bool < /usr/include/curses.h > include/curses.h
  4301.      shell> make
  4302.  
  4303. There have also been reports of scheduling problems.  If only one
  4304. thread is running, things go slow. Avoid this by starting another
  4305. client. This may lead to a 2-to-10-fold increase in execution speed
  4306. thereafter for the other thread.  This is a poorly-understood problem
  4307. with Irix threads; you may have to improvise to find solutions until
  4308. this can be fixed.
  4309.  
  4310. If you are compiling with `gcc', you can use the following `configure'
  4311. command:
  4312.  
  4313.      shell> CC=gcc CXX=gcc CXXFLAGS=-O3 \
  4314.             ./configure --prefix=/usr/local/mysql --with-thread-safe-client --with-named-thread-libs=-lpthread
  4315.  
  4316. FreeBSD notes
  4317. -------------
  4318.  
  4319. FreeBSD 3.x is recommended for running *MySQL* since it the thread
  4320. package is much more integrated.
  4321.  
  4322. The easiest and therefor the preferred way to install is to use the
  4323. mysql-server and mysql-client ports available on
  4324. `http://www.freebsd.org'
  4325.  
  4326. Using these gives you:
  4327.    * A working *MySQL* with all optimizations known to work on your
  4328.      version of FreeBSD enabled.
  4329.  
  4330.    * Automatic configuration and build.
  4331.  
  4332.    * Startup scripts installed in /usr/local/etc/rc.d
  4333.  
  4334.    * Ability to see which files that are installed with pkg_info -L.
  4335.      And to remove them all with pkg_delete if you no longer want
  4336.      *MySQL* on that machine.
  4337.  
  4338. It is recomended to use MIT-pthreads on FreeBSD 2.x and native threads
  4339. on versions 3 and up. It is possible to run with with native threads on
  4340. some late 2.2.x versions but you may encounter problems shutting down
  4341. mysqld.
  4342.  
  4343. Be sure to have your name resolver setup correct. Otherwise you may
  4344. experience resolver delays or failures when connecting to mysqld.
  4345.  
  4346. Make sure that the `localhost' entry in the `/etc/hosts' file is
  4347. correct (otherwise you will have problems connecting to the database).
  4348. The `/etc/hosts' file should start with a line:
  4349.  
  4350.      127.0.0.1       localhost localhost.your.domain
  4351.  
  4352. If you notice that `configure' will use MIT-pthreads, you should read
  4353. the MIT-pthreads notes. *Note MIT-pthreads::.
  4354.  
  4355. If you get an error from `make install' that it can't find
  4356. `/usr/include/pthreads', `configure' didn't detect that you need
  4357. MIT-pthreads. This is fixed by executing these commands:
  4358.  
  4359.      shell> rm config.cache
  4360.      shell> ./configure --with-mit-threads
  4361.  
  4362. The behavior of FreeBSD `make' is slightly different from that of GNU
  4363. `make'. If you have `make'-related problems, you should install GNU
  4364. `make'.
  4365.  
  4366. FreeBSD is also known to have a very low default file handle limit.
  4367. *Note Not enough file handles::. Uncomment the ulimit -n section in
  4368. safe_mysqld or raise the limits for the mysqld user in /etc/login.conf
  4369. (and rebuild it witg cap_mkdb /etc/login.conf) also be sure you set the
  4370. appropriate Class for this user in the password file if you are not
  4371. using the default (use: chpass mysqld-user-name)
  4372.  
  4373. If you get problems with the current date in *MySQL*, setting the `TZ'
  4374. variable will probably help. *Note Environment variables::.
  4375.  
  4376. To get a secure and stable system you should only use FreeBSD kernels
  4377. that are marked `-STABLE'
  4378.  
  4379. NetBSD notes
  4380. ------------
  4381.  
  4382. To compile on NetBSD you need GNU `make'. Otherwise the compile will
  4383. crash when `make' tries to run `lint' on C++ files.
  4384.  
  4385. OpenBSD 2.5 notes
  4386. -----------------
  4387.  
  4388. On OpenBSD 2.5, you can compile *MySQL* with native threads with the
  4389. following options:
  4390.  
  4391.      CFLAGS=-pthread CXXFLAGS=-pthread ./configure --with-mit-threads=no
  4392.  
  4393. BSD/OS notes
  4394. ------------
  4395.  
  4396. BSD/OS 2.x notes
  4397. ................
  4398.  
  4399. If you get the following error when compiling *MySQL*, your `ulimit'
  4400. value for virtual memory is too low:
  4401.  
  4402.      item_func.h: In method `Item_func_ge::Item_func_ge(const Item_func_ge &)':
  4403.      item_func.h:28: virtual memory exhausted
  4404.      make[2]: *** [item_func.o] Error 1
  4405.  
  4406. Try using `ulimit -v 80000' and run `make' again.  If this doesn't work
  4407. and you are using `bash', try switching to `csh' or `sh'; some BSDI
  4408. users have reported problems with `bash' and `ulimit'.
  4409.  
  4410. If you are using `gcc', you may also use have to use the
  4411. `--with-low-memory' flag for `configure' to be able to compile
  4412. `sql_yacc.cc'.
  4413.  
  4414. If you get problems with the current date in *MySQL*, setting the `TZ'
  4415. variable will probably help. *Note Environment variables::.
  4416.  
  4417. BSD/OS 3.x notes
  4418. ................
  4419.  
  4420. Upgrade to BSD/OS 3.1. If that is not possible, install BSDIpatch
  4421. M300-038.
  4422.  
  4423. Use the following command when configuring *MySQL*:
  4424.  
  4425.      shell> env CXX=shlicc++ CC=shlicc2 \
  4426.             ./configure \
  4427.                 --prefix=/usr/local/mysql \
  4428.                 --localstatedir=/var/mysql \
  4429.                 --without-perl \
  4430.                 --with-unix-socket-path=/var/mysql/mysql.sock
  4431.  
  4432. The following is also known to work:
  4433.  
  4434.      shell> env CC=gcc CXX=gcc CXXFLAGS=-O3 \
  4435.             ./configure \
  4436.                 --prefix=/usr/local/mysql \
  4437.                 --with-unix-socket-path=/var/mysql/mysql.sock
  4438.  
  4439. You can change the directory locations if you wish, or just use the
  4440. defaults by not specifying any locations.
  4441.  
  4442. If you have problems with performance under heavy load, try using the
  4443. `--skip-thread-priority' option to `safe_mysqld'!  This will run all
  4444. threads with the same priority; on BSDI 3.1, this gives better
  4445. performance (at least until BSDI fixes their thread scheduler).
  4446.  
  4447. If you get the error `virtual memory exhausted' while compiling, you
  4448. should try using `ulimit -v 80000' and run `make' again.  If this
  4449. doesn't work and you are using `bash', try switching to `csh' or `sh';
  4450. some BSDI users have reported problems with `bash' and `ulimit'.
  4451.  
  4452. BSD/OS 4.x notes
  4453. ................
  4454.  
  4455. BSDI 4.x has some thread related bugs.  If you want to use *MySQL* on
  4456. this, you should install all thread related patches. At least M400-023
  4457. should be installed.
  4458.  
  4459. On some BSDI 4.x systems, you may get problems with shared libraries.
  4460. The symptom is that you can't execute any client programs, like for
  4461. example `mysqladmin'.  In this case you need to reconfigure not to use
  4462. shared libraries with the `--disable-shared' option to configure.
  4463.  
  4464. SCO notes
  4465. ---------
  4466.  
  4467. The current port is tested only on a "sco3.2v5.0.4" and "sco3.2v5.0.5"
  4468. system.  There has also been a lot of progress on a port to "sco
  4469. 3.2v4.2".
  4470.  
  4471. For the moment the recommended compiler on OpenServer is gcc 2.95.2.
  4472. With this you should be able to compile `MySQL' with just:
  4473.  
  4474.      CC=gcc CXX=gcc ./configure ... (options)
  4475.  
  4476.   1. For OpenServer 5.0.X you need to use GDS in Skunkware 95 (95q4c).
  4477.      This is necessary because GNU `gcc' 2.7.2 in Skunkware 97 does not
  4478.      have GNU `as'.  You can also use `egcs' 1.1.2 or newer
  4479.      `http://www.egcs.com/'.  If you are using `egcs' 1.1.2 you have to
  4480.      execute the following command:
  4481.  
  4482.           shell> cp -p /usr/include/pthread/stdtypes.h /usr/local/lib/gcc-lib/i386-pc-sco3.2v5.0.5/egcs-2.91.66/include/pthread/
  4483.  
  4484.   2. You need the port of GCC 2.5.? for this product and the Development
  4485.      system.  They are required on this version of SCO UNIX.  You cannot
  4486.      just use the GCC Dev system.
  4487.  
  4488.   3. You should get the FSU Pthreads package and install it first.
  4489.      This can be found at
  4490.      `http://www.cs.wustl.edu/~schmidt/ACE_wrappers/FSU-threads.tar.gz'.
  4491.      You can also get a precompiled package from
  4492.      `http://www.mysql.com/Downloads/SCO/FSU-threads-3.5c.tar.gz'.
  4493.  
  4494.   4. FSU Pthreads can be compiled with SCO UNIX 4.2 with tcpip.  Or
  4495.      OpenServer 3.0 or Open Desktop 3.0 (OS 3.0 ODT 3.0), with the SCO
  4496.      Development System installed using a good port of GCC 2.5.X ODT or
  4497.      OS 3.0 you will need a good port of GCC 2.5.? There are a lot of
  4498.      problems without a good port.  The port for this product requires
  4499.      the SCO UNIX Development system.  Without it, you are missing the
  4500.      libraries and the linker that is needed.
  4501.  
  4502.   5. To build FSU Pthreads on your system, do the following:
  4503.        1. Run `./configure' in the `threads/src' directory and select
  4504.           the SCO OpenServer option. This command copies
  4505.           `Makefile.SCO5' to `Makefile'.
  4506.  
  4507.        2. Run `make'.
  4508.  
  4509.        3. To install in the default `/usr/include' directory, login as
  4510.           root, then `cd' to the `thread/src' directory, and run `make
  4511.           install'.
  4512.  
  4513.   6. Remember to use GNU `make' when making *MySQL*.
  4514.  
  4515.   7. On OSR 5.0.5, you should use the following configure line:
  4516.           shell> CC="gcc -DSCO" CXX="gcc -DSCO" ./configure
  4517.      The `-DSCO' is needed to help configure detect some thread
  4518.      functions properly.  If you forget `-DSCO', you will get the
  4519.      following error message while compiling:
  4520.           my_pthread.c: In function `my_pthread_mutex_init':
  4521.           my_pthread.c:374: `pthread_mutexattr_default' undeclared (first use this function)
  4522.  
  4523.   8. If you don't start `safe_mysqld' as root, you probably will get
  4524.      only the default 110 open files per process.  `mysqld' will write
  4525.      a note about this in the log file.
  4526.  
  4527.   9. With SCO 3.2V5.0.5, you should use FSU Pthreads version 3.5c or
  4528.      newer.  The following `configure' command should work:
  4529.           shell> CC="gcc -belf" ./configure --prefix=/usr/local/mysql --disable-shared
  4530.  
  4531.  10. With SCO 3.2V4.2, you should use FSU Pthreads version 3.5c or
  4532.      newer.  The following `configure' command should work:
  4533.           shell> CFLAGS="-D_XOPEN_XPG4" CXX=gcc CXXFLAGS="-D_XOPEN_XPG4" \
  4534.                  ./configure \
  4535.                      --with-debug --prefix=/usr/local/mysql \
  4536.                      --with-named-thread-libs="-lgthreads -lsocket -lgen -lgthreads" \
  4537.                      --with-named-curses-libs="-lcurses"
  4538.      You may get some problems with some include files. In this case,
  4539.      you can find new SCO-specific include files at
  4540.      `http://www.mysql.com/Downloads/SCO/SCO-3.2v4.2-includes.tar.gz'.
  4541.      You should unpack this file in the `include' directory of your
  4542.      *MySQL* source tree.
  4543.  
  4544. SCO development notes:
  4545.  
  4546.    * *MySQL* should automatically detect FSU Pthreads and link `mysqld'
  4547.      with `-lgthreads -lsocket -lgthreads'.
  4548.  
  4549.    * The SCO development libraries are reentrant in FSU Pthreads. SCO
  4550.      claims that its libraries' functions are reentrant, so they must
  4551.      be reentrant with FSU Pthreads. FSU Pthreads on OpenServer tries
  4552.      to use the SCO scheme to make reentrant library.
  4553.  
  4554.    * FSU Pthreads (at least the version at `http://www.mysql.com/')
  4555.      comes linked with GNU `malloc'.  If you encounter problems with
  4556.      memory usage, make sure that `gmalloc.o' is included in
  4557.      `libgthreads.a' and `libgthreads.so'.
  4558.  
  4559.    * In FSU Pthreads, the following system calls are pthreads-aware:
  4560.      `read()', `write()', `getmsg()', `connect()', `accept()',
  4561.      `select()' and `wait()'.
  4562.  
  4563. If you want to install DBI on SCO, you have to edit the `Makefiles' in
  4564. DBI-xxx and each subdirectory:
  4565.  
  4566.      OLD:                                  NEW:
  4567.      CC = cc                               CC = gcc -belf
  4568.      CCCDLFLAGS = -KPIC -W1,-Bexport       CCCDLFLAGS = -fpic
  4569.      CCDLFLAGS = -wl,-Bexport              CCDLFLAGS =
  4570.      
  4571.      LD = ld                               LD = gcc -belf -G -fpic
  4572.      LDDLFLAGS = -G -L/usr/local/lib       LDDLFLAGS = -L/usr/local/lib
  4573.      LDFLAGS = -belf -L/usr/local/lib      LDFLAGS = -L/usr/local/lib
  4574.      
  4575.      LD = ld                               LD = gcc -belf -G -fpic
  4576.      OPTIMISE = -Od                       OPTIMISE = -O1
  4577.      
  4578.      OLD:
  4579.      CCCFLAGS = -belf -dy -w0 -U M_XENIX -DPERL_SCO5 -I/usr/local/include
  4580.      
  4581.      NEW:
  4582.      CCFLAGS = -U M_XENIX -DPERL_SCO5 -I/usr/local/include
  4583.  
  4584. This is because the Perl dynaloader will not load the `DBI' modules if
  4585. they were compiled with `icc' or `cc'.
  4586.  
  4587. Perl works best when compiled with `cc'.
  4588.  
  4589. SCO Unixware 7.0 notes
  4590. ----------------------
  4591.  
  4592. You must use a version of *MySQL* at least as recent as 3.22.13, because
  4593. that version fixes some portability problems under Unixware.
  4594.  
  4595. We have been able to compile *MySQL* with the following `configure'
  4596. command on UnixWare 7.0.1:
  4597.  
  4598.      shell> CC=cc CXX=CC ./configure --prefix=/usr/local/mysql
  4599.  
  4600. If you want to use `gcc', you must use `gcc' 2.95.2 or newer.
  4601.  
  4602. IBM-AIX notes
  4603. -------------
  4604.  
  4605. Automatic detection of `xlC' is missing from Autoconf, so a `configure'
  4606. command something like this is needed when compiling *MySQL*: (The
  4607. example uses the IBM compiler)
  4608.  
  4609.      shell> CC="xlc_r" CFLAGS="-ma -O3 -qstrict -DHAVE_INT_8_16_32" \
  4610.             CXX="xlC_r" CXXFLAGS="-ma -O3 -qstrict -DHAVE_INT_8_16_32" \
  4611.             ./configure
  4612.  
  4613. If you change the `-O3' to `-O2' in the above configure line, you must
  4614. also remove the `-qstrict' option (this is a limitation in the IBM C
  4615. compiler).
  4616.  
  4617. If you are using `gcc' or `egcs' to compile *MySQL*, you *MUST* use the
  4618. `-fno-exceptions' flag, as the exception handling in `gcc'/`egcs' is
  4619. not thread-safe!  (This is tested with `egcs' 1.1.)  We recommend the
  4620. following `configure' line with `egcs' and `gcc' on AIX:
  4621.  
  4622.      shell> CC=gcc \
  4623.             CFLAGS="-DHAVE_INT_8_16_32" \
  4624.             CXX=gcc \
  4625.             CXXFLAGS="-felide-constructors -fno-exceptions -fno-rtti -DHAVE_INT_8_16_32" \" \
  4626.             ./configure --prefix=/usr/local/mysql --with-debug --with-low-memory
  4627.  
  4628. If you have problems with signals (*MySQL* dies unexpectedly under high
  4629. load) you may have found an OS bug with threads and signals. In this
  4630. case you can tell *MySQL* not to use signals by configuring with:
  4631.  
  4632.      shell> CFLAGS=-DDONT_USE_THR_ALARM CXX=gcc \
  4633.             CXXFLAGS="-felide-constructors -fno-exceptions -fno-rtti -DDONT_USE_THR_ALARM" \
  4634.             ./configure --prefix=/usr/local/mysql --with-debug --with-low-memory
  4635.  
  4636. This doesn't affect the performance of *MySQL*, but has the side effect
  4637. that you can't kill clients that are "sleeping" on a connection with
  4638. `mysqladmin kill' or `mysqladmin shutdown'.  Instead, the client will
  4639. die when it issues its next command.
  4640.  
  4641. On some versions of AIX, linking with `libbind.a' makes `getservbyname'
  4642. core dump. This is an AIX bug and should be reported to IBM.
  4643.  
  4644. HP-UX 10.20 notes
  4645. -----------------
  4646.  
  4647. There are a couple of "small" problems when compiling *MySQL* on HP-UX.
  4648. We recommend that you use `gcc' instead of the HP-UX native compiler,
  4649. because `gcc' produces better code!
  4650.  
  4651. We recommend one to use gcc 2.95 on HP-UX.  Don't use high optimization
  4652. flags (like -O6) as this may not be safe on HP-UX.
  4653.  
  4654. Note that MIT-pthreads can't be compiled with the HP-UX compiler,
  4655. because it can't compile `.S' (assembler) files.
  4656.  
  4657. The following configure line should work:
  4658.  
  4659.      CFLAGS="-DHPUX -I/opt/dce/include" CXXFLAGS="-DHPUX -I/opt/dce/include -felide-constructors -fno-exceptions -fno-rtti" CXX=gcc ./configure --with-pthread --with-named-thread-libs='-ldce' --prefix=/usr/local/mysql --disable-shared
  4660.  
  4661. If you are compiling `gcc' 2.95 yourself, you should NOT link it with
  4662. the DCE libraries (`libdce.a' or `libcma.a') if you want to compile
  4663. *MySQL* with MIT-pthreads.  If you mix the DCE and MIT-pthreads
  4664. packages you will get a `mysqld' to which you cannot connect.  Remove
  4665. the DCE libraries while you compile `gcc' 2.95!
  4666.  
  4667. HP-UX 11.x notes
  4668. ----------------
  4669.  
  4670. For HPUX 11.x we recommend *MySQL* 3.23.15 or later.
  4671.  
  4672. If you are using `gcc' 2.95.1 on a unpatched HPUX 11.x system you will
  4673. get the error:
  4674.  
  4675.      In file included from /usr/include/unistd.h:11,
  4676.                       from ../include/global.h:125,
  4677.                       from mysql_priv.h:15,
  4678.                       from item.cc:19:
  4679.      /usr/include/sys/unistd.h:184: declaration of C function `int pthread_atfork(void (*)(...), void (*)
  4680.      (...), void (*)(...))' conflicts with
  4681.      /usr/include/sys/pthread.h:440: previous declaration `int pthread_atfork(void (*)(), void (*)(), voi
  4682.      d (*)())' here
  4683.      In file included from item.h:306,
  4684.                       from mysql_priv.h:158,
  4685.                       from item.cc:19:
  4686.  
  4687. The problem is that HP-UX doesn't define `pthreads_atfork()'
  4688. consistently.  It has conflicting prototypes in
  4689. `/usr/include/sys/unistd.h':184 and `/usr/include/sys/pthread.h':440 (I
  4690. post the details below).
  4691.  
  4692. One solution is to copy `/usr/include/sys/unistd.h' into
  4693. `mysql/include' and edit `unistd.h' and change it to match the
  4694. definition in `pthread.h'.  Here's the diff:
  4695.  
  4696.      183,184c183,184
  4697.      <      extern int pthread_atfork(void (*prepare)(), void (*parent)(),
  4698.      <                                                                  void (*child)());
  4699.      ---
  4700.      >      extern int pthread_atfork(void (*prepare)(void), void (*parent)(void),
  4701.      >                                                                  void (*child)(void));
  4702.  
  4703. After this, the following configure line should work:
  4704.  
  4705.      CFLAGS="-fomit-frame-pointer -O6 -fpic" CXX=gcc CXXFLAGS="-felide-constructors -fno-exceptions -fno-rtti -O6" ./configure --prefix=/usr/local/mysql --disable-shared
  4706.  
  4707. Here is some information that a HPUX 11.x user sent us about compile
  4708. *MySQL* with HPUX:x compiler
  4709.  
  4710.    *       Environment:
  4711.                 proper compilers.
  4712.                    setenv CC cc
  4713.                    setenv CXX aCC
  4714.                 flags
  4715.                    setenv CFLAGS -D_REENTRANT
  4716.                    setenv CXXFLAGS -D_REENTRANT
  4717.                    setenv CPPFLAGS -D_REENTRANT
  4718.                % aCC -V
  4719.                aCC: HP ANSI C++ B3910B X.03.14.06
  4720.                % cc -V /tmp/empty.c
  4721.                cpp.ansi: HP92453-01 A.11.02.00 HP C Preprocessor (ANSI)
  4722.                ccom: HP92453-01 A.11.01.00 HP C Compiler
  4723.                cc: "/tmp/empty.c", line 1: warning 501: Empty source file.
  4724.  
  4725.    *        configuration:
  4726.                ./configure  --with-pthread        \
  4727.                --prefix=/source-control/mysql     \
  4728.                --with-named-thread-libs=-lpthread \
  4729.                --with-low-memory
  4730.  
  4731.    *     added '#define _CTYPE_INCLUDED' to include/m_ctype.h. This
  4732.      symbol is the one defined in HP's /usr/include/ctype.h:
  4733.  
  4734.                /* Don't include std ctype.h when this is included */
  4735.                #define _CTYPE_H
  4736.                #define __CTYPE_INCLUDED
  4737.                #define _CTYPE_INCLUDED
  4738.                #define _CTYPE_USING   /* Don't put names in global namespace. */
  4739.  
  4740.    * I had to use the compile-time flag `-D_REENTRANT' to get the
  4741.      compiler to recognize the prototype for `localtime_r'.
  4742.      Alternatively I could have supplied the prototype for
  4743.      `localtime_r'. But I wanted to catch other bugs without needing to
  4744.      run into them. I wasn't sure where I needed it so I added it to all
  4745.      flags.
  4746.  
  4747.    * The optimization flags used by *MySQL* (-O3) are not recognized by
  4748.      HP's compilers. I did not change the flags.
  4749.  
  4750. MacOS X notes
  4751. -------------
  4752.  
  4753. You can get *MySQL* to work on MacOS X by following the links to the
  4754. MacOS X ports. *Note Useful Links::.
  4755.  
  4756. *MySQL* 3.23.7 should include all patches necessary to configure it on
  4757. MacOSX. You must however first install the pthread package from MySql
  4758. for MacOSX Server (http://www.prnet.de/RegEx/mysql.html) before
  4759. configuring *MySQL*.
  4760.  
  4761. You might want to also add aliases to your shell's resource file to
  4762. access `mysql' and `mysqladmin' from the command line.
  4763.  
  4764.      alias mysql '/usr/local/mysql/bin/mysql'
  4765.      alias mysqladmin '/usr/local/mysql/libexec/mysqladmin'
  4766.  
  4767. Win32 notes
  4768. ===========
  4769.  
  4770. This section describes installation and use of *MySQL* on Win32.  This
  4771. is also described in the `README' file that comes with the *MySQL*
  4772. Win32 distribution.
  4773.  
  4774. Installing MySQL on Win32
  4775. -------------------------
  4776.  
  4777. If you don't have a registered version of *MySQL*, you should first
  4778. download the shareware version from:
  4779.  
  4780. *MySQL* 3.22.x (http://www.mysql.com/mysql_w32.htmy)
  4781.  
  4782. If you plan to connect to *MySQL* from some other program, you will
  4783. probably also need the *MyODBC* driver. You can find this at the
  4784. *MyODBC* download page (http://www.mysql.com/downloads/api-myodbc.html).
  4785.  
  4786. To install either distribution, unzip it in some empty directory and
  4787. run the `Setup.exe' program.
  4788.  
  4789. By default, *MySQL*-Win32 is configured to be installed in `C:\mysql'.
  4790. If you want to install *MySQL* elsewhere, install it in `C:\mysql',
  4791. then move the installation to where you want it.  If you do move
  4792. *MySQL*, you must tell `mysqld' where everything is by supplying
  4793. options to `mysqld'. Use `C:\mysql\bin\mysqld --help' to display all
  4794. options!  For example, if you have moved the *MySQL* distribution to
  4795. `D:\programs\mysql', you must start `mysqld' with:
  4796. `D:\programs\mysql\bin\mysqld --basedir D:\programs\mysql'
  4797.  
  4798. With the registered version of *MySQL*, you can also create a
  4799. `C:\my.cnf' file that holds any default options for the *MySQL* server.
  4800. Copy the file `\mysql\my-xxxxx.cnf' to `C:\my.cnf' and edit this to
  4801. suit your setup.  Note that you should specify all paths with `/'
  4802. instead of `\'. If you use `\', you need to specify this twice, as `\'
  4803. is the escape character in *MySQL*.  *Note Option files::.
  4804.  
  4805. Starting MySQL on Win95 / Win98
  4806. -------------------------------
  4807.  
  4808. *MySQL* uses TCP/IP to connect a client to a server. (This will allow
  4809. any machine on your network to connect to your *MySQL* server). Because
  4810. of this, you must install TCP/IP on your machine before starting
  4811. *MySQL*.  You can find TCP/IP on your Windows CD-ROM.
  4812.  
  4813. Note that if you are using an old Win95 release (for example OSR2), it's
  4814. likely that you have an old Winsock package!  *MySQL* requires Winsock
  4815. 2!  You can get the newest Winsock from Microsoft
  4816. (http://www.microsoft.com).  Win98 has as default the new Winsock 2
  4817. library, so the above doesn't apply for Win98.
  4818.  
  4819. There are 2 different *MySQL* servers you can use:
  4820.  
  4821. `mysqld'    Compiled with full debugging and automatic memory allocation
  4822.             checking
  4823. `mysqld-opt'Optimized for a Pentium processor.
  4824.  
  4825. Both of the above should work on any Intel processor >= i386.
  4826.  
  4827. To start the `mysqld' server, you should start an MS-DOS window and
  4828. type:
  4829.  
  4830.      C:\mysql\bin\mysqld
  4831.  
  4832. This will start `mysqld' in the background without a window.
  4833.  
  4834. You can kill the *MySQL* server by executing:
  4835.  
  4836.      C:\mysql\bin\mysqladmin -u root shutdown
  4837.  
  4838. Note that Win95/Win98 don't support creation of named pipes.  On
  4839. Win95/Win98, you can only use named pipes to connect to a remote
  4840. *MySQL* running on an NT server.
  4841.  
  4842. If `mysqld' doesn't start please check whether or not the
  4843. `\mysql\mysql.err' file contains any reason for this.  You can also try
  4844. to start it with `mysqld --standalone';  In this case you may get some
  4845. useful information on the screen that may help solve this.
  4846.  
  4847. The last option is to start `mysqld' with `--debug'.  In this case
  4848. `mysqld' will write a log file in `\mysqld.trace' that should contain
  4849. the reason why `mysqld' doesn't start.  If you make a bug report about
  4850. this, please only send the lines where something seams to go wrong to
  4851. the mailing list!
  4852.  
  4853. Starting MySQL on NT / Win200
  4854. -----------------------------
  4855.  
  4856. The Win95/Win98 section also applies to *MySQL* on NT / Win2000, with
  4857. the following differences:
  4858.  
  4859. To get *MySQL* to work with TCP/IP on NT, you must install service pack
  4860. 3 (or newer)!
  4861.  
  4862. Note that everything in the following that applies for NT, also applies
  4863. for Win2000!
  4864.  
  4865. For NT / Win2000, the server name is `mysqld-nt'.  Normally you should
  4866. install *MySQL* as a service on NT/Win2000:
  4867.  
  4868.      C:\mysql\bin\mysqld-nt --install
  4869.  
  4870. (You could use the `mysqld' or `mysqld-opt' servers on NT, but those
  4871. cannot be started as a service or use named pipes.)
  4872.  
  4873. You can start and stop the *MySQL* service with:
  4874.  
  4875.      NET START mysql
  4876.      NET STOP mysql
  4877.  
  4878. Note that in this case you can't use any other options for `mysqld-nt'!
  4879.  
  4880. You can also run `mysqld-nt' as a standalone program on NT if you need
  4881. to start `mysqld-nt' with any options!  If you start `mysqld-nt'
  4882. without options on NT, `mysqld-nt' tries to starts itself as a service
  4883. with the default service options.  If you have stopped `mysqld-nt', you
  4884. have to start it with `NET START mysql'.
  4885.  
  4886. The service is installed with the name `MySql'. Once installed, it must
  4887. be started using Services Control Manager (SCM) Utility (found in
  4888. Control Panel) or by using the `NET START MySQL' command. If any
  4889. options are desired, they must be specified as "Startup parameters" in
  4890. the SCM utility before you start the *MySQL* service.  Once running,
  4891. `mysqld-nt' can be stopped using `mysqladmin' or from the SCM utility
  4892. or by using the command `NET STOP MySQL'. If you use SCM to stop
  4893. `mysqld-nt', there is a strange message from SCM about `mysqld shutdown
  4894. normally'.  When run as a service, `mysqld-nt' has no access to a
  4895. console and so no messages can be seen.
  4896.  
  4897. On NT you can get the following service error messages:
  4898.  
  4899. Permission Denied      Means that it cannot find `mysqld-nt.exe'
  4900. Cannot Register        Means that the path is incorrect
  4901.  
  4902. If you have problems installing `mysqld-nt' as a service, try starting
  4903. it with the full path:
  4904.  
  4905.      C:\mysql\bin\mysqld-nt --install
  4906.  
  4907. If this doesn't work, you can get `mysqld-nt' to start properly by
  4908. fixing the path in the registry!
  4909.  
  4910. If you don't want to start `mysqld-nt' as a service, you can start it as
  4911. follows:
  4912.  
  4913.      C:\mysql\bin\mysqld-nt --standalone
  4914.  
  4915. or
  4916.  
  4917.      C:\mysql\bin\mysqld --standalone --debug
  4918.  
  4919. The last version gives you a debug trace in `C:\mysqld.trace'.
  4920.  
  4921. Running MySQL on Win32
  4922. ----------------------
  4923.  
  4924. *MySQL* supports TCP/IP on all Win32 platforms and named pipes on NT.
  4925. The default is to use named pipes for local connections on NT and
  4926. TCP/IP for all other cases if the client has TCP/IP installed.  The
  4927. host name specifies which protocol is used:
  4928.  
  4929. *Host name* *protocol*             
  4930. NULL (none)            On NT, try named pipes first; if that doesn't
  4931.                        work, use TCP/IP. On Win95/Win98, TCP/IP is used.
  4932. .                      Named pipes
  4933. localhost              TCP/IP to current host
  4934. hostname               TCP/IP
  4935.  
  4936.  
  4937. You can force a *MySQL* client to use named pipes by specifying the
  4938. `--pipe' option.  Use the `--socket' option to specify the name of the
  4939. pipe.
  4940.  
  4941. You can test whether or not *MySQL* is working by executing the
  4942. following commands:
  4943.  
  4944.      C:\mysql\bin\mysqlshow
  4945.      C:\mysql\bin\mysqlshow -u root mysql
  4946.      C:\mysql\bin\mysqladmin version status proc
  4947.      C:\mysql\bin\mysql test
  4948.  
  4949. If `mysqld' is slow to answer to connections on Win95/Win98, there is
  4950. probably a problem with your DNS. In this case, start `mysqld' with
  4951. `--skip-name-resolve' and use only `localhost' and IP numbers in the
  4952. *MySQL* grant tables.  You can also avoid DNS when connecting to a
  4953. `mysqld-nt' *MySQL* server running on NT by using the `--pipe' argument
  4954. to specify use of named pipes.  This works for most *MySQL* clients.
  4955.  
  4956. There are two versions of the *MySQL* command line tool:
  4957. `mysql'     Compiled on native Win32, which offers very limited text
  4958.             editing capabilities.
  4959. `mysqlc'    Compiled with the Cygnus GNU compiler and libraries, which
  4960.             offers `readline' editing.
  4961.  
  4962. If you want to use `mysqlc.exe', you must copy
  4963. `C:\mysql\lib\cygwinb19.dll' to `\windows\system' (or similar place).
  4964.  
  4965. The default privileges on Win32 give all local users full privileges to
  4966. all databases.  To make *MySQL* more secure, you should set a password
  4967. for all users and remove the row in the `mysql.user' table that has
  4968. `Host='localhost'' and `User='''.
  4969.  
  4970. You should also add a password for the `root' user: (The following
  4971. example starts by removing the anonymous user, that allows anyone to
  4972. access the 'test' database)
  4973.  
  4974.      C:\mysql\bin\mysql mysql
  4975.      mysql> DELETE FROM user WHERE Host='localhost' AND User='';
  4976.      mysql> QUIT
  4977.      C:\mysql\bin\mysqladmin reload
  4978.      C:\mysql\bin\mysqladmin -u root password your_password
  4979.  
  4980. After you've set the password, if you want to take down the `mysqld'
  4981. server, you can do so using this command:
  4982.  
  4983.      mysqladmin --user=root --password=your_password shutdown
  4984.  
  4985. If you are using the old shareware version of *MySQL* 3.21 under
  4986. Windows, the above command will fail with an error: `parse error near
  4987. 'SET OPTION password''.  This is because the old shareware version,
  4988. which is based on *MySQL* 3.21, doesn't have the `SET PASSWORD'
  4989. command.  The fix is in this case is to upgrade to the 3.22 shareware
  4990. version.
  4991.  
  4992. With the newer *MySQL* versions you can easily add new users and change
  4993. privileges with `GRANT' and `REVOKE' commands.  *Note GRANT::.
  4994.  
  4995. Connecting to a remote MySQL from Win32 with SSH
  4996. ------------------------------------------------
  4997.  
  4998. Here is a note about how to connect to get a secure connection to
  4999. remote MySQL server with SSH (by David Carlson).
  5000.  
  5001.    * Install SSH client on your windows machine - I used a free SSH
  5002.      client from `http://www.doc.ic.ac.uk/~ci2/ssh/'.  Other useful
  5003.      links:
  5004.      `http://www.npaci.edu/Security/npaci_security_software.html' and
  5005.      `http://www.npaci.edu/Security/samples/ssh32_windows/index.html'.
  5006.  
  5007.    * Start SSH. Set Host Name = yourmysqlserver name or IP address. Set
  5008.      userid=your userid to log in to your server
  5009.  
  5010.    * Click on "local forwards". Set `local port: 3306', `host:
  5011.      localhost', `remote port: 3306'
  5012.  
  5013.    * Save everything, otherwise you'll have to redo it the next time.
  5014.  
  5015.    * Log in to your server with SSH.
  5016.  
  5017.    * Start some ODBC application (for example Access)
  5018.  
  5019.    * Create a new file and link to mySQL using the ODBC driver the same
  5020.      way you normally do except for server, user "localhost".
  5021.  
  5022. That's it. It works very well with a direct Internet connection. I'm
  5023. having problems with SSH conflicting with my Win95 network and Wingate -
  5024. but that'll be the topic of a posting on another software company's
  5025. usegroup!
  5026.  
  5027. Splitting data across different disks under Win32
  5028. -------------------------------------------------
  5029.  
  5030. On windows *MySQL* 3.23.16 and above is compiled with the
  5031. `-DUSE_SYMDIR' option.  This allows you to put a database on different
  5032. disk by adding a symbolic link to it (in a similar manner that symbolic
  5033. links works on Unix).
  5034.  
  5035. On windows you make a symbolic link to a database by creating a file
  5036. that contains the path to the destination directory and saving this in
  5037. the `mysql_data' directory under the filename `database.sym'.  Note
  5038. that the symbolic link will only be used if the directory
  5039. `mysql_data_dir\database' doesn't exist.
  5040.  
  5041. For example if you want to have database `foo' on `D:\data\foo' you
  5042. should create the file `C:\mysql\data\foo.sym' that should contains the
  5043. text `D:\data\foo'.  After this, all tables created in the database
  5044. `foo' will be created in `D:\data\foo'.
  5045.  
  5046. Compiling MySQL clients on Windows.
  5047. -----------------------------------
  5048.  
  5049. In your source files, you should include `windows.h' before you include
  5050. `mysql.h':
  5051.  
  5052.      #if defined(_WIN32) || defined(_WIN64)
  5053.      #include <windows.h>
  5054.      #endif
  5055.      #include <mysql.h>
  5056.  
  5057. You can either link your code with the dynamic `libmysql.lib' library,
  5058. which is just a wrapper to load in `libmysql.dll' on demand, or link
  5059. with the static `mysqlclient.lib' library.
  5060.  
  5061. Note that as the mysqlclient libraries are compiled as threaded
  5062. libraries, you should also compile your code to be multi-threaded!
  5063.  
  5064. MySQL-Win32 compared to Unix MySQL
  5065. ----------------------------------
  5066.  
  5067. *MySQL*-Win32 has by now proven itself to be very stable. This version
  5068. of *MySQL* has the same features as the corresponding Unix version with
  5069. the following exceptions:
  5070.  
  5071. *Win95 and threads*
  5072.      Win95 leaks about 200 bytes of main memory for each thread
  5073.      creation.  Because of this, you shouldn't run `mysqld' for an
  5074.      extended time on Win95 if you do many connections, because each
  5075.      connection in *MySQL* creates a new thread!  WinNT and Win98 don't
  5076.      suffer from this bug.
  5077.  
  5078. *Concurrent reads*
  5079.      *MySQL* depends on the `pread()' and `pwrite()' calls to be able
  5080.      to mix `INSERT' and `SELECT'. As windows doesn't support these
  5081.      calls, *MySQL* can't currently handle concurrent reads on windows.
  5082.      We plan to fix this by adding an extra mutex to each open file and
  5083.      simulate `pread()'/`pwrite()'.
  5084.  
  5085. *Blocking read*
  5086.      *MySQL* uses a blocking read for each connection.  This means that:
  5087.  
  5088.         * A connection will not be disconnected automatically after 8
  5089.           hours, as happens with the Unix version of *MySQL*.
  5090.  
  5091.         * If a connection "hangs," it's impossible to break it without
  5092.           killing *MySQL*.
  5093.  
  5094.         * `mysqladmin kill' will not work on a sleeping connection.
  5095.  
  5096.         * `mysqladmin shutdown' can't abort as long as there are
  5097.           sleeping connections.
  5098.  
  5099.      We plan to fix this in the near future.
  5100.  
  5101. *UDF functions*
  5102.      For the moment, *MySQL*-Win32 does not support user definable
  5103.      functions.
  5104.  
  5105. *`DROP DATABASE'*
  5106.      You can't drop a database that is in use by some thread.
  5107.  
  5108. *Killing *MySQL* from the task manager*
  5109.      You can't kill *MySQL* from the task manager or with the shutdown
  5110.      utility in Windows95. You must take it down with `mysqladmin
  5111.      shutdown'.
  5112.  
  5113. *Case-insensitive names*
  5114.      Filenames are case insensitive on Win32, so database and table
  5115.      names are also case insensitive in *MySQL* for Win32.  The only
  5116.      restriction is that database and table names must be given in the
  5117.      same case throughout a given statement.  The following query would
  5118.      not work because it refers to a table both as `my_table' and as
  5119.      `MY_TABLE':
  5120.           SELECT * FROM my_table WHERE MY_TABLE.col=1;
  5121.  
  5122. *The `\' directory character*
  5123.      Pathname components in Win95 are separated by `\' characters,
  5124.      which is also the escape character in *MySQL*.  If you are using
  5125.      `LOAD DATA INFILE' or `SELECT ... INTO OUTFILE', you must double
  5126.      the `\' character or use Unix style filenames `/' characters:
  5127.           LOAD DATA INFILE "C:\\tmp\\skr.txt" INTO TABLE skr;
  5128.           SELECT * INTO OUTFILE 'C:/tmp/skr.txt' FROM skr;
  5129.  
  5130. *`Can't open named pipe' error*
  5131.      If you use the shareware version of *MySQL*-Win32 on NT with the
  5132.      newest mysql-clients you will get the following error:
  5133.  
  5134.           error 2017: can't open named pipe to host: . pipe...
  5135.  
  5136.      This is because the release version of *MySQL* uses named pipes on
  5137.      NT by default.  You can avoid this error by using the
  5138.      `--host=localhost' option to the new *MySQL* clients or create a
  5139.      file `C:\my.cnf' that contains the following information:
  5140.  
  5141.           [client]
  5142.           host = localhost
  5143.  
  5144. *`Access denied for user' error*
  5145.      If you get the error `Access denied for user: 'some-user@unknown'
  5146.      to database 'mysql'' when accessing a *MySQL* server on the same
  5147.      machine, this means that *MySQL* can't resolve your host name
  5148.      properly.
  5149.  
  5150.      To fix this, you should create a file `\windows\hosts' with the
  5151.      following information:
  5152.  
  5153.           127.0.0.1       localhost
  5154.  
  5155. Here are some open issues for anyone who might want to help us with the
  5156. Win32 release:
  5157.  
  5158.    * Make a single user `MYSQL.DLL' server.  This should include
  5159.      everything in a standard *MySQL* server, except thread creation.
  5160.      This will make *MySQL* much easier to use in applications that
  5161.      don't need a true client/server and don't need to access the
  5162.      server from other hosts.
  5163.  
  5164.    * Add some nice "start" and "shutdown" icons to the *MySQL*
  5165.      installation.
  5166.  
  5167.    * Create a tool to manage registry entries for the *MySQL* startup
  5168.      options.  The registry entry reading is already coded into
  5169.      `mysqld.cc', but it should be recoded to be more "parameter"
  5170.      oriented.  The tool should also be able to update the `\my.cnf'
  5171.      file if the user would prefer to use this instead of the registry.
  5172.  
  5173.    * When registering `mysqld' as a service with `--install' (on NT) it
  5174.      would be nice if you could also add default options on the command
  5175.      line.  For the moment, the workaround is to update the `C:\my.cnf'
  5176.      file instead.
  5177.  
  5178.    * When you suspend a laptop running Win95, the `mysqld' daemon
  5179.      doesn't accept new connections when the laptop is resumed.  We
  5180.      don't know if this is a problem with Win95, TCP/IP or *MySQL*.
  5181.  
  5182.    * It would be real nice to be able to kill `mysqld' from the task
  5183.      manager.  For the moment, you must use `mysqladmin shutdown'.
  5184.  
  5185.    * Port `readline' to Win32 for use in the `mysql' command line tool.
  5186.  
  5187.    * GUI versions of the standard *MySQL* clients (`mysql',
  5188.      `mysqlshow', `mysqladmin', and `mysqldump') would be nice.
  5189.  
  5190.    * It would be nice if the socket "read" and "write" functions in
  5191.      `net.c' were interruptible. This would make it possible to kill
  5192.      open threads with `mysqladmin kill' on Win32.
  5193.  
  5194.    * Documentation of which Windows programs work with
  5195.      *MySQL*-Win32/*MyODBC* and what must be done to get them working.
  5196.  
  5197.    * `mysqld' always starts in the "C" locale and not in the default
  5198.      locale.  We would like to have `mysqld' use the current locale for
  5199.      the sort order.
  5200.  
  5201.    * Port `sqlclient' to Win32 (almost done) and add more features to
  5202.      it!
  5203.  
  5204.    * Add more options to MysqlManager.
  5205.  
  5206.    * Change the communication protocol between the server and client to
  5207.      use Windows internal communication instead of sockets and TCP/IP.
  5208.  
  5209.    * Implement UDF functions with `.DLL's.
  5210.  
  5211.    * Add macros to use the faster thread-safe increment/decrement
  5212.      methods provided by Win32.
  5213.  
  5214.  
  5215. Other Win32-specific issues are described in the `README' file that
  5216. comes with the *MySQL*-Win32 distribution.
  5217.  
  5218. OS/2 notes
  5219. ==========
  5220.  
  5221. *MySQL* uses quite a few open files. Because of this, you should add
  5222. something like the following to your `CONFIG.SYS' file:
  5223.  
  5224.      SET EMXOPT=-c -n -h1024
  5225.  
  5226. If you don't do this, you will probably run into the following error:
  5227.  
  5228.      File 'xxxx' not found (Errcode: 24)
  5229.  
  5230. When using *MySQL* with OS/2 Warp 3, FixPack 29 or above is required.
  5231. With OS/2 Warp 4, FixPack 4 or above is required. This is a requirement
  5232. of the Pthreads library.  *MySQL* must be installed in a partition that
  5233. supports long file names such as HPFS, FAT32, etc.
  5234.  
  5235. The `INSTALL.CMD' script must be run from OS/2's own `CMD.EXE' and may
  5236. not work with replacement shells such as `4OS2.EXE'.
  5237.  
  5238. The `scripts/mysql-install-db' script has been renamed: it is now called
  5239. `install.cmd' and is a REXX script which will set up the default
  5240. *MySQL* security settings and create the WorkPlace Shell icons for
  5241. *MySQL*.
  5242.  
  5243. Dynamic module support is compiled in but not fully tested. Dynamic
  5244. modules should be compiled using the Pthreads runtime library.
  5245.  
  5246.      gcc -Zdll -Zmt -Zcrtdll=pthrdrtl -I../include -I../regex -I.. \
  5247.          -o example udf_example.cc -L../lib -lmysqlclient udf_example.def
  5248.      mv example.dll example.udf
  5249.  
  5250. *Note:* Due to limitations in OS/2, UDF module name stems must not
  5251. exceed 8 characters. Modules are stored in the `/mysql2/udf' directory;
  5252. the `safe-mysqld.cmd' script will put this directory in the
  5253. `BEGINLIBPATH' environment variable. When using UDF modules, specified
  5254. extensions are ignored -- it is assumed to be `.udf'.  For example, in
  5255. Unix, the shared module might be named `example.so' and you would load
  5256. a function from it like this:
  5257.  
  5258.      CREATE FUNCTION metaphon RETURNS STRING SONAME "example.so";
  5259.  
  5260. Is OS/2, the module would be named `example.udf', but you would not
  5261. specify the module extension:
  5262.  
  5263.      CREATE FUNCTION metaphon RETURNS STRING SONAME "example";
  5264.  
  5265. MySQL binaries
  5266. ==============
  5267.  
  5268. As a service, we at MySQL AB provides a set of binary distributions of
  5269. *MySQL* that are compiled at our site or at sites where customers
  5270. kindly have given us access to their machines.
  5271.  
  5272. These distributions are generated with
  5273. `scripts/make_binary_distribution' and are configured with the
  5274. following compilers and options:
  5275.  
  5276. SunOS 4.1.4 2 sun4c with `gcc' 2.7.2.1
  5277.      `CC=gcc CXX=gcc CXXFLAGS=-O3 ./configure --prefix=/usr/local/mysql
  5278.      --disable-shared --with-extra-charsets=complex'
  5279.  
  5280. SunOS 5.5.1 sun4u with `egcs' 1.0.3a
  5281.      `CC=gcc CFLAGS="-O6 -fomit-frame-pointer" CXX=gcc CXXFLAGS="-O6
  5282.      -fomit-frame-pointer -felide-constructors -fno-exceptions
  5283.      -fno-rtti" ./configure --prefix=/usr/local/mysql --with-low-memory
  5284.      --with-extra-charsets=complex'
  5285.  
  5286. SunOS 5.6 sun4u with `egcs' 2.90.27
  5287.      `CC=gcc CFLAGS="-O6 -fomit-frame-pointer" CXX=gcc CXXFLAGS="-O6
  5288.      -fomit-frame-pointer -felide-constructors -fno-exceptions
  5289.      -fno-rtti" ./configure --prefix=/usr/local/mysql --with-low-memory
  5290.      --with-extra-charsets=complex'
  5291.  
  5292. SunOS 5.6 i86pc with `gcc' 2.8.1
  5293.      `CC=gcc CXX=gcc CXXFLAGS=-O3 ./configure --prefix=/usr/local/mysql
  5294.      --with-low-memory --with-extra-charsets=complex'
  5295.  
  5296. Linux 2.0.33 i386 with `pgcc' 2.90.29 (`egcs' 1.0.3a)
  5297.      `CFLAGS="-O6 -mpentium -mstack-align-double -fomit-frame-pointer"
  5298.      CXX=gcc CXXFLAGS="-O6 -mpentium -mstack-align-double
  5299.      -fomit-frame-pointer -felide-constructors -fno-exceptions
  5300.      -fno-rtti" ./configure --prefix=/usr/local/mysql
  5301.      --enable-assembler --with-mysqld-ldflags=-all-static
  5302.      --with-extra-charsets=complex'
  5303.  
  5304. Linux 2.2.x with x686 with `gcc' 2.95.2
  5305.      `CFLAGS="-O6 -mpentiumpro -fomit-frame-pointer" CXX=gcc
  5306.      CXXFLAGS="-O6 -mpentiumpro -fomit-frame-pointer
  5307.      -felide-constructors -fno-exceptions -fno-rtti" ./configure
  5308.      --prefix=/usr/local/mysql --enable-assembler
  5309.      --with-mysqld-ldflags=-all-static --disable-shared
  5310.      --with-extra-charset=complex'
  5311.  
  5312. SCO 3.2v5.0.4 i386 with `gcc' 2.7-95q4
  5313.      `CC=gcc CXX=gcc CXXFLAGS=-O3 ./configure --prefix=/usr/local/mysql
  5314.      --with-extra-charsets=complex'
  5315.  
  5316. AIX 2 4 with `gcc' 2.7.2.2
  5317.      `CC=gcc CXX=gcc CXXFLAGS=-O3 ./configure --prefix=/usr/local/mysql
  5318.      --with-extra-charsets=complex'
  5319.  
  5320. OSF1 V4.0 564 alpha with `gcc' 2.8.1
  5321.      `CC=gcc CFLAGS=-O CXX=gcc CXXFLAGS=-O3 ./configure
  5322.      --prefix=/usr/local/mysql --with-low-memory
  5323.      --with-extra-charsets=complex'
  5324.  
  5325. Irix 6.3 IP32 with `gcc' 2.8.0
  5326.      `CC=gcc CXX=gcc CXXFLAGS=-O3 ./configure --prefix=/usr/local/mysql
  5327.      --with-extra-charsets=complex'
  5328.  
  5329. BSDI BSD/OS 3.1 i386 with `gcc' 2.7.2.1
  5330.      `CC=gcc CXX=gcc CXXFLAGS=-O ./configure --prefix=/usr/local/mysql
  5331.      --with-extra-charsets=complex'
  5332.  
  5333. BSDI BSD/OS 2.1 i386 with `gcc' 2.7.2
  5334.      `CC=gcc CXX=gcc CXXFLAGS=-O3 ./configure --prefix=/usr/local/mysql
  5335.      --with-extra-charsets=complex'
  5336.  
  5337. Anyone who has more optimal options for any of the configurations listed
  5338. above can always mail them to the developer's mailing list at
  5339. <developer@lists.mysql.com>.
  5340.  
  5341. RPM distributions prior to *MySQL* 3.22 are user-contributed.
  5342. Beginning with 3.22, some RPMs are generated by us at MySQL AB.
  5343.  
  5344. If you want to compile a debug version of *MySQL*, you should add
  5345. `--with-debug' or `--with-debug=full' to the above configure lines and
  5346. remove any `-fomit-frame-pointer' options.
  5347.  
  5348. Post-installation setup and testing
  5349. ===================================
  5350.  
  5351. Once you've installed *MySQL* (from either a binary or source
  5352. distribution), you need to initialize the grant tables, start the server
  5353. and make sure that the server works okay.  You may also wish to arrange
  5354. for the server to be started and stopped automatically when your system
  5355. starts up and shuts down.
  5356.  
  5357. Normally you install the grant tables and start the server like this
  5358. for installation from a source distribution:
  5359.  
  5360.      shell> ./scripts/mysql_install_db
  5361.      shell> cd mysql_installation_directory
  5362.      * Command-line options::        Command-line options
  5363.      shell> ./bin/safe_mysqld &
  5364.  
  5365. For a binary distribution, do this:
  5366.  
  5367.      shell> cd mysql_installation_directory
  5368.      shell> ./bin/mysql_install_db
  5369.      shell> ./bin/safe_mysqld &
  5370.  
  5371. Testing is most easily done from the top-level directory of the *MySQL*
  5372. distribution.  For a binary distribution, this is your installation
  5373. directory (typically something like `/usr/local/mysql').  For a source
  5374. distribution, this is the main directory of your *MySQL* source tree.
  5375.  
  5376. In the commands shown below in this section and in the following
  5377. subsections, `BINDIR' is the path to the location in which programs
  5378. like `mysqladmin' and `safe_mysqld' are installed.  For a binary
  5379. distribution, this is the `bin' directory within the distribution.  For
  5380. a source distribution, `BINDIR' is probably `/usr/local/bin', unless
  5381. you specified an installation directory other than `/usr/local' when
  5382. you ran `configure'.  `EXECDIR' is the location in which the `mysqld'
  5383. server is installed.  For a binary distribution, this is the same as
  5384. `BINDIR'.  For a source distribution, `EXECDIR' is probably
  5385. `/usr/local/libexec'.
  5386.  
  5387. Testing is described in detail below:
  5388.  
  5389.   1. If necessary, start the `mysqld' server and set up the initial
  5390.      *MySQL* grant tables containing the privileges that determine how
  5391.      users are allowed to connect to the server.  This is normally done
  5392.      with the `mysql_install_db' script:
  5393.  
  5394.           shell> scripts/mysql_install_db
  5395.  
  5396.      Typically, `mysql_install_db' needs to be run only the first time
  5397.      you install *MySQL*.  Therefore, if you are upgrading an existing
  5398.      installation, you can skip this step. (However, `mysql_install_db'
  5399.      is quite safe to use and will not update any tables that already
  5400.      exist, so if you are unsure what to do, you can always run
  5401.      `mysql_install_db'.)
  5402.  
  5403.      `mysql_install_db' creates six tables (`user', `db', `host',
  5404.      `tables_priv', `columns_priv' and `func') in the `mysql' database.
  5405.      A description of the initial privileges is given in *Note Default
  5406.      privileges::.  Briefly, these privileges allow the *MySQL* `root'
  5407.      user to do anything, and allow anybody to create or use databases
  5408.      with a name of `'test'' or starting with `'test_''.
  5409.  
  5410.      If you don't set up the grant tables, the following error will
  5411.      appear in the log file when you start the server:
  5412.  
  5413.           mysqld: Can't find file: 'host.frm'
  5414.  
  5415.      The above may also happens with a binary *MySQL* distribution if
  5416.      you don't start *MySQL* by executing exactly `./bin/safe_mysqld'!
  5417.  
  5418.      You might need to run `mysql_install_db' as `root'.  However, if
  5419.      you prefer, you can run the *MySQL* server as an unprivileged
  5420.      (non-`root') user, provided that user can read and write files in
  5421.      the database directory.  Instructions for running *MySQL* as an
  5422.      unprivileged user are given in *Note Changing *MySQL* user:
  5423.      Changing MySQL user.
  5424.  
  5425.      If you have problems with `mysql_install_db', see *Note
  5426.      `mysql_install_db': mysql_install_db.
  5427.  
  5428.      There are some alternatives to running the `mysql_install_db'
  5429.      script as it is provided in the *MySQL* distribution:
  5430.  
  5431.         * You may want to edit `mysql_install_db' before running it, to
  5432.           change the initial privileges that are installed into the
  5433.           grant tables.  This is useful if you want to install *MySQL*
  5434.           on a lot of machines with the same privileges.  In this case
  5435.           you probably should need only to add a few extra `INSERT'
  5436.           statements to the `mysql.user' and `mysql.db' tables!
  5437.  
  5438.         * If you want to change things in the grant tables after
  5439.           installing them, you can run `mysql_install_db', then use
  5440.           `mysql -u root mysql' to connect to the grant tables as the
  5441.           *MySQL* `root' user and issue SQL statements to modify the
  5442.           grant tables directly.
  5443.  
  5444.         * It is possible to recreate the grant tables completely after
  5445.           they have already been created.  You might want to do this if
  5446.           you've already installed the tables but then want to recreate
  5447.           them after editing `mysql_install_db'.
  5448.  
  5449.      For more information about these alternatives, see *Note Default
  5450.      privileges::.
  5451.  
  5452.   2. Start the *MySQL* server like this:
  5453.           shell> cd mysql_installation_directory
  5454.           shell> bin/safe_mysqld &
  5455.      If you have problems starting the server, see *Note Starting
  5456.      server::.
  5457.  
  5458.   3. Use `mysqladmin' to verify that the server is running.  The
  5459.      following commands provide a simple test to check that the server
  5460.      is up and responding to connections:
  5461.  
  5462.           shell> BINDIR/mysqladmin version
  5463.           shell> BINDIR/mysqladmin variables
  5464.  
  5465.      The output from `mysqladmin version' varies slightly depending on
  5466.      your platform and version of *MySQL*, but should be similar to
  5467.      that shown below:
  5468.  
  5469.           shell> BINDIR/mysqladmin version
  5470.           mysqladmin  Ver 6.3 Distrib 3.22.9-beta, for pc-linux-gnu on i686
  5471.           TCX Datakonsult AB, by Monty
  5472.           
  5473.           Server version          3.22.9-beta
  5474.           Protocol version        10
  5475.           Connection              Localhost via UNIX socket
  5476.           TCP port                3306
  5477.           UNIX socket             /tmp/mysql.sock
  5478.           Uptime:                 16 sec
  5479.           
  5480.           Running threads: 1  Questions: 20  Reloads: 2  Open tables: 3
  5481.  
  5482.      To get a feeling for what else you can do with `BINDIR/mysqladmin',
  5483.      invoke it with the `--help' option.
  5484.  
  5485.   4. Verify that you can shut down the server:
  5486.  
  5487.           shell> BINDIR/mysqladmin -u root shutdown
  5488.  
  5489.   5. Verify that you can restart the server.  Do this using
  5490.      `safe_mysqld' or by invoking `mysqld' directly.  For example:
  5491.  
  5492.           shell> BINDIR/safe_mysqld --log &
  5493.  
  5494.      If `safe_mysqld' fails, try running it from the *MySQL*
  5495.      installation directory (if you are not already there).  If that
  5496.      doesn't work, see *Note Starting server::.
  5497.  
  5498.   6. Run some simple tests to verify that the server is working.  The
  5499.      output should be similar to what is shown below:
  5500.  
  5501.           shell> BINDIR/mysqlshow
  5502.           +-----------+
  5503.           | Databases |
  5504.           +-----------+
  5505.           | mysql     |
  5506.           +-----------+
  5507.           
  5508.           shell> BINDIR/mysqlshow mysql
  5509.           Database: mysql
  5510.           +--------------+
  5511.           |    Tables    |
  5512.           +--------------+
  5513.           | columns_priv |
  5514.           | db           |
  5515.           | func         |
  5516.           | host         |
  5517.           | tables_priv  |
  5518.           | user         |
  5519.           +--------------+
  5520.           
  5521.           shell> BINDIR/mysql -e "select host,db,user from db" mysql
  5522.           +------+--------+------+
  5523.           | host | db     | user |
  5524.           +------+--------+------+
  5525.           | %    | test   |      |
  5526.           | %    | test_% |      |
  5527.           +------+--------+------+
  5528.  
  5529.      There is also a benchmark suite in the `sql-bench' directory
  5530.      (under the *MySQL* installation directory) that you can use to
  5531.      compare how *MySQL* performs on different platforms. The
  5532.      `sql-bench/Results' directory contains the results from many runs
  5533.      against different databases and platforms.  To run all tests,
  5534.      execute these commands:
  5535.  
  5536.           shell> cd sql-bench
  5537.           shell> run-all-tests
  5538.  
  5539.      If you don't have the `sql-bench' directory, you are probably
  5540.      using an RPM for a binary distribution.  (Source distribution RPMs
  5541.      include the benchmark directory.) In this case, you must first
  5542.      install the benchmark suite before you can use it.  Beginning with
  5543.      *MySQL* 3.22, there are benchmark RPM files named
  5544.      `mysql-bench-VERSION-i386.rpm' that contain benchmark code and
  5545.      data.
  5546.  
  5547.      If you have a source distribution, you can also run the tests in
  5548.      the `tests' subdirectory. For example, to run
  5549.      `auto_increment.tst', do this:
  5550.  
  5551.           shell> BINDIR/mysql -vvf test < ./tests/auto_increment.tst
  5552.  
  5553.      The expected results are shown in the `./tests/auto_increment.res'
  5554.      file.
  5555.  
  5556. Problems running `mysql_install_db'
  5557. -----------------------------------
  5558.  
  5559. This section lists problems you might encounter when you run
  5560. `mysql_install_db':
  5561.  
  5562. *`mysql_install_db' doesn't install the grant tables*
  5563.      You may find that `mysql_install_db' fails to install the grant
  5564.      tables and terminates after displaying the following messages:
  5565.  
  5566.           starting mysqld daemon with databases from XXXXXX
  5567.           mysql daemon ended
  5568.  
  5569.      In this case, you should examine the log file very carefully!  The
  5570.      log should be located in the directory `XXXXXX' named by the error
  5571.      message, and should indicate why `mysqld' didn't start.  If you
  5572.      don't understand what happened, include the log when you post a
  5573.      bug report using `mysqlbug'!  *Note Bug reports::.
  5574.  
  5575. *There is already a `mysqld' daemon running*
  5576.      In this case, you have probably don't have to run
  5577.      `mysql_install_db' at all.  You have to run `mysql_install_db'
  5578.      only once, when you install *MySQL* the first time.
  5579.  
  5580. *Installing a second `mysqld' daemon doesn't work when one daemon is running*
  5581.      This can happen when you already have an existing *MySQL*
  5582.      installation, but want to put a new installation in a different
  5583.      place (e.g., for testing, or perhaps you simply want to run two
  5584.      installations at the same time).  Generally the problem that
  5585.      occurs when you try to run the second server is that it tries to
  5586.      use the same socket and port as the old one.  In this case you
  5587.      will get the error message: `Can't start server: Bind on TCP/IP
  5588.      port: Address already in use' or `Can't start server : Bind on
  5589.      unix socket...'  You can start the new server with a different
  5590.      socket and port as follows:
  5591.  
  5592.           shell> MYSQL_UNIX_PORT=/tmp/mysqld-new.sock
  5593.           shell> MYSQL_TCP_PORT=3307
  5594.           shell> export MYSQL_UNIX_PORT MYSQL_TCP_PORT
  5595.           shell> scripts/mysql_install_db
  5596.           shell> bin/safe_mysqld &
  5597.  
  5598.      The environment variables appendix includes a list of other
  5599.      environment variables you can use to affect `mysqld'. *Note
  5600.      Environment variables::.
  5601.  
  5602.      After this, you should edit your server boot script to start both
  5603.      daemons with different sockets and ports.  For example, it could
  5604.      invoke `safe_mysqld' twice, but with different `--socket', `--port'
  5605.      and `--basedir' options for each invocation.
  5606.  
  5607. *You don't have write access to `/tmp'*
  5608.      If you don't have write access to create a socket file at the
  5609.      default place (in `/tmp') or permission to create temporary files
  5610.      in `/tmp,' you will get an error when running `mysql_install_db'
  5611.      or when starting or using `mysqld'.
  5612.  
  5613.      You can specify a different socket and temporary directory as
  5614.      follows:
  5615.  
  5616.           shell> TMPDIR=/some_tmp_dir/
  5617.           shell> MYSQL_UNIX_PORT=/some_tmp_dir/mysqld.sock
  5618.           shell> export TMPDIR MYSQL_UNIX_PORT
  5619.  
  5620.      `some_tmp_dir' should be the path to some directory for which you
  5621.      have write permission. *Note Environment variables::.
  5622.  
  5623.      After this you should be able to run `mysql_install_db' and start
  5624.      the server with these commands:
  5625.  
  5626.           shell> scripts/mysql_install_db
  5627.           shell> BINDIR/safe_mysqld &
  5628.  
  5629. *`mysqld' crashes immediately*
  5630.      If you are running RedHat 5.0 with a version of `glibc' older than
  5631.      2.0.7-5, you should make sure you have installed all `glibc'
  5632.      patches!  There is a lot of information about this in the *MySQL*
  5633.      mail archives.  Links to the mail archives are available at the
  5634.      online *MySQL* documentation page
  5635.      (http://www.mysql.com/documentation/).  Also, see *Note Linux::.
  5636.  
  5637.      You can also start `mysqld' manually using the
  5638.      `--skip-grant-tables' option and add the privilege information
  5639.      yourself using `mysql':
  5640.  
  5641.           shell> BINDIR/safe_mysqld --skip-grant-tables &
  5642.           shell> BINDIR/mysql -u root mysql
  5643.  
  5644.      From `mysql', manually execute the SQL commands in
  5645.      `mysql_install_db'.  Make sure you run `mysqladmin
  5646.      flush-privileges' or `mysqladmin reload' afterward to tell the
  5647.      server to reload the grant tables.
  5648.  
  5649. Problems starting the MySQL server
  5650. ----------------------------------
  5651.  
  5652. Generally, you start the `mysqld' server in one of three ways:
  5653.  
  5654.    * By invoking `mysql.server'.  This script is used primarily at
  5655.      system startup and shutdown, and is described more fully in *Note
  5656.      Automatic start::.
  5657.  
  5658.    * By invoking `safe_mysqld', which tries to determine the proper
  5659.      options for `mysqld' and then runs it with those options.
  5660.  
  5661.    * On NT you should install `mysqld' as a service as follows:
  5662.           bin\mysqld-nt --install               # Install MySQL as a service
  5663.  
  5664.      You can now start/stop `mysqld' as follows:
  5665.           NET START mysql
  5666.           NET STOP mysql
  5667.  
  5668.      Note that in this case you can't use any other options for
  5669.      `mysqld'!
  5670.  
  5671.      You can remove the service as follows:
  5672.           bin\mysqld-nt --remove                # remove MySQL as a service
  5673.  
  5674.    * By invoking `mysqld' directly.
  5675.  
  5676. Whichever method you use to start the server, if it fails to start up
  5677. correctly, check the log file to see if you can find out why.  Log files
  5678. are located in the data directory (typically `/usr/local/mysql/data'
  5679. for a binary distribution, `/usr/local/var' for a source distribution),
  5680. `\mysql\mysql.err' on Windows.  Look in the data directory for files
  5681. with names of the form `host_name.err' and `host_name.log' where
  5682. `host_name' is the name of your server host.  Then check the last few
  5683. lines of these files:
  5684.  
  5685.      shell> tail host_name.err
  5686.      shell> tail host_name.log
  5687.  
  5688. If you find in the log file something like: the following:
  5689.      000729 14:50:10  bdb:  Recovery function for LSN 1 27595 failed
  5690.      000729 14:50:10  bdb:  warning: ./test/t1.db: No such file or directory
  5691.      000729 14:50:10  Can't init databases
  5692.  
  5693. This means that you started mysqld with `--bdb-recover' and that
  5694. Berkeley DB found something wrong with it's log files when it tried to
  5695. recover your databases.  To be able to continue, you should move away
  5696. the old Berkeley DB log file from the database directory to some other
  5697. place, where you can later examine these.  The log files are named
  5698. `log.0000000001', where the number will increase over time.
  5699.  
  5700. When the `mysqld' daemon starts up, it changes directory to the data
  5701. directory.  This is where it expects to write log files and the pid
  5702. (process ID) file, and where it expects to find databases.
  5703.  
  5704. The data directory location is hardwired in when the distribution is
  5705. compiled.  However, if `mysqld' expects to find the data directory
  5706. somewhere other than where it really is on your system, it will not work
  5707. properly.  If you have problems with incorrect paths, you can find out
  5708. what options `mysqld' allows and what the default path settings are by
  5709. invoking `mysqld' with the `--help' option.  You can override the
  5710. defaults by specifying the correct pathnames as command-line arguments
  5711. to `mysqld'.  (These options can be used with `safe_mysqld' as well.)
  5712.  
  5713. Normally you should need to tell `mysqld' only the base directory under
  5714. which *MySQL* is installed.  You can do this with the `--basedir'
  5715. option.  You can also use `--help' to check the effect of changing path
  5716. options (note that `--help' _must_ be the final option of the `mysqld'
  5717. command).  For example:
  5718.  
  5719.      shell> EXECDIR/mysqld --basedir=/usr/local --help
  5720.  
  5721. Once you determine the path settings you want, start the server without
  5722. the `--help' option.
  5723.  
  5724. If you get the following error, it means that some other program (or
  5725. another `mysqld' server) is already using the TCP/IP port or socket
  5726. `mysqld' is trying to use:
  5727.  
  5728.      Can't start server: Bind on TCP/IP port: Address already in use
  5729.        or
  5730.      Can't start server : Bind on unix socket...
  5731.  
  5732. Use `ps' to make sure that you don't have another `mysqld' server
  5733. running.  If you can't find another server running, you can try to
  5734. execute the command `telnet your-host-name tcp-ip-port-number' and press
  5735. `RETURN' a couple of times.  If you don't get an error message like
  5736. `telnet: Unable to connect to remote host: Connection refused',
  5737. something is using the TCP/IP port `mysqld' is trying to use.  *Note
  5738. `mysql_install_db': mysql_install_db, and *Note Multiple servers::.
  5739.  
  5740. The `safe_mysqld' script is written so that it normally is able to start
  5741. a server that was installed from either a source or a binary version of
  5742. *MySQL*, even if these install the server in slightly different
  5743. locations.  `safe_mysqld' expects one of these conditions to be true:
  5744.  
  5745.    * The server and databases can be found relative to the directory
  5746.      from which `safe_mysqld' is invoked.  `safe_mysqld' looks under
  5747.      its working directory for `bin' and `data' directories (for binary
  5748.      distributions) or for `libexec' and `var' directories (for source
  5749.      distributions).  This condition should be met if you execute
  5750.      `safe_mysqld' from your *MySQL* installation directory (for
  5751.      example, `/usr/local/mysql' for a binary distribution).
  5752.  
  5753.    * If the server and databases cannot be found relative to its
  5754.      working directory, `safe_mysqld' attempts to locate them by
  5755.      absolute pathnames.  Typical locations are `/usr/local/libexec'
  5756.      and `/usr/local/var'.  The actual locations are determined when
  5757.      the distribution was built from which `safe_mysqld' comes.  They
  5758.      should be correct if *MySQL* was installed in a standard location.
  5759.  
  5760. Because `safe_mysqld' will try to find the server and databases relative
  5761. to its own working directory, you can install a binary distribution of
  5762. *MySQL* anywhere, as long as you start `safe_mysqld' from the *MySQL*
  5763. installation directory:
  5764.  
  5765.      shell> cd mysql_installation_directory
  5766.      shell> bin/safe_mysqld &
  5767.  
  5768. If `safe_mysqld' fails, even when invoked from the *MySQL* installation
  5769. directory, you can modify it to use the path to `mysqld' and the
  5770. pathname options that are correct for your system.  Note that if you
  5771. upgrade *MySQL* in the future, your modified version of `safe_mysqld'
  5772. will be overwritten, so you should make a copy of your edited version
  5773. that you can reinstall.
  5774.  
  5775. If `mysqld' is currently running, you can find out what path settings
  5776. it is using by executing this command:
  5777.  
  5778.      shell> mysqladmin variables
  5779.      
  5780.      or
  5781.      
  5782.      shell> mysqladmin -h 'your-host-name' variables
  5783.  
  5784. If `safe_mysqld' starts the server but you can't connect to it, you
  5785. should make sure you have an entry in `/etc/hosts' that looks like this:
  5786.  
  5787.      127.0.0.1       localhost
  5788.  
  5789. This problem occurs only on systems that don't have a working thread
  5790. library and for which *MySQL* must be configured to use MIT-pthreads.
  5791.  
  5792. On Windows, you can try to start `mysqld' as follows:
  5793.  
  5794.      C:\mysql\bin\mysqld --standalone --debug
  5795.  
  5796. This will not run in the background and it should also write a trace in
  5797. `\mysqld.trace', which may help you determine the source of your
  5798. problems. *Note Win32::.
  5799.  
  5800. Starting and stopping MySQL automatically
  5801. -----------------------------------------
  5802.  
  5803. The `mysql.server' script can be used to start or stop the server, by
  5804. invoking it with `start' or `stop' arguments:
  5805.  
  5806.      shell> mysql.server start
  5807.      shell> mysql.server stop
  5808.  
  5809. `mysql.server' can be found in the `share/mysql' directory under the
  5810. *MySQL* installation directory, or in the `support-files' directory of
  5811. the *MySQL* source tree.
  5812.  
  5813. Before `mysql.server' starts the server, it changes directory to the
  5814. *MySQL* installation directory, then invokes `safe_mysqld'.  You might
  5815. need to edit `mysql.server' if you have a binary distribution that
  5816. you've installed in a non-standard location.  Modify it to `cd' into
  5817. the proper directory before it runs `safe_mysqld'. If you want the
  5818. server to run as some specific user, you can change the
  5819. `mysql_daemon_user=root' line to use another user.  You can also modify
  5820. `mysql.server' to pass other options to `safe_mysqld'.
  5821.  
  5822. `mysql.server stop' brings down server by sending a signal to it.  You
  5823. can take down the server manually by executing `mysqladmin shutdown'.
  5824.  
  5825. You might want to add these start and stop commands to the appropriate
  5826. places in your `/etc/rc*' files when you start using *MySQL* for
  5827. production applications.  Note that if you modify `mysql.server', then
  5828. if you upgrade *MySQL* sometime, your modified version will be
  5829. overwritten, so you should make a copy of your edited version that you
  5830. can reinstall.
  5831.  
  5832. If your system uses `/etc/rc.local' to start external scripts, you
  5833. should append the following to it:
  5834.      /bin/sh -c 'cd /usr/local/mysql ; ./bin/safe_mysqld &'
  5835.  
  5836. You can also add options for `mysql.server' in a global `/etc/my.cnf'
  5837. file.  A typical `/etc/my.cnf' file might look like this:
  5838.  
  5839.      [mysqld]
  5840.      datadir=/usr/local/mysql/var
  5841.      socket=/tmp/mysqld.sock
  5842.      port=3306
  5843.      
  5844.      [mysql.server]
  5845.      user=mysql
  5846.      basedir=/usr/local/mysql
  5847.  
  5848. The `mysql.server' script uses the following variables: `user',
  5849. `datadir', `basedir', `bindir' and `pid-file'.
  5850.  
  5851. *Note Option files::.
  5852.  
  5853. Command-line options
  5854. --------------------
  5855.  
  5856. `mysqld' accepts the following command-line options:
  5857.  
  5858. `--ansi'
  5859.      Use ANSI SQL syntax instead of MySQL syntax. *Note Ansi mode::.
  5860.  
  5861. `-b, --basedir=path'
  5862.      Path to installation directory. All paths are usually resolved
  5863.      relative to this.
  5864.  
  5865. `--big-tables'
  5866.      Allow big result sets by saving all temporary sets on file. It
  5867.      solves most 'table full' errors, but also slows down the queries
  5868.      where in-memory tables would suffice. Since version 3.23.2 *MySQL*
  5869.      is able to solve it automaticaly by using memory for small
  5870.      temporary tables and switching to disk tables where necessary.
  5871.  
  5872. `--bind-address=IP'
  5873.      IP address to bind to.
  5874.  
  5875. `--character-sets-dir=path'
  5876.      Directory where character sets are. *Note Character sets::.
  5877.  
  5878. `--chroot=path'
  5879.      Chroot mysqld daemon during startup.  Recommended security
  5880.      measure. It will somewhat limit `LOAD DATA INFILE' and `SELECT ...
  5881.      INTO OUTFILE' though.
  5882.  
  5883. `-h, --datadir=path'
  5884.      Path to the database root.
  5885.  
  5886. `--default-character-set=charset'
  5887.      Set the default character set. *Note Character sets::.
  5888.  
  5889. `--default-table-type=type'
  5890.      Set the default table type for tables. *Note Table types::.
  5891.  
  5892. `--delay-key-write-for-all-tables'
  5893.      Don't flush key buffers between writes for any `MyISAM' table.
  5894.      *Note Server parameters::.
  5895.  
  5896. `--enable-locking'
  5897.      Enable system locking.
  5898.  
  5899. `-T, --exit-info'
  5900.      Print some debug info at exit.
  5901.  
  5902. `--flush'
  5903.      Flush all changes to disk after each SQL commands;  Normally
  5904.      *MySQL* only does a write of all changes to disk after each SQL
  5905.      command, and lets the operating system handle the syncing to disk.
  5906.      *Note Crashing::.
  5907.  
  5908. `-?, --help'
  5909.      Display short help and exit.
  5910.  
  5911. `--init-file=file'
  5912.      Read SQL commands from this file at startup.
  5913.  
  5914. `-L, --language=...'
  5915.      Client error messages in given language. May be given as a full
  5916.      path.  *Note Languages::.
  5917.  
  5918. `-l, --log[=file]'
  5919.      Log connections and queries to file
  5920.  
  5921. `--log-update[=file]'
  5922.      Log updates to `file.#' where `#' is a unique number if not given.
  5923.      *Note Update log::.
  5924.  
  5925. `--log-isam[=file]'
  5926.      Log all isam changes to file.
  5927.  
  5928. `--log-long-format'
  5929.      Log some extra information to update log.
  5930.  
  5931. `--low-priority-updates'
  5932.      Table-modifying operations (`INSERT'/`DELETE'/`UPDATE') will have
  5933.      lower priority than selects.  It can also be done via `{INSERT |
  5934.      REPLACE | UPDATE | DELETE} LOW_PRIORITY ...' to lower the priority
  5935.      of only one query, or by `SET OPTION SQL_LOW_PRIORITY_UPDATES=1'
  5936.      to change the priority in one thread.  *Note Table locking::.
  5937.  
  5938. `--pid-file=path'
  5939.      Path to pid file used by `safe_mysqld'.
  5940.  
  5941. `-P, --port=...'
  5942.      Port number to listen for TCP/IP connections.
  5943.  
  5944. `-o, --old-protocol'
  5945.      Use the 3.20 protocol for compatibility with some very old clients.
  5946.      *Note Upgrading-from-3.20::.
  5947.  
  5948. `--one-thread'
  5949.      Only use one thread (for debugging under Linux). *Note Debugging
  5950.      server::.
  5951.  
  5952. `-O, --set-variable var=option'
  5953.      Give a variable an value. `--help' lists variables.  You can find
  5954.      a full description for all variables in the `SHOW VARIABLES'
  5955.      section in this manual. *Note SHOW VARIABLES::.  The tuning server
  5956.      parameters section includes information of how to optimize these.
  5957.      *Note Server parameters::.
  5958.  
  5959. `-Sg, --skip-grant-tables'
  5960.      This option causes the server not to use the privilege system at
  5961.      all. This gives everyone _full access_ to all databases!  (You can
  5962.      tell a running server to start using the grant tables again by
  5963.      executing `mysqladmin flush-privileges' or `mysqladmin reload'.)
  5964.  
  5965. `--safe-mode'
  5966.      Skip some optimize stages.  Implies `--skip-delay-key-write'.
  5967.  
  5968. `--secure'
  5969.      IP numbers returned by the `gethostbyname()' system call are
  5970.      checked to make sure they resolve back to the original hostname.
  5971.      This makes it harder for someone on the outside to get access by
  5972.      pretending to be another host. This option also adds some sanity
  5973.      checks of hostnames. The option is turned off by default in
  5974.      *MySQL* 3.21 because sometimes it takes a long time to perform
  5975.      backward resolutions.  *MySQL* 3.22 caches hostnames (unless
  5976.      `--skip-host-cache' is used) and has this option enabled by
  5977.      default.
  5978.  
  5979. `--skip-delay-key-write'
  5980.      Ignore the `delay_key_write' option for all tables.  *Note Server
  5981.      parameters::.
  5982.  
  5983. `--skip-locking'
  5984.      Don't use system locking. To use `isamchk' or `myisamchk' one has
  5985.      to shut down the server. *Note Stability::.  Note that in *MySQL*
  5986.      3.23 one can use `REPAIR' and `CHECK' to repair/check `MyISAM'
  5987.      tables.
  5988.  
  5989. `--skip-name-resolve'
  5990.      Hostnames are not resolved.  All `Host' column values in the grant
  5991.      tables must be IP numbers or `localhost'.
  5992.  
  5993. `--skip-networking'
  5994.      Don't listen for TCP/IP connections at all.  All interaction with
  5995.      `mysqld' must be made via Unix sockets.  This option is highly
  5996.      recommended for systems where only local requests are allowed.
  5997.      However, this option is unsuitable for systems that use
  5998.      MIT-pthreads, because the MIT-pthreads package doesn't support Unix
  5999.      sockets.
  6000.  
  6001. `--skip-new'
  6002.      Don't use new, possible wrong routines.  Implies
  6003.      `--skip-delay-key-write'.  This will also set default table type
  6004.      to `ISAM'. *Note ISAM::.
  6005.  
  6006. `--skip-host-cache'
  6007.      Never use host name cache for faster name-ip resolution, but query
  6008.      DNS server on every connect instead.
  6009.  
  6010. `--skip-show-database'
  6011.      Don't allow 'SHOW DATABASE' commands, unless the user has
  6012.      *process* privilege.
  6013.  
  6014. `--skip-thread-priority'
  6015.      Disable using thread priorities for faster responce time.
  6016.  
  6017. `--socket=path'
  6018.      Socket file to use for local connections instead of default
  6019.      `/tmp/mysql.sock'.
  6020.  
  6021. `-t, --tmpdir=path'
  6022.      Path for temporary files. It may be useful if your default `/tmp'
  6023.      directory resides on a partition too small to hold temporary
  6024.      tables.
  6025.  
  6026. `-u, --user=user_name'
  6027.      Run `mysqld' daemon as user `user_name'. This option is
  6028.      _mandatory_ when starting `mysqld' as root.
  6029.  
  6030. `-V, --version'
  6031.      output version information and exit
  6032.  
  6033. Option files
  6034. ------------
  6035.  
  6036. *MySQL* 3.22 can read default startup options for the server and for
  6037. clients from option files.
  6038.  
  6039. *MySQL* reads default options from the following files on Unix:
  6040.  
  6041. *Filename*             *Purpose*
  6042. `/etc/my.cnf'          Global options
  6043. `DATADIR/my.cnf'       Server-specific options
  6044. `~/.my.cnf'            User-specific options
  6045.  
  6046. `DATADIR' is the *MySQL* data directory (typically
  6047. `/usr/local/mysql/data' for a binary installation, or `/usr/local/var'
  6048. for a source installation).  Note that this is the directory that was
  6049. specified at configuration time, not the one specified with `--datadir'
  6050. when `mysqld' starts up!  (`--datadir' has no effect on where the
  6051. server looks for option files, because it looks for them before it
  6052. processes any command-line arguments.)
  6053.  
  6054. *MySQL* reads default options from the following files on Win32:
  6055.  
  6056. *Filename*             *Purpose*
  6057. `windows-system-directory\my.ini'
  6058. `C:\my.cnf'            Global options
  6059. `C:\mysql\data\my.cnf' Server-specific options
  6060.  
  6061. Note that you on Win32 should specify all paths with `/' instead of
  6062. `\'. If you use `\', you need to specify this twice, as `\' is the
  6063. escape character in *MySQL*.
  6064.  
  6065. *MySQL* tries to read option files in the order listed above.  If
  6066. multiple option files exist, an option specified in a file read later
  6067. takes precedence over the same option specified in a file read earlier.
  6068. Options specified on the command line take precedence over options
  6069. specified in any option file.  Some options can be specified using
  6070. environment variables.  Options specified on the command line or in
  6071. option files take precedence over environment variable values. *Note
  6072. Environment variables::.
  6073.  
  6074. The following programs support option files:  `mysql', `mysqladmin',
  6075. `mysqld', `mysqldump', `mysqlimport', `mysql.server', `myisamchk' and
  6076. `myisampack'.
  6077.  
  6078. You can use option files to specify any long option that a program
  6079. supports!  Run the program with `--help' to get a list of available
  6080. options.
  6081.  
  6082. An option file can contain lines of the following forms:
  6083.  
  6084. `#comment'
  6085.      Comment lines start with `#' or `;'. Empty lines are ignored.
  6086.  
  6087. `[group]'
  6088.      `group' is the name of the program or group for which you want to
  6089.      set options.  After a group line, any `option' or `set-variable'
  6090.      lines apply to the named group until the end of the option file or
  6091.      another group line is given.
  6092.  
  6093. `option'
  6094.      This is equivalent to `--option' on the command line.
  6095.  
  6096. `option=value'
  6097.      This is equivalent to `--option=value' on the command line.
  6098.  
  6099. `set-variable = variable=value'
  6100.      This is equivalent to `--set-variable variable=value' on the
  6101.      command line.  This syntax must be used to set a `mysqld' variable.
  6102.  
  6103. The `client' group allows you to specify options that apply to all
  6104. *MySQL* clients (not `mysqld'). This is the perfect group to use to
  6105. specify the password you use to connect to the server.  (But make sure
  6106. the option file is readable and writable only to yourself.)
  6107.  
  6108. Note that for options and values, all leading and trailing blanks are
  6109. automatically deleted.  You may use the escape sequences `\b', `\t',
  6110. `\n', `\r', `\\' and `\s' in your value string (`\s' == blank).
  6111.  
  6112. Here is a typical global option file:
  6113.  
  6114.      [client]
  6115.      port=3306
  6116.      socket=/tmp/mysql.sock
  6117.      
  6118.      [mysqld]
  6119.      port=3306
  6120.      socket=/tmp/mysql.sock
  6121.      set-variable = key_buffer_size=16M
  6122.      set-variable = max_allowed_packet=1M
  6123.      
  6124.      [mysqldump]
  6125.      quick
  6126.  
  6127. Here is typical user option file:
  6128.  
  6129.      [client]
  6130.      # The following password will be sent to all standard MySQL clients
  6131.      password=my_password
  6132.      
  6133.      [mysql]
  6134.      no-auto-rehash
  6135.  
  6136. If you have a source distribution, you will find sample configuration
  6137. files named `my-xxxx.cnf' in the `support-files' directory.  If you
  6138. have a binary distribution, look in the `DIR/share/mysql' directory,
  6139. where `DIR' is the pathname to the *MySQL* installation directory
  6140. (typically `/usr/local/mysql').  Currently there is sample
  6141. configuration files for small, medium, large and very large systems.
  6142. You can copy `my-xxxx.cnf' to your home directory (rename the copy to
  6143. `.my.cnf') to experiment with this.
  6144.  
  6145. To tell a *MySQL* program not to read any option files, specify
  6146. `--no-defaults' as the first option on the command line.  This *MUST*
  6147. be the first option or it will have no effect!  If you want to check
  6148. which options are used, you can give the option `--print-defaults' as
  6149. the first option.
  6150.  
  6151. If you want to force the use of a specific config file, you can use the
  6152. option `--defaults-file=full-path-to-default-file'. If you do this,
  6153. only the specified file will be read.
  6154.  
  6155. Note for developers:  Option file handling is implemented simply by
  6156. processing all matching options (i.e., options in the appropriate group)
  6157. before any command line arguments. This works nicely for programs that
  6158. use the last instance of an option that is specified multiple times. If
  6159. you have an old program that handles multiply-specified options this
  6160. way but doesn't read option files, you need add only two lines to give
  6161. it that capability.  Check the source code of any of the standard
  6162. *MySQL* clients to see how to do this.
  6163.  
  6164. Is there anything special to do when upgrading/downgrading MySQL?
  6165. =================================================================
  6166.  
  6167. You can always move the *MySQL* form and data files between different
  6168. versions on the same architecture as long as you have the same base
  6169. version of *MySQL*. The current base version is 3. If you change the
  6170. character set when running *MySQL* (which may also change the sort
  6171. order), you must run `myisamchk -r -q' on all tables.  Otherwise your
  6172. indexes may not be ordered correctly.
  6173.  
  6174. If you are paranoid and/or afraid of new versions, you can always
  6175. rename your old `mysqld' to something like
  6176. `mysqld'-'old-version-number'.  If your new `mysqld' then does
  6177. something unexpected, you can simply shut it down and restart with your
  6178. old `mysqld'!
  6179.  
  6180. When you do an upgrade you should also backup your old databases, of
  6181. course.  Sometimes it's good to be a little paranoid!
  6182.  
  6183. After an upgrade, if you experience problems with recompiled client
  6184. programs, like `Commands out of sync' or unexpected core dumps, you
  6185. probably have used an old header or library file when compiling your
  6186. programs.  In this case you should check the date for your `mysql.h'
  6187. file and `libmysqlclient.a' library to verify that they are from the new
  6188. *MySQL* distribution.  If not, please recompile your programs!
  6189.  
  6190. If you get some problems that the new `mysqld' server doesn't want to
  6191. start or that you can't connect without a password, check that you don't
  6192. have some old `my.cnf' file from your old installation!  You can check
  6193. this with: `program-name --print-defaults'.  If this outputs anything
  6194. other than the program name, you have an active `my.cnf' file that will
  6195. may affect things!
  6196.  
  6197. It is a good idea to rebuild and reinstall the `Msql-Mysql-modules'
  6198. distribution whenever you install a new release of *MySQL*,
  6199. particularly if you notice symptoms such as all your `DBI' scripts
  6200. dumping core after you upgrade *MySQL*.
  6201.  
  6202. Upgrading from a 3.22 version to 3.23
  6203. -------------------------------------
  6204.  
  6205. *MySQL* 3.23 supports tables of the new `MyISAM' type and the old
  6206. `ISAM' type.  You don't have to convert your old tables to use these
  6207. with 3.23.  By default, all new tables will be created with type
  6208. `MyISAM' (unless you start `mysqld' with the
  6209. `--default-table-type=isam' option. You can change an `ISAM' table to a
  6210. `MyISAM' table with `ALTER TABLE' or the Perl script
  6211. `mysql_convert_table_format'.
  6212.  
  6213. 3.22 and 3.21 clients will work without any problems with a 3.23 server.
  6214.  
  6215. The following lists what you have to watch out for when upgrading to
  6216. 3.23:
  6217.  
  6218.    * The default return type of `IF' will now depend on both arguments
  6219.      and not only the first argument.
  6220.  
  6221.    * `AUTO_INCREMENT' will not work with negative numbers.
  6222.  
  6223.    * `INNER' and `DELAYED' are now reserved words.
  6224.  
  6225.    * `FLOAT(X)' is now a true floating point types and not a value with
  6226.      a fixed number of decimals.
  6227.  
  6228.    * When declaring `DECIMAL(length,dec)' the length argument no longer
  6229.      includes a place for the sign or the decimal point.
  6230.  
  6231.    * A `TIME' string must now be of one of the following formats:
  6232.      `[[[DAYS] [H]H:]MM:]SS[.fraction]' or
  6233.      `[[[[[H]H]H]H]MM]SS[.fraction]'
  6234.  
  6235.    * `LIKE' now compares strings using the same character comparison
  6236.      rules as `'=''.  If you require the old behavior, you can compile
  6237.      *MySQL* with the `CXXFLAGS=-DLIKE_CMP_TOUPPER' flag.
  6238.  
  6239.    * `REGEXP' is now case insensitive for normal (not binary) strings.
  6240.  
  6241.    * When you check/repair tables you should use `CHECK TABLE' or
  6242.      `myisamchk' for `MyISAM' tables (`.MYI') and `isamchk' for ISAM
  6243.      (`.ISM') tables.
  6244.  
  6245.    * If you want your `mysqldump's to be compatible between *MySQL*
  6246.      3.22 and 3.23, you should not use the `--opt' or `--full' option
  6247.      to `mysqldump'.
  6248.  
  6249.    * Check all your calls to `DATE_FORMAT()' to make sure there is a
  6250.      `%' before each format character.  (Later *MySQL* 3.22 version did
  6251.      allow this syntax.
  6252.  
  6253.    * `mysql_fetch_fields_direct' is now a function (it was a macro) and
  6254.      it returns a pointer to a `MYSQL_FIELD' instead of a `MYSQL_FIELD'.
  6255.  
  6256.    * `mysql_num_fields()' can no longer be used on a `MYSQL*' object
  6257.      (it's now a function that takes `MYSQL_RES*' as an argument. You
  6258.      should now use `mysql_field_count()' instead.
  6259.  
  6260.    * In `MySQL' 3.22, the output of `SELECT DISTINCT ...' was almost
  6261.      always sorted.  In 3.23, you must use `GROUP BY' or `ORDER BY' to
  6262.      obtain sorted output.
  6263.  
  6264.    * `SUM()' now returns `NULL', instead of 0, if there is no matching
  6265.      rows. This is according to ANSI SQL.
  6266.  
  6267.    * New restricted words: `CASE, THEN, WHEN, ELSE and END'
  6268.  
  6269.    * An `AND' or `OR' with `NULL' values will now return `NULL' instead
  6270.      of 0. This mostly affects queries that uses `NOT' on an `AND/OR'
  6271.      expression as `NOT NULL' = `NULL'.
  6272.  
  6273. Upgrading from a 3.21 version to 3.22
  6274. -------------------------------------
  6275.  
  6276. Nothing that affects compatibility has changed between 3.21 and 3.22.
  6277. The only pitfall is that new tables that are created with `DATE' type
  6278. columns will use the new way to store the date. You can't access these
  6279. new fields from an old version of `mysqld'.
  6280.  
  6281. After installing *MySQL* 3.22, you should start the new server and then
  6282. run the `mysql_fix_privilege_tables' script. This will add the new
  6283. privileges that you need to use the `GRANT' command.  If you forget
  6284. this, you will get `Access denied' when you try to use `ALTER TABLE',
  6285. `CREATE INDEX' or `DROP INDEX'. If your *MySQL* root user requires a
  6286. password, you should give this as an argument to
  6287. `mysql_fix_privilege_tables'.
  6288.  
  6289. The C API interface to `mysql_real_connect()' has changed.  If you have
  6290. an old client program that calls this function, you must place a `0' for
  6291. the new `db' argument (or recode the client to send the `db' element
  6292. for faster connections).  You must also call `mysql_init()' before
  6293. calling `mysql_real_connect()'!  This change was done to allow the new
  6294. `mysql_options()' function to save options in the `MYSQL' handler
  6295. structure.
  6296.  
  6297. The `mysqld' variable `key_buffer' has changed names to
  6298. `key_buffer_size', but you can still use the old name in your startup
  6299. files.
  6300.  
  6301. Upgrading from a 3.20 version to 3.21
  6302. -------------------------------------
  6303.  
  6304. If you are running a version older than 3.20.28 and want to switch to
  6305. 3.21.x, you need to do the following:
  6306.  
  6307. You can start the `mysqld' 3.21 server with `safe_mysqld
  6308. --old-protocol' to use it with clients from the 3.20 distribution.  In
  6309. this case, the new client function `mysql_errno()' will not return any
  6310. server error, only `CR_UNKNOWN_ERROR', (but it works for client errors)
  6311. and the server uses the old password() checking rather than the new one.
  6312.  
  6313. If you are *NOT* using the `--old-protocol' option to `mysqld', you
  6314. will need to make the following changes:
  6315.  
  6316.    * All client code must be recompiled. If you are using ODBC, you
  6317.      must get the new *MyODBC* 2.x driver.
  6318.  
  6319.    * The script `scripts/add_long_password' must be run to convert the
  6320.      `Password' field in the `mysql.user' table to `CHAR(16)'.
  6321.  
  6322.    * All passwords must be reassigned in the `mysql.user' table (to get
  6323.      62-bit rather than 31-bit passwords).
  6324.  
  6325.    * The table format hasn't changed, so you don't have to convert any
  6326.      tables.
  6327.  
  6328. *MySQL* 3.20.28 and above can handle the new `user' table format
  6329. without affecting clients. If you have a *MySQL* version earlier than
  6330. 3.20.28, passwords will no longer work with it if you convert the `user'
  6331. table. So to be safe, you should first upgrade to at least 3.20.28 and
  6332. then upgrade to 3.21.x.
  6333.  
  6334. The new client code works with a 3.20.x `mysqld' server, so if you
  6335. experience problems with 3.21.x, you can use the old 3.20.x server
  6336. without having to recompile the clients again.
  6337.  
  6338. If you are not using the `--old-protocol' option to `mysqld', old
  6339. clients will issue the error message:
  6340.  
  6341.      ERROR: Protocol mismatch. Server Version = 10 Client Version = 9
  6342.  
  6343. The new Perl `DBI'/`DBD' interface also supports the old `mysqlperl'
  6344. interface.  The only change you have to make if you use `mysqlperl' is
  6345. to change the arguments to the `connect()' function.  The new arguments
  6346. are: `host', `database', `user', `password' (the `user' and `password'
  6347. arguments have changed places).  *Note Perl `DBI' Class: Perl DBI Class.
  6348.  
  6349. The following changes may affect queries in old applications:
  6350.  
  6351.    * `HAVING' must now be specified before any `ORDER BY' clause.
  6352.  
  6353.    * The parameters to `LOCATE()' have been swapped.
  6354.  
  6355.    * There are some new reserved words. The most notable are `DATE',
  6356.      `TIME' and `TIMESTAMP'.
  6357.  
  6358. Upgrading to another architecture
  6359. ---------------------------------
  6360.  
  6361. If you are using *MySQL* 3.23, you can copy the `.frm', the `.MYI' and
  6362. the `.MYD' files between different architectures that support the same
  6363. floating point format.  (*MySQL* takes care of any byte swapping
  6364. issues).
  6365.  
  6366. The *MySQL* `ISAM' data `*.ISD' and the index files `*.ISM' files) are
  6367. architecture-dependent and in some case OS-dependent.  If you want to
  6368. move your applications to another machine that has a different
  6369. architecture or OS than your current machine, you should not try to
  6370. move a database by simply copying the files to the other machine. Use
  6371. `mysqldump' instead.
  6372.  
  6373. By default, `mysqldump' will create a file full of SQL statements.  You
  6374. can then transfer the file to the other machine and feed it as input to
  6375. the `mysql' client.
  6376.  
  6377. Try `mysqldump --help' to see what options are available.  If you are
  6378. moving the data to a newer version of *MySQL*, you should use
  6379. `mysqldump --opt' with the newer version to get a fast, compact dump.
  6380.  
  6381. The easiest (although not the fastest) way to move a database between
  6382. two machines is to run the following commands on the machine on which
  6383. the database is located:
  6384.  
  6385.      shell> mysqladmin -h 'other hostname' create db_name
  6386.      shell> mysqldump --opt db_name \
  6387.              | mysql -h 'other hostname' db_name
  6388.  
  6389. If you want to copy a database from a remote machine over a slow
  6390. network, you can use:
  6391.  
  6392.      shell> mysqladmin create db_name
  6393.      shell> mysqldump -h 'other hostname' --opt --compress db_name \
  6394.              | mysql db_name
  6395.  
  6396. You can also store the result in a file, then transfer the file to the
  6397. target machine and load the file into the database there.  For example,
  6398. you can dump a database to a file on the source machine like this:
  6399.  
  6400.      shell> mysqldump --quick db_name | gzip > db_name.contents.gz
  6401.  
  6402. (The file created in this example is compressed.) Transfer the file
  6403. containing the database contents to the target machine and run these
  6404. commands there:
  6405.  
  6406.      shell> mysqladmin create db_name
  6407.      shell> gunzip < db_name.contents.gz | mysql db_name
  6408.  
  6409. You can also use `mysqldump' and `mysqlimport' to accomplish the
  6410. database transfer.  For big tables, this is much faster than simply
  6411. using `mysqldump'.  In the commands shown below, `DUMPDIR' represents
  6412. the full pathname of the directory you use to store the output from
  6413. `mysqldump'.
  6414.  
  6415. First, create the directory for the output files and dump the database:
  6416.  
  6417.      shell> mkdir DUMPDIR
  6418.      shell> mysqldump --tab=DUMPDIR db_name
  6419.  
  6420. Then transfer the files in the `DUMPDIR' directory to some corresponding
  6421. directory on the target machine and load the files into *MySQL* there:
  6422.  
  6423.      shell> mysqladmin create db_name           # create database
  6424.      shell> cat DUMPDIR/*.sql | mysql db_name   # create tables in database
  6425.      shell> mysqlimport db_name DUMPDIR/*.txt   # load data into tables
  6426.  
  6427. Also, don't forget to copy the `mysql' database, because that's where
  6428. the grant tables (`user', `db', `host') are stored.  You may have to
  6429. run commands as the *MySQL* `root' user on the new machine until you
  6430. have the `mysql' database in place.
  6431.  
  6432. After you import the `mysql' database on the new machine, execute
  6433. `mysqladmin flush-privileges' so that the server reloads the grant table
  6434. information.
  6435.  
  6436. How standards-compatible is MySQL?
  6437. **********************************
  6438.  
  6439. MySQL extensions to ANSI SQL92
  6440. ==============================
  6441.  
  6442. *MySQL* includes some extensions that you probably will not find in
  6443. other SQL databases.  Be warned that if you use them, your code will
  6444. not be portable to other SQL servers.  In some cases, you can write
  6445. code that includes *MySQL* extensions, but is still portable, by using
  6446. comments of the form `/*! ... */'.  In this case, *MySQL* will parse and
  6447. execute the code within the comment as it would any other *MySQL*
  6448. statement, but other SQL servers will ignore the extensions.  For
  6449. example:
  6450.  
  6451.      SELECT /*! STRAIGHT_JOIN */ col_name FROM table1,table2 WHERE ...
  6452.  
  6453. If you add a version number after the `'!'', the syntax will only be
  6454. executed if the *MySQL* version is equal or newer than the used version
  6455. number:
  6456.  
  6457.      CREATE /*!32302 TEMPORARY */ TABLE (a int);
  6458.  
  6459. The above means that if you have 3.23.02 or newer, then *MySQL* will use
  6460. the `TEMPORARY' keyword.
  6461.  
  6462. *MySQL* extensions are listed below:
  6463.  
  6464.    * The field types `MEDIUMINT', `SET', `ENUM' and the different
  6465.      `BLOB' and `TEXT' types.
  6466.  
  6467.    * The field attributes `AUTO_INCREMENT', `BINARY', `NULL',
  6468.      `UNSIGNED' and `ZEROFILL'.
  6469.  
  6470.    * All string comparisons are case insensitive by default, with sort
  6471.      ordering determined by the current character set (ISO-8859-1
  6472.      Latin1 by default).  If you don't like this, you should declare
  6473.      your columns with the `BINARY' attribute or use the `BINARY' cast,
  6474.      which causes comparisons to be done according to the ASCII order
  6475.      used on the *MySQL* server host.
  6476.  
  6477.    * *MySQL* maps each database to a directory under the *MySQL* data
  6478.      directory, and tables within a database to filenames in the
  6479.      database directory.  This has two implications:
  6480.  
  6481.         - Database names and table names are case sensitive in *MySQL*
  6482.           on operating systems that have case sensitive filenames (like
  6483.           most Unix systems). If you have a problem remembering table
  6484.           names, adopt a consistent convention, such as always creating
  6485.           databases and tables using lowercase names.
  6486.  
  6487.         - Database, table, index, column or alias names may begin with
  6488.           a digit (but may not consist solely of digits).
  6489.  
  6490.         - You can use standard system commands to backup, rename, move,
  6491.           delete and copy tables.  For example, to rename a table,
  6492.           rename the `.MYD', `.MYI' and `.frm' files to which the table
  6493.           corresponds.
  6494.  
  6495.    * In SQL statements, you can access tables from different databases
  6496.      with the `db_name.tbl_name' syntax.  Some SQL servers provide the
  6497.      same functionality but call this `User space'.  *MySQL* dosen't
  6498.      support tablespaces like in: `create table ralph.my_table...IN
  6499.      my_tablespace'.
  6500.  
  6501.    * `LIKE' is allowed on numeric columns.
  6502.  
  6503.    * Use of `INTO OUTFILE' and `STRAIGHT_JOIN' in a `SELECT' statement.
  6504.      *Note `SELECT': SELECT.
  6505.  
  6506.    * The `SQL_SMALL_RESULT' option in a `SELECT' statement.
  6507.  
  6508.    * `EXPLAIN SELECT' to get a description on how tables are joined.
  6509.  
  6510.    * Use of index names, indexes on a prefix of a field, and use of
  6511.      `INDEX' or `KEY' in a `CREATE TABLE' statement. *Note `CREATE
  6512.      TABLE': CREATE TABLE.
  6513.  
  6514.    * Use of `TEMPORARY' or `IF NOT EXISTS' with `CREATE TABLE'.
  6515.  
  6516.    * Use of `COUNT(DISTINCT list)' where 'list' is more than one
  6517.      element.
  6518.  
  6519.    * Use of `CHANGE col_name', `DROP col_name' or `DROP INDEX' in an
  6520.      `ALTER TABLE' statement. *Note `ALTER TABLE': ALTER TABLE.
  6521.  
  6522.    * Use of `IGNORE' in an `ALTER TABLE' statement.
  6523.  
  6524.    * Use of multiple `ADD', `ALTER', `DROP' or `CHANGE' clauses in an
  6525.      `ALTER TABLE' statement.
  6526.  
  6527.    * Use of `DROP TABLE' with the keywords `IF EXISTS'.
  6528.  
  6529.    * You can drop multiple tables with a single `DROP TABLE' statement.
  6530.  
  6531.    * The `LIMIT' clause of the `DELETE' statement.
  6532.  
  6533.    * The `DELAYED' clause of the `INSERT' and `REPLACE' statements.
  6534.  
  6535.    * The `LOW_PRIORITY' clause of the `INSERT', `REPLACE', `DELETE' and
  6536.      `UPDATE' statements.
  6537.  
  6538.    * Use of `LOAD DATA INFILE'. In many cases, this syntax is
  6539.      compatible with Oracle's `LOAD DATA INFILE'. *Note `LOAD DATA':
  6540.      LOAD DATA.
  6541.  
  6542.    * The `OPTIMIZE TABLE' statement.  *Note `OPTIMIZE TABLE': OPTIMIZE
  6543.      TABLE.
  6544.  
  6545.    * The `SHOW' statement.  *Note `SHOW': SHOW.
  6546.  
  6547.    * Strings may be enclosed by either `"' or `'', not just by `''.
  6548.  
  6549.    * Use of the escape `\' character.
  6550.  
  6551.    * The `SET OPTION' statement. *Note `SET OPTION': SET OPTION.
  6552.  
  6553.    * You don't need to name all selected columns in the `GROUP BY' part.
  6554.      This gives better performance for some very specific, but quite
  6555.      normal queries.  *Note Group by functions::.
  6556.  
  6557.    * To make it easier for users that come from other SQL environments,
  6558.      *MySQL* supports aliases for many functions. For example, all
  6559.      string functions support both ANSI SQL syntax and ODBC syntax.
  6560.  
  6561.    * *MySQL* understands the `||' and `&&' operators to mean logical OR
  6562.      and AND, as in the C programming language.  In *MySQL*, `||' and
  6563.      `OR' are synonyms, as are `&&' and `AND'.  Because of this nice
  6564.      syntax, *MySQL* doesn't support the ANSI SQL `||' operator for
  6565.      string concatenation; use `CONCAT()' instead. Because `CONCAT()'
  6566.      takes any number of arguments, it's easy to convert use of the
  6567.      `||' operator to *MySQL*.
  6568.  
  6569.    * `CREATE DATABASE' or `DROP DATABASE'.  *Note `CREATE DATABASE':
  6570.      CREATE DATABASE.
  6571.  
  6572.    * The `%' operator is a synonym for `MOD()'.  That is, `N % M' is
  6573.      equivalent to `MOD(N,M)'.  `%' is supported for C programmers and
  6574.      for compatibility with PostgreSQL.
  6575.  
  6576.    * The `=', `<>', `<=' ,`<', `>=',`>', `<<', `>>', `<=>', `AND', `OR'
  6577.      or `LIKE' operators may be used in column comparisons to the left
  6578.      of the `FROM' in `SELECT' statements.  For example:
  6579.  
  6580.           mysql> SELECT col1=1 AND col2=2 FROM tbl_name;
  6581.  
  6582.    * The `LAST_INSERT_ID()' function.  *Note `mysql_insert_id()':
  6583.      mysql_insert_id.
  6584.  
  6585.    * The `REGEXP' and `NOT REGEXP' extended regular expression
  6586.      operators.
  6587.  
  6588.    * `CONCAT()' or `CHAR()' with one argument or more than two
  6589.      arguments.  (In *MySQL*, these functions can take any number of
  6590.      arguments.)
  6591.  
  6592.    * The `BIT_COUNT()', `CASE', `ELT()', `FROM_DAYS()', `FORMAT()',
  6593.      `IF()', `PASSWORD()', `ENCRYPT()', `md5()', `ENCODE()', `DECODE()',
  6594.      `PERIOD_ADD()', `PERIOD_DIFF()', `TO_DAYS()', or `WEEKDAY()'
  6595.      functions.
  6596.  
  6597.    * Use of `TRIM()' to trim substrings. ANSI SQL only supports removal
  6598.      of single characters.
  6599.  
  6600.    * The `GROUP BY' functions `STD()', `BIT_OR()' and `BIT_AND()'.
  6601.  
  6602.    * Use of `REPLACE' instead of `DELETE' + `INSERT'.  *Note `REPLACE':
  6603.      REPLACE.
  6604.  
  6605.    * The `FLUSH flush_option' statement.
  6606.  
  6607.    * The possiblity to set variables in a statement with `:=':
  6608.           SELECT @a:=SUM(total),@b=COUNT(*),@a/@b AS avg FROM test_table;
  6609.           SELECT @t1:=(@t2:=1)+@t3:=4,@t1,@t2,@t3;
  6610.  
  6611.  
  6612. Runnning MySQL in ANSI mode
  6613. ===========================
  6614.  
  6615. If you start mysqld with the `--ansi' option, the following behaviour
  6616. of *MySQL* changes.
  6617.  
  6618.    * `||' is string concatenation instead of `OR'.
  6619.  
  6620.    * One can have any number of spaces between a function name and the
  6621.      '('. This makes also all function names reserved words.
  6622.  
  6623.    * `"' will be an identifier quote character (like the *MySQL* ``'
  6624.      quote character) and not a string quote character.
  6625.  
  6626.    * `REAL' will be a synonym for `FLOAT' instead of a synonym of
  6627.      `DOUBLE'.
  6628.  
  6629. MySQL differences compared to ANSI SQL92
  6630. ========================================
  6631.  
  6632. We try to make *MySQL* follow the ANSI SQL standard and the ODBC SQL
  6633. standard, but in some cases *MySQL* does some things differently:
  6634.  
  6635.    * `--' is only a comment if followed by a white space. *Note Missing
  6636.      comments::.
  6637.  
  6638.    * For `VARCHAR' columns, trailing spaces are removed when the value
  6639.      is stored. *Note Bugs::.
  6640.  
  6641.    * In some cases, `CHAR' columns are silently changed to `VARCHAR'
  6642.      columns. *Note Silent column changes::.
  6643.  
  6644.    * Privileges for a table is not automatically revoked when you
  6645.      delete a table. You must explicitly issue a `REVOKE' to revoke
  6646.      privileges for a table. *Note `GRANT': GRANT.
  6647.  
  6648.    * `NULL AND FALSE' will evaluate to `NULL' and not to `FALSE'.  This
  6649.      is because we don't think it's good to have to evaluate a lot of
  6650.      extra conditions in this case.
  6651.  
  6652. Functionality missing from MySQL
  6653. ================================
  6654.  
  6655. The following functionality is missing in the current version of
  6656. *MySQL*.  For a prioritized list indicating when new extensions may be
  6657. added to *MySQL*, you should consult the online *MySQL* TODO list
  6658. (http://www.mysql.com/documentation/manual.php?section=TODO). That is
  6659. the latest version of the TODO list in this manual. *Note TODO::.
  6660.  
  6661. Sub-selects
  6662. -----------
  6663.  
  6664. The following will not yet work in *MySQL*:
  6665.  
  6666.      SELECT * FROM table1 WHERE id IN (SELECT id FROM table2);
  6667.      SELECT * FROM table1 WHERE id NOT IN (SELECT id FROM table2);
  6668.  
  6669. However, in many cases you can rewrite the query without a sub select:
  6670.  
  6671.      SELECT table1.* FROM table1,table2 WHERE table1.id=table2.id;
  6672.      SELECT table1.* FROM table1 LEFT JOIN table2 ON table1.id=table2.id where table2.id IS NULL
  6673.  
  6674. For more complicated subqueries you can often create temporary tables
  6675. to hold the subquery.  In some cases, however this option will not
  6676. work. The most frequently encountered of these cases arises with
  6677. `DELETE' statements, for which standard SQL does not support joins
  6678. (except in sub-selects).  For this situation there are two options
  6679. available until subqueries are supported by *MySQL*.
  6680.  
  6681. The first option is to use a procedural programming language (such as
  6682. Perl or PHP) to submit a `SELECT' query to obtain the primary keys for
  6683. the records to be deleted, and then use these values to construct the
  6684. `DELETE' statement (`DELETE FROM ... WHERE ... IN (key1, key2, ...)').
  6685.  
  6686. The second option is to use interactive SQL to contruct a set of
  6687. `DELETE' statements automatically, using the *MySQL* extension
  6688. `CONCAT()' (in lieu of the standard `||' operator).  For example:
  6689.  
  6690.      SELECT CONCAT('DELETE FROM tab1 WHERE pkid = ', tab1.pkid, ';')
  6691.        FROM tab1, tab2
  6692.       WHERE tab1.col1 = tab2.col2;
  6693.  
  6694. You can place this query in a script file and redirect input from it to
  6695. the `mysql' command-line interpreter, piping its output back to a
  6696. second instance of the interpreter:
  6697.  
  6698.      prompt> mysql --skip-column-names mydb < myscript.sql | mysql mydb
  6699.  
  6700. *MySQL* only supports `INSERT ... SELECT ...' and `REPLACE ... SELECT
  6701. ...' Independent sub-selects will be probably be available in 3.24.0.
  6702. You can now use the function `IN()' in other contexts, however.
  6703.  
  6704. `SELECT INTO TABLE'
  6705. -------------------
  6706.  
  6707. *MySQL* doesn't yet support the Oracle SQL extension: `SELECT ... INTO
  6708. TABLE ...'.  *MySQL* supports instead the ANSI SQL syntax `INSERT INTO
  6709. ... SELECT ...', which is basically the same thing.
  6710.  
  6711. Alternatively, you can use `SELECT INTO OUTFILE...' or `CREATE TABLE
  6712. ... SELECT' to solve your problem.
  6713.  
  6714. Transactions
  6715. ------------
  6716.  
  6717. As *MySQL* does nowadays support transactions, the following discussion
  6718. is only valid if you are only using the non-transaction-safe table
  6719. types. *Note COMMIT::.
  6720.  
  6721. The question is often asked, by the curious and the critical, "Why is
  6722. *MySQL* not a transactional database?" or "Why does *MySQL* not support
  6723. transactions?"
  6724.  
  6725. *MySQL* has made a conscious decision to support another paradigm for
  6726. data integrity, "atomic operations." It is our thinking and experience
  6727. that atomic operations offer equal or even better integrity with much
  6728. better performance. We, nonetheless, appreciate and understand the
  6729. transactional database paradigm and plan, within the next few releases,
  6730. to introduce transaction safe tables on a per table basis. We will be
  6731. giving our users the possibility to decide if they need the speed of
  6732. atomic operations or if they need to use transactional features in their
  6733. applications.
  6734.  
  6735. How does one use the features of *MySQL* to maintain rigorous integrity
  6736. and how do these features compare with the transactional paradigm?
  6737.  
  6738. First, in the transactional paradigm, if your applications are written
  6739. in a way that is dependent on the calling of "rollback" instead of
  6740. "commit" in critical situations, then transactions are more convenient.
  6741. Moreover, transactions ensure that unfinished updates or corrupting
  6742. activities are not commited to the database; the server is given the
  6743. opportunity to do an automatic rollback and your database is saved.
  6744.  
  6745. *MySQL*, in almost all cases, allows you to solve for potential
  6746. problems by including simple checks before updates and by running simple
  6747. scripts that check the databases for inconsistencies and automatically
  6748. repair or warn if such occurs. Note that just by using the *MySQL* log
  6749. or even adding one extra log, one can normally fix tables perfectly
  6750. with no data integrity loss.
  6751.  
  6752. Moreover, "fatal" transactional updates can be rewritten to be atomic.
  6753. In fact,we will go so far as to say that all integrity problems that
  6754. transactions solve can be done with `LOCK TABLES' or atomic updates,
  6755. ensuring that you never will get an automatic abort from the database,
  6756. which is a common problem with transactional databases.
  6757.  
  6758. Not even transactions can prevent all loss if the server goes down.  In
  6759. such cases even a transactional system can lose data.  The difference
  6760. between different systems lies in just how small the time-lap is where
  6761. they could lose data. No system is 100% secure, only "secure enough."
  6762. Even Oracle, reputed to be the safest of transactional databases, is
  6763. reported to sometimes lose data in such situations.
  6764.  
  6765. To be safe with *MySQL*, you only need to have backups and have the
  6766. update logging turned on.  With this you can recover from any situation
  6767. that you could with any transactional database.  It is, of course,
  6768. always good to have backups, independent of which database you use.
  6769.  
  6770. The transactional paradigm has its benefits and its drawbacks. Many
  6771. users and application developers depend on the ease with which they can
  6772. code around problems where an "abort" appears or is necessary, and they
  6773. may have to do a little more work with *MySQL* to either think
  6774. differently or write more. If you are new to the atomic operations
  6775. paradigm, or more familiar or more comfortable with transactions, do not
  6776. jump to the conclusion that *MySQL* has not addressed these issues.
  6777. Reliability and integrity are foremost in our minds.  Recent estimates
  6778. are that there are more than 1,000,000 mysqld servers currently
  6779. running, many of which are in production environments.  We hear very,
  6780. very seldom from our users that they have lost any data, and in almost
  6781. all of those cases user error is involved. This is in our opinion the
  6782. best proof of *MySQL*'s stability and reliability.
  6783.  
  6784. Lastly, in situations where integrity is of highest importance,
  6785. *MySQL*'s current features allow for transaction-level or better
  6786. reliability and integrity. If you lock tables with `LOCK TABLES', all
  6787. updates will stall until any integrity checks are made.  If you only
  6788. obtain a read lock (as opposed to a write lock), then reads and inserts
  6789. are still allowed to happen.  The new inserted records will not be seen
  6790. by any of the clients that have a `READ' lock until they relaease their
  6791. read locks.  With `INSERT DELAYED' you can queue inserts into a local
  6792. queue, until the locks are released, without having to have the client
  6793. wait for the insert to complete.
  6794.  
  6795. "Atomic," in the sense that we mean it, is nothing magical. It only
  6796. means that you can be sure that while each specific update is running
  6797. no other user can interfere with it and that there will never be an
  6798. automatic rollback (which can happen on transaction based systems if
  6799. you are not very careful).  *MySQL* also guarantees that there will not
  6800. be any dirty reads.  You can find some example of how to write atomic
  6801. updates in the in the commit-rollback section. *Note Commit-rollback::.
  6802.  
  6803. We have thought quite a bit about integrity and performance and we
  6804. believe that our atomic operations paradigm allows for both high
  6805. reliability and extremely high performance, on the order of three to
  6806. five times the speed of the fastest and most optimally tuned of
  6807. transactional databases. We didn't leave out transactions because they
  6808. are hard to do; The main reason we went with atomic operations as
  6809. opposed to transactions is that by doing this we could apply many speed
  6810. optimizations that would not otherwise have been possible.
  6811.  
  6812. Many of our users who have speed foremost in their minds are not at all
  6813. concerned about transactions. For them transactions are not an issue.
  6814. For those of our users who are concerned with or have wondered about
  6815. transactions vis a vis *MySQL*, there is a "*MySQL* way" as we have
  6816. outlined above.  For those where safety is more important than speed,
  6817. we recommend them to use the `BDB' tables for all their critical data.
  6818. *Note BDB::.
  6819.  
  6820. One final note: we are currently working on a safe replication schema
  6821. that we believe to be better than any commercial replication system we
  6822. know of. This system will work most reliably under the atomic
  6823. operations, non-transactional, paradigm. Stay tuned.
  6824.  
  6825. Stored procedures and triggers
  6826. ------------------------------
  6827.  
  6828. A stored procedure is a set of SQL commands that can be compiled and
  6829. stored in the server. Once this has been done, clients don't need to
  6830. keep reissuing the entire query but can refer to the stored procedure.
  6831. This provides better performance because the query has to be parsed
  6832. only once and less information needs to be sent between the server and
  6833. the client. You can also raise the conceptual level by having libraries
  6834. of functions in the server.
  6835.  
  6836. A trigger is a stored procedure that is invoked when a particular event
  6837. occurs.  For example, you can install a stored procedure that is
  6838. triggered each time a record is deleted from a transaction table and
  6839. that automatically deletes the corresponding customer from a customer
  6840. table when all his transactions are deleted.
  6841.  
  6842. The planned update language will be able to handle stored procedures,
  6843. but without triggers. Triggers usually slow down everything, even
  6844. queries for which they are not needed.
  6845.  
  6846. To see when *MySQL* might get stored procedures, see *Note TODO::.
  6847.  
  6848. Foreign Keys
  6849. ------------
  6850.  
  6851. Note that foreign keys in SQL are not used to join tables, but are used
  6852. mostly for checking referential integrity.  If you want to get results
  6853. from multiple tables from a `SELECT' statement, you do this by joining
  6854. tables!
  6855.  
  6856.      SELECT * from table1,table2 where table1.id = table2.id;
  6857. *Note `JOIN': JOIN. *Note example-Foreign keys::.
  6858.  
  6859. The `FOREIGN KEY' syntax in *MySQL* exists only for compatibility with
  6860. other SQL vendors' `CREATE TABLE' commands; it doesn't do anything.
  6861. The `FOREIGN KEY' syntax without `ON DELETE ...' is mostly used for
  6862. documentation purposes. Some ODBC applications may use this to produce
  6863. automatic `WHERE' clauses, but this is usually easy to override.
  6864. `FOREIGN KEY' is sometimes used as a constraint check, but this check
  6865. is unnecessary in practice if rows are inserted into the tables in the
  6866. right order. *MySQL* only supports these clauses because some
  6867. applications require them to exist (regardless of whether or not they
  6868. work!).
  6869.  
  6870. In *MySQL*, you can work around the problem of `ON DELETE ...' not
  6871. being implemented by adding the appropriate `DELETE' statement to an
  6872. application when you delete records from a table that has a foreign key.
  6873. In practice this is as quick (in some cases quicker) and much more
  6874. portable than using foreign keys.
  6875.  
  6876. In the near future we will extend the `FOREIGN KEY' implementation so
  6877. that at least the information will be saved in the table specification
  6878. file and may be retrieved by `mysqldump' and ODBC.
  6879.  
  6880. Reasons NOT to use foreign keys
  6881. ...............................
  6882.  
  6883. There are so many problems with `FOREIGN KEY's that we don't know where
  6884. to start:
  6885.  
  6886.    * Foreign keys make life very complicated, because the foreign key
  6887.      definitions must be stored in a database and implementing them
  6888.      would destroy the whole "nice approach" of using files that can be
  6889.      moved, copied and removed.
  6890.  
  6891.    * The speed impact is terrible for `INSERT' and `UPDATE' statements,
  6892.      and in this case almost all `FOREIGN KEY' checks are useless
  6893.      because you usually insert records in the right tables in the
  6894.      right order, anyway.
  6895.  
  6896.    * There is also a need to hold locks on many more tables when
  6897.      updating one table, because the side effects can cascade through
  6898.      the entire database. It's MUCH faster to delete records from one
  6899.      table first and subsequently delete them from the other tables.
  6900.  
  6901.    * You can no longer restore a table by doing a full delete from the
  6902.      table and then restoring all records (from a new source or from a
  6903.      backup).
  6904.  
  6905.    * If you have foreign keys you can't dump and restore tables unless
  6906.      you do so in a very specific order.
  6907.  
  6908.    * It's very easy to do "allowed" circular definitions that make the
  6909.      tables impossible to recreate each table with a single create
  6910.      statement, even if the definition works and is usable.
  6911.  
  6912. The only nice aspect of `FOREIGN KEY' is that it gives ODBC and some
  6913. other client programs the ability to see how a table is connected and
  6914. to use this to show connection diagrams and to help in building
  6915. applicatons.
  6916.  
  6917. *MySQL* will soon store `FOREIGN KEY' definitions so that a client can
  6918. ask for and receive an answer how the original connection was made. The
  6919. current `.frm' file format does not have any place for it.
  6920.  
  6921. Views
  6922. -----
  6923.  
  6924. *MySQL* doesn't support views, but this is on the TODO.
  6925.  
  6926. `--' as the start of a comment
  6927. ------------------------------
  6928.  
  6929. Some other SQL databases use `--' to start comments. *MySQL* has `#' as
  6930. the start comment character, even if the `mysql' command line tool
  6931. removes all lines that start with `--'.  You can also use the C comment
  6932. style `/* this is a comment */' with *MySQL*.  *Note Comments::.
  6933.  
  6934. *MySQL* 3.23.3 and above supports the `--' comment style only if the
  6935. comment is followed by a space.  This is because this degenerate
  6936. comment style has caused many problems with automatically generated SQL
  6937. queries that have used something like the following code, where we
  6938. automatically insert the value of the payment for `!payment!':
  6939.  
  6940.      UPDATE tbl_name SET credit=credit-!payment!
  6941.  
  6942. What do you think will happen when the value of `payment' is negative?
  6943.  
  6944. Because `1--1' is legal in SQL, we think it is terrible that `--' means
  6945. start comment.
  6946.  
  6947. In *MySQL* 3.23 you can however use: `1-- This is a comment'
  6948.  
  6949. The following discussing only concerns you if you are running an
  6950. *MySQL* version earlier than 3.23:
  6951.  
  6952. If you have a SQL program in a text file that contains `--' comments
  6953. you should use:
  6954.  
  6955.      shell> replace " --" " #" < text-file-with-funny-comments.sql \
  6956.               | mysql database
  6957.  
  6958. instead of the usual:
  6959.  
  6960.      shell> mysql database < text-file-with-funny-comments.sql
  6961.  
  6962. You can also edit the command file "in place" to change the `--'
  6963. comments to `#' comments:
  6964.  
  6965.      shell> replace " --" " #" -- text-file-with-funny-comments.sql
  6966.  
  6967. Change them back with this command:
  6968.  
  6969.      shell> replace " #" " --" -- text-file-with-funny-comments.sql
  6970.  
  6971. What standards does MySQL follow?
  6972. =================================
  6973.  
  6974. Entry level SQL92. ODBC level 0-2.
  6975.  
  6976. How to cope without `COMMIT'/`ROLLBACK'
  6977. =======================================
  6978.  
  6979. The following mostly apply only for `ISAM', `MyISAM' and `HEAP' tables;
  6980. If you only use transaction safe tables (`BDB' tables) in an a update
  6981. you can do `COMMIT' and `ROLLBACK' also with `MySQL'.  *Note COMMIT::.
  6982.  
  6983. The problem with handling `COMMIT'-`ROLLBACK' efficiently with the
  6984. above table types would require a completely different table layout
  6985. than *MySQL* uses today.  The table type would also need extra threads
  6986. that do automatic cleanups on the tables and the disk usage would be
  6987. much higher. This would these table types about 2-4 times slower than
  6988. they are today.
  6989.  
  6990. For the moment, we are much more for implementing the SQL server
  6991. language (something like stored procedures). With this you would very
  6992. seldom really need `COMMIT'-`ROLLBACK.' This would also give much
  6993. better performance.
  6994.  
  6995. Loops that need transactions normally can be coded with the help of
  6996. `LOCK TABLES', and you don't need cursors when you can update records
  6997. on the fly.
  6998.  
  6999. We at TcX had a greater need for a real fast database than a 100%
  7000. general database. Whenever we find a way to implement these features
  7001. without any speed loss, we will probably do it. For the moment, there
  7002. are many more important things to do. Check the TODO for how we
  7003. prioritize things at the moment. (Customers with higher levels of
  7004. support can alter this, so things may be reprioritized.)
  7005.  
  7006. The current problem is actually `ROLLBACK'. Without `ROLLBACK', you can
  7007. do any kind of `COMMIT' action with `LOCK TABLES'. To support
  7008. `ROLLBACK' with the above table types, *MySQL* would have to be changed
  7009. to store all old records that were updated and revert everything back
  7010. to the starting point if `ROLLBACK' was issued. For simple cases, this
  7011. isn't that hard to do (the current `isamlog' could be used for this
  7012. purpose), but it would be much more difficult to implement `ROLLBACK'
  7013. for `ALTER/DROP/CREATE TABLE'.
  7014.  
  7015. To avoid using `ROLLBACK', you can use the following strategy:
  7016.  
  7017.   1. Use `LOCK TABLES ...' to lock all the tables you want to access.
  7018.  
  7019.   2. Test conditions.
  7020.  
  7021.   3. Update if everything is okay.
  7022.  
  7023.   4. Use `UNLOCK TABLES' to release your locks.
  7024.  
  7025. This is usually a much faster method than using transactions with
  7026. possible `ROLLBACK's, although not always. The only situation this
  7027. solution doesn't handle is when someone kills the threads in the middle
  7028. of an update. In this case, all locks will be released but some of the
  7029. updates may not have been executed.
  7030.  
  7031. You can also use functions to update records in a single operation.
  7032. You can get a very efficient application by using the following
  7033. techniques:
  7034.  
  7035.    * Modify fields relative to their current value
  7036.  
  7037.    * Update only those fields that actually have changed
  7038.  
  7039. For example, when we are doing updates to some customer information, we
  7040. update only the customer data that have changed and test only that none
  7041. of the changed data, or data that depend on the changed data, have
  7042. changed compared to the original row. The test for changed data is done
  7043. with the `WHERE' clause in the `UPDATE' statement. If the record wasn't
  7044. updated, we give the client a message: "Some of the data you have
  7045. changed have been changed by another user". Then we show the old row
  7046. versus the new row in a window, so the user can decide which version of
  7047. the customer record he should use.
  7048.  
  7049. This gives us something that is similar to "column locking" but is
  7050. actually even better, because we only update some of the columns, using
  7051. values that are relative to their current values.  This means that
  7052. typical `UPDATE' statements look something like these:
  7053.  
  7054.      UPDATE tablename SET pay_back=pay_back+'relative change';
  7055.      
  7056.      UPDATE customer
  7057.        SET
  7058.          customer_date='current_date',
  7059.          address='new address',
  7060.          phone='new phone',
  7061.          money_he_owes_us=money_he_owes_us+'new_money'
  7062.        WHERE
  7063.          customer_id=id AND address='old address' AND phone='old phone';
  7064.  
  7065. As you can see, this is very efficient and works even if another client
  7066. has changed the values in the `pay_back' or `money_he_owes_us' columns.
  7067.  
  7068. In many cases, users have wanted `ROLLBACK' and/or `LOCK TABLES' for
  7069. the purpose of managing unique identifiers for some tables. This can be
  7070. handled much more efficiently by using an `AUTO_INCREMENT' column and
  7071. either the SQL function `LAST_INSERT_ID()' or the C API function
  7072. `mysql_insert_id()'. *Note `mysql_insert_id()': mysql_insert_id.
  7073.  
  7074. At MySQL AB, we have never had any need for row-level locking because
  7075. we have always been able to code around it. Some cases really need row
  7076. locking, but they are very few. If you want row-level locking, you can
  7077. use a flag column in the table and do something like this:
  7078.  
  7079.      UPDATE tbl_name SET row_flag=1 WHERE id=ID;
  7080.  
  7081. *MySQL* returns 1 for the number of affected rows if the row was found
  7082. and `row_flag' wasn't already 1 in the original row.
  7083.  
  7084. You can think of it as *MySQL* changed the above query to:
  7085.  
  7086.      UPDATE tbl_name SET row_flag=1 WHERE id=ID and row_flag <> 1;
  7087.  
  7088. The MySQL access privilege system
  7089. *********************************
  7090.  
  7091. *MySQL* has an advanced but non-standard security/privilege system.
  7092. This section describes how it works.
  7093.  
  7094. General security
  7095. ================
  7096.  
  7097. Anyone using *MySQL* on a computer connected to the Internet should
  7098. read this section to avoid the most common security mistakes.
  7099.  
  7100. In discussing "security" we emphasize the necessity of fully protecting
  7101. the entire server host (not simply the *MySQL* server) against all types
  7102. of applicable attacks: eavesdropping, altering, playback and Denial of
  7103. Service. We do not cover all aspects of availability and fault tolerance
  7104. here.
  7105.  
  7106. *MySQL* uses Access Control Lists (ACLs) security for all connections,
  7107. queries, and other operations which a user may attempt to perform.
  7108. There is also some support for SSL encrypted connections between
  7109. *MySQL* clients and servers. Many of the concepts discussed here are
  7110. not specific to *MySQL* at all; the same general ideas apply to almost
  7111. all applications.
  7112.  
  7113. When running *MySQL*, follow these guidelines whenever possible:
  7114.  
  7115.    * Learn the *MySQL* access privilege system. The `GRANT' and
  7116.      `REVOKE' commands are used for restricting access to *MySQL*. Do
  7117.      not grant any more privileges than necessary. Never grant
  7118.      privileges to all hosts.
  7119.  
  7120.      Checklist:
  7121.         * Try `mysql -u root'. If you are able to connect successfully
  7122.           to the server without being asked for a password, you have
  7123.           problems. Any user (not just root) can connect to your
  7124.           *MySQL* server with full privileges!  Review the *MySQL*
  7125.           installation instructions, paying particular attention to the
  7126.           item about setting a `root' password.
  7127.  
  7128.         * Use the command `SHOW GRANTS' and check to see who has access
  7129.           to what. Remove those privileges which are not necessary
  7130.           using the `REVOKE' command.
  7131.  
  7132.    * Do not keep any plain-text passwords in your database. When your
  7133.      computer becomes compromised, the intruder can take the full list
  7134.      of passwords and use them. Instead use `MD5()' or another one-way
  7135.      hashing function.
  7136.  
  7137.    * Do not use passwords from dictionaries. There are special programs
  7138.      to break them. Even passwords like "xfish98" are very bad.  Much
  7139.      better is "duag98" which contains the same word "fish" but typed
  7140.      one key to the left on a standard QWERTY keyboard. Another method
  7141.      is to use "Mhall" which is taken from first characters of sentence
  7142.      "Mary had a little lamb". This is easy to remember and type, but
  7143.      hard to guess for someone who does not know it.
  7144.  
  7145.    * Invest in a firewall. This protects from at least 50% of all types
  7146.      of exploits in any software. Put *MySQL* behind the firewall or in
  7147.      a demilitarized zone (DMZ).
  7148.  
  7149.      Checklist:
  7150.         * Try to scan your ports from the Internet using a tool such as
  7151.           `nmap'. *MySQL* uses port 3306 by default. This port should
  7152.           be inaccessible from untrusted hosts. Another simple way to
  7153.           check whether or not your *MySQL* port is open is to type
  7154.           `telnet server_host 3306' from some remote machine, where
  7155.           `server_host' is the hostname of your *MySQL* server. If you
  7156.           get a connection and some garbage characters, the port is
  7157.           open, and should be closed on your firewall or router, unless
  7158.           you really have a good reason to keep it open. If `telnet'
  7159.           just hangs, everything is OK, the port is blocked.
  7160.  
  7161.    * Do not trust any data entered by your users. They can try to trick
  7162.      your code by entering special or escaped character sequences in
  7163.      web forms, URLs, or whatever application you have built. Be sure
  7164.      that your application remains secure if user enters something like
  7165.      `; DROP DATABASE mysql;'. This is an extreme example, but large
  7166.      security leaks and data loss may occur as a result of hackers
  7167.      using similar techniques, if you do not prepare for them.
  7168.  
  7169.      Also remember to check numeric data. A common mistake is to
  7170.      protect only strings. Sometimes people think that if a database
  7171.      contains only publicly available data that it need not be
  7172.      protected. This is incorrect. At least Denial-of-Service type
  7173.      attacks can be performed on such databases. The simplest way to
  7174.      protect from this type of attack is to use apostrophes around the
  7175.      numeric constants: `SELECT * FROM table WHERE ID='234'' instead of
  7176.      `SELECT * FROM table WHERE ID=234'.  *MySQL* automatically
  7177.      converts this string to a number and meanwhile strips all
  7178.      non-numeric symbols from it.
  7179.  
  7180.      Checklist:
  7181.         * All WWW applications:
  7182.              * Try to enter `'' and `"' in all your Web forms. If you
  7183.                get any kind of *MySQL* error, investigate the problem
  7184.                right away.
  7185.  
  7186.              * Try to modify any dynamic URLs by adding `%22' (`"'),
  7187.                `%23' (`#') and `%27' (`'') in the URL.
  7188.  
  7189.              * Try to modify datatypes in dynamic URLs from numeric
  7190.                ones to character ones containing characters from
  7191.                previous example. Your application should be safe
  7192.                against this and similar attacks.
  7193.  
  7194.              * Try to enter characters, spaces, special symbols instead
  7195.                of numbers in numeric fields. Your application should
  7196.                remove them before passing them to *MySQL* or your
  7197.                application should generate an error. Passing unchecked
  7198.                values to *MySQL* is very dangerous!
  7199.  
  7200.              * Check data sizes before passing them to *MySQL*.
  7201.  
  7202.              * Consider having your application connect to the database
  7203.                using a different user name than the one you use for
  7204.                administrative purposes. Do not give your applications
  7205.                any more access privileges than what they need.
  7206.  
  7207.         * Users of PHP:
  7208.              * Check out the `addslashes()' function.
  7209.  
  7210.         * Users of *MySQL* C API:
  7211.              * Check out the `mysql_escape()' API call.
  7212.  
  7213.         * Users of *MySQL*++:
  7214.              * Check out the `escape' and `quote' modifiers for query
  7215.                streams.
  7216.  
  7217.         * Users of Perl DBI
  7218.              * Check out the `quote()' method.
  7219.  
  7220.    * Do not transmit plain (unencrypted) data over the Internet. These
  7221.      data are accessible to everyone who has the time and ability to
  7222.      intercept it and use it for their own purposes. Instead, use an
  7223.      encrypted protocol such as SSL or SSH. *MySQL* supports internal
  7224.      SSL connections as of version 3.23.9.  SSH port-forwarding can be
  7225.      used to create an encrypted (and compressed) tunnel for the
  7226.      communication.
  7227.  
  7228.    * Learn to use the `tcpdump' and `strings' utilities. For most cases,
  7229.      you can check whether or not *MySQL* data streams are unencrypted
  7230.      by issuing a command like the following:
  7231.  
  7232.           shell> tcpdump -l -i eth0 -w - src or dst port 3306 | strings
  7233.  
  7234.      (This works under Linux and should work with small modifications
  7235.      under other systems).  Warning: If you do not see data this
  7236.      doesn't always actually mean that it is encrypted. If you need
  7237.      high security, you should consult with a security expert.
  7238.  
  7239. How to make MySQL secure against crackers
  7240. =========================================
  7241.  
  7242. When you connect to a *MySQL* server, you normally should use a
  7243. password.  The password is not transmitted in clear text over the
  7244. connection.
  7245.  
  7246. All other information is transferred as text that can be read by anyone
  7247. that is able to watch the connection.  If you are concerned about this,
  7248. you can use the compressed protocol (in *MySQL* 3.22 and above) to make
  7249. things much harder.  To make things even more secure you should use
  7250. `ssh' (see `http://www.cs.hut.fi/ssh').  With this, you can get an
  7251. encrypted TCP/IP connection between a *MySQL* server and a *MySQL*
  7252. client.
  7253.  
  7254. To make a *MySQL* system secure, you should strongly consider the
  7255. following suggestions:
  7256.  
  7257.    * Use passwords for all *MySQL* users. Remember that anyone can log
  7258.      in as any other person as simply as `mysql -u other_user db_name'
  7259.      if `other_user' has no password.  It is common behavior with
  7260.      client/server applications that the client may specify any user
  7261.      name.  You can change the password of all users by editing the
  7262.      `mysql_install_db' script before you run it, or only the password
  7263.      for the *MySQL* `root' user like this:
  7264.  
  7265.           shell> mysql -u root mysql
  7266.           mysql> UPDATE user SET Password=PASSWORD('new_password')
  7267.                      WHERE user='root';
  7268.           mysql> FLUSH PRIVILEGES;
  7269.  
  7270.    * Don't run the *MySQL* daemon as the Unix `root' user.  It is very
  7271.      dangerous as any user with `FILE' privileges will be able to
  7272.      create files as `root' (e.g. `~root/.bashrc'). To prevent this
  7273.      `mysqld' will refuse to run as `root' unless it is specified
  7274.      directly via `--user=root' option.
  7275.  
  7276.      `mysqld' can be run as any user instead.  You can also create a new
  7277.      Unix user `mysql' to make everything even more secure.  If you run
  7278.      `mysqld' as another Unix user, you don't need to change the `root'
  7279.      user name in the `user' table, because *MySQL* user names have
  7280.      nothing to do with Unix user names.  You can edit the
  7281.      `mysql.server' script to start `mysqld' as another Unix user.
  7282.      Normally this is done with the `su' command.  For more details, see
  7283.      *Note Changing *MySQL* user: Changing MySQL user.
  7284.  
  7285.    * If you put a password for the Unix `root' user in the
  7286.      `mysql.server' script, make sure this script is readable only by
  7287.      `root'.
  7288.  
  7289.    * Check that the Unix user that `mysqld' runs as is the only user
  7290.      with read/write privileges in the database directories.
  7291.  
  7292.    * On Unix platforms, do not run `mysqld' as root unless you really
  7293.      need to. Consider creating a user named `mysql' for that purpose.
  7294.  
  7295.    * Don't give the *process* privilege to all users.  The output of
  7296.      `mysqladmin processlist' shows the text of the currently executing
  7297.      queries, so any user who is allowed to execute that command might
  7298.      be able to see if another user issues an `UPDATE user SET
  7299.      password=PASSWORD('not_secure')' query.
  7300.  
  7301.      `mysqld' reserves an extra connection for users who have the
  7302.      *process* privilege, so that a *MySQL* `root' user can log in and
  7303.      check things even if all normal connections are in use.
  7304.  
  7305.    * Don't give the *file* privilege to all users.  Any user that has
  7306.      this privilege can write a file anywhere in the file system with
  7307.      the privileges of the `mysqld' daemon!  To make this a bit safer,
  7308.      all files generated with `SELECT ... INTO OUTFILE' are readable to
  7309.      everyone, and you can't overwrite existing files.
  7310.  
  7311.      The *file* privilege may also be used to read any file accessible
  7312.      to the Unix user that the server runs as.  This could be abused,
  7313.      for example, by using `LOAD DATA' to load `/etc/passwd' into a
  7314.      table, which can then be read with `SELECT'.
  7315.  
  7316.    * If you don't trust your DNS, you should use IP numbers instead of
  7317.      hostnames in the grant tables.  In principle, the `--secure'
  7318.      option to `mysqld' should make hostnames safe.  In any case, you
  7319.      should be very careful about creating grant table entries using
  7320.      hostname values that contain wildcards!
  7321.  
  7322. The following `mysqld' options affect networking security:
  7323.  
  7324. `--secure'
  7325.      IP numbers returned by the `gethostbyname()' system call are
  7326.      checked to make sure they resolve back to the original hostname.
  7327.      This makes it harder for someone on the outside to get access by
  7328.      pretending to be another host.  This option also adds some sanity
  7329.      checks of hostnames.  The option is turned off by default in
  7330.      *MySQL* 3.21 because sometimes it takes a long time to perform
  7331.      backward resolutions.  *MySQL* 3.22 caches hostnames and has this
  7332.      option enabled by default.
  7333.  
  7334. `--skip-grant-tables'
  7335.      This option causes the server not to use the privilege system at
  7336.      all. This gives everyone _full access_ to all databases!  (You can
  7337.      tell a running server to start using the grant tables again by
  7338.      executing `mysqladmin flush-privileges' or `mysqladmin reload'.)
  7339.  
  7340. `--skip-name-resolve'
  7341.      Hostnames are not resolved.  All `Host' column values in the grant
  7342.      tables must be IP numbers or `localhost'.
  7343.  
  7344. `--skip-networking'
  7345.      Don't allow TCP/IP connections over the network.  All connections
  7346.      to `mysqld' must be made via Unix sockets. This option is
  7347.      unsuitable for systems that use MIT-pthreads, because the
  7348.      MIT-pthreads package doesn't support Unix sockets.
  7349.  
  7350. What the privilege system does
  7351. ==============================
  7352.  
  7353. The primary function of the *MySQL* privilege system is to authenticate
  7354. a user connecting from a given host, and to associate that user with
  7355. privileges on a database such as *select*, *insert*, *update* and
  7356. *delete*.
  7357.  
  7358. Additional functionality includes the ability to have an anonymous user
  7359. and to grant privileges for *MySQL*-specific functions such as `LOAD
  7360. DATA INFILE' and administrative operations.
  7361.  
  7362. MySQL user names and passwords
  7363. ==============================
  7364.  
  7365. There are several distinctions between the way user names and passwords
  7366. are used by *MySQL*, and the way they are used by Unix or Windows:
  7367.  
  7368.    * User names, as used by *MySQL* for authentication purposes, have
  7369.      nothing to do with Unix user names (login names) or Windows user
  7370.      names.  Most *MySQL* clients by default try to log in using the
  7371.      current Unix user name as the *MySQL* user name, but that is for
  7372.      convenience only.  Client programs allow a different name to be
  7373.      specified with the `-u' or `--user' options. This means that you
  7374.      can't make a database secure in any way unless all *MySQL* user
  7375.      names have passwords.  Anyone may attempt to connect to the server
  7376.      using any name, and they will succeed if they specify any name
  7377.      that doesn't have a password.
  7378.  
  7379.    * *MySQL* user names can be up to 16 characters long; Unix user names
  7380.      typically are limited to 8 characters.
  7381.  
  7382.    * *MySQL* passwords have nothing to do with Unix passwords.  There
  7383.      is no necessary connection between the password you use to log in
  7384.      to a Unix machine and the password you use to access a database on
  7385.      that machine.
  7386.  
  7387.    * *MySQL* encrypts passwords using a different algorithm than the one
  7388.      used during the Unix login process.  See the descriptions of the
  7389.      `PASSWORD()' and `ENCRYPT()' functions in *Note Miscellaneous
  7390.      functions::.
  7391.  
  7392. Connecting to the MySQL server
  7393. ==============================
  7394.  
  7395. *MySQL* client programs generally require that you specify connection
  7396. parameters when you want to access a *MySQL* server: the host you want
  7397. to connect to, your user name and your password.  For example, the
  7398. `mysql' client can be started like this (optional arguments are enclosed
  7399. between `[' and `]'):
  7400.  
  7401.      shell> mysql [-h host_name] [-u user_name] [-pyour_pass]
  7402.  
  7403. Alternate forms of the `-h', `-u' and `-p' options are
  7404. `--host=host_name', `--user=user_name' and `--password=your_pass'.
  7405. Note that there is _no space_ between `-p' or `--password=' and the
  7406. password following it.
  7407.  
  7408. *NOTE:* Specifying a password on the command line is not secure!  Any
  7409. user on your system may then find out your password by typing a command
  7410. like: `ps auxww'.  *Note Option files::.
  7411.  
  7412. `mysql' uses default values for connection parameters that are missing
  7413. from the command line:
  7414.  
  7415.    * The default hostname is `localhost'.
  7416.  
  7417.    * The default user name is your Unix login name.
  7418.  
  7419.    * No password is supplied if `-p' is missing.
  7420.  
  7421. Thus, for a Unix user `joe', the following commands are equivalent:
  7422.  
  7423.      shell> mysql -h localhost -u joe
  7424.      shell> mysql -h localhost
  7425.      shell> mysql -u joe
  7426.      shell> mysql
  7427.  
  7428. Other *MySQL* clients behave similarly.
  7429.  
  7430. On Unix systems, you can specify different default values to be used
  7431. when you make a connection, so that you need not enter them on the
  7432. command line each time you invoke a client program.  This can be done
  7433. in a couple of ways:
  7434.  
  7435.    * You can specify connection parameters in the `[client]' section of
  7436.      the `.my.cnf' configuration file in your home directory.  The
  7437.      relevant section of the file might look like this:
  7438.  
  7439.           [client]
  7440.           host=host_name
  7441.           user=user_name
  7442.           password=your_pass
  7443.  
  7444.      *Note Option files::.
  7445.  
  7446.    * You can specify connection parameters using environment variables.
  7447.      The host can be specified for `mysql' using `MYSQL_HOST'.  The
  7448.      *MySQL* user name can be specified using `USER' (this is for
  7449.      Windows only).  The password can be specified using `MYSQL_PWD'
  7450.      (but this is insecure; see next section).  *Note Environment
  7451.      variables::.
  7452.  
  7453. Keeping your password secure
  7454. ============================
  7455.  
  7456. It is inadvisable to specify your password in a way that exposes it to
  7457. discovery by other users.  The methods you can use to specify your
  7458. password when you run client programs are listed below, along with an
  7459. assessment of the risks of each method:
  7460.  
  7461.    * Use a `-pyour_pass' or `--password=your_pass' option on the command
  7462.      line.  This is convenient but insecure, because your password
  7463.      becomes visible to system status programs (such as `ps') that may
  7464.      be invoked by other users to display command lines.  (*MySQL*
  7465.      clients typically overwrite the command line argument with zeroes
  7466.      during their initialization sequence, but there is still a brief
  7467.      interval during which the value is visible.)
  7468.  
  7469.    * Use a `-p' or `--password' option (with no `your_pass' value
  7470.      specified).  In this case, the client program solicits the
  7471.      password from the terminal:
  7472.  
  7473.           shell> mysql -u user_name -p
  7474.           Enter password: ********
  7475.  
  7476.      The client echoes `*' characters to the terminal as you enter your
  7477.      password so that onlookers cannot see it.
  7478.  
  7479.      It is more secure to enter your password this way than to specify
  7480.      it on the command line because it is not visible to other users.
  7481.      However, this method of entering a password is suitable only for
  7482.      programs that you run interactively.  If you want to invoke a
  7483.      client from a script that runs non-interactively, there is no
  7484.      opportunity to enter the password from the terminal. On some
  7485.      systems, you may even find that the first line of your script is
  7486.      read and interpreted (incorrectly) as your password!
  7487.  
  7488.    * Store your password in a configuration file.  For example, you can
  7489.      list your password in the `[client]' section of the `.my.cnf' file
  7490.      in your home directory:
  7491.  
  7492.           [client]
  7493.           password=your_pass
  7494.  
  7495.      If you store your password in `.my.cnf', the file should not be
  7496.      group or world readable or writable.  Make sure the file's access
  7497.      mode is `400' or `600'.
  7498.  
  7499.      *Note Option files::.
  7500.  
  7501.    * You can store your password in the `MYSQL_PWD' environment
  7502.      variable, but this method must be considered extremely insecure
  7503.      and should not be used.  Some versions of `ps' include an option
  7504.      to display the environment of running processes; your password
  7505.      will be in plain sight for all to see if you set `MYSQL_PWD'.
  7506.      Even on systems without such a version of `ps', it is unwise to
  7507.      assume there is no other method to observe process environments.
  7508.      *Note Environment variables::.
  7509.  
  7510. All in all, the safest methods are to have the client program prompt
  7511. for the password or to specify the password in a properly-protected
  7512. `.my.cnf' file.
  7513.  
  7514. Privileges provided by MySQL
  7515. ============================
  7516.  
  7517. Privilege information is stored in the `user', `db', `host',
  7518. `tables_priv' and `columns_priv' tables in the `mysql' database (that
  7519. is, in the database named `mysql').  The *MySQL* server reads the
  7520. contents of these tables when it starts up and under the circumstances
  7521. indicated in *Note Privilege changes::.
  7522.  
  7523. The names used in this manual to refer to the privileges provided by
  7524. *MySQL* are shown below, along with the table column name associated
  7525. with each privilege in the grant tables and the context in which the
  7526. privilege applies:
  7527.  
  7528. *Privilege* *Column*           *Context*
  7529. *select*    `Select_priv'      tables
  7530. *insert*    `Insert_priv'      tables
  7531. *update*    `Update_priv'      tables
  7532. *delete*    `Delete_priv'      tables
  7533. *index*     `Index_priv'       tables
  7534. *alter*     `Alter_priv'       tables
  7535. *create*    `Create_priv'      databases, tables or indexes
  7536. *drop*      `Drop_priv'        databases or tables
  7537. *grant*     `Grant_priv'       databases or tables
  7538. *references*`References_priv'  databases or tables
  7539. *reload*    `Reload_priv'      server administration
  7540. *shutdown*  `Shutdown_priv'    server administration
  7541. *process*   `Process_priv'     server administration
  7542. *file*      `File_priv'        file access on server
  7543.  
  7544. The *select*, *insert*, *update* and *delete* privileges allow you to
  7545. perform operations on rows in existing tables in a database.
  7546.  
  7547. `SELECT' statements require the *select* privilege only if they
  7548. actually retrieve rows from a table.  You can execute certain `SELECT'
  7549. statements even without permission to access any of the databases on the
  7550. server.  For example, you could use the `mysql' client as a simple
  7551. calculator:
  7552.  
  7553.      mysql> SELECT 1+1;
  7554.      mysql> SELECT PI()*2;
  7555.  
  7556. The *index* privilege allows you to create or drop (remove) indexes.
  7557.  
  7558. The *alter* privilege allows you to use `ALTER TABLE'.
  7559.  
  7560. The *create* and *drop* privileges allow you to create new databases
  7561. and tables, or to drop (remove) existing databases and tables.
  7562.  
  7563. Note that if you grant the *drop* privilege for the `mysql' database to
  7564. a user, that user can drop the database in which the *MySQL* access
  7565. privileges are stored!
  7566.  
  7567. The *grant* privilege allows you to give to other users those
  7568. privileges you yourself possess.
  7569.  
  7570. The *file* privilege gives you permission to read and write files on
  7571. the server using the `LOAD DATA INFILE' and `SELECT ... INTO OUTFILE'
  7572. statements.  Any user to whom this privilege is granted can read or
  7573. write any file that the *MySQL* server can read or write.
  7574.  
  7575. The remaining privileges are used for administrative operations, which
  7576. are performed using the `mysqladmin' program.  The table below shows
  7577. which `mysqladmin' commands each administrative privilege allows you to
  7578. execute:
  7579.  
  7580. *Privilege* *Commands permitted to privilege holders*
  7581. *reload*    `reload', `refresh', `flush-privileges', `flush-hosts',
  7582.             `flush-logs', `flush-tables'
  7583. *shutdown*  `shutdown'
  7584. *process*   `processlist', `kill'
  7585.  
  7586. The `reload' command tells the server to reread the grant tables.  The
  7587. `refresh' command flushes all tables and opens and closes the log
  7588. files.  `flush-privileges' is a synonym for `reload'.  The other
  7589. `flush-*' commands perform functions similar to `refresh' but are more
  7590. limited in scope, and may be preferable in some instances.  For example,
  7591. if you want to flush just the log files, `flush-logs' is a better choice
  7592. than `refresh'.
  7593.  
  7594. The `shutdown' command shuts down the server.
  7595.  
  7596. The `processlist' command displays information about the threads
  7597. executing within the server.  The `kill' command kills server threads.
  7598. You can always display or kill your own threads, but you need the
  7599. *process* privilege to display or kill threads initiated by other users.
  7600.  
  7601. It is a good idea in general to grant privileges only to those users
  7602. who need them, but you should exercise particular caution in granting
  7603. certain privileges:
  7604.  
  7605.    * The *grant* privilege allows users to give away their privileges to
  7606.      other users.  Two users with different privileges and with the
  7607.      *grant* privilege are able to combine privileges.
  7608.  
  7609.    * The *alter* privilege may be used to subvert the privilege system
  7610.      by renaming tables.
  7611.  
  7612.    * The *file* privilege can be abused to read any world-readable file
  7613.      on the server into a database table, the contents of which can
  7614.      then be accessed using `SELECT'. This includes the contents of all
  7615.      databases hosted by the server!
  7616.  
  7617.    * The *shutdown* privilege can be abused to deny service to other
  7618.      users entirely, by terminating the server.
  7619.  
  7620.    * The *process* privilege can be used to view the plain text of
  7621.      currently executing queries, including queries that set or change
  7622.      passwords.
  7623.  
  7624.    * Privileges on the `mysql' database can be used to change passwords
  7625.      and other access privilege information.  (Passwords are stored
  7626.      encrypted, so a malicious user cannot simply read them.  However,
  7627.      with sufficient privileges, that same user can replace a password
  7628.      with a different one.)
  7629.  
  7630. There are some things that you cannot do with the *MySQL* privilege
  7631. system:
  7632.  
  7633.    * You cannot explicitly specify that a given user should be denied
  7634.      access.  That is, you cannot explicitly match a user and then
  7635.      refuse the connection.
  7636.  
  7637.    * You cannot specify that a user has privileges to create or drop
  7638.      tables in a database but not to create or drop the database itself.
  7639.  
  7640. How the privilege system works
  7641. ==============================
  7642.  
  7643. The *MySQL* privilege system ensures that all users may do exactly the
  7644. things that they are supposed to be allowed to do.  When you connect to
  7645. a *MySQL* server, your identity is determined by *the host from which
  7646. you connect* and *the user name you specify*.  The system grants
  7647. privileges according to your identity and *what you want to do*.
  7648.  
  7649. *MySQL* considers both your hostname and user name in identifying you
  7650. because there is little reason to assume that a given user name belongs
  7651. to the same person everywhere on the Internet.  For example, the user
  7652. `bill' who connects from `whitehouse.gov' need not be the same person
  7653. as the user `bill' who connects from `microsoft.com'.  *MySQL* handles
  7654. this by allowing you to distinguish users on different hosts that
  7655. happen to have the same name:  you can grant `bill' one set of
  7656. privileges for connections from `whitehouse.gov', and a different set
  7657. of privileges for connections from `microsoft.com'.
  7658.  
  7659. *MySQL* access control involves two stages:
  7660.  
  7661.    * Stage 1: The server checks whether or not you are even allowed to
  7662.      connect.
  7663.  
  7664.    * Stage 2: Assuming you can connect, the server checks each request
  7665.      you issue to see whether or not you have sufficient privileges to
  7666.      perform it.  For example, if you try to select rows from a table
  7667.      in a database or drop a table from the database, the server makes
  7668.      sure you have the *select* privilege for the table or the *drop*
  7669.      privilege for the database.
  7670.  
  7671. The server uses the `user', `db' and `host' tables in the `mysql'
  7672. database at both stages of access control.  The fields in these grant
  7673. tables are shown below:
  7674.  
  7675. *Table name*   `user'             `db'               `host'
  7676. *Scope         `Host'             `Host'             `Host'
  7677. fields*                                              
  7678.                `User'             `Db'               `Db'
  7679.                `Password'         `User'             
  7680. *Privilege     `Select_priv'      `Select_priv'      `Select_priv'
  7681. fields*                                              
  7682.                `Insert_priv'      `Insert_priv'      `Insert_priv'
  7683.                `Update_priv'      `Update_priv'      `Update_priv'
  7684.                `Delete_priv'      `Delete_priv'      `Delete_priv'
  7685.                `Index_priv'       `Index_priv'       `Index_priv'
  7686.                `Alter_priv'       `Alter_priv'       `Alter_priv'
  7687.                `Create_priv'      `Create_priv'      `Create_priv'
  7688.                `Drop_priv'        `Drop_priv'        `Drop_priv'
  7689.                `Grant_priv'       `Grant_priv'       `Grant_priv'
  7690.                `References_priv'                     
  7691.                `Reload_priv'                         
  7692.                `Shutdown_priv'                       
  7693.                `Process_priv'                        
  7694.                `File_priv'                           
  7695.  
  7696. For the second stage of access control (request verification), the
  7697. server may, if the request involves tables, additionally consult the
  7698. `tables_priv' and `columns_priv' tables.  The fields in these tables
  7699. are shown below:
  7700.  
  7701. *Table name*   `tables_priv'      `columns_priv'
  7702. *Scope         `Host'             `Host'
  7703. fields*                           
  7704.                `Db'               `Db'
  7705.                `User'             `User'
  7706.                `Table_name'       `Table_name'
  7707.                                   `Column_name'
  7708. *Privilege     `Table_priv'       `Column_priv'
  7709. fields*                           
  7710.                `Column_priv'      
  7711. *Other         `Timestamp'        `Timestamp'
  7712. fields*                           
  7713.                `Grantor'          
  7714.  
  7715. Each grant table contains scope fields and privilege fields.
  7716.  
  7717. Scope fields determine the scope of each entry in the tables, i.e., the
  7718. context in which the entry applies.  For example, a `user' table entry
  7719. with `Host' and `User' values of `'thomas.loc.gov'' and `'bob'' would
  7720. be used for authenticating connections made to the server by `bob' from
  7721. the host `thomas.loc.gov'.  Similarly, a `db' table entry with `Host',
  7722. `User' and `Db' fields of `'thomas.loc.gov'', `'bob'' and `'reports''
  7723. would be used when `bob' connects from the host `thomas.loc.gov' to
  7724. access the `reports' database.  The `tables_priv' and `columns_priv'
  7725. tables contain scope fields indicating tables or table/column
  7726. combinations to which each entry applies.
  7727.  
  7728. For access-checking purposes, comparisons of `Host' values are case
  7729. insensitive.  `User', `Password', `Db' and `Table_name' values are case
  7730. sensitive.  `Column_name' values are case insensitive in *MySQL* 3.22.12
  7731. or later.
  7732.  
  7733. Privilege fields indicate the privileges granted by a table entry, that
  7734. is, what operations can be performed.  The server combines the
  7735. information in the various grant tables to form a complete description
  7736. of a user's privileges.  The rules used to do this are described in
  7737. *Note Request access::.
  7738.  
  7739. Scope fields are strings, declared as shown below; the default value for
  7740. each is the empty string:
  7741.  
  7742. *Field      *Type*      
  7743. name*                   
  7744. `Host'      `CHAR(60)'  
  7745. `User'      `CHAR(16)'  
  7746. `Password'  `CHAR(16)'  
  7747. `Db'        `CHAR(64)'  (`CHAR(60)' for the `tables_priv' and
  7748.                         `columns_priv' tables)
  7749. `Table_name'`CHAR(60)'  
  7750. `Column_name'`CHAR(60)'  
  7751.  
  7752. In the `user', `db' and `host' tables, all privilege fields are
  7753. declared as `ENUM('N','Y')' -- each can have a value of `'N'' or `'Y'',
  7754. and the default value is `'N''.
  7755.  
  7756. In the `tables_priv' and `columns_priv' tables, the privilege fields
  7757. are declared as `SET' fields:
  7758.  
  7759. *Table name*   *Field name*   *Possible set elements*
  7760. `tables_priv'  `Table_priv'   `'Select', 'Insert', 'Update', 'Delete',
  7761.                               'Create', 'Drop', 'Grant', 'References',
  7762.                               'Index', 'Alter''
  7763. `tables_priv'  `Column_priv'  `'Select', 'Insert', 'Update',
  7764.                               'References''
  7765. `columns_priv' `Column_priv'  `'Select', 'Insert', 'Update',
  7766.                               'References''
  7767.  
  7768. Briefly, the server uses the grant tables like this:
  7769.  
  7770.    * The `user' table scope fields determine whether to allow or reject
  7771.      incoming connections.  For allowed connections, any privileges
  7772.      granted in the `user' table indicate the user's global (superuser)
  7773.      privileges.  These privileges apply to *all* databases on the
  7774.      server.
  7775.  
  7776.    * The `db' and `host' tables are used together:
  7777.  
  7778.         - The `db' table scope fields determine which users can access
  7779.           which databases from which hosts.  The privilege fields
  7780.           determine which operations are allowed.
  7781.  
  7782.         - The `host' table is used as an extension of the `db' table
  7783.           when you want a given `db' table entry to apply to several
  7784.           hosts.  For example, if you want a user to be able to use a
  7785.           database from several hosts in your network, leave the `Host'
  7786.           value empty in the user's `db' table entry, then populate the
  7787.           `host' table with an entry for each of those hosts.  This
  7788.           mechanism is described more detail in *Note Request access::.
  7789.  
  7790.    * The `tables_priv' and `columns_priv' tables are similar to the
  7791.      `db' table, but are more fine-grained: they apply at the table and
  7792.      column level rather than at the database level.
  7793.  
  7794. Note that administrative privileges (*reload*, *shutdown*, etc.) are
  7795. specified only in the `user' table.  This is because administrative
  7796. operations are operations on the server itself and are not
  7797. database-specific, so there is no reason to list such privileges in the
  7798. other grant tables.  In fact, only the `user' table need be consulted
  7799. to determine whether or not you can perform an administrative operation.
  7800.  
  7801. The *file* privilege is specified only in the `user' table, too.  It is
  7802. not an administrative privilege as such, but your ability to read or
  7803. write files on the server host is independent of the database you are
  7804. accessing.
  7805.  
  7806. The `mysqld' server reads the contents of the grant tables once, when it
  7807. starts up.  Changes to the grant tables take effect as indicated in
  7808. *Note Privilege changes::.
  7809.  
  7810. When you modify the contents of the grant tables, it is a good idea to
  7811. make sure that your changes set up privileges the way you want.  For
  7812. help in diagnosing problems, see *Note Access denied::.  For advice on
  7813. security issues, *Note Security::.
  7814.  
  7815. A useful diagnostic tool is the `mysqlaccess' script, which Yves
  7816. Carlier has provided for the *MySQL* distribution.  Invoke
  7817. `mysqlaccess' with the `--help' option to find out how it works.  Note
  7818. that `mysqlaccess' checks access using only the `user', `db' and `host'
  7819. tables.  It does not check table- or column-level privileges.
  7820.  
  7821. Access control, stage 1: Connection verification
  7822. ================================================
  7823.  
  7824. When you attempt to connect to a *MySQL* server, the server accepts or
  7825. rejects the connection based on your identity and whether or not you can
  7826. verify your identity by supplying the correct password.  If not, the
  7827. server denies access to you completely.  Otherwise, the server accepts
  7828. the connection, then enters stage 2 and waits for requests.
  7829.  
  7830. Your identity is based on two pieces of information:
  7831.  
  7832.    * The host from which you connect
  7833.  
  7834.    * Your *MySQL* user name
  7835.  
  7836. Identity checking is performed using the three `user' table scope fields
  7837. (`Host', `User' and `Password').  The server accepts the connection
  7838. only if a `user' table entry matches your hostname and user name, and
  7839. you supply the correct password.
  7840.  
  7841. Values in the `user' table scope fields may be specified as follows:
  7842.  
  7843.    * A `Host' value may be a hostname or an IP number, or `'localhost''
  7844.      to indicate the local host.
  7845.  
  7846.    * You can use the wildcard characters `%' and `_' in the `Host'
  7847.      field.
  7848.  
  7849.    * A `Host' value of `'%'' matches any hostname.  A blank `Host'
  7850.      value is equivalent to `'%''.  Note that these values match _any
  7851.      host that can create a connection to your server!_
  7852.  
  7853.    * As of MySQL 3.23, for `Host' values specified as IP numbers, you
  7854.      can specify a netmask indicating how many address bits to use for
  7855.      the network number. For example:
  7856.  
  7857.           GRANT ALL PRIVILEGES on db.* to david1'92.58.197.0/255.255.255.0';
  7858.  
  7859.      This will allow everyone to connect from an IP where the following
  7860.      is true:
  7861.  
  7862.           user_ip & netmask = host_ip.
  7863.  
  7864.      In the above example all IP:s in the interval 192.58.197.0 -
  7865.      192.58.197.255 can connect to the *MySQL* server.
  7866.  
  7867.    * Wildcard characters are not allowed in the `User' field, but you
  7868.      can specify a blank value, which matches any name.  If the `user'
  7869.      table entry that matches an incoming connection has a blank user
  7870.      name, the user is considered to be the anonymous user (the user
  7871.      with no name), rather than the name that the client actually
  7872.      specified.  This means that a blank user name is used for all
  7873.      further access checking for the duration of the connection (that
  7874.      is, during stage 2).
  7875.  
  7876.    * The `Password' field can be blank.  This does not mean that any
  7877.      password matches, it means the user must connect without
  7878.      specifying a password.
  7879.  
  7880. Non-blank `Password' values represent encrypted passwords.  *MySQL*
  7881. does not store passwords in plaintext form for anyone to see.  Rather,
  7882. the password supplied by a user who is attempting to connect is
  7883. encrypted (using the `PASSWORD()' function) and compared to the
  7884. already-encrypted version stored in the `user' table.  If they match,
  7885. the password is correct.
  7886.  
  7887. The examples below show how various combinations of `Host' and `User'
  7888. values in `user' table entries apply to incoming connections:
  7889.  
  7890. `Host' *value*     `User'      *Connections matched by entry*
  7891.                    *value*     
  7892. `'thomas.loc.gov'' `'fred''    `fred', connecting from `thomas.loc.gov'
  7893. `'thomas.loc.gov'' `'''        Any user, connecting from `thomas.loc.gov'
  7894. `'%''              `'fred''    `fred', connecting from any host
  7895. `'%''              `'''        Any user, connecting from any host
  7896. `'%.loc.gov''      `'fred''    `fred', connecting from any host in the
  7897.                                `loc.gov' domain
  7898. `'x.y.%''          `'fred''    `fred', connecting from `x.y.net',
  7899.                                `x.y.com',`x.y.edu', etc. (this is
  7900.                                probably not useful)
  7901. `'144.155.166.177''`'fred''    `fred', connecting from the host with IP
  7902.                                address `144.155.166.177'
  7903. `'144.155.166.%''  `'fred''    `fred', connecting from any host in the
  7904.                                `144.155.166' class C subnet
  7905. `'144.155.166.0/24''`'fred''    Same as previous example
  7906.  
  7907. Because you can use IP wildcard values in the `Host' field (e.g.,
  7908. `'144.155.166.%'' to match every host on a subnet), there is the
  7909. possibility that someone might try to exploit this capability by naming
  7910. a host `144.155.166.somewhere.com'.  To foil such attempts, *MySQL*
  7911. disallows matching on hostnames that start with digits and a dot. Thus,
  7912. if you have a host named something like `1.2.foo.com', its name will
  7913. never match the `Host' column of the grant tables.  Only an IP number
  7914. can match an IP wildcard value.
  7915.  
  7916. An incoming connection may be matched by more than one entry in the
  7917. `user' table.  For example, a connection from `thomas.loc.gov' by
  7918. `fred' would be matched by several of the entries just shown above.  How
  7919. does the server choose which entry to use if more than one matches?  The
  7920. server resolves this question by sorting the `user' table after reading
  7921. it at startup time, then looking through the entries in sorted order
  7922. when a user attempts to connect.  The first matching entry is the one
  7923. that is used.
  7924.  
  7925. `user' table sorting works as follows.  Suppose the `user' table looks
  7926. like this:
  7927.  
  7928.      +-----------+----------+-
  7929.      | Host      | User     | ...
  7930.      +-----------+----------+-
  7931.      | %         | root     | ...
  7932.      | %         | jeffrey  | ...
  7933.      | localhost | root     | ...
  7934.      | localhost |          | ...
  7935.      +-----------+----------+-
  7936.  
  7937. When the server reads in the table, it orders the entries with the
  7938. most-specific `Host' values first (`'%'' in the `Host' column means
  7939. "any host" and is least specific).  Entries with the same `Host' value
  7940. are ordered with the most-specific `User' values first (a blank `User'
  7941. value means "any user" and is least specific).  The resulting sorted
  7942. `user' table looks like this:
  7943.  
  7944.      +-----------+----------+-
  7945.      | Host      | User     | ...
  7946.      +-----------+----------+-
  7947.      | localhost | root     | ...
  7948.      | localhost |          | ...
  7949.      | %         | jeffrey  | ...
  7950.      | %         | root     | ...
  7951.      +-----------+----------+-
  7952.  
  7953. When a connection is attempted, the server looks through the sorted
  7954. entries and uses the first match found.  For a connection from
  7955. `localhost' by `jeffrey', the entries with `'localhost'' in the `Host'
  7956. column match first.  Of those, the entry with the blank user name
  7957. matches both the connecting hostname and user name.  (The
  7958. `'%'/'jeffrey'' entry would have matched, too, but it is not the first
  7959. match in the table.)
  7960.  
  7961. Here is another example.  Suppose the `user' table looks like this:
  7962.  
  7963.      +----------------+----------+-
  7964.      | Host           | User     | ...
  7965.      +----------------+----------+-
  7966.      | %              | jeffrey  | ...
  7967.      | thomas.loc.gov |          | ...
  7968.      +----------------+----------+-
  7969.  
  7970. The sorted table looks like this:
  7971.  
  7972.      +----------------+----------+-
  7973.      | Host           | User     | ...
  7974.      +----------------+----------+-
  7975.      | thomas.loc.gov |          | ...
  7976.      | %              | jeffrey  | ...
  7977.      +----------------+----------+-
  7978.  
  7979. A connection from `thomas.loc.gov' by `jeffrey' is matched by the first
  7980. entry, whereas a connection from `whitehouse.gov' by `jeffrey' is
  7981. matched by the second.
  7982.  
  7983. A common misconception is to think that for a given user name, all
  7984. entries that explicitly name that user will be used first when the
  7985. server attempts to find a match for the connection.  This is simply not
  7986. true.  The previous example illustrates this, where a connection from
  7987. `thomas.loc.gov' by `jeffrey' is first matched not by the entry
  7988. containing `'jeffrey'' as the `User' field value, but by the entry with
  7989. no user name!
  7990.  
  7991. If you have problems connecting to the server, print out the `user'
  7992. table and sort it by hand to see where the first match is being made.
  7993.  
  7994. Access control, stage 2: Request verification
  7995. =============================================
  7996.  
  7997. Once you establish a connection, the server enters stage 2.  For each
  7998. request that comes in on the connection, the server checks whether you
  7999. have sufficient privileges to perform it, based on the type of
  8000. operation you wish to perform.  This is where the privilege fields in
  8001. the grant tables come into play.  These privileges can come from any of
  8002. the `user', `db', `host', `tables_priv' or `columns_priv' tables.  The
  8003. grant tables are manipulated with `GRANT' and `REVOKE' commands.  *Note
  8004. `GRANT': GRANT.  (You may find it helpful to refer to *Note
  8005. Privileges::, which lists the fields present in each of the grant
  8006. tables.)
  8007.  
  8008. The `user' table grants privileges that are assigned to you on a global
  8009. basis and that apply no matter what the current database is.  For
  8010. example, if the `user' table grants you the *delete* privilege, you can
  8011. delete rows from any database on the server host!  In other words,
  8012. `user' table privileges are superuser privileges.  It is wise to grant
  8013. privileges in the `user' table only to superusers such as server or
  8014. database administrators.  For other users, you should leave the
  8015. privileges in the `user' table set to `'N'' and grant privileges on a
  8016. database-specific basis only, using the `db' and `host' tables.
  8017.  
  8018. The `db' and `host' tables grant database-specific privileges.  Values
  8019. in the scope fields may be specified as follows:
  8020.  
  8021.    * The wildcard characters `%' and `_' can be used in the `Host' and
  8022.      `Db' fields of either table.
  8023.  
  8024.    * A `'%'' `Host' value in the `db' table means "any host." A blank
  8025.      `Host' value in the `db' table means "consult the `host' table for
  8026.      further information."
  8027.  
  8028.    * A `'%'' or blank `Host' value in the `host' table means "any host."
  8029.  
  8030.    * A `'%'' or blank `Db' value in either table means "any database."
  8031.  
  8032.    * A blank `User' value in either table matches the anonymous user.
  8033.  
  8034. The `db' and `host' tables are read in and sorted when the server
  8035. starts up (at the same time that it reads the `user' table).  The `db'
  8036. table is sorted on the `Host', `Db' and `User' scope fields, and the
  8037. `host' table is sorted on the `Host' and `Db' scope fields.  As with
  8038. the `user' table, sorting puts the most-specific values first and
  8039. least-specific values last, and when the server looks for matching
  8040. entries, it uses the first match that it finds.
  8041.  
  8042. The `tables_priv' and `columns_priv' tables grant table- and
  8043. column-specific privileges.  Values in the scope fields may be
  8044. specified as follows:
  8045.  
  8046.    * The wildcard characters `%' and `_' can be used in the `Host'
  8047.      field of either table.
  8048.  
  8049.    * A `'%'' or blank `Host' value in either table means "any host."
  8050.  
  8051.    * The `Db', `Table_name' and `Column_name' fields cannot contain
  8052.      wildcards or be blank in either table.
  8053.  
  8054. The `tables_priv' and `columns_priv' tables are sorted on the `Host',
  8055. `Db' and `User' fields.  This is similar to `db' table sorting,
  8056. although the sorting is simpler because only the `Host' field may
  8057. contain wildcards.
  8058.  
  8059. The request verification process is described below.  (If you are
  8060. familiar with the access-checking source code, you will notice that the
  8061. description here differs slightly from the algorithm used in the code.
  8062. The description is equivalent to what the code actually does; it
  8063. differs only to make the explanation simpler.)
  8064.  
  8065. For administrative requests (*shutdown*, *reload*, etc.), the server
  8066. checks only the `user' table entry, because that is the only table that
  8067. specifies administrative privileges.  Access is granted if the entry
  8068. allows the requested operation and denied otherwise.  For example, if
  8069. you want to execute `mysqladmin shutdown' but your `user' table entry
  8070. doesn't grant the *shutdown* privilege to you, access is denied without
  8071. even checking the `db' or `host' tables.  (They contain no
  8072. `Shutdown_priv' column, so there is no need to do so.)
  8073.  
  8074. For database-related requests (*insert*, *update*, etc.), the server
  8075. first checks the user's global (superuser) privileges by looking in the
  8076. `user' table entry.  If the entry allows the requested operation,
  8077. access is granted.  If the global privileges in the `user' table are
  8078. insufficient, the server determines the user's database-specific
  8079. privileges by checking the `db' and `host' tables:
  8080.  
  8081.   1. The server looks in the `db' table for a match on the `Host', `Db'
  8082.      and `User' fields.  The `Host' and `User' fields are matched to
  8083.      the connecting user's hostname and *MySQL* user name.  The `Db'
  8084.      field is matched to the database the user wants to access.  If
  8085.      there is no entry for the `Host' and `User', access is denied.
  8086.  
  8087.   2. If there is a matching `db' table entry and its `Host' field is
  8088.      not blank, that entry defines the user's database-specific
  8089.      privileges.
  8090.  
  8091.   3. If the matching `db' table entry's `Host' field is blank, it
  8092.      signifies that the `host' table enumerates which hosts should be
  8093.      allowed access to the database.  In this case, a further lookup is
  8094.      done in the `host' table to find a match on the `Host' and `Db'
  8095.      fields.  If no `host' table entry matches, access is denied.  If
  8096.      there is a match, the user's database-specific privileges are
  8097.      computed as the intersection (_not_ the union!) of the privileges
  8098.      in the `db' and `host' table entries, i.e., the privileges that
  8099.      are `'Y'' in both entries.  (This way you can grant general
  8100.      privileges in the `db' table entry and then selectively restrict
  8101.      them on a host-by-host basis using the `host' table entries.)
  8102.  
  8103. After determining the database-specific privileges granted by the `db'
  8104. and `host' table entries, the server adds them to the global privileges
  8105. granted by the `user' table.  If the result allows the requested
  8106. operation, access is granted.  Otherwise, the server checks the user's
  8107. table and column privileges in the `tables_priv' and `columns_priv'
  8108. tables and adds those to the user's privileges.  Access is allowed or
  8109. denied based on the result.
  8110.  
  8111. Expressed in boolean terms, the preceding description of how a user's
  8112. privileges are calculated may be summarized like this:
  8113.  
  8114.      global privileges
  8115.      OR (database privileges AND host privileges)
  8116.      OR table privileges
  8117.      OR column privileges
  8118.  
  8119. It may not be apparent why, if the global `user' entry privileges are
  8120. initially found to be insufficient for the requested operation, the
  8121. server adds those privileges to the database-, table- and
  8122. column-specific privileges later. The reason is that a request might
  8123. require more than one type of privilege.  For example, if you execute
  8124. an `INSERT ...  SELECT' statement, you need both *insert* and *select*
  8125. privileges.  Your privileges might be such that the `user' table entry
  8126. grants one privilege and the `db' table entry grants the other.  In
  8127. this case, you have the necessary privileges to perform the request,
  8128. but the server cannot tell that from either table by itself; the
  8129. privileges granted by the entries in both tables must be combined.
  8130.  
  8131. The `host' table can be used to maintain a list of "secure" servers.
  8132. At TcX, the `host' table contains a list of all machines on the local
  8133. network. These are granted all privileges.
  8134.  
  8135. You can also use the `host' table to indicate hosts that are _not_
  8136. secure.  Suppose you have a machine `public.your.domain' that is located
  8137. in a public area that you do not consider secure.  You can allow access
  8138. to all hosts on your network except that machine by using `host' table
  8139. entries like this:
  8140.  
  8141.      +--------------------+----+-
  8142.      | Host               | Db | ...
  8143.      +--------------------+----+-
  8144.      | public.your.domain | %  | ... (all privileges set to 'N')
  8145.      | %.your.domain      | %  | ... (all privileges set to 'Y')
  8146.      +--------------------+----+-
  8147.  
  8148. Naturally, you should always test your entries in the grant tables
  8149. (e.g., using `mysqlaccess') to make sure your access privileges are
  8150. actually set up the way you think they are.
  8151.  
  8152. When privilege changes take effect
  8153. ==================================
  8154.  
  8155. When `mysqld' starts, all grant table contents are read into memory and
  8156. become effective at that point.
  8157.  
  8158. Modifications to the grant tables that you perform using `GRANT',
  8159. `REVOKE', or `SET PASSWORD' are noticed by the server immediately.
  8160.  
  8161. If you modify the grant tables manually (using `INSERT', `UPDATE',
  8162. etc.), you should execute a `FLUSH PRIVILEGES' statement or run
  8163. `mysqladmin flush-privileges' or `mysqladmin reload' to tell the server
  8164. to reload the grant tables.  Otherwise your changes will have _no
  8165. effect_ until you restart the server. If you change the grant tables
  8166. manually but forget to reload the privileges, you will be wondering why
  8167. your changes don't seem to make any difference!
  8168.  
  8169. When the server notices that the grant tables have been changed,
  8170. existing client connections are affected as follows:
  8171.  
  8172.    * Table and column privilege changes take effect with the client's
  8173.      next request.
  8174.  
  8175.    * Database privilege changes take effect at the next `USE db_name'
  8176.      command.
  8177.  
  8178. Global privilege changes and password changes take effect the next time
  8179. the client connects.
  8180.  
  8181. Setting up the initial MySQL privileges
  8182. =======================================
  8183.  
  8184. After installing *MySQL*, you set up the initial access privileges by
  8185. running `scripts/mysql_install_db'.  *Note Quick install::.  The
  8186. `mysql_install_db' script starts up the `mysqld' server, then
  8187. initializes the grant tables to contain the following set of privileges:
  8188.  
  8189.    * The *MySQL* `root' user is created as a superuser who can do
  8190.      anything.  Connections must be made from the local host.
  8191.  
  8192.      *Note:* The initial `root' password is empty, so anyone can
  8193.      connect as `root' _without a password_ and be granted all
  8194.      privileges.
  8195.  
  8196.    * An anonymous user is created that can do anything with databases
  8197.      that have a name of `'test'' or starting with `'test_''.
  8198.      Connections must be made from the local host.  This means any
  8199.      local user can connect without a password and be treated as the
  8200.      anonymous user.
  8201.  
  8202.    * Other privileges are denied.  For example, normal users can't use
  8203.      `mysqladmin shutdown' or `mysqladmin processlist'.
  8204.  
  8205. *NOTE:* The default privileges are different for Win32.  *Note Win32
  8206. running::.
  8207.  
  8208. Because your installation is initially wide open, one of the first
  8209. things you should do is specify a password for the *MySQL* `root' user.
  8210. You can do this as follows (note that you specify the password using
  8211. the `PASSWORD()' function):
  8212.  
  8213.      shell> mysql -u root mysql
  8214.      mysql> UPDATE user SET Password=PASSWORD('new_password')
  8215.                 WHERE user='root';
  8216.      mysql> FLUSH PRIVILEGES;
  8217.  
  8218. You can in *MySQL* 3.22 and above use the `SET PASSWORD' statement:
  8219.  
  8220.      shell> mysql -u root mysql
  8221.      mysql> SET PASSWORD FOR root=PASSWORD('new_password');
  8222.  
  8223. Another way to set the password is by using the `mysqladmin' command:
  8224.  
  8225.      shell> mysqladmin -u root password new_password
  8226.  
  8227. Note that if you update the password in the `user' table directly using
  8228. the first method, you must tell the server to reread the grant tables
  8229. (with `FLUSH PRIVILEGES'), because the change will go unnoticed
  8230. otherwise.
  8231.  
  8232. Once the `root' password has been set, thereafter you must supply that
  8233. password when you connect to the server as `root'.
  8234.  
  8235. You may wish to leave the `root' password blank so that you don't need
  8236. to specify it while you perform additional setup or testing. However,
  8237. be sure to set it before using your installation for any real
  8238. production work.
  8239.  
  8240. See the `scripts/mysql_install_db' script to see how it sets up the
  8241. default privileges.  You can use this as a basis to see how to add
  8242. other users.
  8243.  
  8244. If you want the initial privileges to be different than those just
  8245. described above, you can modify `mysql_install_db' before you run it.
  8246.  
  8247. To recreate the grant tables completely, remove all the `*.frm',
  8248. `*.MYI' and `*.MYD' files in the directory containing the `mysql'
  8249. database.  (This is the directory named `mysql' under the database
  8250. directory, which is listed when you run `mysqld --help'.) Then run the
  8251. `mysql_install_db' script, possibly after editing it first to have the
  8252. privileges you want.
  8253.  
  8254. *NOTE:* For *MySQL* versions older than 3.22.10, you should NOT delete
  8255. the `*.frm' files.  If you accidentally do this, you should copy them
  8256. back from your *MySQL* distribution before running `mysql_install_db'.
  8257.  
  8258. Adding new user privileges to MySQL
  8259. ===================================
  8260.  
  8261. You can add users two different ways: by using `GRANT' statements or by
  8262. manipulating the *MySQL* grant tables directly.  The preferred method
  8263. is to use `GRANT' statements, because they are more concise and less
  8264. error-prone.
  8265.  
  8266. The examples below show how to use the `mysql' client to set up new
  8267. users.  These examples assume that privileges are set up according to
  8268. the defaults described in the previous section.  This means that to
  8269. make changes, you must be on the same machine where `mysqld' is
  8270. running, you must connect as the *MySQL* `root' user, and the `root'
  8271. user must have the *insert* privilege for the `mysql' database and the
  8272. *reload* administrative privilege.  Also, if you have changed the
  8273. `root' user password, you must specify it for the `mysql' commands
  8274. below.
  8275.  
  8276. You can add new users by issuing `GRANT' statements:
  8277.  
  8278.      shell> mysql --user=root mysql
  8279.      mysql> GRANT ALL PRIVILEGES ON *.* TO monty@localhost
  8280.                 IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
  8281.      mysql> GRANT ALL PRIVILEGES ON *.* TO monty@"%"
  8282.                 IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
  8283.      mysql> GRANT RELOAD,PROCESS ON *.* TO admin@localhost;
  8284.      mysql> GRANT USAGE ON *.* TO dummy@localhost;
  8285.  
  8286. These `GRANT' statements set up three new users:
  8287.  
  8288. `monty'
  8289.      A full superuser who can connect to the server from anywhere, but
  8290.      who must use a password `'some_pass'' to do so.  Note that we must
  8291.      issue `GRANT' statements for both `monty@localhost' and
  8292.      `monty@"%"'.  If we don't add the entry with `localhost', the
  8293.      anonymous user entry for `localhost' that is created by
  8294.      `mysql_install_db' will take precedence when we connect from the
  8295.      local host, because it has a more specific `Host' field value and
  8296.      thuse comes earlier in the `user' table sort order.
  8297.  
  8298. `admin'
  8299.      A user who can connect from `localhost' without a password and who
  8300.      is granted the *reload* and *process* administrative privileges.
  8301.      This allows the user to execute the `mysqladmin reload',
  8302.      `mysqladmin refresh' and `mysqladmin flush-*' commands, as well as
  8303.      `mysqladmin processlist' .  No database-related privileges are
  8304.      granted.  (They can be granted later by issuing additional `GRANT'
  8305.      statements.)
  8306.  
  8307. `dummy'
  8308.      A user who can connect without a password, but only from the local
  8309.      host.  The global privileges are all set to `'N'' -- the `USAGE'
  8310.      privilege type allows you to create a user with no privileges.  It
  8311.      is assumed that you will grant database-specific privileges later.
  8312.  
  8313. You can also add the same user access information directly by issuing
  8314. `INSERT' statements and then telling the server to reload the grant
  8315. tables:
  8316.  
  8317.      shell> mysql --user=root mysql
  8318.      mysql> INSERT INTO user VALUES('localhost','monty',PASSWORD('some_pass'),
  8319.                      'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y')
  8320.      mysql> INSERT INTO user VALUES('%','monty',PASSWORD('some_pass'),
  8321.                      'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y')
  8322.      mysql> INSERT INTO user SET Host='localhost',User='admin',
  8323.                       Reload_priv='Y', Process_priv='Y';
  8324.      mysql> INSERT INTO user (Host,User,Password)
  8325.                              VALUES('localhost','dummy','');
  8326.      mysql> FLUSH PRIVILEGES;
  8327.  
  8328. Depending on your *MySQL* version, you may have to use a different
  8329. number of `'Y'' values above (versions prior to 3.22.11 had fewer
  8330. privilege columns).  For the `admin' user, the more readable extended
  8331. `INSERT' syntax that is available starting with 3.22.11 is used.
  8332.  
  8333. Note that to set up a superuser, you need only create a `user' table
  8334. entry with the privilege fields set to `'Y''.  No `db' or `host' table
  8335. entries are necessary.
  8336.  
  8337. The privilege columns in the `user' table were not set explicitly in the
  8338. last `INSERT' statement (for the `dummy' user), so those columns are
  8339. assigned the default value of `'N''.  This is the same thing that
  8340. `GRANT USAGE' does.
  8341.  
  8342. The following example adds a user `custom' who can connect from hosts
  8343. `localhost', `server.domain' and `whitehouse.gov'.  He wants to access
  8344. the `bankaccount' database only from `localhost', the `expenses'
  8345. database only from `whitehouse.gov' and the `customer' database from
  8346. all three hosts.  He wants to use the password `stupid' from all three
  8347. hosts.
  8348.  
  8349. To set up this user's privileges using `GRANT' statements, run these
  8350. commands:
  8351.  
  8352.      shell> mysql --user=root mysql
  8353.      mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
  8354.                 ON bankaccount.*
  8355.                 TO custom@localhost
  8356.                 IDENTIFIED BY 'stupid';
  8357.      mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
  8358.                 ON expenses.*
  8359.                 TO custom@whitehouse.gov
  8360.                 IDENTIFIED BY 'stupid';
  8361.      mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
  8362.                 ON customer.*
  8363.                 TO custom@'%'
  8364.                 IDENTIFIED BY 'stupid';
  8365.  
  8366. To set up the user's privileges by modifying the grant tables directly,
  8367. run these commands (note the `FLUSH PRIVILEGES' at the end):
  8368.  
  8369.      shell> mysql --user=root mysql
  8370.      mysql> INSERT INTO user (Host,User,Password)
  8371.             VALUES('localhost','custom',PASSWORD('stupid'));
  8372.      mysql> INSERT INTO user (Host,User,Password)
  8373.             VALUES('server.domain','custom',PASSWORD('stupid'));
  8374.      mysql> INSERT INTO user (Host,User,Password)
  8375.             VALUES('whitehouse.gov','custom',PASSWORD('stupid'));
  8376.      mysql> INSERT INTO db
  8377.             (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,
  8378.              Create_priv,Drop_priv)
  8379.             VALUES
  8380.             ('localhost','bankaccount','custom','Y','Y','Y','Y','Y','Y');
  8381.      mysql> INSERT INTO db
  8382.             (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,
  8383.              Create_priv,Drop_priv)
  8384.             VALUES
  8385.             ('whitehouse.gov','expenses','custom','Y','Y','Y','Y','Y','Y');
  8386.      mysql> INSERT INTO db
  8387.             (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,
  8388.              Create_priv,Drop_priv)
  8389.             VALUES('%','customer','custom','Y','Y','Y','Y','Y','Y');
  8390.      mysql> FLUSH PRIVILEGES;
  8391.  
  8392. The first three `INSERT' statements add `user' table entries that allow
  8393. user `custom' to connect from the various hosts with the given
  8394. password, but grant no permissions to him (all privileges are set to the
  8395. default value of `'N'').  The next three `INSERT' statements add `db'
  8396. table entries that grant privileges to `custom' for the `bankaccount',
  8397. `expenses' and `customer' databases, but only when accessed from the
  8398. proper hosts.  As usual, when the grant tables are modified directly,
  8399. the server must be told to reload them (with `FLUSH PRIVILEGES') so
  8400. that the privilege changes take effect.
  8401.  
  8402. If you want to give a specific user access from any machine in a given
  8403. domain, you can issue a `GRANT' statement like the following:
  8404.  
  8405.      mysql> GRANT ...
  8406.                 ON *.*
  8407.                 TO myusername@"%.mydomainname.com"
  8408.                 IDENTIFIED BY 'mypassword';
  8409.  
  8410. To do the same thing by modifying the grant tables directly, do this:
  8411.  
  8412.      mysql> INSERT INTO user VALUES ('%.mydomainname.com', 'myusername',
  8413.                 PASSWORD('mypassword'),...);
  8414.      mysql> FLUSH PRIVILEGES;
  8415.  
  8416. You can also use `xmysqladmin', `mysql_webadmin' and even `xmysql' to
  8417. insert, change and update values in the grant tables.  You can find
  8418. these utilities in the Contrib directory of the *MySQL* Website
  8419. (http://www.mysql.com/Downloads/Contrib/).
  8420.  
  8421. How to set up passwords
  8422. =======================
  8423.  
  8424. The examples in the preceding sections illustrate an important
  8425. principle: when you store a non-empty password using `INSERT' or
  8426. `UPDATE' statements, you must use the `PASSWORD()' function to encrypt
  8427. it.  This is because the `user' table stores passwords in encrypted
  8428. form, not as plaintext.  If you forget that fact, you are likely to
  8429. attempt to set passwords like this:
  8430.  
  8431.      shell> mysql -u root mysql
  8432.      mysql> INSERT INTO user (Host,User,Password)
  8433.             VALUES('%','jeffrey','biscuit');
  8434.      mysql> FLUSH PRIVILEGES;
  8435.  
  8436. The result is that the plaintext value `'biscuit'' is stored as the
  8437. password in the `user' table.  When the user `jeffrey' attempts to
  8438. connect to the server using this password, the `mysql' client encrypts
  8439. it with `PASSWORD()' and sends the result to the server.  The server
  8440. compares the value in the `user' table (the encrypted value of
  8441. `'biscuit'') to the encrypted password (which is _not_ `'biscuit'').
  8442. The comparison fails and the server rejects the connection:
  8443.  
  8444.      shell> mysql -u jeffrey -pbiscuit test
  8445.      Access denied
  8446.  
  8447. Passwords must be encrypted when they are inserted in the `user' table,
  8448. so the `INSERT' statement should have been specified like this instead:
  8449.  
  8450.      mysql> INSERT INTO user (Host,User,Password)
  8451.             VALUES('%','jeffrey',PASSWORD('biscuit'));
  8452.  
  8453. You must also use the `PASSWORD()' function when you use `SET PASSWORD'
  8454. statements:
  8455.  
  8456.      mysql> SET PASSWORD FOR jeffrey@"%" = PASSWORD('biscuit');
  8457.  
  8458. If you set passwords using the `GRANT ... IDENTIFIED BY' statement or
  8459. the `mysqladmin password' command, the `PASSWORD()' function is
  8460. unnecessary.  They both take care of encrypting the password for you,
  8461. so you would specify a password of `'biscuit'' like this:
  8462.  
  8463.      mysql> GRANT USAGE ON *.* TO jeffrey@"%" IDENTIFIED BY 'biscuit';
  8464.  
  8465. or
  8466.  
  8467.      shell> mysqladmin -u jeffrey password biscuit
  8468.  
  8469. *NOTE:* `PASSWORD()' does not perform password encryption in the same
  8470. way that Unix passwords are encrypted.  You should not assume that if
  8471. your Unix password and your *MySQL* password are the same, that
  8472. `PASSWORD()' will result in the same encrypted value as is stored in the
  8473. Unix password file.  *Note User names::.
  8474.  
  8475. Causes of `Access denied' errors
  8476. ================================
  8477.  
  8478. If you encounter `Access denied' errors when you try to connect to the
  8479. *MySQL* server, the list below indicates some courses of action you can
  8480. take to correct the problem:
  8481.  
  8482.    * After installing *MySQL*, did you run the `mysql_install_db' script
  8483.      to set up the initial grant table contents?  If not, do so.  *Note
  8484.      Default privileges::.  Test the initial privileges by executing
  8485.      this command:
  8486.  
  8487.           shell> mysql -u root test
  8488.  
  8489.      The server should let you connect without error.  You should also
  8490.      make sure you have a file `user.MYD' in the *MySQL* database
  8491.      directory.  Ordinarily, this is `PATH/var/mysql/user.MYD', where
  8492.      `PATH' is the pathname to the *MySQL* installation root.
  8493.  
  8494.    * After a fresh installation, you should connect to the server and
  8495.      set up your users and their access permissions:
  8496.  
  8497.           shell> mysql -u root mysql
  8498.  
  8499.      The server should let you connect because the *MySQL* `root' user
  8500.      has no password initially.  That is also a security risk, so
  8501.      setting the `root' password is something you should do while
  8502.      you're setting up your other *MySQL* users.
  8503.  
  8504.      If you try to connect as `root' and get this error:
  8505.  
  8506.           Access denied for user: '@unknown' to database mysql
  8507.  
  8508.      this means that you don't have an entry in the `user' table with a
  8509.      `User' column value of `'root'' and that `mysqld' cannot resolve
  8510.      the hostname for your client.  In this case, you must restart the
  8511.      server with the `--skip-grant-tables' option and edit your
  8512.      `/etc/hosts' or `\windows\hosts' file to add an entry for your
  8513.      host.
  8514.  
  8515.    * If you updated an existing *MySQL* installation from a pre-3.22.11
  8516.      version to 3.22.11 or later, did you run the
  8517.      `mysql_fix_privilege_tables' script?  If not, do so.  The
  8518.      structure of the grant tables changed with *MySQL* 3.22.11 when
  8519.      the `GRANT' statement became functional.
  8520.  
  8521.    * If you make changes to the grant tables directly (using `INSERT' or
  8522.      `UPDATE' statement) and your changes seem to be ignored, remember
  8523.      that you must issue a `FLUSH PRIVILEGES' statement or execute a
  8524.      `mysqladmin flush-privileges' command to cause the server to
  8525.      reread the tables.  Otherwise your changes have no effect until
  8526.      the next time the server is restarted.  Remember that after you
  8527.      set the `root' password, you won't need to specify it until after
  8528.      you flush the privileges, because the server still won't know
  8529.      you've changed the password yet!
  8530.  
  8531.    * If your privileges seem to have changed in the middle of a
  8532.      session, it may be that a superuser has changed them.  Reloading
  8533.      the grant tables affects new client connections, but it also
  8534.      affects existing connections as indicated in *Note Privilege
  8535.      changes::.
  8536.  
  8537.    * For testing, start the `mysqld' daemon with the
  8538.      `--skip-grant-tables' option.  Then you can change the *MySQL*
  8539.      grant tables and use the `mysqlaccess' script to check whether or
  8540.      not your modifications have the desired effect.  When you are
  8541.      satisfied with your changes, execute `mysqladmin flush-privileges'
  8542.      to tell the `mysqld' server to start using the new grant tables.
  8543.      *Note:* Reloading the grant tables overrides the
  8544.      `--skip-grant-tables' option.  This allows you to tell the server
  8545.      to begin using the grant tables again without bringing it down and
  8546.      restarting it.
  8547.  
  8548.    * If you have access problems with a Perl, PHP, Python or ODBC
  8549.      program, try to connect to the server with `mysql -u user_name
  8550.      db_name' or `mysql -u user_name -pyour_pass db_name'.  If you are
  8551.      able to connect using the `mysql' client, there is a problem with
  8552.      your program and not with the access privileges.  (Notice that
  8553.      there is no space between `-p' and the password; you can also use
  8554.      the `--password=your_pass' syntax to specify the password.)
  8555.  
  8556.    * If you can't get your password to work, remember that you must use
  8557.      the `PASSWORD()' function if you set the password with the
  8558.      `INSERT', `UPDATE' or `SET PASSWORD' statements.  The `PASSWORD()'
  8559.      function is unnecessary if you specify the password using the
  8560.      `GRANT ... INDENTIFIED BY' statement or the `mysqladmin password'
  8561.      command.  *Note Passwords::.
  8562.  
  8563.    * `localhost' is a synonym for your local hostname, and is also the
  8564.      default host to which clients try to connect if you specify no host
  8565.      explicitly.  However, connections to `localhost' do not work if
  8566.      you are running on a system that uses MIT-pthreads (`localhost'
  8567.      connections are made using Unix sockets, which are not supported
  8568.      by MIT-pthreads).  To avoid this problem on such systems, you
  8569.      should use the `--host' option to name the server host explicitly.
  8570.      This will make a TCP/IP connection to the `mysqld' server.  In
  8571.      this case, you must have your real hostname in `user' table
  8572.      entries on the server host.  (This is true even if you are running
  8573.      a client program on the same host as the server.)
  8574.  
  8575.    * If you get an `Access denied' error when trying to connect to the
  8576.      database with `mysql -u user_name db_name', you may have a problem
  8577.      with the `user' table. Check this by executing `mysql -u root
  8578.      mysql' and issuing this SQL statement:
  8579.  
  8580.           mysql> SELECT * FROM user;
  8581.  
  8582.      The result should include an entry with the `Host' and `User'
  8583.      columns matching your computer's hostname and your *MySQL* user
  8584.      name.
  8585.  
  8586.    * The `Access denied' error message will tell you who you are trying
  8587.      to log in as, the host from which you are trying to connect, and
  8588.      whether or not you were using a password. Normally, you should
  8589.      have one entry in the `user' table that exactly matches the
  8590.      hostname and user name that were given in the error message.
  8591.  
  8592.    * If you get the following error when you try to connect from a
  8593.      different host than the one on which the *MySQL* server is
  8594.      running, then there is no row in the `user' table that matches
  8595.      that host:
  8596.  
  8597.           Host ... is not allowed to connect to this MySQL server
  8598.  
  8599.      You can fix this by using the command line tool `mysql' (on the
  8600.      server host!) to add a row to the `user', `db' or `host' table for
  8601.      the user/hostname combination from which you are trying to connect
  8602.      and then execute `mysqladmin flush-privileges'.  If you are not
  8603.      running *MySQL* 3.22 and you don't know the IP number or hostname
  8604.      of the machine from which you are connecting, you should put an
  8605.      entry with `'%'' as the `Host' column value in the `user' table
  8606.      and restart `mysqld' with the `--log' option on the server
  8607.      machine.  After trying to connect from the client machine, the
  8608.      information in the *MySQL* log will indicate how you really did
  8609.      connect.  (Then replace the `'%'' in the `user' table entry with
  8610.      the actual hostname that shows up in the log.  Otherwise, you'll
  8611.      have a system that is insecure.)
  8612.  
  8613.      Another reason for this error on Linux is that you are using a
  8614.      binary *MySQL* version that is compiled with a different glibc
  8615.      version than the one you are using.  In this case you should
  8616.      either upgrade your OS/glibc or download the source *MySQL*
  8617.      version and compile this yourself; A source RPM is normally
  8618.      trivial to compile and install, so normally this isn't a big
  8619.      problem.
  8620.  
  8621.    * If `mysql -u root test' works but `mysql -h your_hostname -u root
  8622.      test' results in `Access denied', then you may not have the
  8623.      correct name for your host in the `user' table.  A common problem
  8624.      here is that the `Host' value in the user table entry specifies an
  8625.      unqualified hostname, but your system's name resolution routines
  8626.      return a fully-qualified domain name (or vice-versa).  For
  8627.      example, if you have an entry with host `'tcx'' in the `user'
  8628.      table, but your DNS tells *MySQL* that your hostname is
  8629.      `'tcx.subnet.se'', the entry will not work. Try adding an entry to
  8630.      the `user' table that contains the IP number of your host as the
  8631.      `Host' column value.  (Alternatively, you could add an entry to the
  8632.      `user' table with a `Host' value that contains a wildcard--for
  8633.      example, `'tcx.%''.  However, use of hostnames ending with `%' is
  8634.      _insecure_ and is _not_ recommended!)
  8635.  
  8636.    * If `mysql -u user_name test' works but `mysql -u user_name
  8637.      other_db_name' doesn't work, you don't have an entry for
  8638.      `other_db_name' listed in the `db' table.
  8639.  
  8640.    * If `mysql -u user_name db_name' works when executed on the server
  8641.      machine, but `mysql -u host_name -u user_name db_name' doesn't
  8642.      work when executed on another client machine, you don't have the
  8643.      client machine listed in the `user' table or the `db' table.
  8644.  
  8645.    * If you can't figure out why you get `Access denied', remove from
  8646.      the `user' table all entries that have `Host' values containing
  8647.      wildcards (entries that contain `%' or `_').  A very common error
  8648.      is to insert a new entry with `Host'=`'%'' and `User'=`'some
  8649.      user'', thinking that this will allow you to specify `localhost'
  8650.      to connect from the same machine.  The reason that this doesn't
  8651.      work is that the default privileges include an entry with
  8652.      `Host'=`'localhost'' and `User'=`'''.  Because that entry has a
  8653.      `Host' value `'localhost'' that is more specific than `'%'', it is
  8654.      used in preference to the new entry when connecting from
  8655.      `localhost'!  The correct procedure is to insert a second entry
  8656.      with `Host'=`'localhost'' and `User'=`'some_user'', or to remove
  8657.      the entry with with `Host'=`'localhost'' and `User'=`'''.
  8658.  
  8659.    * If you get the following error, you may have a problem with the
  8660.      `db' or `host' table:
  8661.  
  8662.           Access to database denied
  8663.  
  8664.      If the entry selected from the `db' table has an empty value in the
  8665.      `Host' column, make sure there are one or more corresponding
  8666.      entries in the `host' table specifying which hosts the `db' table
  8667.      entry applies to.
  8668.  
  8669.      If you get the error when using the SQL commands `SELECT ...  INTO
  8670.      OUTFILE' or `LOAD DATA INFILE', your entry in the `user' table
  8671.      probably doesn't have the *file* privilege enabled.
  8672.  
  8673.    * Remember that client programs will use connection parameters
  8674.      specified in configuration files or environment variables.  *Note
  8675.      Environment variables::.  If a client seems to be sending the
  8676.      wrong default connection parameters when you don't specify them on
  8677.      the command line, check your environment and the `.my.cnf' file in
  8678.      your home directory.  You might also check the system-wide *MySQL*
  8679.      configuration files, though it is far less likely that client
  8680.      connection parameters will be specified there. *Note Option
  8681.      files::.  If you get `Access denied' when you run a client without
  8682.      any options, make sure you haven't specified an old password in
  8683.      any of your option files!  *Note Option files::.
  8684.  
  8685.    * If everything else fails, start the `mysqld' daemon with a
  8686.      debugging option (for example, `--debug=d,general,query'). This
  8687.      will print host and user information about attempted connections,
  8688.      as well as information about each command issued. *Note Debugging
  8689.      server::.
  8690.  
  8691.    * If you have any other problems with the *MySQL* grant tables and
  8692.      feel you must post the problem to the mailing list, always provide
  8693.      a dump of the *MySQL* grant tables. You can dump the tables with
  8694.      the `mysqldump mysql' command. As always, post your problem using
  8695.      the `mysqlbug' script.  *Note Bug reports::.  In some cases you
  8696.      may need to restart `mysqld' with `--skip-grant-tables' to be able
  8697.      to run `mysqldump'.
  8698.  
  8699. MySQL language reference
  8700. ************************
  8701.  
  8702. Literals: how to write strings and numbers
  8703. ==========================================
  8704.  
  8705. Strings
  8706. -------
  8707.  
  8708. A string is a sequence of characters, surrounded by either single quote
  8709. (`'') or double quote (`"') characters (only the single quote if you
  8710. run in ANSI mode).  Examples:
  8711.  
  8712.      'a string'
  8713.      "another string"
  8714.  
  8715. Within a string, certain sequences have special meaning.  Each of these
  8716. sequences begins with a backslash (`\'), known as the _escape
  8717. character_.  *MySQL* recognizes the following escape sequences:
  8718.  
  8719. `\0'
  8720.      An ASCII 0 (`NUL') character.
  8721.  
  8722. `\n'
  8723.      A newline character.
  8724.  
  8725. `\t'
  8726.      A tab character.
  8727.  
  8728. `\r'
  8729.      A carriage return character.
  8730.  
  8731. `\b'
  8732.      A backspace character.
  8733.  
  8734. `\''
  8735.      A single quote (`'') character.
  8736.  
  8737. `\"'
  8738.      A double quote (`"') character.
  8739.  
  8740. `\\'
  8741.      A backslash (`\') character.
  8742.  
  8743. `\%'
  8744.      A `%' character. This is used to search for literal instances of
  8745.      `%' in contexts where `%' would otherwise be interpreted as a
  8746.      wildcard character. *Note String comparison functions::.
  8747.  
  8748. `\_'
  8749.      A `_' character. This is used to search for literal instances of
  8750.      `_' in contexts where `_' would otherwise be interpreted as a
  8751.      wildcard character. *Note String comparison functions::.
  8752.  
  8753. Note that if you use `\%' or `\_' in some string contexts, these will
  8754. return the strings `\%' and `\_' and not `%' and `_'.
  8755.  
  8756. There are several ways to include quotes within a string:
  8757.  
  8758.    * A `'' inside a string quoted with `'' may be written as `'''.
  8759.  
  8760.    * A `"' inside a string quoted with `"' may be written as `""'.
  8761.  
  8762.    * You can precede the quote character with an escape character (`\').
  8763.  
  8764.    * A `'' inside a string quoted with `"' needs no special treatment
  8765.      and need not be doubled or escaped.  In the same way, `"' inside a
  8766.      string quoted with `'' needs no special treatment.
  8767.  
  8768. The `SELECT' statements shown below demonstrate how quoting and
  8769. escaping work:
  8770.  
  8771.      mysql> SELECT 'hello', '"hello"', '""hello""', 'hel''lo', '\'hello';
  8772.      +-------+---------+-----------+--------+--------+
  8773.      | hello | "hello" | ""hello"" | hel'lo | 'hello |
  8774.      +-------+---------+-----------+--------+--------+
  8775.      
  8776.      mysql> SELECT "hello", "'hello'", "''hello''", "hel""lo", "\"hello";
  8777.      +-------+---------+-----------+--------+--------+
  8778.      | hello | 'hello' | ''hello'' | hel"lo | "hello |
  8779.      +-------+---------+-----------+--------+--------+
  8780.      
  8781.      mysql> SELECT "This\nIs\nFour\nlines";
  8782.      +--------------------+
  8783.      | This
  8784.      Is
  8785.      Four
  8786.      lines |
  8787.      +--------------------+
  8788.  
  8789. If you want to insert binary data into a `BLOB' column, the following
  8790. characters must be represented by escape sequences:
  8791. `NUL'
  8792.      ASCII 0. You should represent this by `\0' (a backslash and an
  8793.      ASCII `0' character).
  8794.  
  8795. `\'
  8796.      ASCII 92, backslash.  Represent this by `\\'.
  8797.  
  8798. `''
  8799.      ASCII 39, single quote.  Represent this by `\''.
  8800.  
  8801. `"'
  8802.      ASCII 34, double quote.  Represent this by `\"'.
  8803.  
  8804. If you write C code, you can use the C API function
  8805. `mysql_escape_string()' to escape characters for the `INSERT'
  8806. statement.  *Note C API function overview::.  In Perl, you can use the
  8807. `quote' method of the `DBI' package to convert special characters to
  8808. the proper escape sequences.  *Note Perl `DBI' Class: Perl DBI Class.
  8809.  
  8810. You should use an escape function on any string that might contain any
  8811. of the special characters listed above!
  8812.  
  8813. Numbers
  8814. -------
  8815.  
  8816. Integers are represented as a sequence of digits. Floats use `.' as a
  8817. decimal separator.  Either type of number may be preceded by `-' to
  8818. indicate a negative value.
  8819.  
  8820. Examples of valid integers:
  8821.  
  8822.      1221
  8823.      0
  8824.      -32
  8825.  
  8826. Examples of valid floating-point numbers:
  8827.  
  8828.      294.42
  8829.      -32032.6809e+10
  8830.      148.00
  8831.  
  8832. An integer may be used in a floating-point context; it is interpreted
  8833. as the equivalent floating-point number.
  8834.  
  8835. Hexadecimal values
  8836. ------------------
  8837.  
  8838. *MySQL* supports hexadecimal values.  In number context these acts like
  8839. an integer (64 bit precision). In string context these acts like a
  8840. binary string where each pair of hex digits is converted to a character.
  8841.  
  8842.      mysql> SELECT 0xa+0
  8843.             -> 10
  8844.      mysql> select 0x5061756c;
  8845.             -> Paul
  8846.  
  8847. Hexadecimal strings is often used by ODBC to give values for BLOB
  8848. columns.
  8849.  
  8850. `NULL' values
  8851. -------------
  8852.  
  8853. The `NULL' value means "no data" and is different from values such as
  8854. `0' for numeric types or the empty string for string types.  *Note
  8855. Problems with `NULL': Problems with NULL.
  8856.  
  8857. `NULL' may be represented by `\N' when using the text file import or
  8858. export formats (`LOAD DATA INFILE', `SELECT ... INTO OUTFILE').  *Note
  8859. `LOAD DATA': LOAD DATA.
  8860.  
  8861. Database, table, index, column and alias names
  8862. ----------------------------------------------
  8863.  
  8864. Database, table, index, column and alias names all follow the same
  8865. rules in *MySQL*:
  8866.  
  8867. Note that the rules changed starting with *MySQL* 3.23.6 when we
  8868. introduced quoting of identifiers (database, table and column names)
  8869. with ``' (`"' will also work to quote identifiers if you run in ANSI
  8870. mode).
  8871.  
  8872. *Identifier**max length*                                       *Allowed characters*
  8873. Database    64                                                 Any character that is allowed in a directory name
  8874.                                                                execpt `/'.
  8875. Table       64                                                 Any character that is allowed in file name, except `/'
  8876.                                                                or `.'
  8877. Column      64                                                 All characters
  8878. Alias       255                                                All characters
  8879.  
  8880. Note that in addition to the above, you can't have ASCII(0) or
  8881. ASCII(255) in an identifier.
  8882.  
  8883. Note that if the identifer is a restricted word or contains special
  8884. character you must always quote it with ``' when you use it:
  8885.  
  8886.      SELECT * from `select` where `select`.id > 100;
  8887.  
  8888. In previous versions of *MySQL*, the name rules are as follows:
  8889.  
  8890.    * A name may consist of alphanumeric characters from the current
  8891.      character set and also `_' and `$'. The default character set is
  8892.      ISO-8859-1 Latin1; this may be changed with the
  8893.      `--default-character-set' option to `mysqld'.  *Note Character
  8894.      sets::.
  8895.  
  8896.    * A name may start with any character that is legal in a name.  In
  8897.      particular, a name may start with a number (this differs from many
  8898.      other database systems!).  However, a name cannot consist _only_
  8899.      of numbers.
  8900.  
  8901.    * You cannot use the `.' character in names because it is used to
  8902.      extend the format by which you can refer to columns (see
  8903.      immediately below).
  8904.  
  8905. It is recommended that you do not use names like `1e', because an
  8906. expression like `1e+1' is ambiguous. It may be interpreted as the
  8907. expression `1e + 1' or as the number `1e+1'.
  8908.  
  8909. In *MySQL* you can refer to a column using any of the following forms:
  8910.  
  8911. *Column reference*        *Meaning*
  8912. `col_name'                Column `col_name' from whichever table used in
  8913.                           the query contains a column of that name
  8914. `tbl_name.col_name'       Column `col_name' from table `tbl_name' of the
  8915.                           current database
  8916. `db_name.tbl_name.col_name'Column `col_name' from table `tbl_name' of the
  8917.                           database `db_name'.  This form is available in
  8918.                           *MySQL* 3.22 or later.
  8919. ``column_name`'           A column that is a keyword or contains special
  8920.                           characters.
  8921.  
  8922. You need not specify a `tbl_name' or `db_name.tbl_name' prefix for a
  8923. column reference in a statement unless the reference would be ambiguous.
  8924. For example, suppose tables `t1' and `t2' each contain a column `c',
  8925. and you retrieve `c' in a `SELECT' statement that uses both `t1' and
  8926. `t2'.  In this case, `c' is ambiguous because it is not unique among
  8927. the tables used in the statement, so you must indicate which table you
  8928. mean by writing `t1.c' or `t2.c'.  Similarly, if you are retrieving
  8929. from a table `t' in database `db1' and from a table `t' in database
  8930. `db2', you must refer to columns in those tables as `db1.t.col_name'
  8931. and `db2.t.col_name'.
  8932.  
  8933. The syntax `.tbl_name' means the table `tbl_name' in the current
  8934. database.  This syntax is accepted for ODBC compatibility, because some
  8935. ODBC programs prefix table names with a `.' character.
  8936.  
  8937. Case sensitivity in names
  8938. .........................
  8939.  
  8940. In *MySQL*, databases and tables correspond to directories and files
  8941. within those directories.  Consequently, the case sensitivity of the
  8942. underlying operating system determines the case sensitivity of database
  8943. and table names.  This means database and table names are case
  8944. sensitive in Unix and case insensitive in Win32.
  8945.  
  8946. *Note:* Although database and table names are case insensitive for
  8947. Win32, you should not refer to a given database or table using different
  8948. cases within the same query.  The following query would not work
  8949. because it refers to a table both as `my_table' and as `MY_TABLE':
  8950.  
  8951.      mysql> SELECT * FROM my_table WHERE MY_TABLE.col=1;
  8952.  
  8953. Column names are case insensitive in all cases.
  8954.  
  8955. Aliases on tables are case sensitive.  The following query would not
  8956. work because it refers to the alias both as `a' and as `A':
  8957.  
  8958.      mysql> SELECT col_name FROM tbl_name AS a
  8959.                 WHERE a.col_name = 1 OR A.col_name = 2;
  8960.  
  8961. Aliases on columns are case insensitive.
  8962.  
  8963. User variables
  8964. ==============
  8965.  
  8966. *MySQL* supports thread specific variables with the `@variablename'
  8967. syntax.  A variable name may consist of alphanumeric characters from
  8968. the current character set and also `_', `$', and `.' . The default
  8969. character set is ISO-8859-1 Latin1; this may be changed with the
  8970. `--default-character-set' option to `mysqld'. *Note Character sets::.
  8971.  
  8972. Variables don't have to be initialized.  They contain `NULL' by default
  8973. and can store an integer, real or string value.  All variables for a
  8974. thread are automatically freed when the thread exits.
  8975.  
  8976. You can set a variable with the `SET' syntax:
  8977.  
  8978.      SET @variable= { integer expression | real expression | string expression }
  8979.      [,@variable= ...].
  8980.  
  8981. You can also set a variable in an expression with the `@variable:=expr'
  8982. syntax:
  8983.  
  8984.      select @t1:=(@t2:=1)+@t3:=4,@t1,@t2,@t3;
  8985.      +----------------------+------+------+------+
  8986.      | @t1:=(@t2:=1)+@t3:=4 | @t1  | @t2  | @t3  |
  8987.      +----------------------+------+------+------+
  8988.      |                    5 |    5 |    1 |    4 |
  8989.      +----------------------+------+------+------+
  8990.  
  8991. (We had to use the `:=' syntax here, because `=' was reserved for
  8992. comparisons.)
  8993.  
  8994. User variables may be used where expressions are allowed.  Note that
  8995. this does not currently include use in contexts where a number is
  8996. explicitly required, such as in the `LIMIT' clause of a `SELECT'
  8997. statement, or the `IGNORE number LINES' clause of a `LOAD DATA'
  8998. statement.
  8999.  
  9000. *NOTE:*  In a `SELECT' statement, each expression is only evaluated
  9001. when it's sent to the client.  This means that one can't in the
  9002. `HAVING', `GROUP BY' or `ORDER BY' clause refer to an expression that
  9003. involves variables that are set in the `SELECT' part.  For example, the
  9004. following statement will NOT work as expected:
  9005.  
  9006.      SELECT (@aa:=id) AS a, (@aa+3) AS b FROM table_name HAVING b=5;
  9007.  
  9008. The reason is that `@aa' will not contain the value of the current row,
  9009. but the value of `id' for the previous accepted row.
  9010.  
  9011. Column types
  9012. ============
  9013.  
  9014. *MySQL* supports a number of column types, which may be grouped into
  9015. three categories: numeric types, date and time types, and string
  9016. (character) types.  This section first gives an overview of the types
  9017. available and summarizes the storage requirements for each column type,
  9018. then provides a more detailed description of the properties of the
  9019. types in each category.  The overview is intentionally brief.  The more
  9020. detailed descriptions should be consulted for additional information
  9021. about particular column types, such as the allowable formats in which
  9022. you can specify values.
  9023.  
  9024. The column types supported by *MySQL* are listed below.  The following
  9025. code letters are used in the descriptions:
  9026.  
  9027. `M'
  9028.      Indicates the maximum display size.  The maximum legal display
  9029.      size is 255.
  9030.  
  9031. `D'
  9032.      Applies to floating-point types and indicates the number of digits
  9033.      following the decimal point.  The maximum possible value is 30, but
  9034.      should be no greater than `M'-2.
  9035.  
  9036. Square brackets (`[' and `]') indicate parts of type specifiers that
  9037. are optional.
  9038.  
  9039. Note that if you specify `ZEROFILL' for a column, *MySQL* will
  9040. automatically add the `UNSIGNED' attribute to the column.
  9041.  
  9042. `TINYINT[(M)] [UNSIGNED] [ZEROFILL]'
  9043.      A very small integer. The signed range is `-128' to `127'. The
  9044.      unsigned range is `0' to `255'.
  9045.  
  9046. `SMALLINT[(M)] [UNSIGNED] [ZEROFILL]'
  9047.      A small integer. The signed range is `-32768' to `32767'. The
  9048.      unsigned range is `0' to `65535'.
  9049.  
  9050. `MEDIUMINT[(M)] [UNSIGNED] [ZEROFILL]'
  9051.      A medium-size integer. The signed range is `-8388608' to
  9052.      `8388607'. The unsigned range is `0' to `16777215'.
  9053.  
  9054. `INT[(M)] [UNSIGNED] [ZEROFILL]'
  9055.      A normal-size integer. The signed range is `-2147483648' to
  9056.      `2147483647'.  The unsigned range is `0' to `4294967295'.
  9057.  
  9058. `INTEGER[(M)] [UNSIGNED] [ZEROFILL]'
  9059.      This is a synonym for `INT'.
  9060.  
  9061. `BIGINT[(M)] [UNSIGNED] [ZEROFILL]'
  9062.      A large integer. The signed range is `-9223372036854775808' to
  9063.      `9223372036854775807'. The unsigned range is `0' to
  9064.      `18446744073709551615'.  Note that all arithmetic is done using
  9065.      signed `BIGINT' or `DOUBLE' values, so you shouldn't use unsigned
  9066.      big integers larger than `9223372036854775807' (63 bits) except
  9067.      with bit functions!  Note that `-', `+' and `*' will use `BIGINT'
  9068.      arithmetic when both arguments are `INTEGER' values!  This means
  9069.      that if you multiply two big integers (or results from functions
  9070.      that return integers) you may get unexpected results if the result
  9071.      is larger than `9223372036854775807'.
  9072.  
  9073. `FLOAT(precision) [ZEROFILL]'
  9074.      A floating-point number. Cannot be unsigned.  `precision' can be
  9075.      `<=24' for a single precision floating point number and between 25
  9076.      and 53 for a double precision floating point number.  these types
  9077.      are like the `FLOAT' and `DOUBLE' types described immediately
  9078.      below. `FLOAT(X)' have the same ranges as the corresponding
  9079.      `FLOAT' and `DOUBLE' types, but the display size and number of
  9080.      decimals is undefined.
  9081.  
  9082.      In *MySQL* 3.23, this is a true floating point value.  In earlier
  9083.      *MySQL* versions, `FLOAT(precision)' always has 2 decimals.
  9084.  
  9085.      This syntax is provided for ODBC compatibility.
  9086.  
  9087. `FLOAT[(M,D)] [ZEROFILL]'
  9088.      A small (single-precision) floating-point number. Cannot be
  9089.      unsigned.  Allowable values are `-3.402823466E+38' to
  9090.      `-1.175494351E-38', `0' and `1.175494351E-38' to
  9091.      `3.402823466E+38'.  The M is the display width and D is the number
  9092.      of decimals.  `FLOAT' without an argument or with an argument of
  9093.      <= 24 stands for a single-precision floating point number.
  9094.  
  9095. `DOUBLE[(M,D)] [ZEROFILL]'
  9096.      A normal-size (double-precision) floating-point number. Cannot be
  9097.      unsigned. Allowable values are `-1.7976931348623157E+308' to
  9098.      `-2.2250738585072014E-308', `0' and `2.2250738585072014E-308' to
  9099.      `1.7976931348623157E+308'.  The M is the display width and D is
  9100.      the number of decimals.  `DOUBLE' without an argument or
  9101.      `FLOAT(X)' where 25 <= X <= 53 stands for a double-precision
  9102.      floating point number.
  9103.  
  9104. `DOUBLE PRECISION[(M,D)] [ZEROFILL]'
  9105. `REAL[(M,D)] [ZEROFILL]'
  9106.      These are synonyms for `DOUBLE'.
  9107.  
  9108. `DECIMAL[(M[,D])] [ZEROFILL]'
  9109.      An unpacked floating-point number.  Cannot be unsigned.  Behaves
  9110.      like a `CHAR' column: "unpacked" means the number is stored as a
  9111.      string, using one character for each digit of the value.  The
  9112.      decimal point, and, for negative numbers, the `-' sign is not
  9113.      counted in M.  If `D' is 0, values will have no decimal point or
  9114.      fractional part.  The maximum range of `DECIMAL' values is the
  9115.      same as for `DOUBLE', but the actual range for a given `DECIMAL'
  9116.      column may be constrained by the choice of `M' and `D'.
  9117.  
  9118.      If `D' is left out it's set to 0. If `M' is left out it's set to
  9119.      10.
  9120.  
  9121.      Note that in *MySQL* 3.22 the `M' argument includes the sign and
  9122.      the decimal point.
  9123.  
  9124. `NUMERIC(M,D) [ZEROFILL]'
  9125.      This is a synonym for `DECIMAL'.
  9126.  
  9127. `DATE'
  9128.      A date.  The supported range is `'1000-01-01'' to `'9999-12-31''.
  9129.      *MySQL* displays `DATE' values in `'YYYY-MM-DD'' format, but
  9130.      allows you to assign values to `DATE' columns using either strings
  9131.      or numbers.
  9132.  
  9133. `DATETIME'
  9134.      A date and time combination.  The supported range is `'1000-01-01
  9135.      00:00:00'' to `'9999-12-31 23:59:59''.  *MySQL* displays
  9136.      `DATETIME' values in `'YYYY-MM-DD HH:MM:SS'' format, but allows you
  9137.      to assign values to `DATETIME' columns using either strings or
  9138.      numbers.
  9139.  
  9140. `TIMESTAMP[(M)]'
  9141.      A timestamp.  The range is `'1970-01-01 00:00:00'' to sometime in
  9142.      the year `2037'.  *MySQL* displays `TIMESTAMP' values in
  9143.      `YYYYMMDDHHMMSS', `YYMMDDHHMMSS', `YYYYMMDD' or `YYMMDD' format,
  9144.      depending on whether `M' is `14' (or missing), `12', `8' or `6',
  9145.      but allows you to assign values to `TIMESTAMP' columns using
  9146.      either strings or numbers.  A `TIMESTAMP' column is useful for
  9147.      recording the date and time of an `INSERT' or `UPDATE' operation
  9148.      because it is automatically set to the date and time of the most
  9149.      recent operation if you don't give it a value yourself.  You can
  9150.      also set it to the current date and time by assigning it a `NULL'
  9151.      value.  *Note Date and time types::.
  9152.  
  9153. `TIME'
  9154.      A time.  The range is `'-838:59:59'' to `'838:59:59''.  *MySQL*
  9155.      displays `TIME' values in `'HH:MM:SS'' format, but allows you to
  9156.      assign values to `TIME' columns using either strings or numbers.
  9157.  
  9158. `YEAR[(2|4)]'
  9159.      A year in 2- or 4- digit formats (default is 4-digit).  The
  9160.      allowable values are `1901' to `2155', and `0000' in the 4 year
  9161.      format and 1970-2069 if you use the 2 digit format (70-69).
  9162.      *MySQL* displays `YEAR' values in `YYYY' format, but allows you to
  9163.      assign values to `YEAR' columns using either strings or numbers.
  9164.      (The `YEAR' type is new in *MySQL* 3.22.)
  9165.  
  9166. `[NATIONAL] CHAR(M) [BINARY]'
  9167.      A fixed-length string that is always right-padded with spaces to
  9168.      the specified length when stored. The range of `M' is 1 to 255
  9169.      characters.  Trailing spaces are removed when the value is
  9170.      retrieved. `CHAR' values are sorted and compared in
  9171.      case-insensitive fashion according to the default character set
  9172.      unless the `BINARY' keyword is given.
  9173.  
  9174.      `NATIONAL CHAR' (short form `NCHAR') is the ANSI SQL way to define
  9175.      that a CHAR column should use the default CHARACTER set.  This is
  9176.      default in `MySQL'.
  9177.  
  9178.      `CHAR' is a shorthand for `CHARACTER'.
  9179.  
  9180.      *MySQL* allows you to create a column of type `CHAR(0)'. This is
  9181.      mainly useful when you have to be compliant with some old
  9182.      applications that depend on the existence of a column but that do
  9183.      not actually use the value.  This is also quite nice when you need
  9184.      a column that only can take 2 values: A `CHAR(0)', that is not
  9185.      defined as `NOT NULL', will only occupy one bit and can only take
  9186.      2 values: `NULL' or `""'.
  9187.  
  9188. `[NATIONAL] VARCHAR(M) [BINARY]'
  9189.      A variable-length string.  Note: Trailing spaces are removed when
  9190.      the value is stored (this differs from the ANSI SQL
  9191.      specification). The range of `M' is 1 to 255 characters.
  9192.      `VARCHAR' values are sorted and compared in case-insensitive
  9193.      fashion unless the `BINARY' keyword is given. *Note Silent column
  9194.      changes::.
  9195.  
  9196.      `VARCHAR' is a shorthand for `CHARACTER VARYING'.
  9197.  
  9198. `TINYBLOB'
  9199. `TINYTEXT'
  9200.      A `BLOB' or `TEXT' column with a maximum length of 255 (2^8 - 1)
  9201.      characters. *Note Silent column changes::.
  9202.  
  9203. `BLOB'
  9204. `TEXT'
  9205.      A `BLOB' or `TEXT' column with a maximum length of 65535 (2^16 - 1)
  9206.      characters. *Note Silent column changes::.
  9207.  
  9208. `MEDIUMBLOB'
  9209. `MEDIUMTEXT'
  9210.      A `BLOB' or `TEXT' column with a maximum length of 16777215 (2^24
  9211.      - 1) characters. *Note Silent column changes::.
  9212.  
  9213. `LONGBLOB'
  9214. `LONGTEXT'
  9215.      A `BLOB' or `TEXT' column with a maximum length of 4294967295
  9216.      (2^32 - 1) characters. *Note Silent column changes::.
  9217.  
  9218. `ENUM('value1','value2',...)'
  9219.      An enumeration.  A string object that can have only one value,
  9220.      chosen from the list of values `'value1'', `'value2'', `...', or
  9221.      `NULL'.  An `ENUM' can have a maximum of 65535 distinct values.
  9222.  
  9223. `SET('value1','value2',...)'
  9224.      A set.  A string object that can have zero or more values, each of
  9225.      which must be chosen from the list of values `'value1'',
  9226.      `'value2'', `...' A `SET' can have a maximum of 64 members.
  9227.  
  9228. Column type storage requirements
  9229. --------------------------------
  9230.  
  9231. The storage requirements for each of the column types supported by
  9232. *MySQL* are listed below by category.
  9233.  
  9234. Numeric types
  9235. -------------
  9236.  
  9237. *Column type*             *Storage required*
  9238. `TINYINT'                 1 byte
  9239. `SMALLINT'                2 bytes
  9240. `MEDIUMINT'               3 bytes
  9241. `INT'                     4 bytes
  9242. `INTEGER'                 4 bytes
  9243. `BIGINT'                  8 bytes
  9244. `FLOAT(X)'                4 if X <= 24 or 8 if 25 <= X <= 53
  9245. `FLOAT'                   4 bytes
  9246. `DOUBLE'                  8 bytes
  9247. `DOUBLE PRECISION'        8 bytes
  9248. `REAL'                    8 bytes
  9249. `DECIMAL(M,D)'            `M' bytes (`D'+2, if `M < D')
  9250. `NUMERIC(M,D)'            `M' bytes (`D'+2, if `M < D')
  9251.  
  9252. Date and time types
  9253. -------------------
  9254.  
  9255. *Column type*             *Storage required*
  9256. `DATE'                    3 bytes
  9257. `DATETIME'                8 bytes
  9258. `TIMESTAMP'               4 bytes
  9259. `TIME'                    3 bytes
  9260. `YEAR'                    1 byte
  9261.  
  9262. String types
  9263. ------------
  9264.  
  9265. *Column type*             *Storage required*
  9266. `CHAR(M)'                 `M' bytes, `1 <= M <= 255'
  9267. `VARCHAR(M)'              `L'+1 bytes, where `L <= M' and `1 <= M <= 255'
  9268. `TINYBLOB', `TINYTEXT'    `L'+1 bytes, where `L' < 2^8
  9269. `BLOB', `TEXT'            `L'+2 bytes, where `L' < 2^16
  9270. `MEDIUMBLOB',             `L'+3 bytes, where `L' < 2^24
  9271. `MEDIUMTEXT'              
  9272. `LONGBLOB', `LONGTEXT'    `L'+4 bytes, where `L' < 2^32
  9273. `ENUM('value1','value2',...)'1 or 2 bytes, depending on the number of
  9274.                           enumeration values (65535 values maximum)
  9275. `SET('value1','value2',...)'1, 2, 3, 4 or 8 bytes, depending on the number
  9276.                           of set members (64 members maximum)
  9277.  
  9278. `VARCHAR' and the `BLOB' and `TEXT' types are variable-length types,
  9279. for which the storage requirements depend on the actual length of
  9280. column values (represented by `L' in the preceding table), rather than
  9281. on the type's maximum possible size.  For example, a `VARCHAR(10)'
  9282. column can hold a string with a maximum length of 10 characters.  The
  9283. actual storage required is the length of the string (`L'), plus 1 byte
  9284. to record the length of the string.  For the string `'abcd'', `L' is 4
  9285. and the storage requirement is 5 bytes.
  9286.  
  9287. The `BLOB' and `TEXT' types require 1, 2, 3 or 4 bytes to record the
  9288. length of the column value, depending on the maximum possible length of
  9289. the type.
  9290.  
  9291. If a table includes any variable-length column types, the record format
  9292. will also be variable-length.  Note that when a table is created,
  9293. *MySQL* may under certain conditions change a column from a
  9294. variable-length type to a fixed-length type, or vice-versa.  *Note
  9295. Silent column changes::.
  9296.  
  9297. The size of an `ENUM' object is determined by the number of different
  9298. enumeration values.  1 byte is used for enumerations with up to 255
  9299. possible values.  2 bytes are used for enumerations with up to 65535
  9300. values.
  9301.  
  9302. The size of a `SET' object is determined by the number of different set
  9303. members.  If the set size is `N', the object occupies `(N+7)/8' bytes,
  9304. rounded up to 1, 2, 3, 4 or 8 bytes.  A `SET' can have a maximum of 64
  9305. members.
  9306.  
  9307. Numeric types
  9308. -------------
  9309.  
  9310. *MySQL* supports all of the ANSI/ISO SQL92 numeric types.  These types
  9311. include the exact numeric data types (`NUMERIC', `DECIMAL', `INTEGER',
  9312. and `SMALLINT'), as well as the approximate numeric data types
  9313. (`FLOAT', `REAL', and `DOUBLE PRECISION'). The keyword `INT' is a
  9314. synonym for `INTEGER', and the keyword `DEC' is a synonym for `DECIMAL'.
  9315.  
  9316. The `NUMERIC' and `DECIMAL' types are implemented as the same type by
  9317. *MySQL*, as permitted by the SQL92 standard.  They are used for values
  9318. for which it is important to preserve exact precision, for example with
  9319. monetary data.  When declaring a column of one of these types the
  9320. precision and scale can be (and usually is) specified; for example:
  9321.  
  9322.          salary DECIMAL(9,2)
  9323.  
  9324. In this example, `9' (`precision') represents the number of significant
  9325. decimal digits which will be stored for values, and `2' (`scale')
  9326. represents the number of digits which will be stored following the
  9327. decimal point.  In this case, therefore, the range of values which can
  9328. be stored in the `salary' column is from `-9999999.99' to `9999999.99'.
  9329. In ANSI/ISO SQL92, the syntax `DECIMAL(p)' is equivalent to
  9330. `DECIMAL(p,0)'.  Similarly, the syntax `DECIMAL' is equivalent to
  9331. `DECIMAL(p,0)', where the implementation is allowed to decide the value
  9332. of `p'.  *MySQL* does not currently support either of these variant
  9333. forms of the `DECIMAL'/`NUMERIC' data types.  This is not generally a
  9334. serious problem, as the principal benefits of these types derive from
  9335. the ability to control both precision and scale explicitly.
  9336.  
  9337. `DECIMAL' and `NUMERIC' values are stored as strings, rather than as
  9338. binary floating point numbers, in order to preserve the decimal
  9339. precision of those values.  One character is used for each digit of the
  9340. value, the decimal point (if `scale' > 0) and the `-' sign (for
  9341. negative numbers).  If `scale' is 0, `DECIMAL' and `NUMERIC' values
  9342. contain no decimal point or fractional part.
  9343.  
  9344. The maximum range of `DECIMAL' and `NUMERIC' values is the same as for
  9345. `DOUBLE', but the actual range for a given `DECIMAL' or `NUMERIC'
  9346. column can be constrained by the `precision' or `scale' for a given
  9347. column.  When such a column is assigned a value with more digits
  9348. following the decimal point than are allowed by the specified `scale',
  9349. the value is rounded to that `scale'.  When a `DECIMAL' or `NUMERIC'
  9350. column is assigned a value whose magnitude exceeds the range implied by
  9351. the specified (or defaulted) `precision' and `scale', *MySQL* stores
  9352. the value representing the corresponding end point of that range.
  9353.  
  9354. As an extension to the ANSI/ISO SQL92 standard, *MySQL* also supports
  9355. the integral types `TINYINT', `MEDIUMINT', and `BIGINT' as listed in
  9356. the tables above.  Another extension is supported by *MySQL* for
  9357. optionally specifying the display width of an integral value in
  9358. parentheses following the base keyword for the type (for example,
  9359. `INT(4)').  This optional width specification is used to left-pad the
  9360. display of values whose width is less than the width specified for the
  9361. column, but does not constrain the range of values which can be stored
  9362. in the column, nor the number of digits which will be displayed for
  9363. values whose width exceeds that specified for the column.  When used in
  9364. conjunction with the optional extension attribute `ZEROFILL' the
  9365. default padding of spaces is replaced with zeroes.  For example, for a
  9366. column declared as `INT(5) ZEROFILL', a value of `4' is retrieved as
  9367. `00004'.  Note that if you store larger values than the display width
  9368. in an integral column, you may experience problems when *MySQL*
  9369. generates temporary tables for some complicated joins as in these case
  9370. *MySQL* trust that the data did fit into the original column width.
  9371.  
  9372. All integral types can have an optional (non-standard) attribute
  9373. `UNSIGNED'.  Unsigned values can be used when you want to allow only
  9374. positive numbers in a column and you need a little bigger numeric range
  9375. for the column.
  9376.  
  9377. The `FLOAT' type is used to represent approximate numeric data types.
  9378. The ANSI/ISO SQL92 standard allows an optional specification of the
  9379. precision (but not the range of the exponent) in bits following the
  9380. keyword `FLOAT' in parentheses.  The *MySQL* implementation also
  9381. supports this optional precision specification.  When the keyword
  9382. `FLOAT' is used for a column type without a precision specification,
  9383. *MySQL* uses four bytes to store the values.  A variant syntax is also
  9384. supported, with two numbers given in parentheses following the `FLOAT'
  9385. keyword.  With this option, the first number continues to represent the
  9386. storage requirements for the value in bytes, and the second number
  9387. specifies the number of digits to be stored and displayed following the
  9388. decimal point (as with `DECIMAL' and `NUMERIC').  When *MySQL* is asked
  9389. to store a number for such a column with more decimal digits following
  9390. the decimal point than specified for the column, the value is rounded
  9391. to eliminate the extra digits when the value is stored.
  9392.  
  9393. The `REAL' and `DOUBLE PRECISION' types do not accept precision
  9394. specifications.  As an extension to the ANSI/ISO SQL92 standard,
  9395. *MySQL* recognizes `DOUBLE' as a synonym for the `DOUBLE PRECISION'
  9396. type.  In contrast with the standard's requirement that the precision
  9397. for `REAL' be smaller than that used for `DOUBLE PRECISION', *MySQL*
  9398. implements both as 8-byte double-precision floating point values (when
  9399. running in non-"Ansi mode").  For maximum portability, code requiring
  9400. storage of approximate numeric data values should use `FLOAT' or
  9401. `DOUBLE PRECISION' with no specification of precision or number of
  9402. decimal points.
  9403.  
  9404. When asked to store a value in a numeric column that is outside the
  9405. column type's allowable range, *MySQL* clips the value to the
  9406. appropriate endpoint of the range and stores the resulting value
  9407. instead.
  9408.  
  9409. For example, the range of an `INT' column is `-2147483648' to
  9410. `2147483647'.  If you try to insert `-9999999999' into an `INT' column,
  9411. the value is clipped to the lower endpoint of the range, and
  9412. `-2147483648' is stored instead. Similarly, if you try to insert
  9413. `9999999999', `2147483647' is stored instead.
  9414.  
  9415. If the `INT' column is `UNSIGNED', the size of the column's range is
  9416. the same but its endpoints shift up to `0' and `4294967295'.  If you
  9417. try to store `-9999999999' and `9999999999', the values stored in the
  9418. column become `0' and `4294967296'.
  9419.  
  9420. Conversions that occur due to clipping are reported as "warnings" for
  9421. `ALTER TABLE', `LOAD DATA INFILE', `UPDATE' and multi-row `INSERT'
  9422. statements.
  9423.  
  9424. Date and time types
  9425. -------------------
  9426.  
  9427. The date and time types are `DATETIME', `DATE', `TIMESTAMP', `TIME' and
  9428. `YEAR'.  Each of these has a range of legal values, as well as a "zero"
  9429. value that is used when you specify a really illegal value.  Note that
  9430. *MySQL* allows you to store certain 'not strictly' legal date values,
  9431. for example `1999-11-31'.  The reason for this is that we think it's
  9432. the responsibility of the application to handle date checking, not the
  9433. SQL servers.  To make the date checking 'fast', *MySQL* only checks
  9434. that the month is in the range of 0-12 and the day is in the range of
  9435. 0-31. The above ranges are defined this way because *MySQL* allows you
  9436. to store, in a `DATE' or `DATETIME' column, dates where the day or
  9437. month-day are zero.  This is extremely useful for applications that
  9438. need to store a birth-date for which you don't know the exact date. In
  9439. this case you simply store the date like `1999-00-00' or `1999-01-00'.
  9440. (You can of course not expect to get a correct value from functions like
  9441. `DATE_SUB()' or `DATE_ADD' for dates like these).
  9442.  
  9443. Here are some general considerations to keep in mind when working with
  9444. date and time types:
  9445.  
  9446.    * *MySQL* retrieves values for a given date or time type in a
  9447.      standard format, but it attempts to interpret a variety of formats
  9448.      for values that you supply (e.g., when you specify a value to be
  9449.      assigned to or compared to a date or time type).  Nevertheless,
  9450.      only the formats described in the following sections are
  9451.      supported.  It is expected that you will supply legal values, and
  9452.      unpredictable results may occur if you use values in other formats.
  9453.  
  9454.    * Although *MySQL* tries to interpret values in several formats, it
  9455.      always expects the year part of date values to be leftmost.  Dates
  9456.      must be given in year-month-day order (e.g., `'98-09-04''), rather
  9457.      than in the month-day-year or day-month-year orders commonly used
  9458.      elsewhere (e.g., `'09-04-98'', `'04-09-98'').
  9459.  
  9460.    * *MySQL* automatically converts a date or time type value to a
  9461.      number if the value is used in a numeric context, and vice versa.
  9462.  
  9463.    * When *MySQL* encounters a value for a date or time type that is
  9464.      out of range or otherwise illegal for the type (see start of this
  9465.      section), it converts the value to the "zero" value for that type.
  9466.      (The exception is that out-of-range `TIME' values are clipped to
  9467.      the appropriate endpoint of the `TIME' range.)  The table below
  9468.      shows the format of the "zero" value for each type:
  9469.  
  9470.      *Column type*        *"Zero" value*
  9471.      `DATETIME'           `'0000-00-00 00:00:00''
  9472.      `DATE'               `'0000-00-00''
  9473.      `TIMESTAMP'          `00000000000000' (length depends on display
  9474.                           size)
  9475.      `TIME'               `'00:00:00''
  9476.      `YEAR'               `0000'
  9477.  
  9478.    * The "zero" values are special, but you can store or refer to them
  9479.      explicitly using the values shown in the table.  You can also do
  9480.      this using the values `'0'' or `0', which are easier to write.
  9481.  
  9482.    * "Zero" date or time values used through *MyODBC* are converted
  9483.      automatically to `NULL' in *MyODBC* 2.50.12 and above, because
  9484.      ODBC can't handle such values.
  9485.  
  9486. Y2K issues and date types
  9487. .........................
  9488.  
  9489. *MySQL* itself is Y2K-safe (*note Year 2000 compliance::), but input
  9490. values presented to *MySQL* may not be.  Any input containing 2-digit
  9491. year values is ambiguous, because the century is unknown.  Such values
  9492. must be interpreted into 4-digit form because *MySQL* stores years
  9493. internally using four digits.
  9494.  
  9495. For `DATETIME', `DATE', `TIMESTAMP' and `YEAR' types, *MySQL*
  9496. interprets dates with ambiguous year values using the following rules:
  9497.  
  9498.    * Year values in the range `00-69' are converted to `2000-2069'.
  9499.  
  9500.    * Year values in the range `70-99' are converted to `1970-1999'.
  9501.  
  9502. Remember that these rules provide only reasonable guesses as to what
  9503. your data mean.  If the heuristics used by *MySQL* don't produce the
  9504. correct values, you should provide unambiguous input containing 4-digit
  9505. year values.
  9506.  
  9507. `ORDER BY' will sort 2 digit `YEAR/DATE/DATETIME' types properly.
  9508.  
  9509. Note also that some functions like `MIN()' and `MAX()' will convert a
  9510. `TIMESTAMP/DATE' to a number. This means that a timestamp with a 2
  9511. digit year will not work properly with these functions.  The fix in this
  9512. case is to convert the `TIMESTAMP/DATE' to 4 digit year format or use
  9513. something like `MIN(DATE_ADD(timestamp,INTERVAL 0 DAYS))'.
  9514.  
  9515. The `DATETIME', `DATE' and `TIMESTAMP' types
  9516. ............................................
  9517.  
  9518. The `DATETIME', `DATE' and `TIMESTAMP' types are related.  This section
  9519. describes their characteristics, how they are similar and how they
  9520. differ.
  9521.  
  9522. The `DATETIME' type is used when you need values that contain both date
  9523. and time information.  *MySQL* retrieves and displays `DATETIME' values
  9524. in `'YYYY-MM-DD HH:MM:SS'' format.  The supported range is `'1000-01-01
  9525. 00:00:00'' to `'9999-12-31 23:59:59''.  ("Supported" means that
  9526. although earlier values might work, there is no guarantee that they
  9527. will.)
  9528.  
  9529. The `DATE' type is used when you need only a date value, without a time
  9530. part.  *MySQL* retrieves and displays `DATE' values in `'YYYY-MM-DD''
  9531. format.  The supported range is `'1000-01-01'' to `'9999-12-31''.
  9532.  
  9533. The `TIMESTAMP' column type provides a type that you can use to
  9534. automatically mark `INSERT' or `UPDATE' operations with the current
  9535. date and time.  If you have multiple `TIMESTAMP' columns, only the first
  9536. one is updated automatically.
  9537.  
  9538. Automatic updating of the first `TIMESTAMP' column occurs under any of
  9539. the following conditions:
  9540.  
  9541.    * The column is not specified explicitly in an `INSERT' or `LOAD
  9542.      DATA INFILE' statement.
  9543.  
  9544.    * The column is not specified explicitly in an `UPDATE' statement
  9545.      and some other column changes value.  (Note that an `UPDATE' that
  9546.      sets a column to the value it already has will not cause the
  9547.      `TIMESTAMP' column to be updated, because if you set a column to
  9548.      its current value, *MySQL* ignores the update for efficiency.)
  9549.  
  9550.    * You explicitly set the `TIMESTAMP' column to `NULL'.
  9551.  
  9552. `TIMESTAMP' columns other than the first may also be set to the current
  9553. date and time.  Just set the column to `NULL', or to `NOW()'.
  9554.  
  9555. You can set any `TIMESTAMP' column to a value different than the current
  9556. date and time by setting it explicitly to the desired value.  This is
  9557. true even for the first `TIMESTAMP' column.  You can use this property
  9558. if, for example, you want a `TIMESTAMP' to be set to the current date
  9559. and time when you create a row, but not to be changed whenever the row
  9560. is updated later:
  9561.  
  9562.    * Let *MySQL* set the column when the row is created.  This will
  9563.      initialize it to the current date and time.
  9564.  
  9565.    * When you perform subsequent updates to other columns in the row,
  9566.      set the `TIMESTAMP' column explicitly to its current value.
  9567.  
  9568. On the other hand, you may find it just as easy to use a `DATETIME'
  9569. column that you initialize to `NOW()' when the row is created and leave
  9570. alone for subsequent updates.
  9571.  
  9572. `TIMESTAMP' values may range from the beginning of 1970 to sometime in
  9573. the year 2037, with a resolution of one second.  Values are displayed as
  9574. numbers.
  9575.  
  9576. The format in which *MySQL* retrieves and displays `TIMESTAMP' values
  9577. depends on the display size, as illustrated by the table below.  The
  9578. `full' `TIMESTAMP' format is 14 digits, but `TIMESTAMP' columns may be
  9579. created with shorter display sizes:
  9580.  
  9581. *Column type*          *Display format*
  9582. `TIMESTAMP(14)'        `YYYYMMDDHHMMSS'
  9583. `TIMESTAMP(12)'        `YYMMDDHHMMSS'
  9584. `TIMESTAMP(10)'        `YYMMDDHHMM'
  9585. `TIMESTAMP(8)'         `YYYYMMDD'
  9586. `TIMESTAMP(6)'         `YYMMDD'
  9587. `TIMESTAMP(4)'         `YYMM'
  9588. `TIMESTAMP(2)'         `YY'
  9589.  
  9590. All `TIMESTAMP' columns have the same storage size, regardless of
  9591. display size.  The most common display sizes are 6, 8, 12, and 14.  You
  9592. can specify an arbitrary display size at table creation time, but
  9593. values of 0 or greater than 14 are coerced to 14.  Odd-valued sizes in
  9594. the range from 1 to 13 are coerced to the next higher even number.
  9595.  
  9596. You can specify `DATETIME', `DATE' and `TIMESTAMP' values using any of
  9597. a common set of formats:
  9598.  
  9599.    * As a string in either `'YYYY-MM-DD HH:MM:SS'' or `'YY-MM-DD
  9600.      HH:MM:SS'' format.  A "relaxed" syntax is allowed--any punctuation
  9601.      character may be used as the delimiter between date parts or time
  9602.      parts.  For example, `'98-12-31 11:30:45'', `'98.12.31 11+30+45'',
  9603.      `'98/12/31 11*30*45'' and `'98@12@31 11^30^45'' are equivalent.
  9604.  
  9605.    * As a string in either `'YYYY-MM-DD'' or `'YY-MM-DD'' format.  A
  9606.      "relaxed" syntax is allowed here, too.  For example, `'98-12-31'',
  9607.      `'98.12.31'', `'98/12/31'' and `'98@12@31'' are equivalent.
  9608.  
  9609.    * As a string with no delimiters in either `'YYYYMMDDHHMMSS'' or
  9610.      `'YYMMDDHHMMSS'' format, provided that the string makes sense as a
  9611.      date.  For example, `'19970523091528'' and `'970523091528'' are
  9612.      interpreted as `'1997-05-23 09:15:28'', but `'971122129015'' is
  9613.      illegal (it has a nonsensical minute part) and becomes `'0000-00-00
  9614.      00:00:00''.
  9615.  
  9616.    * As a string with no delimiters in either `'YYYYMMDD'' or `'YYMMDD''
  9617.      format, provided that the string makes sense as a date.  For
  9618.      example, `'19970523'' and `'970523'' are interpreted as
  9619.      `'1997-05-23'', but `'971332'' is illegal (it has nonsensical month
  9620.      and day parts) and becomes `'0000-00-00''.
  9621.  
  9622.    * As a number in either `YYYYMMDDHHMMSS' or `YYMMDDHHMMSS' format,
  9623.      provided that the number makes sense as a date.  For example,
  9624.      `19830905132800' and `830905132800' are interpreted as
  9625.      `'1983-09-05 13:28:00''.
  9626.  
  9627.    * As a number in either `YYYYMMDD' or `YYMMDD' format, provided that
  9628.      the number makes sense as a date.  For example, `19830905' and
  9629.      `830905' are interpreted as `'1983-09-05''.
  9630.  
  9631.    * As the result of a function that returns a value that is acceptable
  9632.      in a `DATETIME', `DATE' or `TIMESTAMP' context, such as `NOW()' or
  9633.      `CURRENT_DATE'.
  9634.  
  9635. Illegal `DATETIME', `DATE' or `TIMESTAMP' values are converted to the
  9636. "zero" value of the appropriate type (`'0000-00-00 00:00:00'',
  9637. `'0000-00-00'' or `00000000000000').
  9638.  
  9639. For values specified as strings that include date part delimiters, it
  9640. is not necessary to specify two digits for month or day values that are
  9641. less than `10'.  `'1979-6-9'' is the same as `'1979-06-09''.  Similarly,
  9642. for values specified as strings that include time part delimiters, it
  9643. is not necessary to specify two digits for hour, month or second values
  9644. that are less than `10'.  `'1979-10-30 1:2:3'' is the same as
  9645. `'1979-10-30 01:02:03''.
  9646.  
  9647. Values specified as numbers should be 6, 8, 12 or 14 digits long.  If
  9648. the number is 8 or 14 digits long, it is assumed to be in `YYYYMMDD' or
  9649. `YYYYMMDDHHMMSS' format and that the year is given by the first 4
  9650. digits.  If the number is 6 or 12 digits long, it is assumed to be in
  9651. `YYMMDD' or `YYMMDDHHMMSS' format and that the year is given by the
  9652. first 2 digits.  Numbers that are not one of these lengths are
  9653. interpreted as though padded with leading zeros to the closest length.
  9654.  
  9655. Values specified as non-delimited strings are interpreted using their
  9656. length as given.  If the string is 8 or 14 characters long, the year is
  9657. assumed to be given by the first 4 characters.  Otherwise the year is
  9658. assumed to be given by the first 2 characters.  The string is
  9659. interpreted from left to right to find year, month, day, hour, minute
  9660. and second values, for as many parts as are present in the string.
  9661. This means you should not use strings that have fewer than 6
  9662. characters.  For example, if you specify `'9903'', thinking that will
  9663. represent March, 1999, you will find that *MySQL* inserts a "zero" date
  9664. into your table.  This is because the year and month values are `99'
  9665. and `03', but the day part is missing (zero), so the value is not a
  9666. legal date.
  9667.  
  9668. `TIMESTAMP' columns store legal values using the full precision with
  9669. which the value was specified, regardless of the display size.  This has
  9670. several implications:
  9671.  
  9672.    * Always specify year, month, and day, even if your column types are
  9673.      `TIMESTAMP(4)' or `TIMESTAMP(2)'.  Otherwise, the value will not
  9674.      be a legal date and `0' will be stored.
  9675.  
  9676.    * If you use `ALTER TABLE' to widen a narrow `TIMESTAMP' column,
  9677.      information will be displayed that previously was "hidden".
  9678.  
  9679.    * Similarly, narrowing a `TIMESTAMP' column does not cause
  9680.      information to be lost, except in the sense that less information
  9681.      is shown when the values are displayed.
  9682.  
  9683.    * Although `TIMESTAMP' values are stored to full precision, the only
  9684.      function that operates directly on the underlying stored value is
  9685.      `UNIX_TIMESTAMP()'.  Other functions operate on the formatted
  9686.      retrieved value.  This means you cannot use functions such as
  9687.      `HOUR()' or `SECOND()' unless the relevant part of the `TIMESTAMP'
  9688.      value is included in the formatted value.  For example, the `HH'
  9689.      part of a `TIMESTAMP' column is not displayed unless the display
  9690.      size is at least 10, so trying to use `HOUR()' on shorter
  9691.      `TIMESTAMP' values produces a meaningless result.
  9692.  
  9693. You can to some extent assign values of one date type to an object of a
  9694. different date type.  However, there may be some alteration of the
  9695. value or loss of information:
  9696.  
  9697.    * If you assign a `DATE' value to a `DATETIME' or `TIMESTAMP'
  9698.      object, the time part of the resulting value is set to
  9699.      `'00:00:00'', because the `DATE' value contains no time
  9700.      information.
  9701.  
  9702.    * If you assign a `DATETIME' or `TIMESTAMP' value to a `DATE'
  9703.      object, the time part of the resulting value is deleted, because
  9704.      the `DATE' type stores no time information.
  9705.  
  9706.    * Remember that although `DATETIME', `DATE' and `TIMESTAMP' values
  9707.      all can be specified using the same set of formats, the types do
  9708.      not all have the same range of values.  For example, `TIMESTAMP'
  9709.      values cannot be earlier than `1970' or later than `2037'.  This
  9710.      means that a date such as `'1968-01-01'', while legal as a
  9711.      `DATETIME' or `DATE' value, is not a valid `TIMESTAMP' value and
  9712.      will be converted to `0' if assigned to such an object.
  9713.  
  9714. Be aware of certain pitfalls when specifying date values:
  9715.  
  9716.    * The relaxed format allowed for values specified as strings can be
  9717.      deceiving.  For example, a value such as `'10:11:12'' might look
  9718.      like a time value because of the `:' delimiter, but if used in a
  9719.      date context will be interpreted as the year `'2010-11-12''.  The
  9720.      value `'10:45:15'' will be converted to `'0000-00-00'' because
  9721.      `'45'' is not a legal month.
  9722.  
  9723.    * Year values specified as two digits are ambiguous, because the
  9724.      century is unknown.  *MySQL* interprets 2-digit year values using
  9725.      the following rules:
  9726.  
  9727.         - Year values in the range `00-69' are converted to `2000-2069'.
  9728.  
  9729.         - Year values in the range `70-99' are converted to `1970-1999'.
  9730.  
  9731. The `TIME' type
  9732. ...............
  9733.  
  9734. *MySQL* retrieves and displays `TIME' values in `'HH:MM:SS'' format (or
  9735. `'HHH:MM:SS'' format for large hours values).  `TIME' values may range
  9736. from `'-838:59:59'' to `'838:59:59''.  The reason the hours part may be
  9737. so large is that the `TIME' type may be used not only to represent a
  9738. time of day (which must be less than 24 hours), but also elapsed time
  9739. or a time interval between two events (which may be much greater than
  9740. 24 hours, or even negative).
  9741.  
  9742. You can specify `TIME' values in a variety of formats:
  9743.  
  9744.    * As a string in `'D HH:MM:SS.fraction'' format.  (Note that *MySQL*
  9745.      doesn't yet store the fraction for the time column).  One can also
  9746.      use one of the following "relaxed" syntax:
  9747.  
  9748.      `HH:MM:SS.fraction', `HH:MM:SS', `HH:MM', `D HH:MM:SS', `D HH:MM',
  9749.      `D HH' or `SS'.  Here `D' is days between 0-33.
  9750.  
  9751.    * As a string with no delimiters in `'HHMMSS'' format, provided that
  9752.      it makes sense as a time.  For example, `'101112'' is understood as
  9753.      `'10:11:12'', but `'109712'' is illegal (it has a nonsensical
  9754.      minute part) and becomes `'00:00:00''.
  9755.  
  9756.    * As a number in `HHMMSS' format, provided that it makes sense as a
  9757.      time.  For example, `101112' is understood as `'10:11:12''.  The
  9758.      following alternative formats are also understood: `SS',
  9759.      `MMSS',`HHMMSS', `HHMMSS.fraction'.  Note that *MySQL* doesn't yet
  9760.      store the fraction part.
  9761.  
  9762.    * As the result of a function that returns a value that is acceptable
  9763.      in a `TIME' context, such as `CURRENT_TIME'.
  9764.  
  9765. For `TIME' values specified as strings that include a time part
  9766. delimiter, it is not necessary to specify two digits for hours, minutes
  9767. or seconds values that are less than `10'.  `'8:3:2'' is the same as
  9768. `'08:03:02''.
  9769.  
  9770. Be careful about assigning "short" `TIME' values to a `TIME' column.
  9771. *MySQL* interprets values using the assumption that the rightmost
  9772. digits represent seconds.  (*MySQL* interprets `TIME' values as elapsed
  9773. time, rather than as time of day.)  For example, you might think of
  9774. `'11:12'', `'1112'' and `1112' as meaning `'11:12:00'' (12 minutes
  9775. after 11 o'clock), but *MySQL* interprets them as `'00:11:12'' (11
  9776. minutes, 12 seconds).  Similarly, `'12'' and `12' are interpreted as
  9777. `'00:00:12''.
  9778.  
  9779. Values that lie outside the `TIME' range but are otherwise legal are
  9780. clipped to the appropriate endpoint of the range.  For example,
  9781. `'-850:00:00'' and `'850:00:00'' are converted to `'-838:59:59'' and
  9782. `'838:59:59''.
  9783.  
  9784. Illegal `TIME' values are converted to `'00:00:00''.  Note that because
  9785. `'00:00:00'' is itself a legal `TIME' value, there is no way to tell,
  9786. from a value of `'00:00:00'' stored in a table, whether the original
  9787. value was specified as `'00:00:00'' or whether it was illegal.
  9788.  
  9789. The `YEAR' type
  9790. ...............
  9791.  
  9792. The `YEAR' type is a 1-byte type used for representing years.
  9793.  
  9794. *MySQL* retrieves and displays `YEAR' values in `YYYY' format.  The
  9795. range is `1901' to `2155'.
  9796.  
  9797. You can specify `YEAR' values in a variety of formats:
  9798.  
  9799.    * As a four-digit string in the range `'1901'' to `'2155''.
  9800.  
  9801.    * As a four-digit number in the range `1901' to `2155'.
  9802.  
  9803.    * As a two-digit string in the range `'00'' to `'99''.  Values in the
  9804.      ranges `'00'' to `'69'' and `'70'' to `'99'' are converted to
  9805.      `YEAR' values in the ranges `2000' to `2069' and `1970' to `1999'.
  9806.  
  9807.    * As a two-digit number in the range `1' to `99'.  Values in the
  9808.      ranges `1' to `69' and `70' to `99' are converted to `YEAR' values
  9809.      in the ranges `2001' to `2069' and `1970' to `1999'.  Note that
  9810.      the range for two-digit numbers is slightly different than the
  9811.      range for two-digit strings, because you cannot specify zero
  9812.      directly as a number and have it be interpreted as `2000'.  You
  9813.      _must_ specify it as a string `'0'' or `'00'' or it will be
  9814.      interpreted as `0000'.
  9815.  
  9816.    * As the result of a function that returns a value that is acceptable
  9817.      in a `YEAR' context, such as `NOW()'.
  9818.  
  9819. Illegal `YEAR' values are converted to `0000'.
  9820.  
  9821. String types
  9822. ------------
  9823.  
  9824. The string types are `CHAR', `VARCHAR', `BLOB', `TEXT', `ENUM' and
  9825. `SET'.
  9826.  
  9827. The `CHAR' and `VARCHAR' types
  9828. ..............................
  9829.  
  9830. The `CHAR' and `VARCHAR' types are similar, but differ in the way they
  9831. are stored and retrieved.
  9832.  
  9833. The length of a `CHAR' column is fixed to the length that you declare
  9834. when you create the table.  The length can be any value between 1 and
  9835. 255.  (As of *MySQL* 3.23, the length of `CHAR' may be 0 to 255.)  When
  9836. `CHAR' values are stored, they are right-padded with spaces to the
  9837. specified length.  When `CHAR' values are retrieved, trailing spaces are
  9838. removed.
  9839.  
  9840. Values in `VARCHAR' columns are variable-length strings.  You can
  9841. declare a `VARCHAR' column to be any length between 1 and 255, just as
  9842. for `CHAR' columns.  However, in contrast to `CHAR', `VARCHAR' values
  9843. are stored using only as many characters as are needed, plus one byte
  9844. to record the length.  Values are not padded; instead, trailing spaces
  9845. are removed when values are stored.  (This space removal differs from
  9846. the ANSI SQL specification.)
  9847.  
  9848. If you assign a value to a `CHAR' or `VARCHAR' column that exceeds the
  9849. column's maximum length, the value is truncated to fit.
  9850.  
  9851. The table below illustrates the differences between the two types of
  9852. columns by showing the result of storing various string values into
  9853. `CHAR(4)' and `VARCHAR(4)' columns:
  9854.  
  9855. *Value*        `CHAR(4)'   *Storage       `VARCHAR(4)'   *Storage required*
  9856.                            required*                     
  9857. `'''           `'    ''    4 bytes        `'''           1 byte
  9858. `'ab''         `'ab  ''    4 bytes        `'ab''         3 bytes
  9859. `'abcd''       `'abcd''    4 bytes        `'abcd''       5 bytes
  9860. `'abcdefgh''   `'abcd''    4 bytes        `'abcd''       5 bytes
  9861.  
  9862. The values retrieved from the `CHAR(4)' and `VARCHAR(4)' columns will
  9863. be the same in each case, because trailing spaces are removed from
  9864. `CHAR' columns upon retrieval.
  9865.  
  9866. Values in `CHAR' and `VARCHAR' columns are sorted and compared in
  9867. case-insensitive fashion, unless the `BINARY' attribute was specified
  9868. when the table was created.  The `BINARY' attribute means that column
  9869. values are sorted and compared in case-sensitive fashion according to
  9870. the ASCII order of the machine where the *MySQL* server is running.
  9871.  
  9872. The `BINARY' attribute is "sticky".  This means that if a column marked
  9873. `BINARY' is used in an expression, the whole expression is compared as a
  9874. `BINARY' value.
  9875.  
  9876. *MySQL* may silently change the type of a `CHAR' or `VARCHAR' column at
  9877. table creation time.  *Note Silent column changes::.
  9878.  
  9879. The `BLOB' and `TEXT' types
  9880. ...........................
  9881.  
  9882. A `BLOB' is a binary large object that can hold a variable amount of
  9883. data.  The four `BLOB' types `TINYBLOB', `BLOB', `MEDIUMBLOB' and
  9884. `LONGBLOB' differ only in the maximum length of the values they can
  9885. hold.  *Note Storage requirements::.
  9886.  
  9887. The four `TEXT' types `TINYTEXT', `TEXT', `MEDIUMTEXT' and `LONGTEXT'
  9888. correspond to the four `BLOB' types and have the same maximum lengths
  9889. and storage requirements.  The only difference between `BLOB' and
  9890. `TEXT' types is that sorting and comparison is performed in
  9891. case-sensitive fashion for `BLOB' values and case-insensitive fashion
  9892. for `TEXT' values.  In other words, a `TEXT' is a case-insensitive
  9893. `BLOB'.
  9894.  
  9895. If you assign a value to a `BLOB' or `TEXT' column that exceeds the
  9896. column type's maximum length, the value is truncated to fit.
  9897.  
  9898. In most respects, you can regard a `TEXT' column as a `VARCHAR' column
  9899. that can be as big as you like.  Similarly, you can regard a `BLOB'
  9900. column as a `VARCHAR BINARY' column.  The differences are:
  9901.  
  9902.    * You can have indexes on `BLOB' and `TEXT' columns with *MySQL*
  9903.      versions 3.23.2 and newer. Older versions of *MySQL* did not
  9904.      support this.
  9905.  
  9906.    * There is no trailing-space removal for `BLOB' and `TEXT' columns
  9907.      when values are stored, as there is for `VARCHAR' columns.
  9908.  
  9909.    * `BLOB' and `TEXT' columns cannot have `DEFAULT' values.
  9910.  
  9911. *MyODBC* defines `BLOB' values as `LONGVARBINARY' and `TEXT' values as
  9912. `LONGVARCHAR'.
  9913.  
  9914. Because `BLOB' and `TEXT' values may be extremely long, you may run up
  9915. against some constraints when using them:
  9916.  
  9917.    * If you want to use `GROUP BY' or `ORDER BY' on a `BLOB' or `TEXT'
  9918.      column, you must convert the column value into a fixed-length
  9919.      object. The standard way to do this is with the `SUBSTRING'
  9920.      function.  For example:
  9921.  
  9922.           mysql> select comment from tbl_name,substring(comment,20) as substr
  9923.                  ORDER BY substr;
  9924.  
  9925.      If you don't do this, only the first `max_sort_length' bytes of the
  9926.      column are used when sorting.  The default value of
  9927.      `max_sort_length' is 1024; this value can be changed using the
  9928.      `-O' option when starting the `mysqld' server. You can group on an
  9929.      expression involving `BLOB' or `TEXT' values by specifying the
  9930.      column position or by using an alias:
  9931.  
  9932.           mysql> select id,substring(blob_col,1,100) from tbl_name
  9933.                      GROUP BY 2;
  9934.           mysql> select id,substring(blob_col,1,100) as b from tbl_name
  9935.                      GROUP BY b;
  9936.  
  9937.    * The maximum size of a `BLOB' or `TEXT' object is determined by its
  9938.      type, but the largest value you can actually transmit between the
  9939.      client and server is determined by the amount of available memory
  9940.      and the size of the communications buffers.  You can change the
  9941.      message buffer size, but you must do so on both the server and
  9942.      client ends. *Note Server parameters::.
  9943.  
  9944. Note that each `BLOB' or `TEXT' value is represented internally by a
  9945. separately-allocated object. This is in contrast to all other column
  9946. types, for which storage is allocated once per column when the table is
  9947. opened.
  9948.  
  9949. The `ENUM' type
  9950. ...............
  9951.  
  9952. An `ENUM' is a string object whose value normally is chosen from a list
  9953. of allowed values that are enumerated explicitly in the column
  9954. specification at table creation time.
  9955.  
  9956. The value may also be the empty string (`""') or `NULL' under certain
  9957. circumstances:
  9958.  
  9959.    * If you insert an invalid value into an `ENUM' (that is, a string
  9960.      not present in the list of allowed values), the empty string is
  9961.      inserted instead as a special error value.
  9962.  
  9963.    * If an `ENUM' is declared `NULL', `NULL' is also a legal value for
  9964.      the column, and the default value is `NULL'.  If an `ENUM' is
  9965.      declared `NOT NULL', the default value is the first element of the
  9966.      list of allowed values.
  9967.  
  9968. Each enumeration value has an index:
  9969.  
  9970.    * Values from the list of allowable elements in the column
  9971.      specification are numbered beginning with 1.
  9972.  
  9973.    * The index value of the empty string error value is 0.  This means
  9974.      that you can use the following `SELECT' statement to find rows
  9975.      into which invalid `ENUM' values were assigned:
  9976.  
  9977.           mysql> SELECT * FROM tbl_name WHERE enum_col=0;
  9978.  
  9979.    * The index of the `NULL' value is `NULL'.
  9980.  
  9981. For example, a column specified as `ENUM("one", "two", "three")' can
  9982. have any of the values shown below.  The index of each value is also
  9983. shown:
  9984.  
  9985. *Value*        *Index*
  9986. `NULL'         `NULL'
  9987. `""'           0
  9988. `"one"'        1
  9989. `"two"'        2
  9990. `"three"'      3
  9991.  
  9992. An enumeration can have a maximum of 65535 elements.
  9993.  
  9994. Lettercase is irrelevant when you assign values to an `ENUM' column.
  9995. However, values retrieved from the column later have lettercase
  9996. matching the values that were used to specify the allowable values at
  9997. table creation time.
  9998.  
  9999. If you retrieve an `ENUM' in a numeric context, the column value's index
  10000. is returned.  If you store a number into an `ENUM', the number is
  10001. treated as an index, and the the value stored is the enumeration member
  10002. with that index.  (However, this will not work with `LOAD DATA', which
  10003. treats all input as strings.)
  10004.  
  10005. `ENUM' values are sorted according to the order in which the enumeration
  10006. members were listed in the column specification.  (In other words,
  10007. `ENUM' values are sorted according to their index numbers.)  For
  10008. example, `"a"' sorts before `"b"' for `ENUM("a", "b")', but `"b"' sorts
  10009. before `"a"' for `ENUM("b", "a")'.  The empty string sorts before
  10010. non-empty strings, and `NULL' values sort before all other enumeration
  10011. values.
  10012.  
  10013. If you want to get all possible values for an `ENUM' column, you should
  10014. use: `SHOW COLUMNS FROM table_name LIKE enum_column_name' and parse the
  10015. `ENUM' definition in the second column.
  10016.  
  10017. The `SET' type
  10018. ..............
  10019.  
  10020. A `SET' is a string object that can have zero or more values, each of
  10021. which must be chosen from a list of allowed values specified when the
  10022. table is created.  `SET' column values that consist of multiple set
  10023. members are specified with members separated by commas (`,').  A
  10024. consequence of this is that `SET' member values cannot themselves
  10025. contain commas.
  10026.  
  10027. For example, a column specified as `SET("one", "two") NOT NULL' can have
  10028. any of these values:
  10029.  
  10030.      ""
  10031.      "one"
  10032.      "two"
  10033.      "one,two"
  10034.  
  10035. A `SET' can have a maximum of 64 different members.
  10036.  
  10037. *MySQL* stores `SET' values numerically, with the low-order bit of the
  10038. stored value corresponding to the first set member.  If you retrieve a
  10039. `SET' value in a numeric context, the value retrieved has bits set
  10040. corresponding to the set members that make up the column value.  If a
  10041. number is stored into a `SET' column, the bits that are set in the
  10042. binary representation of the number determine the set members in the
  10043. column value.  Suppose a column is specified as `SET("a","b","c","d")'.
  10044. Then the members have the following bit values:
  10045.  
  10046. `SET'          *Decimal       *Binary value*
  10047. *member*       value*         
  10048. `a'            `1'            `0001'
  10049. `b'            `2'            `0010'
  10050. `c'            `4'            `0100'
  10051. `d'            `8'            `1000'
  10052.  
  10053. If you assign a value of `9' to this column, that is `1001' in binary,
  10054. so the first and fourth `SET' value members `"a"' and `"d"' are
  10055. selected and the resulting value is `"a,d"'.
  10056.  
  10057. For a value containing more than one `SET' element, it does not matter
  10058. what order the elements are listed in when you insert the value.  It
  10059. also does not matter how many times a given element is listed in the
  10060. value.  When the value is retrieved later, each element in the value
  10061. will appear once, with elements listed according to the order in which
  10062. they were specified at table creation time.  For example, if a column
  10063. is specified as `SET("a","b","c","d")', then `"a,d"', `"d,a"' and
  10064. `"d,a,a,d,d"' will all appear as `"a,d"' when retrieved.
  10065.  
  10066. `SET' values are sorted numerically.  `NULL' values sort before
  10067. non-`NULL' `SET' values.
  10068.  
  10069. Normally, you perform a `SELECT' on a `SET' column using the `LIKE'
  10070. operator or the `FIND_IN_SET()' function:
  10071.  
  10072.      mysql> SELECT * FROM tbl_name WHERE set_col LIKE '%value%';
  10073.      mysql> SELECT * FROM tbl_name WHERE FIND_IN_SET('value',set_col)>0;
  10074.  
  10075. But the following will also work:
  10076.  
  10077.      mysql> SELECT * FROM tbl_name WHERE set_col = 'val1,val2';
  10078.      mysql> SELECT * FROM tbl_name WHERE set_col & 1;
  10079.  
  10080. The first of these statements looks for an exact match.  The second
  10081. looks for values containing the first set member.
  10082.  
  10083. If you want to get all possible values for a `SET' column, you should
  10084. use: `SHOW COLUMNS FROM table_name LIKE set_column_name' and parse the
  10085. `SET' definition in the second column.
  10086.  
  10087. Choosing the right type for a column
  10088. ------------------------------------
  10089.  
  10090. For the most efficient use of storage, try to use the most precise type
  10091. in all cases. For example, if an integer column will be used for values
  10092. in the range between `1' and `99999', `MEDIUMINT UNSIGNED' is the best
  10093. type.
  10094.  
  10095. Accurate representation of monetary values is a common problem. In
  10096. *MySQL*, you should use the `DECIMAL' type. This is stored as a string,
  10097. so no loss of accuracy should occur. If accuracy is not too important,
  10098. the `DOUBLE' type may also be good enough.
  10099.  
  10100. For high precision, you can always convert to a fixed-point type stored
  10101. in a `BIGINT'. This allows you to do all calculations with integers and
  10102. convert results back to floating-point values only when necessary.
  10103.  
  10104. Column indexes
  10105. --------------
  10106.  
  10107. All *MySQL* column types can be indexed.  Use of indexes on the
  10108. relevant columns is the best way to improve the performance of `SELECT'
  10109. operations.
  10110.  
  10111. A table may have up to 16 indexes.  The maximum index length is 256
  10112. bytes, although this may be changed when compiling *MySQL*.
  10113.  
  10114. For `CHAR' and `VARCHAR' columns, you can index a prefix of a column.
  10115. This is much faster and requires less disk space than indexing the
  10116. whole column.  The syntax to use in the `CREATE TABLE' statement to
  10117. index a column prefix looks like this:
  10118.  
  10119.      KEY index_name (col_name(length))
  10120.  
  10121. The example below creates an index for the first 10 characters of the
  10122. `name' column:
  10123.  
  10124.      mysql> CREATE TABLE test (
  10125.                 name CHAR(200) NOT NULL,
  10126.                 KEY index_name (name(10)));
  10127.  
  10128. For `BLOB' and `TEXT' columns, you must index a prefix of the column,
  10129. you cannot index the entire thing.
  10130.  
  10131. Multiple-column indexes
  10132. -----------------------
  10133.  
  10134. *MySQL* can create indexes on multiple columns.  An index may consist
  10135. of up to 15 columns. (On `CHAR' and `VARCHAR' columns you can also use
  10136. a prefix of the column as a part of an index).
  10137.  
  10138. A multiple-column index can be considered a sorted array containing
  10139. values that are created by concatenating the values of the indexed
  10140. columns.
  10141.  
  10142. *MySQL* uses multiple-column indexes in such a way that queries are
  10143. fast when you specify a known quantity for the first column of the
  10144. index in a `WHERE' clause, even if you don't specify values for the
  10145. other columns.
  10146.  
  10147. Suppose a table is created using the following specification:
  10148.  
  10149.      mysql> CREATE TABLE test (
  10150.                 id INT NOT NULL,
  10151.                 last_name CHAR(30) NOT NULL,
  10152.                 first_name CHAR(30) NOT NULL,
  10153.                 PRIMARY KEY (id),
  10154.                 INDEX name (last_name,first_name));
  10155.  
  10156. Then the index `name' is an index over `last_name' and `first_name'.
  10157. The index will be used for queries that specify values in a known range
  10158. for `last_name', or for both `last_name' and `first_name'.  Therefore,
  10159. the `name' index will be used in the following queries:
  10160.  
  10161.      mysql> SELECT * FROM test WHERE last_name="Widenius";
  10162.      
  10163.      mysql> SELECT * FROM test WHERE last_name="Widenius"
  10164.                                AND first_name="Michael";
  10165.      
  10166.      mysql> SELECT * FROM test WHERE last_name="Widenius"
  10167.                                AND (first_name="Michael" OR first_name="Monty");
  10168.      
  10169.      mysql> SELECT * FROM test WHERE last_name="Widenius"
  10170.                                AND first_name >="M" AND first_name < "N";
  10171.  
  10172. However, the `name' index will NOT be used in the following queries:
  10173.  
  10174.      mysql> SELECT * FROM test WHERE first_name="Michael";
  10175.      
  10176.      mysql> SELECT * FROM test WHERE last_name="Widenius"
  10177.                                OR first_name="Michael";
  10178.  
  10179. For more information on the manner in which *MySQL* uses indexes to
  10180. improve query performance, see *Note *MySQL* indexes: MySQL indexes.
  10181.  
  10182. Using column types from other database engines
  10183. ----------------------------------------------
  10184.  
  10185. To make it easier to use code written for SQL implementations from other
  10186. vendors, *MySQL* maps column types as shown in the table below.  These
  10187. mappings make it easier to move table definitions from other database
  10188. engines to *MySQL*:
  10189.  
  10190. *Other vendor type*           *MySQL type*
  10191. `BINARY(NUM)'                 `CHAR(NUM) BINARY'
  10192. `CHAR VARYING(NUM)'           `VARCHAR(NUM)'
  10193. `FLOAT4'                      `FLOAT'
  10194. `FLOAT8'                      `DOUBLE'
  10195. `INT1'                        `TINYINT'
  10196. `INT2'                        `SMALLINT'
  10197. `INT3'                        `MEDIUMINT'
  10198. `INT4'                        `INT'
  10199. `INT8'                        `BIGINT'
  10200. `LONG VARBINARY'              `MEDIUMBLOB'
  10201. `LONG VARCHAR'                `MEDIUMTEXT'
  10202. `MIDDLEINT'                   `MEDIUMINT'
  10203. `VARBINARY(NUM)'              `VARCHAR(NUM) BINARY'
  10204.  
  10205. Column type mapping occurs at table creation time.  If you create a
  10206. table with types used by other vendors and then issue a `DESCRIBE
  10207. tbl_name' statement, *MySQL* reports the table structure using the
  10208. equivalent *MySQL* types.
  10209.  
  10210. Functions for use in `SELECT' and `WHERE' clauses
  10211. =================================================
  10212.  
  10213. A `select_expression' or `where_definition' in a SQL statement can
  10214. consist of any expression using the functions described below.
  10215.  
  10216. An expression that contains `NULL' always produces a `NULL' value
  10217. unless otherwise indicated in the documentation for the operators and
  10218. functions involved in the expression.
  10219.  
  10220. *Note:* There must be no whitespace between a function name and the
  10221. parenthesis following it. This helps the *MySQL* parser distinguish
  10222. between function calls and references to tables or columns that happen
  10223. to have the same name as a function.  Spaces around arguments are
  10224. permitted, though.
  10225.  
  10226. For the sake of brevity, examples display the output from the `mysql'
  10227. program in abbreviated form.  So this:
  10228.  
  10229.      mysql> select MOD(29,9);
  10230.      1 rows in set (0.00 sec)
  10231.      
  10232.      +-----------+
  10233.      | mod(29,9) |
  10234.      +-----------+
  10235.      |         2 |
  10236.      +-----------+
  10237.  
  10238. Is displayed like this:
  10239.  
  10240.      mysql> select MOD(29,9);
  10241.              -> 2
  10242.  
  10243. Grouping functions
  10244. ------------------
  10245.  
  10246. `( ... )'
  10247.      Parentheses. Use these to force the order of evaluation in an
  10248.      expression.
  10249.           mysql> select 1+2*3;
  10250.                   -> 7
  10251.           mysql> select (1+2)*3;
  10252.                   -> 9
  10253.  
  10254. Normal arithmetic operations
  10255. ----------------------------
  10256.  
  10257. The usual arithmetic operators are available.  Note that in the case of
  10258. `-', `+' and `*', the result is calculated with `BIGINT' (64-bit)
  10259. precision if both arguments are integers!
  10260.  
  10261. `+'
  10262.      Addition
  10263.           mysql> select 3+5;
  10264.                   -> 8
  10265.  
  10266. `-'
  10267.      Subtraction
  10268.           mysql> select 3-5;
  10269.                   -> -2
  10270.  
  10271. `*'
  10272.      Multiplication
  10273.           mysql> select 3*5;
  10274.                   -> 15
  10275.           mysql> select 18014398509481984*18014398509481984.0;
  10276.                   -> 324518553658426726783156020576256.0
  10277.           mysql> select 18014398509481984*18014398509481984;
  10278.                   -> 0
  10279.  
  10280.      The result of the last expression is incorrect because the result
  10281.      of the integer multiplication exceeds the 64-bit range of `BIGINT'
  10282.      calculations.
  10283.  
  10284. `/'
  10285.      Division
  10286.           mysql> select 3/5;
  10287.                   -> 0.60
  10288.  
  10289.      Division by zero produces a `NULL' result:
  10290.  
  10291.           mysql> select 102/(1-1);
  10292.                   -> NULL
  10293.  
  10294.      A division will be calculated with `BIGINT' arithmetic only if
  10295.      performed in a context where its result is converted to an integer!
  10296.  
  10297. Bit functions
  10298. -------------
  10299.  
  10300. *MySQL* uses `BIGINT' (64-bit) arithmetic for bit operations, so these
  10301. operators have a maximum range of 64 bits.
  10302.  
  10303. `|'
  10304.      Bitwise OR
  10305.           mysql> select 29 | 15;
  10306.                   -> 31
  10307.  
  10308. `&'
  10309.      Bitwise AND
  10310.           mysql> select 29 & 15;
  10311.                   -> 13
  10312.  
  10313. `<<'
  10314.      Shifts a longlong (`BIGINT') number to the left.
  10315.           mysql> select 1 << 2
  10316.                   -> 4
  10317.  
  10318. `>>'
  10319.      Shifts a longlong (`BIGINT') number to the right.
  10320.           mysql> select 4 >> 2
  10321.                   -> 1
  10322.  
  10323. `~'
  10324.      Invert all bits.
  10325.           mysql> select 5 & ~1
  10326.                   -> 4
  10327.  
  10328. `BIT_COUNT(N)'
  10329.      Returns the number of bits that are set in the argument `N'.
  10330.           mysql> select BIT_COUNT(29);
  10331.                   -> 4
  10332.  
  10333. Logical operations
  10334. ------------------
  10335.  
  10336. All logical functions return `1' (TRUE) or `0' (FALSE).
  10337.  
  10338. `NOT'
  10339. `!'
  10340.      Logical NOT. Returns `1' if the argument is `0', otherwise returns
  10341.      `0'.  Exception: `NOT NULL' returns `NULL'.
  10342.           mysql> select NOT 1;
  10343.                   -> 0
  10344.           mysql> select NOT NULL;
  10345.                   -> NULL
  10346.           mysql> select ! (1+1);
  10347.                   -> 0
  10348.           mysql> select ! 1+1;
  10349.                   -> 1
  10350.      The last example returns `1' because the expression evaluates the
  10351.      same way as `(!1)+1'.
  10352.  
  10353. `OR'
  10354. `||'
  10355.      Logical OR. Returns `1' if either argument is not `0' and not
  10356.      `NULL'.
  10357.           mysql> select 1 || 0;
  10358.                   -> 1
  10359.           mysql> select 0 || 0;
  10360.                   -> 0
  10361.           mysql> select 1 || NULL;
  10362.                   -> 1
  10363.  
  10364. `AND'
  10365. `&&'
  10366.      Logical AND. Returns `0' if either argument is `0' or `NULL',
  10367.      otherwise returns `1'.
  10368.           mysql> select 1 && NULL;
  10369.                   -> 0
  10370.           mysql> select 1 && 0;
  10371.                   -> 0
  10372.  
  10373. Comparison operators
  10374. --------------------
  10375.  
  10376. Comparison operations result in a value of `1' (TRUE), `0' (FALSE) or
  10377. `NULL'. These functions work for both numbers and strings.  Strings are
  10378. automatically converted to numbers and numbers to strings as needed (as
  10379. in Perl).
  10380.  
  10381. *MySQL* performs comparisons using the following rules:
  10382.  
  10383.    * If one or both arguments are `NULL', the result of the comparison
  10384.      is `NULL', except for the `<=>' operator.
  10385.  
  10386.    * If both arguments in a comparison operation are strings, they are
  10387.      compared as strings.
  10388.  
  10389.    * If both arguments are integers, they are compared as integers.
  10390.  
  10391.    * Hexadecimal values are treated as binary strings if not compared
  10392.      to a number.
  10393.  
  10394.    * If one of the arguments is a `TIMESTAMP' or `DATETIME' column and
  10395.      the other argument is a constant, the constant is converted to a
  10396.      timestamp before the comparison is performed. This is done to be
  10397.      more ODBC-friendly.
  10398.  
  10399.    * In all other cases, the arguments are compared as floating-point
  10400.      (real) numbers.
  10401.  
  10402. By default, string comparisons are done in case-independent fashion
  10403. using the current character set (ISO-8859-1 Latin1 by default, which
  10404. also works excellently for English).
  10405.  
  10406. The examples below illustrate conversion of strings to numbers for
  10407. comparison operations:
  10408.  
  10409.      mysql> SELECT 1 > '6x';
  10410.               -> 0
  10411.      mysql> SELECT 7 > '6x';
  10412.               -> 1
  10413.      mysql> SELECT 0 > 'x6';
  10414.               -> 0
  10415.      mysql> SELECT 0 = 'x6';
  10416.               -> 1
  10417.  
  10418. `='
  10419.      Equal
  10420.           mysql> select 1 = 0;
  10421.                   -> 0
  10422.           mysql> select '0' = 0;
  10423.                   -> 1
  10424.           mysql> select '0.0' = 0;
  10425.                   -> 1
  10426.           mysql> select '0.01' = 0;
  10427.                   -> 0
  10428.           mysql> select '.01' = 0.01;
  10429.                   -> 1
  10430.  
  10431. `<>'
  10432. `!='
  10433.      Not equal
  10434.           mysql> select '.01' <> '0.01';
  10435.                   -> 1
  10436.           mysql> select .01 <> '0.01';
  10437.                   -> 0
  10438.           mysql> select 'zapp' <> 'zappp';
  10439.                   -> 1
  10440.  
  10441. `<='
  10442.      Less than or equal
  10443.           mysql> select 0.1 <= 2;
  10444.                   -> 1
  10445.  
  10446. `<'
  10447.      Less than
  10448.           mysql> select 2 <= 2;
  10449.                   -> 1
  10450.  
  10451. `>='
  10452.      Greater than or equal
  10453.           mysql> select 2 >= 2;
  10454.                   -> 1
  10455.  
  10456. `>'
  10457.      Greater than
  10458.           mysql> select 2 > 2;
  10459.                   -> 0
  10460.  
  10461. `<=>'
  10462.      Null safe equal
  10463.           mysql> select 1 <=> 1, NULL <=> NULL, 1 <=> NULL;
  10464.                   -> 1 1 0
  10465.  
  10466. `IS NULL'
  10467. `IS NOT NULL'
  10468.      Test whether or not a value is or is not `NULL'
  10469.           mysql> select 1 IS NULL, 0 IS NULL, NULL IS NULL:
  10470.                   -> 0 0 1
  10471.           mysql> select 1 IS NOT NULL, 0 IS NOT NULL, NULL IS NOT NULL;
  10472.                   -> 1 1 0
  10473.  
  10474. `expr BETWEEN min AND max'
  10475.      If `expr' is greater than or equal to `min' and `expr' is less
  10476.      than or equal to `max', `BETWEEN' returns `1', otherwise it
  10477.      returns `0'.  This is equivalent to the expression `(min <= expr
  10478.      AND expr <= max)' if all the arguments are of the same type.  The
  10479.      first argument (`expr') determines how the comparison is performed
  10480.      as follows:
  10481.  
  10482.         * If `expr' is a `TIMESTAMP', `DATE' or `DATETIME' column, min
  10483.           and max are formatted to the same format if they are
  10484.           constants.
  10485.  
  10486.         * If `expr' is a case-insensitive string expression, a
  10487.           case-insensitive string comparison is done.
  10488.  
  10489.         * If `expr' is a case-sensitive string expression, a
  10490.           case-sensitive string comparison is done.
  10491.  
  10492.         * If `expr' is an integer expression, an integer comparison is
  10493.           done.
  10494.  
  10495.         * Otherwise, a floating-point (real) comparison is done.
  10496.  
  10497.           mysql> select 1 BETWEEN 2 AND 3;
  10498.                   -> 0
  10499.           mysql> select 'b' BETWEEN 'a' AND 'c';
  10500.                   -> 1
  10501.           mysql> select 2 BETWEEN 2 AND '3';
  10502.                   -> 1
  10503.           mysql> select 2 BETWEEN 2 AND 'x-3';
  10504.                   -> 0
  10505.  
  10506. `expr IN (value,...)'
  10507.      Returns `1' if `expr' is any of the values in the `IN' list, else
  10508.      returns `0'.  If all values are constants, then all values are
  10509.      evaluated according to the type of `expr' and sorted. The search
  10510.      for the item is then done using a binary search. This means `IN'
  10511.      is very quick if the `IN' value list consists entirely of
  10512.      constants.  If `expr' is a case-sensitive string expression, the
  10513.      string comparison is performed in case-sensitive fashion.
  10514.  
  10515.           mysql> select 2 IN (0,3,5,'wefwf');
  10516.                   -> 0
  10517.           mysql> select 'wefwf' IN (0,3,5,'wefwf');
  10518.                   -> 1
  10519.  
  10520. `expr NOT IN (value,...)'
  10521.      Same as `NOT (expr IN (value,...))'.
  10522.  
  10523. `ISNULL(expr)'
  10524.      If `expr' is `NULL', `ISNULL()' returns `1', otherwise it returns
  10525.      `0'.
  10526.           mysql> select ISNULL(1+1);
  10527.                   -> 0
  10528.           mysql> select ISNULL(1/0);
  10529.                   -> 1
  10530.  
  10531.      Note that a comparison of `NULL' values using `=' will always be
  10532.      false!
  10533.  
  10534. `COALESCE(list)'
  10535.      Returns first non-`NULL' element in list.
  10536.  
  10537.           mysql> select COALESCE(NULL,1);
  10538.                   -> 1
  10539.           mysql> select COALESCE(NULL,NULL,NULL);
  10540.                   -> NULL
  10541.  
  10542. `INTERVAL(N,N1,N2,N3,...)'
  10543.      Returns `0' if `N' < `N1', `1' if `N' < `N2' and so on. All
  10544.      arguments are treated as integers.  It is required that `N1' <
  10545.      `N2' < `N3' < `...' < `Nn' for this function to work correctly.
  10546.      This is because a binary search is used (very fast).
  10547.  
  10548.           mysql> select INTERVAL(23, 1, 15, 17, 30, 44, 200);
  10549.                   -> 3
  10550.           mysql> select INTERVAL(10, 1, 10, 100, 1000);
  10551.                   -> 2
  10552.           mysql> select INTERVAL(22, 23, 30, 44, 200);
  10553.                   -> 0
  10554.  
  10555. String comparison functions
  10556. ---------------------------
  10557.  
  10558. Normally, if any expression in a string comparison is case sensitive,
  10559. the comparison is performed in case-sensitive fashion.
  10560.  
  10561. `expr LIKE pat [ESCAPE 'escape-char']'
  10562.      Pattern matching using SQL simple regular expression comparison.
  10563.      Returns `1' (TRUE) or `0' (FALSE).  With `LIKE' you can use the
  10564.      following two wildcard characters in the pattern:
  10565.  
  10566.      `%'     Matches any number of characters, even zero characters
  10567.      `_'     Matches exactly one character
  10568.  
  10569.           mysql> select 'David!' LIKE 'David_';
  10570.                   -> 1
  10571.           mysql> select 'David!' LIKE '%D%v%';
  10572.                   -> 1
  10573.  
  10574.      To test for literal instances of a wildcard character, precede the
  10575.      character with the escape character.  If you don't specify the
  10576.      `ESCAPE' character, `\' is assumed:
  10577.  
  10578.      `\%'    Matches one `%' character
  10579.      `\_'    Matches one `_' character
  10580.  
  10581.           mysql> select 'David!' LIKE 'David\_';
  10582.                   -> 0
  10583.           mysql> select 'David_' LIKE 'David\_';
  10584.                   -> 1
  10585.  
  10586.      To specify a different escape character, use the `ESCAPE' clause:
  10587.  
  10588.           mysql> select 'David_' LIKE 'David|_' ESCAPE '|';
  10589.                   -> 1
  10590.  
  10591.      `LIKE' is allowed on numeric expressions! (This is a *MySQL*
  10592.      extension to the ANSI SQL `LIKE'.)
  10593.  
  10594.           mysql> select 10 LIKE '1%';
  10595.                   -> 1
  10596.  
  10597.      Note: Because *MySQL* uses the C escape syntax in strings (e.g.,
  10598.      `\n'), you must double any `\' that you use in your `LIKE'
  10599.      strings.  For example, to search for `\n', specify it as `\\n'.  To
  10600.      search for `\', specify it as `\\\\' (the backslashes are stripped
  10601.      once by the parser, and another time when the pattern match is
  10602.      done, leaving a single backslash to be matched).
  10603.  
  10604. `expr NOT LIKE pat [ESCAPE 'escape-char']'
  10605.      Same as `NOT (expr LIKE pat [ESCAPE 'escape-char'])'.
  10606.  
  10607. `expr REGEXP pat'
  10608. `expr RLIKE pat'
  10609.      Performs a pattern match of a string expression `expr' against a
  10610.      pattern `pat'.  The pattern can be an extended regular expression.
  10611.      *Note Regexp::.  Returns `1' if `expr' matches `pat', otherwise
  10612.      returns `0'.  `RLIKE' is a synonym for `REGEXP', provided for
  10613.      `mSQL' compatibility. Note: Because *MySQL* uses the C escape
  10614.      syntax in strings (e.g., `\n'), you must double any `\' that you
  10615.      use in your `REGEXP' strings.  In `MySQL' 3.23.4 `REGEXP' is case
  10616.      insensitive for normal (not binary) strings.
  10617.  
  10618.           mysql> select 'Monty!' REGEXP 'm%y%%';
  10619.                   -> 0
  10620.           mysql> select 'Monty!' REGEXP '.*';
  10621.                   -> 1
  10622.           mysql> select 'new*\n*line' REGEXP 'new\\*.\\*line';
  10623.                   -> 1
  10624.           mysql> select "a" REGEXP "A", "a" REGEXP BINARY "A";
  10625.                   -> 1  0
  10626.  
  10627. `'
  10628.      `REGEXP' and `RLIKE' use the current character set (ISO-8859-1
  10629.      Latin1 by default) when deciding the type of a character.
  10630.  
  10631. `expr NOT REGEXP pat'
  10632. `expr NOT RLIKE pat'
  10633.      Same as `NOT (expr REGEXP pat)'.
  10634.  
  10635. `STRCMP(expr1,expr2)'
  10636.      `STRCMP()' returns `0' if the strings are the same, `-1' if the
  10637.      first argument is smaller than the second according to the current
  10638.      sort order, and `1' otherwise.
  10639.  
  10640.           mysql> select STRCMP('text', 'text2');
  10641.                   -> -1
  10642.           mysql> select STRCMP('text2', 'text');
  10643.                   -> 1
  10644.           mysql> select STRCMP('text', 'text');
  10645.                   -> 0
  10646.  
  10647. Cast operators
  10648. --------------
  10649.  
  10650. ``BINARY''
  10651.      The `BINARY' operator casts the string following it to a binary
  10652.      string.  This is an easy way to force a column comparison to be
  10653.      case sensitive even if the column isn't defined as `BINARY' or
  10654.      `BLOB'.
  10655.           mysql> select "a" = "A";
  10656.                   -> 1
  10657.           mysql> select BINARY "a" = "A";
  10658.                   -> 0
  10659.  
  10660.      `BINARY' was introduced in *MySQL* 3.23.0
  10661.  
  10662. Control flow functions
  10663. ----------------------
  10664.  
  10665. `IFNULL(expr1,expr2)'
  10666.      If `expr1' is not `NULL', `IFNULL()' returns `expr1', else it
  10667.      returns `expr2'.  `IFNULL()' returns a numeric or string value,
  10668.      depending on the context in which it is used.
  10669.           mysql> select IFNULL(1,0);
  10670.                   -> 1
  10671.           mysql> select IFNULL(NULL,10);
  10672.                   -> 10
  10673.           mysql> select IFNULL(1/0,10);
  10674.                   -> 10
  10675.           mysql> select IFNULL(1/0,'yes');
  10676.                   -> 'yes'
  10677.  
  10678. `NULLIF(expr1,expr2)'
  10679.      If `expr1 = expr2' is true, return `NULL' else return `expr1'.
  10680.      This is the same as `CASE WHEN x = y THEN NULL ELSE x END'
  10681.           mysql> select NULLIF(1,1);
  10682.                   -> NULL
  10683.           mysql> select NULLIF(1,2);
  10684.                   -> 1
  10685.  
  10686.      Note that `expr1' is evaluated twice in *MySQL* if the arguments
  10687.      are equal.
  10688.  
  10689. `IF(expr1,expr2,expr3)'
  10690.      If `expr1' is TRUE (`expr1 <> 0' and `expr1 <> NULL') then `IF()'
  10691.      returns `expr2', else it returns `expr3'.  `IF()' returns a
  10692.      numeric or string value, depending on the context in which it is
  10693.      used.
  10694.  
  10695.           mysql> select IF(1>2,2,3);
  10696.                   -> 3
  10697.           mysql> select IF(1<2,'yes','no');
  10698.                   -> 'yes'
  10699.           mysql> select IF(strcmp('test','test1'),'no','yes');
  10700.                   -> 'no'
  10701.  
  10702.      `expr1' is evaluated as an integer value, which means that if you
  10703.      are testing floating-point or string values, you should do so
  10704.      using a comparison operation.
  10705.  
  10706.           mysql> select IF(0.1,1,0);
  10707.                   -> 0
  10708.           mysql> select IF(0.1<>0,1,0);
  10709.                   -> 1
  10710.  
  10711.      In the first case above, `IF(0.1)' returns `0' because `0.1' is
  10712.      converted to an integer value, resulting in a test of `IF(0)'.
  10713.      This may not be what you expect.  In the second case, the
  10714.      comparison tests the original floating-point value to see whether
  10715.      it is non-zero.  The result of the comparison is used as an
  10716.      integer.
  10717.  
  10718.      The default return type of `IF()' (which may matter when it stored
  10719.      into a temporary table) is calculated in *MySQL* 3.23 as follows:
  10720.  
  10721.      expr2 or expr3 returns string                   string
  10722.      expr2 or expr3 returns a floating point value   floating point
  10723.      expr2 or expr3 returns an integer               integer
  10724.  
  10725. `CASE value WHEN [compare-value] THEN result [WHEN [compare-value] THEN result ...] [ELSE result] END'
  10726.  
  10727. `CASE WHEN [condition] THEN result [WHEN [condition] THEN result ...] [ELSE result] END'
  10728.      The first version returns the `result' where
  10729.      `value=compare-value'. The second version returns the result for
  10730.      the first condition which is true. If there was no matching result
  10731.      value, then the result after `ELSE' is returned. If there is no
  10732.      `ELSE' part then `NULL' is returned.
  10733.  
  10734.           mysql> SELECT CASE 1 WHEN 1 THEN "one" WHEN 2 THEN "two" ELSE "more" END;
  10735.                  -> "one"
  10736.           mysql> SELECT CASE WHEN 1>0 THEN "true" ELSE "false" END;
  10737.                  -> "true"
  10738.           mysql> SELECT CASE BINARY "B" when "a" then 1 when "b" then 2 END;
  10739.                  -> NULL
  10740.  
  10741. Mathematical functions
  10742. ----------------------
  10743.  
  10744. All mathematical functions return `NULL' in case of an error.
  10745.  
  10746. `-'
  10747.      Unary minus. Changes the sign of the argument.
  10748.           mysql> select - 2;
  10749.                   -> -2
  10750.  
  10751.      Note that if this operator is used with a `BIGINT', the return
  10752.      value is a `BIGINT'!  This means that you should avoid using `-'
  10753.      on integers that may have the value of `-2^63'!
  10754.  
  10755. `ABS(X)'
  10756.      Returns the absolute value of `X'.
  10757.           mysql> select ABS(2);
  10758.                   -> 2
  10759.           mysql> select ABS(-32);
  10760.                   -> 32
  10761.  
  10762.      This function is safe to use with `BIGINT' values.
  10763.  
  10764. `SIGN(X)'
  10765.      Returns the sign of the argument as `-1', `0' or `1', depending on
  10766.      whether `X' is negative, zero, or positive.
  10767.           mysql> select SIGN(-32);
  10768.                   -> -1
  10769.           mysql> select SIGN(0);
  10770.                   -> 0
  10771.           mysql> select SIGN(234);
  10772.                   -> 1
  10773.  
  10774. `MOD(N,M)'
  10775. `%'
  10776.      Modulo (like the `%' operator in C).  Returns the remainder of `N'
  10777.      divided by `M'.
  10778.           mysql> select MOD(234, 10);
  10779.                   -> 4
  10780.           mysql> select 253 % 7;
  10781.                   -> 1
  10782.           mysql> select MOD(29,9);
  10783.                   -> 2
  10784.  
  10785.      This function is safe to use with `BIGINT' values.
  10786.  
  10787. `FLOOR(X)'
  10788.      Returns the largest integer value not greater than `X'.
  10789.           mysql> select FLOOR(1.23);
  10790.                   -> 1
  10791.           mysql> select FLOOR(-1.23);
  10792.                   -> -2
  10793.  
  10794.      Note that the return value is converted to a `BIGINT'!
  10795.  
  10796. `CEILING(X)'
  10797.      Returns the smallest integer value not less than `X'.
  10798.           mysql> select CEILING(1.23);
  10799.                   -> 2
  10800.           mysql> select CEILING(-1.23);
  10801.                   -> -1
  10802.  
  10803.      Note that the return value is converted to a `BIGINT'!
  10804.  
  10805. `ROUND(X)'
  10806.      Returns the argument `X', rounded to the nearest integer.
  10807.           mysql> select ROUND(-1.23);
  10808.                   -> -1
  10809.           mysql> select ROUND(-1.58);
  10810.                   -> -2
  10811.           mysql> select ROUND(1.58);
  10812.                   -> 2
  10813.  
  10814. `ROUND(X,D)'
  10815.      Returns the argument `X', rounded to a number with `D' decimals.
  10816.      If `D' is `0', the result will have no decimal point or fractional
  10817.      part.
  10818.  
  10819.           mysql> select ROUND(1.298, 1);
  10820.                   -> 1.3
  10821.           mysql> select ROUND(1.298, 0);
  10822.                   -> 1
  10823.  
  10824. `EXP(X)'
  10825.      Returns the value of `e' (the base of natural logarithms) raised to
  10826.      the power of `X'.
  10827.           mysql> select EXP(2);
  10828.                   -> 7.389056
  10829.           mysql> select EXP(-2);
  10830.                   -> 0.135335
  10831.  
  10832. `LOG(X)'
  10833.      Returns the natural logarithm of `X'.
  10834.           mysql> select LOG(2);
  10835.                   -> 0.693147
  10836.           mysql> select LOG(-2);
  10837.                   -> NULL
  10838.      If you want the log of a number `X' to some arbitary base `B', use
  10839.      the formula `LOG(X)/LOG(B)'.
  10840.  
  10841. `LOG10(X)'
  10842.      Returns the base-10 logarithm of `X'.
  10843.           mysql> select LOG10(2);
  10844.                   -> 0.301030
  10845.           mysql> select LOG10(100);
  10846.                   -> 2.000000
  10847.           mysql> select LOG10(-100);
  10848.                   -> NULL
  10849.  
  10850. `POW(X,Y)'
  10851. `POWER(X,Y)'
  10852.      Returns the value of `X' raised to the power of `Y'.
  10853.           mysql> select POW(2,2);
  10854.                   -> 4.000000
  10855.           mysql> select POW(2,-2);
  10856.                   -> 0.250000
  10857.  
  10858. `SQRT(X)'
  10859.      Returns the non-negative square root of `X'.
  10860.           mysql> select SQRT(4);
  10861.                   -> 2.000000
  10862.           mysql> select SQRT(20);
  10863.                   -> 4.472136
  10864.  
  10865. `PI()'
  10866.      Returns the value of PI.
  10867.           mysql> select PI();
  10868.                   -> 3.141593
  10869.  
  10870. `COS(X)'
  10871.      Returns the cosine of `X', where `X' is given in radians.
  10872.           mysql> select COS(PI());
  10873.                   -> -1.000000
  10874.  
  10875. `SIN(X)'
  10876.      Returns the sine of `X', where `X' is given in radians.
  10877.           mysql> select SIN(PI());
  10878.                   -> 0.000000
  10879.  
  10880. `TAN(X)'
  10881.      Returns the tangent of `X', where `X' is given in radians.
  10882.           mysql> select TAN(PI()+1);
  10883.                   -> 1.557408
  10884.  
  10885. `ACOS(X)'
  10886.      Returns the arc cosine of `X', that is, the value whose cosine is
  10887.      `X'. Returns `NULL' if `X' is not in the range `-1' to `1'.
  10888.           mysql> select ACOS(1);
  10889.                   -> 0.000000
  10890.           mysql> select ACOS(1.0001);
  10891.                   -> NULL
  10892.           mysql> select ACOS(0);
  10893.                   -> 1.570796
  10894.  
  10895. `ASIN(X)'
  10896.      Returns the arc sine of `X', that is, the value whose sine is `X'.
  10897.      Returns `NULL' if `X' is not in the range `-1' to `1'.
  10898.           mysql> select ASIN(0.2);
  10899.                   -> 0.201358
  10900.           mysql> select ASIN('foo');
  10901.                   -> 0.000000
  10902.  
  10903. `ATAN(X)'
  10904.      Returns the arc tangent of `X', that is, the value whose tangent is
  10905.      `X'.
  10906.           mysql> select ATAN(2);
  10907.                   -> 1.107149
  10908.           mysql> select ATAN(-2);
  10909.                   -> -1.107149
  10910.  
  10911. `ATAN2(X,Y)'
  10912.      Returns the arc tangent of the two variables `X' and `Y'. It is
  10913.      similar to calculating the arc tangent of `Y / X', except that the
  10914.      signs of both arguments are used to determine the quadrant of the
  10915.      result.
  10916.           mysql> select ATAN(-2,2);
  10917.                   -> -0.785398
  10918.           mysql> select ATAN(PI(),0);
  10919.                   -> 1.570796
  10920.  
  10921. `COT(X)'
  10922.      Returns the cotangent of `X'.
  10923.           mysql> select COT(12);
  10924.                   -> -1.57267341
  10925.           mysql> select COT(0);
  10926.                   -> NULL
  10927.  
  10928. `RAND()'
  10929. `RAND(N)'
  10930.      Returns a random floating-point value in the range `0' to `1.0'.
  10931.      If an integer argument `N' is specified, it is used as the seed
  10932.      value.
  10933.           mysql> select RAND();
  10934.                   -> 0.5925
  10935.           mysql> select RAND(20);
  10936.                   -> 0.1811
  10937.           mysql> select RAND(20);
  10938.                   -> 0.1811
  10939.           mysql> select RAND();
  10940.                   -> 0.2079
  10941.           mysql> select RAND();
  10942.                   -> 0.7888
  10943.      You can't use a column with `RAND()' values in an `ORDER BY'
  10944.      clause, because `ORDER BY' would evaluate the column multiple
  10945.      times.  In *MySQL* 3.23, you can however do: `SELECT * FROM
  10946.      table_name ORDER BY RAND()'
  10947.  
  10948.      This is useful to get a random sample of a set `SELECT * FROM
  10949.      table1,table2 WHERE a=b AND c<d ORDER BY RAND() LIMIT 1000'.
  10950.  
  10951.      Note that a `RAND()' in a `WHERE' clause will be re-evaluated
  10952.      every time the `WHERE' is executed.
  10953.  
  10954. `LEAST(X,Y,...)'
  10955.      With two or more arguments, returns the smallest (minimum-valued)
  10956.      argument.  The arguments are compared using the following rules:
  10957.  
  10958.         * If the return value is used in an `INTEGER' context, or all
  10959.           arguments are integer-valued, they are compared as integers.
  10960.  
  10961.         * If the return value is used in a `REAL' context, or all
  10962.           arguments are real-valued, they are compared as reals.
  10963.  
  10964.         * If any argument is a case-sensitive string, the arguments are
  10965.           compared as case-sensitive strings.
  10966.  
  10967.         * In other cases, the arguments are compared as
  10968.           case-insensitive strings.
  10969.  
  10970.           mysql> select LEAST(2,0);
  10971.                   -> 0
  10972.           mysql> select LEAST(34.0,3.0,5.0,767.0);
  10973.                   -> 3.0
  10974.           mysql> select LEAST("B","A","C");
  10975.                   -> "A"
  10976.      In *MySQL* versions prior to 3.22.5, you can use `MIN()' instead
  10977.      of `LEAST'.
  10978.  
  10979. `GREATEST(X,Y,...)'
  10980.      Returns the largest (maximum-valued) argument.  The arguments are
  10981.      compared using the same rules as for `LEAST'.
  10982.           mysql> select GREATEST(2,0);
  10983.                   -> 2
  10984.           mysql> select GREATEST(34.0,3.0,5.0,767.0);
  10985.                   -> 767.0
  10986.           mysql> select GREATEST("B","A","C");
  10987.                   -> "C"
  10988.      In *MySQL* versions prior to 3.22.5, you can use `MAX()' instead
  10989.      of `GREATEST'.
  10990.  
  10991. `DEGREES(X)'
  10992.      Returns the argument `X', converted from radians to degrees.
  10993.           mysql> select DEGREES(PI());
  10994.                   -> 180.000000
  10995.  
  10996. `RADIANS(X)'
  10997.      Returns the argument `X', converted from degrees to radians.
  10998.           mysql> select RADIANS(90);
  10999.                   -> 1.570796
  11000.  
  11001. `TRUNCATE(X,D)'
  11002.      Returns the number `X', truncated to `D' decimals.  If `D' is `0',
  11003.      the result will have no decimal point or fractional part.
  11004.           mysql> select TRUNCATE(1.223,1);
  11005.                   -> 1.2
  11006.           mysql> select TRUNCATE(1.999,1);
  11007.                   -> 1.9
  11008.           mysql> select TRUNCATE(1.999,0);
  11009.                   -> 1
  11010.  
  11011. String functions
  11012. ----------------
  11013.  
  11014. String-valued functions return `NULL' if the length of the result would
  11015. be greater than the `max_allowed_packet' server parameter.  *Note
  11016. Server parameters::.
  11017.  
  11018. For functions that operate on string positions, the first position is
  11019. numbered 1.
  11020.  
  11021. `ASCII(str)'
  11022.      Returns the ASCII code value of the leftmost character of the
  11023.      string `str'. Returns `0' if `str' is the empty string.  Returns
  11024.      `NULL' if `str' is `NULL'.
  11025.  
  11026.           mysql> select ASCII('2');
  11027.                   -> 50
  11028.           mysql> select ASCII(2);
  11029.                   -> 50
  11030.           mysql> select ASCII('dx');
  11031.                   -> 100
  11032.  
  11033.      See also the `ORD()' function.
  11034.  
  11035. `ORD(str)'
  11036.      If the leftmost character of the string str is a multi-byte
  11037.      character, returns the code of multi-byte character by returning
  11038.      the ASCII code value of the character in the format of: `((first
  11039.      byte ASCII code)*256+(second byte ASCII code))[*256+third byte
  11040.      ASCII code...]'.  If the leftmost character is not a multi-byte
  11041.      character, returns the same value as the like `ASCII()' function
  11042.      does.
  11043.  
  11044.           mysql> select ORD('2');
  11045.                   -> 50
  11046.  
  11047. `CONV(N,from_base,to_base)'
  11048.      Converts numbers between different number bases.  Returns a string
  11049.      representation of the number `N', converted from base `from_base'
  11050.      to base `to_base'.  Returns `NULL' if any argument is `NULL'.  The
  11051.      argument `N' is interpreted as an integer, but may be specified as
  11052.      an integer or a string.  The minimum base is `2' and the maximum
  11053.      base is `36'.  If `to_base' is a negative number, `N' is regarded
  11054.      as a signed number.  Otherwise, `N' is treated as unsigned.
  11055.      `CONV' works with 64-bit precision.
  11056.  
  11057.           mysql> select CONV("a",16,2);
  11058.                   -> '1010'
  11059.           mysql> select CONV("6E",18,8);
  11060.                   -> '172'
  11061.           mysql> select CONV(-17,10,-18);
  11062.                   -> '-H'
  11063.           mysql> select CONV(10+"10"+'10'+0xa,10,10);
  11064.                   -> '40'
  11065.  
  11066. `BIN(N)'
  11067.      Returns a string representation of the binary value of `N', where
  11068.      `N' is a longlong (`BIGINT') number.  This is equivalent to
  11069.      `CONV(N,10,2)'.  Returns `NULL' if `N' is `NULL'.
  11070.  
  11071.           mysql> select BIN(12);
  11072.                   -> '1100'
  11073.  
  11074. `OCT(N)'
  11075.      Returns a string representation of the octal value of `N', where
  11076.      `N' is a longlong number.  This is equivalent to `CONV(N,10,8)'.
  11077.      Returns `NULL' if `N' is `NULL'.
  11078.  
  11079.           mysql> select OCT(12);
  11080.                   -> '14'
  11081.  
  11082. `HEX(N)'
  11083.      Returns a string representation of the hexadecimal value of `N',
  11084.      where `N' is a longlong (`BIGINT') number.  This is equivalent to
  11085.      `CONV(N,10,16)'.  Returns `NULL' if `N' is `NULL'.
  11086.  
  11087.           mysql> select HEX(255);
  11088.                   -> 'FF'
  11089.  
  11090. `CHAR(N,...)'
  11091.      `CHAR()' interprets the arguments as integers and returns a string
  11092.      consisting of the characters given by the ASCII code values of
  11093.      those integers. `NULL' values are skipped.
  11094.  
  11095.           mysql> select CHAR(77,121,83,81,'76');
  11096.                   -> 'MySQL'
  11097.           mysql> select CHAR(77,77.3,'77.3');
  11098.                   -> 'MMM'
  11099.  
  11100. `CONCAT(str1,str2,...)'
  11101.      Returns the string that results from concatenating the arguments.
  11102.      Returns `NULL' if any argument is `NULL'.  May have more than 2
  11103.      arguments.  A numeric argument is converted to the equivalent
  11104.      string form.
  11105.           mysql> select CONCAT('My', 'S', 'QL');
  11106.                   -> 'MySQL'
  11107.           mysql> select CONCAT('My', NULL, 'QL');
  11108.                   -> NULL
  11109.           mysql> select CONCAT(14.3);
  11110.                   -> '14.3'
  11111.  
  11112. `CONCAT_WS(separator, str1, str2,...)'
  11113.      `CONCAT_WS()' stands for CONCAT With Separator and is a special
  11114.      form of `CONCAT()'.  The irst argument is the separator for the
  11115.      rest of the arguments. The separator can be a string as well as
  11116.      the rest of the arguments. If the separator is `NULL', the result
  11117.      will be `NULL'.  The function will skip any `NULL's and empty
  11118.      strings, after the separator argument. The separator will be added
  11119.      between the strings to be concatenated.
  11120.           mysql> select CONCAT_WS(",","First name","Second name","Last Name");
  11121.                  -> 'First name,Second name,Last Name'
  11122.           mysql> select CONCAT_WS(",","First name",NULL,"Last Name");
  11123.                  -> 'First name,Last Name'
  11124.  
  11125. `LENGTH(str)'
  11126. `OCTET_LENGTH(str)'
  11127. `CHAR_LENGTH(str)'
  11128. `CHARACTER_LENGTH(str)'
  11129.      Returns the length of the string `str'.
  11130.           mysql> select LENGTH('text');
  11131.                   -> 4
  11132.           mysql> select OCTET_LENGTH('text');
  11133.                   -> 4
  11134.  
  11135.      Note that for `CHAR_LENGTH()', multi-byte characters are only
  11136.      counted once.
  11137.  
  11138. `LOCATE(substr,str)'
  11139. `POSITION(substr IN str)'
  11140.      Returns the position of the first occurrence of substring `substr'
  11141.      in string `str'. Returns `0' if `substr' is not in `str'.
  11142.           mysql> select LOCATE('bar', 'foobarbar');
  11143.                   -> 4
  11144.           mysql> select LOCATE('xbar', 'foobar');
  11145.                   -> 0
  11146.  
  11147.      This function is multi-byte safe.
  11148.  
  11149. `LOCATE(substr,str,pos)'
  11150.      Returns the position of the first occurrence of substring `substr'
  11151.      in string `str', starting at position `pos'.  Returns `0' if
  11152.      `substr' is not in `str'.
  11153.           mysql> select LOCATE('bar', 'foobarbar',5);
  11154.                   -> 7
  11155.  
  11156.      This function is multi-byte safe.
  11157.  
  11158. `INSTR(str,substr)'
  11159.      Returns the position of the first occurrence of substring `substr'
  11160.      in string `str'. This is the same as the two-argument form of
  11161.      `LOCATE()', except that the arguments are swapped.
  11162.  
  11163.           mysql> select INSTR('foobarbar', 'bar');
  11164.                   -> 4
  11165.           mysql> select INSTR('xbar', 'foobar');
  11166.                   -> 0
  11167.  
  11168.      This function is multi-byte safe.
  11169.  
  11170. `LPAD(str,len,padstr)'
  11171.      Returns the string `str', left-padded with the string `padstr'
  11172.      until `str' is `len' characters long.
  11173.           mysql> select LPAD('hi',4,'??');
  11174.                   -> '??hi'
  11175.  
  11176. `RPAD(str,len,padstr)'
  11177.      Returns the string `str', right-padded with the string `padstr'
  11178.      until `str' is `len' characters long.
  11179.           mysql> select RPAD('hi',5,'?');
  11180.                   -> 'hi???'
  11181.  
  11182. `LEFT(str,len)'
  11183.      Returns the leftmost `len' characters from the string `str'.
  11184.           mysql> select LEFT('foobarbar', 5);
  11185.                   -> 'fooba'
  11186.  
  11187.      This function is multi-byte safe.
  11188.  
  11189. `RIGHT(str,len)'
  11190.      Returns the rightmost `len' characters from the string `str'.
  11191.           mysql> select RIGHT('foobarbar', 4);
  11192.                   -> 'rbar'
  11193.  
  11194.      This function is multi-byte safe.
  11195.  
  11196. `SUBSTRING(str,pos,len)'
  11197. `SUBSTRING(str FROM pos FOR len)'
  11198. `MID(str,pos,len)'
  11199.      Returns a substring `len' characters long from string `str',
  11200.      starting at position `pos'.  The variant form that uses `FROM' is
  11201.      ANSI SQL92 syntax.
  11202.           mysql> select SUBSTRING('Quadratically',5,6);
  11203.                   -> 'ratica'
  11204.  
  11205.      This function is multi-byte safe.
  11206.  
  11207. `SUBSTRING(str,pos)'
  11208.  
  11209. `SUBSTRING(str FROM pos)'
  11210.      Returns a substring from string `str' starting at position `pos'.
  11211.           mysql> select SUBSTRING('Quadratically',5);
  11212.                   -> 'ratically'
  11213.           mysql> select SUBSTRING('foobarbar' FROM 4);
  11214.                   -> 'barbar'
  11215.  
  11216.      This function is multi-byte safe.
  11217.  
  11218. `SUBSTRING_INDEX(str,delim,count)'
  11219.      Returns the substring from string `str' before `count' occurrences
  11220.      of the delimiter `delim'.  If `count' is positive, everything to
  11221.      the left of the final delimiter (counting from the left) is
  11222.      returned.  If `count' is negative, everything to the right of the
  11223.      final delimiter (counting from the right) is returned.
  11224.           mysql> select SUBSTRING_INDEX('www.mysql.com', '.', 2);
  11225.                   -> 'www.mysql'
  11226.           mysql> select SUBSTRING_INDEX('www.mysql.com', '.', -2);
  11227.                   -> 'mysql.com'
  11228.  
  11229.      This function is multi-byte safe.
  11230.  
  11231. `LTRIM(str)'
  11232.      Returns the string `str' with leading space characters removed.
  11233.           mysql> select LTRIM('  barbar');
  11234.                   -> 'barbar'
  11235.  
  11236. `RTRIM(str)'
  11237.      Returns the string `str' with trailing space characters removed.
  11238.           mysql> select RTRIM('barbar   ');
  11239.                   -> 'barbar'
  11240.  
  11241.      This function is multi-byte safe.
  11242.  
  11243. `TRIM([[BOTH | LEADING | TRAILING] [remstr] FROM] str)'
  11244.      Returns the string `str' with all `remstr' prefixes and/or suffixes
  11245.      removed. If none of the specifiers `BOTH', `LEADING' or `TRAILING'
  11246.      are given, `BOTH' is assumed. If `remstr' is not specified, spaces
  11247.      are removed.
  11248.           mysql> select TRIM('  bar   ');
  11249.                   -> 'bar'
  11250.           mysql> select TRIM(LEADING 'x' FROM 'xxxbarxxx');
  11251.                   -> 'barxxx'
  11252.           mysql> select TRIM(BOTH 'x' FROM 'xxxbarxxx');
  11253.                   -> 'bar'
  11254.           mysql> select TRIM(TRAILING 'xyz' FROM 'barxxyz');
  11255.                   -> 'barx'
  11256.  
  11257.      This function is multi-byte safe.
  11258.  
  11259. `SOUNDEX(str)'
  11260.      Returns a soundex string from `str'. Two strings that sound "about
  11261.      the same" should have identical soundex strings. A "standard"
  11262.      soundex string is 4 characters long, but the `SOUNDEX()' function
  11263.      returns an arbitrarily long string. You can use `SUBSTRING()' on
  11264.      the result to get a "standard" soundex string.  All
  11265.      non-alphanumeric characters are ignored in the given string. All
  11266.      international alpha characters outside the A-Z range are treated
  11267.      as vowels.
  11268.  
  11269.           mysql> select SOUNDEX('Hello');
  11270.                   -> 'H400'
  11271.           mysql> select SOUNDEX('Quadratically');
  11272.                   -> 'Q36324'
  11273.  
  11274. `SPACE(N)'
  11275.      Returns a string consisting of `N' space characters.
  11276.           mysql> select SPACE(6);
  11277.                   -> '      '
  11278.  
  11279. `REPLACE(str,from_str,to_str)'
  11280.      Returns the string `str' with all all occurrences of the string
  11281.      `from_str' replaced by the string `to_str'.
  11282.  
  11283.           mysql> select REPLACE('www.mysql.com', 'w', 'Ww');
  11284.                   -> 'WwWwWw.mysql.com'
  11285.  
  11286.      This function is multi-byte safe.
  11287.  
  11288. `REPEAT(str,count)'
  11289.      Returns a string consisting of the string `str' repeated `count'
  11290.      times. If `count <= 0', returns an empty string. Returns `NULL' if
  11291.      `str' or `count' are `NULL'.
  11292.  
  11293.           mysql> select REPEAT('MySQL', 3);
  11294.                   -> 'MySQLMySQLMySQL'
  11295.  
  11296. `REVERSE(str)'
  11297.      Returns the string `str' with the order of the characters reversed.
  11298.           mysql> select REVERSE('abc');
  11299.                   -> 'cba'
  11300.  
  11301.      This function is multi-byte safe.
  11302.  
  11303. `INSERT(str,pos,len,newstr)'
  11304.      Returns the string `str', with the substring beginning at position
  11305.      `pos' and `len' characters long replaced by the string `newstr'.
  11306.  
  11307.           mysql> select INSERT('Quadratic', 3, 4, 'What');
  11308.                   -> 'QuWhattic'
  11309.  
  11310.      This function is multi-byte safe.
  11311.  
  11312. `ELT(N,str1,str2,str3,...)'
  11313.      Returns `str1' if `N' = `1', `str2' if `N' = `2', and so on.
  11314.      Returns `NULL' if `N' is less than `1' or greater than the number
  11315.      of arguments.  `ELT()' is the complement of `FIELD()'.
  11316.  
  11317.           mysql> select ELT(1, 'ej', 'Heja', 'hej', 'foo');
  11318.                   -> 'ej'
  11319.           mysql> select ELT(4, 'ej', 'Heja', 'hej', 'foo');
  11320.                   -> 'foo'
  11321.  
  11322. `FIELD(str,str1,str2,str3,...)'
  11323.      Returns the index of `str' in the `str1', `str2', `str3', `...'
  11324.      list.  Returns `0' if `str' is not found.  `FIELD()' is the
  11325.      complement of `ELT()'.
  11326.  
  11327.           mysql> select FIELD('ej', 'Hej', 'ej', 'Heja', 'hej', 'foo');
  11328.                   -> 2
  11329.           mysql> select FIELD('fo', 'Hej', 'ej', 'Heja', 'hej', 'foo');
  11330.                   -> 0
  11331.  
  11332. `FIND_IN_SET(str,strlist)'
  11333.      Returns a value `1' to `N' if the string `str' is in the list
  11334.      `strlist' consisting of `N' substrings. A string list is a string
  11335.      composed of substrings separated by `,' characters. If the first
  11336.      argument is a constant string and the second is a column of type
  11337.      `SET', the `FIND_IN_SET()' function is optimized to use bit
  11338.      arithmetic!  Returns `0' if `str' is not in `strlist' or if
  11339.      `strlist' is the empty string.  Returns `NULL' if either argument
  11340.      is `NULL'.  This function will not work properly if the first
  11341.      argument contains a `,'.
  11342.  
  11343.           mysql> SELECT FIND_IN_SET('b','a,b,c,d');
  11344.                   -> 2
  11345.  
  11346. `MAKE_SET(bits,str1,str2,...)'
  11347.      Returns a set (a string containing substrings separated by `,'
  11348.      characters) consisting of the strings that have the corresponding
  11349.      bit in `bits' set.  `str1' corresponds to bit 0, `str2' to bit 1,
  11350.      etc.  `NULL' strings in `str1', `str2', `...' are not appended to
  11351.      the result.
  11352.  
  11353.           mysql> SELECT MAKE_SET(1,'a','b','c');
  11354.                   -> 'a'
  11355.           mysql> SELECT MAKE_SET(1 | 4,'hello','nice','world');
  11356.                   -> 'hello,world'
  11357.           mysql> SELECT MAKE_SET(0,'a','b','c');
  11358.                   -> ''
  11359.  
  11360. `EXPORT_SET(bits,on,off,[separator,[number_of_bits]])'
  11361.      Returns a string where for every bit set in 'bit', you get a 'on'
  11362.      string and for every reset bit you get an 'off' string. Each
  11363.      string is separated with 'separator' (default ',') and only
  11364.      'number_of_bits' (default 64) of 'bits' is used.
  11365.  
  11366.           mysql> select EXPORT_SET(5,'Y','N',',',4)
  11367.                   -> Y,N,Y,N
  11368.  
  11369. `LCASE(str)'
  11370. `LOWER(str)'
  11371.      Returns the string `str' with all characters changed to lowercase
  11372.      according to the current character set mapping (the default is
  11373.      ISO-8859-1 Latin1).
  11374.  
  11375.      This function is multi-byte safe.
  11376.  
  11377.           mysql> select LCASE('QUADRATICALLY');
  11378.                   -> 'quadratically'
  11379.  
  11380. `UCASE(str)'
  11381. `UPPER(str)'
  11382.      Returns the string `str' with all characters changed to uppercase
  11383.      according to the current character set mapping (the default is
  11384.      ISO-8859-1 Latin1).
  11385.  
  11386.           mysql> select UCASE('Hej');
  11387.                   -> 'HEJ'
  11388.  
  11389.      This function is multi-byte safe.
  11390.  
  11391. `LOAD_FILE(file_name)'
  11392.      Reads the file and returns the file contents as a string.  The file
  11393.      must be on the server, you must specify the full pathname to the
  11394.      file, and you must have the *file* privilege.  The file must be
  11395.      readable by all and be smaller than `max_allowed_packet'.
  11396.  
  11397.      If the file doesn't exist or can't be read due to one of the above
  11398.      reasons, the function returns `NULL'.
  11399.  
  11400.           mysql> UPDATE table_name
  11401.                      SET blob_column=LOAD_FILE("/tmp/picture")
  11402.                      WHERE id=1;
  11403.  
  11404. If you are not using *MySQL 3.23*, you have to do the reading of the
  11405. file inside your application and create an `INSERT' statement to update
  11406. the database with the file information. One way to do this, if you are
  11407. using the *MySQL*++ library, can be found at
  11408. `http://www.mysql.com/documentation/mysql++/mysql++-examples.html'.
  11409.  
  11410. *MySQL* automatically converts numbers to strings as necessary, and
  11411. vice versa:
  11412.  
  11413.      mysql> SELECT 1+"1";
  11414.              -> 2
  11415.      mysql> SELECT CONCAT(2,' test');
  11416.              -> '2 test'
  11417.  
  11418. If you want to convert a number to a string explicitly, pass it as the
  11419. argument to `CONCAT()'.
  11420.  
  11421. If a string function is given a binary string as an argument, the
  11422. resulting string is also a binary string.  A number converted to a
  11423. string is treated as a binary string.  This only affects comparisons.
  11424.  
  11425. Date and time functions
  11426. -----------------------
  11427.  
  11428. See *Note Date and time types:: for a description of the range of values
  11429. each type has, and the valid formats in which date and time values may
  11430. be specified.
  11431.  
  11432. Here is an example that uses date functions.  The query below selects
  11433. all records with a `date_col' value from within the last 30 days:
  11434.  
  11435.      mysql> SELECT something FROM table
  11436.                 WHERE TO_DAYS(NOW()) - TO_DAYS(date_col) <= 30;
  11437.  
  11438. `DAYOFWEEK(date)'
  11439.      Returns the weekday index for `date' (`1' = Sunday, `2' = Monday,
  11440.      ... `7' = Saturday).  These index values correspond to the ODBC
  11441.      standard.
  11442.           mysql> select DAYOFWEEK('1998-02-03');
  11443.                   -> 3
  11444.  
  11445. `WEEKDAY(date)'
  11446.      Returns the weekday index for `date' (`0' = Monday, `1' = Tuesday,
  11447.      ... `6' = Sunday).
  11448.           mysql> select WEEKDAY('1997-10-04 22:23:00');
  11449.                   -> 5
  11450.           mysql> select WEEKDAY('1997-11-05');
  11451.                   -> 2
  11452.  
  11453. `DAYOFMONTH(date)'
  11454.      Returns the day of the month for `date', in the range `1' to `31'.
  11455.           mysql> select DAYOFMONTH('1998-02-03');
  11456.                   -> 3
  11457.  
  11458. `DAYOFYEAR(date)'
  11459.      Returns the day of the year for `date', in the range `1' to `366'.
  11460.           mysql> select DAYOFYEAR('1998-02-03');
  11461.                   -> 34
  11462.  
  11463. `MONTH(date)'
  11464.      Returns the month for `date', in the range `1' to `12'.
  11465.           mysql> select MONTH('1998-02-03');
  11466.                   -> 2
  11467.  
  11468. `DAYNAME(date)'
  11469.      Returns the name of the weekday for `date'.
  11470.           mysql> select DAYNAME("1998-02-05");
  11471.                   -> 'Thursday'
  11472.  
  11473. `MONTHNAME(date)'
  11474.      Returns the name of the month for `date'.
  11475.           mysql> select MONTHNAME("1998-02-05");
  11476.                   -> 'February'
  11477.  
  11478. `QUARTER(date)'
  11479.      Returns the quarter of the year for `date', in the range `1' to
  11480.      `4'.
  11481.           mysql> select QUARTER('98-04-01');
  11482.                   -> 2
  11483.  
  11484. `WEEK(date)'
  11485. `WEEK(date,first)'
  11486.      With a single argument, returns the week for `date', in the range
  11487.      `0' to `53' (yes, there may be the beginnings of a week 53), for
  11488.      locations where Sunday is the first day of the week.  The
  11489.      two-argument form of `WEEK()' allows you to specify whether the
  11490.      week starts on Sunday or Monday.  The week starts on Sunday if the
  11491.      second argument is `0', on Monday if the second argument is `1'.
  11492.           mysql> select WEEK('1998-02-20');
  11493.                   -> 7
  11494.           mysql> select WEEK('1998-02-20',0);
  11495.                   -> 7
  11496.           mysql> select WEEK('1998-02-20',1);
  11497.                   -> 8
  11498.           mysql> select WEEK('1998-12-31',1);
  11499.                   -> 53
  11500.  
  11501. `YEAR(date)'
  11502.      Returns the year for `date', in the range `1000' to `9999'.
  11503.           mysql> select YEAR('98-02-03');
  11504.                   -> 1998
  11505.  
  11506. `YEARWEEK(date)'
  11507. `YEARWEEK(date,first)'
  11508.      Returns year and week for a date.  The second arguments works
  11509.      exactly like the second argument to `WEEK()'.  Note that the year
  11510.      may be different from the year in the date argument for the first
  11511.      and the last week of the year!
  11512.           mysql> select YEARWEEK('1987-01-01');
  11513.                   -> 198653
  11514.  
  11515. `HOUR(time)'
  11516.      Returns the hour for `time', in the range `0' to `23'.
  11517.           mysql> select HOUR('10:05:03');
  11518.                   -> 10
  11519.  
  11520. `MINUTE(time)'
  11521.      Returns the minute for `time', in the range `0' to `59'.
  11522.           mysql> select MINUTE('98-02-03 10:05:03');
  11523.                   -> 5
  11524.  
  11525. `SECOND(time)'
  11526.      Returns the second for `time', in the range `0' to `59'.
  11527.           mysql> select SECOND('10:05:03');
  11528.                   -> 3
  11529.  
  11530. `PERIOD_ADD(P,N)'
  11531.      Adds `N' months to period `P' (in the format `YYMM' or `YYYYMM').
  11532.      Returns a value in the format `YYYYMM'.
  11533.  
  11534.      Note that the period argument `P' is _not_ a date value.
  11535.  
  11536.           mysql> select PERIOD_ADD(9801,2);
  11537.                   -> 199803
  11538.  
  11539. `PERIOD_DIFF(P1,P2)'
  11540.      Returns the number of months between periods `P1' and `P2'.  `P1'
  11541.      and `P2' should be in the format `YYMM' or `YYYYMM'.
  11542.  
  11543.      Note that the period arguments `P1' and `P2' are _not_ date values.
  11544.  
  11545.           mysql> select PERIOD_DIFF(9802,199703);
  11546.                   -> 11
  11547.  
  11548. `DATE_ADD(date,INTERVAL expr type)'
  11549. `DATE_SUB(date,INTERVAL expr type)'
  11550. `ADDDATE(date,INTERVAL expr type)'
  11551. `SUBDATE(date,INTERVAL expr type)'
  11552.      These functions perform date arithmetic.  They are new for *MySQL*
  11553.      3.22.  `ADDDATE()' and `SUBDATE()' are synonyms for `DATE_ADD()'
  11554.      and `DATE_SUB()'.
  11555.  
  11556.      In *MySQL* 3.23, you can use `+' and `-' instead of `DATE_ADD()'
  11557.      and `DATE_SUB()'. (See example)
  11558.  
  11559.      `date' is a `DATETIME' or `DATE' value specifying the starting
  11560.      date.  `expr' is an expression specifying the interval value to be
  11561.      added or substracted from the starting date.  `expr' is a string;
  11562.      it may start with a `-' for negative intervals.  `type' is a
  11563.      keyword indicating how the expression should be interpreted.
  11564.  
  11565.      The `EXTRACT(type FROM date)' function returns the 'type' interval
  11566.      from the date.
  11567.  
  11568.      The following table shows how the `type' and `expr' arguments are
  11569.      related:
  11570.  
  11571.      `type'       *Meaning*            *Expected* `expr' *format*
  11572.      *value*                           
  11573.      `SECOND'     Seconds              `SECONDS'
  11574.      `MINUTE'     Minutes              `MINUTES'
  11575.      `HOUR'       Hours                `HOURS'
  11576.      `DAY'        Days                 `DAYS'
  11577.      `MONTH'      Months               `MONTHS'
  11578.      `YEAR'       Years                `YEARS'
  11579.      `MINUTE_SECOND'Minutes and seconds  `"MINUTES:SECONDS"'
  11580.      `HOUR_MINUTE'Hours and minutes    `"HOURS:MINUTES"'
  11581.      `DAY_HOUR'   Days and hours       `"DAYS HOURS"'
  11582.      `YEAR_MONTH' Years and months     `"YEARS-MONTHS"'
  11583.      `HOUR_SECOND'Hours, minutes,      `"HOURS:MINUTES:SECONDS"'
  11584.      `DAY_MINUTE' Days, hours,         `"DAYS HOURS:MINUTES"'
  11585.                   minutes              
  11586.      `DAY_SECOND' Days, hours,         `"DAYS
  11587.                   minutes, seconds     HOURS:MINUTES:SECONDS"'
  11588.  
  11589.      *MySQL* allows any punctuation delimiter in the `expr' format.
  11590.      The ones shown in the table are the suggested delimiters.  If the
  11591.      `date' argument is a `DATE' value and your calculations involve
  11592.      only `YEAR', `MONTH' and `DAY' parts (that is, no time parts), the
  11593.      result is a `DATE' value.  Otherwise the result is a `DATETIME'
  11594.      value.
  11595.  
  11596.           mysql> SELECT "1997-12-31 23:59:59" + INTERVAL 1 SECOND;
  11597.                   -> 1998-01-01 00:00:00
  11598.           mysql> SELECT INTERVAL 1 DAY + "1997-12-31";
  11599.                   -> 1998-01-01
  11600.           mysql> SELECT "1998-01-01" - INTERVAL 1 SECOND;
  11601.                  -> 1997-12-31 23:59:59
  11602.           mysql> SELECT DATE_ADD("1997-12-31 23:59:59",
  11603.                                  INTERVAL 1 SECOND);
  11604.                   -> 1998-01-01 00:00:00
  11605.           mysql> SELECT DATE_ADD("1997-12-31 23:59:59",
  11606.                                  INTERVAL 1 DAY);
  11607.                   -> 1998-01-01 23:59:59
  11608.           mysql> SELECT DATE_ADD("1997-12-31 23:59:59",
  11609.                                  INTERVAL "1:1" MINUTE_SECOND);
  11610.                   -> 1998-01-01 00:01:00
  11611.           mysql> SELECT DATE_SUB("1998-01-01 00:00:00",
  11612.                                  INTERVAL "1 1:1:1" DAY_SECOND);
  11613.                   -> 1997-12-30 22:58:59
  11614.           mysql> SELECT DATE_ADD("1998-01-01 00:00:00",
  11615.                                  INTERVAL "-1 10" DAY_HOUR);
  11616.                   -> 1997-12-30 14:00:00
  11617.           mysql> SELECT DATE_SUB("1998-01-02", INTERVAL 31 DAY);
  11618.                   -> 1997-12-02
  11619.           mysql> SELECT EXTRACT(YEAR FROM "1999-07-02");
  11620.                  -> 1999
  11621.           mysql> SELECT EXTRACT(YEAR_MONTH FROM "1999-07-02 01:02:03");
  11622.                  -> 199907
  11623.           mysql> SELECT EXTRACT(DAY_MINUTE FROM "1999-07-02 01:02:03");
  11624.                  -> 20102
  11625.  
  11626.      If you specify an interval value that is too short (does not
  11627.      include all the interval parts that would be expected from the
  11628.      `type' keyword), *MySQL* assumes you have left out the leftmost
  11629.      parts of the interval value.  For example, if you specify a `type'
  11630.      of `DAY_SECOND', the value of `expr' is expected to have days,
  11631.      hours, minutes and seconds parts.  If you specify a value like
  11632.      `"1:10"', *MySQL* assumes that the days and hours parts are
  11633.      missing and the value represents minutes and seconds.  In other
  11634.      words, `"1:10" DAY_SECOND' is interpreted in such a way that it is
  11635.      equivalent to `"1:10" MINUTE_SECOND'.  This is analogous to the
  11636.      way that *MySQL* interprets `TIME' values as representing elapsed
  11637.      time rather than as time of day.
  11638.  
  11639.      If you use really incorrect dates, the result is `NULL'. If you add
  11640.      `MONTH', `YEAR_MONTH' or `YEAR' and the resulting date has a day
  11641.      that is larger than the maximum day for the new month, the day is
  11642.      adjusted to the maximum days in the new month.
  11643.  
  11644.           mysql> select DATE_ADD('1998-01-30', Interval 1 month);
  11645.                   -> 1998-02-28
  11646.  
  11647.      Note from the preceding example that the word `INTERVAL' and the
  11648.      `type' keyword are not case sensitive.
  11649.  
  11650. `TO_DAYS(date)'
  11651.      Given a date `date', returns a daynumber (the number of days since
  11652.      year 0).
  11653.  
  11654.           mysql> select TO_DAYS(950501);
  11655.                   -> 728779
  11656.           mysql> select TO_DAYS('1997-10-07');
  11657.                   -> 729669
  11658.  
  11659.      `TO_DAYS()' is not intended for use with values that precede the
  11660.      advent of the Gregorian calendar (1582), because it doesn't take
  11661.      into account the days that were lost when the calender was changed.
  11662.  
  11663. `FROM_DAYS(N)'
  11664.      Given a daynumber `N', returns a `DATE' value.
  11665.  
  11666.           mysql> select FROM_DAYS(729669);
  11667.                   -> '1997-10-07'
  11668.  
  11669.      `FROM_DAYS()' is not intended for use with values that precede the
  11670.      advent of the Gregorian calendar (1582), because it doesn't take
  11671.      into account the days that were lost when the calender was changed.
  11672.  
  11673. `DATE_FORMAT(date,format)'
  11674.      Formats the `date' value according to the `format' string. The
  11675.      following specifiers may be used in the `format' string:
  11676.      `%M'    Month name (`January'..`December')
  11677.      `%W'    Weekday name (`Sunday'..`Saturday')
  11678.      `%D'    Day of the month with english suffix (`1st', `2nd', `3rd',
  11679.              etc.)
  11680.      `%Y'    Year, numeric, 4 digits
  11681.      `%y'    Year, numeric, 2 digits
  11682.      `%X'    Year for the week where Sunday is the first day of the
  11683.              week, numeric, 4 digits, used with '%V'
  11684.      `%x'    Year for the week, where Monday is the first day of the
  11685.              week, numeric, 4 digits, used with '%v'
  11686.      `%a'    Abbreviated weekday name (`Sun'..`Sat')
  11687.      `%d'    Day of the month, numeric (`00'..`31')
  11688.      `%e'    Day of the month, numeric (`0'..`31')
  11689.      `%m'    Month, numeric (`01'..`12')
  11690.      `%c'    Month, numeric (`1'..`12')
  11691.      `%b'    Abbreviated month name (`Jan'..`Dec')
  11692.      `%j'    Day of year (`001'..`366')
  11693.      `%H'    Hour (`00'..`23')
  11694.      `%k'    Hour (`0'..`23')
  11695.      `%h'    Hour (`01'..`12')
  11696.      `%I'    Hour (`01'..`12')
  11697.      `%l'    Hour (`1'..`12')
  11698.      `%i'    Minutes, numeric (`00'..`59')
  11699.      `%r'    Time, 12-hour (`hh:mm:ss [AP]M')
  11700.      `%T'    Time, 24-hour (`hh:mm:ss')
  11701.      `%S'    Seconds (`00'..`59')
  11702.      `%s'    Seconds (`00'..`59')
  11703.      `%p'    `AM' or `PM'
  11704.      `%w'    Day of the week (`0'=Sunday..`6'=Saturday)
  11705.      `%U'    Week (`0'..`53'), where Sunday is the first day of the week
  11706.      `%u'    Week (`0'..`53'), where Monday is the first day of the week
  11707.      `%V'    Week (`1'..`53'), where Sunday is the first day of the
  11708.              week. Used with '%X'
  11709.      `%v'    Week (`1'..`53'), where Monday is the first day of the
  11710.              week. Used with '%x'
  11711.      `%%'    A literal `%'.
  11712.  
  11713.      All other characters are just copied to the result without
  11714.      interpretation.
  11715.  
  11716.           mysql> select DATE_FORMAT('1997-10-04 22:23:00', '%W %M %Y');
  11717.                   -> 'Saturday October 1997'
  11718.           mysql> select DATE_FORMAT('1997-10-04 22:23:00', '%H:%i:%s');
  11719.                   -> '22:23:00'
  11720.           mysql> select DATE_FORMAT('1997-10-04 22:23:00',
  11721.                                     '%D %y %a %d %m %b %j');
  11722.                   -> '4th 97 Sat 04 10 Oct 277'
  11723.           mysql> select DATE_FORMAT('1997-10-04 22:23:00',
  11724.                                     '%H %k %I %r %T %S %w');
  11725.                   -> '22 22 10 10:23:00 PM 22:23:00 00 6'
  11726.           mysql> select DATE_FORMAT('1999-01-01', '%X %V');
  11727.                   -> '1998 52'
  11728.  
  11729.      As of *MySQL* 3.23, the `%' character is required before format
  11730.      specifier characters.  In earlier versions of *MySQL*, `%' was
  11731.      optional.
  11732.  
  11733. `TIME_FORMAT(time,format)'
  11734.      This is used like the `DATE_FORMAT()' function above, but the
  11735.      `format' string may contain only those format specifiers that
  11736.      handle hours, minutes and seconds.  Other specifiers produce a
  11737.      `NULL' value or `0'.
  11738.  
  11739. `CURDATE()'
  11740. `CURRENT_DATE'
  11741.      Returns today's date as a value in `'YYYY-MM-DD'' or `YYYYMMDD'
  11742.      format, depending on whether the function is used in a string or
  11743.      numeric context.
  11744.  
  11745.           mysql> select CURDATE();
  11746.                   -> '1997-12-15'
  11747.           mysql> select CURDATE() + 0;
  11748.                   -> 19971215
  11749.  
  11750. `CURTIME()'
  11751. `CURRENT_TIME'
  11752.      Returns the current time as a value in `'HH:MM:SS'' or `HHMMSS'
  11753.      format, depending on whether the function is used in a string or
  11754.      numeric context.
  11755.  
  11756.           mysql> select CURTIME();
  11757.                   -> '23:50:26'
  11758.           mysql> select CURTIME() + 0;
  11759.                   -> 235026
  11760.  
  11761. `NOW()'
  11762. `SYSDATE()'
  11763. `CURRENT_TIMESTAMP'
  11764.      Returns the current date and time as a value in `'YYYY-MM-DD
  11765.      HH:MM:SS'' or `YYYYMMDDHHMMSS' format, depending on whether the
  11766.      function is used in a string or numeric context.
  11767.  
  11768.           mysql> select NOW();
  11769.                   -> '1997-12-15 23:50:26'
  11770.           mysql> select NOW() + 0;
  11771.                   -> 19971215235026
  11772.  
  11773. `UNIX_TIMESTAMP()'
  11774. `UNIX_TIMESTAMP(date)'
  11775.      If called with no argument, returns a Unix timestamp (seconds since
  11776.      `'1970-01-01 00:00:00'' GMT). If `UNIX_TIMESTAMP()' is called with
  11777.      a `date' argument, it returns the value of the argument as seconds
  11778.      since `'1970-01-01 00:00:00'' GMT.  `date' may be a `DATE' string,
  11779.      a `DATETIME' string, a `TIMESTAMP', or a number in the format
  11780.      `YYMMDD' or `YYYYMMDD' in local time.
  11781.  
  11782.           mysql> select UNIX_TIMESTAMP();
  11783.                   -> 882226357
  11784.           mysql> select UNIX_TIMESTAMP('1997-10-04 22:23:00');
  11785.                   -> 875996580
  11786.  
  11787.      When `UNIX_TIMESTAMP' is used on a `TIMESTAMP' column, the function
  11788.      will receive the value directly, with no implicit
  11789.      "string-to-unix-timestamp" conversion.  If you give
  11790.      `UNIX_TIMESTAMP()' a wrong or out-of-range date, it will return 0.
  11791.  
  11792. `FROM_UNIXTIME(unix_timestamp)'
  11793.      Returns a representation of the `unix_timestamp' argument as a
  11794.      value in `'YYYY-MM-DD HH:MM:SS'' or `YYYYMMDDHHMMSS' format,
  11795.      depending on whether the function is used in a string or numeric
  11796.      context.
  11797.  
  11798.           mysql> select FROM_UNIXTIME(875996580);
  11799.                   -> '1997-10-04 22:23:00'
  11800.           mysql> select FROM_UNIXTIME(875996580) + 0;
  11801.                   -> 19971004222300
  11802.  
  11803. `FROM_UNIXTIME(unix_timestamp,format)'
  11804.      Returns a string representation of the Unix timestamp, formatted
  11805.      according to the `format' string. `format' may contain the same
  11806.      specifiers as those listed in the entry for the `DATE_FORMAT()'
  11807.      function.
  11808.  
  11809.           mysql> select FROM_UNIXTIME(UNIX_TIMESTAMP(),
  11810.                                       '%Y %D %M %h:%i:%s %x');
  11811.                   -> '1997 23rd December 03:43:30 x'
  11812.  
  11813. `SEC_TO_TIME(seconds)'
  11814.      Returns the `seconds' argument, converted to hours, minutes and
  11815.      seconds, as a value in `'HH:MM:SS'' or `HHMMSS' format, depending
  11816.      on whether the function is used in a string or numeric context.
  11817.  
  11818.           mysql> select SEC_TO_TIME(2378);
  11819.                   -> '00:39:38'
  11820.           mysql> select SEC_TO_TIME(2378) + 0;
  11821.                   -> 3938
  11822.  
  11823. `TIME_TO_SEC(time)'
  11824.      Returns the `time' argument, converted to seconds.
  11825.           mysql> select TIME_TO_SEC('22:23:00');
  11826.                   -> 80580
  11827.           mysql> select TIME_TO_SEC('00:39:38');
  11828.                   -> 2378
  11829.  
  11830. Miscellaneous functions
  11831. -----------------------
  11832.  
  11833. `DATABASE()'
  11834.      Returns the current database name.
  11835.           mysql> select DATABASE();
  11836.                   -> 'test'
  11837.  
  11838.      If there is no current database, `DATABASE()' returns the empty
  11839.      string.
  11840.  
  11841. `USER()'
  11842. `SYSTEM_USER()'
  11843. `SESSION_USER()'
  11844.      Returns the current *MySQL* user name.
  11845.           mysql> select USER();
  11846.                   -> 'davida@localhost'
  11847.  
  11848.      In *MySQL* 3.22.11 or later, this includes the client hostname as
  11849.      well as the user name.  You can extract just the user name part
  11850.      like this (which works whether or not the value includes a
  11851.      hostname part):
  11852.  
  11853.           mysql> select substring_index(USER(),"@",1);
  11854.                   -> 'davida'
  11855.  
  11856. `PASSWORD(str)'
  11857.      Calculates a password string from the plaintext password `str'.
  11858.      This is the function that is used for encrypting *MySQL* passwords
  11859.      for storage in the `Password' column of the `user' grant table.
  11860.  
  11861.           mysql> select PASSWORD('badpwd');
  11862.                   -> '7f84554057dd964b'
  11863.  
  11864.      `PASSWORD()' encryption is non-reversible.
  11865.  
  11866.      `PASSWORD()' does not perform password encryption in the same way
  11867.      that Unix passwords are encrypted.  You should not assume that if
  11868.      your Unix password and your *MySQL* password are the same,
  11869.      `PASSWORD()' will result in the same encrypted value as is stored
  11870.      in the Unix password file.  See `ENCRYPT()'.
  11871.  
  11872. `ENCRYPT(str[,salt])'
  11873.      Encrypt `str' using the Unix `crypt()' system call. The `salt'
  11874.      argument should be a string with two characters.  (As of *MySQL*
  11875.      3.22.16, `salt' may be longer than two characters.)
  11876.  
  11877.           mysql> select ENCRYPT("hello");
  11878.                   -> 'VxuFAJXVARROc'
  11879.  
  11880.      If `crypt()' is not available on your system, `ENCRYPT()' always
  11881.      returns `NULL'.
  11882.  
  11883.      `ENCRYPT()' ignores all but the first 8 characters of `str', at
  11884.      least on some systems.  This will be determined by the behavior of
  11885.      the underlying `crypt()' system call.
  11886.  
  11887. `ENCODE(str,pass_str)'
  11888.      Encrypt `str' using `pass_str' as the password.  To decrypt the
  11889.      result, use `DECODE()'.
  11890.  
  11891.      The results is a binary string of the same length as `string'.  If
  11892.      you want to save it in a column, use a `BLOB' column type.
  11893.  
  11894. `DECODE(crypt_str,pass_str)'
  11895.      Descrypts the encrypted string `crypt_str' using `pass_str' as the
  11896.      password.  `crypt_str' should be a string returned from `ENCODE()'.
  11897.  
  11898. `MD5(string)'
  11899.      Calculates a MD5 checksum for the string. Value is returned as a
  11900.      32 long hex number that may, for example, be used as a hash key.
  11901.  
  11902.           mysql> select MD5("testing")
  11903.                   -> 'ae2b1fca515949e5d54fb22b8ed95575'
  11904.  
  11905.      This is an "RSA Data Security, Inc. MD5 Message-Digest Algorithm".
  11906.  
  11907. `LAST_INSERT_ID([expr])'
  11908.      Returns the last automatically generated value that was inserted
  11909.      into an `AUTO_INCREMENT' column.  *Note `mysql_insert_id()':
  11910.      mysql_insert_id.
  11911.  
  11912.           mysql> select LAST_INSERT_ID();
  11913.                   -> 195
  11914.  
  11915.      The last ID that was generated is maintained in the server on a
  11916.      per-connection basis.  It will not be changed by another client.
  11917.      It will not even be changed if you update another `AUTO_INCREMENT'
  11918.      column with a non-magic value (that is, a value that is not `NULL'
  11919.      and not `0').
  11920.  
  11921.      If `expr' is given as an argument to `LAST_INSERT_ID()' in an
  11922.      `UPDATE' clause, then the value of the argument is returned as a
  11923.      `LAST_INSERT_ID()' value.  This can be used to simulate sequences:
  11924.  
  11925.      First create the table:
  11926.  
  11927.           mysql> create table sequence (id int not null);
  11928.           mysql> insert into sequence values (0);
  11929.  
  11930.      Then the table can be used to generate sequence numbers like this:
  11931.  
  11932.           mysql> update sequence set id=LAST_INSERT_ID(id+1);
  11933.  
  11934.      You can generate sequences without calling `LAST_INSERT_ID()', but
  11935.      the utility of using the function this way is that the ID value is
  11936.      maintained in the server as the last automatically generated
  11937.      value.  You can retrieve the new ID as you would read any normal
  11938.      `AUTO_INCREMENT' value in *MySQL*.  For example,
  11939.      `LAST_INSERT_ID()' (without an argument) will return the new ID.
  11940.      The C API function `mysql_insert_id()' can also be used to get the
  11941.      value.
  11942.  
  11943. `FORMAT(X,D)'
  11944.      Formats the number `X' to a format like `'#,###,###.##'', rounded
  11945.      to `D' decimals.  If `D' is `0', the result will have no decimal
  11946.      point or fractional part.
  11947.  
  11948.           mysql> select FORMAT(12332.123456, 4);
  11949.                   -> '12,332.1235'
  11950.           mysql> select FORMAT(12332.1,4);
  11951.                   -> '12,332.1000'
  11952.           mysql> select FORMAT(12332.2,0);
  11953.                   -> '12,332'
  11954.  
  11955. `VERSION()'
  11956.      Returns a string indicating the *MySQL* server version.
  11957.           mysql> select VERSION();
  11958.                   -> '3.23.13-log'
  11959.  
  11960.      Note that if your version ends with `-log' this means that logging
  11961.      is enabled.
  11962.  
  11963. `CONNECTION_ID()'
  11964.      Returns the connection id (`thread_id') for the connection.  Every
  11965.      connection has its own unique id.
  11966.           mysql> select CONNECTION_ID();
  11967.                   -> 1
  11968.  
  11969. `GET_LOCK(str,timeout)'
  11970.      Tries to obtain a lock with a name given by the string `str', with
  11971.      a timeout of `timeout' seconds.  Returns `1' if the lock was
  11972.      obtained successfully, `0' if the attempt timed out, or `NULL' if
  11973.      an error occurred (such as running out of memory or the thread was
  11974.      killed with `mysqladmin kill').  A lock is released when you
  11975.      execute `RELEASE_LOCK()', execute a new `GET_LOCK()' or the thread
  11976.      terminates.  This function can be used to implement application
  11977.      locks or to simulate record locks.  It blocks requests by other
  11978.      clients for locks with the same name; clients that agree on a
  11979.      given lock string name can use the string to perform cooperative
  11980.      advisory locking.
  11981.  
  11982.           mysql> select GET_LOCK("lock1",10);
  11983.                   -> 1
  11984.           mysql> select GET_LOCK("lock2",10);
  11985.                   -> 1
  11986.           mysql> select RELEASE_LOCK("lock2");
  11987.                   -> 1
  11988.           mysql> select RELEASE_LOCK("lock1");
  11989.                   -> NULL
  11990.  
  11991.      Note that the second `RELEASE_LOCK()' call returns `NULL' because
  11992.      the lock `"lock1"' was automatically released by the second
  11993.      `GET_LOCK()' call.
  11994.  
  11995. `RELEASE_LOCK(str)'
  11996.      Releases the lock named by the string `str' that was obtained with
  11997.      `GET_LOCK()'. Returns `1' if the lock was released, `0' if the
  11998.      lock wasn't locked by this thread (in which case the lock is not
  11999.      released) and `NULL' if the named lock didn't exist.  The lock
  12000.      will not exist if it was never obtained by a call to `GET_LOCK()'
  12001.      or if it already has been released.
  12002.  
  12003. `BENCHMARK(count,expr)'
  12004.      The `BENCHMARK()' function executes the expression `expr'
  12005.      repeatedly `count' times.  It may be used to time how fast *MySQL*
  12006.      processes the expression.  The result value is always `0'.  The
  12007.      intended use is in the `mysql' client, which reports query
  12008.      execution times.
  12009.  
  12010.           mysql> select BENCHMARK(1000000,encode("hello","goodbye"));
  12011.           +----------------------------------------------+
  12012.           | BENCHMARK(1000000,encode("hello","goodbye")) |
  12013.           +----------------------------------------------+
  12014.           |                                            0 |
  12015.           +----------------------------------------------+
  12016.           1 row in set (4.74 sec)
  12017.  
  12018.      The time reported is elapsed time on the client end, not CPU time
  12019.      on the server end.  It may be advisable to execute `BENCHMARK()'
  12020.      several times, and interpret the result with regard to how heavily
  12021.      loaded the server machine is.
  12022.  
  12023. `INET_NTOA(expr)'
  12024.      Returns the network address (4 or 8 byte) for the numeric
  12025.      expression.
  12026.  
  12027.           mysql> select INET_NTOA(3520061480);
  12028.                  ->  "209.207.224.40"
  12029.  
  12030. `INET_ATON(expr)'
  12031.      Returns an integer that represents the numeric value for a network
  12032.      address Addresses may be 4 or 8 byte addresses.
  12033.  
  12034.           mysql> select INET_ATON("209.207.224.40");
  12035.                  ->  3520061480
  12036.  
  12037. Functions for use with `GROUP BY' clauses
  12038. -----------------------------------------
  12039.  
  12040. If you use a group function in a statement containing no `GROUP BY'
  12041. clause, it is equivalent to grouping on all rows.
  12042.  
  12043. `COUNT(expr)'
  12044.      Returns a count of the number of non-`NULL' values in the rows
  12045.      retrieved by a `SELECT' statement.
  12046.  
  12047.           mysql> select student.student_name,COUNT(*)
  12048.                      from student,course
  12049.                      where student.student_id=course.student_id
  12050.                      GROUP BY student_name;
  12051.  
  12052.      `COUNT(*)' is somewhat different in that it returns a count of the
  12053.      number of rows retrieved, whether or not they contain `NULL'
  12054.      values.
  12055.  
  12056.      `COUNT(*)' is optimized to return very quickly if the `SELECT'
  12057.      retrieves from one table, no other columns are retrieved and there
  12058.      is no `WHERE' clause.  For example:
  12059.  
  12060.           mysql> select COUNT(*) from student;
  12061.  
  12062. `COUNT(DISTINCT expr,[expr...])'
  12063.      Returns a count of the number of different values.
  12064.  
  12065.           mysql> select COUNT(DISTINCT results) from student;
  12066.  
  12067.      In *MySQL* you can get the number of distinct expressions
  12068.      combinations by giving a list of expressions.  In ANSI SQL you
  12069.      would have to do a concatenation of all expressions inside
  12070.      `CODE(DISTINCT ..)'.
  12071.  
  12072. `AVG(expr)'
  12073.      Returns the average value of `expr'.
  12074.  
  12075.           mysql> select student_name, AVG(test_score)
  12076.                      from student
  12077.                      GROUP BY student_name;
  12078.  
  12079. `MIN(expr)'
  12080. `MAX(expr)'
  12081.      Returns the minimum or maximum value of `expr'.  `MIN()' and
  12082.      `MAX()' may take a string argument; in such cases they return the
  12083.      minimum or maximum string value.
  12084.  
  12085.           mysql> select student_name, MIN(test_score), MAX(test_score)
  12086.                      from student
  12087.                      GROUP BY student_name;
  12088.  
  12089. `SUM(expr)'
  12090.      Returns the sum of `expr'.  Note that if the return set has no
  12091.      rows, it returns NULL!
  12092.  
  12093. `STD(expr)'
  12094. `STDDEV(expr)'
  12095.      Returns the standard deviation of `expr'. This is an extension to
  12096.      ANSI SQL.  The `STDDEV()' form of this function is provided for
  12097.      Oracle compatability.
  12098.  
  12099. `BIT_OR(expr)'
  12100.      Returns the bitwise `OR' of all bits in `expr'. The calculation is
  12101.      performed with 64-bit (`BIGINT' precision.
  12102.  
  12103. `BIT_AND(expr)'
  12104.      Returns the bitwise `AND' of all bits in `expr'. The calculation is
  12105.      performed with 64-bit (`BIGINT' precision.
  12106.  
  12107. *MySQL* has extended the use of `GROUP BY'. You can use columns or
  12108. calculations in the `SELECT' expressions which don't appear in the
  12109. `GROUP BY' part. This stands for _any possible value for this group_.
  12110. You can use this to get better performance by avoiding sorting and
  12111. grouping on unnecessary items.  For example, you don't need to group on
  12112. `customer.name' in the following query:
  12113.  
  12114.      mysql> select order.custid,customer.name,max(payments)
  12115.             from order,customer
  12116.             where order.custid = customer.custid
  12117.             GROUP BY order.custid;
  12118.  
  12119. In ANSI SQL, you would have to add `customer.name' to the `GROUP BY'
  12120. clause.  In *MySQL*, the name is redundant if you don't run in ANSI
  12121. mode.
  12122.  
  12123. Don't use this feature if the columns you omit from the `GROUP BY' part
  12124. aren't unique in the group!
  12125.  
  12126. In some cases, you can use `MIN()' and `MAX()' to obtain a specific
  12127. column value even if it isn't unique. The following gives the value of
  12128. `column' from the row containing the smallest value in the `sort'
  12129. column:
  12130.  
  12131.      substr(MIN(concat(sort,space(6-length(sort)),column),7,length(column)))
  12132.  
  12133. Note that if you are using *MySQL* 3.22 (or earlier) or if you are
  12134. trying to follow ANSI SQL, you can't use expressions in `GROUP BY' or
  12135. `ORDER BY' clauses.  You can work around this limitation by using an
  12136. alias for the expression:
  12137.  
  12138.      mysql> SELECT id,FLOOR(value/100) AS val FROM tbl_name
  12139.                 GROUP BY id,val ORDER BY val;
  12140.  
  12141. In `MySQL' 3.23 you can do:
  12142.  
  12143.      mysql> SELECT id,FLOOR(value/100) FROM tbl_name ORDER BY RAND();
  12144.  
  12145. `CREATE DATABASE' syntax
  12146. ========================
  12147.  
  12148.      CREATE DATABASE [IF NOT EXISTS] db_name
  12149.  
  12150. `CREATE DATABASE' creates a database with the given name.  Rules for
  12151. allowable database names are given in *Note Legal names::.  An error
  12152. occurs if the database already exists and you didn't specify `IF NOT
  12153. EXISTS'.
  12154.  
  12155. Databases in *MySQL* are implemented as directories containing files
  12156. that correspond to tables in the database.  Because there are no tables
  12157. in a database when it is initially created, the `CREATE DATABASE'
  12158. statement only creates a directory under the *MySQL* data directory.
  12159.  
  12160. You can also create databases with `mysqladmin'.  *Note Programs::.
  12161.  
  12162. `DROP DATABASE' syntax
  12163. ======================
  12164.  
  12165.      DROP DATABASE [IF EXISTS] db_name
  12166.  
  12167. `DROP DATABASE' drops all tables in the database and deletes the
  12168. database.  *Be VERY careful with this command!*
  12169.  
  12170. `DROP DATABASE' returns the number of files that were removed from the
  12171. database directory.  Normally, this is three times the number of tables,
  12172. because each table corresponds to a `.MYD' file, a `.MYI' file and a
  12173. `.frm' file.
  12174.  
  12175. In *MySQL* 3.22 or later, you can use the keywords `IF EXISTS' to
  12176. prevent an error from occurring if the database doesn't exist.
  12177.  
  12178. You can also drop databases with `mysqladmin'.  *Note Programs::.
  12179.  
  12180. `CREATE TABLE' syntax
  12181. =====================
  12182.  
  12183.      CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name [(create_definition,...)]
  12184.      [table_options] [select_statement]
  12185.      
  12186.      create_definition:
  12187.        col_name type [NOT NULL | NULL] [DEFAULT default_value] [AUTO_INCREMENT]
  12188.                  [PRIMARY KEY] [reference_definition]
  12189.        or    PRIMARY KEY (index_col_name,...)
  12190.        or    KEY [index_name] (index_col_name,...)
  12191.        or    INDEX [index_name] (index_col_name,...)
  12192.        or    UNIQUE [INDEX] [index_name] (index_col_name,...)
  12193.        or    [CONSTRAINT symbol] FOREIGN KEY index_name (index_col_name,...)
  12194.                  [reference_definition]
  12195.        or    CHECK (expr)
  12196.      
  12197.      type:
  12198.              TINYINT[(length)] [UNSIGNED] [ZEROFILL]
  12199.        or    SMALLINT[(length)] [UNSIGNED] [ZEROFILL]
  12200.        or    MEDIUMINT[(length)] [UNSIGNED] [ZEROFILL]
  12201.        or    INT[(length)] [UNSIGNED] [ZEROFILL]
  12202.        or    INTEGER[(length)] [UNSIGNED] [ZEROFILL]
  12203.        or    BIGINT[(length)] [UNSIGNED] [ZEROFILL]
  12204.        or    REAL[(length,decimals)] [UNSIGNED] [ZEROFILL]
  12205.        or    DOUBLE[(length,decimals)] [UNSIGNED] [ZEROFILL]
  12206.        or    FLOAT[(length,decimals)] [UNSIGNED] [ZEROFILL]
  12207.        or    DECIMAL(length,decimals) [UNSIGNED] [ZEROFILL]
  12208.        or    NUMERIC(length,decimals) [UNSIGNED] [ZEROFILL]
  12209.        or    CHAR(length) [BINARY]
  12210.        or    VARCHAR(length) [BINARY]
  12211.        or    DATE
  12212.        or    TIME
  12213.        or    TIMESTAMP
  12214.        or    DATETIME
  12215.        or    TINYBLOB
  12216.        or    BLOB
  12217.        or    MEDIUMBLOB
  12218.        or    LONGBLOB
  12219.        or    TINYTEXT
  12220.        or    TEXT
  12221.        or    MEDIUMTEXT
  12222.        or    LONGTEXT
  12223.        or    ENUM(value1,value2,value3,...)
  12224.        or    SET(value1,value2,value3,...)
  12225.      
  12226.      index_col_name:
  12227.              col_name [(length)]
  12228.      
  12229.      reference_definition:
  12230.              REFERENCES tbl_name [(index_col_name,...)]
  12231.                         [MATCH FULL | MATCH PARTIAL]
  12232.                         [ON DELETE reference_option]
  12233.                         [ON UPDATE reference_option]
  12234.      
  12235.      reference_option:
  12236.              RESTRICT | CASCADE | SET NULL | NO ACTION | SET DEFAULT
  12237.      
  12238.      table_options:
  12239.          TYPE = {ISAM | MYISAM | HEAP}
  12240.      or    AUTO_INCREMENT = #
  12241.      or    AVG_ROW_LENGTH = #
  12242.      or    CHECKSUM = {0 | 1}
  12243.      or    COMMENT = "string"
  12244.      or    MAX_ROWS = #
  12245.      or    MIN_ROWS = #
  12246.      or    PACK_KEYS = {0 | 1}
  12247.      or    PASSWORD = "string"
  12248.      or    DELAY_KEY_WRITE = {0 | 1}
  12249.      or      ROW_FORMAT= { default | dynamic | static | compressed }
  12250.      or    RAID_TYPE= {1 | STRIPED | RAID0 } RAID_CHUNKS=#  RAID_CHUNKSIZE=#;
  12251.      
  12252.      select_statement:
  12253.          [IGNORE | REPLACE] SELECT ...  (Some legal select statement)
  12254.  
  12255. `CREATE TABLE' creates a table with the given name in the current
  12256. database.  Rules for allowable table names are given in *Note Legal
  12257. names::.  An error occurs if there is no current database or if the
  12258. table already exists.
  12259.  
  12260. In *MySQL* 3.22 or later, the table name can be specified as
  12261. `db_name.tbl_name'.  This works whether or not there is a current
  12262. database.
  12263.  
  12264. In *MySQL* 3.23, you can use the `TEMPORARY' keyword when you create a
  12265. table.  A temporary table will automatically be deleted if a connection
  12266. dies and the name is per connection.  This means that two different
  12267. connections can both use the same temporary table name without
  12268. conflicting with each other or with an existing table of the same name.
  12269. (The existing table is hidden until the temporary table is deleted).
  12270.  
  12271. In *MySQL* 3.23 or later, you can use the keywords `IF NOT EXISTS' so
  12272. that an error does not occur if the table already exists.  Note that
  12273. there is no verification that the table structures are identical.
  12274.  
  12275. Each table `tbl_name' is represented by some files in the database
  12276. directory. In the case of MyISAM-type tables you will get:
  12277.  
  12278. *File*         *Purpose*
  12279. `tbl_name.frm' Table definition (form) file
  12280. `tbl_name.MYD' Data file
  12281. `tbl_name.MYI' Index file
  12282.  
  12283. For more information on the properties of the various column types, see
  12284. *Note Column types::.
  12285.  
  12286.    * If neither `NULL' nor `NOT NULL' is specified, the column is
  12287.      treated as though `NULL' had been specified.
  12288.  
  12289.    * An integer column may have the additional attribute
  12290.      `AUTO_INCREMENT'.  When you insert a value of `NULL' (recommended)
  12291.      or `0' into an `AUTO_INCREMENT' column, the column is set to
  12292.      `value+1', where `value' is the largest value for the column
  12293.      currently in the table.  `AUTO_INCREMENT' sequences begin with `1'.
  12294.      *Note `mysql_insert_id()': mysql_insert_id.
  12295.  
  12296.      If you delete the row containing the maximum value for an
  12297.      `AUTO_INCREMENT' column, the value will be reused with an ISAM
  12298.      table but not with a `MyISAM' table.  If you delete all rows in the
  12299.      table with `DELETE FROM table_name' (without a `WHERE') in
  12300.      `AUTOCOMMIT' mode, the sequence starts over for both table types.
  12301.  
  12302.      *Note:* There can be only one `AUTO_INCREMENT' column per table,
  12303.      and it must be indexed. *MySQL* 3.23 will also only work properly
  12304.      if the auto_increment column only has positive values. Inserting a
  12305.      negative number is regarded as inserting a very large positive
  12306.      number.  This is done to avoid precision problems when numbers
  12307.      'wrap' over from positive to negative and also to ensure that one
  12308.      doesn't accidently get a auto_increment column that contains 0.
  12309.  
  12310.      To make *MySQL* compatible with some ODBC applications, you can
  12311.      find the last inserted row with the following query:
  12312.  
  12313.           SELECT * FROM tbl_name WHERE auto_col IS NULL
  12314.  
  12315.    * `NULL' values are handled differently for `TIMESTAMP' columns than
  12316.      for other column types.  You cannot store a literal `NULL' in a
  12317.      `TIMESTAMP' column; setting the column to `NULL' sets it to the
  12318.      current date and time.  Because `TIMESTAMP' columns behave this
  12319.      way, the `NULL' and `NOT NULL' attributes do not apply in the
  12320.      normal way and are ignored if you specify them.
  12321.  
  12322.      On the other hand, to make it easier for *MySQL* clients to use
  12323.      `TIMESTAMP' columns, the server reports that such columns may be
  12324.      assigned `NULL' values (which is true), even though `TIMESTAMP'
  12325.      never actually will contain a `NULL' value.  You can see this when
  12326.      you use `DESCRIBE tbl_name' to get a description of your table.
  12327.  
  12328.      Note that setting a `TIMESTAMP' column to `0' is not the same as
  12329.      setting it to `NULL', because `0' is a valid `TIMESTAMP' value.
  12330.  
  12331.    * If no `DEFAULT' value is specified for a column, *MySQL*
  12332.      automatically assigns one.
  12333.  
  12334.      If the column may take `NULL' as a value, the default value is
  12335.      `NULL'.
  12336.  
  12337.      If the column is declared as `NOT NULL', the default value depends
  12338.      on the column type:
  12339.  
  12340.         - For numeric types other than those declared with the
  12341.           `AUTO_INCREMENT' attribute, the default is `0'.  For an
  12342.           `AUTO_INCREMENT' column, the default value is the next value
  12343.           in the sequence.
  12344.  
  12345.         - For date and time types other than `TIMESTAMP', the default
  12346.           is the appropriate "zero" value for the type.  For the first
  12347.           `TIMESTAMP' column in a table, the default value is the
  12348.           current date and time.  *Note Date and time types::.
  12349.  
  12350.         - For string types other than `ENUM', the default value is the
  12351.           empty string.  For `ENUM', the default is the first
  12352.           enumeration value.
  12353.  
  12354.    * `KEY' is a synonym for `INDEX'.
  12355.  
  12356.    * In *MySQL*, a `UNIQUE' key can have only distinct values. An error
  12357.      occurs if you try to add a new row with a key that matches an
  12358.      existing row.
  12359.  
  12360.    * A `PRIMARY KEY' is a unique `KEY' with the extra constraint that
  12361.      all key columns must be defined as `NOT NULL'.  In *MySQL* the key
  12362.      is named `PRIMARY'. A table can have only one `PRIMARY KEY'.  If
  12363.      you don't have a `PRIMARY KEY' and some applications ask for the
  12364.      `PRIMARY KEY' in your tables, *MySQL* will return the first
  12365.      `UNIQUE' key, which doesn't have any `NULL' columns, as the
  12366.      `PRIMARY KEY'.
  12367.  
  12368.    * A `PRIMARY KEY' can be a multiple-column index.  However, you
  12369.      cannot create a multiple-column index using the `PRIMARY KEY' key
  12370.      attibute in a column specification.  Doing so will mark only that
  12371.      single column as primary.  You must use the `PRIMARY
  12372.      KEY(index_col_name, ...)' syntax.
  12373.  
  12374.    * If the `PRIMARY' or `UNIQUE' key consists of only one column and
  12375.      this is of type integer, you can also refer to it as `_rowid' (new
  12376.      in 3.23.11).
  12377.  
  12378.    * If you don't assign a name to an index, the index will be assigned
  12379.      the same name as the first `index_col_name', with an optional
  12380.      suffix (`_2', `_3', `...') to make it unique.  You can see index
  12381.      names for a table using `SHOW INDEX FROM tbl_name'.  *Note `SHOW':
  12382.      SHOW.
  12383.  
  12384.    * Only the `MyISAM' table type supports indexes on columns that can
  12385.      have `NULL' values. In other cases you must declare such columns
  12386.      `NOT NULL' or an error results.
  12387.  
  12388.    * With `col_name(length)' syntax, you can specify an index which
  12389.      uses only a part of a `CHAR' or `VARCHAR' column. This can make
  12390.      the index file much smaller.  *Note Indexes::.
  12391.  
  12392.    * Only the `MyISAM' table type supports indexing on `BLOB' and
  12393.      `TEXT' columns.  When putting an index on a `BLOB' or `TEXT'
  12394.      column you MUST always specify the length of the index:
  12395.           CREATE TABLE test (blob_col BLOB, index(blob_col(10)));
  12396.  
  12397.    * When you use `ORDER BY' or `GROUP BY' with a `TEXT' or `BLOB'
  12398.      column, only the first `max_sort_length' bytes are used.  *Note
  12399.      `BLOB': BLOB.
  12400.  
  12401.    * The `FOREIGN KEY', `CHECK' and `REFERENCES' clauses don't actually
  12402.      do anything.  The syntax for them is provided only for
  12403.      compatibility, to make it easier to port code from other SQL
  12404.      servers and to run applications that create tables with references.
  12405.      *Note Missing functions::.
  12406.  
  12407.    * Each `NULL' column takes one bit extra, rounded up to the nearest
  12408.      byte.
  12409.  
  12410.    * The maximum record length in bytes can be calculated as follows:
  12411.  
  12412.           row length = 1
  12413.                        + (sum of column lengths)
  12414.                        + (number of NULL columns + 7)/8
  12415.                        + (number of variable-length columns)
  12416.  
  12417.    * The `table_options' and `SELECT' options is only implemented in
  12418.      *MySQL* 3.23 and above.
  12419.  
  12420.      The different table types are:
  12421.  
  12422.      ISAM          The original table handler. *Note ISAM::.
  12423.      MyISAM        The new binary portable table handler. *Note MyISAM::.
  12424.      HEAP          The data for this table is only stored in memory.
  12425.                    *Note HEAP::.
  12426.      BDB or        Transaction safe tables *Note BDB::.
  12427.      Berkeley_db   
  12428.      *Note Table types::.
  12429.  
  12430.      The other table options are used to optimize the behavior of the
  12431.      table. In most cases, you don't have to specify any of them.  The
  12432.      options work for all table types, if not otherwise indicated.
  12433.  
  12434.      `AUTO_INCREMENT'The next auto_increment value you want to set for
  12435.                    your table (MyISAM)
  12436.      `AVG_ROW_LENGTH'An approximation of the average row length for your
  12437.                    table. You only need to set this for tables with
  12438.                    variable size records.
  12439.      `CHECKSUM'    Set this to 1 if you want *MySQL* to maintain a
  12440.                    checksum for all rows (makes the table a little
  12441.                    slower to update but makes it easier to find
  12442.                    corrupted tables) (MyISAM)
  12443.      `COMMENT'     A 60 character comment for your table
  12444.      `MAX_ROWS'    Max number of rows you plan to store in the table
  12445.      `MIN_ROWS'    Minimum number of rows you plan to store in the table
  12446.      `PACK_KEYS'   Set this to 1 if you want to have smaller index. This
  12447.                    usually makes updates slower and reads faster
  12448.                    (MyISAM, ISAM).
  12449.      `PASSWORD'    Encrypt the `.frm' file with a password.  This option
  12450.                    doesn't do anything in the standard *MySQL* version.
  12451.      `DELAY_KEY_WRITE'Set this to 1 if want to delay key table updates
  12452.                    until the table is closed (MyISAM).
  12453.      `ROW_FORMAT'  Defines how the rows should be stored (for the
  12454.                    future).
  12455.  
  12456.      When you use a `MyISAM' table, *MySQL* uses the product of
  12457.      `max_rows * avg_row_length' to decide how big the resulting table
  12458.      will be.  If you don't specify any of the above options, the
  12459.      maximum size for a table will be 4G (or 2G if your operating
  12460.      systems only supports 2G tables).
  12461.  
  12462.      If you don't use `PACK_KEYS', the default is to only pack strings,
  12463.      not numbers.  If you use `PACK_KEYS=1', numbers will be packed as
  12464.      well.
  12465.  
  12466.      When packing binary number keys, *MySQL* will use prefix
  12467.      compression.  This means that you will only get a big benefit of
  12468.      this if you have many numbers that are the same.  Prefix
  12469.      compression means that every key needs one extra byte to indicate
  12470.      how many bytes of the previous key are the same for the next key
  12471.      (note that the pointer to the row is stored in
  12472.      high-byte-first-order directly after the key, to improve
  12473.      compression.  This means that if you have many equal keys on two
  12474.      rows in a row, all following 'same' keys will usually only take 2
  12475.      bytes (including the pointer to the row).  Compare this to the
  12476.      ordinary case where the following keys will take
  12477.      'storage_size_for_key' + pointer_size (usually 4).  On the other
  12478.      hand, if all keys are totally different, you will lose 1 byte per
  12479.      key, if the key isn't a key that can have `NULL' values (In this
  12480.      case the packed key length will be stored in the same byte that is
  12481.      used to mark if a key is `NULL').
  12482.  
  12483.    * If you specify a `SELECT' after the `CREATE STATEMENT', *MySQL*
  12484.      will create new fields for all elements in the `SELECT'.  For
  12485.      example:
  12486.  
  12487.           mysql> CREATE TABLE test (a int not null auto_increment,
  12488.                      primary key (a), key(b))
  12489.                      TYPE=HEAP SELECT b,c from test2;
  12490.  
  12491.      This will create a `HEAP' table with 3 columns.  Note that the
  12492.      table will automatically be deleted if any errors occur while
  12493.      copying data into the table.
  12494.  
  12495.    * The `RAID_TYPE' option will help you to break the 2G/4G limit on
  12496.      OSes that don't support big files. You can get also more speed
  12497.      from the I/O bottleneck by putting `RAID' directories on different
  12498.      physical disks.  `RAID_TYPE' will work on any OS, as long as you
  12499.      have configured *MySQL* with `--with-raid'.  For now the only
  12500.      allowed `RAID_TYPE' is `STRIPED' (`1' and `RAID0' are aliases for
  12501.      this).
  12502.  
  12503.      If you specify `RAID_TYPE=STRIPED' for a `MyISAM' table, `MyISAM'
  12504.      will create `RAID_CHUNKS' sub-directories named 00, 01, 02 in the
  12505.      database directory.  In each of these directories `MyISAM' will
  12506.      create an `table_name.MYD'.  When writing data to the data file,
  12507.      the `RAID' handler will map the first `RAID_CHUNKSIZE' *1024 bytes
  12508.      to the first file, the next `RAID_CHUNKSIZE' *1024 bytes to the
  12509.      next file and so on.
  12510.  
  12511. Silent column specification changes
  12512. -----------------------------------
  12513.  
  12514. In some cases, *MySQL* silently changes a column specification from
  12515. that given in a `CREATE TABLE' statement.  (This may also occur with
  12516. `ALTER TABLE'.)
  12517.  
  12518.    * `VARCHAR' columns with a length less than four are changed to
  12519.      `CHAR'.
  12520.  
  12521.    * If any column in a table has a variable length, the entire row is
  12522.      variable-length as a result.  Therefore, if a table contains any
  12523.      variable-length columns (`VARCHAR', `TEXT' or `BLOB'), all `CHAR'
  12524.      columns longer than three characters are changed to `VARCHAR'
  12525.      columns.  This doesn't affect how you use the columns in any way;
  12526.      in *MySQL*, `VARCHAR' is just a different way to store characters.
  12527.      *MySQL* performs this conversion because it saves space and makes
  12528.      table operations faster.  *Note Table types::.
  12529.  
  12530.    * `TIMESTAMP' display sizes must be even and in the range from 2 to
  12531.      14.  If you specify a display size of 0 or greater than 14, the
  12532.      size is coerced to 14.  Odd-valued sizes in the range from 1 to 13
  12533.      are coerced to the next higher even number.
  12534.  
  12535.    * You cannot store a literal `NULL' in a `TIMESTAMP' column; setting
  12536.      it to `NULL' sets it to the current date and time.  Because
  12537.      `TIMESTAMP' columns behave this way, the `NULL' and `NOT NULL'
  12538.      attributes do not apply in the normal way and are ignored if you
  12539.      specify them.  `DESCRIBE tbl_name' always reports that a
  12540.      `TIMESTAMP' column may be assigned `NULL' values.
  12541.  
  12542.    * *MySQL* maps certain column types used by other SQL database
  12543.      vendors to *MySQL* types.  *Note Other-vendor column types::.
  12544.  
  12545. If you want to see whether or not *MySQL* used a column type other than
  12546. the one you specified, issue a `DESCRIBE tbl_name' statement after
  12547. creating or altering your table.
  12548.  
  12549. Certain other column type changes may occur if you compress a table
  12550. using `myisampack'. *Note Compressed format::.
  12551.  
  12552. `ALTER TABLE' syntax
  12553. ====================
  12554.  
  12555.      ALTER [IGNORE] TABLE tbl_name alter_spec [, alter_spec ...]
  12556.      
  12557.      alter_specification:
  12558.              ADD [COLUMN] create_definition [FIRST | AFTER column_name ]
  12559.        or    ADD [COLUMN] (create_definition, create_definition,...)
  12560.        or    ADD INDEX [index_name] (index_col_name,...)
  12561.        or    ADD PRIMARY KEY (index_col_name,...)
  12562.        or    ADD UNIQUE [index_name] (index_col_name,...)
  12563.        or    ALTER [COLUMN] col_name {SET DEFAULT literal | DROP DEFAULT}
  12564.        or    CHANGE [COLUMN] old_col_name create_definition
  12565.        or    MODIFY [COLUMN] create_definition
  12566.        or    DROP [COLUMN] col_name
  12567.        or    DROP PRIMARY KEY
  12568.        or    DROP INDEX index_name
  12569.        or    RENAME [AS] new_tbl_name
  12570.        or    table_options
  12571.  
  12572. `ALTER TABLE' allows you to change the structure of an existing table.
  12573. For example, you can add or delete columns, create or destroy indexes,
  12574. change the type of existing columns, or rename columns or the table
  12575. itself.  You can also change the comment for the table and type of the
  12576. table.  *Note `CREATE TABLE': CREATE TABLE.
  12577.  
  12578. If you use `ALTER TABLE' to change a column specification but `DESCRIBE
  12579. tbl_name' indicates that your column was not changed, it is possible
  12580. that *MySQL* ignored your modification for one of the reasons described
  12581. in *Note Silent column changes::.  For example, if you try to change a
  12582. `VARCHAR' column to `CHAR', *MySQL* will still use `VARCHAR' if the
  12583. table contains other variable-length columns.
  12584.  
  12585. `ALTER TABLE' works by making a temporary copy of the original table.
  12586. The alteration is performed on the copy, then the original table is
  12587. deleted and the new one is renamed. This is done in such a way that all
  12588. updates are automatically redirected to the new table without any
  12589. failed updates. While `ALTER TABLE' is executing, the original table is
  12590. readable by other clients. Updates and writes to the table are stalled
  12591. until the new table is ready.
  12592.  
  12593.    * To use `ALTER TABLE', you need *select*, *insert*, *delete*,
  12594.      *update*, *create* and *drop* privileges on the table.
  12595.  
  12596.    * `IGNORE' is a *MySQL* extension to ANSI SQL92.  It controls how
  12597.      `ALTER TABLE' works if there are duplicates on unique keys in the
  12598.      new table.  If `IGNORE' isn't specified, the copy is aborted and
  12599.      rolled back.  If `IGNORE' is specified, then for rows with
  12600.      duplicates on a unique key, only the first row is used; the others
  12601.      are deleted.
  12602.  
  12603.    * You can issue multiple `ADD', `ALTER', `DROP' and `CHANGE' clauses
  12604.      in a single `ALTER TABLE' statement. This is a *MySQL* extension
  12605.      to ANSI SQL92, which allows only one of each clause per `ALTER
  12606.      TABLE' statement.
  12607.  
  12608.    * `CHANGE col_name', `DROP col_name' and `DROP INDEX' are *MySQL*
  12609.      extensions to ANSI SQL92.
  12610.  
  12611.    * `MODIFY' is an Oracle extension to `ALTER TABLE'.
  12612.  
  12613.    * The optional word `COLUMN' is a pure noise word and can be omitted.
  12614.  
  12615.    * If you use `ALTER TABLE tbl_name RENAME AS new_name' without any
  12616.      other options, *MySQL* simply renames the files that correspond to
  12617.      the table `tbl_name'.  There is no need to create the temporary
  12618.      table.
  12619.  
  12620.    * `create_definition' clauses use the same syntax for `ADD' and
  12621.      `CHANGE' as for `CREATE TABLE'.  Note that this syntax includes
  12622.      the column name, not just the column type.  *Note `CREATE TABLE':
  12623.      CREATE TABLE.
  12624.  
  12625.    * You can rename a column using a `CHANGE old_col_name
  12626.      create_definition' clause.  To do so, specify the old and new
  12627.      column names and the type that the column currently has.  For
  12628.      example, to rename an `INTEGER' column from `a' to `b', you can do
  12629.      this:
  12630.  
  12631.           mysql> ALTER TABLE t1 CHANGE a b INTEGER;
  12632.  
  12633.      If you want to change a column's type but not the name, `CHANGE'
  12634.      syntax still requires two column names even if they are the same.
  12635.      For example:
  12636.  
  12637.           mysql> ALTER TABLE t1 CHANGE b b BIGINT NOT NULL;
  12638.  
  12639.      However, as of *MySQL* 3.22.16a, you can also use `MODIFY' to
  12640.      change a column's type without renaming it:
  12641.  
  12642.           mysql> ALTER TABLE t1 MODIFY b BIGINT NOT NULL;
  12643.  
  12644.    * If you use `CHANGE' or `MODIFY' to shorten a column for which an
  12645.      index exists on part of the column (for instance, if you have an
  12646.      index on the first 10 characters of a `VARCHAR' column), you
  12647.      cannot make the column shorter than the number of characters that
  12648.      are indexed.
  12649.  
  12650.    * When you change a column type using `CHANGE' or `MODIFY', *MySQL*
  12651.      tries to convert data to the new type as well as possible.
  12652.  
  12653.    * In *MySQL* 3.22 or later, you can use `FIRST' or `ADD ...  AFTER
  12654.      col_name' to add a column at a specific position within a table
  12655.      row.  The default is to add the column last.
  12656.  
  12657.    * `ALTER COLUMN' specifies a new default value for a column or
  12658.      removes the old default value.  If the old default is removed and
  12659.      the column can be `NULL', the new default is `NULL'. If the column
  12660.      cannot be `NULL', *MySQL* assigns a default value.  Default value
  12661.      assignment is described in *Note `CREATE TABLE': CREATE TABLE.
  12662.  
  12663.    * `DROP INDEX' removes an index. This is a *MySQL* extension to ANSI
  12664.      SQL92.
  12665.  
  12666.    * If columns are dropped from a table, the columns are also removed
  12667.      from any index of which they are a part.  If all columns that make
  12668.      up an index are dropped, the index is dropped as well.
  12669.  
  12670.    * `DROP PRIMARY KEY' drops the primary index. If no such index
  12671.      exists, it drops the first `UNIQUE' index in the table.  (*MySQL*
  12672.      marks the first `UNIQUE' key as the `PRIMARY KEY' if no `PRIMARY
  12673.      KEY' was specified explicitly.)
  12674.  
  12675.    * With the C API function `mysql_info()', you can find out how many
  12676.      records were copied, and (when `IGNORE' is used) how many records
  12677.      were deleted due to duplication of unique key values.
  12678.  
  12679.    * The `FOREIGN KEY', `CHECK' and `REFERENCES' clauses don't actually
  12680.      do anything.  The syntax for them is provided only for
  12681.      compatibility, to make it easier to port code from other SQL
  12682.      servers and to run applications that create tables with references.
  12683.      *Note Missing functions::.
  12684.  
  12685. Here is an example that shows some of the uses of `ALTER TABLE'.  We
  12686. begin with a table `t1' that is created as shown below:
  12687.  
  12688.      mysql> CREATE TABLE t1 (a INTEGER,b CHAR(10));
  12689.  
  12690. To rename the table from `t1' to `t2':
  12691.  
  12692.      mysql> ALTER TABLE t1 RENAME t2;
  12693.  
  12694. To change column `a' from `INTEGER' to `TINYINT NOT NULL' (leaving the
  12695. name the same), and to change column `b' from `CHAR(10)' to `CHAR(20)'
  12696. as well as renaming it from `b' to `c':
  12697.  
  12698.      mysql> ALTER TABLE t2 MODIFY a TINYINT NOT NULL, CHANGE b c CHAR(20);
  12699.  
  12700. To add a new `TIMESTAMP' column named `d':
  12701.  
  12702.      mysql> ALTER TABLE t2 ADD d TIMESTAMP;
  12703.  
  12704. To add an index on column `d', and make column `a' the primary key:
  12705.  
  12706.      mysql> ALTER TABLE t2 ADD INDEX (d), ADD PRIMARY KEY (a);
  12707.  
  12708. To remove column `c':
  12709.  
  12710.      mysql> ALTER TABLE t2 DROP COLUMN c;
  12711.  
  12712. To add a new `AUTO_INCREMENT' integer column named `c':
  12713.  
  12714.      mysql> ALTER TABLE t2 ADD c INT UNSIGNED NOT NULL AUTO_INCREMENT,
  12715.                 ADD INDEX (c);
  12716.  
  12717. Note that we indexed `c', because `AUTO_INCREMENT' columns must be
  12718. indexed, and also that we declare `c' as `NOT NULL', because indexed
  12719. columns cannot be `NULL'.
  12720.  
  12721. When you add an `AUTO_INCREMENT' column, column values are filled in
  12722. with sequence numbers for you automatically.
  12723.  
  12724. See also *Note `ALTER TABLE' problems: ALTER TABLE problems.
  12725.  
  12726. `DROP TABLE' syntax
  12727. ===================
  12728.  
  12729.      DROP TABLE [IF EXISTS] tbl_name [, tbl_name,...]
  12730.  
  12731. `DROP TABLE' removes one or more tables. All table data and the table
  12732. definition are _removed_, so *be careful* with this command!
  12733.  
  12734. In *MySQL* 3.22 or later, you can use the keywords `IF EXISTS' to
  12735. prevent an error from occurring for tables that don't exist.
  12736.  
  12737. `OPTIMIZE TABLE' syntax
  12738. =======================
  12739.  
  12740.      OPTIMIZE TABLE tbl_name
  12741.  
  12742. `OPTIMIZE TABLE' should be used if you have deleted a large part of a
  12743. table or if you have made many changes to a table with variable-length
  12744. rows (tables that have `VARCHAR', `BLOB' or `TEXT' columns).  Deleted
  12745. records are maintained in a linked list and subsequent `INSERT'
  12746. operations reuse old record positions. You can use `OPTIMIZE TABLE' to
  12747. reclaim the unused space.
  12748.  
  12749. `OPTIMIZE TABLE' works by making a temporary copy of the original
  12750. table; The old table is copied to the new table (without the unused
  12751. rows), then the original table is deleted and the new one is renamed.
  12752. While `OPTIMIZE TABLE' is executing, the original table is readable by
  12753. other clients. Updates and writes to the table are stalled until the
  12754. new table is ready. This is done in such a way that all updates are
  12755. automatically redirected to the new table without any failed updates.
  12756.  
  12757. `CHECK TABLE' syntax
  12758. ====================
  12759.  
  12760.      CHECK TABLE tbl_name[,tbl_name...] [TYPE = QUICK]
  12761.  
  12762. Check the table(s) for errors. The command returns a table with the
  12763. following columns:
  12764.  
  12765. Table                     Table name
  12766. Op                        Always 'check'
  12767. Msg_type                  One of `status', `error', `info' or `warning'.
  12768. Msg_text                  The message.
  12769.  
  12770. Note that you can get many rows of information for each checked table.
  12771. The last one row will be of `Msg_type status' and should normally be
  12772. `OK'.  If you don't get `OK', you should normally run a repair of the
  12773. table. *Note Table maintenance::.
  12774.  
  12775. If `TYPE=QUICK' is given then *MySQL* will not scan the rows for table
  12776. with fixed size records.
  12777.  
  12778. `CHECK TABLE' only works on `MyISAM' tables and is the same things as
  12779. running `myisamchk -m table_name' on the table.
  12780.  
  12781. `ANALYZE TABLE' syntax
  12782. ======================
  12783.  
  12784.      ANALYZE TABLE tbl_name[,tbl_name...]
  12785.  
  12786. Analyze and store the key distribution for the table.  During the
  12787. analyze the table is locked with a read lock.  This is equivalent of
  12788. running `myisamchk -a' on the table.
  12789.  
  12790. *MySQL* uses the stored key distribution to decide in which order
  12791. tables should be joined when one does a join on something else than a
  12792. constant.
  12793.  
  12794. The command returns a table with the following columns:
  12795.  
  12796. Table                     Table name
  12797. Op                        Always 'analyze
  12798. Msg_type                  One of `status', `error', `info' or `warning'.
  12799. Msg_text                  The message.
  12800.  
  12801. You can check the stored key distribution with the `SHOW INDEX' command.
  12802. *Note SHOW DATABASE INFO::.
  12803.  
  12804. `REPAIR TABLE' syntax
  12805. =====================
  12806.  
  12807.      REPAIR TABLE tbl_name[,tbl_name...] [TYPE = QUICK]
  12808.  
  12809. `REPAIR TABLE' only works on `MyISAM' tables and is the same things as
  12810. running `myisamchk -r table_name' on the table.
  12811.  
  12812. Repair the corrupted table. The command returns a table with the
  12813. following columns:
  12814.  
  12815. Table                     Table name
  12816. Op                        Always 'repair'
  12817. Msg_type                  One of `status', `error', `info' or `warning'.
  12818. Msg_text                  The message.
  12819.  
  12820. Note that you can get many rows of information for each repaired table.
  12821. The last one row will be of `Msg_type status' and should normally be
  12822. `OK'.  If you don't get `OK', you should try repairing the table with
  12823. `myisamchk -o', as `REPAIR TABLE' does not yet implement all the
  12824. options of `myisamchk'. In the near future, we will make it more
  12825. flexible.
  12826.  
  12827. If `TYPE=QUICK' is given then *MySQL* will try to do a `REPAIR' of only
  12828. the index tree.
  12829.  
  12830. `DELETE' syntax
  12831. ===============
  12832.  
  12833.      DELETE [LOW_PRIORITY] FROM tbl_name
  12834.          [WHERE where_definition] [LIMIT rows]
  12835.  
  12836. `DELETE' deletes rows from `tbl_name' that satisfy the condition given
  12837. by `where_definition', and returns the number of records deleted.
  12838.  
  12839. If you issue a `DELETE' with no `WHERE' clause, all rows are deleted.
  12840. If you do this in `AUTOCOMMIT' mode, *MySQL* does this by recreating
  12841. the table as an empty table, which is much faster than deleting each
  12842. row.  In this case, `DELETE' returns zero as the number of affected
  12843. records. (*MySQL* can't return the number of rows that were actually
  12844. deleted, because the recreate is done without opening the data files.
  12845. As long as the table definition file `tbl_name.frm' is valid, the table
  12846. can be recreated this way, even if the data or index files have become
  12847. corrupted.).
  12848.  
  12849. If you really want to know how many records are deleted when you are
  12850. deleting all rows, and are willing to suffer a speed penalty, you can
  12851. use a `DELETE' statement of this form:
  12852.  
  12853.      mysql> DELETE FROM tbl_name WHERE 1>0;
  12854.  
  12855. Note that this is MUCH slower than `DELETE FROM tbl_name' with no
  12856. `WHERE' clause, because it deletes rows one at a time.
  12857.  
  12858. If you specify the keyword `LOW_PRIORITY', execution of the `DELETE' is
  12859. delayed until no other clients are reading from the table.
  12860.  
  12861. Deleted records are maintained in a linked list and subsequent `INSERT'
  12862. operations reuse old record positions. To reclaim unused space and
  12863. reduce file sizes, use the `OPTIMIZE TABLE' statement or the `myisamchk'
  12864. utility to reorganize tables.  `OPTIMIZE TABLE' is easier, but
  12865. `myisamchk' is faster.  *Note `OPTIMIZE TABLE': OPTIMIZE TABLE, and
  12866. *Note Optimization::.
  12867.  
  12868. The *MySQL*-specific `LIMIT rows' option to `DELETE' tells the server
  12869. the maximum number of rows to be deleted before control is returned to
  12870. the client.  This can be used to ensure that a specific `DELETE'
  12871. command doesn't take too much time.  You can simply repeat the `DELETE'
  12872. command until the number of affected rows is less than the `LIMIT'
  12873. value.
  12874.  
  12875. `SELECT' syntax
  12876. ===============
  12877.  
  12878.      SELECT [STRAIGHT_JOIN] [SQL_SMALL_RESULT] [SQL_BIG_RESULT] [SQL_BUFFER_RESULT]
  12879.             [HIGH_PRIORITY]
  12880.             [DISTINCT | DISTINCTROW | ALL]
  12881.          select_expression,...
  12882.          [INTO {OUTFILE | DUMPFILE} 'file_name' export_options]
  12883.          [FROM table_references
  12884.              [WHERE where_definition]
  12885.              [GROUP BY {unsigned_integer | col_name | formula}]
  12886.              [HAVING where_definition]
  12887.              [ORDER BY {unsigned_integer | col_name | formula} [ASC | DESC] ,...]
  12888.              [LIMIT [offset,] rows]
  12889.              [PROCEDURE procedure_name] ]
  12890.  
  12891. `SELECT' is used to retrieve rows selected from one or more tables.
  12892. `select_expression' indicates the columns you want to retrieve.
  12893. `SELECT' may also be used to retrieve rows computed without reference to
  12894. any table.  For example:
  12895.  
  12896.      mysql> SELECT 1 + 1;
  12897.               -> 2
  12898.  
  12899. All keywords used must be given in exactly the order shown above. For
  12900. example, a `HAVING' clause must come after any `GROUP BY' clause and
  12901. before any `ORDER BY' clause.
  12902.  
  12903.    * A `SELECT' expression may be given an alias using `AS'. The alias
  12904.      is used as the expression's column name and can be used with
  12905.      `ORDER BY' or `HAVING' clauses.  For example:
  12906.  
  12907.           mysql> select concat(last_name,', ',first_name) AS full_name
  12908.               from mytable ORDER BY full_name;
  12909.  
  12910.    * The `FROM table_references' clause indicates the tables from which
  12911.      to retrieve rows.  If you name more than one table, you are
  12912.      performing a join.  For information on join syntax, see *Note
  12913.      `JOIN': JOIN.
  12914.  
  12915.    * You can refer to a column as `col_name', `tbl_name.col_name' or
  12916.      `db_name.tbl_name.col_name'.  You need not specify a `tbl_name' or
  12917.      `db_name.tbl_name' prefix for a column reference in a `SELECT'
  12918.      statement unless the reference would be ambiguous.  See *Note
  12919.      Legal names::, for examples of ambiguity that require the more
  12920.      explicit column reference forms.
  12921.  
  12922.    * A table reference may be aliased using `tbl_name [AS] alias_name'.
  12923.  
  12924.           mysql> select t1.name, t2.salary from employee AS t1, info AS t2
  12925.                      where t1.name = t2.name;
  12926.           mysql> select t1.name, t2.salary from employee t1, info t2
  12927.                      where t1.name = t2.name;
  12928.  
  12929.    * Columns selected for output may be referred to in `ORDER BY' and
  12930.      `GROUP BY' clauses using column names, column aliases or column
  12931.      positions.  Column positions begin with 1.
  12932.  
  12933.           mysql> select college, region, seed from tournament
  12934.                      ORDER BY region, seed;
  12935.           mysql> select college, region AS r, seed AS s from tournament
  12936.                      ORDER BY r, s;
  12937.           mysql> select college, region, seed from tournament
  12938.                      ORDER BY 2, 3;
  12939.  
  12940.      To sort in reverse order, add the `DESC' (descending) keyword to
  12941.      the name of the column in the `ORDER BY' clause that you are
  12942.      sorting by.  The default is ascending order; this may be specified
  12943.      explicitly using the `ASC' keyword.
  12944.  
  12945.    * The `HAVING' clause can refer to any column or alias named in the
  12946.      `select_expression'. It is applied last, just before items are
  12947.      sent to the client, with no optimization. Don't use `HAVING' for
  12948.      items that should be in the `WHERE' clause.  For example, do not
  12949.      write this:
  12950.  
  12951.           mysql> select col_name from tbl_name HAVING col_name > 0;
  12952.  
  12953.      Write this instead:
  12954.  
  12955.           mysql> select col_name from tbl_name WHERE col_name > 0;
  12956.  
  12957.      In *MySQL* 3.22.5 or later, you can also write queries like this:
  12958.  
  12959.           mysql> select user,max(salary) from users
  12960.                      group by user HAVING max(salary)>10;
  12961.  
  12962.      In older *MySQL* versions, you can write this instead:
  12963.  
  12964.           mysql> select user,max(salary) AS sum from users
  12965.                      group by user HAVING sum>10;
  12966.  
  12967.    * `SQL_SMALL_RESULT', `SQL_BIG_RESULT', `SQL_BUFFER_RESULT',
  12968.      `STRAIGHT_JOIN' and `HIGH_PRIORITY' are *MySQL* extensions to ANSI
  12969.      SQL92.
  12970.  
  12971.    * `HIGH_PRIORITY' will give the `SELECT' higher priority than a
  12972.      statement that updates a table.  You should only use this for
  12973.      queries that are very fast and must be done at once.  A `SELECT
  12974.      HIGH_PRIORITY' query will run if the table is locked for read even
  12975.      if there is an update statement that is waiting for the table to
  12976.      be free.
  12977.  
  12978.    * `SQL_BIG_RESULT' can be used with `GROUP BY' or `DISTINCT' to tell
  12979.      the optimizer that the result set will have many rows.  In this
  12980.      case, *MySQL* will directly use disk based temporary tables if
  12981.      needed.  *MySQL* will also in this case prefer sorting to doing a
  12982.      temporary table with a key on the `GROUP BY' elements.
  12983.  
  12984.    * `SQL_BUFFER_RESULT' will put force the result to be put into a
  12985.      temporary table. This will help *MySQL* free the table locks early
  12986.      and will help in cases where it takes a long time to send the
  12987.      result set to the client.
  12988.  
  12989.    * `SQL_SMALL_RESULT', a *MySQL*-specific option, can be used with
  12990.      `GROUP BY' or `DISTINCT' to tell the optimizer that the result set
  12991.      will be small.  In this case, *MySQL* will use fast temporary
  12992.      tables to store the resulting table instead of using sorting. In
  12993.      *MySQL* 3.23 this shouldn't normally be needed.
  12994.  
  12995.    * `STRAIGHT_JOIN' forces the optimizer to join the tables in the
  12996.      order in which they are listed in the `FROM' clause. You can use
  12997.      this to speed up a query if the optimizer joins the tables in
  12998.      non-optimal order.  *Note `EXPLAIN': EXPLAIN.
  12999.  
  13000.    * The `LIMIT' clause can be used to constrain the number of rows
  13001.      returned by the `SELECT' statement.  `LIMIT' takes one or two
  13002.      numeric arguments.
  13003.  
  13004.      If two arguments are given, the first specifies the offset of the
  13005.      first row to return, the second specifies the maximum number of
  13006.      rows to return.  The offset of the initial row is 0 (not 1).
  13007.  
  13008.           mysql> select * from table LIMIT 5,10;  # Retrieve rows 6-15
  13009.  
  13010.      If one argument is given, it indicates the maximum number of rows
  13011.      to return.
  13012.  
  13013.           mysql> select * from table LIMIT 5;     # Retrieve first 5 rows
  13014.  
  13015.      In other words, `LIMIT n' is equivalent to `LIMIT 0,n'.
  13016.  
  13017.    * The `SELECT ... INTO OUTFILE 'file_name'' form of `SELECT' writes
  13018.      the selected rows to a file. The file is created on the server
  13019.      host, and cannot already exist (among other things, this prevents
  13020.      database tables and files such as `/etc/passwd' from being
  13021.      destroyed).  You must have the *file* privilege on the server host
  13022.      to use this form of `SELECT'.
  13023.  
  13024.      `SELECT ...  INTO OUTFILE' is the complement of `LOAD DATA
  13025.      INFILE'; the syntax for the `export_options' part of the statement
  13026.      consists of the same `FIELDS' and `LINES' clauses that are used
  13027.      with the `LOAD DATA INFILE' statement.  *Note `LOAD DATA': LOAD
  13028.      DATA.
  13029.  
  13030.      In the resulting text file, only the following characters are
  13031.      escaped by the `ESCAPED BY' character:
  13032.  
  13033.         * The `ESCAPED BY' character
  13034.  
  13035.         * The first character in `FIELDS TERMINATED BY'
  13036.  
  13037.         * The first character in `LINES TERMINATED BY'
  13038.  
  13039.      Additionally, `ASCII 0' is converted to `ESCAPED BY' followed by 0
  13040.      (`ASCII 48').
  13041.  
  13042.      The reason for the above is that you MUST escape any `FIELDS
  13043.      TERMINATED BY', `ESCAPED BY' or `LINES TERMINATED BY' characters
  13044.      to reliably be able to read the file back. `ASCII 0' is escaped to
  13045.      make it easier to view with some pagers.
  13046.  
  13047.      As the resulting file doesn't have to conform to the SQL syntax,
  13048.      nothing else need be escaped.
  13049.  
  13050. If you use `INTO DUMPFILE' instead of `INTO OUTFILE' *MySQL* will only
  13051. write one row into the file, without any column or line terminations
  13052. and without any escaping.  This is useful if you want to store a blob
  13053. in a file.
  13054.  
  13055. `JOIN' syntax
  13056. =============
  13057.  
  13058. *MySQL* supports the following `JOIN' syntaxes for use in `SELECT'
  13059. statements:
  13060.  
  13061.      table_reference, table_reference
  13062.      table_reference [CROSS] JOIN table_reference
  13063.      table_reference INNER JOIN table_reference join_condition
  13064.      table_reference STRAIGHT_JOIN table_reference
  13065.      table_reference LEFT [OUTER] JOIN table_reference join_condition
  13066.      table_reference LEFT [OUTER] JOIN table_reference
  13067.      table_reference NATURAL [LEFT [OUTER]] JOIN table_reference
  13068.      { oj table_reference LEFT OUTER JOIN table_reference ON conditional_expr }
  13069.  
  13070. Where `table_reference' is defined as
  13071.      table_name [[AS] alias] [USE INDEX (key_list)] [IGNORE INDEX (key_list)]
  13072.  
  13073. and `join_condition' is defined as
  13074.  
  13075.      ON conditional_expr |
  13076.      USING (column_list)
  13077.  
  13078. Note that in version before 3.23.16 the `INNER JOIN' didn't take a join
  13079. condition!
  13080.  
  13081. The last `LEFT OUTER JOIN' syntax shown above exists only for
  13082. compatibility with ODBC.
  13083.  
  13084.    * A table reference may be aliased using `tbl_name AS alias_name' or
  13085.      `tbl_name alias_name'.
  13086.  
  13087.           mysql> select t1.name, t2.salary from employee AS t1, info AS t2
  13088.                      where t1.name = t2.name;
  13089.  
  13090.    * `INNER JOIN' and `,' (comma) are semantically equivalent.  Both do
  13091.      a full join between the tables used.  Normally, you specify how
  13092.      the tables should be linked in the `WHERE' condition.
  13093.  
  13094.    * The `ON' conditional is any conditional of the form that may be
  13095.      used in a `WHERE' clause.
  13096.  
  13097.    * If there is no matching record for the right table in the `ON' or
  13098.      `USING' part in a `LEFT JOIN', a row with all columns set to
  13099.      `NULL' is used for the right table.  You can use this fact to find
  13100.      records in a table that have no counterpart in another table:
  13101.  
  13102.           mysql> select table1.* from table1
  13103.                      LEFT JOIN table2 ON table1.id=table2.id
  13104.                      where table2.id is NULL;
  13105.  
  13106.      This example finds all rows in `table1' with an `id' value that is
  13107.      not present in `table2' (i.e., all rows in `table1' with no
  13108.      corresponding row in `table2').  This assumes that `table2.id' is
  13109.      declared `NOT NULL', of course.
  13110.  
  13111.    * The `USING' `(column_list)' clause names a list of columns that
  13112.      must exist in both tables.  A `USING' clause such as:
  13113.  
  13114.           A LEFT JOIN B USING (C1,C2,C3,...)
  13115.  
  13116.      is defined to be semantically identical to an `ON' expression like
  13117.      this:
  13118.  
  13119.           A.C1=B.C1 AND A.C2=B.C2 AND A.C3=B.C3,...
  13120.  
  13121.    * The `NATURAL [LEFT] JOIN' of two tables is defined to be
  13122.      semantically equivalent to a `INNER JOIN' or a `LEFT JOIN' with a
  13123.      `USING' clause that names all columns that exist in both tables.
  13124.  
  13125.    * `STRAIGHT_JOIN' is identical to `JOIN', except that the left table
  13126.      is always read before the right table. This can be used for those
  13127.      (few) cases where the join optimizer puts the tables in the wrong
  13128.      order.
  13129.  
  13130.    * As of *MySQL* 3.23.12, you can give hints about which index
  13131.      *MySQL* should use when retrieving information from a table. This
  13132.      is useful if `EXPLAIN' shows that *MySQL* is using the wrong
  13133.      index.  By specifying `USE INDEX (key_list)', you can tell *MySQL*
  13134.      to use only one of the specified indexes to find rows in the
  13135.      table.  The alternative syntax `IGNORE INDEX (key_list)' can be
  13136.      used to tell *MySQL* to not use some particular index.
  13137.  
  13138. Some examples:
  13139.  
  13140.      mysql> select * from table1,table2 where table1.id=table2.id;
  13141.      mysql> select * from table1 LEFT JOIN table2 ON table1.id=table2.id;
  13142.      mysql> select * from table1 LEFT JOIN table2 USING (id);
  13143.      mysql> select * from table1 LEFT JOIN table2 ON table1.id=table2.id
  13144.                 LEFT JOIN table3 ON table2.id=table3.id;
  13145.      mysql> select * from table1 USE INDEX (key1,key2) WHERE key1=1 and key2=2 AND
  13146.             key3=3;
  13147.      mysql> select * from table1 IGNORE INDEX (key3) WHERE key1=1 and key2=2 AND
  13148.             key3=3;
  13149.  
  13150. *Note `LEFT JOIN' optimization: LEFT JOIN optimization.
  13151.  
  13152. `INSERT' syntax
  13153. ===============
  13154.  
  13155.          INSERT [LOW_PRIORITY | DELAYED] [IGNORE]
  13156.              [INTO] tbl_name [(col_name,...)]
  13157.              VALUES (expression,...),(...),...
  13158.      or  INSERT [LOW_PRIORITY | DELAYED] [IGNORE]
  13159.              [INTO] tbl_name [(col_name,...)]
  13160.              SELECT ...
  13161.      or  INSERT [LOW_PRIORITY | DELAYED] [IGNORE]
  13162.              [INTO] tbl_name
  13163.              SET col_name=expression, col_name=expression, ...
  13164.  
  13165. `INSERT' inserts new rows into an existing table.  The `INSERT ...
  13166. VALUES' form of the statement inserts rows based on explicitly-specified
  13167. values.  The `INSERT ... SELECT' form inserts rows selected from another
  13168. table or tables.  The `INSERT ... VALUES' form with multiple value lists
  13169. is supported in *MySQL* 3.22.5 or later.  The `col_name=expression'
  13170. syntax is supported in *MySQL* 3.22.10 or later.
  13171.  
  13172. `tbl_name' is the table into which rows should be inserted.  The column
  13173. name list or the `SET' clause indicates which columns the statement
  13174. specifies values for.
  13175.  
  13176.    * If you specify no column list for `INSERT ... VALUES' or `INSERT
  13177.      ... SELECT', values for all columns must be provided in the
  13178.      `VALUES()' list or by the `SELECT'.  If you don't know the order of
  13179.      the columns in the table, use `DESCRIBE tbl_name' to find out.
  13180.  
  13181.    * Any column not explicitly given a value is set to its default
  13182.      value.  For example, if you specify a column list that doesn't
  13183.      name all the columns in the table, unnamed columns are set to
  13184.      their default values.  Default value assignment is described in
  13185.      *Note `CREATE TABLE': CREATE TABLE.
  13186.  
  13187.    * An `expression' may refer to any column that was set earlier in a
  13188.      value list.  For example, you can say this:
  13189.  
  13190.           mysql> INSERT INTO tbl_name (col1,col2) VALUES(15,col1*2);
  13191.  
  13192.      But not this:
  13193.  
  13194.           mysql> INSERT INTO tbl_name (col1,col2) VALUES(col2*2,15);
  13195.  
  13196.    * If you specify the keyword `LOW_PRIORITY', execution of the
  13197.      `INSERT' is delayed until no other clients are reading from the
  13198.      table.  In this case the client has to wait until the insert
  13199.      statement is completed, which may take a long time if the table is
  13200.      in heavy use. This is in contrast to `INSERT DELAYED' which lets
  13201.      the client continue at once.
  13202.  
  13203.    * If you specify the keyword `IGNORE' in an `INSERT' with many value
  13204.      rows, any rows which duplicate an existing `PRIMARY' or `UNIQUE'
  13205.      key in the table are ignored and are not inserted.  If you do not
  13206.      specify `IGNORE', the insert is aborted if there is any row that
  13207.      duplicates an existing key value.  You can check with the C API
  13208.      function `mysql_info()' how many rows were inserted into the table.
  13209.  
  13210.    * If *MySQL* was configured using the `DONT_USE_DEFAULT_FIELDS'
  13211.      option, `INSERT' statements generate an error unless you explicitly
  13212.      specify values for all columns that require a non-`NULL' value.
  13213.      *Note `configure' options: configure options.
  13214.  
  13215.    * The following conditions hold for a `INSERT INTO ... SELECT'
  13216.      statement:
  13217.  
  13218.         - The query cannot contain an `ORDER BY' clause.
  13219.  
  13220.         - The target table of the `INSERT' statement cannot appear in
  13221.           the `FROM' clause of the `SELECT' part of the query, because
  13222.           it's forbidden in ANSI SQL to `SELECT' from the same table
  13223.           into which you are `INSERT'ing.  (The problem is that the
  13224.           `SELECT' possibly would find records that were inserted
  13225.           earlier during the same run.  When using sub-select clauses,
  13226.           the situation could easily be very confusing!)
  13227.  
  13228.         - `AUTO_INCREMENT' columns work as usual.
  13229.  
  13230. If you use `INSERT ... SELECT' or a `INSERT ... VALUES' statement with
  13231. multiple value lists, you can use the C API function `mysql_info()' to
  13232. get information about the query.  The format of the information string
  13233. is shown below:
  13234.  
  13235.      Records: 100 Duplicates: 0 Warnings: 0
  13236.  
  13237. `Duplicates' indicates the number of rows that couldn't be inserted
  13238. because they would duplicate some existing unique index value.
  13239. `Warnings' indicates the number of attempts to insert column values that
  13240. were problematic in some way. Warnings can occur under any of the
  13241. following conditions:
  13242.  
  13243.    * Inserting `NULL' into a column that has been declared `NOT NULL'.
  13244.      The column is set to its default value.
  13245.  
  13246.    * Setting a numeric column to a value that lies outside the column's
  13247.      range.  The value is clipped to the appropriate endpoint of the
  13248.      range.
  13249.  
  13250.    * Setting a numeric column to a value such as `'10.34 a''.  The
  13251.      trailing garbage is stripped and the remaining numeric part is
  13252.      inserted.  If the value doesn't make sense as a number at all, the
  13253.      column is set to `0'.
  13254.  
  13255.    * Inserting a string into a `CHAR', `VARCHAR', `TEXT' or `BLOB'
  13256.      column that exceeds the column's maximum length.  The value is
  13257.      truncated to the column's maximum length.
  13258.  
  13259.    * Inserting a value into a date or time column that is illegal for
  13260.      the column type.  The column is set to the appropriate "zero"
  13261.      value for the type.
  13262.  
  13263. The `DELAYED' option for the `INSERT' statement is a *MySQL*-specific
  13264. option that is very useful if you have clients that can't wait for the
  13265. `INSERT' to complete.  This is a common problem when you use *MySQL*
  13266. for logging and you also periodically run `SELECT' statements that take
  13267. a long time to complete.  `DELAYED' was introduced in *MySQL* 3.22.15.
  13268. It is a *MySQL* extension to ANSI SQL92.
  13269.  
  13270. When you use `INSERT DELAYED', the client will get an ok at once and
  13271. the row will be inserted when the table is not in use by any other
  13272. thread.
  13273.  
  13274. Another major benefit of using `INSERT DELAYED' is that inserts from
  13275. many clients are bundled together and written in one block. This is much
  13276. faster than doing many separate inserts.
  13277.  
  13278. Note that currently the queued rows are only stored in memory until
  13279. they are inserted into the table.  This means that if you kill `mysqld'
  13280. the hard way (`kill -9') or if `mysqld' dies unexpectedly, any queued
  13281. rows that weren't written to disk are lost!
  13282.  
  13283. The following describes in detail what happens when you use the
  13284. `DELAYED' option to `INSERT' or `REPLACE'.  In this description, the
  13285. "thread" is the thread that received an `INSERT DELAYED' command and
  13286. "handler" is the thread that handles all `INSERT DELAYED' statements
  13287. for a particular table.
  13288.  
  13289.    * When a thread executes a `DELAYED' statement for a table, a handler
  13290.      thread is created to process all `DELAYED' statements for the
  13291.      table, if no such handler already exists.
  13292.  
  13293.    * The thread checks whether or not the handler has acquired a
  13294.      `DELAYED' lock already; if not, it tells the handler thread to do
  13295.      so.  The `DELAYED' lock can be obtained even if other threads have
  13296.      a `READ' or `WRITE' lock on the table.  However, the handler will
  13297.      wait for all `ALTER TABLE' locks or `FLUSH TABLES' to ensure that
  13298.      the table structure is up to date.
  13299.  
  13300.    * The thread executes the `INSERT' statement but instead of writing
  13301.      the row to the table it puts a copy of the final row into a queue
  13302.      that is managed by the handler thread. Any syntax errors are
  13303.      noticed by the thread and reported to the client program.
  13304.  
  13305.    * The client can't report the number of duplicates or the
  13306.      `AUTO_INCREMENT' value for the resulting row; it can't obtain them
  13307.      from the server, because the `INSERT' returns before the insert
  13308.      operation has been completed.  If you use the C API, the
  13309.      `mysql_info()' function doesn't return anything meaningful, for
  13310.      the same reason.
  13311.  
  13312.    * The update log is updated by the handler thread when the row is
  13313.      inserted into the table.  In case of multiple-row inserts, the
  13314.      update log is updated when the first row is inserted.
  13315.  
  13316.    * After every `delayed_insert_limit' rows are written, the handler
  13317.      checks whether or not any `SELECT' statements are still pending.
  13318.      If so, it allows these to execute before continuing.
  13319.  
  13320.    * When the handler has no more rows in its queue, the table is
  13321.      unlocked.  If no new `INSERT DELAYED' commands are received within
  13322.      `delayed_insert_timeout' seconds, the handler terminates.
  13323.  
  13324.    * If more than `delayed_queue_size' rows are pending already in a
  13325.      specific handler queue, the thread waits until there is room in
  13326.      the queue.  This is useful to ensure that the `mysqld' server
  13327.      doesn't use all memory for the delayed memory queue.
  13328.  
  13329.    * The handler thread will show up in the *MySQL* process list with
  13330.      `delayed_insert' in the `Command' column.  It will be killed if
  13331.      you execute a `FLUSH TABLES' command or kill it with `KILL
  13332.      thread_id'. However, it will first store all queued rows into the
  13333.      table before exiting. During this time it will not accept any new
  13334.      `INSERT' commands from another thread. If you execute an `INSERT
  13335.      DELAYED' command after this, a new handler thread will be created.
  13336.  
  13337.    * Note that the above means that `INSERT DELAYED' commands have
  13338.      higher priority than normal `INSERT' commands if there is an
  13339.      `INSERT DELAYED' handler already running!  Other update commands
  13340.      will have to wait until the `INSERT DELAYED' queue is empty,
  13341.      someone kills the handler thread (with `KILL thread_id') or
  13342.      someone executes `FLUSH TABLES'.
  13343.  
  13344.    * The following status variables provide information about `INSERT
  13345.      DELAYED' commands:
  13346.  
  13347.      `Delayed_insert_threads'Number of handler threads
  13348.      `Delayed_writes'        Number of rows written with `INSERT DELAYED'
  13349.      `Not_flushed_delayed_rows'Number of rows waiting to be written
  13350.  
  13351.      You can view these variables by issuing a `SHOW STATUS' statement
  13352.      or by executing a `mysqladmin extended-status' command.
  13353.  
  13354. Note that `INSERT DELAYED' is slower than a normal INSERT if the table
  13355. is not in use.  There is also the additional overhead for the server to
  13356. handle a separate thread for each table on which you use `INSERT
  13357. DELAYED'.  This means that you should only use `INSERT DELAYED' when
  13358. you are really sure you need it!
  13359.  
  13360. `REPLACE' syntax
  13361. ================
  13362.  
  13363.          REPLACE [LOW_PRIORITY | DELAYED]
  13364.              [INTO] tbl_name [(col_name,...)]
  13365.              VALUES (expression,...)
  13366.      or  REPLACE [LOW_PRIORITY | DELAYED]
  13367.              [INTO] tbl_name [(col_name,...)]
  13368.              SELECT ...
  13369.      or  REPLACE [LOW_PRIORITY | DELAYED]
  13370.              [INTO] tbl_name
  13371.              SET col_name=expression, col_name=expression,...
  13372.  
  13373. `REPLACE' works exactly like `INSERT', except that if an old record in
  13374. the table has the same value as a new record on a unique index, the old
  13375. record is deleted before the new record is inserted.  *Note `INSERT':
  13376. INSERT.
  13377.  
  13378. `LOAD DATA INFILE' syntax
  13379. =========================
  13380.  
  13381.      LOAD DATA [LOW_PRIORITY] [LOCAL] INFILE 'file_name.txt' [REPLACE | IGNORE]
  13382.          INTO TABLE tbl_name
  13383.          [FIELDS
  13384.              [TERMINATED BY '\t']
  13385.              [OPTIONALLY] ENCLOSED BY '']
  13386.              [ESCAPED BY '\\' ]]
  13387.          [LINES TERMINATED BY '\n']
  13388.          [IGNORE number LINES]
  13389.          [(col_name,...)]
  13390.  
  13391. The `LOAD DATA INFILE' statement reads rows from a text file into a
  13392. table at a very high speed.  If the `LOCAL' keyword is specified, the
  13393. file is read from the client host.  If `LOCAL' is not specified, the
  13394. file must be located on the server.  (`LOCAL' is available in *MySQL*
  13395. 3.22.6 or later.)
  13396.  
  13397. For security reasons, when reading text files located on the server, the
  13398. files must either reside in the database directory or be readable by
  13399. all.  Also, to use `LOAD DATA INFILE' on server files, you must have the
  13400. *file* privilege on the server host.  *Note Privileges provided::.
  13401.  
  13402. If you specify the keyword `LOW_PRIORITY', execution of the `LOAD DATA'
  13403. statement is delayed until no other clients are reading from the table.
  13404.  
  13405. Using `LOCAL' will be a bit slower than letting the server access the
  13406. files directly, because the contents of the file must travel from the
  13407. client host to the server host.  On the other hand, you do not need the
  13408. *file* privilege to load local files.
  13409.  
  13410. You can also load data files by using the `mysqlimport' utility; it
  13411. operates by sending a `LOAD DATA INFILE' command to the server.  The
  13412. `--local' option causes `mysqlimport' to read data files from the
  13413. client host.  You can specify the `--compress' option to get better
  13414. performance over slow networks if the client and server support the
  13415. compressed protocol.
  13416.  
  13417. When locating files on the server host, the server uses the following
  13418. rules:
  13419.  
  13420.    * If an absolute pathname is given, the server uses the pathname as
  13421.      is.
  13422.  
  13423.    * If a relative pathname with one or more leading components is
  13424.      given, the server searches for the file relative to the server's
  13425.      data directory.
  13426.  
  13427.    * If a filename with no leading components is given, the server
  13428.      looks for the file in the database directory of the current
  13429.      database.
  13430.  
  13431. Note that these rules mean a file given as `./myfile.txt' is read from
  13432. the server's data directory, whereas a file given as `myfile.txt' is
  13433. read from the database directory of the current database.  For example,
  13434. the following `LOAD DATA' statement reads the file `data.txt' from the
  13435. database directory for `db1' because `db1' is the current database,
  13436. even though the statement explicitly loads the file into a table in the
  13437. `db2' database:
  13438.  
  13439.      mysql> USE db1;
  13440.      mysql> LOAD DATA INFILE "data.txt" INTO TABLE db2.my_table;
  13441.  
  13442. The `REPLACE' and `IGNORE' keywords control handling of input records
  13443. that duplicate existing records on unique key values.  If you specify
  13444. `REPLACE', new rows replace existing rows that have the same unique key
  13445. value. If you specify `IGNORE', input rows that duplicate an existing
  13446. row on a unique key value are skipped.  If you don't specify either
  13447. option, an error occurs when a duplicate key value is found, and the
  13448. rest of the text file is ignored.
  13449.  
  13450. If you load data from a local file using the `LOCAL' keyword, the server
  13451. has no way to stop transmission of the file in the middle of the
  13452. operation, so the default bahavior is the same as if `IGNORE' is
  13453. specified.
  13454.  
  13455. `LOAD DATA INFILE' is the complement of `SELECT ... INTO OUTFILE'.
  13456. *Note `SELECT': SELECT.  To write data from a database to a file, use
  13457. `SELECT ... INTO OUTFILE'.  To read the file back into the database,
  13458. use `LOAD DATA INFILE'.  The syntax of the `FIELDS' and `LINES' clauses
  13459. is the same for both commands.  Both clauses are optional, but `FIELDS'
  13460. must precede `LINES' if both are specified.
  13461.  
  13462. If you specify a `FIELDS' clause, each of its subclauses (`TERMINATED
  13463. BY', `[OPTIONALLY] ENCLOSED BY' and `ESCAPED BY') is also optional,
  13464. except that you must specify at least one of them.
  13465.  
  13466. If you don't specify a `FIELDS' clause, the defaults are the same as if
  13467. you had written this:
  13468.  
  13469.      FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\'
  13470.  
  13471. If you don't specify a `LINES' clause, the default is the same as if
  13472. you had written this:
  13473.  
  13474.      LINES TERMINATED BY '\n'
  13475.  
  13476. In other words, the defaults cause `LOAD DATA INFILE' to act as follows
  13477. when reading input:
  13478.  
  13479.    * Look for line boundaries at newlines
  13480.  
  13481.    * Break lines into fields at tabs
  13482.  
  13483.    * Do not expect fields to be enclosed within any quoting characters
  13484.  
  13485.    * Interpret occurrences of tab, newline or `\' preceded by `\' as
  13486.      literal characters that are part of field values
  13487.  
  13488. Conversely, the defaults cause `SELECT ... INTO OUTFILE' to act as
  13489. follows when writing output:
  13490.  
  13491.    * Write tabs between fields
  13492.  
  13493.    * Do not enclose fields within any quoting characters
  13494.  
  13495.    * Use `\' to escape instances of tab, newline or `\' that occur
  13496.      within field values
  13497.  
  13498.    * Write newlines at the ends of lines
  13499.  
  13500. Note that to write `FIELDS ESCAPED BY '\\'', you must specify two
  13501. backslashes for the value to be read as a single backslash.
  13502.  
  13503. The `IGNORE number LINES' option can be used to ignore a header of
  13504. column names at the start of the file:
  13505.  
  13506.      mysql> LOAD DATA INFILE "/tmp/file_name" into table test IGNORE 1 LINES;
  13507.  
  13508. When you use `SELECT ... INTO OUTFILE' in tandem with `LOAD DATA
  13509. INFILE' to write data from a database into a file and then read the
  13510. file back into the database later, the field and line handling options
  13511. for both commands must match.  Otherwise, `LOAD DATA INFILE' will not
  13512. interpret the contents of the file properly.  Suppose you use `SELECT
  13513. ... INTO OUTFILE' to write a file with fields delimited by commas:
  13514.  
  13515.      mysql> SELECT * INTO OUTFILE 'data.txt'
  13516.                 FIELDS TERMINATED BY ','
  13517.                 FROM ...
  13518.  
  13519. To read the comma-delimited file back in, the correct statement would
  13520. be:
  13521.  
  13522.      mysql> LOAD DATA INFILE 'data.txt' INTO TABLE table2
  13523.                 FIELDS TERMINATED BY ',';
  13524.  
  13525. If instead you tried to read in the file with the statement shown
  13526. below, it wouldn't work because it instructs `LOAD DATA INFILE' to look
  13527. for tabs between fields:
  13528.  
  13529.      mysql> LOAD DATA INFILE 'data.txt' INTO TABLE table2
  13530.                 FIELDS TERMINATED BY '\t';
  13531.  
  13532. The likely result is that each input line would be interpreted as a
  13533. single field.
  13534.  
  13535. `LOAD DATA INFILE' can be used to read files obtained from external
  13536. sources, too. For example, a file in dBASE format will have fields
  13537. separated by commas and enclosed in double quotes.  If lines in the
  13538. file are terminated by newlines, the command shown below illustrates
  13539. the field and line handling options you would use to load the file:
  13540.  
  13541.      mysql> LOAD DATA INFILE 'data.txt' INTO TABLE tbl_name
  13542.                 FIELDS TERMINATED BY ',' ENCLOSED BY '"'
  13543.                 LINES TERMINATED BY '\n';
  13544.  
  13545. Any of the field or line handling options may specify an empty string
  13546. (`''').  If not empty, the `FIELDS [OPTIONALLY] ENCLOSED BY' and
  13547. `FIELDS ESCAPED BY' values must be a single character.  The `FIELDS
  13548. TERMINATED BY' and `LINES TERMINATED BY' values may be more than one
  13549. character.  For example, to write lines that are terminated by carriage
  13550. return-linefeed pairs, or to read a file containing such lines, specify
  13551. a `LINES TERMINATED BY '\r\n'' clause.
  13552.  
  13553. `FIELDS [OPTIONALLY] ENCLOSED BY' controls quoting of fields.  For
  13554. output (`SELECT ... INTO OUTFILE'), if you omit the word `OPTIONALLY',
  13555. all fields are enclosed by the `ENCLOSED BY' character.  An example of
  13556. such output (using a comma as the field delimiter) is shown below:
  13557.  
  13558.      "1","a string","100.20"
  13559.      "2","a string containing a , comma","102.20"
  13560.      "3","a string containing a \" quote","102.20"
  13561.      "4","a string containing a \", quote and comma","102.20"
  13562.  
  13563. If you specify `OPTIONALLY', the `ENCLOSED BY' character is used only
  13564. to enclose `CHAR' and `VARCHAR' fields:
  13565.  
  13566.      1,"a string",100.20
  13567.      2,"a string containing a , comma",102.20
  13568.      3,"a string containing a \" quote",102.20
  13569.      4,"a string containing a \", quote and comma",102.20
  13570.  
  13571. Note that occurrences of the `ENCLOSED BY' character within a field
  13572. value are escaped by prefixing them with the `ESCAPED BY' character.
  13573. Also note that if you specify an empty `ESCAPED BY' value, it is
  13574. possible to generate output that cannot be read properly by `LOAD DATA
  13575. INFILE'. For example, the output just shown above would appear as shown
  13576. below if the escape character is empty.  Observe that the second field
  13577. in the fourth line contains a comma following the quote, which
  13578. (erroneously) appears to terminate the field:
  13579.  
  13580.      1,"a string",100.20
  13581.      2,"a string containing a , comma",102.20
  13582.      3,"a string containing a " quote",102.20
  13583.      4,"a string containing a ", quote and comma",102.20
  13584.  
  13585. For input, the `ENCLOSED BY' character, if present, is stripped from the
  13586. ends of field values.  (This is true whether or not `OPTIONALLY' is
  13587. specified; `OPTIONALLY' has no effect on input interpretation.)
  13588. Occurrences of the `ENCLOSED BY' character preceded by the `ESCAPED BY'
  13589. character are interpreted as part of the current field value.  In
  13590. addition, duplicated `ENCLOSED BY' characters occurring within fields
  13591. are interpreted as single `ENCLOSED BY' characters if the field itself
  13592. starts with that character.  For example, if `ENCLOSED BY '"'' is
  13593. specified, quotes are handled as shown below:
  13594.  
  13595.      "The ""BIG"" boss"  -> The "BIG" boss
  13596.      The "BIG" boss      -> The "BIG" boss
  13597.      The ""BIG"" boss    -> The ""BIG"" boss
  13598.  
  13599. `FIELDS ESCAPED BY' controls how to write or read special characters.
  13600. If the `FIELDS ESCAPED BY' character is not empty, it is used to prefix
  13601. the following characters on output:
  13602.    * The `FIELDS ESCAPED BY' character
  13603.  
  13604.    * The `FIELDS [OPTIONALLY] ENCLOSED BY' character
  13605.  
  13606.    * The first character of the `FIELDS TERMINATED BY' and `LINES
  13607.      TERMINATED BY' values
  13608.  
  13609.    * ASCII `0' (what is actually written following the escape character
  13610.      is ASCII `'0'', not a zero-valued byte)
  13611.  
  13612. If the `FIELDS ESCAPED BY' character is empty, no characters are
  13613. escaped.  It is probably not a good idea to specify an empty escape
  13614. character, particularly if field values in your data contain any of the
  13615. characters in the list just given.
  13616.  
  13617. For input, if the `FIELDS ESCAPED BY' character is not empty,
  13618. occurrences of that character are stripped and the following character
  13619. is taken literally as part of a field value.  The exceptions are an
  13620. escaped `0' or `N' (e.g., `\0' or `\N' if the escape character is `\').
  13621. These sequences are interpreted as ASCII `0' (a zero-valued byte) and
  13622. `NULL'.  See below for the rules on `NULL' handling.
  13623.  
  13624. For more information about `\'-escape syntax, see *Note Literals::.
  13625.  
  13626. In certain cases, field and line handling options interact:
  13627.  
  13628.    * If `LINES TERMINATED BY' is an empty string and `FIELDS TERMINATED
  13629.      BY' is non-empty, lines are also terminated with `FIELDS
  13630.      TERMINATED BY'.
  13631.  
  13632.    * If the `FIELDS TERMINATED BY' and `FIELDS ENCLOSED BY' values are
  13633.      both empty (`'''), a fixed-row (non-delimited) format is used.
  13634.      With fixed-row format, no delimiters are used between fields.
  13635.      Instead, column values are written and read using the "display"
  13636.      widths of the columns.  For example, if a column is declared as
  13637.      `INT(7)', values for the column are written using 7-character
  13638.      fields.  On input, values for the column are obtained by reading 7
  13639.      characters.  Fixed-row format also affects handling of `NULL'
  13640.      values; see below.  Note that fixed size format will not work if
  13641.      you are using a multi-byte character set.
  13642.  
  13643. Handling of `NULL' values varies, depending on the `FIELDS' and `LINES'
  13644. options you use:
  13645.  
  13646.    * For the default `FIELDS' and `LINES' values, `NULL' is written as
  13647.      `\N' for output and `\N' is read as `NULL' for input (assuming the
  13648.      `ESCAPED BY' character is `\').
  13649.  
  13650.    * If `FIELDS ENCLOSED BY' is not empty, a field containing the
  13651.      literal word `NULL' as its value is read as a `NULL' value (this
  13652.      differs from the word `NULL' enclosed within `FIELDS ENCLOSED BY'
  13653.      characters, which is read as the string `'NULL'').
  13654.  
  13655.    * If `FIELDS ESCAPED BY' is empty, `NULL' is written as the word
  13656.      `NULL'.
  13657.  
  13658.    * With fixed-row format (which happens when `FIELDS TERMINATED BY'
  13659.      and `FIELDS ENCLOSED BY' are both empty), `NULL' is written as an
  13660.      empty string.  Note that this causes both `NULL' values and empty
  13661.      strings in the table to be indistinguishable when written to the
  13662.      file because they are both written as empty strings.  If you need
  13663.      to be able to tell the two apart when reading the file back in,
  13664.      you should not use fixed-row format.
  13665.  
  13666. Some cases are not supported by `LOAD DATA INFILE':
  13667.    * Fixed-size rows (`FIELDS TERMINATED BY' and `FIELDS ENCLOSED BY'
  13668.      both empty) and `BLOB' or `TEXT' columns.
  13669.  
  13670.    * If you specify one separator that is the same as or a prefix of
  13671.      another, `LOAD DATA INFILE' won't be able to interpret the input
  13672.      properly.  For example, the following `FIELDS' clause would cause
  13673.      problems:
  13674.  
  13675.           FIELDS TERMINATED BY '"' ENCLOSED BY '"'
  13676.  
  13677.    * If `FIELDS ESCAPED BY' is empty, a field value that contains an
  13678.      occurrence of `FIELDS ENCLOSED BY' or `LINES TERMINATED BY'
  13679.      followed by the `FIELDS TERMINATED BY' value will cause `LOAD DATA
  13680.      INFILE' to stop reading a field or line too early.  This happens
  13681.      because `LOAD DATA INFILE' cannot properly determine where the
  13682.      field or line value ends.
  13683.  
  13684. The following example loads all columns of the `persondata' table:
  13685.  
  13686.      mysql> LOAD DATA INFILE 'persondata.txt' INTO TABLE persondata;
  13687.  
  13688. No field list is specified, so `LOAD DATA INFILE' expects input rows to
  13689. contain a field for each table column.  The default `FIELDS' and
  13690. `LINES' values are used.
  13691.  
  13692. If you wish to load only some of a table's columns, specify a field
  13693. list:
  13694.  
  13695.      mysql> LOAD DATA INFILE 'persondata.txt'
  13696.                 INTO TABLE persondata (col1,col2,...);
  13697.  
  13698. You must also specify a field list if the order of the fields in the
  13699. input file differs from the order of the columns in the table.
  13700. Otherwise, *MySQL* cannot tell how to match up input fields with table
  13701. columns.
  13702.  
  13703. If a row has too few fields, the columns for which no input field is
  13704. present are set to default values.  Default value assignment is
  13705. described in *Note `CREATE TABLE': CREATE TABLE.
  13706.  
  13707. An empty field value is interpreted differently than if the field value
  13708. is missing:
  13709.  
  13710.    * For string types, the column is set to the empty string.
  13711.  
  13712.    * For numeric types, the column is set to `0'.
  13713.  
  13714.    * For date and time types, the column is set to the appropriate
  13715.      "zero" value for the type.  *Note Date and time types::.
  13716.  
  13717. `TIMESTAMP' columns are only set to the current date and time if there
  13718. is a `NULL' value for the column, or (for the first `TIMESTAMP' column
  13719. only) if the `TIMESTAMP' column is left out from the field list when a
  13720. field list is specified.
  13721.  
  13722. If an input row has too many fields, the extra fields are ignored and
  13723. the number of warnings is incremented.
  13724.  
  13725. `LOAD DATA INFILE' regards all input as strings, so you can't use
  13726. numeric values for `ENUM' or `SET' columns the way you can with
  13727. `INSERT' statements.  All `ENUM' and `SET' values must be specified as
  13728. strings!
  13729.  
  13730. If you are using the C API, you can get information about the query by
  13731. calling the API function `mysql_info()' when the `LOAD DATA INFILE'
  13732. query finishes.  The format of the information string is shown below:
  13733.  
  13734.      Records: 1  Deleted: 0  Skipped: 0  Warnings: 0
  13735.  
  13736. Warnings occur under the same circumstances as when values are inserted
  13737. via the `INSERT' statement (*note `INSERT': INSERT.), except that `LOAD
  13738. DATA INFILE' also generates warnings when there are too few or too many
  13739. fields in the input row.  The warnings are not stored anywhere; the
  13740. number of warnings can only be used as an indication if everything went
  13741. well.  If you get warnings and want to know exactly why you got them,
  13742. one way to do this is to use `SELECT ... INTO OUTFILE' into another
  13743. file and compare this to your original input file.
  13744.  
  13745. If you need `LOAD DATA INFILE' to read from a pipe, you can use the
  13746. following trick:
  13747.  
  13748.      mkfifo /mysql/db/x/x
  13749.      chmod 666 /mysql/db/x/x
  13750.      cat < /dev/tcp/10.1.1.12/4711 > /nt/mysql/db/x/x
  13751.      mysql -e "LOAD DATA INFILE 'x' INTO TABLE x" x
  13752.  
  13753. For more information about the efficiency of `INSERT' versus `LOAD DATA
  13754. INFILE' and speeding up `LOAD DATA INFILE', *Note Insert speed::.
  13755.  
  13756. `UPDATE' syntax
  13757. ===============
  13758.  
  13759.      UPDATE [LOW_PRIORITY] [IGNORE] tbl_name SET col_name1=expr1,col_name2=expr2,...
  13760.          [WHERE where_definition] [LIMIT #]
  13761.  
  13762. `UPDATE' updates columns in existing table rows with new values.  The
  13763. `SET' clause indicates which columns to modify and the values they
  13764. should be given.  The `WHERE' clause, if given, specifies which rows
  13765. should be updated.  Otherwise all rows are updated.
  13766.  
  13767. If you specify the keyword `LOW_PRIORITY', execution of the `UPDATE' is
  13768. delayed until no other clients are reading from the table.
  13769.  
  13770. If you specify the keyword `IGNORE', the update statement will not
  13771. abort even if we get duplicate key errors during the update.  Rows that
  13772. would cause conflicts will not be updated.
  13773.  
  13774. If you access a column from `tbl_name' in an expression, `UPDATE' uses
  13775. the current value of the column.  For example, the following statement
  13776. sets the `age' column to one more than its current value:
  13777.  
  13778.      mysql> UPDATE persondata SET age=age+1;
  13779.  
  13780. `UPDATE' assignments are evaluated from left to right.  For example, the
  13781. following statement doubles the `age' column, then increments it:
  13782.  
  13783.      mysql> UPDATE persondata SET age=age*2, age=age+1;
  13784.  
  13785. If you set a column to the value it currently has, *MySQL* notices this
  13786. and doesn't update it.
  13787.  
  13788. `UPDATE' returns the number of rows that were actually changed.  In
  13789. *MySQL* 3.22 or later, the C API function `mysql_info()' returns the
  13790. number of rows that were matched and updated and the number of warnings
  13791. that occurred during the `UPDATE'.
  13792.  
  13793. In *MySQL* 3.23 you can use `LIMIT #' to ensure that only a given
  13794. number of rows are changed.
  13795.  
  13796. `USE' syntax
  13797. ============
  13798.  
  13799.      USE db_name
  13800.  
  13801. The `USE db_name' statement tells *MySQL* to use the `db_name' database
  13802. as the default database for subsequent queries.  The database remains
  13803. current until the end of the session, or until another `USE' statement
  13804. is issued:
  13805.  
  13806.      mysql> USE db1;
  13807.      mysql> SELECT count(*) FROM mytable;      # selects from db1.mytable
  13808.      mysql> USE db2;
  13809.      mysql> SELECT count(*) FROM mytable;      # selects from db2.mytable
  13810.  
  13811. Making a particular database current by means of the `USE' statement
  13812. does not preclude you from accessing tables in other databases.  The
  13813. example below accesses the `author' table from the `db1' database and
  13814. the `editor' table from the `db2' database:
  13815.  
  13816.      mysql> USE db1;
  13817.      mysql> SELECT author_name,editor_name FROM author,db2.editor
  13818.                 WHERE author.editor_id = db2.editor.editor_id;
  13819.  
  13820. The `USE' statement is provided for Sybase compatibility.
  13821.  
  13822. `FLUSH' syntax (clearing caches)
  13823. ================================
  13824.  
  13825.      FLUSH flush_option [,flush_option]
  13826.  
  13827. You should use the `FLUSH' command if you want to clear some of the
  13828. internal caches *MySQL* uses.  To execute `FLUSH', you must have the
  13829. *reload* privilege.
  13830.  
  13831. `flush_option' can be any of the following:
  13832.  
  13833. `HOSTS'     Empties the host cache tables.  You should flush the host
  13834.             tables if some of your hosts change IP number or if you get
  13835.             the error message `Host ... is blocked'.  When more than
  13836.             `max_connect_errors' errors occur in a row for a given host
  13837.             while connection to the *MySQL* server, *MySQL* assumes
  13838.             something is wrong and blocks the host from further
  13839.             connection requests.  Flushing the host tables allows the
  13840.             host to attempt to connect again. *Note Blocked host::.) You
  13841.             can start `mysqld' with `-O max_connection_errors=999999999'
  13842.             to avoid this error message.
  13843. `LOGS'      Closes and reopens the standard and update log files.  If
  13844.             you have specified the update log file without an extension,
  13845.             the extension number of the new update log file will be
  13846.             incremented by one relative to the previous file.  If you
  13847.             have used an extension in the file name, *MySQL* will close
  13848.             and reopen the update log file.  *Note Update log::.
  13849. `PRIVILEGES'Reloads the privileges from the grant tables in the `mysql'
  13850.             database.
  13851. `TABLES'    Closes all open tables.
  13852. `TABLES     Closes all open tables and locks all tables for all
  13853. WITH READ   databases with a read until one executes `UNLOCK TABLES'.
  13854. LOCK'       
  13855. `STATUS'    Resets most status variables to zero.
  13856.  
  13857. You can also access each of the commands shown above with the
  13858. `mysqladmin' utility, using the `flush-hosts', `flush-logs', `reload'
  13859. or `flush-tables' commands.
  13860.  
  13861. `KILL' syntax
  13862. =============
  13863.  
  13864.      KILL thread_id
  13865.  
  13866. Each connection to `mysqld' runs in a separate thread.  You can see
  13867. which threads are running with the `SHOW PROCESSLIST' command, and kill
  13868. a thread with the `KILL thread_id' command.
  13869.  
  13870. If you have the *process* privilege, you can see and kill all threads.
  13871. Otherwise, you can see and kill only your own threads.
  13872.  
  13873. You can also use the `mysqladmin processlist' and `mysqladmin kill'
  13874. commands to examine and kill threads.
  13875.  
  13876. `SHOW' syntax (Get information about tables, columns,...)
  13877. =========================================================
  13878.  
  13879.         SHOW DATABASES [LIKE wild]
  13880.      or SHOW TABLES [FROM db_name] [LIKE wild]
  13881.      or SHOW COLUMNS FROM tbl_name [FROM db_name] [LIKE wild]
  13882.      or SHOW INDEX FROM tbl_name [FROM db_name]
  13883.      or SHOW TABLE STATUS [FROM db_name] [LIKE wild]
  13884.      or SHOW STATUS [LIKE wild]
  13885.      or SHOW VARIABLES [LIKE wild]
  13886.      or SHOW [FULL] PROCESSLIST
  13887.      or SHOW GRANTS FOR user
  13888.  
  13889. `SHOW' provides information about databases, tables, columns or status
  13890. information about the server. If the `LIKE wild' part is used, the
  13891. `wild' string can be a string that uses the SQL `%' and `_' wildcard
  13892. characters.
  13893.  
  13894. SHOW information about database, tables, columns and index
  13895. ----------------------------------------------------------
  13896.  
  13897. You can use `db_name.tbl_name' as an alternative to the `tbl_name FROM
  13898. db_name' syntax.  These two statements are equivalent:
  13899.  
  13900.      mysql> SHOW INDEX FROM mytable FROM mydb;
  13901.      mysql> SHOW INDEX FROM mydb.mytable;
  13902.  
  13903. `SHOW DATABASES' lists the databases on the *MySQL* server host.  You
  13904. can also get this list using the `mysqlshow' command.
  13905.  
  13906. `SHOW TABLES' lists the tables in a given database.  You can also get
  13907. this list using the `mysqlshow db_name' command.
  13908.  
  13909. *Note:* If a user doesn't have any privileges for a table, the table
  13910. will not show up in the output from `SHOW TABLES' or `mysqlshow
  13911. db_name'.
  13912.  
  13913. `SHOW COLUMNS' lists the columns in a given table.  If the column types
  13914. are different than you expect them to be based on a `CREATE TABLE'
  13915. statement, note that *MySQL* sometimes changes column types.  *Note
  13916. Silent column changes::.
  13917.  
  13918. The `DESCRIBE' statement provides information similar to `SHOW COLUMNS'.
  13919. *Note `DESCRIBE': DESCRIBE.
  13920.  
  13921. `SHOW FIELDS' is a synonym for `SHOW COLUMNS' and `SHOW KEYS' is a
  13922. synonym for `SHOW INDEX'.  You can also list a table's columns or
  13923. indexes with `mysqlshow db_name tbl_name' or `mysqlshow -k db_name
  13924. tbl_name'.
  13925.  
  13926. `SHOW INDEX' returns the index information in a format that closely
  13927. resembles the `SQLStatistics' call in ODBC. The following columns are
  13928. returned:
  13929.  
  13930. *Column*                  *Meaning*
  13931. `Table'                   Name of the table
  13932. `Non_unique'              0 if the index can't contain duplicates.
  13933. `Key_name'                Name of the index
  13934. `Seq_in_index'            Column sequence number in index, starting with
  13935.                           1.
  13936. `Column_name'             Column name.
  13937. `Collation'               How the column is sorted in the index.  In
  13938.                           *MySQL*, this can have values `A' (Ascending)
  13939.                           or `NULL' (Not sorted).
  13940. `Cardinality'             Number of unique values in the index.  This is
  13941.                           updated by running `isamchk -a'.
  13942. `Sub_part'                Number of indexed characters if the column is
  13943.                           only partly indexed. `NULL' if the entire key
  13944.                           is indexed.
  13945.  
  13946. SHOW status information about tables
  13947. ------------------------------------
  13948.  
  13949. `SHOW TABLE STATUS' (new in version 3.23) works likes `SHOW STATUS',
  13950. but provides a lot of information about each table. You can also get
  13951. this list using the `mysqlshow --status db_name' command.  The
  13952. following columns are returned:
  13953.  
  13954. *Column*               *Meaning*
  13955. `Name'                 Name of the table
  13956. `Type'                 Type of table (BDB, ISAM, MyISAM or HEAP)
  13957. `Row_format'           The row storage format (Fixed, Dynamic, or
  13958.                        Compressed)
  13959. `Rows'                 Number of rows
  13960. `Avg_row_length'       Average row length
  13961. `Data_length'          Length of the data file
  13962. `Max_data_length'      Max length of the data file
  13963. `Index_length'         Length of the index file
  13964. `Data_free'            Number of allocated but not used bytes
  13965. `Auto_increment'       Next autoincrement value
  13966. `Create_time'          When the table was created
  13967. `Update_time'          When the data file was last updated
  13968. `Check_time'           When one last run a check on the table
  13969. `Create_options'       Extra options used with `CREATE TABLE'
  13970. `Comment'              The comment used when creating the table (or some
  13971.                        information why *MySQL* couldn't access the table
  13972.                        information).
  13973.  
  13974. SHOW status information
  13975. -----------------------
  13976.  
  13977. `SHOW STATUS' provides server status information (like `mysqladmin
  13978. extended-status'). The output resembles that shown below, though the
  13979. format and numbers probably differ:
  13980.  
  13981.      +--------------------------+-------+
  13982.      | Variable_name            | Value |
  13983.      +--------------------------+-------+
  13984.      | Aborted_clients          | 0     |
  13985.      | Aborted_connects         | 0     |
  13986.      | Bytes_received           | 100   |
  13987.      | Bytes_sent               | 2106  |
  13988.      | Connections              | 4     |
  13989.      | Created_tmp_tables       | 0     |
  13990.      | Delayed_insert_threads   | 0     |
  13991.      | Delayed_writes           | 0     |
  13992.      | Delayed_errors           | 0     |
  13993.      | Flush_commands           | 1     |
  13994.      | Handler_delete           | 0     |
  13995.      | Handler_read_first       | 1     |
  13996.      | Handler_read_key         | 0     |
  13997.      | Handler_read_next        | 2     |
  13998.      | Handler_read_prev        | 0     |
  13999.      | Handler_read_rnd         | 0     |
  14000.      | Handler_read_rnd_next    | 25    |
  14001.      | Handler_update           | 0     |
  14002.      | Handler_write            | 0     |
  14003.      | Key_blocks_used          | 1     |
  14004.      | Key_read_requests        | 2     |
  14005.      | Key_reads                | 1     |
  14006.      | Key_write_requests       | 0     |
  14007.      | Key_writes               | 0     |
  14008.      | Max_used_connections     | 0     |
  14009.      | Not_flushed_key_blocks   | 0     |
  14010.      | Not_flushed_delayed_rows | 0     |
  14011.      | Open_tables              | 0     |
  14012.      | Open_files               | 0     |
  14013.      | Open_streams             | 0     |
  14014.      | Opened_tables            | 6     |
  14015.      | Questions                | 4     |
  14016.      | Slow_launch_threads      | 0     |
  14017.      | Slow_queries             | 0     |
  14018.      | Slave_running            | OFF   |
  14019.      | Threads_cached           | 0     |
  14020.      | Threads_connected        | 1     |
  14021.      | Threads_running          | 1     |
  14022.      | Uptime                   | 1256  |
  14023.      +--------------------------+-------+
  14024.  
  14025. The status variables listed above have the following meaning:
  14026.  
  14027. `Aborted_clients'         Number of connections that has been aborted
  14028.                           because the client has died without closing
  14029.                           the connection properly.
  14030. `Aborted_connects'        Number of tries to connect to the *MySQL*
  14031.                           server that has failed.
  14032. `Bytes_received'          Number of bytes received from the client
  14033. `Bytes_sent'              Number of bytes received from the client
  14034. `Connections'             Number of connection attempts to the *MySQL*
  14035.                           server.
  14036. `Created_tmp_tables'      Number of implicit temporary tables that has
  14037.                           been created while executing statements.
  14038. `Delayed_insert_threads'  Number of delayed insert handler threads in
  14039.                           use.
  14040. `Delayed_writes'          Number of rows written with `INSERT DELAYED'.
  14041. `Delayed_errors'          Number of rows written with `INSERT DELAYED'
  14042.                           for which some error occurred (probably
  14043.                           `duplicate key').
  14044. `Flush_commands'          Number of executed `FLUSH' commands.
  14045. `Handler_delete'          Number of times a row was deleted from a table.
  14046. `Handler_read_first'      Number of times the first entry was read from
  14047.                           an index.  If this is high, it suggests that
  14048.                           the server is doing a lot of full index scans,
  14049.                           for example, `SELECT col1 FROM foo', assuming
  14050.                           that col1 is indexed
  14051. `Handler_read_key'        Number of requests to read a row based on a
  14052.                           key. If this is high, it is a good indication
  14053.                           that your queries and tables are properly
  14054.                           indexed.
  14055. `Handler_read_next'       Number of requests to read next row in key
  14056.                           order. This will be incremented if you are
  14057.                           querying an index column with a range
  14058.                           contraint. This also will be incremented if
  14059.                           you are doing an index scan.
  14060. `Handler_read_rnd'        Number of requests to read a row based on a
  14061.                           fixed position.  This will be high if you are
  14062.                           doing a lot of queries that require sorting of
  14063.                           the result.
  14064. `Handler_read_rnd_next'   Number of requests to read the next row in the
  14065.                           datafile.  This will be high if you are doing
  14066.                           a lot of table scans - generally this suggests
  14067.                           that you tables are not properly indexed or
  14068.                           that you queries are not written to take
  14069.                           advantaged of the indeces you have..
  14070. `Handler_update'          Number of requests to update a row in a table.
  14071. `Handler_write'           Number of requests to insert a row in a table.
  14072. `Key_blocks_used'         The number of used blocks in the key cache.
  14073. `Key_read_requests'       The number of requests to read a key block
  14074.                           from the cache.
  14075. `Key_reads'               The number of physical reads of a key block
  14076.                           from disk.
  14077. `Key_write_requests'      The number of requests to write a key block to
  14078.                           the cache.
  14079. `Key_writes'              The number of physical writes of a key block
  14080.                           to disk.
  14081. `Max_used_connections'    The maximum number of connections that has
  14082.                           been in use simultaneously.
  14083. `Not_flushed_key_blocks'  Keys blocks in the key cache that has changed
  14084.                           but hasn't yet been flushed to disk.
  14085. `Not_flushed_delayed_rows'Number of rows waiting to be written in
  14086.                           `INSERT DELAY' queues.
  14087. `Open_tables'             Number of tables that are open.
  14088. `Open_files'              Number of files that are open.
  14089. `Open_streams'            Number of streams that are open (used mainly
  14090.                           for logging)
  14091. `Opened_tables'           Number of tables that has been opened.
  14092. `Questions'               Number of queries sent to the server.
  14093. `Slow_launch_threads'     Number of threads that has taken more than
  14094.                           `slow_launch_time' to connect.
  14095. `Slow_queries'            Number of queries that has taken more than
  14096.                           `long_query_time'
  14097. `Threads_cached'          Number of threads in the thread cache.
  14098. `Threads_connected'       Number of currently open connections.
  14099. `Threads_running'         Number of threads that are not sleeping.
  14100. `Uptime'                  How many seconds the server has been up.
  14101.  
  14102. Some comments about the above:
  14103.  
  14104.    * If `Opened_tables' is big, then your `table_cache' variable is
  14105.      probably too small.
  14106.  
  14107.    * If `key_reads' is big, then your `key_cache' is probably too
  14108.      small.  The cache hit rate can be calculated with
  14109.      `key_reads'/`key_read_requests'.
  14110.  
  14111.    * If `Handler_read_rnd' is big, then you have a probably a lot of
  14112.      queries that requires *MySQL* to scan whole tables or you have
  14113.      joins that doesn't use keys properly.
  14114.  
  14115. SHOW VARIABLES
  14116. --------------
  14117.  
  14118. `SHOW VARIABLES' shows the values of the some of *MySQL* system
  14119. variables.  You can also get this information using the `mysqladmin
  14120. variables' command.  If the default values are unsuitable, you can set
  14121. most of these variables using command-line options when `mysqld' starts
  14122. up.  *Note Command-line options::.
  14123.  
  14124. The output resembles that shown below, though the format and numbers may
  14125. differ somewhat:
  14126.  
  14127.      +----------------------------+------------------------------+
  14128.      | Variable_name           | Value                           |
  14129.      +----------------------------+------------------------------+
  14130.      | ansi_mode               | OFF                             |
  14131.      | back_log                | 50                              |
  14132.      | basedir                 | /usr/local/mysql/               |
  14133.      | bdb_cache_size          | 1048540                         |
  14134.      | bdb_home                | /usr/local/mysql/data/          |
  14135.      | bdb_logdir              |                                 |
  14136.      | bdb_tmpdir              | /tmp/                           |
  14137.      | character_set           | latin1                          |
  14138.      | character_sets          | latin1                          |
  14139.      | connect_timeout         | 5                               |
  14140.      | concurrent_insert       | ON                              |
  14141.      | datadir                 | /usr/local/mysql/data/          |
  14142.      | delay_key_write         | ON                              |
  14143.      | delayed_insert_limit    | 100                             |
  14144.      | delayed_insert_timeout  | 300                             |
  14145.      | delayed_queue_size      | 1000                            |
  14146.      | join_buffer_size        | 131072                          |
  14147.      | flush                   | OFF                             |
  14148.      | flush_time              | 0                               |
  14149.      | init_file               |                                 |
  14150.      | interactive_timeout     | 28800                           |
  14151.      | key_buffer_size         | 16776192                        |
  14152.      | language                | /usr/local/mysql/share/english/ |
  14153.      | log                     | OFF                             |
  14154.      | log_update              | OFF                             |
  14155.      | log_bin                 | OFF                             |
  14156.      | log_slave_updates       | OFF                             |
  14157.      | long_query_time         | 10                              |
  14158.      | low_priority_updates    | OFF                             |
  14159.      | lower_case_table_names  | 0                               |
  14160.      | max_allowed_packet      | 1047552                         |
  14161.      | max_connections         | 100                             |
  14162.      | max_connect_errors      | 10                              |
  14163.      | max_delayed_threads     | 20                              |
  14164.      | max_heap_table_size     | 16777216                        |
  14165.      | max_join_size           | 4294967295                      |
  14166.      | max_sort_length         | 1024                            |
  14167.      | max_tmp_tables          | 32                              |
  14168.      | max_write_lock_count    | 4294967295                      |
  14169.      | myisam_sort_buffer_size | 8388608                         |
  14170.      | net_buffer_length       | 16384                           |
  14171.      | net_retry_count         | 10                              |
  14172.      | pid_file                | /usr/local/mysql/data/tik.pid   |
  14173.      | port                    | 3306                            |
  14174.      | protocol_version        | 10                              |
  14175.      | record_buffer           | 131072                          |
  14176.      | skip_locking            | ON                              |
  14177.      | skip_networking         | OFF                             |
  14178.      | skip_show_database      | OFF                             |
  14179.      | slow_launch_time        | 2                               |
  14180.      | socket                  | /tmp/mysql.sock                 |
  14181.      | sort_buffer             | 2097116                         |
  14182.      | table_cache             | 64                              |
  14183.      | table_type              | MYISAM                          |
  14184.      | thread_stack            | 131072                          |
  14185.      | thread_cache_size       | 3                               |
  14186.      | tmp_table_size          | 1048576                         |
  14187.      | tmpdir                  | /tmp/                           |
  14188.      | version                 | 3.23.21-beta-debug              |
  14189.      | wait_timeout            | 28800                           |
  14190.      +-----------------------------------+-----------------------+
  14191.  
  14192. Each option is described below. Values for buffer sizes, lengths and
  14193. stack sizes are given in bytes.  You can specify values with a suffix
  14194. of `K' or `M' to indicate kilobytes or megabytes. For example, `16M'
  14195. indicates 16 megabytes.  The case of suffix letters does not matter;
  14196. `16M' and `16m' are equivalent.
  14197.  
  14198. ``ansi_mode'.'
  14199.      Is `ON' if `mysqld' was started with `--ansi'.  *Note Ansi mode::.
  14200.  
  14201. ``back_log''
  14202.      The number of outstanding connection requests *MySQL* can have.
  14203.      This comes into play when the main *MySQL* thread gets *VERY* many
  14204.      connection requests in a very short time. It then takes some time
  14205.      (although very little) for the main thread to check the connection
  14206.      and start a new thread. The `back_log' value indicates how many
  14207.      requests can be stacked during this short time before *MySQL*
  14208.      momentarily stops answering new requests. You need to increase
  14209.      this only if you expect a large number of connections in a short
  14210.      period of time.
  14211.  
  14212.      In other words, this value is the size of the listen queue for
  14213.      incoming TCP/IP connections.  Your operating system has its own
  14214.      limit on the size of this queue.  The manual page for the Unix
  14215.      `listen(2)' system call should have more details.  Check your OS
  14216.      documentation for the maximum value for this variable.  Attempting
  14217.      to set `back_log' higher than your operating system limit will be
  14218.      ineffective.
  14219.  
  14220. ``bdb_cache_size''
  14221.      The buffer that is allocated to cache index and rows for `BDB'
  14222.      tables.  If you don't use `BDB' tables, you should set this to 0 or
  14223.      start `mysqld' with `--skip-bdb' o not waste memory for this cache.
  14224.  
  14225. ``concurrent_inserts''
  14226.      If `ON' (the default), `MySQL' will allow you to use `INSERT' on
  14227.      `MyISAM' tables at the same time as you run `SELECT' queries on
  14228.      them.  You can turn this option off by starting mysqld with
  14229.      `--safe' or `--skip-new'.
  14230.  
  14231. ``connect_timeout''
  14232.      The number of seconds the `mysqld' server is waiting for a connect
  14233.      packet before responding with `Bad handshake'.
  14234.  
  14235. ``delayed_insert_timeout''
  14236.      How long a `INSERT DELAYED' thread should wait for `INSERT'
  14237.      statements before terminating.
  14238.  
  14239. ``delayed_insert_limit''
  14240.      After inserting `delayed_insert_limit' rows, the `INSERT DELAYED'
  14241.      handler will check if there are any `SELECT' statements pending.
  14242.      If so, it allows these to execute before continuing.
  14243.  
  14244. ``delay_key_write''
  14245.      If enabled (is on by default), *MySQL* will honor the
  14246.      `delay_key_write' option `CREATE TABLE'.  This means that the key
  14247.      buffer for tables with this option will not get flushed on every
  14248.      index update, but only when a table is closed.  This will speed up
  14249.      writes on keys a lot but you should add automatic checking of all
  14250.      tables with `myisamchk --fast --force' if you use this.  Note that
  14251.      if you start `mysqld' with the `--delay-key-write-for-all-tables'
  14252.      option this means that all tables will be treated as if they were
  14253.      created with the `delay_key_write' option.  You can clear this flag
  14254.      by starting `mysqld' with `--skip-new' or `--safe-mode'.
  14255.  
  14256. ``delayed_queue_size''
  14257.      What size queue (in rows) should be allocated for handling `INSERT
  14258.      DELAYED'.  If the queue becomes full, any client that does `INSERT
  14259.      DELAYED' will wait until there is room in the queue again.
  14260.  
  14261. ``flush''
  14262.      This is `ON' if you have started *MySQL* with the `--flush' option.
  14263.  
  14264. ``flush_time''
  14265.      If this is set to a non-zero value, then every `flush_time'
  14266.      seconds all tables will be closed (to free up resources and sync
  14267.      things to disk). We only recommend this option on Win95, Win98 or
  14268.      on system where you have very little resources.
  14269.  
  14270. ``init_file''
  14271.      The name of the file specified with the `--init-file' option when
  14272.      you start the server.  This is a file of SQL statements you want
  14273.      the server to execute when it starts.
  14274.  
  14275. ``interactive_timeout''
  14276.      The number of seconds the server waits for activity on an
  14277.      interactive connection before closing it.  An interactive client
  14278.      is defined as a client that uses the `CLIENT_INTERACTIVE' option to
  14279.      `mysql_real_connect()'.  See also `wait_timeout'.
  14280.  
  14281. ``join_buffer_size''
  14282.      The size of the buffer that is used for full joins (joins that do
  14283.      not use indexes).  The buffer is allocated one time for each full
  14284.      join between two tables. Increase this value to get a faster full
  14285.      join when adding indexes is not possible. (Normally the best way
  14286.      to get fast joins is to add indexes.)
  14287.  
  14288. ``key_buffer_size''
  14289.      Index blocks are buffered and are shared by all threads.
  14290.      `key_buffer_size' is the size of the buffer used for index blocks.
  14291.  
  14292.      Increase this to get better index handling (for all reads and
  14293.      multiple writes) to as much as you can afford; 64M on a 256M
  14294.      machine that mainly runs *MySQL* is quite common.  If you however
  14295.      make this too big (more than 50% of your total memory?) your
  14296.      system may start to page and become REALLY slow. Remember that
  14297.      because *MySQL* does not cache data read, that you will have to
  14298.      leave some room for the OS filesystem cache.
  14299.  
  14300.      You can check the performance of the key buffer by doing `show
  14301.      status' and examine the variables `Key_read_requests',
  14302.      `Key_reads', `Key_write_requests' and `Key_writes'.  The
  14303.      `Key_reads/Key_read_request' ratio should normally be < 0.01.  The
  14304.      `Key_write/Key_write_requests' is usually near 1 if you are using
  14305.      mostly updates/deletes but may be much smaller if you tend to do
  14306.      updates that affect many at the same time or if you are using
  14307.      `delay_key_write'. *Note SHOW::.
  14308.  
  14309.      To get even more speed when writing many rows at the same time use
  14310.      `LOCK TABLES'.  *Note `LOCK TABLES': LOCK TABLES.
  14311.  
  14312. ``lower_case_table_names''
  14313.      Change all table names to lower case on disk.
  14314.  
  14315. ``long_query_time''
  14316.      If a query takes longer than this (in seconds), the `Slow_queries'
  14317.      counter will be incremented.
  14318.  
  14319. ``max_allowed_packet''
  14320.      The maximum size of one packet. The message buffer is initialized
  14321.      to `net_buffer_length' bytes, but can grow up to
  14322.      `max_allowed_packet' bytes when needed.  This value by default is
  14323.      small, to catch big (possibly wrong) packets.  You must increase
  14324.      this value if you are using big `BLOB' columns. It should be as
  14325.      big as the biggest `BLOB' you want to use.
  14326.  
  14327. ``max_connections''
  14328.      The number of simultaneous clients allowed. Increasing this value
  14329.      increases the number of file descriptors that `mysqld' requires.
  14330.      See below for comments on file descriptor limits. *Note Too many
  14331.      connections::.
  14332.  
  14333. ``max_connect_errors''
  14334.      If there is more than this number of interrupted connections from
  14335.      a host this host will be blocked from further connections.  You
  14336.      can unblock a host with the command `FLUSH HOSTS'.
  14337.  
  14338. ``max_delayed_threads''
  14339.      Don't start more than this number of threads to handle `INSERT
  14340.      DELAYED' statements.  If you try to insert data into a new table
  14341.      after all `INSERT DELAYED' threads are in use, the row will be
  14342.      inserted as if the `DELAYED' attribute wasn't specified.
  14343.  
  14344. ``max_join_size''
  14345.      Joins that are probably going to read more than `max_join_size'
  14346.      records return an error. Set this value if your users tend to
  14347.      perform joins without a `WHERE' clause that take a long time and
  14348.      return millions of rows.
  14349.  
  14350. ``max_heap_table_size''
  14351.      Don't allow creation of heap tables bigger than this.
  14352.  
  14353. ``max_sort_length''
  14354.      The number of bytes to use when sorting `BLOB' or `TEXT' values
  14355.      (only the first `max_sort_length' bytes of each value are used;
  14356.      the rest are ignored).
  14357.  
  14358. ``max_tmp_tables''
  14359.      (This option doesn't yet do anything).  Maximum number of
  14360.      temporary tables a client can keep open at the same time.
  14361.  
  14362. ``max_write_lock_count''
  14363.      After this many write locks, allow some read locks to run in
  14364.      between.
  14365.  
  14366. ``myisam_sort_buffer_size''
  14367.      The buffer that is allocated when sorting the index when doing a
  14368.      `REPAIR' table.
  14369.  
  14370. ``net_buffer_length''
  14371.      The communication buffer is reset to this size between queries.
  14372.      This should not normally be changed, but if you have very little
  14373.      memory, you can set it to the expected size of a query.  (That is,
  14374.      the expected length of SQL statements sent by clients.  If
  14375.      statements exceed this length, the buffer is automatically
  14376.      enlarged, up to `max_allowed_packet' bytes.)
  14377.  
  14378. ``net_retry_count''
  14379.      If a read on a communication port is interrupted, retry this many
  14380.      times before giving up.  This value should be quite high on
  14381.      `FreeBSD' as internal interrupts is sent to all threads.
  14382.  
  14383. ``net_read_timeout''
  14384.      Number of seconds to wait for more data from a connection before
  14385.      aborting the read.  Note that when we don't expect data from a
  14386.      connection, the timeout is defined by `write_timeout'.
  14387.  
  14388. ``net_write_timeout''
  14389.      Number of seconds to wait for a block to be written to a
  14390.      connection before aborting the write.
  14391.  
  14392. ``record_buffer''
  14393.      Each thread that does a sequential scan allocates a buffer of this
  14394.      size for each table it scans. If you do many sequential scans, you
  14395.      may want to increase this value.
  14396.  
  14397. ``query_buffer_size''
  14398.      The initial allocation of the query buffer. If most of your
  14399.      queries are long (like when inserting blobs), you should increase
  14400.      this!
  14401.  
  14402. ``skip_show_databases''
  14403.      This prevents people from doing `SHOW DATABASES', if they don't
  14404.      have the `PROCESS_PRIV' privilege. This can improve security if
  14405.      you're concerned about people being able to see what databases and
  14406.      tables other users have.
  14407.  
  14408. ``slow_launch_time''
  14409.      If the creating of the thread longer than this (in seconds), the
  14410.      `Slow_launch_threads' counter will be incremented.
  14411.  
  14412. ``sort_buffer''
  14413.      Each thread that needs to do a sort allocates a buffer of this
  14414.      size. Increase this value for faster `ORDER BY' or `GROUP BY'
  14415.      operations.  *Note Temporary files::.
  14416.  
  14417. ``table_cache''
  14418.      The number of open tables for all threads. Increasing this value
  14419.      increases the number of file descriptors that `mysqld' requires.
  14420.      *MySQL* needs two file descriptors for each unique open table.
  14421.      See below for comments on file descriptor limits. You can check if
  14422.      you need to increase the table cache by checking the
  14423.      `Opened_tables' variable. *Note SHOW::.  If this variable is big
  14424.      and you don't do `FLUSH TABLES' a lot (which just forces all
  14425.      tables to be closed and reopenend), then you should increase the
  14426.      value of this variable.
  14427.  
  14428.      For information about how the table cache works, see *Note Table
  14429.      cache::.
  14430.  
  14431. ``thread_cache_size''
  14432.      How many threads we should keep keep in a cache for reuse.  When a
  14433.      client disconnects the clients threads is put in the cache if there
  14434.      isn't more than `thread_cache_size' threads from before.  All new
  14435.      threads are first taken from the cache and only when the cache is
  14436.      empty a new thread is created.  This variable can be increased to
  14437.      improve performance if you have a lot of new connections (Normally
  14438.      this doesn't however give a notable performance improvement if you
  14439.      have a good thread implementation).
  14440.  
  14441. ``thread_concurrency''
  14442.      On Solaris, `mysqld' will call `thr_setconcurrency()' with this
  14443.      value.  `thr_setconcurrency()' permits the application to give the
  14444.      threads system a hint, for the desired number of threads that
  14445.      should be run at the same time.
  14446.  
  14447. ``thread_stack''
  14448.      The stack size for each thread.  Many of the limits detected by the
  14449.      `crash-me' test are dependent on this value. The default is large
  14450.      enough for normal operation.  *Note Benchmarks::.
  14451.  
  14452. ``tmp_table_size''
  14453.      If an in-memory temporary table exceeds this size, *MySQL* will
  14454.      automatically convert it to an on-disk `MyISAM' table.  Increase
  14455.      the value of `tmp_table_size' if you do many advanced `GROUP BY'
  14456.      queries and you have lots of memory.
  14457.  
  14458. ``wait_timeout''
  14459.      The number of seconds the server waits for activity on a
  14460.      connection before closing it. See also `interactive_timeout'.
  14461.  
  14462. The manual section that describes tuning *MySQL* contains some
  14463. information of how to tune the above variables.
  14464.  
  14465. SHOW information about connected threads (processes)
  14466. ----------------------------------------------------
  14467.  
  14468. `SHOW PROCESSLIST' shows you which threads are running.  You can also
  14469. get this information using the `mysqladmin processlist' command.  If
  14470. you have the *process* privilege, you can see all threads.  Otherwise,
  14471. you can see only your own threads.  *Note `KILL': KILL.  If you don't
  14472. use the the `FULL' option, then only the first 100 characters of each
  14473. query will be shown.
  14474.  
  14475. SHOW GRANTS (privileges) for a user
  14476. -----------------------------------
  14477.  
  14478. `SHOW GRANTS FOR user' lists the grant commands that must be issued to
  14479. duplicate the grants for a user.
  14480.  
  14481.      mysql> SHOW GRANTS FOR root@localhost;
  14482.      +---------------------------------------------------------------------+
  14483.      | Grants for root@localhost                                           |
  14484.      +---------------------------------------------------------------------+
  14485.      | GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
  14486.      +---------------------------------------------------------------------+
  14487.  
  14488. `EXPLAIN' syntax (Get information about a `SELECT')
  14489. ===================================================
  14490.  
  14491.          EXPLAIN tbl_name
  14492.      or  EXPLAIN SELECT select_options
  14493.  
  14494. `EXPLAIN tbl_name' is a synonym for `DESCRIBE tbl_name' or `SHOW
  14495. COLUMNS FROM tbl_name'.
  14496.  
  14497. When you precede a `SELECT' statement with the keyword `EXPLAIN',
  14498. *MySQL* explains how it would process the `SELECT', providing
  14499. information about how tables are joined and in which order.
  14500.  
  14501. With the help of `EXPLAIN', you can see when you must add indexes to
  14502. tables to get a faster `SELECT' that uses indexes to find the records.
  14503. You can also see if the optimizer joins the tables in an optimal order.
  14504. To force the optimizer to use a specific join order for a `SELECT'
  14505. statement, add a `STRAIGHT_JOIN' clause.
  14506.  
  14507. For non-simple joins, `EXPLAIN' returns a row of information for each
  14508. table used in the `SELECT' statement. The tables are listed in the order
  14509. they would be read.  *MySQL* resolves all joins using a single-sweep
  14510. multi-join method. This means that *MySQL* reads a row from the first
  14511. table, then finds a matching row in the second table, then in the third
  14512. table and so on. When all tables are processed, it outputs the selected
  14513. columns and backtracks through the table list until a table is found
  14514. for which there are more matching rows. The next row is read from this
  14515. table and the process continues with the next table.
  14516.  
  14517. Output from `EXPLAIN' includes the following columns:
  14518.  
  14519. `table'
  14520.      The table to which the row of output refers.
  14521.  
  14522. `type'
  14523.      The join type.  Information about the various types is given below.
  14524.  
  14525. `possible_keys'
  14526.      The `possible_keys' column indicates which indexes *MySQL* could
  14527.      use to find the rows in this table. Note that this column is
  14528.      totally independent of the order of the tables. That means that
  14529.      some of the keys in possible_keys may not be useable in practice
  14530.      with the generated table order.
  14531.  
  14532.      If this column is empty, there are no relevant indexes. In this
  14533.      case, you may be able to improve the performance of your query by
  14534.      examining the `WHERE' clause to see if it refers to some column or
  14535.      columns that would be suitable for indexing.  If so, create an
  14536.      appropriate index and check the query with `EXPLAIN' again. *Note
  14537.      ALTER TABLE::.
  14538.  
  14539.      To see what indexes a table has, use `SHOW INDEX FROM tbl_name'.
  14540.  
  14541. `key'
  14542.      The `key' column indicates the key that *MySQL* actually decided
  14543.      to use. The key is `NULL' if no index was chosen.  If *MySQL*
  14544.      chooses the wrong index, you can probably force *MySQL* to use
  14545.      another index by using `myisamchk --analyze', *Note myisamchk
  14546.      syntax::, or by using `USE INDEX/IGNORE INDEX'.  *Note JOIN::.
  14547.  
  14548. `key_len'
  14549.      The `key_len' column indicates the length of the key that *MySQL*
  14550.      decided to use.  The length is `NULL' if the `key' is `NULL'. Note
  14551.      that this tell us how many parts of a multi-part key *MySQL* will
  14552.      actually use.
  14553.  
  14554. `ref'
  14555.      The `ref' column shows which columns or constants are used with the
  14556.      `key' to select rows from the table.
  14557.  
  14558. `rows'
  14559.      The `rows' column indicates the number of rows *MySQL* believes it
  14560.      must examine to execute the query.
  14561.  
  14562. `Extra'
  14563.      This column contains additional information of how *MySQL* will
  14564.      resolve the query. Here follows an explanation of the different
  14565.      text strings that can be found in this column:
  14566.  
  14567.     `Not exists'
  14568.           *MySQL* was able to do a `LEFT JOIN' optimization on the
  14569.           query and will not examine more rows in this table for a row
  14570.           combination after it founds one rows that matches the `LEFT
  14571.           JOIN' criteria.
  14572.  
  14573.     ``range checked for each record (index map: #)''
  14574.           *MySQL* didn't find a real good index to use. It will instead
  14575.           for each row combination in the preceding tables do a check
  14576.           which index to use (if any) use this index to retrieve the
  14577.           rows from the table.  This isn't very fast but is of course
  14578.           faster than having to do a join without an index.
  14579.  
  14580.     `Using filesort'
  14581.           *MySQL* will need to do an extra pass to find out how to
  14582.           retrieve the rows in sorted order.  The sort is done by going
  14583.           through all rows according to the `join type' and storing the
  14584.           sort key + pointer to the row for all rows that match the
  14585.           `WHERE'. Then the keys are sorted. Finally the rows are
  14586.           retrieved in sorted order.
  14587.  
  14588.     `Using index'
  14589.           The column information is retrieved from the table using only
  14590.           information in the index tree without having to do an
  14591.           additional seek to read the actually row.  This can be done
  14592.           when all the used columns for the table are part of the same
  14593.           index.
  14594.  
  14595.     `Using temporary'
  14596.           To be able to resolve the query *MySQL* will need to create a
  14597.           temporary table to hold the result.  This typically happens
  14598.           if you do an `ORDER BY' on a different column set than you
  14599.           did an `GROUP BY' on.
  14600.  
  14601.     `Where used'
  14602.           A `WHERE' clause will be used to restrict which rows will be
  14603.           matched against the next table or sent to the client.  If you
  14604.           don't have this information and the the table is of type
  14605.           `ALL' or `index' you may have something wrong in your query
  14606.           (if you don't intend to fetch/examine all rows from the
  14607.           table).
  14608.  
  14609.      If you want to get your queries as fast as possible, you should
  14610.      look out for `Using filesort' and `Using temporary'.
  14611.  
  14612. The different join types are listed below, ordered from best to worst
  14613. type:
  14614.  
  14615. `system'
  14616.      The table has only one row (= system table). This is a special
  14617.      case of the `const' join type.
  14618.  
  14619. `const'
  14620.      The table has at most one matching row, which will be read at the
  14621.      start of the query. Because there is only one row, values from the
  14622.      column in this row can be regarded as constants by the rest of the
  14623.      optimizer. `const' tables are very fast as they are read only once!
  14624.  
  14625. `eq_ref'
  14626.      One row will be read from this table for each combination of rows
  14627.      from the previous tables.  This the best possible join type, other
  14628.      than the `const' types.  It is used when all parts of an index are
  14629.      used by the join and the index is `UNIQUE' or a `PRIMARY KEY'.
  14630.  
  14631. `ref'
  14632.      All rows with matching index values will be read from this table
  14633.      for each combination of rows from the previous tables.  `ref' is
  14634.      used if the join uses only a leftmost prefix of the key, or if the
  14635.      key is not `UNIQUE' or a `PRIMARY KEY' (in other words, if the
  14636.      join cannot select a single row based on the key value).  If the
  14637.      key that is used matches only a few rows, this join type is good.
  14638.  
  14639. `range'
  14640.      Only rows that are in a given range will be retrieved, using an
  14641.      index to select the rows.  The `ref' column indicates which index
  14642.      is used.
  14643.  
  14644. `index'
  14645.      This is the same as `ALL', except that only the index tree is
  14646.      scanned.  This is usually faster than `ALL', as the index file is
  14647.      usually smaller than the data file.
  14648.  
  14649. `ALL'
  14650.      A full table scan will be done for each combination of rows from
  14651.      the previous tables.  This is normally not good if the table is
  14652.      the first table not marked `const', and usually *very* bad in all
  14653.      other cases. You normally can avoid `ALL' by adding more indexes,
  14654.      so that the row can be retrieved based on constant values or
  14655.      column values from earlier tables.
  14656.  
  14657. You can get a good indication of how good a join is by multiplying all
  14658. values in the `rows' column of the `EXPLAIN' output. This should tell
  14659. you roughly how many rows *MySQL* must examine to execute the query.
  14660. This number is also used when you restrict queries with the
  14661. `max_join_size' variable.  *Note Server parameters::.
  14662.  
  14663. The following example shows how a `JOIN' can be optimized progressively
  14664. using the information provided by `EXPLAIN'.
  14665.  
  14666. Suppose you have the `SELECT' statement shown below, that you examine
  14667. using `EXPLAIN':
  14668.  
  14669.      EXPLAIN SELECT tt.TicketNumber, tt.TimeIn,
  14670.                  tt.ProjectReference, tt.EstimatedShipDate,
  14671.                  tt.ActualShipDate, tt.ClientID,
  14672.                  tt.ServiceCodes, tt.RepetitiveID,
  14673.                  tt.CurrentProcess, tt.CurrentDPPerson,
  14674.                  tt.RecordVolume, tt.DPPrinted, et.COUNTRY,
  14675.                  et_1.COUNTRY, do.CUSTNAME
  14676.              FROM tt, et, et AS et_1, do
  14677.              WHERE tt.SubmitTime IS NULL
  14678.                  AND tt.ActualPC = et.EMPLOYID
  14679.                  AND tt.AssignedPC = et_1.EMPLOYID
  14680.                  AND tt.ClientID = do.CUSTNMBR;
  14681.  
  14682. For this example, assume that:
  14683.  
  14684.    * The columns being compared have been declared as follows:
  14685.  
  14686.      *Table* *Column*      *Column type*
  14687.      `tt'    `ActualPC'    `CHAR(10)'
  14688.      `tt'    `AssignedPC'  `CHAR(10)'
  14689.      `tt'    `ClientID'    `CHAR(10)'
  14690.      `et'    `EMPLOYID'    `CHAR(15)'
  14691.      `do'    `CUSTNMBR'    `CHAR(15)'
  14692.  
  14693.    * The tables have the indexes shown below:
  14694.  
  14695.      *Table* *Index*
  14696.      `tt'    `ActualPC'
  14697.      `tt'    `AssignedPC'
  14698.      `tt'    `ClientID'
  14699.      `et'    `EMPLOYID' (primary key)
  14700.      `do'    `CUSTNMBR' (primary key)
  14701.  
  14702.    * The `tt.ActualPC' values aren't evenly distributed.
  14703.  
  14704. Initially, before any optimizations have been performed, the `EXPLAIN'
  14705. statement produces the following information:
  14706.  
  14707.      table type possible_keys                key  key_len ref  rows  Extra
  14708.      et    ALL  PRIMARY                      NULL NULL    NULL 74
  14709.      do    ALL  PRIMARY                      NULL NULL    NULL 2135
  14710.      et_1  ALL  PRIMARY                      NULL NULL    NULL 74
  14711.      tt    ALL  AssignedPC,ClientID,ActualPC NULL NULL    NULL 3872
  14712.            range checked for each record (key map: 35)
  14713.  
  14714. Because `type' is `ALL' for each table, this output indicates that
  14715. *MySQL* is doing a full join for all tables!  This will take quite a
  14716. long time, as the product of the number of rows in each table must be
  14717. examined!  For the case at hand, this is `74 * 2135 * 74 * 3872 =
  14718. 45,268,558,720' rows.  If the tables were bigger, you can only imagine
  14719. how long it would take...
  14720.  
  14721. One problem here is that *MySQL* can't (yet) use indexes on columns
  14722. efficiently if they are declared differently.  In this context,
  14723. `VARCHAR' and `CHAR' are the same unless they are declared as different
  14724. lengths. Because `tt.ActualPC' is declared as `CHAR(10)' and
  14725. `et.EMPLOYID' is declared as `CHAR(15)', there is a length mismatch.
  14726.  
  14727. To fix this disparity between column lengths, use `ALTER TABLE' to
  14728. lengthen `ActualPC' from 10 characters to 15 characters:
  14729.  
  14730.      mysql> ALTER TABLE tt MODIFY ActualPC VARCHAR(15);
  14731.  
  14732. Now `tt.ActualPC' and `et.EMPLOYID' are both `VARCHAR(15)'.  Executing
  14733. the `EXPLAIN' statement again produces this result:
  14734.  
  14735.      table type   possible_keys   key     key_len ref         rows    Extra
  14736.      tt    ALL    AssignedPC,ClientID,ActualPC NULL NULL NULL 3872    where used
  14737.      do    ALL    PRIMARY         NULL    NULL    NULL        2135
  14738.            range checked for each record (key map: 1)
  14739.      et_1  ALL    PRIMARY         NULL    NULL    NULL        74
  14740.            range checked for each record (key map: 1)
  14741.      et    eq_ref PRIMARY         PRIMARY 15      tt.ActualPC 1
  14742.  
  14743. This is not perfect, but is much better (the product of the `rows'
  14744. values is now less by a factor of 74). This version is executed in a
  14745. couple of seconds.
  14746.  
  14747. A second alteration can be made to eliminate the column length
  14748. mismatches for the `tt.AssignedPC = et_1.EMPLOYID' and `tt.ClientID =
  14749. do.CUSTNMBR' comparisons:
  14750.  
  14751.      mysql> ALTER TABLE tt MODIFY AssignedPC VARCHAR(15),
  14752.                            MODIFY ClientID   VARCHAR(15);
  14753.  
  14754. Now `EXPLAIN' produces the output shown below:
  14755.  
  14756.      table type   possible_keys   key     key_len ref            rows     Extra
  14757.      et    ALL    PRIMARY         NULL    NULL    NULL           74
  14758.      tt    ref    AssignedPC,ClientID,ActualPC ActualPC 15 et.EMPLOYID 52 where used
  14759.      et_1  eq_ref PRIMARY         PRIMARY 15      tt.AssignedPC  1
  14760.      do    eq_ref PRIMARY         PRIMARY 15      tt.ClientID    1
  14761.  
  14762. This is "almost" as good as it can get.
  14763.  
  14764. The remaining problem is that, by default, *MySQL* assumes that values
  14765. in the `tt.ActualPC' column are evenly distributed, and that isn't the
  14766. case for the `tt' table.  Fortunately, it is easy to tell *MySQL* about
  14767. this:
  14768.  
  14769.      shell> myisamchk --analyze PATH_TO_MYSQL_DATABASE/tt
  14770.      shell> mysqladmin refresh
  14771.  
  14772. Now the join is "perfect", and `EXPLAIN' produces this result:
  14773.  
  14774.      table type   possible_keys   key     key_len ref            rows    Extra
  14775.      tt    ALL    AssignedPC,ClientID,ActualPC NULL NULL NULL    3872    where used
  14776.      et    eq_ref PRIMARY         PRIMARY 15      tt.ActualPC    1
  14777.      et_1  eq_ref PRIMARY         PRIMARY 15      tt.AssignedPC  1
  14778.      do    eq_ref PRIMARY         PRIMARY 15      tt.ClientID    1
  14779.  
  14780. Note that the `rows' column in the output from `EXPLAIN' is an
  14781. "educated guess" from the *MySQL* join optimizer;  To optimize a query,
  14782. you should check if the numbers are even close to the truth.  If not,
  14783. you may get better performance by using `STRAIGHT_JOIN' in your
  14784. `SELECT' statement and trying to list the tables in a different order in
  14785. the `FROM' clause.
  14786.  
  14787. `DESCRIBE' syntax (Get information about columns)
  14788. =================================================
  14789.  
  14790.      {DESCRIBE | DESC} tbl_name {col_name | wild}
  14791.  
  14792. `DESCRIBE' provides information about a table's columns.  `col_name'
  14793. may be a column name or a string containing the SQL `%' and `_'
  14794. wildcard characters.
  14795.  
  14796. If the column types are different than you expect them to be based on a
  14797. `CREATE TABLE' statement, note that *MySQL* sometimes changes column
  14798. types.  *Note Silent column changes::.
  14799.  
  14800. This statement is provided for Oracle compatibility.
  14801.  
  14802. The `SHOW' statement provides similar information.  *Note `SHOW': SHOW.
  14803.  
  14804. `BEGIN/COMMIT/ROLLBACK' syntax
  14805. ==============================
  14806.  
  14807. By default, *MySQL* runs in `autocommit' mode. This means that as soon
  14808. as you execute an update, *MySQL* will store the update on disk.
  14809.  
  14810. If you are using `BDB' tables, you can put *MySQL* into
  14811. non-`autocommit' mode with the following command:
  14812.  
  14813.      SET AUTOCOMMIT=0
  14814.  
  14815. After this you must use `COMMIT' to store your changes to disk or
  14816. `ROLLBACK' if you want to ignore the changes you have made since the
  14817. beginning of your transaction.
  14818.  
  14819. If you want to switch from `AUTOCOMMIT' mode for one serie of
  14820. statements, you can use the `BEGIN' or `BEGIN WORK' statement.
  14821.  
  14822.      BEGIN;
  14823.      SELECT @A:=SUM(salary) FROM table1 WHERE type=1;
  14824.      UPDATE table2 SET summmary=@A WHERE type=1;
  14825.      COMMIT;
  14826.  
  14827. Note that if you are using non-transaction-safe tables, the changes
  14828. will be stored at once, independent of the status of the `autocommit'
  14829. mode.
  14830.  
  14831. `LOCK TABLES/UNLOCK TABLES' syntax
  14832. ==================================
  14833.  
  14834.      LOCK TABLES tbl_name [AS alias] {READ | [READ LOCAL] | [LOW_PRIORITY] WRITE}
  14835.                  [, tbl_name {READ | [LOW_PRIORITY] WRITE} ...]
  14836.      ...
  14837.      UNLOCK TABLES
  14838.  
  14839. `LOCK TABLES' locks tables for the current thread.  `UNLOCK TABLES'
  14840. releases any locks held by the current thread.  All tables that are
  14841. locked by the current thread are automatically unlocked when the thread
  14842. issues another `LOCK TABLES', or when the connection to the server is
  14843. closed.
  14844.  
  14845. If a thread obtains a `READ' lock on a table, that thread (and all other
  14846. threads) can only read from the table. If a thread obtains a `WRITE'
  14847. lock on a table, then only the thread holding the lock can `READ' from
  14848. or `WRITE' to the table.  Other threads are blocked.
  14849.  
  14850. The difference between `READ LOCAL' and `READ' is that `READ LOCAL'
  14851. allows non-conflicting `INSERT' statements to execute while the lock is
  14852. held.  This can't however be used if you are going to manipulate the
  14853. database files outside *MySQL* while you hold the lock.
  14854.  
  14855. Each thread waits (without timing out) until it obtains all the locks
  14856. it has requested.
  14857.  
  14858. `WRITE' locks normally have higher priority than `READ' locks, to
  14859. ensure that updates are processed as soon as possible. This means that
  14860. if one thread obtains a `READ' lock and then another thread requests a
  14861. `WRITE' lock, subsequent `READ' lock requests will wait until the
  14862. `WRITE' thread has gotten the lock and released it.  You can use
  14863. `LOW_PRIORITY WRITE' locks to allow other threads to obtain `READ'
  14864. locks while the thread is waiting for the `WRITE' lock. You should only
  14865. use `LOW_PRIORITY WRITE' locks if you are sure that there will
  14866. eventually be a time when no threads will have a `READ' lock.
  14867.  
  14868. When you use `LOCK TABLES', you must lock all tables that you are going
  14869. to use and you must use the same alias that you are going to use in
  14870. your queries!  If you are using a table multiple times in a query (with
  14871. aliases), you must get a lock for each alias! This policy ensures that
  14872. table locking is deadlock free.
  14873.  
  14874. Note that you should *NOT* lock any tables that you are using with
  14875. `INSERT DELAYED'.  This is because that in this case the `INSERT' is
  14876. done by a separate thread.
  14877.  
  14878. Normally, you don't have to lock tables, as all single `UPDATE'
  14879. statements are atomic; no other thread can interfere with any other
  14880. currently executing SQL statement. There are a few cases when you would
  14881. like to lock tables anyway:
  14882.  
  14883.    * If you are going to run many operations on a bunch of tables, it's
  14884.      much faster to lock the tables you are going to use.  The downside
  14885.      is, of course, that no other thread can update a `READ'-locked
  14886.      table and no other thread can read a `WRITE'-locked table.
  14887.  
  14888.    * *MySQL* doesn't support a transaction environment, so you must use
  14889.      `LOCK TABES' if you want to ensure that no other thread comes
  14890.      between a `SELECT' and an `UPDATE'. The example shown below
  14891.      requires `LOCK TABLES' in order to execute safely:
  14892.  
  14893.           mysql> LOCK TABLES trans READ, customer WRITE;
  14894.           mysql> select sum(value) from trans where customer_id= some_id;
  14895.           mysql> update customer set total_value=sum_from_previous_statement
  14896.                      where customer_id=some_id;
  14897.           mysql> UNLOCK TABLES;
  14898.  
  14899.      Without `LOCK TABLES', there is a chance that another thread might
  14900.      insert a new row in the `trans' table between execution of the
  14901.      `SELECT' and `UPDATE' statements.
  14902.  
  14903. By using incremental updates (`UPDATE customer SET
  14904. value=value+new_value') or the `LAST_INSERT_ID()' function, you can
  14905. avoid using `LOCK TABLES' in many cases.
  14906.  
  14907. You can also solve some cases by using the user-level lock functions
  14908. `GET_LOCK()' and `RELEASE_LOCK()'.  These locks are saved in a hash
  14909. table in the server and implemented with `pthread_mutex_lock()' and
  14910. `pthread_mutex_unlock()' for high speed.  *Note Miscellaneous
  14911. functions::.
  14912.  
  14913. See *Note Internal locking::, for more information on locking policy.
  14914.  
  14915. You can also lock all tables in all databases with read locks with the
  14916. `FLUSH TABLES WITH READ LOCK' command. *Note FLUSH::.
  14917.  
  14918. `SET' syntax
  14919. ============
  14920.  
  14921.      SET [OPTION] SQL_VALUE_OPTION= value, ...
  14922.  
  14923. `SET OPTION' sets various options that affect the operation of the
  14924. server or your client.  Any option you set remains in effect until the
  14925. current session ends, or until you set the option to a different value.
  14926.  
  14927. `CHARACTER SET character_set_name | DEFAULT'
  14928.      This maps all strings from and to the client with the given
  14929.      mapping.  Currently the only option for `character_set_name' is
  14930.      `cp1251_koi8', but you can easily add new mappings by editing the
  14931.      `sql/convert.cc' file in the *MySQL* source distribution.  The
  14932.      default mapping can be restored by using a `character_set_name'
  14933.      value of `DEFAULT'.
  14934.  
  14935.      Note that the syntax for setting the `CHARACTER SET' option differs
  14936.      from the syntax for setting the other options.
  14937.  
  14938. `PASSWORD = PASSWORD('some password')'
  14939.      Set the password for the current user. Any non-anonymous user can
  14940.      change his own password!
  14941.  
  14942. `PASSWORD FOR user = PASSWORD('some password')'
  14943.      Set the password for a specific user on the current server host.
  14944.      Only a user with access to the `mysql' database can do this.  The
  14945.      user should be given in `user@hostname' format, where `user' and
  14946.      `hostname' are exactly as they are listed in the `User' and `Host'
  14947.      columns of the `mysql.user' table entry.  For example, if you had
  14948.      an entry with `User' and `Host' fields of `'bob'' and
  14949.      `'%.loc.gov'', you would write:
  14950.  
  14951.           mysql> SET PASSWORD FOR bob@"%.loc.gov" = PASSWORD("newpass");
  14952.           
  14953.           or
  14954.           
  14955.           mysql> UPDATE mysql.user SET password=PASSWORD("newpass") where user="bob' and host="%.loc.gov";
  14956.  
  14957. `SQL_AUTO_IS_NULL = 0 | 1'
  14958.      If set to `1' (default) then one can find the last inserted row
  14959.      for a table with an auto_increment row with the following
  14960.      construct: `WHERE auto_increment_column IS NULL'.  This is used by
  14961.      some ODBC programs like Access.
  14962.  
  14963. `SET AUTOCOMMIT= 0 | 1'
  14964.      If set to `1' all changes to a table will be done at once. To start
  14965.      an multi command transaction you have to use the `BEGIN'
  14966.      statement. *Note COMMIT::. If set to `0' you have to use `COMMIT' /
  14967.      `ROLLBACK' to accept/revoke that transaction. *Note COMMIT::.  Note
  14968.      that when you change from not `AUTOCOMMIT' mode to `AUTOCOMMIT'
  14969.      mode, *MySQL* will do an automatic `COMMIT' on any open
  14970.      transactions.
  14971.  
  14972. `SQL_BIG_TABLES = 0 | 1'
  14973.      If set to `1', all temporary tables are stored on disk rather than
  14974.      in memory.  This will be a little slower, but you will not get the
  14975.      error `The table tbl_name is full' for big `SELECT' operations that
  14976.      require a large temporary table.  The default value for a new
  14977.      connection is `0' (i.e., use in-memory temporary tables).
  14978.  
  14979. `SQL_BIG_SELECTS = 0 | 1'
  14980.      If set to `0', *MySQL* will abort if a `SELECT' is attempted that
  14981.      probably will take a very long time. This is useful when an
  14982.      inadvisable `WHERE' statement has been issued. A big query is
  14983.      defined as a `SELECT' that probably will have to examine more than
  14984.      `max_join_size' rows.  The default value for a new connection is
  14985.      `1' (which will allow all `SELECT' statements).
  14986.  
  14987. `SQL_BUFFER_RESULT = 0 | 1'
  14988.      `SQL_BUFFER_RESULT' will force the result from `SELECT''s to be
  14989.      put into a temporary table. This will help *MySQL* free the table
  14990.      locks early and will help in cases where it takes a long time to
  14991.      send the result set to the client.
  14992.  
  14993. `SQL_LOW_PRIORITY_UPDATES = 0 | 1'
  14994.      If set to `1', all `INSERT', `UPDATE', `DELETE' and and `LOCK
  14995.      TABLE WRITE' statements wait until there is no pending `SELECT' or
  14996.      `LOCK TABLE READ' on the affected table.
  14997.  
  14998. `SQL_MAX_JOIN_SIZE = value | DEFAULT'
  14999.      Don't allow `SELECT''s that will probably need to examine more than
  15000.      `value' row combinations.  By setting this value, you can catch
  15001.      `SELECT''s where keys are not used properly and that would probably
  15002.      take a long time. Setting this to a value other than `DEFAULT'
  15003.      will reset the `SQL_BIG_SELECTS' flag.  If you set the
  15004.      `SQL_BIG_SELECTS' flag again, the `SQL_MAX_JOIN_SIZE' variable
  15005.      will be ignored.  You can set a default value for this variable by
  15006.      starting `mysqld' with `-O max_join_size=#'.
  15007.  
  15008. `SQL_SAFE_MODE = 0 | 1'
  15009.      If set to `1', *MySQL* will abort if a `UPDATE' or `DELETE' is
  15010.      attempted that doesn't use a key or `LIMIT' in the `WHERE' clause.
  15011.      This makes it possible to catch wrong updates when creating SQL
  15012.      commands by hand.
  15013.  
  15014. `SQL_SELECT_LIMIT = value | DEFAULT'
  15015.      The maximum number of records to return from `SELECT' statements.
  15016.      If a `SELECT' has a `LIMIT' clause, the `LIMIT' takes precedence
  15017.      over the value of `SQL_SELECT_LIMIT'.  The default value for a new
  15018.      connection is "unlimited".  If you have changed the limit, the
  15019.      default value can be restored by using a `SQL_SELECT_LIMIT' value
  15020.      of `DEFAULT'.
  15021.  
  15022. `SQL_LOG_OFF = 0 | 1'
  15023.      If set to `1', no logging will be done to the standard log for this
  15024.      client, if the client has the *process* privilege.  This does not
  15025.      affect the update log!
  15026.  
  15027. `SQL_LOG_UPDATE = 0 | 1'
  15028.      If set to `0', no logging will be done to the update log for the
  15029.      client, if the client has the *process* privilege.  This does not
  15030.      affect the standard log!
  15031.  
  15032. `TIMESTAMP = timestamp_value | DEFAULT'
  15033.      Set the time for this client.  This is used to get the original
  15034.      timestamp if you use the update log to restore rows.
  15035.  
  15036. `LAST_INSERT_ID = #'
  15037.      Set the value to be returned from `LAST_INSERT_ID()'. This is
  15038.      stored in the update log when you use `LAST_INSERT_ID()' in a
  15039.      command that updates a table.
  15040.  
  15041. `INSERT_ID = #'
  15042.      Set the value to be used by the following `INSERT' command when
  15043.      inserting an `AUTO_INCREMENT' value.  This is mainly used with the
  15044.      update log.
  15045.  
  15046. `GRANT' and `REVOKE' syntax
  15047. ===========================
  15048.  
  15049.      GRANT priv_type [(column_list)] [, priv_type [(column_list)] ...]
  15050.          ON {tbl_name | * | *.* | db_name.*}
  15051.          TO user_name [IDENTIFIED BY 'password']
  15052.              [, user_name [IDENTIFIED BY 'password'] ...]
  15053.          [WITH GRANT OPTION]
  15054.      
  15055.      REVOKE priv_type [(column_list)] [, priv_type [(column_list)] ...]
  15056.          ON {tbl_name | * | *.* | db_name.*}
  15057.          FROM user_name [, user_name ...]
  15058.  
  15059. `GRANT' is implemented in *MySQL* 3.22.11 or later. For earlier *MySQL*
  15060. versions, the `GRANT' statement does nothing.
  15061.  
  15062. The `GRANT' and `REVOKE' commands allow system administrators to grant
  15063. and revoke rights to *MySQL* users at four privilege levels:
  15064.  
  15065. *Global level*
  15066.      Global privileges apply to all databases on a given server. These
  15067.      privileges are stored in the `mysql.user' table.
  15068.  
  15069. *Database level*
  15070.      Database privileges apply to all tables in a given database. These
  15071.      privileges are stored in the `mysql.db' and `mysql.host' tables.
  15072.  
  15073. *Table level*
  15074.      Table privileges apply to all columns in a given table. These
  15075.      privileges are stored in the `mysql.tables_priv' table.
  15076.  
  15077. *Column level*
  15078.      Column privileges apply to single columns in a given table. These
  15079.      privileges are stored in the `mysql.columns_priv' table.
  15080.  
  15081. For examples of how `GRANT' works, see *Note Adding users::.
  15082.  
  15083. For the `GRANT' and `REVOKE' statements, `priv_type' may be specified
  15084. as any of the following:
  15085.  
  15086.      ALL PRIVILEGES      FILE                RELOAD
  15087.      ALTER               INDEX               SELECT
  15088.      CREATE              INSERT              SHUTDOWN
  15089.      DELETE              PROCESS             UPDATE
  15090.      DROP                REFERENCES          USAGE
  15091.  
  15092. `ALL' is a synonym for `ALL PRIVILEGES'.  `REFERENCES' is not yet
  15093. implemented.  `USAGE' is currently a synonym for "no privileges".  It
  15094. can be used when you want to create a user that has no privileges.
  15095.  
  15096. To revoke the *grant* privilege from a user, use a `priv_type' value of
  15097. `GRANT OPTION':
  15098.  
  15099.      REVOKE GRANT OPTION ON ... FROM ...;
  15100.  
  15101. The only `priv_type' values you can specify for a table are `SELECT',
  15102. `INSERT', `UPDATE', `DELETE', `CREATE', `DROP', `GRANT', `INDEX' and
  15103. `ALTER'.
  15104.  
  15105. The only `priv_type' values you can specify for a column (that is, when
  15106. you use a `column_list' clause) are `SELECT', `INSERT' and `UPDATE'.
  15107.  
  15108. You can set global privileges by using `ON *.*' syntax.  You can set
  15109. database privileges by using `ON db_name.*' syntax. If you specify `ON
  15110. *' and you have a current database, you will set the privileges for
  15111. that database.  (*Warning:* If you specify `ON *' and you _don't_ have
  15112. a current database, you will affect the global privileges!)
  15113.  
  15114. In order to accommodate granting rights to users from arbitrary hosts,
  15115. *MySQL* supports specifying the `user_name' value in the form
  15116. `user@host'.  If you want to specify a `user' string containing special
  15117. characters (such as `-'), or a `host' string containing special
  15118. characters or wildcard characters (such as `%'), you can quote the user
  15119. or host name (e.g., `'test-user'@'test-hostname'').
  15120.  
  15121. You can specify wildcards in the hostname.  For example,
  15122. `user@"%.loc.gov"' applies to `user' for any host in the `loc.gov'
  15123. domain, and `user@"144.155.166.%"' applies to `user' for any host in
  15124. the `144.155.166' class C subnet.
  15125.  
  15126. The simple form `user' is a synonym for `user@"%"'.  *Note:* If you
  15127. allow anonymous users to connect to the *MySQL* server (which is the
  15128. default), you should also add all local users as `user@localhost'
  15129. because otherwise the anonymous user entry for the local host in the
  15130. `mysql.user' table will be used when the user tries to log into the
  15131. *MySQL* server from the local machine!  Anonymous users are defined by
  15132. inserting entries with `User=''' into the `mysql.user' table. You can
  15133. verify if this applies to you by executing this query:
  15134.  
  15135.      mysql> SELECT Host,User FROM mysql.user WHERE User='';
  15136.  
  15137. For the moment, `GRANT' only supports host, table, database and column
  15138. names up to 60 characters long. A user name can be up to 16 characters.
  15139.  
  15140. The privileges for a table or column are formed from the logical OR of
  15141. the privileges at each of the four privilege levels.  For example, if
  15142. the `mysql.user' table specifies that a user has a global *select*
  15143. privilege, this can't be denied by an entry at the database, table or
  15144. column level.
  15145.  
  15146. The privileges for a column can be calculated as follows:
  15147.  
  15148.      global privileges
  15149.      OR (database privileges AND host privileges)
  15150.      OR table privileges
  15151.      OR column privileges
  15152.  
  15153. In most cases, you grant rights to a user at only one of the privilege
  15154. levels, so life isn't normally as complicated as above. :) The details
  15155. of the privilege-checking procedure are presented in *Note Privilege
  15156. system::.
  15157.  
  15158. If you grant privileges for a user/hostname combination that does not
  15159. exist in the `mysql.user' table, an entry is added and remains there
  15160. until deleted with a `DELETE' command.  In other words, `GRANT' may
  15161. create `user' table entries, but `REVOKE' will not remove them; you
  15162. must do that explicitly using `DELETE'.
  15163.  
  15164. In *MySQL* 3.22.12 or later, if a new user is created or if you have
  15165. global grant privileges, the user's password will be set to the
  15166. password specified by the `IDENTIFIED BY' clause, if one is given.  If
  15167. the user already had a password, it is replaced by the new one.
  15168.  
  15169. *Warning:* If you create a new user but do not specify an `IDENTIFIED
  15170. BY' clause, the user has no password.  This is insecure.
  15171.  
  15172. Passwords can also be set with the `SET PASSWORD' command.  *Note `SET
  15173. OPTION': SET OPTION.
  15174.  
  15175. If you grant privileges for a database, an entry in the `mysql.db'
  15176. table is created if needed. When all privileges for the database have
  15177. been removed with `REVOKE', this entry is deleted.
  15178.  
  15179. If a user doesn't have any privileges on a table, the table is not
  15180. displayed when the user requests a list of tables (e.g., with a `SHOW
  15181. TABLES' statement).
  15182.  
  15183. The `WITH GRANT OPTION' clause gives the user the ability to give to
  15184. other users any privileges the user has at the specified privilege
  15185. level.  You should be careful to whom you give the *grant* privilege,
  15186. as two users with different privileges may be able to join privileges!
  15187.  
  15188. You cannot grant another user a privilege you don't have yourself; the
  15189. *grant* privilege allows you to give away only those privileges you
  15190. possess.
  15191.  
  15192. Be aware that when you grant a user the *grant* privilege at a
  15193. particular privilege level, any privileges the user already possesses
  15194. (or is given in the future!) at that level are also grantable by that
  15195. user.  Suppose you grant a user the *insert* privilege on a database.
  15196. If you then grant the *select* privilege on the database and specify
  15197. `WITH GRANT OPTION', the user can give away not only the *select*
  15198. privilege, but also *insert*.  If you then grant the *update* privilege
  15199. to the user on the database, the user can give away the *insert*,
  15200. *select* and *update*.
  15201.  
  15202. You should not grant *alter* privileges to a normal user.  If you do
  15203. that, the user can try to subvert the privilege system by renaming
  15204. tables!
  15205.  
  15206. Note that if you are using table or column privileges for even one
  15207. user, the server examines table and column privileges for all users and
  15208. this will slow down *MySQL* a bit.
  15209.  
  15210. When `mysqld' starts, all privileges are read into memory.  Database,
  15211. table and column privileges take effect at once and user-level
  15212. privileges take effect the next time the user connects.  Modifications
  15213. to the grant tables that you perform using `GRANT' or `REVOKE' are
  15214. noticed by the server immediately.  If you modify the grant tables
  15215. manually (using `INSERT', `UPDATE', etc.), you should execute a `FLUSH
  15216. PRIVILEGES' statement or run `mysqladmin flush-privileges' to tell the
  15217. server to reload the grant tables.  *Note Privilege changes::.
  15218.  
  15219. The biggest differences between the ANSI SQL and *MySQL* versions of
  15220. `GRANT' are:
  15221.  
  15222.    * ANSI SQL doesn't have global or database-level privileges and ANSI
  15223.      SQL doesn't support all privilege types that *MySQL* supports.
  15224.  
  15225.    * When you drop a table in ANSI SQL, all privileges for the table
  15226.      are revoked.  If you revoke a privilege in ANSI SQL, all
  15227.      privileges that were granted based on this privilege are also
  15228.      revoked. In *MySQL*, privileges can be dropped only with explicit
  15229.      `REVOKE' commands or by manipulating the *MySQL* grant tables.
  15230.  
  15231. `CREATE INDEX' syntax
  15232. =====================
  15233.  
  15234.      CREATE [UNIQUE] INDEX index_name ON tbl_name (col_name[(length)],... )
  15235.  
  15236. The `CREATE INDEX' statement doesn't do anything in *MySQL* prior to
  15237. version 3.22.  In 3.22 or later, `CREATE INDEX' is mapped to an `ALTER
  15238. TABLE' statement to create indexes.  *Note `ALTER TABLE': ALTER TABLE.
  15239.  
  15240. Normally, you create all indexes on a table at the time the table itself
  15241. is created with `CREATE TABLE'.  *Note `CREATE TABLE': CREATE TABLE.
  15242. `CREATE INDEX' allows you to add indexes to existing tables.
  15243.  
  15244. A column list of the form `(col1,col2,...)' creates a multiple-column
  15245. index.  Index values are formed by concatenating the values of the given
  15246. columns.
  15247.  
  15248. For `CHAR' and `VARCHAR' columns, indexes can be created that use only
  15249. part of a column, using `col_name(length)' syntax.  (On `BLOB' and
  15250. `TEXT' columns the length is required). The statement shown below
  15251. creates an index using the first 10 characters of the `name' column:
  15252.  
  15253.      mysql> CREATE INDEX part_of_name ON customer (name(10));
  15254.  
  15255. Because most names usually differ in the first 10 characters, this
  15256. index should not be much slower than an index created from the entire
  15257. `name' column.  Also, using partial columns for indexes can make the
  15258. index file much smaller, which could save a lot of disk space and might
  15259. also speed up `INSERT' operations!
  15260.  
  15261. Note that you can only add an index on a column that can have `NULL'
  15262. values or on a `BLOB'/`TEXT' column if you are useing *MySQL* version
  15263. 3.23.2 or newer and are using the `MyISAM' table type.
  15264.  
  15265. For more information about how *MySQL* uses indexes, see *Note *MySQL*
  15266. indexes: MySQL indexes.
  15267.  
  15268. `DROP INDEX' syntax
  15269. ===================
  15270.  
  15271.      DROP INDEX index_name ON tbl_name
  15272.  
  15273. `DROP INDEX' drops the index named `index_name' from the table
  15274. `tbl_name'.  `DROP INDEX' doesn't do anything in *MySQL* prior to
  15275. version 3.22.  In 3.22 or later, `DROP INDEX' is mapped to an `ALTER
  15276. TABLE' statement to drop the index.  *Note `ALTER TABLE': ALTER TABLE.
  15277.  
  15278. Comment syntax
  15279. ==============
  15280.  
  15281. The *MySQL* server supports the `# to end of line', `-- to end of line'
  15282. and `/* in-line or multiple-line */' comment styles:
  15283.  
  15284.      mysql> select 1+1;     # This comment continues to the end of line
  15285.      mysql> select 1+1;     -- This comment continues to the end of line
  15286.      mysql> select 1 /* this is an in-line comment */ + 1;
  15287.      mysql> select 1+
  15288.      /*
  15289.      this is a
  15290.      multiple-line comment
  15291.      */
  15292.      1;
  15293.  
  15294. Note that the `--' comment style requires you to have at least one space
  15295. after the `--'!
  15296.  
  15297. Although the server understands the comment syntax just described,
  15298. there are some limitations on the way that the `mysql' client parses
  15299. `/* ... */' comments:
  15300.  
  15301.    * Single-quote and double-quote characters are taken to indicate the
  15302.      beginning of a quoted string, even within a comment.  If the quote
  15303.      is not matched by a second quote within the comment, the parser
  15304.      doesn't realize the comment has ended.  If you are running `mysql'
  15305.      interactively, you can tell that it has gotten confused like this
  15306.      because the prompt changes from `mysql>' to `'>' or `">'.
  15307.  
  15308.    * A semicolon is taken to indicate the end of the current SQL
  15309.      statement and anything following it to indicate the beginning of
  15310.      the next statement.
  15311.  
  15312. These limitations apply both when you run `mysql' interactively and
  15313. when you put commands in a file and tell `mysql' to read its input from
  15314. that file with `mysql < some-file'.
  15315.  
  15316. *MySQL* doesn't support the `--' ANSI SQL comment style.  *Note Missing
  15317. comments::.
  15318.  
  15319. `CREATE FUNCTION/DROP FUNCTION' syntax
  15320. ======================================
  15321.  
  15322.      CREATE [AGGREGATE] FUNCTION function_name RETURNS {STRING|REAL|INTEGER}
  15323.             SONAME shared_library_name
  15324.      
  15325.      DROP FUNCTION function_name
  15326.  
  15327. A user-definable function (UDF) is a way to extend *MySQL* with a new
  15328. function that works like native (built in) *MySQL* functions such as
  15329. `ABS()' and `CONCAT()'.
  15330.  
  15331. `AGGREGATE' is a new option for *MySQL* 3.23.  An `AGGREGATE' function
  15332. works exactly like a native *MySQL* `GROUP' function like `SUM' or
  15333. `COUNT()'.
  15334.  
  15335. `CREATE FUNCTION' saves the function's name, type and shared library
  15336. name in the `mysql.func' system table.  You must have the *insert* and
  15337. *delete* privileges for the `mysql' database to create and drop
  15338. functions.
  15339.  
  15340. All active functions are reloaded each time the server starts, unless
  15341. you start `mysqld' with the `--skip-grant-tables' option.  In this
  15342. case, UDF initialization is skipped and UDFs are unavailable.  (An
  15343. active function is one that has been loaded with `CREATE FUNCTION' and
  15344. not removed with `DROP FUNCTION'.)
  15345.  
  15346. For instructions on writing user-definable functions, see *Note Adding
  15347. functions::.  For the UDF mechanism to work, functions must be written
  15348. in C or C++, your operating system must support dynamic loading and you
  15349. must have compiled `mysqld' dynamically (not statically).
  15350.  
  15351. Is MySQL picky about reserved words?
  15352. ====================================
  15353.  
  15354. A common problem stems from trying to create a table with column names
  15355. that use the names of datatypes or functions built into *MySQL*, such as
  15356. `TIMESTAMP' or `GROUP'.  You're allowed to do it (for example, `ABS' is
  15357. an allowed column name), but whitespace is not allowed between a
  15358. function name and the `(' when using functions whose names are also
  15359. column names.
  15360.  
  15361. The following words are explicitly reserved in *MySQL*. Most of them
  15362. are forbidden by ANSI SQL92 as column and/or table names (for example,
  15363. `group').  A few are reserved because *MySQL* needs them and is
  15364. (currently) using a `yacc' parser:
  15365.  
  15366. `action'           `add'              `aggregate'        `all'
  15367. `alter'            `after'            `and'              `as'
  15368. `asc'              `avg'              `avg_row_length'   `auto_increment'
  15369. `between'          `bigint'           `bit'              `binary'
  15370. `blob'             `bool'             `both'             `by'
  15371. `cascade'          `case'             `char'             `character'
  15372. `change'           `check'            `checksum'         `column'
  15373. `columns'          `comment'          `constraint'       `create'
  15374. `cross'            `current_date'     `current_time'     `current_timestamp'
  15375. `data'             `database'         `databases'        `date'
  15376. `datetime'         `day'              `day_hour'         `day_minute'
  15377. `day_second'       `dayofmonth'       `dayofweek'        `dayofyear'
  15378. `dec'              `decimal'          `default'          `delayed'
  15379. `delay_key_write'  `delete'           `desc'             `describe'
  15380. `distinct'         `distinctrow'      `double'           `drop'
  15381. `end'              `else'             `escape'           `escaped'
  15382. `enclosed'         `enum'             `explain'          `exists'
  15383. `fields'           `file'             `first'            `float'
  15384. `float4'           `float8'           `flush'            `foreign'
  15385. `from'             `for'              `full'             `function'
  15386. `global'           `grant'            `grants'           `group'
  15387. `having'           `heap'             `high_priority'    `hour'
  15388. `hour_minute'      `hour_second'      `hosts'            `identified'
  15389. `ignore'           `in'               `index'            `infile'
  15390. `inner'            `insert'           `insert_id'        `int'
  15391. `integer'          `interval'         `int1'             `int2'
  15392. `int3'             `int4'             `int8'             `into'
  15393. `if'               `is'               `isam'             `join'
  15394. `key'              `keys'             `kill'             `last_insert_id'
  15395. `leading'          `left'             `length'           `like'
  15396. `lines'            `limit'            `load'             `local'
  15397. `lock'             `logs'             `long'             `longblob'
  15398. `longtext'         `low_priority'     `max'              `max_rows'
  15399. `match'            `mediumblob'       `mediumtext'       `mediumint'
  15400. `middleint'        `min_rows'         `minute'           `minute_second'
  15401. `modify'           `month'            `monthname'        `myisam'
  15402. `natural'          `numeric'          `no'               `not'
  15403. `null'             `on'               `optimize'         `option'
  15404. `optionally'       `or'               `order'            `outer'
  15405. `outfile'          `pack_keys'        `partial'          `password'
  15406. `precision'        `primary'          `procedure'        `process'
  15407. `processlist'      `privileges'       `read'             `real'
  15408. `references'       `reload'           `regexp'           `rename'
  15409. `replace'          `restrict'         `returns'          `revoke'
  15410. `rlike'            `row'              `rows'             `second'
  15411. `select'           `set'              `show'             `shutdown'
  15412. `smallint'         `soname'           `sql_big_tables'   `sql_big_selects'
  15413. `sql_low_priority_updates'`sql_log_off'      `sql_log_update'   `sql_select_limit'
  15414. `sql_small_result' `sql_big_result'   `sql_warnings'     `straight_join'
  15415. `starting'         `status'           `string'           `table'
  15416. `tables'           `temporary'        `terminated'       `text'
  15417. `then'             `time'             `timestamp'        `tinyblob'
  15418. `tinytext'         `tinyint'          `trailing'         `to'
  15419. `type'             `use'              `using'            `unique'
  15420. `unlock'           `unsigned'         `update'           `usage'
  15421. `values'           `varchar'          `variables'        `varying'
  15422. `varbinary'        `with'             `write'            `when'
  15423. `where'            `year'             `year_month'       `zerofill'
  15424.  
  15425. The following symbols (from the table above) are disallowed by ANSI SQL
  15426. but allowed by *MySQL* as column/table names. This is because some of
  15427. these names are very natural names and a lot of people have already
  15428. used them.
  15429.  
  15430.    * `ACTION'
  15431.  
  15432.    * `BIT'
  15433.  
  15434.    * `DATE'
  15435.  
  15436.    * `ENUM'
  15437.  
  15438.    * `NO'
  15439.  
  15440.    * `TEXT'
  15441.  
  15442.    * `TIME'
  15443.  
  15444.    * `TIMESTAMP'
  15445.  
  15446. MySQL table types
  15447. *****************
  15448.  
  15449. As of *MySQL* 3.23.6, you can choose between three basic table formats.
  15450. When you create a new table, you can tell *MySQL* which table type it
  15451. should use for the table.  *MySQL* will always create a `.frm' file to
  15452. hold the table and column definitions.  Depending on the table type the
  15453. index and data will be stored in other files.
  15454.  
  15455. The default table type in *MySQL* is `MyISAM'. If you are trying to use
  15456. a table type that is not incompiled or activated, *MySQL* will instead
  15457. create a table of type `MyISAM'.
  15458.  
  15459. You can convert tables between different types with the `ALTER TABLE'
  15460. statement. *Note `ALTER TABLE': ALTER TABLE.
  15461.  
  15462. Note that *MySQL* supports two different kind of tables. Transactions
  15463. safe tables (`BDB') and not transaction safe tables (`ISAM',`MyISAM'
  15464. and `HEAP'.
  15465.  
  15466. Advantages of transaction safe tables (TST)
  15467.  
  15468.    * Safer; Even if `MySQL' crashes or you get hardware problems, you
  15469.      can get your data back;  Either by automatic recovery or from a
  15470.      backup + the transaction log.
  15471.  
  15472.    * You can combine many statements and accept these all in one go with
  15473.      the `COMMIT' command.
  15474.  
  15475.    * You can execute `ROLLBACK' to ignore your changes (if you are not
  15476.      running in auto commit mode).
  15477.  
  15478.    * If an update fails, all your changes will be restored. (With NTST
  15479.      tables all changes that has taken place are permanent)
  15480.  
  15481. Advantages of not transaction safe tables (NTST):
  15482.  
  15483.    * Much faster as there is no transcation overhead.
  15484.  
  15485.    * Will use less disk space as there is no overhead of transactions.
  15486.  
  15487.    * Will use less memory to do updates.
  15488.  
  15489. You can combine TST and NTST tables in the same statements to get the
  15490. best of both worlds.
  15491.  
  15492. MyISAM tables
  15493. =============
  15494.  
  15495. `MyISAM' is the default table type in *MySQL* 3.23. It's based on the
  15496. `ISAM' code and has a lot of useful extensions.
  15497.  
  15498. The index is stored in a file with the `.MYI' (MYIndex) extension and
  15499. the data is stored in file with the `.MYD' (MYData) extension.  You can
  15500. check/repair `MyISAM' tables with the `myisamchk' utility. *Note Crash
  15501. recovery::.
  15502.  
  15503. The following is new in `MyISAM':
  15504.  
  15505.    * You can `INSERT' new rows in a table without deleted rows, while
  15506.      other threads are reading from the table.
  15507.  
  15508.    * Support for big files (63-bit) on filesystems/operating systems
  15509.      that support big files.
  15510.  
  15511.    * All data is stored with the low byte first. This makes the data
  15512.      machine and OS independent. The only requirement is that the
  15513.      machine uses two's-complement signed integers (as every machine
  15514.      for the last 20 years has) and IEEE floating point format (also
  15515.      totally dominant among mainstream machines). The only area of
  15516.      machines that may not support binary compatibility are embedded
  15517.      systems (because they sometimes have peculiar processors).
  15518.  
  15519.    * All number keys are stored with high byte first to give better
  15520.      index compression.
  15521.  
  15522.    * Internal handling of one `AUTO_INCREMENT' column. `MyISAM' will
  15523.      automatically update this on `INSERT/UPDATE'. The `AUTO_INCREMENT'
  15524.      value can be reset with `myisamchk'. This will make
  15525.      `AUTO_INCREMENT' columns faster (at least 10 %) and old numbers
  15526.      will not be reused as with the old ISAM. Note that when a
  15527.      `AUTO_INCREMENT' is defined on the end of a multi-part-key the old
  15528.      behavior is still present.
  15529.  
  15530.    * When inserted in sorted order (as when you are using an
  15531.      `AUTO_INCREMENT' column) the key tree will be split so that the
  15532.      high node only contains one key. This will improve the space
  15533.      utilization in the key tree.
  15534.  
  15535.    * `BLOB' and `TEXT' columns can be indexed.
  15536.  
  15537.    * `NULL' values are allowed in indexed columns.  This takes 0-1
  15538.      bytes/key.
  15539.  
  15540.    * Maximum key length is now 500 bytes by default. In cases of keys
  15541.      longer than 250 bytes, a bigger key block size than the default of
  15542.      1024 bytes is used for this key.
  15543.  
  15544.    * Maximum number of keys/table enlarged to 32 as default. This can be
  15545.      enlarged to 64 without having to recompile `myisamchk'.
  15546.  
  15547.    * There is a flag in the `MyISAM' file that indicates whether or not
  15548.      the table was closed correctly.  This will soon be used for
  15549.      automatic repair in the *MySQL* server.
  15550.  
  15551.    * `myisamchk' will mark tables as checked if one runs it with
  15552.      `--update-state'. `myisamchk --fast' will only check those tables
  15553.      that don't have this mark.
  15554.  
  15555.    * `myisamchk -a' stores statistics for key parts (and not only for
  15556.      whole keys as in `ISAM').
  15557.  
  15558.    * Dynamic size rows will now be much less fragmented when mixing
  15559.      deletes with updates and inserts.  This is done by automatically
  15560.      combining adjacent deleted blocks and by extending blocks if the
  15561.      next block is deleted.
  15562.  
  15563.    * `myisampack' can pack `BLOB' and `VARCHAR' columns.
  15564.  
  15565. `MyISAM' also supports the following things, which *MySQL* will be able
  15566. to use in the near future.
  15567.  
  15568.    * Support for a true `VARCHAR' type; A `VARCHAR' column starts with
  15569.      a length stored in 2 bytes.
  15570.  
  15571.    * Tables with `VARCHAR' may have fixed or dynamic record length.
  15572.  
  15573.    * `VARCHAR' and `CHAR' may be up to 64K.  All key segments have
  15574.      their own language definition. This will enable *MySQL* to have
  15575.      different language definitions per column.
  15576.  
  15577.    * A hashed computed index can be used for `UNIQUE'; This will allow
  15578.      you to have `UNIQUE' on any combination of columns in a table. (You
  15579.      can't search on a `UNIQUE' computed index, however.)
  15580.  
  15581. Note that index files are usually much smaller with `MyISAM' than with
  15582. `ISAM'. This means that `MyISAM' will normally use less system
  15583. resources than `ISAM', but will need more CPU when inserting data into
  15584. compressed index.
  15585.  
  15586. Space needed for keys
  15587. ---------------------
  15588.  
  15589. *MySQL* can support different index types, but the normal type is ISAM
  15590. or MyISAM.  These use a B-tree index and you can roughly calculate the
  15591. size for the index file as `(key_length+4)/0.67', summed over all keys.
  15592. (This is for the worst case when all keys are inserted in sorted order
  15593. and we don't have any compressed keys.)
  15594.  
  15595. String indexes are space compressed. If the first index part is a
  15596. string, it will also be prefix compressed.  Space compression makes the
  15597. index file smaller than the above figures if the string column has a lot
  15598. of trailing space or is a `VARCHAR' column that is not always used to
  15599. the full length. Prefix compression is used on keys that start with a
  15600. string.  Prefix compression helps if there are many strings with an
  15601. identical prefix.
  15602.  
  15603. In `MyISAM' tables, you can also prefix compress numbers by specifying
  15604. `PACK_KEYS=1' when you create the table.  This helps when you have many
  15605. integer keys which have an identical prefix when the numbers are stored
  15606. high-byte first.
  15607.  
  15608. MyISAM table formats
  15609. --------------------
  15610.  
  15611. *MyISAM* supports 3 different table types. 2 of them are chosen
  15612. automatically depending on the type of columns you are using. The third,
  15613. compressed tables, can only be created with the `myisampack' tool.
  15614.  
  15615. Static (Fixed-length) table characteristics
  15616. ...........................................
  15617.  
  15618. This is the default format. It's used when the table contains no
  15619. `VARCHAR', `BLOB' or `TEXT' columns.
  15620.  
  15621. This format is the simplest and most secure format. It is also the
  15622. fastest of the on-disk formats. The speed comes from the easy way data
  15623. can be found on disk. When looking up something with an index and static
  15624. format it is very simple, just multiply the row number by the row
  15625. length.
  15626.  
  15627. Also when scanning a table it is very easy to read a constant number of
  15628. records with each disk read.
  15629.  
  15630. The security comes from if your computer crashes when writing to a
  15631. fixed size MyISAM file, `myisamchk' can easily figure out where each
  15632. row starts and ends. So it can usually reclaim all records except the
  15633. partially written one. Note that in *MySQL* all indexes can always be
  15634. reconstructed.
  15635.  
  15636.    * All `CHAR', `NUMERIC' and `DECIMAL' columns are space-padded to
  15637.      the column width.
  15638.  
  15639.    * Very quick.
  15640.  
  15641.    * Easy to cache.
  15642.  
  15643.    * Easy to reconstruct after a crash, because records are located in
  15644.      fixed positions.
  15645.  
  15646.    * Doesn't have to be reorganized (with `myisamchk') unless a huge
  15647.      number of records are deleted and you want to return free disk
  15648.      space to the operating system.
  15649.  
  15650.    * Usually requires more disk space than dynamic tables.
  15651.  
  15652. Dynamic table characteristics
  15653. .............................
  15654.  
  15655. This format is used if the table contains any `VARCHAR', `BLOB' or
  15656. `TEXT' columns or if the table was created with `ROW_FORMAT=dynamic'.
  15657.  
  15658. This format is a litte more complex because each row has to have a
  15659. header that says how long it is. One record can also end up at more
  15660. than one location when it is made longer at an update.
  15661.  
  15662. You can use `OPTIMIZE table' or `myisamchk' to defragment a table. If
  15663. you have static data that you access/change a lot in the same table as
  15664. some `VARCHAR' or `BLOB' columns, it might be a good idea to move the
  15665. dynamic columns to other tables just to avoid fragmentation.
  15666.  
  15667.    * All string columns are dynamic (except those with a length less
  15668.      than 4).
  15669.  
  15670.    * Each record is preceded by a bitmap indicating which columns are
  15671.      empty (`''') for string columns, or zero for numeric columns (this
  15672.      isn't the same as columns containing `NULL' values).  If a string
  15673.      column has a length of zero after removal of trailing spaces, or a
  15674.      numeric column has a value of zero, it is marked in the bit map
  15675.      and not saved to disk.  Non-empty strings are saved as a length
  15676.      byte plus the string contents.
  15677.  
  15678.    * Usually takes much less disk space than fixed-length tables.
  15679.  
  15680.    * Each record uses only as much space as is required. If a record
  15681.      becomes larger, it is split into as many pieces as required.  This
  15682.      results in record fragmentation.
  15683.  
  15684.    * If you update a row with information that extends the row length,
  15685.      the row will be fragmented.  In this case, you may have to run
  15686.      `myisamchk -r' from time to time to get better performance.  Use
  15687.      `myisamchk -ei tbl_name' for some statistics.
  15688.  
  15689.    * Not as easy to reconstruct after a crash, because a record may be
  15690.      fragmented into many pieces and a link (fragment) may be missing.
  15691.  
  15692.    * The expected row length for dynamic sized records is:
  15693.  
  15694.           3
  15695.           + (number of columns + 7) / 8
  15696.           + (number of char columns)
  15697.           + packed size of numeric columns
  15698.           + length of strings
  15699.           + (number of NULL columns + 7) / 8
  15700.  
  15701.      There is a penalty of 6 bytes for each link. A dynamic record is
  15702.      linked whenever an update causes an enlargement of the record.
  15703.      Each new link will be at least 20 bytes, so the next enlargement
  15704.      will probably go in the same link.  If not, there will be another
  15705.      link. You may check how many links there are with `myisamchk -ed'.
  15706.      All links may be removed with `myisamchk -r'.
  15707.  
  15708. Compressed table characteristics
  15709. ................................
  15710.  
  15711. This is a read only type that is generated with the optional
  15712. `myisampack' tool (`pack_isam' for `ISAM' tables).
  15713.  
  15714.    * All MySQL distributions, even those that existed before *MySQL*
  15715.      went GPL, can read tables that were compressed with `myisampack'.
  15716.  
  15717.    * Compressed tables takes very little disk space. This minimizes
  15718.      disk usage which is very nice when using slow disks (like CD-ROMs).
  15719.  
  15720.    * Each record is compressed separately (very little access
  15721.      overhead).  The header for a record is fixed (1-3 bytes) depending
  15722.      on the biggest record in the table.  Each column is compressed
  15723.      differently. Some of the compression types are:
  15724.         - There is usually a different Huffman table for each column.
  15725.  
  15726.         - Suffix space compression.
  15727.  
  15728.         - Prefix space compression.
  15729.  
  15730.         - Numbers with value `0' are stored using 1 bit.
  15731.  
  15732.         - If values in an integer column have a small range, the column
  15733.           is stored using the smallest possible type. For example, a
  15734.           `BIGINT' column (8 bytes) may be stored as a `TINYINT' column
  15735.           (1 byte) if all values are in the range `0' to `255'.
  15736.  
  15737.         - If a column has only a small set of possible values, the
  15738.           column type is converted to `ENUM'.
  15739.  
  15740.         - A column may use a combination of the above compressions.
  15741.  
  15742.    * Can handle fixed or dynamic length records, but not `BLOB' or
  15743.      `TEXT' columns.
  15744.  
  15745.    * Can be uncompressed with `myisamchk'.
  15746.  
  15747. ISAM tables
  15748. ===========
  15749.  
  15750. You can also use the deprecated ISAM table type. This will disappear
  15751. rather soon because `MyISAM' is a better implementation of the same
  15752. thing. ISAM uses a `B-tree' index. The index is stored in a file with
  15753. the `.ISM' extension and the data is stored in file with the `.ISD'
  15754. extension.  You can check/repair ISAM tables with the `isamchk'
  15755. utility. *Note Crash recovery::.
  15756.  
  15757. `ISAM' has the following features/properties:
  15758.  
  15759.    * Compressed and fixed length keys
  15760.  
  15761.    * Fixed and dynamic record length
  15762.  
  15763.    * 16 keys with 16 key parts / key
  15764.  
  15765.    * Max key length 256 (default)
  15766.  
  15767.    * Data is stored in machine format; this is fast, but is machine/OS
  15768.      dependent.
  15769.  
  15770. Most of the things for `MyISAM' tables are also true for `ISAM' tables.
  15771. *Note MyISAM::. The major differences compared to `MyISAM' tables are:
  15772.  
  15773.    * ISAM tables are not binary portable across OS/Platforms.
  15774.  
  15775.    * Can't handle tables > 4G.
  15776.  
  15777.    * Only support prefix compression on strings
  15778.  
  15779.    * Smaller key limits.
  15780.  
  15781.    * Dynamic tables gets more fragmented.
  15782.  
  15783.    * Tables are compressed with `pack_isam' rather than with
  15784.      `myisampack'.
  15785.  
  15786. HEAP tables
  15787. ===========
  15788.  
  15789. `HEAP' tables use a hashed index and are stored in memory.  This makes
  15790. them very fast, but if *MySQL* crashes you will lose all data stored in
  15791. them.  `HEAP' is very useful for temporary tables!
  15792.  
  15793. The *MySQL* internal HEAP tables uses 100% dynamic hashing without
  15794. overflow areas. There is no extra space needed for free lists.  `HEAP'
  15795. tables also don't have problems with delete + inserts, which normally
  15796. is common with hashed tables..
  15797.  
  15798.      mysql> CREATE TABLE test TYPE=HEAP SELECT ip,SUM(downloads) as down
  15799.              FROM log_table GROUP BY ip;
  15800.      mysql> SELECT COUNT(ip),AVG(down) FROM test;
  15801.      mysql> DROP TABLE test;
  15802.  
  15803. Here are some things you should consider when you use `HEAP' tables:
  15804.  
  15805.    * You should always use specify `MAX_ROWS' in the `CREATE' statement
  15806.      to ensure that you accidently do not use all memory.
  15807.  
  15808.    * Indexes will only be used with `=' and `<=>' (but are VERY fast).
  15809.  
  15810.    * `HEAP' tables can only use whole keys to search for a row; compare
  15811.      this to `MyISAM' tables where any prefix of the key can be used to
  15812.      find rows.
  15813.  
  15814.    * `HEAP' tables use a fixed record length format.
  15815.  
  15816.    * `HEAP' doesn't support `BLOB'/`TEXT' columns.
  15817.  
  15818.    * `HEAP' doesn't support `AUTO_INCREMENT' columns.
  15819.  
  15820.    * `HEAP' doesn't support an index on a `NULL' column.
  15821.  
  15822.    * You can have non-unique keys in a `HEAP' table (this isn't common
  15823.      for hashed tables).
  15824.  
  15825.    * `HEAP' tables are shared between all clients (just like any other
  15826.      table).
  15827.  
  15828.    * You can't search for the next entry in order (that is to use the
  15829.      index to do a `ORDER BY').
  15830.  
  15831.    * Data for `HEAP' tables are allocated in small blocks. The tables
  15832.      are 100% dynamic (on inserting). No overflow areas and no extra key
  15833.      space is needed.  Deleted rows are put in a linked list and are
  15834.      reused when you insert new data into the table.
  15835.  
  15836.    * You need enough extra memory for all HEAP tables that you want to
  15837.      use at the same time.
  15838.  
  15839.    * To free memory, you should execute `DELETE FROM heap_table' or
  15840.      `DROP TABLE heap_table'.
  15841.  
  15842.    * *MySQL* cannot find out how approximately many rows there are
  15843.      between two values (this is used by the range optimizer to decide
  15844.      which index to use).  This may affect some queries if you change a
  15845.      `MyISAM' table to a `HEAP' table.
  15846.  
  15847.    * To ensure that you accidentally don't do anything stupid, you
  15848.      can't create `HEAP' tables bigger than `max_heap_table_size'.
  15849.  
  15850. Memory needed for one row in a `HEAP' table is:
  15851.  
  15852. SUM_OVER_ALL_KEYS(max_length_of_key + sizeof(char*)*2) +
  15853. ALIGN(length_of_row+1,sizeof(char*))
  15854.  
  15855. `sizeof(char*)' is 4 on 32 bit machines and 8 on 64 bit machines.
  15856.  
  15857. BDB or Berkeley_db tables
  15858. =========================
  15859.  
  15860. Berkeley DB (`http://www.sleepycat.com') has provided *MySQL* with a
  15861. transaction safe table handler. This will survive crashes and also
  15862. provides `COMMIT' and `ROLLBACK' on transactions. In order to build
  15863. MySQL 3.23.x (BDB support first appeared in 3.23.15) with support for
  15864. `BDB' tables, you will need Berkeley DB 3.1.14 or newer which can be
  15865. downloaded from `http://www.mysql.com/downloads/mysql-3.23.html'; or
  15866. also from Sleepycat's download page at
  15867. `http://www.sleepycat.com/download.html'.
  15868.  
  15869. To install Berkeley DB first uncompress the `BDB' distribution and
  15870. follow the instructions in the README provided in the distiribution
  15871. directory. Basicly what you need to do is:
  15872.    * cd build_[your_os]
  15873.  
  15874.    * ../dist/configure
  15875.  
  15876.    * make
  15877.  
  15878.    * make install
  15879.  
  15880. Please refer to the manual provided by `BDB' distribution for
  15881. more/updated information.
  15882.  
  15883. After this you need to configure your *MySQL* with
  15884. -with-berkeley-db=DIR The directory is the one where you installed
  15885. `BDB' binaries with make install. (Usually it is
  15886. /usr/local/BerkeleyDB.3.1/) You can give additional options to *MySQL*
  15887. configure, -with-berkeley-db-includes=DIR and
  15888. -with-berkeley-db-libs=DIR, if the `BDB' includes and/or libs directory
  15889. is not under the first directory. By default they are.  Then complete
  15890. the *MySQL* installation as normal.
  15891.  
  15892. Even if Berkeley DB is in itself very tested and reliably, the *MySQL*
  15893. interface is still very alpha, but we are actively improving and
  15894. optimizing it to get it this stable real soon.
  15895.  
  15896. If you are running with `AUTOCOMMIT=0' then your changes in `BDB'
  15897. tables will not be updated until you execute `COMMIT'.  Instead of
  15898. commit you can execute `ROLLBACK' to forget your changes. *Note
  15899. COMMIT::.
  15900.  
  15901. The following options to `mysqld' can be used to change the behavour of
  15902. BDB tables:
  15903.  
  15904. -bdb-home=  directory  Berkeley home direcory
  15905. -bdb-lock-detect=#     Berkeley lock detect. One of (DEFAULT, OLDEST,
  15906.                        RANDOM or YOUNGEST)
  15907. -bdb-logdir=directory  Berkeley DB log file directory
  15908. -bdb-nosync            Don't synchronously flush logs
  15909. -bdb-recover           Start Berkeley DB in recover mode
  15910. -bdb-tmpdir=directory  Berkeley DB tempfile name
  15911. -skip-bdb              Don't use berkeley db.
  15912.  
  15913. If you use `--skip-bdb', *MySQL* will not initialize the Berkeley DB
  15914. library and this will save a lot of memory.  You can of course not use
  15915. `BDB' tables if you are using this option.
  15916.  
  15917. Normally you should start mysqld with `--bdb-recover' if you intend to
  15918. use BDB tables.  This may however give you problems when you try to
  15919. start mysqld if the BDB log files are corrupted. *Note Starting
  15920. server::.
  15921.  
  15922. Some characteristic of `BDB' tables:
  15923.  
  15924.    * All `BDB' tables must have a primary key.
  15925.  
  15926.    * If all columns you access in a `BDB' tables is part of the same
  15927.      index or part of the the primary key then *MySQL* can execute the
  15928.      query without having to access the actual row.  In a `MyISAM'
  15929.      table the above holds only if the columns are part of the same
  15930.      index.
  15931.  
  15932.    * `LOCK TABLES' works on `BDB' tables as with other tables.  If you
  15933.      don't use `LOCK TABLE', *MYSQL* will issue an internal multiple
  15934.      write lock on the table to ensure that the table will be properly
  15935.      locked if one another thread issues a table lock.
  15936.  
  15937.    * `ALTER TABLE' doesn't yet work on `BDB' tables.
  15938.  
  15939.    * Internal locking in `BDB' tables are done on page level.
  15940.  
  15941.    * Scanning is slower than with `MyISAM' tables as one has data in BDB
  15942.      tables is stored in B-trees and not in a separate data file.
  15943.  
  15944.    * One must in the application always be prepared to handle the case
  15945.      that any change of a `BDB' table may make an automatic rollback
  15946.      and any read may fail with a deadlock error.
  15947.  
  15948.    * Keys are not compressed to previous keys as with ISAM or MyISAM
  15949.      tables. In other words, the key information will take a little more
  15950.      space in `BDB' tables compared to MyISAM tables with don't use
  15951.      `PACK_KEYS=0'.
  15952.  
  15953.    * One must do a `FLUSH LOGS' from time to time to sync to get
  15954.      checkpoints for the `BDB' tables.
  15955.  
  15956.    * As transaction logs take more place than ordinary logs it's more
  15957.      important to rotate and remove old logs when using `BDB' tables
  15958.      than using other table types.
  15959.  
  15960. Some things that we have to fix in the near future:
  15961.  
  15962.    * Remove the requirement that `BDB' tables must have a primary key.
  15963.      This will be fixed by having an automatic hidden auto_increment
  15964.      column for the tables without a primary key.
  15965.  
  15966.    * `LOCK TABLES' should work as for other *MySQL* tables.
  15967.  
  15968.    * `ALTER TABLE' doesn't yet work.
  15969.  
  15970.    * `SHOW TABLE STATUS' doesn't yet provide that much information for
  15971.      BDB tables.
  15972.  
  15973. MySQL Tutorial
  15974. **************
  15975.  
  15976. This chapter provides a tutorial introduction to *MySQL* by showing how
  15977. to use the `mysql' client program to create and use a simple database.
  15978. `mysql' (sometimes referred to as the "terminal monitor" or just
  15979. "monitor") is an interactive program that allows you to connect to a
  15980. *MySQL* server, run queries and view the results.  `mysql' may also be
  15981. used in batch mode: you place your queries in a file beforehand, then
  15982. tell `mysql' to execute the contents of the file.  Both ways of using
  15983. `mysql' are covered here.
  15984.  
  15985. To see a list of options provided by `mysql', invoke it with the
  15986. `--help' option:
  15987.  
  15988.      shell> mysql --help
  15989.  
  15990. This chapter assumes that `mysql' is installed on your machine, and that
  15991. a *MySQL* server is available to which you can connect.  If this is not
  15992. true, contact your *MySQL* administrator.  (If _you_ are the
  15993. administrator, you will need to consult other sections of this manual.)
  15994.  
  15995. The chapter describes the entire process of setting up and using a
  15996. database.  If you are interested only in accessing an already-existing
  15997. database, you may want to skip over the sections that describe how to
  15998. create the database and the tables it contains.
  15999.  
  16000. Because this chapter is tutorial in nature, many details are
  16001. necessarily left out.  Consult the relevant sections of the manual for
  16002. more information on the topics covered here.
  16003.  
  16004. Connecting to and disconnecting from the server
  16005. ===============================================
  16006.  
  16007. To connect to the server, you'll usually need to provide a *MySQL* user
  16008. name when you invoke `mysql' and, most likely, a password.  If the
  16009. server runs on a machine other than the one where you log in, you'll
  16010. also need to specify a hostname.  Contact your administrator to find
  16011. out what connection parameters you should use to connect (i.e., what
  16012. host, user name and password to use).  Once you know the proper
  16013. parameters, you should be able to connect like this:
  16014.  
  16015.      shell> mysql -h host -u user -p
  16016.      Enter password: ********
  16017.  
  16018. The `********' represents your password; enter it when `mysql' displays
  16019. the `Enter password:' prompt.
  16020.  
  16021. If that works, you should see some introductory information followed by
  16022. a `mysql>' prompt:
  16023.  
  16024.      shell> mysql -h host -u user -p
  16025.      Enter password: ********
  16026.      Welcome to the MySQL monitor.  Commands end with ; or \g.
  16027.      Your MySQL connection id is 459 to server version: 3.22.20a-log
  16028.      
  16029.      Type 'help' for help.
  16030.      
  16031.      mysql>
  16032.  
  16033. The prompt tells you that `mysql' is ready for you to enter commands.
  16034.  
  16035. Some *MySQL* installations allow users to connect as the "anonymous"
  16036. (unnamed) user to the server running on the local host.  If this is the
  16037. case on your machine, you should be able to connect to that server by
  16038. invoking `mysql' without any options:
  16039.  
  16040.      shell> mysql
  16041.  
  16042. After you have connected successfully, you can disconnect any time by
  16043. typing `QUIT' at the `mysql>' prompt:
  16044.  
  16045.      mysql> QUIT
  16046.      Bye
  16047.  
  16048. You can also disconnect by typing control-D.
  16049.  
  16050. Most examples in the following sections assume you are connected to the
  16051. server.  They indicate this by the `mysql>' prompt.
  16052.  
  16053. Entering queries
  16054. ================
  16055.  
  16056. Make sure you are connected to the server, as discussed in the previous
  16057. section.  Doing so will not in itself select any database to work with,
  16058. but that's okay.  At this point, it's more important to find out a
  16059. little about how to issue queries than to jump right in creating
  16060. tables, loading data into them and retrieving data from them.  This
  16061. section describes the basic principles of entering commands, using
  16062. several queries you can try out to familiarize yourself with how
  16063. `mysql' works.
  16064.  
  16065. Here's a simple command that asks the server to tell you its version
  16066. number and the current date.  Type it in as shown below following the
  16067. `mysql>' prompt and hit the RETURN key:
  16068.  
  16069.      mysql> SELECT VERSION(), CURRENT_DATE;
  16070.      +--------------+--------------+
  16071.      | version()    | CURRENT_DATE |
  16072.      +--------------+--------------+
  16073.      | 3.22.20a-log | 1999-03-19   |
  16074.      +--------------+--------------+
  16075.      1 row in set (0.01 sec)
  16076.      mysql>
  16077.  
  16078. This query illustrates several things about `mysql':
  16079.  
  16080.    * A command normally consists of a SQL statement followed by a
  16081.      semicolon.  (There are some exceptions where a semicolon is not
  16082.      needed.  `QUIT', mentioned earlier, is one of them.  We'll get to
  16083.      others later.)
  16084.  
  16085.    * When you issue a command, `mysql' sends it to the server for
  16086.      execution and displays the results, then prints another `mysql>'
  16087.      to indicate that it is ready for another command.
  16088.  
  16089.    * `mysql' displays query output as a table (rows and columns).  The
  16090.      first row contains labels for the columns.  The rows following are
  16091.      the query results.  Normally, column labels are the names of the
  16092.      columns you fetch from database tables.  If you're retrieving the
  16093.      value of an expression rather than a table column (as in the
  16094.      example just shown), `mysql' labels the column using the
  16095.      expression itself.
  16096.  
  16097.    * `mysql' shows how many rows were returned, and how long the query
  16098.      took to execute, which gives you a rough idea of server
  16099.      performance.  These values are imprecise because they represent
  16100.      wall clock time (not CPU or machine time), and because they are
  16101.      affected by factors such as server load and network latency.  (For
  16102.      brevity, the "rows in set" line is not shown in the remaining
  16103.      examples in this chapter.)
  16104.  
  16105. Keywords may be entered in any lettercase.  The following queries are
  16106. equivalent:
  16107.  
  16108.      mysql> SELECT VERSION(), CURRENT_DATE;
  16109.      mysql> select version(), current_date;
  16110.      mysql> SeLeCt vErSiOn(), current_DATE;
  16111.  
  16112. Here's another query.  It demonstrates that you can use `mysql' as a
  16113. simple calculator:
  16114.  
  16115.      mysql> SELECT SIN(PI()/4), (4+1)*5;
  16116.      +-------------+---------+
  16117.      | SIN(PI()/4) | (4+1)*5 |
  16118.      +-------------+---------+
  16119.      |    0.707107 |      25 |
  16120.      +-------------+---------+
  16121.  
  16122. The commands shown thus far have been relatively short, single-line
  16123. statements.  You can even enter multiple statements on a single line.
  16124. Just end each one with a semicolon:
  16125.  
  16126.      mysql> SELECT VERSION(); SELECT NOW();
  16127.      +--------------+
  16128.      | version()    |
  16129.      +--------------+
  16130.      | 3.22.20a-log |
  16131.      +--------------+
  16132.      
  16133.      +---------------------+
  16134.      | NOW()               |
  16135.      +---------------------+
  16136.      | 1999-03-19 00:15:33 |
  16137.      +---------------------+
  16138.  
  16139. A command need not be given all on a single line, so lengthy commands
  16140. that require several lines are not a problem.  `mysql' determines where
  16141. your statement ends by looking for the terminating semicolon, not by
  16142. looking for the end of the input line.  (In other words, `mysql'
  16143. accepts free-format input:  it collects input lines but does not
  16144. execute them until it sees the semicolon.)
  16145.  
  16146. Here's a simple multiple-line statement:
  16147.  
  16148.      mysql> SELECT
  16149.          -> USER()
  16150.          -> ,
  16151.          -> CURRENT_DATE;
  16152.      +--------------------+--------------+
  16153.      | USER()             | CURRENT_DATE |
  16154.      +--------------------+--------------+
  16155.      | joesmith@localhost | 1999-03-18   |
  16156.      +--------------------+--------------+
  16157.  
  16158. In this example, notice how the prompt changes from `mysql>' to `->'
  16159. after you enter the first line of a multiple-line query.  This is how
  16160. `mysql' indicates that it hasn't seen a complete statement and is
  16161. waiting for the rest.  The prompt is your friend, because it provides
  16162. valuable feedback.  If you use that feedback, you will always be aware
  16163. of what `mysql' is waiting for.
  16164.  
  16165. If you decide you don't want to execute a command that you are in the
  16166. process of entering, cancel it by typing `\c':
  16167.  
  16168.      mysql> SELECT
  16169.          -> USER()
  16170.          -> \c
  16171.      mysql>
  16172.  
  16173. Here, too, notice the prompt.  It switches back to `mysql>' after you
  16174. type `\c', providing feedback to indicate that `mysql' is ready for a
  16175. new command.
  16176.  
  16177. The following table shows each of the prompts you may see and
  16178. summarizes what they mean about the state that `mysql' is in:
  16179.  
  16180. *Prompt**Meaning*
  16181. `mysql>'Ready for new command
  16182. `       Waiting for next line of multiple-line command
  16183. ->'     
  16184. `       Waiting for next line, collecting a string that begins with a
  16185. '>'     single quote (`'')
  16186. `       Waiting for next line, collecting a string that begins with a
  16187. ">'     double quote (`"')
  16188.  
  16189. Multiple-line statements commonly occur "by accident" when you intend to
  16190. issue a command on a single line, but forget the terminating semicolon.
  16191. In this case, `mysql' waits for more input:
  16192.  
  16193.      mysql> SELECT USER()
  16194.          ->
  16195.  
  16196. If this happens to you (you think you've entered a statement but the
  16197. only response is a `->' prompt), most likely `mysql' is waiting for the
  16198. semicolon.  If you don't notice what the prompt is telling you, you
  16199. might sit there for a while before realizing what you need to do.
  16200. Enter a semicolon to complete the statement, and `mysql' will execute
  16201. it:
  16202.  
  16203.      mysql> SELECT USER()
  16204.          -> ;
  16205.      +--------------------+
  16206.      | USER()             |
  16207.      +--------------------+
  16208.      | joesmith@localhost |
  16209.      +--------------------+
  16210.  
  16211. The `'>' and `">' prompts occur during string collection.  In *MySQL*,
  16212. you can write strings surrounded by either `'' or `"' characters (for
  16213. example, `'hello'' or `"goodbye"'), and `mysql' lets you enter strings
  16214. that span multiple lines.  When you see a `'>' or `">' prompt, it means
  16215. that you've entered a line containing a string that begins with a `''
  16216. or `"' quote character, but have not yet entered the matching quote
  16217. that terminates the string.  That's fine if you really are entering a
  16218. multiple-line string, but how likely is that?  Not very.  More often,
  16219. the `'>' and `">' prompts indicate that you've inadvertantly left out a
  16220. quote character.  For example:
  16221.  
  16222.      mysql> SELECT * FROM my_table WHERE name = "Smith AND age < 30;
  16223.          ">
  16224.  
  16225. If you enter this `SELECT' statement, then hit RETURN and wait for the
  16226. result, nothing will happen.  Instead of wondering, "why does this
  16227. query take so long?," notice the clue provided by the `">' prompt.  It
  16228. tells you that `mysql' expects to see the rest of an unterminated
  16229. string.  (Do you see the error in the statement?  The string `"Smith' is
  16230. missing the second quote.)
  16231.  
  16232. At this point, what do you do?  The simplest thing is to cancel the
  16233. command.  However, you cannot just type `\c' in this case, because
  16234. `mysql' interprets it as part of the string that it is collecting!
  16235. Instead, enter the closing quote character (so `mysql' knows you've
  16236. finished the string), then type `\c':
  16237.  
  16238.      mysql> SELECT * FROM my_table WHERE name = "Smith AND age < 30;
  16239.          "> "\c
  16240.      mysql>
  16241.  
  16242. The prompt changes back to `mysql>', indicating that `mysql' is ready
  16243. for a new command.
  16244.  
  16245. It's important to know what the `'>' and `">' prompts signify, because
  16246. if you mistakenly enter an unterminated string, any further lines you
  16247. type will appear to be ignored by `mysql' -- including a line
  16248. containing `QUIT'!  This can be quite confusing, especially if you
  16249. don't know that you need to supply the terminating quote before you can
  16250. cancel the current command.
  16251.  
  16252. Examples of common queries
  16253. ==========================
  16254.  
  16255. Here follows examples of how to solve some common problems with *MySQL*.
  16256.  
  16257. Some of the examples use the table `shop' to hold the price of each
  16258. article (item number) for certain traders (dealers).  Supposing that
  16259. each trader has a single fixed price per article, then (`item',
  16260. `trader') is a primary key for the records.
  16261.  
  16262. You can create the example table as:
  16263.  
  16264.      CREATE TABLE shop (
  16265.       article INT(4) UNSIGNED ZEROFILL DEFAULT '0000' NOT NULL,
  16266.       dealer  CHAR(20)                 DEFAULT ''     NOT NULL,
  16267.       price   DOUBLE(16,2)             DEFAULT '0.00' NOT NULL,
  16268.       PRIMARY KEY(article, dealer));
  16269.      
  16270.      INSERT INTO shop VALUES
  16271.      (1,'A',3.45),(1,'B',3.99),(2,'A',10.99),(3,'B',1.45),(3,'C',1.69),
  16272.      (3,'D',1.25),(4,'D',19.95);
  16273.  
  16274. Okay, so the example data is:
  16275.  
  16276.      SELECT * FROM shop
  16277.      
  16278.      +---------+--------+-------+
  16279.      | article | dealer | price |
  16280.      +---------+--------+-------+
  16281.      |    0001 | A      |  3.45 |
  16282.      |    0001 | B      |  3.99 |
  16283.      |    0002 | A      | 10.99 |
  16284.      |    0003 | B      |  1.45 |
  16285.      |    0003 | C      |  1.69 |
  16286.      |    0003 | D      |  1.25 |
  16287.      |    0004 | D      | 19.95 |
  16288.      +---------+--------+-------+
  16289.  
  16290. The maximum value for a column
  16291. ------------------------------
  16292.  
  16293. "What's the highest item number?"
  16294.  
  16295.      SELECT MAX(article) AS article FROM shop
  16296.      
  16297.      +---------+
  16298.      | article |
  16299.      +---------+
  16300.      |       4 |
  16301.      +---------+
  16302.  
  16303. The row holding the maximum of a certain column
  16304. -----------------------------------------------
  16305.  
  16306. "Find number, dealer, and price of the most expensive article."
  16307.  
  16308. In ANSI SQL this is easily done with a sub-query:
  16309.  
  16310.      SELECT article, dealer, price
  16311.      FROM   shop
  16312.      WHERE  price=(SELECT MAX(price) FROM shop)
  16313.  
  16314. In *MySQL* (which does not yet have sub-selects), just do it in two
  16315. steps:
  16316.  
  16317.   1. Get the maximum price value from the table with a `SELECT'
  16318.      statement.
  16319.  
  16320.   2. Using this value compile the actual query:
  16321.           SELECT article, dealer, price
  16322.           FROM   shop
  16323.           WHERE  price=19.95
  16324.  
  16325. Another solution is to sort all rows descending by price and only get
  16326. the first row using the *MySQL* specific `LIMIT' clause:
  16327.  
  16328.      SELECT article, dealer, price
  16329.      FROM   shop
  16330.      ORDER BY price DESC
  16331.      LIMIT 1
  16332.  
  16333. *Note*:  If there are several most expensive articles (e.g. each 19.95)
  16334. the `LIMIT' solution shows only one of them!
  16335.  
  16336. Maximum of column: per group: only the values
  16337. ---------------------------------------------
  16338.  
  16339. "What's the highest price per article?"
  16340.  
  16341.      SELECT article, MAX(price) AS price
  16342.      FROM   shop
  16343.      GROUP BY article
  16344.      
  16345.      +---------+-------+
  16346.      | article | price |
  16347.      +---------+-------+
  16348.      |    0001 |  3.99 |
  16349.      |    0002 | 10.99 |
  16350.      |    0003 |  1.69 |
  16351.      |    0004 | 19.95 |
  16352.      +---------+-------+
  16353.  
  16354. The rows holding the group-wise maximum of a certain field
  16355. ----------------------------------------------------------
  16356.  
  16357. "For each article, find the dealer(s) with the most expensive price."
  16358.  
  16359. In ANSI SQL, I'd do it with a sub-query like this:
  16360.  
  16361.      SELECT article, dealer, price
  16362.      FROM   shop s1
  16363.      WHERE  price=(SELECT MAX(s2.price)
  16364.                    FROM shop s2
  16365.                    WHERE s1.article = s2.article)
  16366.  
  16367. In *MySQL* it's best do it in several steps:
  16368.  
  16369.   1. Get the list of (article,maxprice). *Note
  16370.      example-Maximum-column-group-row::.
  16371.  
  16372.   2. For each article get the corresponding rows which have the stored
  16373.      maximum price.
  16374.  
  16375. This can easily be done with a temporary table:
  16376.  
  16377.      CREATE TEMPORARY TABLE tmp (
  16378.              article INT(4) UNSIGNED ZEROFILL DEFAULT '0000' NOT NULL,
  16379.              price   DOUBLE(16,2)             DEFAULT '0.00' NOT NULL);
  16380.      
  16381.      LOCK TABLES article read;
  16382.      
  16383.      INSERT INTO tmp SELECT article, MAX(price) FROM shop GROUP BY article;
  16384.      
  16385.      SELECT article, dealer, price FROM shop, tmp
  16386.      WHERE shop.article=tmp.article AND shop.price=tmp.price;
  16387.      
  16388.      UNLOCK TABLES;
  16389.      
  16390.      DROP TABLE tmp;
  16391.  
  16392. If you don't use a `TEMPORARY' table, you must also lock the 'tmp'
  16393. table.
  16394.  
  16395. "Can it be done with a single query?"
  16396.  
  16397. Yes, but only by using a quite inefficient trick that I call the
  16398. "MAX-CONCAT trick":
  16399.  
  16400.      SELECT article,
  16401.             SUBSTRING( MAX( CONCAT(LPAD(price,6,'0'),dealer) ), 7) AS dealer,
  16402.        0.00+LEFT(      MAX( CONCAT(LPAD(price,6,'0'),dealer) ), 6) AS price
  16403.      FROM   shop
  16404.      GROUP BY article;
  16405.      
  16406.      +---------+--------+-------+
  16407.      | article | dealer | price |
  16408.      +---------+--------+-------+
  16409.      |    0001 | B      |  3.99 |
  16410.      |    0002 | A      | 10.99 |
  16411.      |    0003 | C      |  1.69 |
  16412.      |    0004 | D      | 19.95 |
  16413.      +---------+--------+-------+
  16414.  
  16415. The last example can of course be made a bit more efficient by doing the
  16416. splitting of the concatenated column in the client.
  16417.  
  16418. Using foreign keys
  16419. ------------------
  16420.  
  16421. You don't need foreign keys to join 2 tables.
  16422.  
  16423. The only thing *MySQL* doesn't do is `CHECK' to make sure that the keys
  16424. you use really exist in the table(s) you're referencing and it doesn't
  16425. automatically delete rows from table with a foreign key definition. If
  16426. you use your keys like normal, it'll work just fine!
  16427.  
  16428.      CREATE TABLE persons (
  16429.          id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
  16430.          name CHAR(60) NOT NULL,
  16431.          PRIMARY KEY (id)
  16432.      );
  16433.      
  16434.      CREATE TABLE shirts (
  16435.          id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
  16436.          style ENUM('t-shirt', 'polo', 'dress') NOT NULL,
  16437.          color ENUM('red', 'blue', 'orange', 'white', 'black') NOT NULL,
  16438.          owner SMALLINT UNSIGNED NOT NULL REFERENCES persons,
  16439.          PRIMARY KEY (id)
  16440.      );
  16441.      
  16442.      
  16443.      INSERT INTO persons VALUES (NULL, 'Antonio Paz');
  16444.      
  16445.      INSERT INTO shirts VALUES
  16446.      (NULL, 'polo', 'blue', LAST_INSERT_ID()),
  16447.      (NULL, 'dress', 'white', LAST_INSERT_ID()),
  16448.      (NULL, 't-shirt', 'blue', LAST_INSERT_ID());
  16449.      
  16450.      
  16451.      INSERT INTO persons VALUES (NULL, 'Lilliana Angelovska');
  16452.      
  16453.      INSERT INTO shirts VALUES
  16454.      (NULL, 'dress', 'orange', LAST_INSERT_ID()),
  16455.      (NULL, 'polo', 'red', LAST_INSERT_ID()),
  16456.      (NULL, 'dress', 'blue', LAST_INSERT_ID()),
  16457.      (NULL, 't-shirt', 'white', LAST_INSERT_ID());
  16458.      
  16459.      
  16460.      SELECT * FROM persons;
  16461.      +----+---------------------+
  16462.      | id | name                |
  16463.      +----+---------------------+
  16464.      |  1 | Antonio Paz         |
  16465.      |  2 | Lilliana Angelovska |
  16466.      +----+---------------------+
  16467.      
  16468.      SELECT * FROM shirts;
  16469.      +----+---------+--------+-------+
  16470.      | id | style   | color  | owner |
  16471.      +----+---------+--------+-------+
  16472.      |  1 | polo    | blue   |     1 |
  16473.      |  2 | dress   | white  |     1 |
  16474.      |  3 | t-shirt | blue   |     1 |
  16475.      |  4 | dress   | orange |     2 |
  16476.      |  5 | polo    | red    |     2 |
  16477.      |  6 | dress   | blue   |     2 |
  16478.      |  7 | t-shirt | white  |     2 |
  16479.      +----+---------+--------+-------+
  16480.      
  16481.      
  16482.      SELECT s.* FROM persons p, shirts s
  16483.       WHERE p.name LIKE 'Lilliana%'
  16484.         AND s.owner = p.id
  16485.         AND s.color <> 'white';
  16486.      
  16487.      +----+-------+--------+-------+
  16488.      | id | style | color  | owner |
  16489.      +----+-------+--------+-------+
  16490.      |  4 | dress | orange |     2 |
  16491.      |  5 | polo  | red    |     2 |
  16492.      |  6 | dress | blue   |     2 |
  16493.      +----+-------+--------+-------+
  16494.  
  16495. Searching on two keys
  16496. =====================
  16497.  
  16498. *MySQL* doesn't yet optimize when you search on two different keys
  16499. combined with `OR' (Searching on one key with different `OR' parts is
  16500. optimized quite good):
  16501.  
  16502.      SELECT field1_index, field2_index FROM test_table WHERE field1_index = '1'
  16503.      OR  field2_index = '1'
  16504.  
  16505. The reason is that we haven't yet had time to come up with an efficient
  16506. way to handle this in the general case. (The `AND' handling is in
  16507. comparison now completely general and works very well).
  16508.  
  16509. For the moment you can solve this very efficently by using a
  16510. `TEMPORARY' table; This type of optimization is also very good if you
  16511. are using very complicated queries where the SQL server does the
  16512. optimizations in the wrong order.
  16513.  
  16514.      CREATE TEMPORARY TABLE tmp
  16515.      SELECT field1_index, field2_index FROM test_table WHERE field1_index = '1';
  16516.      INSERT INTO tmp
  16517.      SELECT field1_index, field2_index FROM test_table WHERE field2_index = '1';
  16518.      SELECT * from tmp;
  16519.      DROP TABLE tmp;
  16520.  
  16521. The above way to solve this query is in effect an `UNION' of two
  16522. queries.
  16523.  
  16524. Creating and using a database
  16525. =============================
  16526.  
  16527. Now that you know how to enter commands, it's time to access a database.
  16528.  
  16529. Suppose you have several pets in your home (your "menagerie") and you'd
  16530. like to keep track of various types of information about them.  You can
  16531. do so by creating tables to hold your data and loading them with the
  16532. desired information.  Then you can answer different sorts of questions
  16533. about your animals by retrieving data from the tables.  This section
  16534. shows how to do all that:
  16535.  
  16536.    * How to create a database
  16537.  
  16538.    * How to create a table
  16539.  
  16540.    * How to load data into the table
  16541.  
  16542.    * How to retrieve data from the table in various ways
  16543.  
  16544.    * How to use multiple tables
  16545.  
  16546. The menagerie database will be simple (deliberately), but it is not
  16547. difficult to think of real-world situations in which a similar type of
  16548. database might be used.  For example, a database like this could be
  16549. used by a farmer to keep track of livestock, or by a veterinarian to
  16550. keep track of patient records.
  16551.  
  16552. Use the `SHOW' statement to find out what databases currently exist on
  16553. the server:
  16554.  
  16555.      mysql> SHOW DATABASES;
  16556.      +----------+
  16557.      | Database |
  16558.      +----------+
  16559.      | mysql    |
  16560.      | test     |
  16561.      | tmp      |
  16562.      +----------+
  16563.  
  16564. The list of databases is probably different on your machine, but the
  16565. `mysql' and `test' databases are likely to be among them.  The `mysql'
  16566. database is required because it describes user access privileges.  The
  16567. `test' database is often provided as a workspace for users to try
  16568. things out.
  16569.  
  16570. If the `test' database exists, try to access it:
  16571.  
  16572.      mysql> USE test
  16573.      Database changed
  16574.  
  16575. Note that `USE', like `QUIT', does not require a semicolon.  (You can
  16576. terminate such statements with a semicolon if you like; it does no
  16577. harm.)  The `USE' statement is special in another way, too:  it must be
  16578. given on a single line.
  16579.  
  16580. You can use the `test' database (if you have access to it) for the
  16581. examples that follow, but anything you create in that database can be
  16582. removed by anyone else with access to it.  For this reason, you should
  16583. probably ask your *MySQL* administrator for permission to use a
  16584. database of your own.  Suppose you want to call yours `menagerie'.  The
  16585. administrator needs to execute a command like this:
  16586.  
  16587.      mysql> GRANT ALL ON menagerie.* TO your_mysql_name;
  16588.  
  16589. where `your_mysql_name' is the *MySQL* user name assigned to you.
  16590.  
  16591. Creating and selecting a database
  16592. ---------------------------------
  16593.  
  16594. If the administrator creates your database for you when setting up your
  16595. permissions, you can begin using it.  Otherwise, you need to create it
  16596. yourself:
  16597.  
  16598.      mysql> CREATE DATABASE menagerie;
  16599.  
  16600. Under Unix, database names are case sensitive (unlike SQL keywords), so
  16601. you must always refer to your database as `menagerie', not as
  16602. `Menagerie', `MENAGERIE' or some other variant.  This is also true for
  16603. table names.  (Under Windows, this restriction does not apply, although
  16604. you must refer to databases and tables using the same lettercase
  16605. throughout a given query.)
  16606.  
  16607. Creating a database does not select it for use, you must do that
  16608. explicitly.  To make `menagerie' the current database, use this command:
  16609.  
  16610.      mysql> USE menagerie
  16611.      Database changed
  16612.  
  16613. Your database needs to be created only once, but you must select it for
  16614. use each time you begin a `mysql' session.  You can do this by issuing a
  16615. `USE' statement as shown above.  Alternatively, you can select the
  16616. database on the command line when you invoke `mysql'.  Just specify its
  16617. name after any connection parameters that you might need to provide.
  16618. For example:
  16619.  
  16620.      shell> mysql -h host -u user -p menagerie
  16621.      Enter password: ********
  16622.  
  16623. Note that `menagerie' is not your password on the command just shown.
  16624. If you want to supply your password on the command line after the `-p'
  16625. option, you must do so with no intervening space (e.g., as
  16626. `-pmypassword', not as `-p mypassword').  However, putting your
  16627. password on the command line is not recommended, because doing so
  16628. exposes it to snooping by other users logged in on your machine.
  16629.  
  16630. Creating a table
  16631. ----------------
  16632.  
  16633. Creating the database is the easy part, but at this point it's empty, as
  16634. `SHOW TABLES' will tell you:
  16635.  
  16636.      mysql> SHOW TABLES;
  16637.      Empty set (0.00 sec)
  16638.  
  16639. The harder part is deciding what the structure of your database should
  16640. be: what tables you will need, and what columns will be in each of them.
  16641.  
  16642. You'll want a table that contains a record for each of your pets.  This
  16643. can be called the `pet' table, and it should contain, as a bare minimum,
  16644. each animal's name.  Because the name by itself is not very
  16645. interesting, the table should contain other information.  For example,
  16646. if more than one person in your family keeps pets, you might want to
  16647. list each animal's owner.  You might also want to record some basic
  16648. descriptive information such as species and sex.
  16649.  
  16650. How about age?  That might be of interest, but it's not a good thing to
  16651. store in a database.  Age changes as time passes, which means you'd
  16652. have to update your records often.  Instead, it's better to store a
  16653. fixed value such as date of birth.  Then, whenever you need age, you
  16654. can calculate it as the difference between the current date and the
  16655. birth date.  *MySQL* provides functions for doing date arithmetic, so
  16656. this is not difficult.  Storing birth date rather than age has other
  16657. advantages, too:
  16658.  
  16659.    * You can use the database for tasks such as generating reminders
  16660.      for upcoming pet birthdays.  (If you think this type of query is
  16661.      somewhat silly, note that it is the same question you might ask in
  16662.      the context of a business database to identify clients to whom
  16663.      you'll soon need to send out birthday greetings, for that
  16664.      computer-assisted personal touch.)
  16665.  
  16666.    * You can calculate age in relation to dates other than the current
  16667.      date.  For example, if you store death date in the database, you
  16668.      can easily calculate how old a pet was when it died.
  16669.  
  16670. You can probably think of other types of information that would be
  16671. useful in the `pet' table, but the ones identified so far are
  16672. sufficient for now: name, owner, species, sex, birth and death.
  16673.  
  16674. Use a `CREATE TABLE' statement to specify the layout of your table:
  16675.  
  16676.      mysql> CREATE TABLE pet (name VARCHAR(20), owner VARCHAR(20),
  16677.          -> species VARCHAR(20), sex CHAR(1), birth DATE, death DATE);
  16678.  
  16679. `VARCHAR' is a good choice for the `name', `owner' and `species'
  16680. columns because the column values will vary in length.  The lengths of
  16681. those columns need not all be the same, and need not be `20'.  You can
  16682. pick any length from `1' to `255', whatever seems most reasonable to
  16683. you.  (If you make a poor choice and it turns out later that you need a
  16684. longer field, *MySQL* provides an `ALTER TABLE' statement.)
  16685.  
  16686. Animal sex can be represented in a variety of ways, for example, `"m"'
  16687. and `"f"', or perhaps `"male"' and `"female"'.  It's simplest to use
  16688. the single characters `"m"' and `"f"'.
  16689.  
  16690. The use of the `DATE' data type for the `birth' and `death' columns is
  16691. a fairly obvious choice.
  16692.  
  16693. Now that you have created a table, `SHOW TABLES' should produce some
  16694. output:
  16695.  
  16696.      mysql> SHOW TABLES;
  16697.      +---------------------+
  16698.      | Tables in menagerie |
  16699.      +---------------------+
  16700.      | pet                 |
  16701.      +---------------------+
  16702.  
  16703. To verify that your table was created the way you expected, use a
  16704. `DESCRIBE' statement:
  16705.  
  16706.      mysql> DESCRIBE pet;
  16707.      +---------+-------------+------+-----+---------+-------+
  16708.      | Field   | Type        | Null | Key | Default | Extra |
  16709.      +---------+-------------+------+-----+---------+-------+
  16710.      | name    | varchar(20) | YES  |     | NULL    |       |
  16711.      | owner   | varchar(20) | YES  |     | NULL    |       |
  16712.      | species | varchar(20) | YES  |     | NULL    |       |
  16713.      | sex     | char(1)     | YES  |     | NULL    |       |
  16714.      | birth   | date        | YES  |     | NULL    |       |
  16715.      | death   | date        | YES  |     | NULL    |       |
  16716.      +---------+-------------+------+-----+---------+-------+
  16717.  
  16718. You can use `DESCRIBE' any time, for example, if you forget the names of
  16719. the columns in your table or what types they are.
  16720.  
  16721. Loading data into a table
  16722. -------------------------
  16723.  
  16724. After creating your table, you need to populate it.  The `LOAD DATA' and
  16725. `INSERT' statements are useful for this.
  16726.  
  16727. Suppose your pet records can be described as shown below.  (Observe
  16728. that *MySQL* expects dates in `YYYY-MM-DD' format; this may be
  16729. different than what you are used to.)
  16730.  
  16731. *name*       *owner*      *species*    *sex*        *birth*      *death*
  16732. Fluffy       Harold       cat          f            1993-02-04   
  16733. Claws        Gwen         cat          m            1994-03-17   
  16734. Buffy        Harold       dog          f            1989-05-13   
  16735. Fang         Benny        dog          m            1990-08-27   
  16736. Bowser       Diane        dog          m            1998-08-31   1995-07-29
  16737. Chirpy       Gwen         bird         f            1998-09-11   
  16738. Whistler     Gwen         bird                      1997-12-09   
  16739. Slim         Benny        snake        m            1996-04-29   
  16740.  
  16741. Because you are beginning with an empty table, an easy way to populate
  16742. it is to create a text file containing a row for each of your animals,
  16743. then load the contents of the file into the table with a single
  16744. statement.
  16745.  
  16746. You could create a text file `pet.txt' containing one record per line,
  16747. with values separated by tabs, and given in the order in which the
  16748. columns were listed in the `CREATE TABLE' statement.  For missing
  16749. values (such as unknown sexes, or death dates for animals that are
  16750. still living), you can use `NULL' values.  To represent these in your
  16751. text file, use `\N'.  For example, the record for Whistler the bird
  16752. would look like this (where the whitespace between values is a single
  16753. tab character):
  16754.  
  16755. `Whistler'  `Gwen'      `bird'      `\N'        `1997-12-09'       `\N'
  16756.  
  16757. To load the text file `pet.txt' into the `pet' table, use this command:
  16758.  
  16759.      mysql> LOAD DATA LOCAL INFILE "pet.txt" INTO TABLE pet;
  16760.  
  16761. You can specify the column value separator and end of line marker
  16762. explicitly in the `LOAD DATA' statement if you wish, but the defaults
  16763. are tab and linefeed.  These are sufficient for the statement to read
  16764. the file `pet.txt' properly.
  16765.  
  16766. When you want to add new records one at a time, the `INSERT' statement
  16767. is useful.  In its simplest form, you supply values for each column, in
  16768. the order in which the columns were listed in the `CREATE TABLE'
  16769. statement.  Suppose Diane gets a new hamster named Puffball.  You could
  16770. add a new record using an `INSERT' statement like this:
  16771.  
  16772.      mysql> INSERT INTO pet
  16773.          -> VALUES ('Puffball','Diane','hamster','f','1999-03-30',NULL);
  16774.  
  16775. Note that string and date values are specified as quoted strings here.
  16776. Also, with `INSERT', you can insert `NULL' directly to represent a
  16777. missing value.  You do not use `\N' like you do with `LOAD DATA'.
  16778.  
  16779. From this example, you should be able to see that there would be a lot
  16780. more typing involved to load your records initially using several
  16781. `INSERT' statements rather than a single `LOAD DATA' statement.
  16782.  
  16783. Retrieving information from a table
  16784. -----------------------------------
  16785.  
  16786. The `SELECT' statement is used to pull information from a table.  The
  16787. general form of the statement is:
  16788.  
  16789.      SELECT what_to_select
  16790.      FROM which_table
  16791.      WHERE conditions_to_satisfy
  16792.  
  16793. `what_to_select' indicates what you want to see.  This can be a list of
  16794. columns, or `*' to indicate "all columns." `which_table' indicates the
  16795. table from which you want to retrieve data.  The `WHERE' clause is
  16796. optional.  If it's present, `conditions_to_satisfy' specifies
  16797. conditions that rows must satisfy to qualify for retrieval.
  16798.  
  16799. Selecting all data
  16800. ..................
  16801.  
  16802. The simplest form of `SELECT' retrieves everything from a table:
  16803.  
  16804.      mysql> SELECT * FROM pet;
  16805.      +----------+--------+---------+------+------------+------------+
  16806.      | name     | owner  | species | sex  | birth      | death      |
  16807.      +----------+--------+---------+------+------------+------------+
  16808.      | Fluffy   | Harold | cat     | f    | 1993-02-04 | NULL       |
  16809.      | Claws    | Gwen   | cat     | m    | 1994-03-17 | NULL       |
  16810.      | Buffy    | Harold | dog     | f    | 1989-05-13 | NULL       |
  16811.      | Fang     | Benny  | dog     | m    | 1990-08-27 | NULL       |
  16812.      | Bowser   | Diane  | dog     | m    | 1998-08-31 | 1995-07-29 |
  16813.      | Chirpy   | Gwen   | bird    | f    | 1998-09-11 | NULL       |
  16814.      | Whistler | Gwen   | bird    | NULL | 1997-12-09 | NULL       |
  16815.      | Slim     | Benny  | snake   | m    | 1996-04-29 | NULL       |
  16816.      | Puffball | Diane  | hamster | f    | 1999-03-30 | NULL       |
  16817.      +----------+--------+---------+------+------------+------------+
  16818.  
  16819. This form of `SELECT' is useful if you want to review your entire table,
  16820. for instance, after you've just loaded it with your initial dataset.
  16821. As it happens, the output just shown reveals an error in your data
  16822. file:  Bowser appears to have been born after he died!  Consulting your
  16823. original pedigree papers, you find that the correct birth year is 1989,
  16824. not 1998.
  16825.  
  16826. There are are least a couple of ways to fix this:
  16827.  
  16828.    * Edit the file `pet.txt' to correct the error, then empty the table
  16829.      and reload it using `DELETE' and `LOAD DATA':
  16830.  
  16831.           mysql> SET AUTOCOMMIT=1;  # Used for quick recreate of the table
  16832.           mysql> DELETE FROM pet;
  16833.           mysql> LOAD DATA LOCAL INFILE "pet.txt" INTO TABLE pet;
  16834.  
  16835.      However, if you do this, you must also re-enter the record for
  16836.      Puffball.
  16837.  
  16838.    * Fix only the erroneous record with an `UPDATE' statement:
  16839.  
  16840.           mysql> UPDATE pet SET birth = "1989-08-31" WHERE name = "Bowser";
  16841.  
  16842. As shown above, it is easy to retrieve an entire table.  But typically
  16843. you don't want to do that, particularly when the table becomes large.
  16844. Instead, you're usually more interested in answering a particular
  16845. question, in which case you specify some constraints on the information
  16846. you want.  Let's look at some selection queries in terms of questions
  16847. about your pets that they answer.
  16848.  
  16849. Selecting particular rows
  16850. .........................
  16851.  
  16852. You can select only particular rows from your table.  For example, if
  16853. you want to verify the change that you made to Bowser's birth date,
  16854. select Bowser's record like this:
  16855.  
  16856.      mysql> SELECT * FROM pet WHERE name = "Bowser";
  16857.      +--------+-------+---------+------+------------+------------+
  16858.      | name   | owner | species | sex  | birth      | death      |
  16859.      +--------+-------+---------+------+------------+------------+
  16860.      | Bowser | Diane | dog     | m    | 1989-08-31 | 1995-07-29 |
  16861.      +--------+-------+---------+------+------------+------------+
  16862.  
  16863. The output confirms that the year is correctly recorded now as 1989,
  16864. not 1998.
  16865.  
  16866. String comparisons are normally case-insensitive, so you can specify the
  16867. name as `"bowser"', `"BOWSER"', etc.  The query result will be the same.
  16868.  
  16869. You can specify conditions on any column, not just `name'.  For example,
  16870. if you want to know which animals were born after 1998, test the `birth'
  16871. column:
  16872.  
  16873.      mysql> SELECT * FROM pet WHERE birth >= "1998-1-1";
  16874.      +----------+-------+---------+------+------------+-------+
  16875.      | name     | owner | species | sex  | birth      | death |
  16876.      +----------+-------+---------+------+------------+-------+
  16877.      | Chirpy   | Gwen  | bird    | f    | 1998-09-11 | NULL  |
  16878.      | Puffball | Diane | hamster | f    | 1999-03-30 | NULL  |
  16879.      +----------+-------+---------+------+------------+-------+
  16880.  
  16881. You can combine conditions, for example, to locate female dogs:
  16882.  
  16883.      mysql> SELECT * FROM pet WHERE species = "dog" AND sex = "f";
  16884.      +-------+--------+---------+------+------------+-------+
  16885.      | name  | owner  | species | sex  | birth      | death |
  16886.      +-------+--------+---------+------+------------+-------+
  16887.      | Buffy | Harold | dog     | f    | 1989-05-13 | NULL  |
  16888.      +-------+--------+---------+------+------------+-------+
  16889.  
  16890. The preceding query uses the `AND' logical operator.  There is also an
  16891. `OR' operator:
  16892.  
  16893.      mysql> SELECT * FROM pet WHERE species = "snake" OR species = "bird";
  16894.      +----------+-------+---------+------+------------+-------+
  16895.      | name     | owner | species | sex  | birth      | death |
  16896.      +----------+-------+---------+------+------------+-------+
  16897.      | Chirpy   | Gwen  | bird    | f    | 1998-09-11 | NULL  |
  16898.      | Whistler | Gwen  | bird    | NULL | 1997-12-09 | NULL  |
  16899.      | Slim     | Benny | snake   | m    | 1996-04-29 | NULL  |
  16900.      +----------+-------+---------+------+------------+-------+
  16901.  
  16902. `AND' and `OR' may be intermixed.  If you do that, it's a good idea to
  16903. use parentheses to indicate how conditions should be grouped:
  16904.  
  16905.      mysql> SELECT * FROM pet WHERE (species = "cat" AND sex = "m")
  16906.          -> OR (species = "dog" AND sex = "f");
  16907.      +-------+--------+---------+------+------------+-------+
  16908.      | name  | owner  | species | sex  | birth      | death |
  16909.      +-------+--------+---------+------+------------+-------+
  16910.      | Claws | Gwen   | cat     | m    | 1994-03-17 | NULL  |
  16911.      | Buffy | Harold | dog     | f    | 1989-05-13 | NULL  |
  16912.      +-------+--------+---------+------+------------+-------+
  16913.  
  16914. Selecting particular columns
  16915. ............................
  16916.  
  16917. If you don't want to see entire rows from your table, just name the
  16918. columns in which you're interested, separated by commas.  For example,
  16919. if you want to know when your animals were born, select the `name' and
  16920. `birth' columns:
  16921.  
  16922.      mysql> SELECT name, birth FROM pet;
  16923.      +----------+------------+
  16924.      | name     | birth      |
  16925.      +----------+------------+
  16926.      | Fluffy   | 1993-02-04 |
  16927.      | Claws    | 1994-03-17 |
  16928.      | Buffy    | 1989-05-13 |
  16929.      | Fang     | 1990-08-27 |
  16930.      | Bowser   | 1989-08-31 |
  16931.      | Chirpy   | 1998-09-11 |
  16932.      | Whistler | 1997-12-09 |
  16933.      | Slim     | 1996-04-29 |
  16934.      | Puffball | 1999-03-30 |
  16935.      +----------+------------+
  16936.  
  16937. To find out who owns pets, use this query:
  16938.  
  16939.      mysql> SELECT owner FROM pet;
  16940.      +--------+
  16941.      | owner  |
  16942.      +--------+
  16943.      | Harold |
  16944.      | Gwen   |
  16945.      | Harold |
  16946.      | Benny  |
  16947.      | Diane  |
  16948.      | Gwen   |
  16949.      | Gwen   |
  16950.      | Benny  |
  16951.      | Diane  |
  16952.      +--------+
  16953.  
  16954. However, notice that the query simply retrieves the `owner' field from
  16955. each record, and some of them appear more than once.  To minimize the
  16956. output, retrieve each unique output record just once by adding the
  16957. keyword `DISTINCT':
  16958.  
  16959.      mysql> SELECT DISTINCT owner FROM pet;
  16960.      +--------+
  16961.      | owner  |
  16962.      +--------+
  16963.      | Benny  |
  16964.      | Diane  |
  16965.      | Gwen   |
  16966.      | Harold |
  16967.      +--------+
  16968.  
  16969. You can use a `WHERE' clause to combine row selection with column
  16970. selection.  For example, to get birth dates for dogs and cats only, use
  16971. this query:
  16972.  
  16973.      mysql> SELECT name, species, birth FROM pet
  16974.          -> WHERE species = "dog" OR species = "cat";
  16975.      +--------+---------+------------+
  16976.      | name   | species | birth      |
  16977.      +--------+---------+------------+
  16978.      | Fluffy | cat     | 1993-02-04 |
  16979.      | Claws  | cat     | 1994-03-17 |
  16980.      | Buffy  | dog     | 1989-05-13 |
  16981.      | Fang   | dog     | 1990-08-27 |
  16982.      | Bowser | dog     | 1989-08-31 |
  16983.      +--------+---------+------------+
  16984.  
  16985. Sorting rows
  16986. ............
  16987.  
  16988. You may have noticed in the preceding examples that the result rows are
  16989. displayed in no particular order.  However, it's often easier to examine
  16990. query output when the rows are sorted in some meaningful way.  To sort a
  16991. result, use an `ORDER BY' clause.
  16992.  
  16993. Here are animal birthdays, sorted by date:
  16994.  
  16995.      mysql> SELECT name, birth FROM pet ORDER BY birth;
  16996.      +----------+------------+
  16997.      | name     | birth      |
  16998.      +----------+------------+
  16999.      | Buffy    | 1989-05-13 |
  17000.      | Bowser   | 1989-08-31 |
  17001.      | Fang     | 1990-08-27 |
  17002.      | Fluffy   | 1993-02-04 |
  17003.      | Claws    | 1994-03-17 |
  17004.      | Slim     | 1996-04-29 |
  17005.      | Whistler | 1997-12-09 |
  17006.      | Chirpy   | 1998-09-11 |
  17007.      | Puffball | 1999-03-30 |
  17008.      +----------+------------+
  17009.  
  17010. To sort in reverse order, add the `DESC' (descending) keyword to the
  17011. name of the column you are sorting by:
  17012.  
  17013.      mysql> SELECT name, birth FROM pet ORDER BY birth DESC;
  17014.      +----------+------------+
  17015.      | name     | birth      |
  17016.      +----------+------------+
  17017.      | Puffball | 1999-03-30 |
  17018.      | Chirpy   | 1998-09-11 |
  17019.      | Whistler | 1997-12-09 |
  17020.      | Slim     | 1996-04-29 |
  17021.      | Claws    | 1994-03-17 |
  17022.      | Fluffy   | 1993-02-04 |
  17023.      | Fang     | 1990-08-27 |
  17024.      | Bowser   | 1989-08-31 |
  17025.      | Buffy    | 1989-05-13 |
  17026.      +----------+------------+
  17027.  
  17028. You can sort on multiple columns.  For example, to sort by type of
  17029. animal, then by birth date within animal type with youngest animals
  17030. first, use the following query:
  17031.  
  17032.      mysql> SELECT name, species, birth FROM pet ORDER BY species, birth DESC;
  17033.      +----------+---------+------------+
  17034.      | name     | species | birth      |
  17035.      +----------+---------+------------+
  17036.      | Chirpy   | bird    | 1998-09-11 |
  17037.      | Whistler | bird    | 1997-12-09 |
  17038.      | Claws    | cat     | 1994-03-17 |
  17039.      | Fluffy   | cat     | 1993-02-04 |
  17040.      | Fang     | dog     | 1990-08-27 |
  17041.      | Bowser   | dog     | 1989-08-31 |
  17042.      | Buffy    | dog     | 1989-05-13 |
  17043.      | Puffball | hamster | 1999-03-30 |
  17044.      | Slim     | snake   | 1996-04-29 |
  17045.      +----------+---------+------------+
  17046.  
  17047. Note that the `DESC' keyword applies only to the column name immediately
  17048. preceding it (`birth'); `species' values are still sorted in ascending
  17049. order.
  17050.  
  17051. Date calculations
  17052. .................
  17053.  
  17054. *MySQL* provides several functions that you can use to perform
  17055. calculations on dates, for example, to calculate ages or extract parts
  17056. of dates.
  17057.  
  17058. To determine how many years old each of your pets is, compute age as the
  17059. difference between the birth date and the current date.  Do this by
  17060. converting the two dates to days, take the difference, and divide by
  17061. 365 (the number of days in a year):
  17062.  
  17063.      mysql> SELECT name, (TO_DAYS(NOW())-TO_DAYS(birth))/365 FROM pet;
  17064.      +----------+-------------------------------------+
  17065.      | name     | (TO_DAYS(NOW())-TO_DAYS(birth))/365 |
  17066.      +----------+-------------------------------------+
  17067.      | Fluffy   |                                6.15 |
  17068.      | Claws    |                                5.04 |
  17069.      | Buffy    |                                9.88 |
  17070.      | Fang     |                                8.59 |
  17071.      | Bowser   |                                9.58 |
  17072.      | Chirpy   |                                0.55 |
  17073.      | Whistler |                                1.30 |
  17074.      | Slim     |                                2.92 |
  17075.      | Puffball |                                0.00 |
  17076.      +----------+-------------------------------------+
  17077.  
  17078. Although the query works, there are some things about it that could be
  17079. improved.  First, the result could be scanned more easily if the rows
  17080. were presented in some order.  Second, the heading for the age column
  17081. isn't very meaningful.
  17082.  
  17083. The first problem can be handled by adding an `ORDER BY name' clause to
  17084. sort the output by name.  To deal with the column heading, provide a
  17085. name for the column so that a different label appears in the output
  17086. (this is called a column alias):
  17087.  
  17088.      mysql> SELECT name, (TO_DAYS(NOW())-TO_DAYS(birth))/365 AS age
  17089.          -> FROM pet ORDER BY name;
  17090.      +----------+------+
  17091.      | name     | age  |
  17092.      +----------+------+
  17093.      | Bowser   | 9.58 |
  17094.      | Buffy    | 9.88 |
  17095.      | Chirpy   | 0.55 |
  17096.      | Claws    | 5.04 |
  17097.      | Fang     | 8.59 |
  17098.      | Fluffy   | 6.15 |
  17099.      | Puffball | 0.00 |
  17100.      | Slim     | 2.92 |
  17101.      | Whistler | 1.30 |
  17102.      +----------+------+
  17103.  
  17104. To sort the output by `age' rather than `name', just use a different
  17105. `ORDER BY' clause:
  17106.  
  17107.      mysql>  SELECT name, (TO_DAYS(NOW())-TO_DAYS(birth))/365 AS age
  17108.          ->  FROM pet ORDER BY age;
  17109.      +----------+------+
  17110.      | name     | age  |
  17111.      +----------+------+
  17112.      | Puffball | 0.00 |
  17113.      | Chirpy   | 0.55 |
  17114.      | Whistler | 1.30 |
  17115.      | Slim     | 2.92 |
  17116.      | Claws    | 5.04 |
  17117.      | Fluffy   | 6.15 |
  17118.      | Fang     | 8.59 |
  17119.      | Bowser   | 9.58 |
  17120.      | Buffy    | 9.88 |
  17121.      +----------+------+
  17122.  
  17123. A similar query can be used to determine age at death for animals that
  17124. have died.  You determine which animals these are by checking whether
  17125. or not the `death' value is `NULL'.  Then, for those with non-`NULL'
  17126. values, compute the difference between the `death' and `birth' values:
  17127.  
  17128.      mysql>  SELECT name, birth, death, (TO_DAYS(death)-TO_DAYS(birth))/365 AS age
  17129.          ->  FROM pet WHERE death IS NOT NULL ORDER BY age;
  17130.      +--------+------------+------------+------+
  17131.      | name   | birth      | death      | age  |
  17132.      +--------+------------+------------+------+
  17133.      | Bowser | 1989-08-31 | 1995-07-29 | 5.91 |
  17134.      +--------+------------+------------+------+
  17135.  
  17136. The query uses `death IS NOT NULL' rather than `death != NULL' because
  17137. `NULL' is a special value.  This is explained later.  *Note Working
  17138. with `NULL': Working with NULL.
  17139.  
  17140. What if you want to know which animals have birthdays next month?  For
  17141. this type of calculation, year and day are irrelevant, you simply want
  17142. to extract the month part of the `birth' column.  *MySQL* provides
  17143. several date-part extraction functions, such as `YEAR()', `MONTH()' and
  17144. `DAYOFMONTH()'.  `MONTH()' is the appropriate function here.  To see
  17145. how it works, run a simple query that displays the value of both
  17146. `birth' and `MONTH(birth)':
  17147.  
  17148.      mysql> SELECT name, birth, MONTH(birth) FROM pet;
  17149.      +----------+------------+--------------+
  17150.      | name     | birth      | MONTH(birth) |
  17151.      +----------+------------+--------------+
  17152.      | Fluffy   | 1993-02-04 |            2 |
  17153.      | Claws    | 1994-03-17 |            3 |
  17154.      | Buffy    | 1989-05-13 |            5 |
  17155.      | Fang     | 1990-08-27 |            8 |
  17156.      | Bowser   | 1989-08-31 |            8 |
  17157.      | Chirpy   | 1998-09-11 |            9 |
  17158.      | Whistler | 1997-12-09 |           12 |
  17159.      | Slim     | 1996-04-29 |            4 |
  17160.      | Puffball | 1999-03-30 |            3 |
  17161.      +----------+------------+--------------+
  17162.  
  17163. Finding animals with birthdays in the upcoming month is easy, too.
  17164. Suppose the current month is April.  Then the month value is `4' and
  17165. you look for animals born in May (month 5) like this:
  17166.  
  17167.      mysql> SELECT name, birth FROM pet WHERE MONTH(birth) = 5;
  17168.      +-------+------------+
  17169.      | name  | birth      |
  17170.      +-------+------------+
  17171.      | Buffy | 1989-05-13 |
  17172.      +-------+------------+
  17173.  
  17174. There is a small complication if the current month is December, of
  17175. course.  You don't just add one to the month number (`12') and look for
  17176. animals born in month 13, because there is no such month.  Instead, you
  17177. look for animals born in January (month 1).
  17178.  
  17179. You can even write the query so that it works no matter what the current
  17180. month is.  That way you don't have to use a particular month number in
  17181. the query.  `DATE_ADD()' allows you to add a time interval to a given
  17182. date.  If you add a month to the value of `NOW()', then extract the
  17183. month part with `MONTH()', the result produces the month in which to
  17184. look for birthdays:
  17185.  
  17186.      mysql> SELECT name, birth FROM pet
  17187.          -> WHERE MONTH(birth) = MONTH(DATE_ADD(NOW(), INTERVAL 1 MONTH));
  17188.  
  17189. A different way to accomplish the same task is to add `1' to get the
  17190. next month after the current one (after using the modulo function
  17191. (`MOD') to "wrap around" the month value to `0' if it is currently
  17192. `12'):
  17193.  
  17194.      mysql> SELECT name, birth FROM pet
  17195.          -> WHERE MONTH(birth) = MOD(MONTH(NOW()), 12) + 1;
  17196.  
  17197. Note that `MONTH' return a number between 1 and 12. And
  17198. `MOD(something,12)' returns a number between 0 and 11. So the addition
  17199. has to be after the `MOD()' oterwise we would go from November (11) to
  17200. January (1).
  17201.  
  17202. Working with `NULL' values
  17203. ..........................
  17204.  
  17205. The `NULL' value can be surprising until you get used to it.
  17206. Conceptually, `NULL' means "missing value" or "unknown value" and it is
  17207. treated somewhat differently than other values.  To test for `NULL',
  17208. you cannot use the arithmetic comparison operators such as `=', `<' or
  17209. `!='.  To demonstrate this for yourself, try the following query:
  17210.  
  17211.      mysql> SELECT 1 = NULL, 1 != NULL, 1 < NULL, 1 > NULL;
  17212.      +----------+-----------+----------+----------+
  17213.      | 1 = NULL | 1 != NULL | 1 < NULL | 1 > NULL |
  17214.      +----------+-----------+----------+----------+
  17215.      |     NULL |      NULL |     NULL |     NULL |
  17216.      +----------+-----------+----------+----------+
  17217.  
  17218. Clearly you get no meaningful results from these comparisons.  Use the
  17219. `IS NULL' and `IS NOT NULL' operators instead:
  17220.  
  17221.      mysql> SELECT 1 IS NULL, 1 IS NOT NULL;
  17222.      +-----------+---------------+
  17223.      | 1 IS NULL | 1 IS NOT NULL |
  17224.      +-----------+---------------+
  17225.      |         0 |             1 |
  17226.      +-----------+---------------+
  17227.  
  17228. In *MySQL*, 0 means false and 1 means true.
  17229.  
  17230. This special treatment of `NULL' is why, in the previous section, it
  17231. was necessary to determine which animals are no longer alive using
  17232. `death IS NOT NULL' instead of `death != NULL'.
  17233.  
  17234. Pattern matching
  17235. ................
  17236.  
  17237. *MySQL* provides standard SQL pattern matching as well as a form of
  17238. pattern matching based on extended regular expressions similar to those
  17239. used by Unix utilities such as `vi', `grep' and `sed'.
  17240.  
  17241. SQL pattern matching allows you to use `_' to match any single
  17242. character, and `%' to match an arbitrary number of characters (including
  17243. zero characters).  In *MySQL*, SQL patterns are case insensitive by
  17244. default.  Some examples are shown below.  Note that you do not use `='
  17245. or `!=' when you use SQL patterns; use the `LIKE' or `NOT LIKE'
  17246. comparison operators instead.
  17247.  
  17248. To find names beginning with `b':
  17249.  
  17250.      mysql> SELECT * FROM pet WHERE name LIKE "b%";
  17251.      +--------+--------+---------+------+------------+------------+
  17252.      | name   | owner  | species | sex  | birth      | death      |
  17253.      +--------+--------+---------+------+------------+------------+
  17254.      | Buffy  | Harold | dog     | f    | 1989-05-13 | NULL       |
  17255.      | Bowser | Diane  | dog     | m    | 1989-08-31 | 1995-07-29 |
  17256.      +--------+--------+---------+------+------------+------------+
  17257.  
  17258. To find names ending with `fy':
  17259.  
  17260.      mysql> SELECT * FROM pet WHERE name LIKE "%fy";
  17261.      +--------+--------+---------+------+------------+-------+
  17262.      | name   | owner  | species | sex  | birth      | death |
  17263.      +--------+--------+---------+------+------------+-------+
  17264.      | Fluffy | Harold | cat     | f    | 1993-02-04 | NULL  |
  17265.      | Buffy  | Harold | dog     | f    | 1989-05-13 | NULL  |
  17266.      +--------+--------+---------+------+------------+-------+
  17267.  
  17268. To find names containing a `w':
  17269.  
  17270.      mysql> SELECT * FROM pet WHERE name LIKE "%w%";
  17271.      +----------+-------+---------+------+------------+------------+
  17272.      | name     | owner | species | sex  | birth      | death      |
  17273.      +----------+-------+---------+------+------------+------------+
  17274.      | Claws    | Gwen  | cat     | m    | 1994-03-17 | NULL       |
  17275.      | Bowser   | Diane | dog     | m    | 1989-08-31 | 1995-07-29 |
  17276.      | Whistler | Gwen  | bird    | NULL | 1997-12-09 | NULL       |
  17277.      +----------+-------+---------+------+------------+------------+
  17278.  
  17279. To find names containing exactly five characters, use the `_' pattern
  17280. character:
  17281.  
  17282.      mysql> SELECT * FROM pet WHERE name LIKE "_____";
  17283.      +-------+--------+---------+------+------------+-------+
  17284.      | name  | owner  | species | sex  | birth      | death |
  17285.      +-------+--------+---------+------+------------+-------+
  17286.      | Claws | Gwen   | cat     | m    | 1994-03-17 | NULL  |
  17287.      | Buffy | Harold | dog     | f    | 1989-05-13 | NULL  |
  17288.      +-------+--------+---------+------+------------+-------+
  17289.  
  17290. The other type of pattern matching provided by *MySQL* uses extended
  17291. regular expressions.  When you test for a match for this type of
  17292. pattern, use the `REGEXP' and `NOT REGEXP' operators (or `RLIKE' and
  17293. `NOT RLIKE', which are synonyms).
  17294.  
  17295. Some characteristics of extended regular expressions are:
  17296.  
  17297.    * `.' matches any single character.
  17298.  
  17299.    * A character class `[...]' matches any character within the
  17300.      brackets.  For example, `[abc]' matches `a', `b' or `c'.  To name a
  17301.      range of characters, use a dash.  `[a-z]' matches any lowercase
  17302.      letter, whereas `[0-9]' matches any digit.
  17303.  
  17304.    * `*' matches zero or more instances of the thing preceding it.  For
  17305.      example, `x*' matches any number of `x' characters, `[0-9]*'
  17306.      matches any number of digits, and `.*' matches any number of
  17307.      anything.
  17308.  
  17309.    * Regular expressions are case sensitive, but you can use a
  17310.      character class to match both lettercases if you wish.  For
  17311.      example, `[aA]' matches lowercase or uppercase `a' and `[a-zA-Z]'
  17312.      matches any letter in either case.
  17313.  
  17314.    * The pattern matches if it occurs anywhere in the value being tested
  17315.      (SQL patterns match only if they match the entire value).
  17316.  
  17317.    * To anchor a pattern so that it must match the beginning or end of
  17318.      the value being tested, use `^' at the beginning or `$' at the end
  17319.      of the pattern.
  17320.  
  17321. To demonstrate how extended regular expressions work, the `LIKE' queries
  17322. shown above are rewritten below to use `REGEXP':
  17323.  
  17324. To find names beginning with `b', use `^' to match the beginning of the
  17325. name and `[bB]' to match either lowercase or uppercase `b':
  17326.  
  17327.      mysql> SELECT * FROM pet WHERE name REGEXP "^[bB]";
  17328.      +--------+--------+---------+------+------------+------------+
  17329.      | name   | owner  | species | sex  | birth      | death      |
  17330.      +--------+--------+---------+------+------------+------------+
  17331.      | Buffy  | Harold | dog     | f    | 1989-05-13 | NULL       |
  17332.      | Bowser | Diane  | dog     | m    | 1989-08-31 | 1995-07-29 |
  17333.      +--------+--------+---------+------+------------+------------+
  17334.  
  17335. To find names ending with `fy', use `$' to match the end of the name:
  17336.  
  17337.      mysql> SELECT * FROM pet WHERE name REGEXP "fy$";
  17338.      +--------+--------+---------+------+------------+-------+
  17339.      | name   | owner  | species | sex  | birth      | death |
  17340.      +--------+--------+---------+------+------------+-------+
  17341.      | Fluffy | Harold | cat     | f    | 1993-02-04 | NULL  |
  17342.      | Buffy  | Harold | dog     | f    | 1989-05-13 | NULL  |
  17343.      +--------+--------+---------+------+------------+-------+
  17344.  
  17345. To find names containing a `w', use `[wW]' to match either lowercase or
  17346. uppercase `w':
  17347.  
  17348.      mysql> SELECT * FROM pet WHERE name REGEXP "[wW]";
  17349.      +----------+-------+---------+------+------------+------------+
  17350.      | name     | owner | species | sex  | birth      | death      |
  17351.      +----------+-------+---------+------+------------+------------+
  17352.      | Claws    | Gwen  | cat     | m    | 1994-03-17 | NULL       |
  17353.      | Bowser   | Diane | dog     | m    | 1989-08-31 | 1995-07-29 |
  17354.      | Whistler | Gwen  | bird    | NULL | 1997-12-09 | NULL       |
  17355.      +----------+-------+---------+------+------------+------------+
  17356.  
  17357. Because a regular expression pattern matches if it occurs anywhere in
  17358. the value, it is not necessary in the previous query to put a wildcard
  17359. on either side of the pattern to get it to match the entire value like
  17360. it would be if you used a SQL pattern.
  17361.  
  17362. To find names containing exactly five characters, use `^' and `$' to
  17363. match the beginning and end of the name, and five instances of `.' in
  17364. between:
  17365.  
  17366.      mysql> SELECT * FROM pet WHERE name REGEXP "^.....$";
  17367.      +-------+--------+---------+------+------------+-------+
  17368.      | name  | owner  | species | sex  | birth      | death |
  17369.      +-------+--------+---------+------+------------+-------+
  17370.      | Claws | Gwen   | cat     | m    | 1994-03-17 | NULL  |
  17371.      | Buffy | Harold | dog     | f    | 1989-05-13 | NULL  |
  17372.      +-------+--------+---------+------+------------+-------+
  17373.  
  17374. You could also write the previous query using the `{n}'
  17375. "repeat-`n'-times" operator:
  17376.  
  17377.      mysql> SELECT * FROM pet WHERE name REGEXP "^.{5}$";
  17378.      +-------+--------+---------+------+------------+-------+
  17379.      | name  | owner  | species | sex  | birth      | death |
  17380.      +-------+--------+---------+------+------------+-------+
  17381.      | Claws | Gwen   | cat     | m    | 1994-03-17 | NULL  |
  17382.      | Buffy | Harold | dog     | f    | 1989-05-13 | NULL  |
  17383.      +-------+--------+---------+------+------------+-------+
  17384.  
  17385. Counting rows
  17386. .............
  17387.  
  17388. Databases are often used to answer the question, "How often does a
  17389. certain type of data occur in a table?"  For example, you might want to
  17390. know how many pets you have, or how many pets each owner has, or you
  17391. might want to perform various kinds of censuses on your animals.
  17392.  
  17393. Counting the total number of animals you have is the same question as
  17394. "How many rows are in the `pet' table?," because there is one record
  17395. per pet.  The `COUNT()' function counts the number of non-`NULL'
  17396. results, so the query to count your animals looks like this:
  17397.  
  17398.      mysql> SELECT COUNT(*) FROM pet;
  17399.      +----------+
  17400.      | COUNT(*) |
  17401.      +----------+
  17402.      |        9 |
  17403.      +----------+
  17404.  
  17405. Earlier, you retrieved the names of the people who owned pets.  You can
  17406. use `COUNT()' if you want to find out how many pets each owner has:
  17407.  
  17408.      mysql> SELECT owner, COUNT(*) FROM pet GROUP BY owner;
  17409.      +--------+----------+
  17410.      | owner  | COUNT(*) |
  17411.      +--------+----------+
  17412.      | Benny  |        2 |
  17413.      | Diane  |        2 |
  17414.      | Gwen   |        3 |
  17415.      | Harold |        2 |
  17416.      +--------+----------+
  17417.  
  17418. Note the use of `GROUP BY' to group together all records for each
  17419. `owner'.  Without it, all you get is an error message:
  17420.  
  17421.      mysql> SELECT owner, COUNT(owner) FROM pet;
  17422.      ERROR 1140 at line 1: Mixing of GROUP columns (MIN(),MAX(),COUNT()...)
  17423.      with no GROUP columns is illegal if there is no GROUP BY clause
  17424.  
  17425. `COUNT()' and `GROUP BY' are useful for characterizing your data in
  17426. various ways.  The following examples show different ways to perform
  17427. animal census operations.
  17428.  
  17429. Number of animals per species:
  17430.  
  17431.      mysql> SELECT species, COUNT(*) FROM pet GROUP BY species;
  17432.      +---------+----------+
  17433.      | species | COUNT(*) |
  17434.      +---------+----------+
  17435.      | bird    |        2 |
  17436.      | cat     |        2 |
  17437.      | dog     |        3 |
  17438.      | hamster |        1 |
  17439.      | snake   |        1 |
  17440.      +---------+----------+
  17441.  
  17442. Number of animals per sex:
  17443.  
  17444.      mysql> SELECT sex, COUNT(*) FROM pet GROUP BY sex;
  17445.      +------+----------+
  17446.      | sex  | COUNT(*) |
  17447.      +------+----------+
  17448.      | NULL |        1 |
  17449.      | f    |        4 |
  17450.      | m    |        4 |
  17451.      +------+----------+
  17452.  
  17453. (In this output, `NULL' indicates "sex unknown.")
  17454.  
  17455. Number of animals per combination of species and sex:
  17456.  
  17457.      mysql> SELECT species, sex, COUNT(*) FROM pet GROUP BY species, sex;
  17458.      +---------+------+----------+
  17459.      | species | sex  | COUNT(*) |
  17460.      +---------+------+----------+
  17461.      | bird    | NULL |        1 |
  17462.      | bird    | f    |        1 |
  17463.      | cat     | f    |        1 |
  17464.      | cat     | m    |        1 |
  17465.      | dog     | f    |        1 |
  17466.      | dog     | m    |        2 |
  17467.      | hamster | f    |        1 |
  17468.      | snake   | m    |        1 |
  17469.      +---------+------+----------+
  17470.  
  17471. You need not retrieve an entire table when you use `COUNT()'.  For
  17472. example, the previous query, when performed just on dogs and cats,
  17473. looks like this:
  17474.  
  17475.      mysql> SELECT species, sex, COUNT(*) FROM pet
  17476.          -> WHERE species = "dog" OR species = "cat"
  17477.          -> GROUP BY species, sex;
  17478.      +---------+------+----------+
  17479.      | species | sex  | COUNT(*) |
  17480.      +---------+------+----------+
  17481.      | cat     | f    |        1 |
  17482.      | cat     | m    |        1 |
  17483.      | dog     | f    |        1 |
  17484.      | dog     | m    |        2 |
  17485.      +---------+------+----------+
  17486.  
  17487. Or, if you wanted the number of animals per sex only for known-sex
  17488. animals:
  17489.  
  17490.      mysql> SELECT species, sex, COUNT(*) FROM pet
  17491.          -> WHERE sex IS NOT NULL
  17492.          -> GROUP BY species, sex;
  17493.      +---------+------+----------+
  17494.      | species | sex  | COUNT(*) |
  17495.      +---------+------+----------+
  17496.      | bird    | f    |        1 |
  17497.      | cat     | f    |        1 |
  17498.      | cat     | m    |        1 |
  17499.      | dog     | f    |        1 |
  17500.      | dog     | m    |        2 |
  17501.      | hamster | f    |        1 |
  17502.      | snake   | m    |        1 |
  17503.      +---------+------+----------+
  17504.  
  17505. Using more than one table
  17506. -------------------------
  17507.  
  17508. The `pet' table keeps track of which pets you have.  If you want to
  17509. record other information about them, such as events in their lives like
  17510. visits to the vet or when litters are born, you need another table.
  17511. What should this table look like?
  17512.  
  17513.    * It needs to contain the pet name so you know which animal each
  17514.      event pertains to.
  17515.  
  17516.    * It needs a date so you know when the event occurred.
  17517.  
  17518.    * It needs a field to describe the event.
  17519.  
  17520.    * If you want to be able to categorize events, it would be useful to
  17521.      have an event type field.
  17522.  
  17523. Given these considerations, the `CREATE TABLE' statement for the
  17524. `event' table might look like this:
  17525.  
  17526.      mysql> CREATE TABLE event (name VARCHAR(20), date DATE,
  17527.          -> type VARCHAR(15), remark VARCHAR(255));
  17528.  
  17529. As with the `pet' table, it's easiest to load the initial records by
  17530. creating a tab-delimited text file containing the information:
  17531.  
  17532. Fluffy      1995-05-15  litter      4 kittens, 3 female, 1 male
  17533. Buffy       1993-06-23  litter      5 puppies, 2 female, 3 male
  17534. Buffy       1994-06-19  litter      3 puppies, 3 female
  17535. Chirpy      1999-03-21  vet         needed beak straightened
  17536. Slim        1997-08-03  vet         broken rib
  17537. Bowser      1991-10-12  kennel      
  17538. Fang        1991-10-12  kennel      
  17539. Fang        1998-08-28  birthday    Gave him a new chew toy
  17540. Claws       1998-03-17  birthday    Gave him a new flea collar
  17541. Whistler    1998-12-09  birthday    First birthday
  17542.  
  17543. Load the records like this:
  17544.  
  17545.      mysql> LOAD DATA LOCAL INFILE "event.txt" INTO TABLE event;
  17546.  
  17547. Based on what you've learned from the queries you've run on the `pet'
  17548. table, you should be able to perform retrievals on the records in the
  17549. `event' table; the principles are the same.  But when is the `event'
  17550. table by itself insufficient to answer questions you might ask?
  17551.  
  17552. Suppose you want to find out the ages of each pet when they had their
  17553. litters.  The `event' table indicates when this occurred, but to
  17554. calculate age of the mother, you need her birth date.  Because that is
  17555. stored in the `pet' table, you need both tables for the query:
  17556.  
  17557.      mysql> SELECT pet.name, (TO_DAYS(date) - TO_DAYS(birth))/365 AS age, remark
  17558.          -> FROM pet, event
  17559.          -> WHERE pet.name = event.name AND type = "litter";
  17560.      +--------+------+-----------------------------+
  17561.      | name   | age  | remark                      |
  17562.      +--------+------+-----------------------------+
  17563.      | Fluffy | 2.27 | 4 kittens, 3 female, 1 male |
  17564.      | Buffy  | 4.12 | 5 puppies, 2 female, 3 male |
  17565.      | Buffy  | 5.10 | 3 puppies, 3 female         |
  17566.      +--------+------+-----------------------------+
  17567.  
  17568. There are several things to note about this query:
  17569.  
  17570.    * The `FROM' clause lists two tables because the query needs to pull
  17571.      information from both of them.
  17572.  
  17573.    * When combining (joining) information from multiple tables, you
  17574.      need to specify how records in one table can be matched to records
  17575.      in the other.  This is easy because they both have a `name'
  17576.      column.  The query uses `WHERE' clause to match up records in the
  17577.      two tables based on the `name' values.
  17578.  
  17579.    * Because the `name' column occurs in both tables, you must be
  17580.      specific about which table you mean when referring to the column.
  17581.      This is done by prepending the table name to the column name.
  17582.  
  17583. You need not have two different tables to perform a join.  Sometimes it
  17584. is useful to join a table to itself, if you want to compare records in
  17585. a table to other records in that same table.  For example, to find
  17586. breeding pairs among your pets, you can join the `pet' table with
  17587. itself to pair up males and females of like species:
  17588.  
  17589.      mysql> SELECT p1.name, p1.sex, p2.name, p2.sex, p1.species
  17590.          -> FROM pet AS p1, pet AS p2
  17591.          -> WHERE p1.species = p2.species AND p1.sex = "f" AND p2.sex = "m";
  17592.      +--------+------+--------+------+---------+
  17593.      | name   | sex  | name   | sex  | species |
  17594.      +--------+------+--------+------+---------+
  17595.      | Fluffy | f    | Claws  | m    | cat     |
  17596.      | Buffy  | f    | Fang   | m    | dog     |
  17597.      | Buffy  | f    | Bowser | m    | dog     |
  17598.      +--------+------+--------+------+---------+
  17599.  
  17600. In this query, we specify aliases for the table name in order to be able
  17601. to refer to the columns and keep straight which instance of the table
  17602. each column reference is associated with.
  17603.  
  17604. Getting information about databases and tables
  17605. ==============================================
  17606.  
  17607. What if you forget the name of a database or table, or what the
  17608. structure of a given table is (e.g., what its columns are called)?
  17609. *MySQL* addresses this problem through several statements that provide
  17610. information about the databases and tables it supports.
  17611.  
  17612. You have already seen `SHOW DATABASES', which lists the databases
  17613. managed by the server.  To find out which database is currently
  17614. selected, use the `DATABASE()' function:
  17615.  
  17616.      mysql> SELECT DATABASE();
  17617.      +------------+
  17618.      | DATABASE() |
  17619.      +------------+
  17620.      | menagerie  |
  17621.      +------------+
  17622.  
  17623. If you haven't selected any database yet, the result is blank.
  17624.  
  17625. To find out what tables the current database contains (for example, when
  17626. you're not sure about the name of a table), use this command:
  17627.  
  17628.      mysql> SHOW TABLES;
  17629.      +---------------------+
  17630.      | Tables in menagerie |
  17631.      +---------------------+
  17632.      | event               |
  17633.      | pet                 |
  17634.      +---------------------+
  17635.  
  17636. If you want to find out about the structure of a table, the `DESCRIBE'
  17637. command is useful; it displays information about each of a table's
  17638. columns:
  17639.  
  17640.      mysql> DESCRIBE pet;
  17641.      +---------+-------------+------+-----+---------+-------+
  17642.      | Field   | Type        | Null | Key | Default | Extra |
  17643.      +---------+-------------+------+-----+---------+-------+
  17644.      | name    | varchar(20) | YES  |     | NULL    |       |
  17645.      | owner   | varchar(20) | YES  |     | NULL    |       |
  17646.      | species | varchar(20) | YES  |     | NULL    |       |
  17647.      | sex     | char(1)     | YES  |     | NULL    |       |
  17648.      | birth   | date        | YES  |     | NULL    |       |
  17649.      | death   | date        | YES  |     | NULL    |       |
  17650.      +---------+-------------+------+-----+---------+-------+
  17651.  
  17652. `Field' indicates the column name, `Type' is the data type for the
  17653. column, `Null' indicates whether or not the column can contain `NULL'
  17654. values, `Key' indicates whether or not the column is indexed and
  17655. `Default' specifies the column's default value.
  17656.  
  17657. If you have indexes on a table, `SHOW INDEX FROM tbl_name' produces
  17658. information about them.
  17659.  
  17660. Using `mysql' in batch mode
  17661. ===========================
  17662.  
  17663. In the previous sections, you used `mysql' interactively to enter
  17664. queries and view the results.  You can also run `mysql' in batch mode.
  17665. To do this, put the commands you want to run in a file, then tell
  17666. `mysql' to read its input from the file:
  17667.  
  17668.      shell> mysql < batch-file
  17669.  
  17670. If you need to specify connection parameters on the command line, the
  17671. command might look like this:
  17672.  
  17673.      shell> mysql -h host -u user -p < batch-file
  17674.      Enter password: ********
  17675.  
  17676. When you use `mysql' this way, you are creating a script file, then
  17677. executing the script.
  17678.  
  17679. Why use a script?  Here are a few reasons:
  17680.  
  17681.    * If you run a query repeatedly (say, every day or every week),
  17682.      making it a script allows you to avoid retyping it each time you
  17683.      execute it.
  17684.  
  17685.    * You can generate new queries from existing ones that are similar
  17686.      by copying and editing script files.
  17687.  
  17688.    * Batch mode can also be useful while you're developing a query,
  17689.      particularly for multiple-line commands or multiple-statement
  17690.      sequences of commands.  If you make a mistake, you don't have to
  17691.      retype everything.  Just edit your script to correct the error,
  17692.      then tell `mysql' to execute it again.
  17693.  
  17694.    * If you have a query that produces a lot of output, you can run the
  17695.      output through a pager rather than watching it scroll off the top
  17696.      of your screen:
  17697.  
  17698.           shell> mysql < batch-file | more
  17699.  
  17700.    * You can catch the output in a file for further processing:
  17701.  
  17702.           shell> mysql < batch-file > mysql.out
  17703.  
  17704.    * You can distribute your script to other people so they can run the
  17705.      commands, too.
  17706.  
  17707.    * Some situations do not allow for interactive use, for example,
  17708.      when you run a query from a `cron' job.  In this case, you must
  17709.      use batch mode.
  17710.  
  17711. The default output format is different (more concise) when you run
  17712. `mysql' in batch mode than when you use it interactively.  For example,
  17713. the output of `SELECT DISTINCT species FROM pet' looks like this when
  17714. run interactively:
  17715.  
  17716.      +---------+
  17717.      | species |
  17718.      +---------+
  17719.      | bird    |
  17720.      | cat     |
  17721.      | dog     |
  17722.      | hamster |
  17723.      | snake   |
  17724.      +---------+
  17725.  
  17726. But like this when run in batch mode:
  17727.  
  17728.      species
  17729.      bird
  17730.      cat
  17731.      dog
  17732.      hamster
  17733.      snake
  17734.  
  17735. If you want to get the interactive output format in batch mode, use
  17736. `mysql -t'.  To echo to the output the commands that are executed, use
  17737. `mysql -vvv'.
  17738.  
  17739. Queries from twin project
  17740. =========================
  17741.  
  17742. At Analytikerna and Lentus, we have been doing the systems and field
  17743. work for a big research project. This project is a collaboration
  17744. between the Institute of Environmental Medicine at Karolinska
  17745. Institutet Stockholm and the Section on Clinical Research in Aging and
  17746. Psychology at the University of Southern California.
  17747.  
  17748. The project involves a screening part where all twins in Sweden older
  17749. than 65 years are interviewed by telephone. Twins who meet certain
  17750. criteria are passed on to the next stage. In this latter stage, twins
  17751. who want to participate are visited by a doctor/nurse team. Some of the
  17752. examinations include physical and neuropsychological examination,
  17753. laboratory testing, neuroimaging, psychological status assessment, and
  17754. family history collection. In addition, data are collected on medical
  17755. and environmental risk factors.
  17756.  
  17757. More information about Twin studies can be found at:
  17758.  
  17759.      <http://www.imm.ki.se/TWIN/TWINUKW.HTM>
  17760.  
  17761. The latter part of the project is administered with a web interface
  17762. written using Perl and *MySQL*.
  17763.  
  17764. Each night all data from the interviews are moved into a *MySQL*
  17765. database.
  17766.  
  17767. Find all non-distributed twins
  17768. ------------------------------
  17769.  
  17770. The following query is used to determine who goes into the second part
  17771. of the project:
  17772.  
  17773.      select
  17774.              concat(p1.id, p1.tvab) + 0 as tvid,
  17775.              concat(p1.christian_name, " ", p1.surname) as Name,
  17776.              p1.postal_code as Code,
  17777.              p1.city as City,
  17778.              pg.abrev as Area,
  17779.              if(td.participation = "Aborted", "A", " ") as A,
  17780.              p1.dead as dead1,
  17781.              l.event as event1,
  17782.              td.suspect as tsuspect1,
  17783.              id.suspect as isuspect1,
  17784.              td.severe as tsevere1,
  17785.              id.severe as isevere1,
  17786.              p2.dead as dead2,
  17787.              l2.event as event2,
  17788.              h2.nurse as nurse2,
  17789.              h2.doctor as doctor2,
  17790.              td2.suspect as tsuspect2,
  17791.              id2.suspect as isuspect2,
  17792.              td2.severe as tsevere2,
  17793.              id2.severe as isevere2,
  17794.              l.finish_date
  17795.      from
  17796.              twin_project as tp
  17797.              /* For Twin 1 */
  17798.              left join twin_data as td on tp.id = td.id and tp.tvab = td.tvab
  17799.              left join informant_data as id on tp.id = id.id and tp.tvab = id.tvab
  17800.              left join harmony as h on tp.id = h.id and tp.tvab = h.tvab
  17801.              left join lentus as l on tp.id = l.id and tp.tvab = l.tvab
  17802.              /* For Twin 2 */
  17803.              left join twin_data as td2 on p2.id = td2.id and p2.tvab = td2.tvab
  17804.              left join informant_data as id2 on p2.id = id2.id and p2.tvab = id2.tvab
  17805.              left join harmony as h2 on p2.id = h2.id and p2.tvab = h2.tvab
  17806.              left join lentus as l2 on p2.id = l2.id and p2.tvab = l2.tvab,
  17807.              person_data as p1,
  17808.              person_data as p2,
  17809.              postal_groups as pg
  17810.      where
  17811.              /* p1 gets main twin and p2 gets his/her twin. */
  17812.              /* ptvab is a field inverted from tvab */
  17813.              p1.id = tp.id and p1.tvab = tp.tvab and
  17814.              p2.id = p1.id and p2.ptvab = p1.tvab and
  17815.              /* Just the sceening survey */
  17816.              tp.survey_no = 5 and
  17817.              /* Skip if partner died before 65 but allow emigration (dead=9) */
  17818.              (p2.dead = 0 or p2.dead = 9 or
  17819.               (p2.dead = 1 and
  17820.                (p2.death_date = 0 or
  17821.                 (((to_days(p2.death_date) - to_days(p2.birthday)) / 365)
  17822.                  >= 65))))
  17823.              and
  17824.              (
  17825.              /* Twin is suspect */
  17826.              (td.future_contact = 'Yes' and td.suspect = 2) or
  17827.              /* Twin is suspect - Informant is Blessed */
  17828.              (td.future_contact = 'Yes' and td.suspect = 1 and id.suspect = 1) or
  17829.              /* No twin - Informant is Blessed */
  17830.              (ISNULL(td.suspect) and id.suspect = 1 and id.future_contact = 'Yes') or
  17831.              /* Twin broken off - Informant is Blessed */
  17832.              (td.participation = 'Aborted'
  17833.               and id.suspect = 1 and id.future_contact = 'Yes') or
  17834.              /* Twin broken off - No inform - Have partner */
  17835.              (td.participation = 'Aborted' and ISNULL(id.suspect) and p2.dead = 0))
  17836.              and
  17837.              l.event = 'Finished'
  17838.              /* Get at area code */
  17839.              and substring(p1.postal_code, 1, 2) = pg.code
  17840.              /* Not already distributed */
  17841.              and (h.nurse is NULL or h.nurse=00 or h.doctor=00)
  17842.              /* Has not refused or been aborted */
  17843.              and not (h.status = 'Refused' or h.status = 'Aborted'
  17844.              or h.status = 'Died' or h.status = 'Other')
  17845.      order by
  17846.              tvid;
  17847.  
  17848. Some explanations:
  17849. `concat(p1.id, p1.tvab) + 0 as tvid'
  17850.      We want to sort on the concatenated `id' and `tvab' in numerical
  17851.      order. Adding `0' to the result causes *MySQL* to treat the result
  17852.      as a number.
  17853.  
  17854. column `id'
  17855.      This identifies a pair of twins. It is a key in all tables.
  17856.  
  17857. column `tvab'
  17858.      This identifies a twin in a pair. It has a value of `1' or `2'.
  17859.  
  17860. column `ptvab'
  17861.      This is an inverse of `tvab'. When `tvab' is `1' this is `2', and
  17862.      vice versa. It exists to save typing and to make it easier for
  17863.      *MySQL* to optimize the query.
  17864.  
  17865. This query demonstrates, among other things, how to do lookups on a
  17866. table from the same table with a join (`p1' and `p2'). In the example,
  17867. this is used to check whether a twin's partner died before the age of
  17868. 65. If so, the row is not returned.
  17869.  
  17870. All of the above exist in all tables with twin-related information. We
  17871. have a key on both `id,tvab' (all tables) and `id,ptvab'
  17872. (`person_data') to make queries faster.
  17873.  
  17874. On our production machine (A 200MHz UltraSPARC), this query returns
  17875. about 150-200 rows and takes less than one second.
  17876.  
  17877. The current number of records in the tables used above:
  17878. *Table*                *Rows*
  17879. `person_data'          71074
  17880. `lentus'               5291
  17881. `twin_project'         5286
  17882. `twin_data'            2012
  17883. `informant_data'       663
  17884. `harmony'              381
  17885. `postal_groups'        100
  17886.  
  17887. Show a table on twin pair status
  17888. --------------------------------
  17889.  
  17890. Each interview ends with a status code called `event'. The query shown
  17891. below is used to display a table over all twin pairs combined by event.
  17892. This indicates in how many pairs both twins are finished, in how many
  17893. pairs one twin is finished and the other refused, and so on.
  17894.  
  17895.      select
  17896.              t1.event,
  17897.              t2.event,
  17898.              count(*)
  17899.      from
  17900.              lentus as t1,
  17901.              lentus as t2,
  17902.              twin_project as tp
  17903.      where
  17904.              /* We are looking at one pair at a time */
  17905.              t1.id = tp.id
  17906.              and t1.tvab=tp.tvab
  17907.              and t1.id = t2.id
  17908.              /* Just the sceening survey */
  17909.              and tp.survey_no = 5
  17910.              /* This makes each pair only appear once */
  17911.              and t1.tvab='1' and t2.tvab='2'
  17912.      group by
  17913.              t1.event, t2.event;
  17914.  
  17915. MySQL server functions
  17916. **********************
  17917.  
  17918. What languages are supported by MySQL?
  17919. ======================================
  17920.  
  17921. `mysqld' can issue error messages in the following languages: Czech,
  17922. Dutch, English (the default), Estonia, French, German, Hungarian,
  17923. Italian, Norwegian, Norwegian-ny, Polish, Portuguese, Spanish and
  17924. Swedish.
  17925.  
  17926. To start `mysqld' with a particular language, use either the
  17927. `--language=lang' or `-L lang' options. For example:
  17928.  
  17929.      shell> mysqld --language=swedish
  17930.  
  17931. or:
  17932.  
  17933.      shell> mysqld --language=/usr/local/share/swedish
  17934.  
  17935. Note that all language names are specified in lowercase.
  17936.  
  17937. The language files are located (by default) in
  17938. `MYSQL_BASE_DIR/share/LANGUAGE/'.
  17939.  
  17940. To update the error message file, you should edit the `errmsg.txt' file
  17941. and execute the following command to generate the `errmsg.sys' file:
  17942.  
  17943.      shell> comp_err errmsg.txt errmsg.sys
  17944.  
  17945. If you upgrade to a newer version of *MySQL*, remember to repeat your
  17946. changes with the new `errmsg.txt' file.
  17947.  
  17948. The character set used for data and sorting
  17949. -------------------------------------------
  17950.  
  17951. By default, *MySQL* uses the ISO-8859-1 (Latin1) character set. This is
  17952. the character set used in the USA and western Europe.
  17953.  
  17954. The character set determines what characters are allowed in names and
  17955. how things are sorted by the `ORDER BY' and `GROUP BY' clauses of the
  17956. `SELECT' statement.
  17957.  
  17958. You can change the character set with the `--default-character-set'
  17959. option when you start the server.  The character sets available depend
  17960. on the `--with-charset=charset' option to `configure', and the
  17961. character set configuration files listed in `SHAREDIR/charsets/Index'.
  17962. *Note Quick install::.
  17963.  
  17964. When a client connects to a *MySQL* server, the server sends the
  17965. default character set in use to the client.  The client will switch to
  17966. use this character set for this connection.
  17967.  
  17968. One should use `mysql_real_escape_string()' when escaping strings for a
  17969. SQL query.  `mysql_real_escape_string()' is identical to the old
  17970. `mysql_escape_string()' function, except that it takes the MYSQL
  17971. connection handle as the first parameter.
  17972.  
  17973. If the client is compiled with different paths than where the server is
  17974. installed and the user that configured *MySQL* didn't included all
  17975. character sets in the *MySQL* binary one must specify for the client
  17976. where it can find the additional character sets it will need if the
  17977. server runs with a different character set than the client.
  17978.  
  17979. On can specify this by putting in a *MySQL* option file:
  17980.  
  17981.      [client]
  17982.      default-set-dir=/usr/local/mysql/share/mysql/charsets
  17983.  
  17984. where the path points to where the dynamic *MySQL* character sets are
  17985. stored.
  17986.  
  17987. One can force the client to use specific character set by specifying:
  17988.  
  17989.      [client]
  17990.      default-character-set=character-set-name
  17991.  
  17992. but normally this is never needed.
  17993.  
  17994. To add another character set to *MySQL*, use the following procedure:
  17995.  
  17996. Adding a new character set
  17997. --------------------------
  17998.  
  17999.   1. Choose a name for the character set, denoted `MYSET' below.
  18000.  
  18001.   2. Decide if the set is simple or complex.  If the character set does
  18002.      not need to use special string collating routines for sorting, and
  18003.      does not need mulit-byte character support, it is simple.  If it
  18004.      needs either of those features, it is complex.
  18005.  
  18006.   3. If the character set is simple, then create the file
  18007.      `sql/share/charsets/MYSET.conf', and add MYSET the
  18008.      `sql/share/charsets/Index' file.  Read the
  18009.      `sql/share/charsets/README' for more instructions.
  18010.  
  18011.   4. Add the character set name to the `CHARSETS_AVAILABLE' and
  18012.      `COMPILED_CHARSETS' lists in `configure.in'.
  18013.  
  18014.   5. Reconfigure, recompile and test.
  18015.  
  18016.   6. If the character set is complex, create the file
  18017.      `strings/ctype-MYSET.c' in the *MySQL* source distribution.
  18018.  
  18019.   7. Add MYSET to the end of the `sql/share/charsets/Index' file.  Take
  18020.      note of its position in the file - this is its character set
  18021.      number, denoted `MYNUMBER' below.
  18022.  
  18023.   8. Look at one of the existing `ctype-*.c' files to see what needs to
  18024.      be defined. Note that the arrays in your file must have names like
  18025.      `ctype_MYSET', `to_lower_MYSET' and so on.
  18026.  
  18027.      Near the top of the file, place a special comment like this:
  18028.  
  18029.           /*
  18030.            * This comment is parsed by configure to create ctype.c,
  18031.            * so don't change it unless you know what you are doing.
  18032.            *
  18033.            * .configure. number_MYSET=MYNUMBER
  18034.            * .configure. strxfrm_multiply_MYSET=N
  18035.            * .configure. mbmaxlen_MYSET=N
  18036.            */
  18037.  
  18038.      The `configure' program uses this comment to include the character
  18039.      set into the *MySQL* library automatically.
  18040.  
  18041.      The strxfrm_multiply and mbmaxlen lines will be explained in the
  18042.      following sections.  Only include them if you the string collating
  18043.      functions or the multi-byte character set functions, respectively.
  18044.  
  18045.      `to_lower[]' and `to_upper[]' are simple arrays that hold the
  18046.      lowercase and uppercase characters corresponding to each member of
  18047.      the character set.  For example:
  18048.  
  18049.           to_lower['A'] should contain 'a'
  18050.           to_upper['a'] should contain 'A'
  18051.  
  18052.      `sort_order[]' is a map indicating how characters should be
  18053.      ordered for comparison and sorting purposes.  For many character
  18054.      sets, this is the same as `to_upper[]' (which means sorting will
  18055.      be case insensitive).  *MySQL* will sort characters based on the
  18056.      value of `sort_order[character]'.  For more complicated sorting
  18057.      rules, see the discussion of string collating below.
  18058.  
  18059.      `ctype[]' is an array of bit values, with one element for one
  18060.      character.  (Note that `to_lower[]', `to_upper[]' and
  18061.      `sort_order[]' are indexed by character value, but `ctype[]' is
  18062.      indexed by character value + 1.  This is an old legacy to be able
  18063.      to handle EOF.)  You can find the following bitmask definitions in
  18064.      `m_ctype.h':
  18065.  
  18066.           #define _U      01      /* Upper case */
  18067.           #define _L      02      /* Lower case */
  18068.           #define _N      04      /* Numeral (digit) */
  18069.           #define _S      010     /* Spacing character */
  18070.           #define _P      020     /* Punctuation */
  18071.           #define _C      040     /* Control character */
  18072.           #define _B      0100    /* Blank */
  18073.           #define _X      0200    /* heXadecimal digit */
  18074.  
  18075.      The `ctype[]' entry for each character should be the union of the
  18076.      applicable bitmask values that describe the character.  For
  18077.      example, `'A'' is an uppercase character (`_U') as well as a
  18078.      hexadecimal digit (`_X'), so `ctype['A'+1]' should contain the
  18079.      value:
  18080.           _U + _X = 01 + 0200 = 0201
  18081.  
  18082.   9. Add support for the string collating or multi-byte features
  18083.      needed, as described in the following sections.
  18084.  
  18085.  10. Add the character set name to the `CHARSETS_AVAILABLE' and
  18086.      `COMPILED_CHARSETS' lists in `configure.in'.
  18087.  
  18088.  11. Reconfigure, recompile and test.
  18089.  
  18090. String collating support
  18091. ------------------------
  18092.  
  18093. If the sorting rules for your language are too complex to be handled
  18094. with the simple `sort_order[]' table, you need to use the string
  18095. collating functions.
  18096.  
  18097. Right now the best documentation on this is the character sets that are
  18098. already implemented.  Look at the big5, czech, gbk, sjis and tis160
  18099. character sets for examples.
  18100.  
  18101. You must specify the `strxfrm_multiply_MYSET=N' value in the special
  18102. comment at the top of the file.  `N' should be set to the maximum ratio
  18103. the strings may grow during my_strxfrm_MYSET (it must be a positive
  18104. integer).
  18105.  
  18106. Multi-byte character support
  18107. ----------------------------
  18108.  
  18109. If your character set includes multi-byte characters, you need to use
  18110. the multi-byte character functions.
  18111.  
  18112. Right now the best documentation on this is the character sets that are
  18113. already implemented.  Look at the euc_kr, gb2312, gbk, sjis and ujis
  18114. character sets for examples.
  18115.  
  18116. You must specify the `mbmaxlen_MYSET=N' value in the special comment at
  18117. the top of the file.  `N' should be set to the size in bytes of the
  18118. largest character in the set.
  18119.  
  18120. How big MySQL tables can be
  18121. ===========================
  18122.  
  18123. *MySQL* 3.22 has a 4G limit on table size. With the new `MyISAM' in
  18124. *MySQL* 3.23 the maximum table size is pushed up to 8 million terabytes
  18125. (2 ^ 63 bytes).
  18126.  
  18127. Note however that operating systems have their own file size limits.
  18128. Here are some examples:
  18129.  
  18130. Linux-Intel                                 2G (or 4G with reiserfs)
  18131. Linux-Alpha                                 8T (?)
  18132. Solaris 2.5.1                               2G (possible 4G with patch)
  18133. Solaris 2.6                                 4G
  18134. Solaris 2.7 Intel                           4G
  18135. Solaris 2.7 ULTRA-SPARC                     8T (?)
  18136.  
  18137. This means that the table size for *MySQL* is normally limited by the
  18138. operating system.
  18139.  
  18140. By default, *MySQL* tables have a maximum size of about 4G.  You can
  18141. check the maximum table size for a table with the `SHOW TABLE STATUS'
  18142. command or with the `myisamchk -dv table_name'.  *Note SHOW::.
  18143.  
  18144. If you need bigger tables than 4G (and your operating system supports
  18145. this), you should set the `AVG_ROW_LENGTH' and `MAX_ROWS' parameter
  18146. when you create your table.  *Note CREATE TABLE::.  You can also set
  18147. these later with `ALTER TABLE'. *Note ALTER TABLE::.
  18148.  
  18149. If you need to have bigger tables than 2G / 4G
  18150.  
  18151. If your big table is going to be read-only, you could use `myisampack'
  18152. to merge and compress many tables to one.  `myisampack' usually
  18153. compresses a table by at least 50%, so you can have, in effect, much
  18154. bigger tables.  *Note `myisampack': myisampack.
  18155.  
  18156. Another solution can be the included MERGE library, which allows you to
  18157. handle a collection of identical tables as one.  (Identical in this case
  18158. means that all tables are created with identical column information.)
  18159. Currently MERGE can only be used to scan a collection of tables because
  18160. it doesn't support indexes. We will add indexes to this in the near
  18161. future.
  18162.  
  18163. Replication in MySQL
  18164. ********************
  18165.  
  18166. Introduction
  18167. ============
  18168.  
  18169. One way replication can be used both to increase robustness and speed.
  18170. For robustness you have two systems and switch to the backup if you
  18171. have problems with the master. The extra speed is achieved by sending a
  18172. part of the non-updating queries to the replica server. Of course this
  18173. only works if non-updating queries dominate, but that is the normal
  18174. case.
  18175.  
  18176. Starting in 3.23.15, *MySQL* supports one-way replication internally.
  18177. One server acts as the master, while the other acts as the slave. Note
  18178. that one server could play the roles of master in one pair and slave in
  18179. the other. The master server keeps a binary log of updates and an index
  18180. file to binary logs to keep track of log rotation.  The slave upon
  18181. connecting informs the master where it left off sinse the last
  18182. successfully propogated update, catches up on the updates, and then
  18183. blocks and waits for the master to notify it of the new updates.
  18184.  
  18185. Replication Implementation Overview
  18186. ===================================
  18187.  
  18188. *MySQL* internal replication uses the master-slave approach. One server
  18189. is designated as the master, while the other ( or others) as slave(s).
  18190. The master keeps a binary log of updates. The slave connects to the
  18191. master, catches up on the missed updates, and then starts receiving
  18192. updates immediately as they come to the master. If the connection is
  18193. lost, the slave will reconnect. If the master goes down, the slave will
  18194. keep trying to connect every `master-connect-retry' seconds until the
  18195. master comes back up and the connection can be established. The slave
  18196. keeps track of where it left off in the replication process, so it can
  18197. use the info in the case it goes down and gets restarted later.
  18198.  
  18199. HOWTO
  18200. =====
  18201.  
  18202. Below is a quick HOWTO on how to set up replication on your current
  18203. system:
  18204.  
  18205.    * Upgrade both slave and master to 3.23.15 or higher. We recommend
  18206.      that you use the latest 3.23 version on both the slave and the
  18207.      master. While 3.23 is in beta, the versions may be not backwards
  18208.      compatible. In addition, the newer version will fix some bugs and
  18209.      add new features.
  18210.  
  18211.    * Set up special replication user(s) on the master with the `FILE'
  18212.      privilege and permission to connect from all the slaves. If the
  18213.      user is only doing replication, you don't need to grant him other
  18214.      privileges.
  18215.  
  18216.    * Take a snapshot of all the tables/databases on the master that
  18217.      could possibly be involved in the update queries before taking the
  18218.      next step
  18219.  
  18220.    * In `my.cnf' on the master add `log-bin' and restart it. Make sure
  18221.      there are no important updates to the master between the time you
  18222.      have taken the snapshot and the time master is restarted with
  18223.      `log-bin' option
  18224.  
  18225.    * Load the snapshot of the master to all the slaves
  18226.  
  18227.    * Add the following to `my.cnf' on the slave(s):
  18228.  
  18229.           master-host=<hostname of the master>
  18230.           master-user=<replication user name>
  18231.           master-password=<replication user password>
  18232.  
  18233.      replacting the values in <> with what is relevant to your system.
  18234.  
  18235.    * Restart the slave(s)
  18236.  
  18237.  
  18238. After you have done the above, the master and the slave(s) should be in
  18239. sync.
  18240.  
  18241. Replication Features
  18242. ====================
  18243.  
  18244. Below is an explanation of what is supported and what is not:
  18245.  
  18246.    * Replication will be done correctly with `AUTO_INCREMENT',
  18247.      `LAST_INSERT_ID', and `TIMESTAMP' values
  18248.  
  18249.    * `LOAD DATA INFILE' will be handled properly as long as the file
  18250.      still resides on the master server at the time of update
  18251.      propogation. `LOAD LOCAL DATA INFILE' will be skipped.
  18252.  
  18253.    * Update queries that use user variables are not replication-safe
  18254.      (yet)
  18255.  
  18256.    * If the query on the slave gets an error, the slave thread will
  18257.      terminate, and a message will appear in `.err' file. You should
  18258.      then connect to the slave manually, fix the cause of the error
  18259.      (eg. non-existent table), and then run `SLAVE START' sql command (
  18260.      available starting in 3.23.16, in 3.23.15 you will have to restart
  18261.      the server).
  18262.  
  18263.    * If connection to the master is lost, the slave will retry
  18264.      immediately, and then in case of failure every
  18265.      `master-connect-retry' (default 60) seconds. Because of this, it
  18266.      is safe to shut down the master, and then restart it after a
  18267.      while. The slave will also be able to deal with network
  18268.      connectivity outages.
  18269.  
  18270.    * Shutting down the slave (cleanly) is also safe, as it keeps track
  18271.      of where it left off.  Unclean shutdowns might produce problems,
  18272.      especially if disk cache was not synced before the system died.
  18273.      Your system fault tolerance will be greatly increased if you have
  18274.      a good UPS.
  18275.  
  18276.    * If the master is listening on a non-standard port, you will also
  18277.      need to specify this with `master-port' parameter in `my.cnf' .
  18278.  
  18279.    * In 3.23.15,all of the tables and databases will be replicated.
  18280.      Starting in 3.23.16, you can restrict replication to a set of
  18281.      databases with `replicate-do-db' directives in `my.cnf' or just
  18282.      excluse a set of databases with `replicate-ignore-db'.
  18283.  
  18284.    * Starting in 3.23.16, `SET SQL_LOG_BIN = 0' will turn off
  18285.      replication (binary) logging on the master, and `SET SQL_LOG_BIN =
  18286.      1' will turn in back on - you must have the process privilege to do
  18287.      this.
  18288.  
  18289.    * The slave thread does not log updates to the binary log of the
  18290.      slave, so it is possible to couple two servers in a mutual
  18291.      master-slave relationship. You can actually set up a load
  18292.      balancing scheme and do queries safely on either of the servers.
  18293.      Just do not expect to do LOCK TABLES on one server, then connect
  18294.      to the other and still have that lock :-) .
  18295.  
  18296.    * Starting in 3.23.19 you can clean up stale replication leftovers
  18297.      when something goes wrong and you want a clean start with `FLUSH
  18298.      MASTER' and `FLUSH SLAVE' commands
  18299.  
  18300.    * Starting in 3.23.21 you can use LOAD TABLE FROM MASTER for network
  18301.      backup and to set up replication initially.
  18302.  
  18303. Replication Options in my.cnf
  18304. =============================
  18305.  
  18306. The table below explains the replications options in `my.cnf' . All of
  18307. the are available starting in 3.23.15 unless indicated otherwise.
  18308.  
  18309. *Option*           *Description*      *Where to set*     *Example*
  18310. `log-bin'          Should be set on   Master              `log-bin'
  18311.                    the master. Tells                     
  18312.                    it to keep a                          
  18313.                    binary update                         
  18314.                    log. If a                             
  18315.                    parameter is                          
  18316.                    specified, the                        
  18317.                    log will be                           
  18318.                    written to the                        
  18319.                    specified                             
  18320.                    location.                             
  18321. `log-bin-index'    Because the user   Master             `log-bin-index=db.index'
  18322.                    could issue                           
  18323.                    `FLUSH LOGS'                          
  18324.                    command, we need                      
  18325.                    to know which log                     
  18326.                    is currently                          
  18327.                    active and which                      
  18328.                    ones have been                        
  18329.                    rotated out and                       
  18330.                    it what sequence.                     
  18331.                    This info is                          
  18332.                    stored in the                         
  18333.                    binary log index                      
  18334.                    file. The default                     
  18335.                    is                                    
  18336.                    `hostname`.index                      
  18337.                    . You can use                         
  18338.                    this option if                        
  18339.                    you want to be a                      
  18340.                    rebel.                                
  18341. `master-host'      Master hostname    Slave              `master-host=db-master.mycompany.com'
  18342.                    or IP address for                     
  18343.                    replication. If                       
  18344.                    not set, the                          
  18345.                    slave thread will                     
  18346.                    not be started                        
  18347. `master-user'      The user the       Slave              `master-user=scott'
  18348.                    slave thread will                     
  18349.                    authenticate as                       
  18350.                    when connecting to                    
  18351.                    the master. The                       
  18352.                    user must have                        
  18353.                    `FILE' privilige.                     
  18354.                    If the master                         
  18355.                    user is not set,                      
  18356.                    user `test'  is                       
  18357.                    assumed.                              
  18358. `master-password'  The password the   Slave               `master-password=tiger'
  18359.                    slave thread will                     
  18360.                    authenticate with                     
  18361.                    when connecting                       
  18362.                    to the master. If                     
  18363.                    not set, empty                        
  18364.                    password is                           
  18365.                    assumed                               
  18366. `master-port'      The port the       Slave              `master-port=3306'
  18367.                    master is                             
  18368.                    listening on. If                      
  18369.                    not set, the                          
  18370.                    compiled setting                      
  18371.                    of `MYSQL_PORT'                       
  18372.                    is assumed. If                        
  18373.                    you have not                          
  18374.                    tinkered with                         
  18375.                    `configure'                           
  18376.                    options, this                         
  18377.                    should be 3306.                       
  18378. `master-connect-retry'The number of      Slave              `master-connect-retry=60'
  18379.                    seconds the slave                     
  18380.                    thread will sleep                     
  18381.                    before retrying                       
  18382.                    to connect to the                     
  18383.                    master in case                        
  18384.                    the master goes                       
  18385.                    down or the                           
  18386.                    connection is                         
  18387.                    lost.  Default is                     
  18388.                    60.                                   
  18389. `master-info-file'  The location of   Slave              `master-info-file=master.info'
  18390.                    the file that                         
  18391.                    remembers where                       
  18392.                    we left off on                        
  18393.                    the master during                     
  18394.                    the replication                       
  18395.                    process. The                          
  18396.                    default is                            
  18397.                    master.info in                        
  18398.                    the data                              
  18399.                    directory.                            
  18400.                    Sasha: The only                       
  18401.                    reason I see for                      
  18402.                    ever changing the                     
  18403.                    default is the                        
  18404.                    desire to be                          
  18405.                    rebelious.                            
  18406. `replicate-do-db'  Tells the slave    Slave              `replicate-do-db=some_db'
  18407.                    thread to                             
  18408.                    restrict                              
  18409.                    replication to                        
  18410.                    the specified                         
  18411.                    database. To                          
  18412.                    specify more than                     
  18413.                    one database, use                     
  18414.                    the directive                         
  18415.                    multiple times,                       
  18416.                    once for each                         
  18417.                    database.  Note                       
  18418.                    that this will                        
  18419.                    only work if you                      
  18420.                    do not use                            
  18421.                    cross-database                        
  18422.                    queries such as                       
  18423.                    `UPDATE                               
  18424.                    some_db.some_table                    
  18425.                    SET foo='bar''                        
  18426.                    while having                          
  18427.                    selected a                            
  18428.                    different or no                       
  18429.                    database.                             
  18430. `replicate-ignore-db'Tells the slave    Slave              `replicate-ignore-db=some_db'
  18431.                    thread to not                         
  18432.                    replicate to the                      
  18433.                    specified                             
  18434.                    database. To                          
  18435.                    specify more than                     
  18436.                    one database to                       
  18437.                    ignore, use the                       
  18438.                    directive                             
  18439.                    multiple times,                       
  18440.                    once for each                         
  18441.                    database. You                         
  18442.                    must not use                          
  18443.                    cross database                        
  18444.                    updates for this                      
  18445.                    option.                               
  18446. `sql-bin-update-same'If set, setting    Master             `sql-bin-update-same'
  18447.                    `SQL_LOG_BIN' to                      
  18448.                    a value will                          
  18449.                    automatically set                     
  18450.                    `SQL_LOG_UPDATE'                      
  18451.                    to the same value                     
  18452.                    and vice versa.                       
  18453. `log-slave-updates'Tells the slave    Slave              `log-slave-updates'
  18454.                    to log the                            
  18455.                    updates from the                      
  18456.                    slave thread to                       
  18457.                    the binary log.                       
  18458.                    Off by default.                       
  18459.                    You will need to                      
  18460.                    turn it on if you                     
  18461.                    plan to                               
  18462.                    daisy-chain the                       
  18463.                    slaves                                
  18464.  
  18465. SQL commands related to replication
  18466. ===================================
  18467.  
  18468. Replication can be controlled through the SQL interface. Below is the
  18469. summary of commands:
  18470.  
  18471. *Command*              *Description*                 *Where to run*
  18472. `SLAVE START'          Starts the slave thread.      Slave
  18473. `SLAVE STOP'           Stops the slave thread.       Slave
  18474. `SET SQL_LOG_BIN=0'    Disables update logging       Master
  18475. `SET SQL_LOG_BIN=1'    Re-enable update logging      Master
  18476. `FLUSH MASTER'         Deletes all binary logs       Master
  18477.                        listed in the inded file,     
  18478.                        resetting the binlog index    
  18479.                        file to be empty.             
  18480. `FLUSH SLAVE'          Makes the slave forget its    Slave
  18481.                        replication position in the   
  18482.                        master logs                   
  18483. `LOAD TABLE tblname    Downloads a copy of the       Slave
  18484. FROM MASTER'           table from master to the      
  18485.                        slave                         
  18486.  
  18487. Getting maximum performance from MySQL
  18488. **************************************
  18489.  
  18490. Optimization is a complicated task because it ultimately requires
  18491. understanding of the whole system. While it may be possible to do some
  18492. local optimizations with small knowledge of your system/application, the
  18493. more optimal you want your system to become the more you will have to
  18494. know about it.
  18495.  
  18496. So this chapter will try to explain and give some examples of different
  18497. ways to optimize *MySQL*. But remember that there are always some
  18498. (increasingly harder) ways to make the system even faster left to do.
  18499.  
  18500. Optimization overview
  18501. =====================
  18502.  
  18503. The most important part for getting a system fast is of course the basic
  18504. design. You also need to know what kinds of things your system will be
  18505. doing, and what your bottlenecks are.
  18506.  
  18507. The most common bottlenecks are:
  18508.    * Disk seeks It takes time for the disk to find a piece of data.
  18509.      With modern disks in 1999 the mean time for this is usually lower
  18510.      than 10ms, so we can in theory do about 1000 seeks a second. This
  18511.      time improves slowly with new disks and is very hard to optimize
  18512.      for a single table. The way to optimize this is to spread the data
  18513.      on more than one disk.
  18514.  
  18515.    * Disk reading/writing When the disk is at the correct position we
  18516.      need to read the data. With modern disks in 1999 one disk delivers
  18517.      something like 10-20Mb/s. This is easier to optimize than seeks
  18518.      because you can read in parallel from multiple disks.
  18519.  
  18520.    * CPU cycles When we have got the data into main memory (or if it
  18521.      already were there) we need to process it to get to our result.
  18522.      When we have small tables compared to the memory this is the most
  18523.      common limiting factor. But then with small tables speed is
  18524.      usually not the problem.
  18525.  
  18526.    * Memory bandwidth When the CPU needs more data than can fit in the
  18527.      CPU cache the main memory bandwidth becomes a bottleneck. This is
  18528.      an uncommon bottleneck for most systems but one should be aware of
  18529.      it.
  18530.  
  18531. System/Compile time and startup parameter tuning
  18532. ================================================
  18533.  
  18534. We start with the system level things since some of these decisions have
  18535. to be made very early. In other cases a fast look at this part may
  18536. suffice because it not that important for the big gains. However, it is
  18537. always nice to have a feeling about how much one could gain by changing
  18538. things at this level.
  18539.  
  18540. The default OS to use is really important!  To get the most use of
  18541. multiple CPU machines one should use Solaris (because the threads works
  18542. really nice) or Linux (because the 2.2 kernel has really good SMP
  18543. support). Also on 32bit machines Linux has a 2G file size limit by
  18544. default. Hopefully this will be fixed soon when new filesystems is
  18545. released (XFS/Reiserfs).
  18546.  
  18547. Because we have not run *MySQL* in production on that many platforms we
  18548. advice you to test your intended platform before choosing it, if
  18549. possible.
  18550.  
  18551. Other tips:
  18552.    * If you have enough RAM, you could remove all swap devices. Some
  18553.      operating systems will use a swap device in some contexts even if
  18554.      you have free memory.
  18555.  
  18556.    * Use the `--skip-locking' *MySQL* option to avoid external locking.
  18557.      Note that this will not impact *MySQL*'s functionality as long as
  18558.      you only run one server. Just remember to take down the server (or
  18559.      lock relevant parts) before you run `myisamchk'. On some system
  18560.      this switch is mandatory because the external locking does not
  18561.      work in any case.
  18562.  
  18563.      The `--skip-locking' option is on by default when compiling with
  18564.      MIT-pthreads, because `flock()' isn't fully supported by
  18565.      MIT-pthreads on all platforms.
  18566.  
  18567.      The only case when you can't use `--skip-locking' is if you run
  18568.      multiple *MySQL* _servers_ (not clients) on the same data, or run
  18569.      `myisamchk' on the table without first flushing and locking the
  18570.      `mysqld' server tables first.
  18571.  
  18572.      You can still use `LOCK TABLES' / `UNLOCK TABLES' even if you are
  18573.      using `--skip-locking'
  18574.  
  18575. How compiling and linking affects the speed of MySQL
  18576. ----------------------------------------------------
  18577.  
  18578. Most of the following tests are done on Linux with the *MySQL*
  18579. benchmarks, but they should give some indication for other operating
  18580. systems and workloads.
  18581.  
  18582. You get the fastest executable when you link with `-static'.
  18583.  
  18584. On Linux, you will get the fastest code when compiling with `pgcc' and
  18585. `-O6'. To compile `sql_yacc.cc' with these options, you need about 200M
  18586. memory because `gcc/pgcc' needs a lot of memory to make all functions
  18587. inline. You should also set `CXX=gcc' when configuring *MySQL* to avoid
  18588. inclusion of the `libstdc++' library (it is not needed). Note that with
  18589. some versions of `pgcc', the resulting code will only run on true
  18590. Pentium processors, even if you use the compiler option that you want
  18591. the resulting code to be working on all x586 type processors (Like AMD).
  18592.  
  18593. By just using a better compiler and/or better compiler options you can
  18594. get a 10-30 % speed increase in your application.  This is particularly
  18595. important if you compile the SQL server yourself!
  18596.  
  18597. We have tested the both Cygnus CodeFusion and the Fujitsu compiler but
  18598. when we tested them, neither was enough bug free enough to compile
  18599. *MySQL* with optimizations on.
  18600.  
  18601. When you compile *MySQL* you should only include support for the
  18602. character sets that you are going to use. (Option `--with-charset=xxx').
  18603. The standard *MySQL* binary distributions are compiled with support for
  18604. all character sets.
  18605.  
  18606. Here is a list of some mesurements that we have done:
  18607.    * If you use `pgcc' and compile everything with `-O6', the `mysqld'
  18608.      server is 11% faster than with `gcc' versions older than `gcc'
  18609.      2.95.2.
  18610.  
  18611.    * If you link dynamically (without `-static'), the result is 13%
  18612.      slower.  Note that you still can use a dynamic linked *MySQL*
  18613.      library. It is only the server that is critical for performance.
  18614.  
  18615.    * If you connect using TCP/IP rather than Unix sockets, the result
  18616.      is 7.5% slower on the same computer. (If you are connection to
  18617.      `localhost', *MySQL* will by default use sockets).
  18618.  
  18619.    * On a Sun SPARCstation 10, `gcc' 2.7.3 is 13% faster than Sun Pro
  18620.      C++ 4.2.
  18621.  
  18622.    * On Solaris 2.5.1, MIT-pthreads is 8-12% slower than Solaris native
  18623.      threads on a single processor. With more load/CPUs the difference
  18624.      should get bigger.
  18625.  
  18626. The *MySQL*-Linux distribution provided by MySQL AB used to be compiled
  18627. with `pgcc', but we had to go back to regular gcc because of a bug in
  18628. `pgcc' that would generate the code that does not run on AMD. We will
  18629. continue using gcc until that bug is resolved.  In the meantime, if you
  18630. have a non-AMD machine, you can get a faster binary by compiling with
  18631. `pgcc'.  The standard MySqL Linux binary is linked statically to get it
  18632. faster and more portable.
  18633.  
  18634. Disk issues
  18635. -----------
  18636.  
  18637.    * As mentioned before disks seeks are a big performance bottleneck.
  18638.      This problems gets more and more apparent when the data starts to
  18639.      grow so large that effective caching becomes impossible. For large
  18640.      databases, where you access data more or less randomly, you can be
  18641.      sure that you will need at least one disk seek to read and a
  18642.      couple of disk seeks to write things. To minimize this problem,
  18643.      use disks with low seek times.
  18644.  
  18645.    * Increase the number of available disk spindles (and thereby reduce
  18646.      the seek overhead) by either symlink files to different disks or
  18647.      stripe the disks.
  18648.     *Using symbolic links*
  18649.           This means that you symlink the index and/or data file(s)
  18650.           from the normal data directory to another disk (that may also
  18651.           be striped). This makes both the seek and read times better
  18652.           (if the disks are not used for other things). *Note Symbolic
  18653.           links::.
  18654.  
  18655.     *Striping*
  18656.           Striping means that you have many disks and put the first
  18657.           block on the first disk, the second block on the second disk,
  18658.           and the Nth on the (Nth mod number_of_disks) disk, and so on.
  18659.           This means if your normal data size is less than the stripe
  18660.           size (or perfectly aligned) you will get much better
  18661.           performance. Note that striping if very dependent on the OS
  18662.           and stripe-size. So benchmark your application with different
  18663.           stripe-sizes. *Note Benchmarks::.
  18664.  
  18665.           Note that the speed difference for striping is *very*
  18666.           dependent on the parameters. Depending on how you set the
  18667.           striping parameters and number of disks you may get
  18668.           difference in orders of magnitude. Note that you have to
  18669.           choose to optimize for random or sequential access.
  18670.  
  18671.    * For reliability you may want to use RAID 0+1 (striping +
  18672.      mirroring), but in this case you will need 2*N drives to hold N
  18673.      drives of data. This is probably the best option if you have the
  18674.      money for it!  You may however also have to invest in some volume
  18675.      management software to handle it efficiently.
  18676.  
  18677.    * A good option is to have semi-important data (that can be
  18678.      re-generated) on RAID 0 disk while store really important data
  18679.      (like host information and logs) on a RAID 0+1 or RAID N disks.
  18680.      RAID N can be a problem if you have many writes because of the
  18681.      time to update the parity bits.
  18682.  
  18683.    * You may also set the parameters for the file system that the
  18684.      database uses. One easy change is to mount the file system with
  18685.      the noatime option. That makes it skip the updating of the last
  18686.      access time in the inode and by this will avoid some disk seeks.
  18687.  
  18688.    * On Linux, you can get much more performance (up to 100 % under
  18689.      load is not uncommon) by using hdpram to configure your disks
  18690.      interface!  The following should be quite good hdparm options for
  18691.      `MySQL' (and probably many other applications):
  18692.           hdparm -m 16 -d 1
  18693.  
  18694.      Note that the performance/reliability when using the above depends
  18695.      on your hardware, so we strongly suggest that you test your system
  18696.      throughly after using `hdparm'!  Please consult the `hdparm' man
  18697.      page for more information!  If `hdparm' is not used wisely,
  18698.      filesystem corruption may result.  Backup everything before
  18699.      experimenting!
  18700.  
  18701.    * On many OS system you can mount the disks with the 'async' flag to
  18702.      set the file system to be updated asynchronously.  If your
  18703.      computer is reasonable stable, this should give you more
  18704.      performance without sacrificing too much reliability.  (This flag
  18705.      is on by default on Linux).
  18706.  
  18707.    * If you don't need to know when a file was last accessed (which is
  18708.      not really useful on a databasa server), you can mount your file
  18709.      systems with the noatime flag.
  18710.  
  18711. Using symbolic links for databases and tables
  18712. .............................................
  18713.  
  18714. You can move tables and databases from the database directory to other
  18715. locations and replace them with symbolic links to the new locations.
  18716. You might want to do this, for example, to move a database to a file
  18717. system with more free space.
  18718.  
  18719. If *MySQL* notices that a table is a symbolically-linked, it will
  18720. resolve the symlink and use the table it points to instead. This works
  18721. on all systems that support the `realpath()' call (at least Linux and
  18722. Solaris support `realpath()')!  On systems that don't support
  18723. `realpath()', you should not access the table through the real path and
  18724. through the symlink at the same time!  If you do, the table will be
  18725. inconsistent after any update.
  18726.  
  18727. *MySQL* doesn't that you link one directory to multiple databases.
  18728. Replacing a database directory with a symbolic link will work fine as
  18729. long as you don't make a symbolic link between databases.  Suppose you
  18730. have a database `db1' under the *MySQL* data directory, and then make a
  18731. symlink `db2' that points to `db1':
  18732.  
  18733.      shell> cd /path/to/datadir
  18734.      shell> ln -s db1 db2
  18735.  
  18736. Now, for any table `tbl_a' in `db1', there also appears to be a table
  18737. `tbl_a' in `db2'.  If one thread updates `db1.tbl_a' and another thread
  18738. updates `db2.tbl_a', there will be problems.
  18739.  
  18740. If you really need this, you must change the following code in
  18741. `mysys/mf_format.c':
  18742.  
  18743.      if (flag & 32 || (!lstat(to,&stat_buff) && S_ISLNK(stat_buff.st_mode)))
  18744.  
  18745. to
  18746.  
  18747.      if (1)
  18748.  
  18749. On windows you can use internal symbolic links to directories by
  18750. compiling *MySQL* with `-DUSE_SYMDIR'. This allows you to put different
  18751. databases on different disks. *Note Win32 symbolic links::.
  18752.  
  18753. Tuning server parameters
  18754. ------------------------
  18755.  
  18756. You can get the default buffer sizes used by the `mysqld' server with
  18757. this command:
  18758.  
  18759.      shell> mysqld --help
  18760.  
  18761. This command produces a list of all `mysqld' options and configurable
  18762. variables. The output includes the default values and looks something
  18763. like this:
  18764.  
  18765.      Possible variables for option --set-variable (-O) are:
  18766.      back_log              current value: 5
  18767.      bdb_cache_size        current value: 1048540
  18768.      connect_timeout       current value: 5
  18769.      delayed_insert_timeout  current value: 300
  18770.      delayed_insert_limit  current value: 100
  18771.      delayed_queue_size    current value: 1000
  18772.      flush_time            current value: 0
  18773.      interactive_timeout   current value: 28800
  18774.      join_buffer_size      current value: 131072
  18775.      key_buffer_size       current value: 1048540
  18776.      lower_case_table_names  current value: 0
  18777.      long_query_time       current value: 10
  18778.      max_allowed_packet    current value: 1048576
  18779.      max_connections       current value: 100
  18780.      max_connect_errors    current value: 10
  18781.      max_delayed_threads   current value: 20
  18782.      max_heap_table_size   current value: 16777216
  18783.      max_join_size         current value: 4294967295
  18784.      max_sort_length       current value: 1024
  18785.      max_tmp_tables        current value: 32
  18786.      max_write_lock_count  current value: 4294967295
  18787.      myisam_sort_buffer_size  current value: 8388608
  18788.      net_buffer_length     current value: 16384
  18789.      net_retry_count       current value: 10
  18790.      net_read_timeout      current value: 30
  18791.      net_write_timeout     current value: 60
  18792.      query_buffer_size     current value: 0
  18793.      record_buffer         current value: 131072
  18794.      slow_launch_time      current value: 2
  18795.      sort_buffer           current value: 2097116
  18796.      table_cache           current value: 64
  18797.      thread_concurrency    current value: 10
  18798.      tmp_table_size        current value: 1048576
  18799.      thread_stack          current value: 131072
  18800.      wait_timeout          current value: 28800
  18801.  
  18802. If there is a `mysqld' server currently running, you can see what
  18803. values it actually is using for the variables by executing this command:
  18804.  
  18805.      shell> mysqladmin variables
  18806. <<<<<<< manual.texi
  18807.  
  18808. Each option is described below. Values for buffer sizes, lengths and
  18809. stack sizes are given in bytes.  You can specify values with a suffix
  18810. of `K' or `M' to indicate kilobytes or megabytes. For example, `16M'
  18811. indicates 16 megabytes.  The case of suffix letters does not matter;
  18812. `16M' and `16m' are equivalent.
  18813.  
  18814. You can also see some statistics from a running server by issuing the
  18815. command `SHOW STATUS'. *Note SHOW::.
  18816.  
  18817. ``ansi_mode'.'
  18818.      Is `ON' if `mysqld' was started with `--ansi'.  *Note Ansi mode::.
  18819.  
  18820. ``back_log''
  18821.      The number of outstanding connection requests *MySQL* can have.
  18822.      This comes into play when the main *MySQL* thread gets *VERY* many
  18823.      connection requests in a very short time. It then takes some time
  18824.      (although very little) for the main thread to check the connection
  18825.      and start a new thread. The `back_log' value indicates how many
  18826.      requests can be stacked during this short time before *MySQL*
  18827.      momentarily stops answering new requests. You need to increase
  18828.      this only if you expect a large number of connections in a short
  18829.      period of time.
  18830.  
  18831.      In other words, this value is the size of the listen queue for
  18832.      incoming TCP/IP connections.  Your operating system has its own
  18833.      limit on the size of this queue.  The manual page for the Unix
  18834.      `listen(2)' system call should have more details.  Check your OS
  18835.      documentation for the maximum value for this variable.  Attempting
  18836.      to set `back_log' higher than your operating system limit will be
  18837.      ineffective.
  18838.  
  18839. ``bdb_cache_size''
  18840.      The buffer that is allocated to cache index and rows for `BDB'
  18841.      tables.  If you don't use `BDB' tables, you should set this to 0 or
  18842.      start `mysqld' with `--skip-bdb' o not waste memory for this cache.
  18843.  
  18844. ``concurrent_inserts''
  18845.      If `ON' (the default), `MySQL' will allow you to use `INSERT' on
  18846.      `MyISAM' tables at the same time as you run `SELECT' queries on
  18847.      them.  You can turn this option off by starting mysqld with
  18848.      `--safe' or `--skip-new'.
  18849.  
  18850. ``connect_timeout''
  18851.      The number of seconds the `mysqld' server is waiting for a connect
  18852.      packet before responding with `Bad handshake'.
  18853.  
  18854. ``delayed_insert_timeout''
  18855.      How long a `INSERT DELAYED' thread should wait for `INSERT'
  18856.      statements before terminating.
  18857.  
  18858. ``delayed_insert_limit''
  18859.      After inserting `delayed_insert_limit' rows, the `INSERT DELAYED'
  18860.      handler will check if there are any `SELECT' statements pending.
  18861.      If so, it allows these to execute before continuing.
  18862.  
  18863. ``delay_key_write''
  18864.      If enabled (is on by default), *MySQL* will honor the
  18865.      `delay_key_write' option `CREATE TABLE'.  This means that the key
  18866.      buffer for tables with this option will not get flushed on every
  18867.      index update, but only when a table is closed.  This will speed up
  18868.      writes on keys a lot but you should add automatic checking of all
  18869.      tables with `myisamchk --fast --force' if you use this.  Note that
  18870.      if you start `mysqld' with the `--delay-key-write-for-all-tables'
  18871.      option this means that all tables will be treated as if they were
  18872.      created with the `delay_key_write' option.  You can clear this flag
  18873.      by starting `mysqld' with `--skip-new' or `--safe-mode'.
  18874.  
  18875. ``delayed_queue_size''
  18876.      What size queue (in rows) should be allocated for handling `INSERT
  18877.      DELAYED'.  If the queue becomes full, any client that does `INSERT
  18878.      DELAYED' will wait until there is room in the queue again.
  18879.  
  18880. ``flush_time''
  18881.      If this is set to a non-zero value, then every `flush_time'
  18882.      seconds all tables will be closed (to free up resources and sync
  18883.      things to disk).
  18884.  
  18885. ``init_file''
  18886.      The name of the file specified with the `--init-file' option when
  18887.      you start the server.  This is a file of SQL statements you want
  18888.      the server to execute when it starts.
  18889.  
  18890. ``interactive_timeout''
  18891.      The number of seconds the server waits for activity on an
  18892.      interactive connection before closing it.  An interactive client
  18893.      is defined as a client that uses the `CLIENT_INTERACTIVE' option to
  18894.      `mysql_real_connect()'.  See also `wait_timeout'.
  18895.  
  18896. ``join_buffer_size''
  18897.      The size of the buffer that is used for full joins (joins that do
  18898.      not use indexes).  The buffer is allocated one time for each full
  18899.      join between two tables. Increase this value to get a faster full
  18900.      join when adding indexes is not possible. (Normally the best way
  18901.      to get fast joins is to add indexes.)
  18902.  
  18903. ``key_buffer_size''
  18904.      Index blocks are buffered and are shared by all threads.
  18905.      `key_buffer_size' is the size of the buffer used for index blocks.
  18906.  
  18907.      Increase this to get better index handling (for all reads and
  18908.      multiple writes) to as much as you can afford; 64M on a 256M
  18909.      machine that mainly runs *MySQL* is quite common.  If you however
  18910.      make this too big (more than 50% of your total memory?) your
  18911.      system may start to page and become REALLY slow. Remember that
  18912.      because *MySQL* does not cache data read, that you will have to
  18913.      leave some room for the OS filesystem cache.
  18914.  
  18915.      You can check the performance of the key buffer by doing `show
  18916.      status' and examine the variables `Key_read_requests',
  18917.      `Key_reads', `Key_write_requests' and `Key_writes'.  The
  18918.      `Key_reads/Key_read_request' ratio should normally be < 0.01.  The
  18919.      `Key_write/Key_write_requests' is usually near 1 if you are using
  18920.      mostly updates/deletes but may be much smaller if you tend to do
  18921.      updates that affect many at the same time or if you are using
  18922.      `delay_key_write'. *Note SHOW::.
  18923.  
  18924.      To get even more speed when writing many rows at the same time use
  18925.      `LOCK TABLES'.  *Note `LOCK TABLES': LOCK TABLES.
  18926.  
  18927. ``lower_case_table_names''
  18928.      Change all table names to lower case on disk.
  18929.  
  18930. ``long_query_time''
  18931.      If a query takes longer than this (in seconds), the `Slow_queries'
  18932.      counter will be incremented.
  18933.  
  18934. ``max_allowed_packet''
  18935.      The maximum size of one packet. The message buffer is initialized
  18936.      to `net_buffer_length' bytes, but can grow up to
  18937.      `max_allowed_packet' bytes when needed.  This value by default is
  18938.      small, to catch big (possibly wrong) packets.  You must increase
  18939.      this value if you are using big `BLOB' columns. It should be as
  18940.      big as the biggest `BLOB' you want to use.
  18941.  
  18942. ``max_connections''
  18943.      The number of simultaneous clients allowed. Increasing this value
  18944.      increases the number of file descriptors that `mysqld' requires.
  18945.      See below for comments on file descriptor limits. *Note Too many
  18946.      connections::.
  18947.  
  18948. ``max_connect_errors''
  18949.      If there is more than this number of interrupted connections from
  18950.      a host this host will be blocked from further connections.  You
  18951.      can unblock a host with the command `FLUSH HOSTS'.
  18952.  
  18953. ``max_delayed_threads''
  18954.      Don't start more than this number of threads to handle `INSERT
  18955.      DELAYED' statements.  If you try to insert data into a new table
  18956.      after all `INSERT DELAYED' threads are in use, the row will be
  18957.      inserted as if the `DELAYED' attribute wasn't specified.
  18958.  
  18959. ``max_join_size''
  18960.      Joins that are probably going to read more than `max_join_size'
  18961.      records return an error. Set this value if your users tend to
  18962.      perform joins without a `WHERE' clause that take a long time and
  18963.      return millions of rows.
  18964.  
  18965. ``max_heap_table_size''
  18966.      Don't allow creation of heap tables bigger than this.
  18967.  
  18968. ``max_sort_length''
  18969.      The number of bytes to use when sorting `BLOB' or `TEXT' values
  18970.      (only the first `max_sort_length' bytes of each value are used;
  18971.      the rest are ignored).
  18972.  
  18973. ``max_tmp_tables''
  18974.      (This option doesn't yet do anything).  Maximum number of
  18975.      temporary tables a client can keep open at the same time.
  18976.  
  18977. ``max_write_lock_count''
  18978.      After this many write locks, allow some read locks to run in
  18979.      between.
  18980.  
  18981. ``myisam_sort_buffer_size''
  18982.      The buffer that is allocated when sorting the index when doing a
  18983.      `REPAIR' table.
  18984.  
  18985. ``net_buffer_length''
  18986.      The communication buffer is reset to this size between queries.
  18987.      This should not normally be changed, but if you have very little
  18988.      memory, you can set it to the expected size of a query.  (That is,
  18989.      the expected length of SQL statements sent by clients.  If
  18990.      statements exceed this length, the buffer is automatically
  18991.      enlarged, up to `max_allowed_packet' bytes.)
  18992.  
  18993. ``net_retry_count''
  18994.      If a read on a communication port is interrupted, retry this many
  18995.      times before giving up.  This value should be quite high on
  18996.      `FreeBSD' as internal interrupts is sent to all threads.
  18997.  
  18998. ``net_read_timeout''
  18999.      Number of seconds to wait for more data from a connection before
  19000.      aborting the read.  Note that when we don't expect data from a
  19001.      connection, the timeout is defined by `write_timeout'.
  19002.  
  19003. ``net_write_timeout''
  19004.      Number of seconds to wait for a block to be written to a
  19005.      connection before aborting the write.  ======= >>>>>>> 1.148
  19006.  
  19007.      <<<<<<< manual.texi
  19008.  
  19009. ``record_buffer''
  19010.      Each thread that does a sequential scan allocates a buffer of this
  19011.      size for each table it scans. If you do many sequential scans, you
  19012.      may want to increase this value.  ======= or the `SHOW VARIABLES'
  19013.      in the `mysql' command client.  >>>>>>> 1.148
  19014.  
  19015.      <<<<<<< manual.texi
  19016.  
  19017. ``query_buffer_size''
  19018.      The initial allocation of the query buffer. If most of your
  19019.      queries are long (like when inserting blobs), you should increase
  19020.      this!  ======= You can find a full description for all variables
  19021.      in the `SHOW VARIABLES' section in this manual. *Note SHOW
  19022.      VARIABLES::.  >>>>>>> 1.148
  19023.  
  19024.      <<<<<<< manual.texi
  19025.  
  19026. ``skip_show_databases''
  19027.      This prevents people from doing `SHOW DATABASES', if they don't
  19028.      have the `PROCESS_PRIV' privilege. This can improve security if
  19029.      you're concerned about people being able to see what databases and
  19030.      tables other users have.
  19031.  
  19032. ``slow_launch_time''
  19033.      If the creating of the thread longer than this (in seconds), the
  19034.      `Slow_launch_threads' counter will be incremented.
  19035.  
  19036. ``sort_buffer''
  19037.      Each thread that needs to do a sort allocates a buffer of this
  19038.      size. Increase this value for faster `ORDER BY' or `GROUP BY'
  19039.      operations.  *Note Temporary files::.
  19040.  
  19041. ``table_cache''
  19042.      The number of open tables for all threads. Increasing this value
  19043.      increases the number of file descriptors that `mysqld' requires.
  19044.      *MySQL* needs two file descriptors for each unique open table.
  19045.      See below for comments on file descriptor limits. You can check if
  19046.      you need to increase the table cache by checking the
  19047.      `Opened_tables' variable. *Note SHOW::.  If this variable is big
  19048.      and you don't do `FLUSH TABLES' a lot (which just forces all
  19049.      tables to be closed and reopenend), then you should increase the
  19050.      value of this variable.
  19051.  
  19052.      For information about how the table cache works, see *Note Table
  19053.      cache::.
  19054.  
  19055. ``thread_cache_size''
  19056.      How many threads we should keep keep in a cache for reuse.  When a
  19057.      client disconnects the clients threads is put in the cache if there
  19058.      isn't more than `thread_cache_size' threads from before.  All new
  19059.      threads are first taken from the cache and only when the cache is
  19060.      empty a new thread is created.  This variable can be increased to
  19061.      improve performance if you have a lot of new connections (Normally
  19062.      this doesn't however give a notable performance improvement if you
  19063.      have a good thread implementation).
  19064.  
  19065. ``thread_concurrency''
  19066.      On Solaris, `mysqld' will call `thr_setconcurrency()' with this
  19067.      value.  `thr_setconcurrency()' permits the application to give the
  19068.      threads system a hint, for the desired number of threads that
  19069.      should be run at the same time.
  19070.  
  19071. ``thread_stack''
  19072.      The stack size for each thread.  Many of the limits detected by the
  19073.      `crash-me' test are dependent on this value. The default is large
  19074.      enough for normal operation.  *Note Benchmarks::.
  19075.  
  19076. ``tmp_table_size''
  19077.      If an in-memory temporary table exceeds this size, *MySQL* will
  19078.      automatically convert it to an on-disk `MyISAM' table.  Increase
  19079.      the value of `tmp_table_size' if you do many advanced `GROUP BY'
  19080.      queries and you have lots of memory.
  19081.  
  19082. ``wait_timeout''
  19083.      The number of seconds the server waits for activity on a
  19084.      connection before closing it. See also `interactive_timeout'.
  19085. ======= You can also see some statistics from a running server by
  19086. issuing the command `SHOW STATUS'. *Note SHOW STATUS::.  >>>>>>> 1.148
  19087.  
  19088. *MySQL* uses algorithms that are very scalable, so you can usually run
  19089. with very little memory. If you however give *MySQL* more memory you
  19090. will normally also get better performance.
  19091.  
  19092. When tuning a *MySQL* server, the two most important variables to use
  19093. are `key_buffer_size' and `table_cache'.  You should first feel
  19094. confident that you have these right before trying to change any of the
  19095. other variables.
  19096.  
  19097. If you have much memory (>=256M) and many tables and want maximum
  19098. performance with a moderate number of clients, you should use something
  19099. like this:
  19100.  
  19101.      shell> safe_mysqld -O key_buffer=64M -O table_cache=256 \
  19102.                 -O sort_buffer=4M -O record_buffer=1M &
  19103.  
  19104. If you have only 128M and only a few tables, but you still do a lot of
  19105. sorting, you can use something like:
  19106.  
  19107.      shell> safe_mysqld -O key_buffer=16M -O sort_buffer=1M
  19108.  
  19109. If you have little memory and lots of connections, use something like
  19110. this:
  19111.  
  19112.      shell> safe_mysqld -O key_buffer=512k -O sort_buffer=100k \
  19113.                 -O record_buffer=100k &
  19114.  
  19115. or even:
  19116.  
  19117.      shell> safe_mysqld -O key_buffer=512k -O sort_buffer=16k \
  19118.                 -O table_cache=32 -O record_buffer=8k -O net_buffer=1K &
  19119.  
  19120. When you have installed *MySQL*, the `Docs' directory will contain some
  19121. different `my.cnf' example files, `my-huge.cnf',
  19122. `my-large.cnf',`my-medium.cnf' and`my-small.cnf', you can use as a base
  19123. to optimize your system.
  19124.  
  19125. If there are very many connections, "swapping problems" may occur unless
  19126. `mysqld' has been configured to use very little memory for each
  19127. connection. `mysqld' performs better if you have enough memory for all
  19128. connections, of course.
  19129.  
  19130. Note that if you change an option to `mysqld', it remains in effect only
  19131. for that instance of the server.
  19132.  
  19133. To see the effects of a parameter change, do something like this:
  19134.  
  19135.      shell> mysqld -O key_buffer=32m --help
  19136.  
  19137. Make sure that the `--help' option is last; otherwise, the effect of any
  19138. options listed after it on the command line will not be reflected in the
  19139. output.
  19140.  
  19141. How MySQL opens and closes tables
  19142. ---------------------------------
  19143.  
  19144. `table_cache', `max_connections' and `max_tmp_tables' affect the
  19145. maximum number of files the server keeps open.  If you increase one or
  19146. both of these values, you may run up against a limit imposed by your
  19147. operating system on the per-process number of open file descriptors.
  19148. However, you can increase the limit on many systems.  Consult your OS
  19149. documentation to find out how to do this, because the method for
  19150. changing the limit varies widely from system to system.
  19151.  
  19152. `table_cache' is related to `max_connections'.  For example, for 200
  19153. concurrent running connections, you should have a table cache of at
  19154. least `200 * n', where `n' is the maximum number of tables in a join.
  19155.  
  19156. The cache of open tables can grow to a maximum of `table_cache'
  19157. (default 64; this can be changed with with the `-O table_cache=#'
  19158. option to `mysqld').  A table is never closed, except when the cache is
  19159. full and another thread tries to open a table or if you use `mysqladmin
  19160. refresh' or `mysqladmin flush-tables'.
  19161.  
  19162. When the table cache fills up, the server uses the following procedure
  19163. to locate a cache entry to use:
  19164.  
  19165.    * Tables that are not currently in use are released, in
  19166.      least-recently-used order.
  19167.  
  19168.    * If the cache is full and no tables can be released, but a new
  19169.      table needs to be opened, the cache is temporarily extended as
  19170.      necessary.
  19171.  
  19172.    * If the cache is in a temporarily-extended state and a table goes
  19173.      from in-use to not-in-use state, the table is closed and released
  19174.      from the cache.
  19175.  
  19176. A table is opened for each concurrent access. This means that if you
  19177. have two threads accessing the same table or access the table twice in
  19178. the same query (with `AS') the table needs to be opened twice.  The
  19179. first open of any table takes two file descriptors; each additional use
  19180. of the table takes only one file descriptor.  The extra descriptor for
  19181. the first open is used for the index file; this descriptor is shared
  19182. among all threads.
  19183.  
  19184. You can check if your table cache is too small by checking the mysqld
  19185. variable `opened_tables'.  If this is quite big, even if you haven't
  19186. done alot of `flush tables', you should increase your table cache.
  19187. *Note SHOW STATUS::.
  19188.  
  19189. Drawbacks of creating large numbers of tables in the same database
  19190. ------------------------------------------------------------------
  19191.  
  19192. If you have many files in a directory, open, close and create
  19193. operations will be slow.  If you execute `SELECT' statements on many
  19194. different tables, there will be a little overhead when the table cache
  19195. is full, because for every table that has to be opened, another must be
  19196. closed. You can reduce this overhead by making the table cache larger.
  19197.  
  19198. Why so many open tables?
  19199. ------------------------
  19200.  
  19201. When you run `mysqladmin status', you'll see something like this:
  19202.  
  19203.      Uptime: 426 Running threads: 1 Questions: 11082 Reloads: 1 Open tables: 12
  19204.  
  19205. This can be somewhat perplexing if you only have 6 tables.
  19206.  
  19207. *MySQL* is multithreaded, so it may have many queries on the same table
  19208. simultaneously. To minimize the problem with two threads having
  19209. different states on the same file, the table is opened independently by
  19210. each concurrent thread. This takes some memory and one extra file
  19211. descriptor for the data file. The index file descriptor is shared
  19212. between all threads.
  19213.  
  19214. How MySQL uses memory
  19215. ---------------------
  19216.  
  19217. The list below indicates some of the ways that the `mysqld' server uses
  19218. memory.  Where applicable, the name of the server variable relevant to
  19219. the memory use is given.
  19220.  
  19221.    * The key buffer (variable `key_buffer_size') is shared by all
  19222.      threads; Other buffers used by the server are allocated as needed.
  19223.      *Note Server parameters::.
  19224.  
  19225.    * Each connection uses some thread specific space; A stack (default
  19226.      64K, variable `thread_stack') a connection buffer (variable
  19227.      `net_buffer_length'), and a result buffer (variable
  19228.      `net_buffer_length'). The connection buffer and result buffer are
  19229.      dynamically enlarged up to `max_allowed_packet' when needed.  When
  19230.      a query is running, a copy of the current query string is also
  19231.      allocated.
  19232.  
  19233.    * All threads share the same base memory.
  19234.  
  19235.    * Only the compressed ISAM / MyISAM tables are memory mapped.  This
  19236.      is because the 32-bit memory space of 4GB is not large enough for
  19237.      most big tables. When systems with a 64-bit address-space become
  19238.      more common we may add general support for memory-mapping.
  19239.  
  19240.    * Each request doing a sequential scan over a table allocates a read
  19241.      buffer (variable `record_buffer').
  19242.  
  19243.    * All joins are done in one pass and most joins can be done without
  19244.      even using a temporary table. Most temporary tables are
  19245.      memory-based (HEAP) tables.  Temporary tables with a big record
  19246.      length (calculated as the sum of all column lengths) or that
  19247.      contain `BLOB' columns are stored on disk.
  19248.  
  19249.      One problem in *MySQL* versions before 3.23.2 is that if a HEAP
  19250.      table exceeds the size of `tmp_table_size', you get the error `The
  19251.      table tbl_name is full'. In newer versions this is handled by
  19252.      automatically changing the in-memory (HEAP) table to a disk-based
  19253.      (MyISAM) table as necessary. To work around this problem, you can
  19254.      increase the temporary table size by setting the `tmp_table_size'
  19255.      option to `mysqld', or by setting the SQL option `SQL_BIG_TABLES'
  19256.      in the client program.  *Note `SET OPTION': SET OPTION. In *MySQL*
  19257.      3.20, the maximum size of the temporary table was
  19258.      `record_buffer*16', so if you are using this version, you have to
  19259.      increase the value of `record_buffer'. You can also start `mysqld'
  19260.      with the `--big-tables' option to always store temporary tables on
  19261.      disk, however, this will affect the speed of many complicated
  19262.      queries.
  19263.  
  19264.    * Most requests doing a sort allocates a sort buffer and 0-2
  19265.      temporary files depending on the result set size. *Note Temporary
  19266.      files::.
  19267.  
  19268.    * Almost all parsing and calculating is done in a local memory
  19269.      store. No memory overhead is needed for small items and the normal
  19270.      slow memory allocation and freeing is avoided. Memory is allocated
  19271.      only for unexpectedly large strings (this is done with `malloc()'
  19272.      and `free()').
  19273.  
  19274.    * Each index file is opened once and the data file is opened once
  19275.      for each concurrently-running thread. For each concurrent thread,
  19276.      a table structure, column structures for each column, and a buffer
  19277.      of size `3 * n' is allocated (where `n' is the maximum row length,
  19278.      not counting `BLOB' columns). A `BLOB' uses 5 to 8 bytes plus the
  19279.      length of the `BLOB' data.
  19280.  
  19281.    * For each table having `BLOB' columns, a buffer is enlarged
  19282.      dynamically to read in larger `BLOB' values. If you scan a table,
  19283.      a buffer as large as the largest `BLOB' value is allocated.
  19284.  
  19285.    * Table handlers for all in-use tables are saved in a cache and
  19286.      managed as a FIFO. Normally the cache has 64 entries. If a table
  19287.      has been used by two running threads at the same time, the cache
  19288.      contains two entries for the table. *Note Table cache::.
  19289.  
  19290.    * A `mysqladmin flush-tables' command closes all tables that are not
  19291.      in use and marks all in-use tables to be closed when the currently
  19292.      executing thread finishes. This will effectively free most in-use
  19293.      memory.
  19294.  
  19295. `ps' and other system status programs may report that `mysqld' uses a
  19296. lot of memory. This may be caused by thread-stacks on different memory
  19297. addresses. For example, the Solaris version of `ps' counts the unused
  19298. memory between stacks as used memory. You can verify this by checking
  19299. available swap with `swap -s'. We have tested `mysqld' with commercial
  19300. memory-leakage detectors, so there should be no memory leaks.
  19301.  
  19302. How MySQL locks tables
  19303. ----------------------
  19304.  
  19305. You can find a discussion about different locking methods in the
  19306. appendix.  *Note Locking methods::.
  19307.  
  19308. All locking in *MySQL* is deadlock-free.  This is managed by always
  19309. requesting all needed locks at once at the beginning of a query and
  19310. always locking the tables in the same order.
  19311.  
  19312. The locking method *MySQL* uses for `WRITE' locks works as follows:
  19313.  
  19314.    * If there are no locks on the table, put a write lock on it.
  19315.  
  19316.    * Otherwise, put the lock request in the write lock queue.
  19317.  
  19318. The locking method *MySQL* uses for `READ' locks works as follows:
  19319.  
  19320.    * If there are no write locks on the table, put a read lock on it.
  19321.  
  19322.    * Otherwise, put the lock request in the read lock queue.
  19323.  
  19324. When a lock is released, the lock is made available to the threads in
  19325. the write lock queue, then to the threads in the read lock queue.
  19326.  
  19327. This means that if you have many updates on a table, `SELECT'
  19328. statements will wait until there are no more updates.
  19329.  
  19330. To work around this for the case where you want to do many `INSERT' and
  19331. `SELECT' operations on a table, you can insert rows in a temporary
  19332. table and update the real table with the records from the temporary
  19333. table once in a while.
  19334.  
  19335. This can be done with the following code:
  19336.      mysql> LOCK TABLES real_table WRITE, insert_table WRITE;
  19337.      mysql> insert into real_table select * from insert_table;
  19338.      mysql> delete from insert_table;
  19339.      mysql> UNLOCK TABLES;
  19340.  
  19341. You can use the `LOW_PRIORITY' options with `INSERT' if you want to
  19342. prioritize retrieval in some specific cases.  *Note `INSERT': INSERT.
  19343.  
  19344. You could also change the locking code in `mysys/thr_lock.c' to use a
  19345. single queue.  In this case, write locks and read locks would have the
  19346. same priority, which might help some applications.
  19347.  
  19348. Table locking issues
  19349. --------------------
  19350.  
  19351. The table locking code in *MySQL* is deadlock free.
  19352.  
  19353. *MySQL* uses table locking (instead of row locking or column locking)
  19354. on all table types, except `BDB' tables, to achieve a very high lock
  19355. speed.  For large tables, table locking is MUCH better than row locking
  19356. for most applications, but there are of course some pitfalls.
  19357.  
  19358. For `BDB' tables, *MySQL* only uses table locking of you explicitely
  19359. lock the table with `LOCK TABLES' or execute an command that will
  19360. modify every row in the table, like `ALTER TABLE'.
  19361.  
  19362. In *MySQL* 3.23.7 and above, you can insert rows into `MyISAM' tables
  19363. at the same time as other threads are reading from the table.  Note
  19364. that currently this only works if there are no holes after deleted rows
  19365. in the table at the time the insert is made.
  19366.  
  19367. Table locking enables many threads to read from a table at the same
  19368. time, but if a thread wants to write to a table, it must first get
  19369. exclusive access.  During the update all other threads that want to
  19370. access this particular table will wait until the update is ready.
  19371.  
  19372. As updates on tables normally are considered to be more important than
  19373. `SELECT', all statements that update a table have higher priority than
  19374. statements that retrieve information from a table. This should ensure
  19375. that updates are not 'starved' because one issues a lot of heavy
  19376. queries against a specific table. (You can change this by using
  19377. LOW_PRIORITY with the statement that does the update or `HIGH_PRIORITY'
  19378. with the `SELECT' statement.
  19379.  
  19380. Starting from *MySQL 3.23.7* one can use the `max_write_lock_count'
  19381. variable to force *MySQL* to temporary give all `SELECT' statements,
  19382. that waits for a table, a higher priority after a specific number of
  19383. inserts on a table.
  19384.  
  19385. Table locking is however not very good under the following senario:
  19386.  
  19387.    * A client issues a `SELECT' that takes a long time to run.
  19388.  
  19389.    * Another client then issues an `UPDATE' on a used table;  This
  19390.      client will wait until the `SELECT' is finished
  19391.  
  19392.    * Another client issues another `SELECT' statement on the same
  19393.      table;  As `UPDATE' has higher priority than `SELECT', this
  19394.      `SELECT' will wait for the `UPDATE' to finish.  It will also wait
  19395.      for the first `SELECT' to finish!
  19396.  
  19397. Some possible solutions to this problem are:
  19398.  
  19399.    * Try to get the `SELECT' statements to run faster;  You may have to
  19400.      create some summary tables to do this.
  19401.  
  19402.    * Start `mysqld' with `--low-priority-updates'.  This will give all
  19403.      statements that update (modify) a table lower priority than a
  19404.      `SELECT' statement. In this case the last `SELECT' statement in
  19405.      the previous scenario would execute before the `INSERT' statement.
  19406.  
  19407.    * You can give a specific `INSERT',`UPDATE' or `DELETE' statement
  19408.      lower priority with the `LOW_PRIORITY' attribute.
  19409.  
  19410.    * Start `mysqld' with a low value for *max_write_lock_count* to give
  19411.      `READ' locks after a certain number of `WRITE' locks.
  19412.  
  19413.    * You can specify that all updates from a specific thread should be
  19414.      done with low priority by using the SQL command: `SET
  19415.      SQL_LOW_PRIORITY_UPDATES=1'.  *Note `SET OPTION': SET OPTION.
  19416.  
  19417.    * You can specify that a specific `SELECT' is very important with the
  19418.      `HIGH_PRIORITY' attribute. *Note `SELECT': SELECT.
  19419.  
  19420.    * If you have problems with `INSERT' combined with `SELECT', switch
  19421.      to use the new `MyISAM' tables as these supports concurrent
  19422.      `SELECT's and `INSERT's.
  19423.  
  19424.    * If you mainly mix `INSERT' and `SELECT' statements, the `DELAYED'
  19425.      attribute to `INSERT' will probably solve your problems.  *Note
  19426.      `INSERT': INSERT.
  19427.  
  19428.    * If you have problems with `SELECT' and `DELETE', the `LIMIT'
  19429.      option to `DELETE' may help. *Note `DELETE': DELETE.
  19430.  
  19431. Get your data as small as possible
  19432. ==================================
  19433.  
  19434. One of the most basic optimization is to get your data (and indexes) to
  19435. take as little space on the disk (and in memory) as possible. This can
  19436. give huge improvements because disk reads are faster and normally less
  19437. main memory will be used. Indexing also takes less resources if done on
  19438. smaller columns.
  19439.  
  19440. *MySQL* supports a lot of different table types and row formats.
  19441. Choosing the right table format may give you a big performance gain.
  19442. *Note Table types::.
  19443.  
  19444. You can get better performance on a table and minimize storage space
  19445. using the techniques listed below:
  19446.  
  19447.    * Use the most efficient (smallest) types possible. *MySQL* has a
  19448.      many specialized types that save disk space and memory.
  19449.  
  19450.    * Use the smaller integer types if possible to get smaller tables.
  19451.      For example, `MEDIUMINT' is often better than `INT'.
  19452.  
  19453.    * Declare columns to be `NOT NULL' if possible. It makes everything
  19454.      faster and you save one bit per column. Note that if you really
  19455.      need `NULL' in your application you should definitely use it, just
  19456.      avoid having it on all columns by default.
  19457.  
  19458.    * If you don't have any variable-length columns (`VARCHAR', `TEXT'
  19459.      or `BLOB' columns), a fixed-size record format is used. This is
  19460.      faster but unfortunately may waste some space.  *Note MyISAM table
  19461.      formats::.
  19462.  
  19463.    * Each table should have as short as possible primary index. This
  19464.      makes identification of one row easy and efficient.
  19465.  
  19466.    * For each table you have to decide which storage/index method to
  19467.      use. *Note Table types::.
  19468.  
  19469.    * Only create the indexes that you really need. Indexes are good for
  19470.      retrieval but bad when you need to store things fast. If you mostly
  19471.      access a table by searching on a combination of columns, make an
  19472.      index on them. The first index part should be the most used
  19473.      column. If you are ALWAYS using many columns you should use the
  19474.      column with more duplicates first to get better compression of the
  19475.      index.
  19476.  
  19477.    * If it's very likely that a column has a unique prefix on the first
  19478.      number of characters, it's better to only index this prefix.
  19479.      *MySQL* supports an index on a part of a character column. Shorter
  19480.      indexes is faster not only because they take less disk space but
  19481.      also because they will give you more hits in the index cache and
  19482.      thus fewer disk seeks. *Note Server parameters::.
  19483.  
  19484.    * In some circumstances it can be beneficial to split a table that is
  19485.      scanned very often into two. This is especially true if it is a
  19486.      dynamic format table and it is possible to use a smaller static
  19487.      format table that can be used to find the relevant rows when
  19488.      scanning the table.
  19489.  
  19490. How *MySQL* uses indexes
  19491. ========================
  19492.  
  19493. Indexes are used to find rows with a specific value of one column fast.
  19494. Without an index *MySQL* has to start with the first record and then
  19495. read through the whole table until it finds the relevent rows. The
  19496. bigger the table, the more this costs. If the table has an index for
  19497. the colums in question, *MySQL* can get fast a position to seek to in
  19498. the middle of the data file without having to look at all the data. If
  19499. a table has 1000 rows this is at least 100 times faster than reading
  19500. sequentially. Note that if you need to access almost all 1000 rows it
  19501. is faster to read sequentially because we then avoid disk seeks.
  19502.  
  19503. All *MySQL* indexes (`PRIMARY', `UNIQUE' and `INDEX') are stored in
  19504. B-trees. Strings are automatically prefix- and end-space compressed.
  19505. *Note `CREATE INDEX': CREATE INDEX.
  19506.  
  19507. Indexes are used to:
  19508.    * Quickly find the rows that match a `WHERE' clause.
  19509.  
  19510.    * Retrieve rows from other tables when performing joins.
  19511.  
  19512.    * Find the `MAX()' or `MIN()' value for a specific indexed column.
  19513.           SELECT MIN(key_part2),MAX(key_part2) FROM table_name where key_part1=10
  19514.  
  19515.    * Sort or group a table if the sorting or grouping is done on a
  19516.      leftmost prefix of a usable key (e.g., `ORDER BY
  19517.      key_part_1,key_part_2 '). The key is read in reverse order if all
  19518.      key parts are followed by `DESC'.
  19519.  
  19520.      The index can also be used even if the `ORDER BY' doesn't match
  19521.      gthe index exactly, as long as all the not used index parts and
  19522.      all the extra are `ORDER BY' columns are constants in the `WHERE'
  19523.      clause. The following queries will use the index to resolve the
  19524.      `ORDER BY' part.
  19525.  
  19526.           SELECT * FROM foo ORDER BY key_part1,key_part2,key_part3;
  19527.           SELECT * FROM foo WHERE column=constant ORDER BY column, key_part1;
  19528.           SELECT * FROM foo WHERE key_part1=const GROUP BY key_part2;
  19529.  
  19530.    * In some cases a query can be optimized to retrieve values without
  19531.      consulting the data file. If all used columns for some table are
  19532.      numeric and form a leftmost prefix for some key, the values may be
  19533.      retrieved from the index tree for greater speed.
  19534.  
  19535.           SELECT key_part3 FROM table_name WHERE key_part1=1
  19536.  
  19537.  
  19538. Suppose you issue the following `SELECT' statement:
  19539.  
  19540.      mysql> SELECT * FROM tbl_name WHERE col1=val1 AND col2=val2;
  19541.  
  19542. If a multiple-column index exists on `col1' and `col2', the appropriate
  19543. rows can be fetched directly. If separate single-column indexes exist
  19544. on `col1' and `col2', the optimizer tries to find the most restrictive
  19545. index by deciding which index will find fewer rows and using that index
  19546. to fetch the rows.
  19547.  
  19548. If the table has a multiple-column index, any leftmost prefix of the
  19549. index can be used by the optimizer to find rows. For example, if you
  19550. have a three-column index on `(col1,col2,col3)', you have indexed
  19551. search capabilities on `(col1)', `(col1,col2)' and `(col1,col2,col3)'.
  19552.  
  19553. *MySQL* can't use a partial index if the columns don't form a leftmost
  19554. prefix of the index.  Suppose you have the `SELECT' statements shown
  19555. below:
  19556.  
  19557.      mysql> SELECT * FROM tbl_name WHERE col1=val1;
  19558.      mysql> SELECT * FROM tbl_name WHERE col2=val2;
  19559.      mysql> SELECT * FROM tbl_name WHERE col2=val2 AND col3=val3;
  19560.  
  19561. If an index exists on `(col1,col2,col3)', only the first query shown
  19562. above uses the index. The second and third queries do involve indexed
  19563. columns, but `(col2)' and `(col2,col3)' are not leftmost prefixes of
  19564. `(col1,col2,col3)'.
  19565.  
  19566. *MySQL* also uses indexes for `LIKE' comparisons if the argument to
  19567. `LIKE' is a constant string that doesn't start with a wildcard
  19568. character.  For example, the following `SELECT' statements use indexes:
  19569.  
  19570.      mysql> select * from tbl_name where key_col LIKE "Patrick%";
  19571.      mysql> select * from tbl_name where key_col LIKE "Pat%_ck%";
  19572.  
  19573. In the first statement, only rows with `"Patrick" <= key_col <
  19574. "Patricl"' are considered.  In the second statement, only rows with
  19575. `"Pat" <= key_col < "Pau"' are considered.
  19576.  
  19577. The following `SELECT' statements will not use indexes:
  19578.      mysql> select * from tbl_name where key_col LIKE "%Patrick%";
  19579.      mysql> select * from tbl_name where key_col LIKE other_col;
  19580.  
  19581. In the first statement, the `LIKE' value begins with a wildcard
  19582. character.  In the second statement, the `LIKE' value is not a constant.
  19583.  
  19584. Searching using `column_name IS NULL' will use indexes if column_name
  19585. is an index.
  19586.  
  19587. *MySQL* normally uses the index that finds least number of rows. An
  19588. index is used for columns that you compare with the following operators:
  19589. `=', `>', `>=', `<', `<=', `BETWEEN' and a `LIKE' with a non-wildcard
  19590. prefix like `'something%''.
  19591.  
  19592. Any index that doesn't span all `AND' levels in the `WHERE' clause is
  19593. not used to optimize the query. In other words:  To be able to use an
  19594. index, a prefix of the index must be used in every `AND' group.
  19595.  
  19596. The following `WHERE' clauses use indexes:
  19597.      ... WHERE index_part1=1 AND index_part2=2 AND other_column=3
  19598.      ... WHERE index=1 OR A=10 AND index=2      /* index = 1 OR index = 2 */
  19599.      ... WHERE index_part1='hello' AND index_part_3=5
  19600.                /* optimized like "index_part1='hello'" */
  19601.      ... WHERE index1=1 and index2=2 or index1=3 and index3=3;
  19602.                /* Can use index on index1 but not on index2 or index 3 */
  19603.  
  19604. These `WHERE' clauses do *NOT* use indexes:
  19605.      ... WHERE index_part2=1 AND index_part3=2  /* index_part_1 is not used */
  19606.      ... WHERE index=1 OR A=10                  /* Index is not used in both AND parts */
  19607.      ... WHERE index_part1=1 OR index_part2=10  /* No index spans all rows */
  19608.  
  19609. Note that in some cases `MySQL' will not use an index, even if one
  19610. would be available.  Some of the cases where this happens are:
  19611.  
  19612.    * If the use of the index, would require *MySQL* to access more than
  19613.      30 % of the rows in the table.  (In this case a table scan is
  19614.      probably much faster as this will require us to do much fewer
  19615.      seeks).  Note that if you with such a query use `LIMIT' to only
  19616.      retrieve part of the rows, *MySQL* will use an index anyway as it
  19617.      can this way much more quickly find the few rows to return in the
  19618.      result.
  19619.  
  19620. Speed of queries that access or update data
  19621. ===========================================
  19622.  
  19623. First, one thing that affects all queries: The more complex permission
  19624. system setup you have, the more overhead you get.
  19625.  
  19626. If you do not have any `GRANT' statements done *MySQL* will optimize
  19627. the permission checking somewhat. So if you have a very high volume it
  19628. may be worth the time to avoid grants. Otherwise more permission check
  19629. results in a larger overhead.
  19630.  
  19631. If your problem is with some explicit *MySQL* function, you can always
  19632. time this in the *MySQL* client:
  19633.  
  19634.      mysql> select benchmark(1000000,1+1);
  19635.      +------------------------+
  19636.      | benchmark(1000000,1+1) |
  19637.      +------------------------+
  19638.      |                      0 |
  19639.      +------------------------+
  19640.      1 row in set (0.32 sec)
  19641.  
  19642. The above shows that *MySQL* can execute 1,000,000 `+' expressions in
  19643. 0.32 seconds on a `PentiumII 400MHz'.
  19644.  
  19645. All *MySQL* functions should be very optimized, but there may be some
  19646. exceptions and the `benchmark(loop_count,expression)' is a great tool
  19647. to find out if this is a problem with your query.
  19648.  
  19649. Estimating query performance
  19650. ----------------------------
  19651.  
  19652. In most cases you can estimate the performance by counting disk seeks.
  19653. For small tables you can usually find the row in 1 disk seek (as the
  19654. index is probably cached).  For bigger tables, you can estimate that,
  19655. (using B++ tree indexes), you will need: `log(row_count) /
  19656. log(index_block_length / 3 * 2 / (index_length + data_pointer_length)) +
  19657. 1' seeks to find a row.
  19658.  
  19659. In *MySQL* an index block is usually 1024 bytes and the data pointer is
  19660. usually 4 bytes, which gives for a 500,000 row table with a index
  19661. length of 3 (medium integer) gives you:
  19662. `log(500,000)/log(1024/3*2/(3+4)) + 1' = 4 seeks.
  19663.  
  19664. As the above index would require about 500,000 * 7 * 3/2 = 5.2M,
  19665. (assuming that the index buffers are filled to 2/3 (which is typical)
  19666. you will probably have much of the index in memory and you will probably
  19667. only need 1-2 calls to read data from the OS to find the row.
  19668.  
  19669. For writes you will however need 4 seek requests (as above) to find
  19670. where to place the new index and normally 2 seeks to update the index
  19671. and write the row.
  19672.  
  19673. Note that the above doesn't mean that your application will slowly
  19674. degenerate by N log N!  As long as everything is cached by the OS or SQL
  19675. server things will only go marginally slower while the table gets
  19676. bigger. After the data gets too big to be cached, things will start to
  19677. go much slower until your applications is only bound by disk-seeks
  19678. (which increase by N log N). To avoid this, increase the index cache as
  19679. the data grows. *Note Server parameters::.
  19680.  
  19681. Speed of `SELECT' queries
  19682. -------------------------
  19683.  
  19684. In general, when you want to make a slow `SELECT ... WHERE' faster, the
  19685. first thing to check is whether or not you can add an index. *Note
  19686. *MySQL* indexes: MySQL indexes. All references between different tables
  19687. should usually be done with indexes. You can use the `EXPLAIN' command
  19688. to determine which indexes are used for a `SELECT'.  *Note `EXPLAIN':
  19689. EXPLAIN.
  19690.  
  19691. Some general tips:
  19692.  
  19693.    * To help *MySQL* optimize queries better, run `myisamchk --analyze'
  19694.      on a table after it has been loaded with relevant data. This
  19695.      updates a value for each index part that indicates the average
  19696.      number of rows that have the same value.  (For unique indexes,
  19697.      this is always 1, of course.).  *MySQL* will use this to decide
  19698.      which index to choose when you connect two tables with 'a
  19699.      non-constant expression'.  You can check the result from the
  19700.      `analyze' run by doing `SHOW INDEX FROM table_name' and examining
  19701.      the `Cardinality' column.
  19702.  
  19703.    * To sort an index and data according to an index, use `myisamchk
  19704.      --sort-index --sort-records=1' (if you want to sort on index 1).
  19705.      If you have a unique index from which you want to read all records
  19706.      in order according to that index, this is a good way to make that
  19707.      faster.  Note however that this sorting isn't written optimally
  19708.      and will take a long time for a large table!
  19709.  
  19710. How MySQL optimizes `WHERE' clauses
  19711. -----------------------------------
  19712.  
  19713. The `WHERE' optimizations are put in the `SELECT' part here because
  19714. they are mostly used with `SELECT', but the same optimizations apply for
  19715. `WHERE' in `DELETE' and `UPDATE' statements.
  19716.  
  19717. Also note that this section is incomplete. *MySQL* does many
  19718. optimizations and we have not had time to document them all.
  19719.  
  19720. Some of the optimizations performed by *MySQL* are listed below:
  19721.  
  19722.    * Removal of unnecessary parentheses:
  19723.              ((a AND b) AND c OR (((a AND b) AND (c AND d))))
  19724.           -> (a AND b AND c) OR (a AND b AND c AND d)
  19725.  
  19726.    * Constant folding:
  19727.              (a<b AND b=c) AND a=5
  19728.           -> b>5 AND b=c AND a=5
  19729.  
  19730.    * Constant condition removal (needed because of constant folding):
  19731.              (B>=5 AND B=5) OR (B=6 AND 5=5) OR (B=7 AND 5=6)
  19732.           -> B=5 OR B=6
  19733.  
  19734.    * Constant expressions used by indexes are evaluated only once.
  19735.  
  19736.    * `COUNT(*)' on a single table without a `WHERE' is retrieved
  19737.      directly from the table information.  This is also done for any
  19738.      `NOT NULL' expression when used with only one table.
  19739.  
  19740.    * Early detection of invalid constant expressions. *MySQL* quickly
  19741.      detects that some `SELECT' statements are impossible and returns
  19742.      no rows.
  19743.  
  19744.    * `HAVING' is merged with `WHERE' if you don't use `GROUP BY' or
  19745.      group functions (`COUNT()', `MIN()'...)
  19746.  
  19747.    * For each sub-join, a simpler `WHERE' is constructed to get a fast
  19748.      `WHERE' evaluation for each sub-join and also to skip records as
  19749.      soon as possible.
  19750.  
  19751.    * All constant tables are read first, before any other tables in the
  19752.      query.  A constant table is:
  19753.         - An empty table or a table with 1 row.
  19754.  
  19755.         - A table that is used with a `WHERE' clause on a `UNIQUE'
  19756.           index, or a `PRIMARY KEY', where all index parts are used
  19757.           with constant expressions and the index parts are defined as
  19758.           `NOT NULL'.
  19759.      All the following tables are used as constant tables:
  19760.           mysql> SELECT * FROM t WHERE primary_key=1;
  19761.           mysql> SELECT * FROM t1,t2
  19762.                      WHERE t1.primary_key=1 AND t2.primary_key=t1.id;
  19763.  
  19764.    * The best join combination to join the tables is found by trying all
  19765.      possibilities. If all columns in `ORDER BY' and in `GROUP BY' come
  19766.      from the same table, then this table is preferred first when
  19767.      joining.
  19768.  
  19769.    * If there is an `ORDER BY' clause and a different `GROUP BY' clause,
  19770.      or if the `ORDER BY' or `GROUP BY' contains columns from tables
  19771.      other than the first table in the join queue, a temporary table is
  19772.      created.
  19773.  
  19774.    * If you use `SQL_SMALL_RESULT', *MySQL* will use an in-memory
  19775.      temporary table.
  19776.  
  19777.    * As `DISTINCT' is converted to a `GROUP BY' on all columns,
  19778.      `DISTINCT' combined with `ORDER BY' will in many cases also need a
  19779.      temporary table.
  19780.  
  19781.    * Each table index is queried and the best index that spans fewer
  19782.      than 30% of the rows is used. If no such index can be found, a
  19783.      quick table scan is used.
  19784.  
  19785.    * In some cases, *MySQL* can read rows from the index without even
  19786.      consulting the data file.  If all columns used from the index are
  19787.      numeric, then only the index tree is used to resolve the query.
  19788.  
  19789.    * Before each record is output, those that do not match the `HAVING'
  19790.      clause are skipped.
  19791.  
  19792. Some examples of queries that are very fast:
  19793.  
  19794.      mysql> SELECT COUNT(*) FROM tbl_name;
  19795.      mysql> SELECT MIN(key_part1),MAX(key_part1) FROM tbl_name;
  19796.      mysql> SELECT MAX(key_part2) FROM tbl_name
  19797.                 WHERE key_part_1=constant;
  19798.      mysql> SELECT ... FROM tbl_name
  19799.                 ORDER BY key_part1,key_part2,... LIMIT 10;
  19800.      mysql> SELECT ... FROM tbl_name
  19801.                 ORDER BY key_part1 DESC,key_part2 DESC,... LIMIT 10;
  19802.  
  19803. The following queries are resolved using only the index tree (assuming
  19804. the indexed columns are numeric):
  19805.  
  19806.      mysql> SELECT key_part1,key_part2 FROM tbl_name WHERE key_part1=val;
  19807.      mysql> SELECT COUNT(*) FROM tbl_name
  19808.                 WHERE key_part1=val1 AND key_part2=val2;
  19809.      mysql> SELECT key_part2 FROM tbl_name GROUP BY key_part1;
  19810.  
  19811. The following queries use indexing to retrieve the rows in sorted order
  19812. without a separate sorting pass:
  19813.  
  19814.      mysql> SELECT ... FROM tbl_name ORDER BY key_part1,key_part2,...
  19815.      mysql> SELECT ... FROM tbl_name ORDER BY key_part1 DESC,key_part2 DESC,...
  19816.  
  19817. How MySQL optimizes `LEFT JOIN'
  19818. -------------------------------
  19819.  
  19820. `A LEFT JOIN B' is in *MySQL* implemented as follows:
  19821.  
  19822.    * The table `B' is set to be dependent on table `A' and all tables
  19823.      that `A' is dependent on.
  19824.  
  19825.    * The table `A' is set to be dependent on all tables (except `B')
  19826.      that are used in the `LEFT JOIN' condition.
  19827.  
  19828.    * All `LEFT JOIN' conditions are moved to the `WHERE' clause.
  19829.  
  19830.    * All standard join optimizations are done, with the exception that
  19831.      a table is always read after all tables it is dependent on.  If
  19832.      there is a circular dependence then *MySQL* will issue an error.
  19833.  
  19834.    * All standard `WHERE' optimizations are done.
  19835.  
  19836.    * If there is a row in `A' that matches the `WHERE' clause, but there
  19837.      wasn't any row in `B' that matched the `LEFT JOIN' condition, then
  19838.      an extra `B' row is generated with all columns set to `NULL'.
  19839.  
  19840.    * If you use `LEFT JOIN' to find rows that doesn't exist in some
  19841.      table and you have the following test: `column_name IS NULL' in the
  19842.      `WHERE' part, where column_name is a column that is declared as
  19843.      `NOT NULL', then `MySQL' will stop searching after more rows (for
  19844.      a particular key combination) after it has found one row that
  19845.      matches the `LEFT JOIN' condition.
  19846.  
  19847. The table read order forced by `LEFT JOIN' and `STRAIGHT JOIN' will help
  19848. the join optimizer (which calculates in which order tables should be
  19849. joined) to do its work much more quickly as there are fewer table
  19850. permutations to check.
  19851.  
  19852. Note that the above means that if you do a query of type:
  19853.  
  19854.      SELECT * FROM a,b LEFT JOIN c ON (c.key=a.key) LEFT JOIN d (d.key=a.key) WHERE b.key=d.key
  19855.  
  19856. Then *MySQL* will do a full scan on `b' as the `LEFT JOIN' will force
  19857. it to be read before `d'.
  19858.  
  19859. The fix in this case is to change the query to:
  19860.  
  19861.      SELECT * FROM b,a LEFT JOIN c ON (c.key=a.key) LEFT JOIN d (d.key=a.key) WHERE b.key=d.key
  19862.  
  19863. How MySQL optimizes `LIMIT'
  19864. ---------------------------
  19865.  
  19866. In some cases *MySQL* will handle the query differently when you are
  19867. using `LIMIT #' and not using `HAVING':
  19868.  
  19869.    * If you are selecting only a few rows with `LIMIT', *MySQL* will
  19870.      use indexes in some cases when it normally would prefer to do a
  19871.      full table scan.
  19872.  
  19873.    * If you use `LIMIT #' with `ORDER BY', *MySQL* will end the sorting
  19874.      as soon as it has found the first `#' lines instead of sorting the
  19875.      whole table.
  19876.  
  19877.    * When combining `LIMIT #' with `DISTINCT', *MySQL* will stop as
  19878.      soon as it finds `#' unique rows.
  19879.  
  19880.    * In some cases a `GROUP BY' can be resolved by reading the key in
  19881.      order (or do a sort on the key) and then calculate summaries until
  19882.      the key value changes.  In this case `LIMIT #' will not calculate
  19883.      any unnecessary `GROUP BY''s.
  19884.  
  19885.    * As soon as *MySQL* has sent the first `#' rows to the client, it
  19886.      will abort the query.
  19887.  
  19888.    * `LIMIT 0' will always quickly return an empty set.  This is useful
  19889.      to check the query and to get the column types of the result
  19890.      columns.
  19891.  
  19892.    * The size of temporary tables uses the `LIMIT #' to calculate how
  19893.      much space is needed to resolve the query.
  19894.  
  19895. Speed of `INSERT' queries
  19896. -------------------------
  19897.  
  19898. The time to insert a record consists approximately of:
  19899.  
  19900.    * Connect:                 (3)
  19901.  
  19902.    * Sending query to server: (2)
  19903.  
  19904.    * Parsing query:           (2)
  19905.  
  19906.    * Inserting record:        (1 x size of record)
  19907.  
  19908.    * Inserting indexes:       (1 x number of indexes)
  19909.  
  19910.    * Close:                   (1)
  19911.  
  19912. Where the numbers are somewhat proportional to the overall time. This
  19913. does not take into consideration the initial overhead to open tables
  19914. (which is done once for each concurrently-running query).
  19915.  
  19916. The size of the table slows down the insertion of indexes by N log N
  19917. (B-trees).
  19918.  
  19919. Some ways to speed up inserts:
  19920.  
  19921.    * If you are inserting many rows from the same client at the same
  19922.      time use multiple value lists `INSERT' statements. This is much
  19923.      faster (many times in some cases) than using separate `INSERT'
  19924.      statements.
  19925.  
  19926.    * If you are inserting a lot of rows from different clients, you can
  19927.      get higher speed by using the `INSERT DELAYED' statement. *Note
  19928.      `INSERT': INSERT.
  19929.  
  19930.    * Note that with `MyISAM' you can insert rows at the same time
  19931.      `SELECT's are running if there are no deleted rows in the tables.
  19932.  
  19933.    * When loading a table from a text file, use `LOAD DATA INFILE'. This
  19934.      is usually 20 times faster than using a lot of `INSERT' statements.
  19935.      *Note `LOAD DATA': LOAD DATA.
  19936.  
  19937.    * It is possible with some extra work to make `LOAD DATA INFILE' run
  19938.      even faster when the table has many indexes. Use the following
  19939.      procedure:
  19940.  
  19941.        1. Optionally create the table with `CREATE TABLE'. For example
  19942.           using `mysql' or Perl-DBI.
  19943.  
  19944.        2. Execute a `FLUSH TABLES' statement or the shell command
  19945.           `mysqladmin flush-tables'.
  19946.  
  19947.        3. Use `myisamchk --keys-used=0 -rq /path/to/db/tbl_name'. This
  19948.           will remove all usage of all indexes from the table.
  19949.  
  19950.        4. Insert data into the table with `LOAD DATA INFILE'. This will
  19951.           not update any indexes and will therefore be very fast.
  19952.  
  19953.        5. If you are going to only read the table in the future, run
  19954.           `myisampack' on it to make it smaller. *Note Compressed
  19955.           format::.
  19956.  
  19957.        6. Recreate the indexes with `myisamchk -r -q
  19958.           /path/to/db/tbl_name'. This will create the index tree in
  19959.           memory before writing it to disk, which is much faster
  19960.           because it avoid lots of disk seeks. The resulting index tree
  19961.           is also perfectly balanced.
  19962.  
  19963.        7. Execute a `FLUSH TABLES' statement or the shell command
  19964.           `mysqladmin flush-tables'.
  19965.  
  19966.      This procedure will be built into `LOAD DATA INFILE' in some future
  19967.      version of MySQL.
  19968.  
  19969.    * You can speed up insertions by locking your tables:
  19970.  
  19971.           mysql> LOCK TABLES a WRITE;
  19972.           mysql> INSERT INTO a VALUES (1,23),(2,34),(4,33);
  19973.           mysql> INSERT INTO a VALUES (8,26),(6,29);
  19974.           mysql> UNLOCK TABLES;
  19975.  
  19976.      The main speed difference is that the index buffer is flushed to
  19977.      disk only once, after all `INSERT' statements have completed.
  19978.      Normally there would be as many index buffer flushes as there are
  19979.      different `INSERT' statements. Locking is not needed if you can
  19980.      insert all rows with a single statement.
  19981.  
  19982.      Locking will also lower the total time of multi-connection tests,
  19983.      but the maximum wait time for some threads will go up (because
  19984.      they wait for locks).  For example:
  19985.  
  19986.           thread 1 does 1000 inserts
  19987.           thread 2, 3, and 4 does 1 insert
  19988.           thread 5 does 1000 inserts
  19989.  
  19990.      If you don't use locking, 2, 3 and 4 will finish before 1 and 5.
  19991.      If you use locking, 2, 3 and 4 probably will not finish before 1
  19992.      or 5, but the total time should be about 40% faster.
  19993.  
  19994.      As `INSERT', `UPDATE' and `DELETE' operations are very fast in
  19995.      *MySQL*, you will obtain better overall performance by adding
  19996.      locks around everything that does more than about 5 inserts or
  19997.      updates in a row.  If you do very many inserts in a row, you could
  19998.      do a `LOCK TABLES' followed by a `UNLOCK TABLES' once in a while
  19999.      (about each 1000 rows) to allow other threads access to the table.
  20000.      This would still result in a nice performance gain.
  20001.  
  20002.      Of course, `LOAD DATA INFILE' is much faster still for loading
  20003.      data.
  20004.  
  20005. To get some more speed for both `LOAD DATA INFILE' and `INSERT',
  20006. enlarge the key buffer. *Note Server parameters::.
  20007.  
  20008. Speed of `UPDATE' queries
  20009. -------------------------
  20010.  
  20011. Update queries are optimized as a `SELECT' query with the additional
  20012. overhead of a write. The speed of the write is dependent on the size of
  20013. the data that is being updated and the number of indexes that are
  20014. updated.  Indexes that are not changed will not be updated.
  20015.  
  20016. Also another way to get fast updates is to delay updates and then do
  20017. many updates in a row later. Doing many updates in a row is much quicker
  20018. than doing one at a time if you lock the table.
  20019.  
  20020. Note that, with dynamic record format, updating a record to a longer
  20021. total length may split the record.  So if you do this often it is very
  20022. important to `OPTIMIZE TABLE' sometimes.  *Note `OPTIMIZE TABLE':
  20023. OPTIMIZE TABLE.
  20024.  
  20025. Speed of `DELETE' queries
  20026. -------------------------
  20027.  
  20028. The time to delete a record is exactly proportional to the number of
  20029. indexes. To delete records more quickly, you can increase the size of
  20030. the index cache. *Note Server parameters::.
  20031.  
  20032. It's also much faster to remove all rows than to remove a big part of
  20033. the rows from a table.
  20034.  
  20035. Other optimization tips
  20036. =======================
  20037.  
  20038. Unsorted tips for faster systems:
  20039.  
  20040.    * Use persistent connections to the database to avoid the connection
  20041.      overhead. If you can't use persistent connections and you are
  20042.      doing a lot of new connections to the database, you may want to
  20043.      change the value of the `thread_cache_size' variable. *Note Server
  20044.      parameters::.
  20045.  
  20046.    * Always check that all your queries really use the indexes you have
  20047.      created in the tables. In *MySQL* you can do this with the
  20048.      `EXPLAIN' command. *Note Explain: (manual)EXPLAIN.
  20049.  
  20050.    * Try to avoid complex `SELECT' queries on tables that are updated a
  20051.      lot. This is to avoid problems with table locking.
  20052.  
  20053.    * The new `MyISAM' tables can insert rows in a table without deleted
  20054.      rows at the same time another table is reading from it.  If this
  20055.      is important for you, you should consider methods where you don't
  20056.      have to delete rows or run `OPTIMIZE TABLE' after you have deleted
  20057.      a lot of rows.
  20058.  
  20059.    * In some cases it may make sense to introduce a column that is
  20060.      'hashed' based on information from other columns. If this column
  20061.      is short and reasonably unique it may be much faster than a big
  20062.      index on many columns. In *MySQL* its very easy to use this extra
  20063.      column: `SELECT * FROM table_name WHERE hash=MP5(concat(col1,col2))
  20064.      AND col_1='constant' AND col_2='constant''
  20065.  
  20066.    * For tables that changes a lot you should try to avoid all `VARCHAR'
  20067.      or `BLOB' columns. You will get dynamic row length as soon as you
  20068.      are using a single `VARCHAR' or `BLOB' columns. *Note Table
  20069.      types::.
  20070.  
  20071.    * It's not normally useful to split a table into different tables
  20072.      just because the rows gets 'big'. To access a row, the biggest
  20073.      performance hit is the disk seek to find the first byte of the
  20074.      row. After finding the data most new disks can read the whole row
  20075.      fast enough for most applications. The only cases it really
  20076.      matters to split up a table is if its a dynamic row size table
  20077.      (see above) that you can change to a fixed row size. Or if you
  20078.      very often need to scan the table and don't need most of the
  20079.      columns. *Note Table types::.
  20080.  
  20081.    * If you very often need to calculate things based on information
  20082.      from a lot of rows (like counts of things) it's probably much
  20083.      better to introduce a new table and update the counter in real
  20084.      time. An update of type `UPDATE table set count=count+1 where
  20085.      index_column=constant' is very fast!
  20086.  
  20087.      This is really important when you use databases like *MySQL* that
  20088.      only has table locking (multiple readers / single writers). This
  20089.      will also give better performance with most databases as the row
  20090.      locking manager in this case will have less to do.
  20091.  
  20092.    * If you need to collect statistics from big log tables, use summary
  20093.      tables instead of scanning the whole table. Maintaining the
  20094.      summaries should be much faster than trying to do statistics
  20095.      'live'. It's much faster to re-generate new summary tables from
  20096.      the logs when things change (depending on business decisions) than
  20097.      to have to change the running application!
  20098.  
  20099.    * If possible one should classify reports as 'live' or 'statistical',
  20100.      where data needed for statistical reports are only generated based
  20101.      on summary tables that are generated from the actual data.
  20102.  
  20103.    * Take advantage of the fact that columns have default values. Insert
  20104.      values explicitly only when the value to be inserted differs from
  20105.      the default. This reduces the parsing that *MySQL* need to do and
  20106.      improves the insert speed.
  20107.  
  20108.    * In some cases it's convenient to pack and store data into a blob.
  20109.      In this case you have to add some extra code in your appliction to
  20110.      pack/unpack things in the blob but this may save a lot of accesses
  20111.      at some stage.  This is practical when you have data that doesn't
  20112.      conform to a static table structure.
  20113.  
  20114.    * Normally you should try to keep all data non-redundant (what is
  20115.      called 3rd normal form in database theory), but you should not be
  20116.      afraid of duplicating things or creating summary tables if you
  20117.      need these to gain more speed.
  20118.  
  20119.    * Stored procedures or UDF (user defined functions) may be a good
  20120.      way to get more performance.  In this case you should however
  20121.      always have a way to do this some other (slower) way if you use
  20122.      some database that doesn't support this.
  20123.  
  20124.    * You can always gain something by caching queries/answers in your
  20125.      application and trying to do many inserts/updates at the same
  20126.      time.  If your database supports lock tables (like *MySQL* and
  20127.      Oracle), this should help to ensure that the index cache is only
  20128.      flushed once after all updates.
  20129.  
  20130.    * Use `INSERT /*! DELAYED */' when you do not need to know when your
  20131.      data is written. This speeds things up because many records can be
  20132.      written with a single disk write.
  20133.  
  20134.    * Use `INSERT /*! LOW_PRIORITY */' when you want your selects to be
  20135.      more important.
  20136.  
  20137.    * Use `SELECT /*! HIGH_PRIORITY */' to get selects that jump the
  20138.      queue. That is the select is done even if there is somebody
  20139.      waiting to do a write.
  20140.  
  20141.    * Use the multi-line `INSERT' statement to store many rows with one
  20142.      SQL command (many SQL servers supports this).
  20143.  
  20144.    * Use `LOAD DATA INFILE' to load bigger amounts of data. This is
  20145.      faster than normal inserts and will be even faster when `myisamchk'
  20146.      is integrated in `mysqld'.
  20147.  
  20148.    * Use `AUTO_INCREMENT' columns to make unique values.
  20149.  
  20150.    * Use `OPTIMIZE TABLE' once in a while to avoid fragmentation when
  20151.      using dynamic table format. *Note `OPTIMIZE TABLE': OPTIMIZE TABLE.
  20152.  
  20153.    * Use `HEAP' tables to get more speed when possible. *Note Table
  20154.      types::.
  20155.  
  20156.    * When using a normal web server setup, images should be stored as
  20157.      files. That is, store only a file reference in the database.  The
  20158.      main reason for this is that a normal web server is much better at
  20159.      caching files than database contents. So it it's much easier to
  20160.      get a fast system if you are using files.
  20161.  
  20162.    * Use in memory tables for non-critical data that are accessed often
  20163.      (like information about the last shown banner for users that
  20164.      doesn't have cookies).
  20165.  
  20166.    * Columns with identical information in different tables should be
  20167.      declared identical and have identical names. Before version 3.23
  20168.      you got slow joins otherwise.
  20169.  
  20170.      Try to keep the names simple (use `name' instead of
  20171.      `customer_name' in the customer table). To make your names portable
  20172.      to other SQL servers you should keep them shorter than 18
  20173.      characters.
  20174.  
  20175.    * If you need REALLY high speed you should take a look at the low
  20176.      level interfaces for data storage that the different SQL servers
  20177.      support!  For example by accessing the *MySQL* `MyISAM' directly
  20178.      you could get a speed increase of 2-5 times compared to using the
  20179.      SQL interface.  To be able to do this the data must however be on
  20180.      the same server as the application and usually it should only be
  20181.      accessed by one process (because external file locking is really
  20182.      slow).  One could eliminate the above problems by introducing
  20183.      low-level `MyISAM' commands in the *MySQL* server (this could be
  20184.      one easy way to get more performance if needed).  By carefully
  20185.      designing the database interface it should be quite easy to
  20186.      support this types of optimization.
  20187.  
  20188.    * In many cases it's faster to access data from a database (using a
  20189.      live connection) than accessing a text file, just because the
  20190.      database is likely to be more compact than the text file (if you
  20191.      are using numerical data) and this will involve fewer disk
  20192.      accesses.  You will also save code because you don't have to parse
  20193.      your text files to find line and column boundaries.
  20194.  
  20195.    * You can also use replication to speed things up. *Note
  20196.      Replication::.
  20197.  
  20198.    * Declaring a table with `DELAY_KEY_WRITE=1' will make the updating
  20199.      of indexes faster as these are not logged to disk until the file
  20200.      is closed.  The downside is that you should run `myisamchk' on
  20201.      these tables before you start `mysqld' to ensure that they are
  20202.      okay if something killed `mysqld' in the middle.  As the key
  20203.      information can always be generated from the data you should not
  20204.      lose anything by using `DELAY_KEY_WRITE'.
  20205.  
  20206. Using your own benchmarks
  20207. =========================
  20208.  
  20209. You should definately benchmark your application and database to find
  20210. out where the bottlenecks are.  By fixing it (or by replacing the
  20211. bottleneck with a 'dummy module') you can then easily identify the next
  20212. bottleneck (and so on).  Even if the overall performance for your
  20213. application is sufficient you should at least make a plan for each
  20214. bottleneck, and decide how to solve it if someday you really need the
  20215. extra performance.
  20216.  
  20217. For an example of portable benchmark programs look at the *MySQL*
  20218. benchmark suite. *Note *MySQL* Benchmarks: MySQL Benchmarks. You can
  20219. take any program from this suite and modify it for your needs. By doing
  20220. this, you can try different solutions to your problem and test which is
  20221. really the fastest solution for you.
  20222.  
  20223. It is very common that some problems only occur when the system is very
  20224. heavily loaded. We have had many customers who contact us when they
  20225. have a (tested) system in production and have encountered load
  20226. problems. In every one of these cases so far it has been problems with
  20227. basic design (table scans are NOT good at high load) or OS/Library
  20228. issues. Most of this would be a *LOT* easier to fix if the systems were
  20229. not already in production.
  20230.  
  20231. To avoid problems like this you should put some effort into benchmarking
  20232. your whole application under the worst possible load! You can use
  20233. Sasha's recent hack for this - mysql-super-smack
  20234. (http://www.mysql.com/Downloads/Contrib/mysql-bench-0.6.tar.gz).  As
  20235. the name suggests, it can bring your system down to its knees if you
  20236. ask it, so make sure to use it only on your developement systems.
  20237.  
  20238. Design choices
  20239. ==============
  20240.  
  20241. *MySQL* keeps row data and index data in separate files. Many (almost
  20242. all) other databases mix row and index data in the same file. We
  20243. believe that the *MySQL* choice is better for a very wide range of
  20244. modern systems.
  20245.  
  20246. Another way to store the row data is to keep the information for each
  20247. column in a separate area (examples are SDBM and Focus). This will
  20248. cause a performance hit for every query that accesses more than one
  20249. column. Because this degenerates so quickly when more than one column
  20250. is accessed, we believe that this model is not good for general purpose
  20251. databases.
  20252.  
  20253. The more common case is that the index and data are stored together
  20254. (like in Oracle/Sybase et al). In this case you will find the row
  20255. information at the leaf page of the index. The good thing with this
  20256. layout is that it, in many cases, depending on how well the index is
  20257. cached, saves a disk read.  The bad things with this layout is:
  20258.  
  20259. *
  20260.      Table scanning is much slower because you have to read through the
  20261.      indexes to get at the data.
  20262.  
  20263. *
  20264.      You can't use only the index table to retrieve data for a query.
  20265.  
  20266. *
  20267.      You lose a lot of space as you must duplicate indexes from the
  20268.      nodes (as you can't store the row in the nodes).
  20269.  
  20270. *
  20271.      Deletes will degenerate the table over time (as indexes in nodes
  20272.      are usually not updated on delete).
  20273.  
  20274. *
  20275.      It's harder to cache ONLY the index data.
  20276.  
  20277. MySQL design limitations/tradeoffs
  20278. ==================================
  20279.  
  20280. Because *MySQL* uses extremely fast table locking (multiple readers /
  20281. single writers) the biggest remaining problem is a mix of a steady
  20282. stream of inserts and slow selects on the same table.
  20283.  
  20284. We believe that for a huge number of systems the extremely fast
  20285. performance in other cases make this choice a win. This case is usually
  20286. also possible to solve by having multiple copies of the table, but it
  20287. takes more effort and hardware.
  20288.  
  20289. We are also working on some extensions to solve this problem for some
  20290. common application niches.
  20291.  
  20292. Portability
  20293. ===========
  20294.  
  20295. Because all SQL servers implement different parts of SQL, it takes work
  20296. to write portable SQL applications. For very simple selects/inserts it
  20297. is very easy but the more you need the harder it gets. If you want an
  20298. application that is fast with many databases it becomes even harder!
  20299.  
  20300. To make a complex application portable you need to choose a number of
  20301. SQL servers that it should work with.
  20302.  
  20303. You can use the *MySQL* crash-me program/web-page
  20304. `http://www.mysql.com/information/crashme/choose.php' to find functions,
  20305. types and limits you can use with a selection of database servers.
  20306. Crash-me now tests far from everything possible but it is still
  20307. comprehensive with about 450 things tested.
  20308.  
  20309. For example, you shouldn't have column names longer than 18 characters
  20310. if you want to be able to use Informix or DB2.
  20311.  
  20312. Both the *MySQL* benchmarks and crash-me programs are very
  20313. database-independent.  By taking a look at how we have handled this, you
  20314. can get a feeling of what you have to do to write your application
  20315. database-independent.  The benchmarks themselves can be found in the
  20316. `sql-bench' directory in the *MySQL* source distribution. They are
  20317. written in Perl with DBI database interface (which solves the access
  20318. part of the problem).
  20319.  
  20320. See `http://www.mysql.com/information/benchmarks.html' the results from
  20321. this benchmark.
  20322.  
  20323. As you can see in these results all databases have some weak points.
  20324. That is, they have different design compromises that lead to different
  20325. behavior.
  20326.  
  20327. If you strive for database independence you need to get a good feeling
  20328. of each SQL server's bottlenecks. *MySQL* is VERY fast in retrieving
  20329. and updating things, but will have a problem in mixing slow
  20330. readers/writers on the same table. Oracle on the other hand has a big
  20331. problem when you try to access rows that you have recently updated
  20332. (until they are flushed to disk). Transaction databases in general are
  20333. not very good at generating summary tables from log tables as in this
  20334. case row locking is almost useless.
  20335.  
  20336. To get your application _really_ database-independent you need to define
  20337. an easy extendable interface through which you manipulate your data. As
  20338. C++ is available on most systems, it makes sense to use a C++ classes
  20339. interface to the databases.
  20340.  
  20341. If you use some specific feature for some database (like the `REPLACE'
  20342. command in *MySQL*), you should code a method for the other SQL servers
  20343. to implement the same feature (but slower).  With *MySQL* you can use
  20344. the `/*!  */' syntax to add *MySQL* specific keywords to a query.  The
  20345. code inside `/**/' will be treated as a comment (ignored) by most other
  20346. SQL servers.
  20347.  
  20348. If REAL high performance is more important than exactness, like in some
  20349. web applications, a possibility is to create an application layer that
  20350. caches all results to give you even higher performance. By letting old
  20351. results 'expire' after a while you can keep the cache reasonably fresh.
  20352. This is quite nice in case of extremely high load, in which case you
  20353. can dynamically increase the cache and set the expire timeout higher
  20354. until things get back to normal.
  20355.  
  20356. In this case the table creation information should contain information
  20357. of the initial size of the cache and how often the table should normally
  20358. be refreshed.
  20359.  
  20360. What have we used MySQL for?
  20361. ============================
  20362.  
  20363. During *MySQL* initial development, the features of *MySQL* were made
  20364. to fit our largest customer. They handle data warehousing for a couple
  20365. of the biggest retailers in Sweden.
  20366.  
  20367. From all stores, we get weekly summaries of all bonus card transactions
  20368. and we are expected to provide useful information for the store owners
  20369. to help them find how their advertisement campaigns are affecting their
  20370. customers.
  20371.  
  20372. The data is quite huge (about 7 million summary transactions per month)
  20373. and we have data for 4-10 years that we need to present to the users.
  20374. We got weekly requests from the customers that they want to get
  20375. 'instant' access to new reports from this data.
  20376.  
  20377. We solved this by storing all information per month in compressed
  20378. 'transaction' tables. We have a set of simple macros (script) that
  20379. generates summary tables grouped by different criteria (product group,
  20380. customer id, store ...) from the transaction tables.  The reports are
  20381. web pages that are dynamically generated by a small Perl script that
  20382. parses a web page, executes the SQL statements in it and inserts the
  20383. results. We would have used PHP or mod_perl instead but they were not
  20384. available at that time.
  20385.  
  20386. For graphical data we wrote a simple tool in `C' that can produce GIFs
  20387. based on the result of a SQL query (with some processing of the
  20388. result). This is also dynamically executed from the Perl script that
  20389. parses the `HTML' files.
  20390.  
  20391. In most cases a new report can simply be done by copying an existing
  20392. script and modifying the SQL query in it.  In some cases we will need to
  20393. add more fields to an existing summary table or generate a new one, but
  20394. this is also quite simple as we keep all transactions tables on disk.
  20395. (Currently we have at least 50G of transactions tables and 200G of other
  20396. customer data).
  20397.  
  20398. We also let our customers access the summary tables directly with ODBC
  20399. so that the advanced users can themselves experiment with the data.
  20400.  
  20401. We haven't had any problems handling this with quite modest Sun Ultra
  20402. SPARCstation (2x200 Mhz). We recently upgraded one of our servers to a 2
  20403. CPU 400 Mhz UltraSPARC and we are now planning to start handling
  20404. transactions on the product level, which would mean a ten-fold increase
  20405. of data. We think we can keep up with this by just adding more disk to
  20406. our systems.
  20407.  
  20408. We are also experimenting with Intel-Linux to be able to get more CPU
  20409. power cheaper. Now that we have the binary portable database format (new
  20410. in 3.32) we will start to use this for some parts of the application.
  20411.  
  20412. Our initial feelings are that Linux will perform much better on low to
  20413. medium load but Solaris will perform better when you start to get a
  20414. high load because of extreme disk IO, but we don't yet have anything
  20415. conclusive about this. After some discussion with a Linux Kernel
  20416. developer this might be a side effect of Linux giving so much resources
  20417. to the batch job that the interactive performance gets very low. This
  20418. makes the machine feel very slow and unresponsive while big batches are
  20419. going. Hopefully this will be better handled in future Linux Kernels.
  20420.  
  20421. The MySQL benchmark suite
  20422. *************************
  20423.  
  20424. This should contain a technical description of the *MySQL* benchmark
  20425. suite (and `crash-me') but that description is not written yet.
  20426. Currently, you should look at the code and results in the `sql-bench'
  20427. directory in the distribution (and of course on the Web page at
  20428. `http://www.mysql.com/crashme/choose.php' and (normally found in the
  20429. `sql-bench' directory in the *MySQL* distribution)).
  20430.  
  20431. It is meant to be a benchmark that will tell any user what things a
  20432. given SQL implementation performs well or poorly at.
  20433.  
  20434. Note that this benchmark is single threaded so it measures the minimum
  20435. time for the operations.
  20436.  
  20437. For example (run on the same NT 4.0 machine):
  20438.  
  20439. *Reading 2000000 rows by index* *Seconds*                                   *Seconds*      
  20440. mysql                                       367            249
  20441. mysql_odbc                                  464            
  20442. db2_odbc                                    1206           
  20443. informix_odbc                               121126         
  20444. ms-sql_odbc                                 1634           
  20445. oracle_odbc                                 20800          
  20446. solid_odbc                                  877            
  20447. sybase_odbc                                 17614          
  20448.  
  20449.  
  20450. *Inserting (350768) rows* *Seconds*                                   *Seconds*      
  20451. mysql                                       381            206
  20452. mysql_odbc                                  619            
  20453. db2_odbc                                    3460           
  20454. informix_odbc                               2692           
  20455. ms-sql_odbc                                 4012           
  20456. oracle_odbc                                 11291          
  20457. solid_odbc                                  1801           
  20458. sybase_odbc                                 4802           
  20459.  
  20460.  
  20461. In the above test *MySQL* was run with a 8M index cache.
  20462.  
  20463. Note that Oracle is not included because they asked to be removed. All
  20464. Oracle benchmarks has to be passed by Oracle! We believe that makes
  20465. Oracle benchmarks *VERY* biased because the above benchmarks are
  20466. supposed to show what a standard installation can do for a single
  20467. client.
  20468.  
  20469. `crash-me' tries to determine what features a database supports and
  20470. what it's capabilities and limitations are by actually running queries.
  20471. For example, it determines:
  20472.  
  20473.    * What column types are supported
  20474.  
  20475.    * How many indexes are supported
  20476.  
  20477.    * What functions are supported
  20478.  
  20479.    * How big a query can be
  20480.  
  20481.    * How big a `VARCHAR' column can be
  20482.  
  20483. MySQL Utilites
  20484. **************
  20485.  
  20486. Overview of the different MySQL programs
  20487. ========================================
  20488.  
  20489. All *MySQL* clients that communicate with the server using the
  20490. `mysqlclient' library use the following environment variables:
  20491.  
  20492. *Name*             *Description*
  20493. `MYSQL_UNIX_PORT'  The default socket; used for connections to
  20494.                    `localhost'
  20495. `MYSQL_TCP_PORT'   The default TCP/IP port
  20496. `MYSQL_PWD'        The default password
  20497. `MYSQL_DEBUG'      Debug-trace options when debugging
  20498. `TMPDIR'           The directory where temporary tables/files are created
  20499.  
  20500. Use of `MYSQL_PWD' is insecure.  *Note Connecting::.
  20501.  
  20502. The `mysql' client uses the file named in the `MYSQL_HISTFILE'
  20503. environment variable to save the command line history. The default
  20504. value for the history file is `$HOME/.mysql_history', where `$HOME' is
  20505. the value of the `HOME' environment variable. *Note Environment
  20506. variables::.
  20507.  
  20508. All *MySQL* programs take many different options. However, every
  20509. *MySQL* program provides a `--help' option that you can use to get a
  20510. full description of the program's different options. For example, try
  20511. `mysql --help'.
  20512.  
  20513. You can override default options for all standard client programs with
  20514. an option file. *Note Option files::.
  20515.  
  20516. The list below briefly describes the *MySQL* programs:
  20517.  
  20518. `myisamchk'
  20519.      Utility to describe, check, optimize and repair *MySQL* tables.
  20520.      Because `myisamchk' has many functions, it is described in its own
  20521.      chapter. *Note Maintenance::.
  20522.  
  20523. `make_binary_distribution'
  20524.      Makes a binary release of a compiled *MySQL*. This could be sent
  20525.      by FTP to `/pub/mysql/Incoming' on `support.mysql.com' for the
  20526.      convenience of other *MySQL* users.
  20527.  
  20528. `msql2mysql'
  20529.      A shell script that converts `mSQL' programs to *MySQL*. It doesn't
  20530.      handle all cases, but it gives a good start when converting.
  20531.  
  20532. `mysqlaccess'
  20533.      A script that checks the access privileges for a host, user and
  20534.      database combination.
  20535.  
  20536. `mysqladmin'
  20537.      Utility for performing administrative operations, such as creating
  20538.      or dropping databases, reloading the grant tables, flushing tables
  20539.      to disk and reopening log files.  `mysqladmin' can also be used to
  20540.      retrieve version, process and status information from the server.
  20541.      *Note `mysqladmin': mysqladmin.
  20542.  
  20543. `mysqlbug'
  20544.      The *MySQL* bug report script.  This script should always be used
  20545.      when filing a bug report to the *MySQL* list.
  20546.  
  20547. `mysqld'
  20548.      The SQL daemon. This should always be running.
  20549.  
  20550. `mysqldump'
  20551.      Dumps a *MySQL* database into a file as SQL statements or as
  20552.      tab-separated text files. Enhanced freeware originally by Igor
  20553.      Romanenko.  *Note `mysqldump': mysqldump.
  20554.  
  20555. `mysqlimport'
  20556.      Imports text files into their respective tables using `LOAD DATA
  20557.      INFILE'. *Note `mysqlimport': mysqlimport.
  20558.  
  20559. `mysqlshow'
  20560.      Displays information about databases, tables, columns and indexes.
  20561.  
  20562. `mysql_install_db'
  20563.      Creates the *MySQL* grant tables with default privileges. This is
  20564.      usually executed only once, when first installing *MySQL* on a
  20565.      system.
  20566.  
  20567. `replace'
  20568.      A utility program that is used by `msql2mysql', but that has more
  20569.      general applicability as well.  `replace' changes strings in place
  20570.      in files or on the standard input. Uses a finite state machine to
  20571.      match longer strings first. Can be used to swap strings. For
  20572.      example, this command swaps `a' and `b' in the given files:
  20573.  
  20574.           shell> replace a b b a -- file1 file2 ...
  20575.  
  20576. `safe_mysqld'
  20577.      A script that starts the `mysqld' daemon with some safety
  20578.      features, such as restarting the server when an error occurs and
  20579.      logging runtime information to a log file.
  20580.  
  20581. The command line tool
  20582. =====================
  20583.  
  20584. `mysql' is a simple SQL shell (with GNU `readline' capabilities).  It
  20585. supports interactive and non-interactive use. When used interactively,
  20586. query results are presented in an ASCII-table format. When used
  20587. non-interactively (e.g., as a filter), the result is presented in
  20588. tab-separated format.  (The output format can be changed using
  20589. command-line options.)  You can run scripts simply like this:
  20590.  
  20591.      shell> mysql database < script.sql > output.tab
  20592.  
  20593. If you have problems due to insufficient memory in the client, use the
  20594. `--quick' option!  This forces `mysql' to use `mysql_use_result()'
  20595. rather than `mysql_store_result()' to retrieve the result set.
  20596.  
  20597. Using `mysql' is very easy;  Just start it as follows `mysql database'
  20598. or `mysql --user=user_name --password=your_password database'. Type a
  20599. SQL statement, end it with `;', `\g' or `\G' and press return/enter.
  20600.  
  20601. `mysql' supports the following options:
  20602.  
  20603. `-?, --help'
  20604.      Display this help and exit
  20605.  
  20606. `-A, --no-auto-rehash'
  20607.      No automatic rehashing. One has to use 'rehash' to get table and
  20608.      field completion. This gives a quicker start of mysql.
  20609.  
  20610. `-B, --batch'
  20611.      Print results with a tab as separator, each row on a new line.
  20612.      Doesn't use history file.
  20613.  
  20614. `-C, --compress'
  20615.      Use compression in server/client protocol.
  20616.  
  20617. `-#, --debug[=...]'
  20618.      Debug log. Default is 'd:t:o,/tmp/mysql.trace'
  20619.  
  20620. `-D, --database=..'
  20621.      Database to use;  This is mainly useful in the `my.cnf' file.
  20622.  
  20623. `-e, --execute=...'
  20624.      Execute command and quit. (Output like with -batch)
  20625.  
  20626. `-E, --vertical'
  20627.      Print the output of a query (rows) vertically. Without this option
  20628.      you can also force this output by ending your statements with `\G'.
  20629.  
  20630. `-f, --force'
  20631.      Continue even if we get a SQL error.
  20632.  
  20633. `-i, --ignore-space'
  20634.      Ignore space after function names.
  20635.  
  20636. `-h, --host=...'
  20637.      Connect to the given host.
  20638.  
  20639. `-H, --html'
  20640.      Produce HTML output.
  20641.  
  20642. `-L, --skip-line-numbers'
  20643.      Don't write line number for errors. Useful when one want's to
  20644.      compare result files that includes error messages.
  20645.  
  20646. `-n, --unbuffered'
  20647.      Flush buffer after each query.
  20648.  
  20649. `-N, --skip-column-names'
  20650.      Don't write column names in results.
  20651.  
  20652. `-O, --set-variable var=option'
  20653.      Give a variable a value. `--help' lists variables.
  20654.  
  20655. `-o, --one-database'
  20656.      Only update the default database. This is useful for skipping
  20657.      updates to other database in the update log.
  20658.  
  20659. `'
  20660.  
  20661. `-p[password], --password[=...]'
  20662.      Password to use when connecting to server. If password is not
  20663.      given on the command line, you will be prompted for it.  Note that
  20664.      if you use the short form `-p' you can't have a space between the
  20665.      option and the password.
  20666.  
  20667. `-P  --port=...'
  20668.      TCP/IP port number to use for connection.
  20669.  
  20670. `-q, --quick'
  20671.      Don't cache result, print it row-by-row. This may slow down the
  20672.      server if the output is suspended. Doesn't use history file.
  20673.  
  20674. `-r, --raw'
  20675.      Write column values without escape conversion. Used with `--batch'
  20676.  
  20677. `-s, --silent'
  20678.      Be more silent.
  20679.  
  20680. `-S  --socket=...'
  20681.      Socket file to use for connection.
  20682.  
  20683. `-t  --table'
  20684.      Output in table format. This is default in non-batch mode.
  20685.  
  20686. `-T, --exit-info'
  20687.      Only used when debugging.  -exit-info=0 will print some usage
  20688.      information on exit.
  20689.  
  20690. `-u, --user=#'
  20691.      User for login if not current user.
  20692.  
  20693. `-U, --safe-updates[=#], --i-am-a-dummy[=#]'
  20694.      Only allow `UPDATE' and `DELETE' that uses keys. See below for
  20695.      more information about this option.  You can reset this option if
  20696.      you have it in your `my.cnf' file by using `--safe-updates=0'.
  20697.  
  20698. `-v, --verbose'
  20699.      More verbose output (-v -v -v gives the table output format).
  20700.  
  20701. `-V, --version'
  20702.      Output version information and exit.
  20703.  
  20704. `-w, --wait'
  20705.      Wait and retry if connection is down instead of aborting.
  20706.  
  20707. If you type 'help' on the command line, `mysql' will print out the
  20708. commands that it supports:
  20709.  
  20710.      mysql> help
  20711.      
  20712.      MySQL commands:
  20713.      help    (\h)    Display this text
  20714.      ?       (\h)    Synonym for `help'
  20715.      clear   (\c)    Clear command
  20716.      connect (\r)    Reconnect to the server. Optional arguments are db and host
  20717.      edit    (\e)    Edit command with $EDITOR
  20718.      exit    (\q)    Exit mysql. Same as quit
  20719.      go      (\g)    Send command to mysql server
  20720.      ego     (\G)    Send command to mysql server; Display result vertically
  20721.      print   (\p)    Print current command
  20722.      quit    (\q)    Quit mysql
  20723.      rehash  (\#)    Rebuild completion hash
  20724.      source  (\.)    Execute a SQL script file. Takes a file name as an argument
  20725.      status  (\s)    Get status information from the server
  20726.      use     (\u)    Use another database. Takes database name as argument
  20727.  
  20728. The `status' command gives you some information about the connection
  20729. and the server you are using. If you are running in the
  20730. `--safe-updates' mode, `status' will also print the values for the
  20731. `mysql' variables that affects your queries.
  20732.  
  20733. A useful startup option for beginners (introduced in *MySQL* 3.23.11) is
  20734. `--safe-mode' (or `--i-am-a-dummy' for users that has at some time done
  20735. a `DELETE FROM table_name' but forgot the `WHERE' clause.  When using
  20736. this option, `mysql' sends the following command to the *MySQL* server
  20737. when opening the connection:
  20738.  
  20739.      SET SQL_SAFE_UPDATES=1,SQL_SELECT_LIMIT=#select_limit#,
  20740.          SQL_MAX_JOIN_SIZE=#max_join_size#"
  20741.  
  20742. where `#select_limit#' and `#max_join_size#' are variables that can be
  20743. set from the `mysql' command line. *Note `SET': SET OPTION.
  20744.  
  20745. The effect of the above is:
  20746.  
  20747.    * You are not allowed to do an `UPDATE' or `DELETE' statements if
  20748.      you don't have a key constraint in the `WHERE' part. One can
  20749.      however force an `UPDATE/DELETE' by using `LIMIT':
  20750.           UPDATE table_name SET not_key_column=# WHERE not_key_column=# LIMIT 1;
  20751.  
  20752.    * All big results are automatically limited to `#select_limit#' rows.
  20753.  
  20754.    * `SELECT''s that will probably need to examine more than
  20755.      `#max_join_size' row combinations will be aborted.
  20756.  
  20757. Administering a MySQL server
  20758. ============================
  20759.  
  20760. Utility for performing administrative operations. The syntax is:
  20761.  
  20762.      shell> mysqladmin [OPTIONS] command [command-option] command ...
  20763.  
  20764. You can get a list of the options your version of `mysqladmin' supports
  20765. by executing `mysqladmin --help'.
  20766.  
  20767. The current `mysqladmin' supports the following commands:
  20768.  
  20769. create databasename    Create a new database.
  20770. drop databasename      Delete a database and all its tables.
  20771. extended-status        Gives an extended status message from the server.
  20772. flush-hosts            Flush all cached hosts.
  20773. flush-logs             Flush all logs.
  20774. flush-tables           Flush all tables.
  20775. flush-privileges       Reload grant tables (same as reload).
  20776. kill id,id,...         Kill mysql threads.
  20777. password               new-password Change old password to new-password.
  20778. ping                   Check if mysqld is alive.
  20779. processlist            Show list of active threads in server.
  20780. reload                 Reload grant tables.
  20781. refresh                Flush all tables and close and open logfiles.
  20782. shutdown               Take server down.
  20783. slave-start            Start slave replication thread.
  20784. slave-stop             Stop slave replication thread.
  20785. status                 Gives a short status message from the server.
  20786. variables              Prints variables available.
  20787. version                Get version info from server.
  20788.  
  20789. All commands can be shortened to their unique prefix.  For example:
  20790.  
  20791.      shell> mysqladmin proc stat
  20792.      +----+-------+-----------+----+-------------+------+-------+------+
  20793.      | Id | User  | Host      | db | Command     | Time | State | Info |
  20794.      +----+-------+-----------+----+-------------+------+-------+------+
  20795.      | 6  | monty | localhost |    | Processlist | 0    |       |      |
  20796.      +----+-------+-----------+----+-------------+------+-------+------+
  20797.      Uptime: 10077  Threads: 1  Questions: 9  Slow queries: 0  Opens: 6  Flush tables: 1  Open tables: 2  Memory in use: 1092K  Max memory used: 1116K
  20798.  
  20799. The `mysqladmin status' command result has the following columns:
  20800.  
  20801. Uptime                 Number of seconds the *MySQL* server has been up.
  20802. Threads                Number of active threads (clients).
  20803. Questions              Number of questions from clients since `mysqld'
  20804.                        was started.
  20805. Slow queries           Queries that have taken more than
  20806.                        `long_query_time' seconds.
  20807. Opens                  How many tables `mysqld' has opened.
  20808. Flush tables           Number of `flush ...', `refresh' and `reload'
  20809.                        commands.
  20810. Open tables            Number of tables that are open now.
  20811. Memory in use          Memory allocated directly by the mysqld code
  20812.                        (only available when *MySQL* is compiled with
  20813.                        -with-debug).
  20814. Max memory used        Maximum memory allocated directly by the mysqld
  20815.                        code (only available when *MySQL* is compiled
  20816.                        with -with-debug).
  20817.  
  20818. If you do `myslqadmin shutdown' on a socket (in other words, on a the
  20819. computer where `mysqld' is running), `mysqladmin' will wait until the
  20820. `MySQL' `pid-file' is removed to ensure that the `mysqld server' has
  20821. stopped properly.
  20822.  
  20823. Dumping the structure and data from MySQL databases and tables
  20824. ==============================================================
  20825.  
  20826. Utility to dump a database or a collection of database for backup or
  20827. for transferring the data to another SQL server.  The dump will contain
  20828. SQL statements to create the table and/or populate the table.
  20829.  
  20830.      shell> mysqldump [OPTIONS] database [tables]
  20831.      OR     mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]
  20832.      OR     mysqldump [OPTIONS] --all-databases [OPTIONS]
  20833.  
  20834. If you don't give any tables or use the `--databases' or
  20835. `--all-databases', the whole database(s) will be dumped.
  20836.  
  20837. You can get a list of the options your version of `mysqldump' supports
  20838. by executing `mysqldump --help'.
  20839.  
  20840. Note that if you run `mysqldump' without `--quick' or `--opt',
  20841. `mysqldump' will load the whole result set into memory before dumping
  20842. the result.  This will probably be a problem if you are dumping a big
  20843. database.
  20844.  
  20845. `mysqldump' supports the following options:
  20846.  
  20847. `--add-locks'
  20848.      Add `LOCK TABLES' before and `UNLOCK TABLE' after each table dump.
  20849.      (To get faster inserts into *MySQL*).
  20850.  
  20851. `--add-drop-table'
  20852.      Add a `drop table' before each create statement.
  20853.  
  20854. `-A, --all-databases'
  20855.      Dump all the databases. This will be same as `--databases' with all
  20856.      databases selected.
  20857.  
  20858. `-a, --all'
  20859.      Include all *MySQL* specific create options.
  20860.  
  20861. `--allow-keywords'
  20862.      Allow creation of column names that are keywords.  This works by
  20863.      prefixing each column name with the table name.
  20864.  
  20865. `-c, --complete-insert'
  20866.      Use complete insert statements (with column names).
  20867.  
  20868. `-C, --compress'
  20869.      Compress all information between the client and the server if both
  20870.      support compression.
  20871.  
  20872. `-B, --databases'
  20873.      To dump several databases. Note the difference in usage; In this
  20874.      case no tables are given. All name arguments are regarded as
  20875.      databasenames.  `USE db_name;' will be included in the output
  20876.      before each new database.
  20877.  
  20878. `--delayed'
  20879.      Insert rows with the `INSERT DELAYED' command.
  20880.  
  20881. `-e, --extended-insert'
  20882.      Use the new multiline `INSERT' syntax. (Gives more compact and
  20883.      faster inserts statements.)
  20884.  
  20885. `-#, --debug[=option_string]'
  20886.      Trace usage of the program (for debugging).
  20887.  
  20888. `--help'
  20889.      Display a help message and exit.
  20890.  
  20891. `--fields-terminated-by=...'
  20892. `--fields-enclosed-by=...'
  20893. `--fields-optionally-enclosed-by=...'
  20894. `--fields-escaped-by=...'
  20895. `--lines-terminated-by=...'
  20896.      These options are used with the `-T' option and have the same
  20897.      meaning as the corresponding clauses for `LOAD DATA INFILE'.
  20898.      *Note `LOAD DATA': LOAD DATA.
  20899.  
  20900. `-F, --flush-logs'
  20901.      Flush log file in the *MySQL* server before starting the dump.
  20902.  
  20903. `-f, --force,'
  20904.      Continue even if we get a SQL error during a table dump.
  20905.  
  20906. `-h, --host=..'
  20907.      Dump data from the *MySQL* server on the named host. The default
  20908.      host is `localhost'.
  20909.  
  20910. `-l, --lock-tables.'
  20911.      Lock all tables before starting the dump.  The tables are locked
  20912.      with `READ LOCAL' to allow concurrent inserts in the case of
  20913.      `MyISAM' tables.
  20914.  
  20915. `-n, --no-create-db'
  20916.      'CREATE DATABASE /*!32312 IF NOT EXISTS*/ db_name;' will not be
  20917.      put in the output. The above line will be added otherwise, if
  20918.      -databases or -all-databases option was given.
  20919.  
  20920. `-t, --no-create-info'
  20921.      Don't write table creation info (The `CREATE TABLE' statement.)
  20922.  
  20923. `-d, --no-data'
  20924.      Don't write any row information for the table.  This is very
  20925.      useful if you just want to get a dump of the structure for a table!
  20926.  
  20927. `--opt'
  20928.      Same as `--quick --add-drop-table --add-locks --extended-insert
  20929.      --lock-tables'.  Should give you the fastest possible dump for
  20930.      reading into a *MySQL* server.
  20931.  
  20932. `-pyour_pass, --password[=your_pass]'
  20933.      The password to use when connecting to the server. If you specify
  20934.      no `=your_pass' part, `mysqldump' you will be prompted for a
  20935.      password.
  20936.  
  20937. `-P port_num, --port=port_num'
  20938.      The TCP/IP port number to use for connecting to a host.  (This is
  20939.      used for connections to hosts other than `localhost', for which
  20940.      Unix sockets are used.)
  20941.  
  20942. `-q, --quick'
  20943.      Don't buffer query, dump directly to stdout;  Uses
  20944.      `mysql_use_result()' to do this.
  20945.  
  20946. `-S /path/to/socket, --socket=/path/to/socket'
  20947.      The socket file to use when connecting to `localhost' (which is the
  20948.      default host).
  20949.  
  20950. `--tables'
  20951.      Overrides option -databases (-B).
  20952.  
  20953. `-T, --tab=path-to-some-directory'
  20954.      Creates a `table_name.sql' file, that contains the SQL CREATE
  20955.      commands, and a `table_name.txt' file, that contains the data, for
  20956.      each give table.  *NOTE*: This only works if `mysqldump' is run on
  20957.      the same machine as the `mysqld' daemon.  The format of the `.txt'
  20958.      file is made according to the `--fields-xxx' and `--lines--xxx'
  20959.      options.
  20960.  
  20961. `-u user_name, --user=user_name'
  20962.      The *MySQL* user name to use when connecting to the server. The
  20963.      default value is your Unix login name.
  20964.  
  20965. `-O var=option, --set-variable var=option'
  20966.      Set the value of a variable.  The possible variables are listed
  20967.      below.
  20968.  
  20969. `-v, --verbose'
  20970.      Verbose mode.  Print out more information what the program does.
  20971.  
  20972. `-V, --version'
  20973.      Print version information and exit.
  20974.  
  20975. `-w, --where='where-condition''
  20976.      Dump only selected records; Note that QUOTES are mandatory!
  20977.  
  20978.           "--where=user='jimf'" "-wuserid>1" "-wuserid<1"
  20979.  
  20980. `-O net_buffer_length=#, where # < 24M'
  20981.      When creating multi-row-insert statements (as with option
  20982.      `--extended-insert' or `--opt'), `mysqldump' will create rows up
  20983.      to `net_buffer_length' length. If you increase this variable, you
  20984.      should also ensure that the `max_allowed_packet' variable in the
  20985.      *MySQL* server is bigger than the `net_buffer_length'.
  20986.  
  20987. The most normal use of `mysqldump' is probably for making a backup of
  20988. whole databases. *Note Backup::.
  20989.  
  20990.      mysqldump --opt database > backup-file.sql
  20991.  
  20992. However, it's also very useful to populate another *MySQL* server with
  20993. information from a database:
  20994.  
  20995.      mysqldump --opt database | mysql ---host=remote-host -C database
  20996.  
  20997. It is possible to dump several databases with one command:
  20998.  
  20999.      mysqldump --databases database1 [database2 database3...] > my_databases.sql
  21000.  
  21001. If all the databases are wanted, one can use:
  21002.  
  21003.      mysqldump --all-databases > all_databases.sql
  21004.  
  21005. Importing data from text files
  21006. ==============================
  21007.  
  21008. `mysqlimport' provides a command line interface to the `LOAD DATA
  21009. INFILE' SQL statement.  Most options to `mysqlimport' correspond
  21010. directly to the same options to `LOAD DATA INFILE'.  *Note `LOAD DATA':
  21011. LOAD DATA.
  21012.  
  21013. `mysqlimport' is invoked like this:
  21014.  
  21015.      shell> mysqlimport [options] database textfile1 [textfile2....]
  21016.  
  21017. For each text file named on the command line, `mysqlimport' strips any
  21018. extension from the filename and uses the result to determine which
  21019. table to import the file's contents into.  For example, files named
  21020. `patient.txt', `patient.text' and `patient' would all be imported into
  21021. a table named `patient'.
  21022.  
  21023. `mysqlimport' supports the following options:
  21024.  
  21025. `-c, --columns=...'
  21026.      This option takes a comma separated list of field names as an
  21027.      argument.  The field list is passed to LOAD DATA INFILE MySQL sql
  21028.      command, which mysqlimport calls MySQL to execute. For more
  21029.      information, please see `LOAD DATA INFILE'. *Note `LOAD DATA':
  21030.      LOAD DATA.
  21031.  
  21032. `-C, --compress'
  21033.      Compress all information between the client and the server if both
  21034.      support compression.
  21035.  
  21036. `-#, --debug[=option_string]'
  21037.      Trace usage of the program (for debugging).
  21038.  
  21039. `-d, --delete'
  21040.      Empty the table before importing the text file.
  21041.  
  21042. `--fields-terminated-by=...'
  21043. `--fields-enclosed-by=...'
  21044. `--fields-optionally-enclosed-by=...'
  21045. `--fields-escaped-by=...'
  21046. `--lines-terminated-by=...'
  21047.      These options have the same meaning as the corresponding clauses
  21048.      for `LOAD DATA INFILE'. *Note `LOAD DATA': LOAD DATA.
  21049.  
  21050. `-f, --force'
  21051.      Ignore errors.  For example, if a table for a text file doesn't
  21052.      exist, continue processing any remaining files.  Without `--force',
  21053.      `mysqlimport' exits if a table doesn't exist.
  21054.  
  21055. `--help'
  21056.      Display a help message and exit.
  21057.  
  21058. `-h host_name, --host=host_name'
  21059.      Import data to the *MySQL* server on the named host. The default
  21060.      host is `localhost'.
  21061.  
  21062. `-i, --ignore'
  21063.      See the description for the `--replace' option.
  21064.  
  21065. `-l, --lock-tables'
  21066.      Lock *ALL* tables for writing before processing any text files.
  21067.      This ensures that all tables are synchronized on the server.
  21068.  
  21069. `-L, --local'
  21070.      Read input files from the client.  By default, text files are
  21071.      assumed to be on the server if you connect to `localhost' (which
  21072.      is the default host).
  21073.  
  21074. `-pyour_pass, --password[=your_pass]'
  21075.      The password to use when connecting to the server. If you specify
  21076.      no `=your_pass' part, `mysqlimport' you will be prompted for a
  21077.      password.
  21078.  
  21079. `-P port_num, --port=port_num'
  21080.      The TCP/IP port number to use for connecting to a host.  (This is
  21081.      used for connections to hosts other than `localhost', for which
  21082.      Unix sockets are used.)
  21083.  
  21084. `-r, --replace'
  21085.      The `--replace' and `--ignore' options control handling of input
  21086.      records that duplicate existing records on unique key values.  If
  21087.      you specify `--replace', new rows replace existing rows that have
  21088.      the same unique key value. If you specify `--ignore', input rows
  21089.      that duplicate an existing row on a unique key value are skipped.
  21090.      If you don't specify either option, an error occurs when a
  21091.      duplicate key value is found, and the rest of the text file is
  21092.      ignored.
  21093.  
  21094. `-s, --silent'
  21095.      Silent mode.  Write output only when errors occur.
  21096.  
  21097. `-S /path/to/socket, --socket=/path/to/socket'
  21098.      The socket file to use when connecting to `localhost' (which is the
  21099.      default host).
  21100.  
  21101. `-u user_name, --user=user_name'
  21102.      The *MySQL* user name to use when connecting to the server. The
  21103.      default value is your Unix login name.
  21104.  
  21105. `-v, --verbose'
  21106.      Verbose mode.  Print out more information what the program does.
  21107.  
  21108. `-V, --version'
  21109.      Print version information and exit.
  21110.  
  21111. Here follows a sample run of using `mysqlimport':
  21112.  
  21113.      $ mysql --version
  21114.      mysql  Ver 9.33 Distrib 3.22.25, for pc-linux-gnu (i686)
  21115.      $ uname -a
  21116.      Linux xxx.com 2.2.5-15 #1 Mon Apr 19 22:21:09 EDT 1999 i586 unknown
  21117.      $ mysql -e 'CREATE TABLE imptest(id INT, n VARCHAR(30))' test
  21118.      $ ed
  21119.      a
  21120.      100     Max Sydow
  21121.      101     Count Dracula
  21122.      .
  21123.      w imptest.txt
  21124.      32
  21125.      q
  21126.      $ od -c imptest.txt
  21127.      0000000   1   0   0  \t   M   a   x       S   y   d   o   w  \n   1   0
  21128.      0000020   1  \t   C   o   u   n   t       D   r   a   c   u   l   a  \n
  21129.      0000040
  21130.      $ mysqlimport --local test imptest.txt
  21131.      test.imptest: Records: 2  Deleted: 0  Skipped: 0  Warnings: 0
  21132.      $ mysql -e 'SELECT * FROM imptest' test
  21133.      +------+---------------+
  21134.      | id   | n             |
  21135.      +------+---------------+
  21136.      |  100 | Max Sydow     |
  21137.      |  101 | Count Dracula |
  21138.      +------+---------------+
  21139.  
  21140. Showing databases, tables and columns
  21141. =====================================
  21142.  
  21143. `mysqlshow' can be used to quickly look at which databases exist, their
  21144. tables, and the table's columns.
  21145.  
  21146. With the `mysql' program you can get the same information with the
  21147. `SHOW' commands.  *Note SHOW::.
  21148.  
  21149. `mysqlshow' is invoked like this:
  21150.  
  21151.      shell> mysqlshow [OPTIONS] [database [table [column]]]
  21152.  
  21153.    * If no database is given, all matching databases are shown.
  21154.  
  21155.    * If no table is given, all matching tables in database are shown.
  21156.  
  21157.    * If no column is given, all matching columns and column types in
  21158.      table are shown.
  21159.  
  21160. Note that in newer *MySQL* versions you only see those
  21161. database/tables/columns for which you have some privileges.
  21162.  
  21163. If the last argument contains a shell or SQL wildcard (`*', `?', `%' or
  21164. `_') then only what's matched by the wildcard is shown.  This may cause
  21165. some confusion when you try to display the columns for a table with a
  21166. `_' as in this case `mysqlshow' only shows you the table names that
  21167. matches the pattern.  This is easily fixed by adding an extra `%' last
  21168. on the command line (as a separate argument).
  21169.  
  21170. The MySQL compressed read-only table generator.
  21171. ===============================================
  21172.  
  21173. `myisampack' is used to compress MyISAM tables and `pack_isam' is used
  21174. to compress ISAM tables. Because ISAM tables are deprecated, we will
  21175. only discuss `myisampack' here, but everything said about `myisampack'
  21176. should also be true for `pack_isam'.
  21177.  
  21178. `myisampack' works by compressing each column in the table separately.
  21179. The information needed to decompress columns is read into memory when
  21180. the table is opened. This results in much better performance when
  21181. accessing individual records, because you only have to uncompress
  21182. exactly one record, not a much larger disk block like when using
  21183. Stacker on MS-DOS.  Usually, `myisampack' packs the data file 40%-70%.
  21184.  
  21185. *MySQL* uses memory mapping (`mmap()') on compressed tables and falls
  21186. back to normal read/write file usage if `mmap()' doesn't work.
  21187.  
  21188. There are currently two limitations with `myisampack':
  21189.    * After packing, the table is read only.
  21190.  
  21191.    * `myisampack' can also pack `BLOB' or `TEXT' columns. The older
  21192.      `pack_isam' could not do this.
  21193.  
  21194. Fixing these limitations is on our TODO list but with low priority.
  21195.  
  21196. `myisampack' is invoked like this:
  21197.  
  21198.      shell> myisampack [options] filename ...
  21199.  
  21200. Each filename should be the name of an index (`.MYI') file.  If you are
  21201. not in the database directory, you should specify the pathname to the
  21202. file.  It is permissible to omit the `.MYI' extension.
  21203.  
  21204. `myisampack' supports the following options:
  21205.  
  21206. `-b, --backup'
  21207.      Make a backup of the table as `tbl_name.OLD'.
  21208.  
  21209. `-#, --debug=debug_options'
  21210.      Output debug log. The `debug_options' string often is
  21211.      `'d:t:o,filename''.
  21212.  
  21213. `-f, --force'
  21214.      Force packing of the table even if it becomes bigger or if the
  21215.      temporary file exists.  (`myisampack' creates a temporary file
  21216.      named `tbl_name.TMD' while it compresses the table.  If you kill
  21217.      `myisampack', the `.TMD' file may not be deleted.  Normally,
  21218.      `myisampack' exits with an error if it finds that `tbl_name.TMD'
  21219.      exists.  With `--force', `myisampack' packs the table anyway.
  21220.  
  21221. `-?, --help'
  21222.      Display a help message and exit.
  21223.  
  21224. `-j big_tbl_name, --join=big_tbl_name'
  21225.      Join all tables named on the command line into a single table
  21226.      `big_tbl_name'.  All tables that are to be combined MUST be
  21227.      identical (same column names and types, same indexes, etc.).
  21228.  
  21229. `-p #, --packlength=#'
  21230.      Specify the record length storage size, in bytes.  The value
  21231.      should be 1, 2 or 3.  (`myisampack' stores all rows with length
  21232.      pointers of 1, 2 or 3 bytes.  In most normal cases, `myisampack'
  21233.      can determine the right length value before it begins packing the
  21234.      file, but it may notice during the packing process that it could
  21235.      have used a shorter length. In this case, `myisampack' will print
  21236.      a note that the next time you pack the same file, you could use a
  21237.      shorter record length.)
  21238.  
  21239. `-s, --silent'
  21240.      Silent mode.  Write output only when errors occur.
  21241.  
  21242. `-t, --test'
  21243.      Don't pack table, only test packing it.
  21244.  
  21245. `-T dir_name, --tmp_dir=dir_name'
  21246.      Use the named directory as the location in which to write the
  21247.      temporary table.
  21248.  
  21249. `-v, --verbose'
  21250.      Verbose mode.  Write info about progress and packing result.
  21251.  
  21252. `-V, --version'
  21253.      Display version information and exit.
  21254.  
  21255. `-w, --wait'
  21256.      Wait and retry if table is in use.  If the `mysqld' server was
  21257.      invoked with the `--skip-locking' option, it is not a good idea to
  21258.      invoke `myisampack' if the table might be updated during the
  21259.      packing process.
  21260.  
  21261. The sequence of commands shown below illustrates a typical table
  21262. compression session:
  21263.  
  21264.      shell> ls -l station.*
  21265.      -rw-rw-r--   1 monty    my         994128 Apr 17 19:00 station.MYD
  21266.      -rw-rw-r--   1 monty    my          53248 Apr 17 19:00 station.MYI
  21267.      -rw-rw-r--   1 monty    my           5767 Apr 17 19:00 station.frm
  21268.      
  21269.      shell> myisamchk -dvv station
  21270.      
  21271.      MyISAM file:     station
  21272.      Isam-version:  2
  21273.      Creation time: 1996-03-13 10:08:58
  21274.      Recover time:  1997-02-02  3:06:43
  21275.      Data records:              1192  Deleted blocks:              0
  21276.      Datafile: Parts:           1192  Deleted data:                0
  21277.      Datafile pointer (bytes):     2  Keyfile pointer (bytes):     2
  21278.      Max datafile length:   54657023  Max keyfile length:   33554431
  21279.      Recordlength:               834
  21280.      Record format: Fixed length
  21281.      
  21282.      table description:
  21283.      Key Start Len Index   Type                       Root  Blocksize    Rec/key
  21284.      1   2     4   unique  unsigned long              1024       1024          1
  21285.      2   32    30  multip. text                      10240       1024          1
  21286.      
  21287.      Field Start Length Type
  21288.      1     1     1
  21289.      2     2     4
  21290.      3     6     4
  21291.      4     10    1
  21292.      5     11    20
  21293.      6     31    1
  21294.      7     32    30
  21295.      8     62    35
  21296.      9     97    35
  21297.      10    132   35
  21298.      11    167   4
  21299.      12    171   16
  21300.      13    187   35
  21301.      14    222   4
  21302.      15    226   16
  21303.      16    242   20
  21304.      17    262   20
  21305.      18    282   20
  21306.      19    302   30
  21307.      20    332   4
  21308.      21    336   4
  21309.      22    340   1
  21310.      23    341   8
  21311.      24    349   8
  21312.      25    357   8
  21313.      26    365   2
  21314.      27    367   2
  21315.      28    369   4
  21316.      29    373   4
  21317.      30    377   1
  21318.      31    378   2
  21319.      32    380   8
  21320.      33    388   4
  21321.      34    392   4
  21322.      35    396   4
  21323.      36    400   4
  21324.      37    404   1
  21325.      38    405   4
  21326.      39    409   4
  21327.      40    413   4
  21328.      41    417   4
  21329.      42    421   4
  21330.      43    425   4
  21331.      44    429   20
  21332.      45    449   30
  21333.      46    479   1
  21334.      47    480   1
  21335.      48    481   79
  21336.      49    560   79
  21337.      50    639   79
  21338.      51    718   79
  21339.      52    797   8
  21340.      53    805   1
  21341.      54    806   1
  21342.      55    807   20
  21343.      56    827   4
  21344.      57    831   4
  21345.      
  21346.      shell> myisampack station.MYI
  21347.      Compressing station.MYI: (1192 records)
  21348.      - Calculating statistics
  21349.      
  21350.      normal:     20  empty-space:      16  empty-zero:        12  empty-fill:  11
  21351.      pre-space:   0  end-space:        12  table-lookups:      5  zero:         7
  21352.      Original trees:  57  After join: 17
  21353.      - Compressing file
  21354.      87.14%
  21355.      
  21356.      shell> ls -l station.*
  21357.      -rw-rw-r--   1 monty    my         127874 Apr 17 19:00 station.MYD
  21358.      -rw-rw-r--   1 monty    my          55296 Apr 17 19:04 station.MYI
  21359.      -rw-rw-r--   1 monty    my           5767 Apr 17 19:00 station.frm
  21360.      
  21361.      shell> myisamchk -dvv station
  21362.      
  21363.      MyISAM file:     station
  21364.      Isam-version:  2
  21365.      Creation time: 1996-03-13 10:08:58
  21366.      Recover time:  1997-04-17 19:04:26
  21367.      Data records:              1192  Deleted blocks:              0
  21368.      Datafile: Parts:           1192  Deleted data:                0
  21369.      Datafilepointer (bytes):      3  Keyfile pointer (bytes):     1
  21370.      Max datafile length:   16777215  Max keyfile length:     131071
  21371.      Recordlength:               834
  21372.      Record format: Compressed
  21373.      
  21374.      table description:
  21375.      Key Start Len Index   Type                       Root  Blocksize    Rec/key
  21376.      1   2     4   unique  unsigned long             10240       1024          1
  21377.      2   32    30  multip. text                      54272       1024          1
  21378.      
  21379.      Field Start Length Type                         Huff tree  Bits
  21380.      1     1     1      constant                             1     0
  21381.      2     2     4      zerofill(1)                          2     9
  21382.      3     6     4      no zeros, zerofill(1)                2     9
  21383.      4     10    1                                           3     9
  21384.      5     11    20     table-lookup                         4     0
  21385.      6     31    1                                           3     9
  21386.      7     32    30     no endspace, not_always              5     9
  21387.      8     62    35     no endspace, not_always, no empty    6     9
  21388.      9     97    35     no empty                             7     9
  21389.      10    132   35     no endspace, not_always, no empty    6     9
  21390.      11    167   4      zerofill(1)                          2     9
  21391.      12    171   16     no endspace, not_always, no empty    5     9
  21392.      13    187   35     no endspace, not_always, no empty    6     9
  21393.      14    222   4      zerofill(1)                          2     9
  21394.      15    226   16     no endspace, not_always, no empty    5     9
  21395.      16    242   20     no endspace, not_always              8     9
  21396.      17    262   20     no endspace, no empty                8     9
  21397.      18    282   20     no endspace, no empty                5     9
  21398.      19    302   30     no endspace, no empty                6     9
  21399.      20    332   4      always zero                          2     9
  21400.      21    336   4      always zero                          2     9
  21401.      22    340   1                                           3     9
  21402.      23    341   8      table-lookup                         9     0
  21403.      24    349   8      table-lookup                        10     0
  21404.      25    357   8      always zero                          2     9
  21405.      26    365   2                                           2     9
  21406.      27    367   2      no zeros, zerofill(1)                2     9
  21407.      28    369   4      no zeros, zerofill(1)                2     9
  21408.      29    373   4      table-lookup                        11     0
  21409.      30    377   1                                           3     9
  21410.      31    378   2      no zeros, zerofill(1)                2     9
  21411.      32    380   8      no zeros                             2     9
  21412.      33    388   4      always zero                          2     9
  21413.      34    392   4      table-lookup                        12     0
  21414.      35    396   4      no zeros, zerofill(1)               13     9
  21415.      36    400   4      no zeros, zerofill(1)                2     9
  21416.      37    404   1                                           2     9
  21417.      38    405   4      no zeros                             2     9
  21418.      39    409   4      always zero                          2     9
  21419.      40    413   4      no zeros                             2     9
  21420.      41    417   4      always zero                          2     9
  21421.      42    421   4      no zeros                             2     9
  21422.      43    425   4      always zero                          2     9
  21423.      44    429   20     no empty                             3     9
  21424.      45    449   30     no empty                             3     9
  21425.      46    479   1                                          14     4
  21426.      47    480   1                                          14     4
  21427.      48    481   79     no endspace, no empty               15     9
  21428.      49    560   79     no empty                             2     9
  21429.      50    639   79     no empty                             2     9
  21430.      51    718   79     no endspace                         16     9
  21431.      52    797   8      no empty                             2     9
  21432.      53    805   1                                          17     1
  21433.      54    806   1                                           3     9
  21434.      55    807   20     no empty                             3     9
  21435.      56    827   4      no zeros, zerofill(2)                2     9
  21436.      57    831   4      no zeros, zerofill(1)                2     9
  21437.  
  21438. The information printed by `myisampack' is described below:
  21439.  
  21440. `normal'
  21441.      The number of columns for which no extra packing is used.
  21442.  
  21443. `empty-space'
  21444.      The number of columns containing values that are only spaces;
  21445.      these will occupy 1 bit.
  21446.  
  21447. `empty-zero'
  21448.      The number of columns containing values that are only binary 0's;
  21449.      these will occupy 1 bit.
  21450.  
  21451. `empty-fill'
  21452.      The number of integer columns that don't occupy the full byte
  21453.      range of their type; these are changed to a smaller type (for
  21454.      example, an `INTEGER' column may be changed to `MEDIUMINT').
  21455.  
  21456. `pre-space'
  21457.      The number of decimal columns that are stored with leading space.
  21458.      In this case, each value will contain a count for the number of
  21459.      leading spaces.
  21460.  
  21461. `end-space'
  21462.      The number of columns that have a lot of trailing space.  In this
  21463.      case, each value will contain a count for the number of trailing
  21464.      spaces.
  21465.  
  21466. `table-lookup'
  21467.      The column had only a small number of different values, and that
  21468.      were converted to an `ENUM' before Huffman compression.
  21469.  
  21470. `zero'
  21471.      The number of columns for which all values are zero.
  21472.  
  21473. `Original trees'
  21474.      The initial number of Huffman trees.
  21475.  
  21476. `After join'
  21477.      The number of distinct Huffman trees left after joining trees to
  21478.      save some header space.
  21479.  
  21480. After a table has been compressed, `myisamchk -dvv' prints additional
  21481. information about each field:
  21482.  
  21483. `Type'
  21484.      The field type may contain the following descriptors:
  21485.  
  21486.     `constant'
  21487.           All rows have the same value.
  21488.  
  21489.     `no endspace'
  21490.           Don't store endspace.
  21491.  
  21492.     `no endspace, not_always'
  21493.           Don't store endspace and don't do end space compression for
  21494.           all values.
  21495.  
  21496.     `no endspace, no empty'
  21497.           Don't store endspace. Don't store empty values.
  21498.  
  21499.     `table-lookup'
  21500.           The column was converted to an `ENUM'.
  21501.  
  21502.     `zerofill(n)'
  21503.           The most significant `n' bytes in the value are always 0 and
  21504.           are not stored.
  21505.  
  21506.     `no zeros'
  21507.           Don't store zeros.
  21508.  
  21509.     `always zero'
  21510.           0 values are stored in 1 bit.
  21511.  
  21512. `Huff tree'
  21513.      The Huffman tree associated with the field.
  21514.  
  21515. `Bits'
  21516.      The number of bits used in the Huffman tree.
  21517.  
  21518. After you have run `pack_isam'/`myisampack' you must run
  21519. `isamchk'/`myisamchk' to recreate the index.  At this time you can also
  21520. sort the index blocks and create statistics that is needed for the
  21521. *MySQL* optimizer to work more efficiently.
  21522.  
  21523.      myisamchk -rq --analyze --sort-index table_name.MYI
  21524.      isamchk   -rq --analyze --sort-index table_name.ISM
  21525.  
  21526. After you have installed the packed table into the *MySQL* database
  21527. directory you should do `mysqladmin flush-tables' to force `mysqld' to
  21528. start using the new table.
  21529.  
  21530. Maintaining a MySQL installation
  21531. ********************************
  21532.  
  21533. Using `myisamchk' for table maintenance and crash recovery
  21534. ==========================================================
  21535.  
  21536. Starting with *MySQL* 3.23.13, you can check tables MyISAM with the
  21537. `CHECK TABLE' command. *Note CHECK TABLE::.  You can repair tables with
  21538. the `REPAIR TABLE' command. *Note REPAIR TABLE::.
  21539.  
  21540. To check/repair MyISAM tables (`.MYI' and `.MYD') you should use the
  21541. `myisamchk' utility. To check/repair ISAM tables (`.ISM' and `.ISD')
  21542. you should use the `isamchk' utility. *Note Table types::.
  21543.  
  21544. In the following text we will talk about `myisamchk', but everything
  21545. also applies to the old `isamchk'.
  21546.  
  21547. You can use the `myisamchk' utility to get information about your
  21548. database tables, check and repair them or optimize them.  The following
  21549. sections describe how to invoke `myisamchk' (including a description of
  21550. its options), how to set up a table maintenance schedule, and how to use
  21551. `myisamchk' to perform its various functions.
  21552.  
  21553. You can, in most cases, also use the command `OPTIMIZE TABLES' to
  21554. optimize and repair tables, but this is not as fast or reliable (in case
  21555. of real fatal errors) as `myisamchk'.  On the other hand, `OPTIMIZE
  21556. TABLE' is easier to use and you don't have to worry about flushing
  21557. tables.  *Note `OPTIMIZE TABLE': OPTIMIZE TABLE.
  21558.  
  21559. `myisamchk' invocation syntax
  21560. -----------------------------
  21561.  
  21562. `myisamchk' is invoked like this:
  21563.  
  21564.      shell> myisamchk [options] tbl_name
  21565.  
  21566. The `options' specify what you want `myisamchk' to do.  They are
  21567. described below.  (You can also get a list of options by invoking
  21568. `myisamchk --help'.)  With no options, `myisamchk' simply checks your
  21569. table.  To get more information or to tell `myisamchk' to take
  21570. corrective action, specify options as described below and in the
  21571. following sections.
  21572.  
  21573. `tbl_name' is the database table you want to check.  If you run
  21574. `myisamchk' somewhere other than in the database directory, you must
  21575. specify the path to the file, because `myisamchk' has no idea where your
  21576. database is located.  Actually, `myisamchk' doesn't care whether or not
  21577. the files you are working on are located in a database directory; you
  21578. can copy the files that correspond to a database table into another
  21579. location and perform recovery operations on them there.
  21580.  
  21581. You can name several tables on the `myisamchk' command line if you
  21582. wish.  You can also specify a name as an index file name (with the
  21583. `.MYI' suffix), which allows you to specify all tables in a directory
  21584. by using the pattern `*.MYI'.  For example, if you are in a database
  21585. directory, you can check all the tables in the directory like this:
  21586.  
  21587.      shell> myisamchk *.MYI
  21588.  
  21589. If you are not in the database directory, you can check all the tables
  21590. there by specifying the path to the directory:
  21591.  
  21592.      shell> myisamchk /path/to/database_dir/*.MYI
  21593.  
  21594. You can even check all tables in all databases by specifying a wildcard
  21595. with the path to the *MySQL* data directory:
  21596.  
  21597.      shell> myisamchk /path/to/datadir/*/*.MYI
  21598.  
  21599. `myisamchk' supports the following options:
  21600.  
  21601. General options for myisamchk
  21602. .............................
  21603.  
  21604. `-# or --debug=debug_options'
  21605.      Output debug log. The `debug_options' string often is
  21606.      `'d:t:o,filename''.
  21607.  
  21608. `-? or --help'
  21609.      Display a help message and exit.
  21610.  
  21611. `-O var=option, --set-variable var=option'
  21612.      Set the value of a variable.  The possible variables and their
  21613.      default values for myisamchk can be examined with `myisamchk
  21614.      --help'.
  21615.      key_buffer_size      523264
  21616.      read_buffer_size     262136
  21617.      write_buffer_size    262136
  21618.      sort_buffer_size     2097144
  21619.      sort_key_blocks      16
  21620.      decode_bits          9
  21621.  
  21622.      `key_buffer_size' is only used when you check the table with `-e'
  21623.      or repair it with `-o'.  `sort_buffer_size' is used when you
  21624.      repair the table with `-r'.
  21625.  
  21626.      If you want a faster repair, set the above variables to about 1/4
  21627.      of your available memory.  You can set both variables to big
  21628.      values as only one of the above buffers will be used at a time.
  21629.  
  21630. `-s or --silent'
  21631.      Silent mode.  Write output only when errors occur. You can use `-s'
  21632.      twice (`-ss') to make `myisamchk' very silent.
  21633.  
  21634. `-v or --verbose'
  21635.      Verbose mode.  Print more information. This can be used with `-d'
  21636.      and `-e'. Use `-v' multiple times (`-vv', `-vvv') for more
  21637.      verbosity!
  21638.  
  21639. `-V or --version'
  21640.      Print the `myisamchk' version and exit.
  21641.  
  21642. `-w or, --wait'
  21643.      Instead of giving an error if the table is locked, wait until the
  21644.      table is unlocked before continuing.  Note that if you are running
  21645.      `mysqld' on the table with `--skip-locking', the table is can only
  21646.      be locked by another `myisamchk' command.
  21647.  
  21648. Check options for myisamchk
  21649. ...........................
  21650.  
  21651. `-c or --check'
  21652.      Check table for errors. This is the default operation if you are
  21653.      not giving `myisamchk' any options that overrides this.
  21654.  
  21655. `-e or --extend-check'
  21656.      Check the table VERY thoroughly (which is quite slow if you have
  21657.      many indexes).  This options should only be used extreme cases.
  21658.      Normally, `myisamchk' or `myisamchk --medium-check' should in most
  21659.      cases be able to find out if there is any errors in the table.
  21660.  
  21661.      If you are using `--extended-check' and have much memory, you
  21662.      should increase the value of `key_buffer_size' a lot!
  21663.  
  21664. `-F or --fast'
  21665.      Check only tables that hasn't been closed properly.
  21666.  
  21667. `-C or --check-only-changed'
  21668.      Check only tables that has changed since last check.
  21669.  
  21670. `-f or --force'
  21671.      Restart `myisamchk' with `-r' (repair) on the table, if
  21672.      `myisamchk' finds any errors in the table.
  21673.  
  21674. `-i or --information'
  21675.      Print informational statistics about the table that is checked.
  21676.  
  21677. `-m or --medium-check'
  21678.      Faster than extended-check, but only finds 99.99% of all errors.
  21679.      Should however be good enough for most cases.
  21680.  
  21681. `-U or --update-state'
  21682.      Store in the `.MYI' file when the table was checked and if the
  21683.      table was crashed.  This should be used to get full benefit of the
  21684.      `--check-only-changed' option, but you shouldn't use this if
  21685.      option if the `mysqld' server is using the table and you are
  21686.      running `mysqld' with `--skip-locking'.
  21687.  
  21688. `-T or --read-only'
  21689.      Don't mark table as checked. This is useful if you use `myisamchk'
  21690.      to check a table that is in use by some other application that
  21691.      doesn't use locking (like `mysqld --skip-locking')
  21692.  
  21693. Repair options for myisamchk
  21694. ............................
  21695.  
  21696. The following options are used if you start `myisamchk' with `-r' or
  21697. `-o':
  21698.  
  21699. `-D # or --data-file-length=#'
  21700.      Max length of data file (when recreating data file when it's
  21701.      'full')
  21702.  
  21703. `-e or --extend-check'
  21704.      Try to recover every possible row from the data file.  Normally
  21705.      this will also find a lot of garbage rows; Don't use this option
  21706.      if you are not totally desperate.
  21707.  
  21708. `-f or --force'
  21709.      Overwrite old temporary files (`table_name.TMD') instead of
  21710.      aborting.
  21711.  
  21712. `-k # or keys-used=#'
  21713.      If you are using ISAM, tells the ISAM table handler to update only
  21714.      the first `#' indexes.  If you are using `MyISAM' tells which keys
  21715.      to use, where each binary bit stands for one key (First key is bit
  21716.      0).  This can be used to get faster inserts!  Deactivated indexes
  21717.      can be reactivated by using `myisamchk -r'.  keys.
  21718.  
  21719. `-l or --no-symlinks'
  21720.      Do not follow symbolic links. Normally `myisamchk' repairs the
  21721.      table a symlink points at.
  21722.  
  21723. `-r or --recover'
  21724.      Can fix almost anything except unique keys that aren't unique.
  21725.      (which is a extremely unlikely error with ISAM/MyISAM tables).  If
  21726.      you want to recover a table, this is the option to try first. Only
  21727.      if myisamchk reports that the table can't be recovered by `-r', you
  21728.      should then try `-o'.  (Note that in the unlikely case that `-r'
  21729.      fails, the data file is still intact).  If you have lot's of
  21730.      memory, you should increase the size of `sort_buffer_size'!
  21731.  
  21732. `-o or --safe-recover'
  21733.      Uses an old recovery method (reads through all rows in order and
  21734.      updates all index trees based on the found rows); this is a
  21735.      magnitude slower than `-r', but can handle a couple of very
  21736.      unlikely cases that `-r' cannot handle.  This recovery method also
  21737.      uses much less disk space than `-r'. Normally one should always
  21738.      first repair with `-r' and only if this fails use `-o'.
  21739.  
  21740.      If you have lot's of memory, you should increase the size of
  21741.      `key_buffer_size'!
  21742.  
  21743. `--character-sets-dir=...'
  21744.      Directory where character sets are stored.
  21745.  
  21746. `--set-character-set=name'
  21747.      Change the character set used by the index
  21748.  
  21749. `.t or --tmpdir=path'
  21750.      Path where to store temporary files. If this is not set,
  21751.      `myisamchk' will use the environment variable `TMPDIR' for this.
  21752.  
  21753. `-q or --quick'
  21754.      Faster repair by not modifying the data file. One can give a second
  21755.      `-q' to force `myisamchk' to modify the original datafile in case
  21756.      of duplicate keys
  21757.  
  21758. `-u or --unpack'
  21759.      Unpack file packed with myisampack.
  21760.  
  21761. Other options for myisamchk
  21762. ...........................
  21763.  
  21764. Other actions that `myisamchk' can do, besides repair and check tables:
  21765.  
  21766. `-a or --analyze'
  21767.      Analyze the distribution of keys. This improves join performance by
  21768.      enabling the join optimizer to better choose in which order it
  21769.      should join the tables and which keys it should use.  `myisamchk
  21770.      --describe --verbose table_name'' or using `SHOW KEYS' in *MySQL*
  21771.  
  21772. `-d or --description'
  21773.      Prints some information about table.
  21774.  
  21775. `-A or --set-auto-increment[=value]'
  21776.      Force auto_increment to start at this or higher value. If no value
  21777.      is given, then sets the next auto_increment value to the highest
  21778.      used value for the auto key + 1.
  21779.  
  21780. `-S or --sort-index'
  21781.      Sort the index tree blocks in high-low order.  This will optimize
  21782.      seeks and will make table scanning by key faster.
  21783.  
  21784. `-R or --sort-records=#'
  21785.      Sorts records according to an index.  This makes your data much
  21786.      more localized and may speed up ranged `SELECT' and `ORDER BY'
  21787.      operations on this index. (It may be VERY slow to do a sort the
  21788.      first time!)  To find out a table's index numbers, use `SHOW
  21789.      INDEX', which shows a table's indexes in the same order that
  21790.      `myisamchk' sees them.  Indexes are numbered beginning with 1.
  21791.  
  21792. `myisamchk' memory usage
  21793. ------------------------
  21794.  
  21795. Memory allocation is important when you run `myisamchk'.  `myisamchk'
  21796. uses no more memory than you specify with the `-O' options.  If you are
  21797. going to use `myisamchk' on very large files, you should first decide
  21798. how much memory you want it to use.  The default is to use only about
  21799. 3M to fix things.  By using larger values, you can get `myisamchk' to
  21800. operate faster.  For example, if you have more than 32M RAM, you could
  21801. use options such as these (in addition to any other options you might
  21802. specify):
  21803.  
  21804.      shell> myisamchk -O sort=16M -O key=16M -O read=1M -O write=1M ...
  21805.  
  21806. Using `-O sort=16M' should probably be enough for most cases.
  21807.  
  21808. Be aware that `myisamchk' uses temporary files in `TMPDIR'. If `TMPDIR'
  21809. points to a memory file system, you may easily get out of memory
  21810. errors. If this happens, set `TMPDIR' to point at some directory with
  21811. more space and restart `myisamchk'
  21812.  
  21813. When repairing, `myisamchk' will also nead a lot of diskspace:
  21814.  
  21815.    * Double the size of the record file (The original one and a copy).
  21816.      This space is not needed if one does a repair with `--quick', as
  21817.      in this case only the index file will be recreated.  This space is
  21818.      needed on the same disk as the original record file!
  21819.  
  21820.    * Space for the new index file (that replaces the old one; The old
  21821.      index file is truncated at start, so one usually ignore this
  21822.      space).  This space is needed on the same disk as the original
  21823.      index file!
  21824.  
  21825.    * When using `--repair' (but not when using `--safe-repair', you
  21826.      will need space for a sort buffer for: `(largest_key +
  21827.      row_pointer_length)*number_of_rows * 2'.  You can check the length
  21828.      of the keys and the row_pointer_length with `myisamchk -dv table'.
  21829.      This space is allocated on the temporary disk (specified by
  21830.      `TMPDIR' or `--tmpdir=#').
  21831.  
  21832. If you have a problem with disk space during repair, you can try to use
  21833. `--safe-repair' instead of `--repair'.
  21834.  
  21835. Setting up a table maintenance regimen
  21836. ======================================
  21837.  
  21838. It is a good idea to perform table checks on a regular basis rather than
  21839. waiting for problems to occur.  For maintenance purposes, you can use
  21840. `myisamchk -s' to check tables.  The `-s' option causes `myisamchk' to
  21841. run in silent mode, printing messages only when errors occur.
  21842.  
  21843. It's a good idea to check tables when the server starts up.  For
  21844. example, whenever the machine has done a reboot in the middle of an
  21845. update, you usually need to check all the tables that could have been
  21846. affected. (This is an "expected crashed table".) You could add a test to
  21847. `safe_mysqld' that runs `myisamchk' to check all tables that have been
  21848. modified during the last 24 hours if there is an old `.pid' (process
  21849. ID) file left after a reboot.  (The `.pid' file is created by `mysqld'
  21850. when it starts up and removed when it terminates normally.  The
  21851. presence of a `.pid' file at system startup time indicates that
  21852. `mysqld' terminated abnormally.)
  21853.  
  21854. An even better test would be to check any table whose last-modified time
  21855. is more recent than that of the `.pid' file.
  21856.  
  21857. You should also check your tables regularly during normal system
  21858. operation.  At MySQL AB, we run a `cron' job to check all our important
  21859. tables once a week, using a line like this in a `crontab' file:
  21860.  
  21861.      35 0 * * 0 /path/to/myisamchk -s /path/to/datadir/*/*.MYI
  21862.  
  21863. This prints out information about crashed tables so we can examine and
  21864. repair them when needed.
  21865.  
  21866. As we haven't had any unexpectedly crashed tables (tables that become
  21867. corrupted for reasons other than hardware trouble) for a couple of
  21868. years now (this is really true), once a week is more than enough for us.
  21869.  
  21870. We recommend that to start with, you execute `myisamchk -s' each night
  21871. on all tables that have been updated during the last 24 hours, until
  21872. you come to trust *MySQL* as much as we do.
  21873.  
  21874. Getting information about a table
  21875. =================================
  21876.  
  21877. To get a description of a table or statistics about it, use the
  21878. commands shown below. We explain some of the information in more detail
  21879. later.
  21880.  
  21881. `myisamchk -d tbl_name'
  21882.      Runs `myisamchk' in "describe mode" to produce a description of
  21883.      your table. If you start the *MySQL* server using the
  21884.      `--skip-locking' option, `myisamchk' may report an error for a
  21885.      table that is updated while it runs.  However, because `myisamchk'
  21886.      doesn't change the table in describe mode, there isn't any risk of
  21887.      destroying data.
  21888.  
  21889. `myisamchk -d -v tbl_name'
  21890.      To produce more information about what `myisamchk' is doing, add
  21891.      `-v' to tell it to run in verbose mode.
  21892.  
  21893. `myisamchk -eis tbl_name'
  21894.      Shows only the most important information from a table. It is slow
  21895.      because it must read the whole table.
  21896.  
  21897. `myisamchk -eiv tbl_name'
  21898.      This is like `-eis', but tells you what is being done.
  21899.  
  21900. Example of `myisamchk -d' output:
  21901.      MyISAM file:     company.MYI
  21902.      Record format:       Fixed length
  21903.      Data records:           1403698  Deleted blocks:         0
  21904.      Recordlength:               226
  21905.      
  21906.      table description:
  21907.      Key Start Len Index   Type
  21908.      1   2     8   unique  double
  21909.      2   15    10  multip. text packed stripped
  21910.      3   219   8   multip. double
  21911.      4   63    10  multip. text packed stripped
  21912.      5   167   2   multip. unsigned short
  21913.      6   177   4   multip. unsigned long
  21914.      7   155   4   multip. text
  21915.      8   138   4   multip. unsigned long
  21916.      9   177   4   multip. unsigned long
  21917.          193   1           text
  21918.  
  21919. Example of `myisamchk -d -v' output:
  21920.      MyISAM file:         company
  21921.      Record format:       Fixed length
  21922.      File-version:        1
  21923.      Creation time:       1999-10-30 12:12:51
  21924.      Recover time:        1999-10-31 19:13:01
  21925.      Status:              checked
  21926.      Data records:           1403698  Deleted blocks:              0
  21927.      Datafile parts:         1403698  Deleted data:                0
  21928.      Datafilepointer (bytes):      3  Keyfile pointer (bytes):     3
  21929.      Max datafile length: 3791650815  Max keyfile length: 4294967294
  21930.      Recordlength:               226
  21931.      
  21932.      table description:
  21933.      Key Start Len Index   Type                  Rec/key     Root Blocksize
  21934.      1   2     8   unique  double                      1 15845376      1024
  21935.      2   15    10  multip. text packed stripped        2 25062400      1024
  21936.      3   219   8   multip. double                     73 40907776      1024
  21937.      4   63    10  multip. text packed stripped        5 48097280      1024
  21938.      5   167   2   multip. unsigned short           4840 55200768      1024
  21939.      6   177   4   multip. unsigned long            1346 65145856      1024
  21940.      7   155   4   multip. text                     4995 75090944      1024
  21941.      8   138   4   multip. unsigned long              87 85036032      1024
  21942.      9   177   4   multip. unsigned long             178 96481280      1024
  21943.          193   1           text
  21944.  
  21945. Example of `myisamchk -eis' output:
  21946.      Checking MyISAM file: company
  21947.      Key:  1:  Keyblocks used:  97%  Packed:    0%  Max levels:  4
  21948.      Key:  2:  Keyblocks used:  98%  Packed:   50%  Max levels:  4
  21949.      Key:  3:  Keyblocks used:  97%  Packed:    0%  Max levels:  4
  21950.      Key:  4:  Keyblocks used:  99%  Packed:   60%  Max levels:  3
  21951.      Key:  5:  Keyblocks used:  99%  Packed:    0%  Max levels:  3
  21952.      Key:  6:  Keyblocks used:  99%  Packed:    0%  Max levels:  3
  21953.      Key:  7:  Keyblocks used:  99%  Packed:    0%  Max levels:  3
  21954.      Key:  8:  Keyblocks used:  99%  Packed:    0%  Max levels:  3
  21955.      Key:  9:  Keyblocks used:  98%  Packed:    0%  Max levels:  4
  21956.      Total:    Keyblocks used:  98%  Packed:   17%
  21957.      
  21958.      Records:          1403698    M.recordlength:     226   Packed:             0%
  21959.      Recordspace used:     100%   Empty space:          0%  Blocks/Record:   1.00
  21960.      Record blocks:    1403698    Delete blocks:        0
  21961.      Recorddata:     317235748    Deleted data:         0
  21962.      Lost space:             0    Linkdata:             0
  21963.      
  21964.      User time 1626.51, System time 232.36
  21965.      Maximum resident set size 0, Integral resident set size 0
  21966.      Non physical pagefaults 0, Physical pagefaults 627, Swaps 0
  21967.      Blocks in 0 out 0, Messages in 0 out 0, Signals 0
  21968.      Voluntary context switches 639, Involuntary context switches 28966
  21969.  
  21970. Example of `myisamchk -eiv' output:
  21971.      Checking MyISAM file: company
  21972.      Data records: 1403698   Deleted blocks:       0
  21973.      - check file-size
  21974.      - check delete-chain
  21975.      block_size 1024:
  21976.      index  1:
  21977.      index  2:
  21978.      index  3:
  21979.      index  4:
  21980.      index  5:
  21981.      index  6:
  21982.      index  7:
  21983.      index  8:
  21984.      index  9:
  21985.      No recordlinks
  21986.      - check index reference
  21987.      - check data record references index: 1
  21988.      Key:  1:  Keyblocks used:  97%  Packed:    0%  Max levels:  4
  21989.      - check data record references index: 2
  21990.      Key:  2:  Keyblocks used:  98%  Packed:   50%  Max levels:  4
  21991.      - check data record references index: 3
  21992.      Key:  3:  Keyblocks used:  97%  Packed:    0%  Max levels:  4
  21993.      - check data record references index: 4
  21994.      Key:  4:  Keyblocks used:  99%  Packed:   60%  Max levels:  3
  21995.      - check data record references index: 5
  21996.      Key:  5:  Keyblocks used:  99%  Packed:    0%  Max levels:  3
  21997.      - check data record references index: 6
  21998.      Key:  6:  Keyblocks used:  99%  Packed:    0%  Max levels:  3
  21999.      - check data record references index: 7
  22000.      Key:  7:  Keyblocks used:  99%  Packed:    0%  Max levels:  3
  22001.      - check data record references index: 8
  22002.      Key:  8:  Keyblocks used:  99%  Packed:    0%  Max levels:  3
  22003.      - check data record references index: 9
  22004.      Key:  9:  Keyblocks used:  98%  Packed:    0%  Max levels:  4
  22005.      Total:    Keyblocks used:   9%  Packed:   17%
  22006.      
  22007.      - check records and index references
  22008.      [LOTS OF ROW NUMBERS DELETED]
  22009.      
  22010.      Records:          1403698    M.recordlength:     226   Packed:             0%
  22011.      Recordspace used:     100%   Empty space:          0%  Blocks/Record:   1.00
  22012.      Record blocks:    1403698    Delete blocks:        0
  22013.      Recorddata:     317235748    Deleted data:         0
  22014.      Lost space:             0    Linkdata:             0
  22015.      
  22016.      User time 1639.63, System time 251.61
  22017.      Maximum resident set size 0, Integral resident set size 0
  22018.      Non physical pagefaults 0, Physical pagefaults 10580, Swaps 0
  22019.      Blocks in 4 out 0, Messages in 0 out 0, Signals 0
  22020.      Voluntary context switches 10604, Involuntary context switches 122798
  22021.  
  22022. Here are the sizes of the data and index files for the table used in the
  22023. preceding examples:
  22024.  
  22025.      -rw-rw-r--   1 monty    tcx     317235748 Jan 12 17:30 company.MYD
  22026.      -rw-rw-r--   1 davida   tcx      96482304 Jan 12 18:35 company.MYM
  22027.  
  22028. Explanations for the types of information `myisamchk' produces are
  22029. given below.  The "keyfile" is the index file.  "Record" and "row" are
  22030. synonymous.
  22031.  
  22032. `ISAM file'
  22033.      Name of the ISAM (index) file.
  22034.  
  22035. `Isam-version'
  22036.      Version of ISAM format. Currently always 2.
  22037.  
  22038. `Creation time'
  22039.      When the data file was created.
  22040.  
  22041. `Recover time'
  22042.      When the index/data file was last reconstructed.
  22043.  
  22044. `Data records'
  22045.      How many records are in the table.
  22046.  
  22047. `Deleted blocks'
  22048.      How many deleted blocks still have reserved space.  You can
  22049.      optimize your table to minimize this space.  *Note Optimization::.
  22050.  
  22051. `Datafile: Parts'
  22052.      For dynamic record format, this indicates how many data blocks
  22053.      there are. For an optimized table without fragmented records, this
  22054.      is the same as `Data records'.
  22055.  
  22056. `Deleted data'
  22057.      How many bytes of non-reclaimed deleted data there are.  You can
  22058.      optimize your table to minimize this space.  *Note Optimization::.
  22059.  
  22060. `Datafile pointer'
  22061.      The size of the data file pointer, in bytes. It is usually 2, 3, 4
  22062.      or 5 bytes. Most tables manage with 2 bytes, but this cannot be
  22063.      controlled from *MySQL* yet. For fixed tables, this is a record
  22064.      address. For dynamic tables, this is a byte address.
  22065.  
  22066. `Keyfile pointer'
  22067.      The size of the index file pointer, in bytes. It is usually 1, 2
  22068.      or 3 bytes. Most tables manage with 2 bytes, but this is calculated
  22069.      automatically by *MySQL*. It is always a block address.
  22070.  
  22071. `Max datafile length'
  22072.      How long the table's data file (`.MYD' file) can become, in bytes.
  22073.  
  22074. `Max keyfile length'
  22075.      How long the table's key file (`.MYI' file) can become, in bytes.
  22076.  
  22077. `Recordlength'
  22078.      How much space each record takes, in bytes.
  22079.  
  22080. `Record format'
  22081.      The format used to store table rows.  The examples shown above use
  22082.      `Fixed length'.  Other possible values are `Compressed' and
  22083.      `Packed'.
  22084.  
  22085. `table description'
  22086.      A list of all keys in the table. For each key, some low-level
  22087.      information is presented:
  22088.  
  22089.     `Key'
  22090.           This key's number.
  22091.  
  22092.     `Start'
  22093.           Where in the record this index part starts.
  22094.  
  22095.     `Len'
  22096.           How long this index part is. For packed numbers, this should
  22097.           always be the full length of the column. For strings, it may
  22098.           be shorter than the full length of the indexed column,
  22099.           because you can index a prefix of a string column.
  22100.  
  22101.     `Index'
  22102.           `unique' or `multip.' (multiple). Indicates whether or not
  22103.           one value can exist multiple times in this index.
  22104.  
  22105.     `Type'
  22106.           What data-type this index part has. This is an ISAM data-type
  22107.           with the options `packed', `stripped' or `empty'.
  22108.  
  22109.     `Root'
  22110.           Address of the root index block.
  22111.  
  22112.     `Blocksize'
  22113.           The size of each index block. By default this is 1024, but
  22114.           the value may be changed at compile time.
  22115.  
  22116.     `Rec/key'
  22117.           This is a statistical value used by the optimizer. It tells
  22118.           how many records there are per value for this key. A unique
  22119.           key always has a value of 1. This may be updated after a
  22120.           table is loaded (or greatly changed) with `myisamchk -a'. If
  22121.           this is not updated at all, a default value of 30 is given.
  22122.  
  22123. `'
  22124.      In the first example above, the 9th key is a multi-part key with
  22125.      two parts.
  22126.  
  22127. `Keyblocks used'
  22128.      What percentage of the keyblocks are used. Because the table used
  22129.      in the examples had just been reorganized with `myisamchk', the
  22130.      values are very high (very near the theoretical maximum).
  22131.  
  22132. `Packed'
  22133.      *MySQL* tries to pack keys with a common suffix. This can only be
  22134.      used for `CHAR'/`VARCHAR'/`DECIMAL' keys. For long strings like
  22135.      names, this can significantly reduce the space used. In the third
  22136.      example above, the 4th key is 10 characters long and a 60%
  22137.      reduction in space is achieved.
  22138.  
  22139. `Max levels'
  22140.      How deep the B-tree for this key is. Large tables with long keys
  22141.      get high values.
  22142.  
  22143. `Records'
  22144.      How many rows are in the table.
  22145.  
  22146. `M.recordlength'
  22147.      The average record length. For tables with fixed-length records,
  22148.      this is the exact record length.
  22149.  
  22150. `Packed'
  22151.      *MySQL* strips spaces from the end of strings. The `Packed' value
  22152.      indicates the percentage savings achieved by doing this.
  22153.  
  22154. `Recordspace used'
  22155.      What percentage of the data file is used.
  22156.  
  22157. `Empty space'
  22158.      What percentage of the data file is unused.
  22159.  
  22160. `Blocks/Record'
  22161.      Average number of blocks per record (i.e., how many links a
  22162.      fragmented record is composed of). This is always 1 for
  22163.      fixed-format tables. This value should stay as close to 1.0 as
  22164.      possible. If it gets too big, you can reorganize the table with
  22165.      `myisamchk'.  *Note Optimization::.
  22166.  
  22167. `Recordblocks'
  22168.      How many blocks (links) are used. For fixed format, this is the
  22169.      same as the number of records.
  22170.  
  22171. `Deleteblocks'
  22172.      How many blocks (links) are deleted.
  22173.  
  22174. `Recorddata'
  22175.      How many bytes in the data file are used.
  22176.  
  22177. `Deleted data'
  22178.      How many bytes in the data file are deleted (unused).
  22179.  
  22180. `Lost space'
  22181.      If a record is updated to a shorter length, some space is lost.
  22182.      This is the sum of all such losses, in bytes.
  22183.  
  22184. `Linkdata'
  22185.      When the dynamic table format is used, record fragments are linked
  22186.      with pointers (4 to 7 bytes each). `Linkdata' is the sum of the
  22187.      amount of storage used by all such pointers.
  22188.  
  22189. If a table has been compressed with `myisampack', `myisamchk -d' prints
  22190. additional information about each table column.  See *Note
  22191. `myisampack': myisampack, for an example of this information and a
  22192. description of what it means.
  22193.  
  22194. Using `myisamchk' for crash recovery
  22195. ====================================
  22196.  
  22197. If you run `mysqld' with `--skip-locking' (which is the default on some
  22198. systems, like Linux), you can't reliably use `myisamchk' to check a
  22199. table when `mysqld' is using the same table.  If you can be sure that
  22200. no one is accessing the tables through `mysqld' while you run
  22201. `myisamchk', you only have to do `mysqladmin flush-tables' before you
  22202. start checking the tables.  If you can't guarantee the above, then you
  22203. must take down `mysqld' while you check the tables.  If you run
  22204. `myisamchk' while `mysqld' is updating the tables, you may get a
  22205. warning that a table is corrupt even if it isn't.
  22206.  
  22207. If you are not using `--skip-locking', you can use `myisamchk' to check
  22208. tables at any time.  While you do this, all clients that try to update
  22209. the table will wait until `myisamchk' is ready before continuing.
  22210.  
  22211. If you use `myisamchk' to repair or optimize tables, you *MUST* always
  22212. ensure that the `mysqld' server is not using the table (this also
  22213. applies if you are using `--skip-locking').  If you don't take down
  22214. `mysqld' you should at least do a `mysqladmin flush-tables' before you
  22215. run `myisamchk'.
  22216.  
  22217. The file format that *MySQL* uses to store data has been extensively
  22218. tested, but there are always external circumstances that may cause
  22219. database tables to become corrupted:
  22220.  
  22221.    * The `mysqld' process being killed in the middle of a write.
  22222.  
  22223.    * Unexpected shutdown of the computer (for example, if the computer
  22224.      is turned off).
  22225.  
  22226.    * A hardware error.
  22227.  
  22228. This chapter describes how to check for and deal with data corruption
  22229. in *MySQL* databases.  If your tables get corrupted a lot you should
  22230. try to find the reason for this! *Note Debugging server::.
  22231.  
  22232. When performing crash recovery, it is important to understand that each
  22233. table `tbl_name' in a database corresponds to three files in the
  22234. database directory:
  22235.  
  22236. *File*         *Purpose*
  22237. `tbl_name.frm' Table definition (form) file
  22238. `tbl_name.MYD' Data file
  22239. `tbl_name.MYI' Index file
  22240.  
  22241. Each of these three file types is subject to corruption in various
  22242. ways, but problems occur most often in data files and index files.
  22243.  
  22244. `myisamchk' works by creating a copy of the `.MYD' (data) file row by
  22245. row. It ends the repair stage by removing the old `.MYD' file and
  22246. renaming the new file to the original file name.  If you use `--quick',
  22247. `myisamchk' does not create a temporary `.MYD' file, but instead
  22248. assumes that the `.MYD' file is correct and only generates a new index
  22249. file without touching the `.MYD' file. This is safe, because
  22250. `myisamchk' automatically detects if the `.MYD' file is corrupt and
  22251. aborts the repair in this case.  You can also give two `--quick'
  22252. options to `myisamchk'.  In this case, `myisamchk' does not abort on
  22253. some errors (like duplicate key) but instead tries to resolve them by
  22254. modifying the `.MYD' file. Normally the use of two `--quick' options is
  22255. useful only if you have too little free disk space to perform a normal
  22256. repair.  In this case you should at least make a backup before running
  22257. `myisamchk'.
  22258.  
  22259. How to check tables for errors
  22260. ------------------------------
  22261.  
  22262. To check a table, use the following commands:
  22263.  
  22264. `myisamchk tbl_name'
  22265.      This finds 99.99% of all errors. What it can't find is corruption
  22266.      that involves *ONLY* the data file (which is very unusual). If you
  22267.      want to check a table, you should normally run `myisamchk' without
  22268.      options or with either the `-s' or `--silent' option.
  22269.  
  22270. `myisamchk -m tbl_name'
  22271.      This finds 99.999% of all errors. It checks first all index for
  22272.      errors and then it reads through all rows. It calculates a
  22273.      checksum for all keys in the rows and verifies that they checksum
  22274.      matches the checksum for the keys in the index tree.
  22275.  
  22276. `myisamchk -e tbl_name'
  22277.      This does a complete and thorough check of all data (`-e' means
  22278.      "extended check"). It does a check-read of every key for each row
  22279.      to verify that they indeed point to the correct row.  This may
  22280.      take a LONG time on a big table with many keys.  `myisamchk' will
  22281.      normally stop after the first error it finds. If you want to
  22282.      obtain more information, you can add the `--verbose' (`-v')
  22283.      option.  This causes `myisamchk' to keep going, up through a
  22284.      maximum of 20 errors.  In normal usage, a simple `myisamchk' (with
  22285.      no arguments other than the table name) is sufficient.
  22286.  
  22287. `myisamchk -e -i tbl_name'
  22288.      Like the previous command, but the `-i' option tells `myisamchk' to
  22289.      print some informational statistics, too.
  22290.  
  22291. How to repair tables
  22292. --------------------
  22293.  
  22294. In the following we only talk about using `myisamchk' on `MyISAM'
  22295. tables (extensions `.MYI' and `.MYD').  If you are using `ISAM' tables
  22296. (extensions `.ISM' and `.ISD'), you should use `isamchk' instead.
  22297.  
  22298. The symptoms of a corrupted table are usually that queries abort
  22299. unexpectedly and you observe errors such as these:
  22300.  
  22301.    * `tbl_name.frm' is locked against change
  22302.  
  22303.    * Can't find file `tbl_name.MYI' (Errcode: ###)
  22304.  
  22305.    * Got error ### from table handler (Error 135 is an exception in
  22306.      this case)
  22307.  
  22308.    * Unexpected end of file
  22309.  
  22310.    * Record file is crashed
  22311.  
  22312. In these cases, you must repair your tables. `myisamchk' can usually
  22313. detect and fix most things that go wrong.
  22314.  
  22315. The repair process involves up to four stages, described below. Before
  22316. you begin, you should `cd' to the database directory and check the
  22317. permissions of the table files. Make sure they are readable by the Unix
  22318. user that `mysqld' runs as (and to you, because you need to access the
  22319. files you are checking).  If it turns out you need to modify files,
  22320. they must also be writable by you.
  22321.  
  22322. If you are using *MySQL* 3.23.16 and above you can (and should) use the
  22323. `CHECK' and `REPAIR' commands to check and repair `MyISAM' tables.
  22324. *Note CHECK TABLE::. *Note REPAIR TABLE::.
  22325.  
  22326. The manual section about table maintenence includes the options to
  22327. `isamchk'/`myisamchk'. *Note Table maintenance::.
  22328.  
  22329. The following section is for the cases where the above command fails or
  22330. if you want to use the extended features that isamchk/myisamchk
  22331. provides.
  22332.  
  22333. If you are going to repair a table from the command line, you must first
  22334. take down the `mysqld' server. Note that when you do `mysqladmin
  22335. shutdown' on a remote server, the `mysqld' server will still be alive
  22336. for a while after `mysqladmin' returns until all queries are stopped
  22337. and all keys have been flushed to disk.
  22338.  
  22339. *Stage 1: Checking your tables*
  22340.  
  22341. Run `myisamchk *.MYI' or (`myisamchk -e *.MYI' if you have more time).
  22342. Use the `-s' (silent) option to suppress unnecessary information.
  22343.  
  22344. If the mysqld server is done you should use the -update option to tell
  22345. `myisamchk' to mark the table as 'checked'.
  22346.  
  22347. You have to repair only those tables for which `myisamchk' announces an
  22348. error.  For such tables, proceed to Stage 2.
  22349.  
  22350. If you get weird errors when checking (such as `out of memory' errors),
  22351. or if `myisamchk' crashes, go to Stage 3.
  22352.  
  22353. *Stage 2: Easy safe repair*
  22354.  
  22355. Note: If you want repairing to go much faster, you should add: `-O
  22356. sort_buffer=# -O key_buffer=#' (where # is about 1/4 of the available
  22357. memory) to all `isamchk/myisamchk' commands.
  22358.  
  22359. First, try `myisamchk -r -q tbl_name' (`-r -q' means "quick recovery
  22360. mode"). This will attempt to repair the index file without touching the
  22361. data file.  If the data file contains everything that it should and the
  22362. delete links point at the correct locations within the data file, this
  22363. should work, and the table is fixed. Start repairing the next table.
  22364. Otherwise, use the following procedure:
  22365.  
  22366.   1. Make a backup of the data file before continuing.
  22367.  
  22368.   2. Use `myisamchk -r tbl_name' (`-r' means "recovery mode"). This will
  22369.      remove incorrect records and deleted records from the data file and
  22370.      reconstruct the index file.
  22371.  
  22372.   3. If the preceding step fails, use `myisamchk --safe-recover
  22373.      tbl_name'.  Safe recovery mode uses an old recovery method that
  22374.      handles a few cases that regular recovery mode doesn't (but is
  22375.      slower).
  22376.  
  22377. If you get weird errors when repairing (such as `out of memory'
  22378. errors), or if `myisamchk' crashes, go to Stage 3.
  22379.  
  22380. *Stage 3: Difficult repair*
  22381.  
  22382. You should only reach this stage if the first 16K block in the index
  22383. file is destroyed or contains incorrect information, or if the index
  22384. file is missing.  In this case, it's necessary to create a new index
  22385. file. Do so as follows:
  22386.  
  22387.   1. Move the data file to some safe place.
  22388.  
  22389.   2. Use the table description file to create new (empty) data and
  22390.      index files:
  22391.  
  22392.           shell> mysql db_name
  22393.           mysql> SET AUTOCOMMIT=1;
  22394.           mysql> DELETE FROM tbl_name;
  22395.           mysql> quit
  22396.  
  22397.   3. Copy the old data file back onto the newly created data file.
  22398.      (Don't just move the old file back onto the new file; you want to
  22399.      retain a copy in case something goes wrong.)
  22400.  
  22401. Go back to Stage 2.  `myisamchk -r -q' should work now.  (This shouldn't
  22402. be an endless loop).
  22403.  
  22404. *Stage 4: Very difficult repair*
  22405.  
  22406. You should reach this stage only if the description file has also
  22407. crashed. That should never happen, because the description file isn't
  22408. changed after the table is created.
  22409.  
  22410.   1. Restore the description file from a backup and go back to Stage 3.
  22411.      You can also restore the index file and go back to Stage 2.  In
  22412.      the latter case, you should start with `myisamchk -r'.
  22413.  
  22414.   2. If you don't have a backup but know exactly how the table was
  22415.      created, create a copy of the table in another database.  Remove
  22416.      the new data file, then move the description and index files from
  22417.      the other database to your crashed database.  This gives you new
  22418.      description and index files, but leaves the data file alone.  Go
  22419.      back to Stage 2 and attempt to reconstruct the index file.
  22420.  
  22421. Table optimization
  22422. ------------------
  22423.  
  22424. To coalesce fragmented records and eliminate wasted space resulting from
  22425. deleting or updating records, run `myisamchk' in recovery mode:
  22426.  
  22427.      shell> myisamchk -r tbl_name
  22428.  
  22429. You can optimize a table in the same way using the SQL `OPTIMIZE TABLE'
  22430. statement.  `OPTIMIZE TABLE' is easier, but `myisamchk' is faster.
  22431. There is also no possibility of unwanted interaction between a utility
  22432. and the server, because the server does all the work when you use
  22433. `OPTIMIZE TABLE'.
  22434.  
  22435. `myisamchk' also has a number of other options you can use to improve
  22436. the performance of a table:
  22437.  
  22438. `-S, --sort-index'
  22439.  
  22440. `-R index_num, --sort-records=index_num'
  22441.  
  22442. `-a, --analyze'
  22443. For a full description of the option see *Note myisamchk syntax::.
  22444.  
  22445. Log file maintenance
  22446. ====================
  22447.  
  22448. When using *MySQL* with log files, you will from time to time want to
  22449. remove/backup old log files and tell *MySQL* to start logging on new
  22450. files.  *Note Update log::.
  22451.  
  22452. On a Linux (`Redhat') installation, you can use the `mysql-log-rotate'
  22453. script for this. If you installed *MySQL* from an RPM distribution, the
  22454. script should have been installed automatically.
  22455.  
  22456. On other systems you must install a short script yourself that you
  22457. start from `cron' to handle log files.
  22458.  
  22459. You can force *MySQL* to start using new log files by using `mysqladmin
  22460. flush-logs' or by using the SQL command `FLUSH LOGS'.  If you are using
  22461. *MySQL* 3.21 you must use `mysqladmin refresh'.
  22462.  
  22463. The above command does the following:
  22464.  
  22465.    * If standard logging (`--log') is used, closes and reopens the log
  22466.      file.  (`mysql.log' as default).
  22467.  
  22468.    * If update logging (`--log-update') is used, closes the update log
  22469.      and opens a new log file with a higher sequence number.
  22470.  
  22471. If you are using only an update log, you only have to flush the logs
  22472. and then move away the old update log files to a backup.  If you are
  22473. using the normal logging, you can do something like:
  22474.  
  22475.      shell> cd mysql-data-directory
  22476.      shell> mv mysql.log mysql.old
  22477.      shell> mysqladmin flush-logs
  22478.  
  22479. and then take a backup and remove `mysql.old'.
  22480.  
  22481. Adding new functions to MySQL
  22482. *****************************
  22483.  
  22484. There are two ways to add new functions to *MySQL*:
  22485.  
  22486.    * You can add the function through the user-definable function (UDF)
  22487.      interface.  User-definable functions are added and removed
  22488.      dynamically using the `CREATE FUNCTION' and `DROP FUNCTION'
  22489.      statements.  *Note `CREATE FUNCTION': CREATE FUNCTION.
  22490.  
  22491.    * You can add the function as a native (built in) *MySQL* function.
  22492.      Native functions are compiled into the `mysqld' server and become
  22493.      available on a permanent basis.
  22494.  
  22495. Each method has advantages and disadvantages:
  22496.  
  22497.    * If you write a user-definable function, you must install the
  22498.      object file in addition to the server itself.  If you compile your
  22499.      function into the server, you don't need to do that.
  22500.  
  22501.    * You can add UDFs to a binary *MySQL* distribution.  Native
  22502.      functions require you to modify a source distribution.
  22503.  
  22504.    * If you upgrade your *MySQL* distribution, you can continue to use
  22505.      your previously-installed UDFs.  For native functions, you must
  22506.      repeat your modifications each time you upgrade.
  22507.  
  22508. Whichever method you use to add new functions, they may be used just
  22509. like native functions such as `ABS()' or `SOUNDEX()'.
  22510.  
  22511. Adding a new user-definable function
  22512. ====================================
  22513.  
  22514. For the UDF mechanism to work, functions must be written in C or C++
  22515. and your operating system must support dynamic loading.  The *MySQL*
  22516. source distribution includes a file `sql/udf_example.cc' that defines 5
  22517. new functions.  Consult this file to see how UDF calling conventions
  22518. work.
  22519.  
  22520. For each function that you want to use in SQL statements, you should
  22521. define corresponding C (or C++) functions.  In the discussion below,
  22522. the name "xxx" is used for an example function name.  To distinquish
  22523. between SQL and C/C++ usage, `XXX()' (uppercase) indicates a SQL
  22524. function call, and `xxx()' (lowercase) indicates a C/C++ function call.
  22525.  
  22526. The C/C++ functions that you write to implement the inferface for
  22527. `XXX()' are:
  22528.  
  22529. `xxx()' (required)
  22530.      The main function.  This is where the function result is computed.
  22531.      The correspondence between the SQL type and return type of your
  22532.      C/C++ function is shown below:
  22533.  
  22534.      *SQL type*    *C/C++ type*
  22535.      `STRING'      `char *'
  22536.      `INTEGER'     `long long'
  22537.      `REAL'        `double'
  22538.  
  22539. `xxx_init()' (optional)
  22540.      The initialization function for `xxx()'.  It can be used to:
  22541.  
  22542.         * Check the number of arguments to `XXX()'.
  22543.  
  22544.         * Check that the arguments are of a required type, or,
  22545.           alternatively, tell *MySQL* to coerce arguments to the types
  22546.           you want when the main function is called.
  22547.  
  22548.         * Allocate any memory required by the main function.
  22549.  
  22550.         * Specify the maximum length of the result.
  22551.  
  22552.         * Specify (for `REAL' functions) the maximum number of decimals.
  22553.  
  22554.         * Specify whether or not the result can be `NULL'.
  22555.  
  22556. `xxx_deinit()' (optional)
  22557.      The deinitialization function for `xxx()'.  It should deallocate
  22558.      any memory allocated by the initialization function.
  22559.  
  22560. When a SQL statement invokes `XXX()', *MySQL* calls the initialization
  22561. function `xxx_init()' to let it perform any required setup, such as
  22562. argument checking or memory allocation.  If `xxx_init()' returns an
  22563. error, the SQL statement is aborted with an error message and the main
  22564. and deinitialization functions are not called.  Otherwise, the main
  22565. function `xxx()' is called once for each row.  After all rows have been
  22566. processed, the deinitialization function `xxx_deinit()' is called so it
  22567. can perform any required cleanup.
  22568.  
  22569. All functions must be thread-safe (not just the main function, but the
  22570. initialization and deinitialization functions as well). This means that
  22571. you are not allowed to allocate any global or static variables that
  22572. change!  If you need memory, you should allocate it in `xxx_init()' and
  22573. free it in `xxx_deinit()'.
  22574.  
  22575. UDF calling sequences
  22576. ---------------------
  22577.  
  22578. The main function should be declared as shown below.  Note that the
  22579. return type and parameters differ, depending on whether you will
  22580. declare the SQL function `XXX()' to return `STRING', `INTEGER' or `REAL'
  22581. in the `CREATE FUNCTION' statement:
  22582.  
  22583. For `STRING' functions:
  22584.  
  22585.      char *xxx(UDF_INIT *initid, UDF_ARGS *args,
  22586.                    char *result, unsigned long *length,
  22587.                    char *is_null, char *error);
  22588.  
  22589. For `INTEGER' functions:
  22590.  
  22591.      long long xxx(UDF_INIT *initid, UDF_ARGS *args,
  22592.                    char *is_null, char *error);
  22593.  
  22594. For `REAL' functions:
  22595.  
  22596.      double xxx(UDF_INIT *initid, UDF_ARGS *args,
  22597.                    char *is_null, char *error);
  22598.  
  22599. The initialization and deinitialization functions are declared like
  22600. this:
  22601.  
  22602.      my_bool xxx_init(UDF_INIT *initid, UDF_ARGS *args, char *message);
  22603.      
  22604.      void xxx_deinit(UDF_INIT *initid);
  22605.  
  22606. The `initid' parameter is passed to all three functions.  It points to a
  22607. `UDF_INIT' structure that is used to communicate information between
  22608. functions.  The `UDF_INIT' structure members are listed below.  The
  22609. initialization function should fill in any members that it wishes to
  22610. change.  (To use the default for a member, leave it unchanged.)
  22611.  
  22612. `my_bool maybe_null'
  22613.      `xxx_init()' should set `maybe_null' to `1' if `xxx()' can return
  22614.      `NULL'.  The default value is `1' if any of the arguments are
  22615.      declared `maybe_null'.
  22616.  
  22617. `unsigned int decimals'
  22618.      Number of decimals.  The default value is the maximum number of
  22619.      decimals in the arguments passed to the main function.  (For
  22620.      example, if the function is passed `1.34', `1.345' and `1.3', the
  22621.      default would be 3, because `1.345' has 3 decimals.
  22622.  
  22623. `unsigned int max_length'
  22624.      The maximum length of the string result.  The default value
  22625.      differs depending on the result type of the function.  For string
  22626.      functions, the default is the length of the longest argument.  For
  22627.      integer functions, the default is 21 digits.  For real functions,
  22628.      the default is 13 plus the number of decimals indicated by
  22629.      `initid->decimals'.  (For numeric functions, the length includes
  22630.      any sign or decimal point characters.)
  22631.  
  22632. `char *ptr'
  22633.      A pointer that the function can use for its own purposes.  For
  22634.      example, functions can use `initid->ptr' to communicate allocated
  22635.      memory between functions.  In `xxx_init()', allocate the memory
  22636.      and assign it to this pointer:
  22637.  
  22638.           initid->ptr = allocated_memory;
  22639.  
  22640.      In `xxx()' and `xxx_deinit()', refer to `initid->ptr' to use or
  22641.      deallocate the memory.
  22642.  
  22643. Argument processing
  22644. -------------------
  22645.  
  22646. The `args' parameter points to a `UDF_ARGS' structure which has the
  22647. members listed below:
  22648.  
  22649. `unsigned int arg_count'
  22650.      The number of arguments.  Check this value in the initialization
  22651.      function if you want your function to be called with a particular
  22652.      number of arguments.  For example:
  22653.  
  22654.           if (args->arg_count != 2)
  22655.           {
  22656.               strcpy(message,"XXX() requires two arguments");
  22657.               return 1;
  22658.           }
  22659.  
  22660. `enum Item_result *arg_type'
  22661.      The types for each argument.  The possible type values are
  22662.      `STRING_RESULT', `INT_RESULT' and `REAL_RESULT'.
  22663.  
  22664.      To make sure that arguments are of a given type and return an
  22665.      error if they are not, check the `arg_type' array in the
  22666.      initialization function.  For example:
  22667.  
  22668.           if (args->arg_type[0] != STRING_RESULT ||
  22669.               args->arg_type[1] != INT_RESULT)
  22670.           {
  22671.               strcpy(message,"XXX() requires a string and an integer");
  22672.               return 1;
  22673.           }
  22674.  
  22675.      As an alternative to requiring your function's arguments to be of
  22676.      particular types, you can use the initialization function to set
  22677.      the `arg_type' elements to the types you want.  This causes
  22678.      *MySQL* to coerce arguments to those types for each call to
  22679.      `xxx()'.  For example, to specify coercion of the first two
  22680.      arguments to string and integer, do this in `xxx_init()':
  22681.  
  22682.           args->arg_type[0] = STRING_RESULT;
  22683.           args->arg_type[1] = INT_RESULT;
  22684.  
  22685. `char **args'
  22686.      `args->args' communicates information to the initialization
  22687.      function about the general nature of the arguments your function
  22688.      was called with.  For a constant argument `i', `args->args[i]'
  22689.      points to the argument value.  (See below for instructions on how
  22690.      to access the value properly.)  For a non-constant argument,
  22691.      `args->args[i]' is `0'.  A constant argument is an expression that
  22692.      uses only constants, such as `3' or `4*7-2' or `SIN(3.14)'.  A
  22693.      non-constant argument is an expression that refers to values that
  22694.      may change from row to row, such as column names or functions that
  22695.      are called with non-constant arguments.
  22696.  
  22697.      For each invocation of the main function, `args->args' contains the
  22698.      actual arguments that are passed for the row currently being
  22699.      processed.
  22700.  
  22701.      Functions can refer to an argument `i' as follows:
  22702.  
  22703.         * An argument of type `STRING_RESULT' is given as a string
  22704.           pointer plus a length, to allow handling of binary data or
  22705.           data of arbitrary length.  The string contents are available
  22706.           as `args->args[i]' and the string length is
  22707.           `args->lengths[i]'.  You should not assume that strings are
  22708.           null-terminated.
  22709.  
  22710.         * For an argument of type `INT_RESULT', you must cast
  22711.           `args->args[i]' to a `long long' value:
  22712.  
  22713.                long long int_val;
  22714.                int_val = *((long long*) args->args[i]);
  22715.  
  22716.         * For an argument of type `REAL_RESULT', you must cast
  22717.           `args->args[i]' to a `double' value:
  22718.  
  22719.                double    real_val;
  22720.                real_val = *((double*) args->args[i]);
  22721.  
  22722. `unsigned long *lengths'
  22723.      For the initialization function, the `lengths' array indicates the
  22724.      maximum string length for each argument.  For each invocation of
  22725.      the main function, `lengths' contains the actual lengths of any
  22726.      string arguments that are passed for the row currently being
  22727.      processed.  For arguments of types `INT_RESULT' or `REAL_RESULT',
  22728.      `lengths' still contains the maximum length of the argument (as
  22729.      for the initialization function).
  22730.  
  22731. Return values and error handling
  22732. --------------------------------
  22733.  
  22734. The initialization function should return `0' if no error occurred and
  22735. `1' otherwise.  If an error occurs, `xxx_init()' should store a
  22736. null-terminated error message in the `message' parameter.  The message
  22737. will be returned to the client.  The message buffer is
  22738. `MYSQL_ERRMSG_SIZE' characters long, but you should try to keep the
  22739. message to less than 80 characters so that it fits the width of a
  22740. standard terminal screen.
  22741.  
  22742. The return value of the main function `xxx()' is the function value, for
  22743. `long long' and `double' functions.  For string functions, the string
  22744. is returned in the `result' and `length' arguments.  `result' is a
  22745. buffer at least 255 bytes long.  Set these to the contents and length
  22746. of the return value.  For example:
  22747.  
  22748.      memcpy(result, "result string", 13);
  22749.      *length = 13;
  22750.  
  22751. The string function return value normally also points to the result.
  22752.  
  22753. To indicate a return value of `NULL' in the main function, set
  22754. `is_null' to `1':
  22755.  
  22756.      *is_null = 1;
  22757.  
  22758. To indicate an error return in the main function, set the `error'
  22759. parameter to `1':
  22760.  
  22761.      *error = 1;
  22762.  
  22763. If `xxx()' sets `*error' to `1' for any row, the function value is
  22764. `NULL' for the current row and for any subsequent rows processed by the
  22765. statement in which `XXX()' was invoked.  (`xxx()' will not even be
  22766. called for subsequent rows.) *Note:* In *MySQL* versions prior to
  22767. 3.22.10, you should set both `*error' and `*is_null':
  22768.  
  22769.      *error = 1;
  22770.      *is_null = 1;
  22771.  
  22772. Compiling and installing user-definable functions
  22773. -------------------------------------------------
  22774.  
  22775. Files implementing UDFs must be compiled and installed on the host
  22776. where the server runs.  This process is described below for the example
  22777. UDF file `udf_example.cc' that is included in the *MySQL* source
  22778. distribution.  This file contains the following functions:
  22779.  
  22780.    * `metaphon()' returns a metaphon string of the string argument.
  22781.      This is something like a soundex string, but it's more tuned for
  22782.      English.
  22783.  
  22784.    * `myfunc_double()' returns the sum of the ASCII values of the
  22785.      characters in its arguments, divided by the sum of the length of
  22786.      its arguments.
  22787.  
  22788.    * `myfunc_int()' returns the sum of the length of its arguments.
  22789.  
  22790.    * `lookup()' returns the IP number for a hostname.
  22791.  
  22792.    * `reverse_lookup()' returns the hostname for an IP number.  The
  22793.      function may be called with a string `"xxx.xxx.xxx.xxx"' or four
  22794.      numbers.
  22795.  
  22796. A dynamically-loadable file should be compiled as a sharable object
  22797. file, using a command something like this:
  22798.  
  22799.      shell> gcc -shared -o udf_example.so myfunc.cc
  22800.  
  22801. You can easily find out the correct compiler options for your system by
  22802. running this command in the `sql' directory of your *MySQL* source tree:
  22803.  
  22804.      shell> make udf_example.o
  22805.  
  22806. You should run a compile command similar to the one that `make'
  22807. displays, except that you should remove the `-c' option near the end of
  22808. the line and add `-o udf_example.so' to the end of the line.  (On some
  22809. systems, you may need to leave  the `-c' on the command.)
  22810.  
  22811. Once you compile a shared object containing UDFs, you must install it
  22812. and tell *MySQL* about it.  Compiling a shared object from
  22813. `udf_example.cc' produces a file named something like `udf_example.so'
  22814. (the exact name may vary from platform to platform).  Copy this file to
  22815. some directory searched by `ld', such as `/usr/lib'.  On many systems,
  22816. you can set the `LD_LIBRARY' or `LD_LIBRARY_PATH' environment variable
  22817. to point at the directory where you have your UDF function files. The
  22818. `dlopen' manual page tells you which variable you should use on your
  22819. system. You should set this in `mysql.server' or `safe_mysqld' and
  22820. restart `mysqld'.
  22821.  
  22822. After the library is installed, notify `mysqld' about the new functions
  22823. with these commands:
  22824.  
  22825.      mysql> CREATE FUNCTION metaphon RETURNS STRING SONAME "udf_example.so";
  22826.      mysql> CREATE FUNCTION myfunc_double RETURNS REAL SONAME "udf_example.so";
  22827.      mysql> CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "udf_example.so";
  22828.      mysql> CREATE FUNCTION lookup RETURNS STRING SONAME "udf_example.so";
  22829.      mysql> CREATE FUNCTION reverse_lookup RETURNS STRING SONAME "udf_example.so";
  22830.  
  22831. Functions can be deleted using `DROP FUNCTION':
  22832.  
  22833.      mysql> DROP FUNCTION metaphon;
  22834.      mysql> DROP FUNCTION myfunc_double;
  22835.      mysql> DROP FUNCTION myfunc_int;
  22836.      mysql> DROP FUNCTION lookup;
  22837.      mysql> DROP FUNCTION reverse_lookup;
  22838.  
  22839. The `CREATE FUNCTION' and `DROP FUNCTION' statements update the system
  22840. table `func' in the `mysql' database.  The function's name, type and
  22841. shared library name are saved in the table.  You must have the *insert*
  22842. and *delete* privileges for the `mysql' database to create and drop
  22843. functions.
  22844.  
  22845. You should not use `CREATE FUNCTION' to add a function that has already
  22846. been created.  If you need to reinstall a function, you should remove
  22847. it with `DROP FUNCTION' and then reinstall it with `CREATE FUNCTION'.
  22848. You would need to do this, for example, if you recompile a new version
  22849. of your function, so that `mysqld' gets the new version.  Otherwise the
  22850. server will continue to use the old version.
  22851.  
  22852. Active functions are reloaded each time the server starts, unless you
  22853. start `mysqld' with the `--skip-grant-tables' option.  In this case, UDF
  22854. initialization is skipped and UDFs are unavailable.  (An active
  22855. function is one that has been loaded with `CREATE FUNCTION' and not
  22856. removed with `DROP FUNCTION'.)
  22857.  
  22858. Adding a new native function
  22859. ============================
  22860.  
  22861. The procedure for adding a new native function is described below.
  22862. Note that you cannot add native functions to a binary distribution
  22863. because the procedure involves modifying *MySQL* source code.  You must
  22864. compile *MySQL* yourself from a source distribution.  Also note that if
  22865. you migrate to another version of *MySQL* (e.g., when a new version is
  22866. released), you will need to repeat the procedure with the new version.
  22867.  
  22868. To add a new native *MySQL* function, follow these steps:
  22869.  
  22870.   1. Add one line to `lex.h' that defines the function name in the
  22871.      `sql_functions[]' array.
  22872.  
  22873.   2. Add two lines to `sql_yacc.yy'. One indicates the preprocessor
  22874.      symbol that `yacc' should define (this should be added at the
  22875.      beginning of the file). Then define the function parameters and
  22876.      add an "item" with these parameters to the `simple_expr' parsing
  22877.      rule.  For an example, check all occurrences of `SOUNDEX' in
  22878.      `sql_yacc.yy' to see how this is done.
  22879.  
  22880.   3. In `item_func.h', declare a class inheriting from `Item_num_func'
  22881.      or `Item_str_func', depending on whether your function returns a
  22882.      number or a string.
  22883.  
  22884.   4. In `item_func.cc', add one of the following declarations, depending
  22885.      on whether you are defining a numeric or string function:
  22886.           double   Item_func_newname::val()
  22887.           longlong Item_func_newname::val_int()
  22888.           String  *Item_func_newname::Str(String *str)
  22889.  
  22890.   5. You should probably also define the following function:
  22891.           void Item_func_newname::fix_length_and_dec()
  22892.      This function should at least calculate `max_length' based on the
  22893.      given arguments. `max_length' is the maximum number of characters
  22894.      the function may return.  This function should also set
  22895.      `maybe_null = 0' if the main function can't return a `NULL' value.
  22896.      The function can check if any of the function arguments can
  22897.      return `NULL' by checking the arguments `maybe_null' variable.
  22898.  
  22899. All functions must be thread-safe.
  22900.  
  22901. For string functions, there are some additional considerations to be
  22902. aware of:
  22903.    * The `String *str' argument provides a string buffer that may be
  22904.      used to hold the result.
  22905.  
  22906.    * The function should return the string that holds the result.
  22907.  
  22908.    * All current string functions try to avoid allocating any memory
  22909.      unless absolutely necessary!
  22910.  
  22911. Adding new procedures to MySQL
  22912. ******************************
  22913.  
  22914. In *MySQL*, you can define a procedure in C++ that can access and
  22915. modify the data in a query before it is sent to the client.  The
  22916. modification can be done on row by row or `GROUP BY' level.
  22917.  
  22918. We have created an example procedure in *MySQL* 3.23 to show you what
  22919. can be done.
  22920.  
  22921. Procedure analyse
  22922. =================
  22923.  
  22924. `analyse([max elements,[max memory]])'
  22925.  
  22926. This procedure is defined in the `sql/sql_analyse.cc'.  This examines
  22927. the result from your query and returns an analysis of the results.
  22928.  
  22929.    * `max elements' (default 256) is the maximum number of distinct
  22930.      values `analyse' will notice per column.  This is used by
  22931.      `analyse' to check if the optimal column type should be of type
  22932.      `ENUM'.
  22933.  
  22934.    * `max memory' (default 8192) is the maximum memory `analyse' should
  22935.      allocate per column while trying to find all distinct values.
  22936.  
  22937.      SELECT ... FROM ... WHERE ... PROCEDURE ANALYSE([max elements,[max memory]])
  22938.  
  22939. Writing a procedure.
  22940. ====================
  22941.  
  22942. For the moment, the only documentation for this is the source. :(
  22943.  
  22944. You can find all information about procedures by examining the
  22945. following files:
  22946.  
  22947.    * `sql/sql_analyse.cc'
  22948.  
  22949.    * `sql/procedure.h'
  22950.  
  22951.    * `sql/procedure.cc'
  22952.  
  22953.    * `sql/sql_select.cc'
  22954.  
  22955. MySQL ODBC Support
  22956. ******************
  22957.  
  22958. *MySQL* provides support for ODBC by means of the *MyODBC* program.
  22959.  
  22960. Operating systems supported by MyODBC
  22961. =====================================
  22962.  
  22963. *MyODBC* is a 32-bit ODBC (2.50) level 0 driver for connecting an
  22964. ODBC-aware application to *MySQL*.  *MyODBC* works on Windows95,
  22965. Windows98, NT and on most Unix platforms.
  22966.  
  22967. Normally you only need to install *MyODBC* on Windows machines.  You
  22968. only need *MyODBC* for Unix if you have a program like ColdFusion that
  22969. is running on the Unix machine and uses ODBC to connect to the
  22970. databases.
  22971.  
  22972. *MyODBC* is in public domain and you can find the newest version at
  22973. `http://www.mysql.com/downloads/api-myodbc.html'.
  22974.  
  22975. If you want to install *MyODBC* on a Unix box, you will also need an
  22976. *ODBC* manager.  *MyODBC* is known to work with most of the Unix ODBC
  22977. managers.  You can find a list at these in the *ODBC*-related links
  22978. section on the *MySQL* useful links page.  *Note Useful Links::.
  22979.  
  22980. On Windows/NT you may get the following error when trying to install
  22981. *MyODBC*:
  22982.  
  22983.      An error occurred while copying C:\WINDOWS\SYSTEM\MFC30.DLL. Restart Windows
  22984.      and try installing again (before running any applications which use ODBC)
  22985.  
  22986. The problem in this case is that some other program is using ODBC and
  22987. because of how windows is designed, you cannot in this case install new
  22988. ODBC drivers with Microsoft's ODBC setup program. :( The solution to
  22989. this is to reboot your computer in "safe mode" (You can choose this by
  22990. pressing F8 just before your machine starts Windows during rebooting),
  22991. install *MyODBC* and reboot to normal mode.
  22992.  
  22993.    * To make a connection to an Unix box from a Windows box, with an
  22994.      ODBC application (one that doesn't support *MySQL* natively), you
  22995.      must first install *MyODBC* on the Windows machine.
  22996.  
  22997.    * The user and Windows machine must have the access privileges to the
  22998.      *MySQL* server the Unix machine.  This is set up with the `GRANT'
  22999.      command. *Note `GRANT': GRANT.
  23000.  
  23001.    * You must create an ODBC DSN entry as follows:
  23002.  
  23003.         * Open the Control Panel on the Windows machine.
  23004.  
  23005.         * Double click the ODBC Data Sources 32 bits icon.
  23006.  
  23007.         * Click the tab User DSN.
  23008.  
  23009.         * Click the button Add.
  23010.  
  23011.         * Select *MySQL* in the screen Create New Data Source and click
  23012.           the Finish button.
  23013.  
  23014.         * The *MySQL* Driver default configuration screen is shown.
  23015.           *Note ODBC administrator::.
  23016.  
  23017.    * Now start your application and select the ODBC driver with the DSN
  23018.      you specified in the ODBC administrator.
  23019.  
  23020. Notice that there are other configuration options in the screen of
  23021. *MySQL* (trace, don't prompt on connect, etc) that you can try if you
  23022. run into problems.
  23023.  
  23024. How to fill in the various fields in the ODBC administrator program
  23025. ===================================================================
  23026.  
  23027. There are three possibilities for specifying the server name on
  23028. Windows95:
  23029.  
  23030.    * Use the IP address of the server.
  23031.  
  23032.    * Add a file `\windows\lmhosts' with the following information:
  23033.  
  23034.           ip hostname
  23035.  
  23036.      For example:
  23037.  
  23038.           194.216.84.21 my_hostname
  23039.  
  23040.    * Configure the PC to use DNS.
  23041.  
  23042. Example of how to fill in the `ODBC setup'
  23043.      Windows DSN name:   test
  23044.      Description:        This is my test database
  23045.      MySql Database:     test
  23046.      Server:             194.216.84.21
  23047.      User:               monty
  23048.      Password:           my_password
  23049.      Port:
  23050.  
  23051. The value for the `Windows DSN name' field is any name that is unique
  23052. in your Windows ODBC setup.
  23053.  
  23054. You don't have to specify values for the `Server', `User', `Password'
  23055. or `Port' fields in the ODBC setup screen.  However, if you do, the
  23056. values will be used as the defaults later when you attempt to make a
  23057. connection.  You have the option of changing the values at that time.
  23058.  
  23059. If the port number is not given, the default port (3306) is used.
  23060.  
  23061. If you specify the option `Read options from C:\my.cnf', the groups
  23062. `client' and `odbc' will be read from the `C:\my.cnf' file.  You can
  23063. use all options that are usable by `mysql_options()'.  *Note
  23064. `mysql_options': mysql_options.
  23065.  
  23066. How to report problems with MyODBC
  23067. ==================================
  23068.  
  23069. *MyODBC* has been tested with Access, Admndemo.exe, C++-Builder,
  23070. Borland Builder 4, Centura Team Developer (formerly Gupta SQL/Windows),
  23071. ColdFusion (on Solaris and NT with svc pack 5), Crystal Reports,
  23072. DataJunction, Delphi, ERwin, Excel, iHTML, FileMaker Pro, FoxPro, Notes
  23073. 4.5/4.6, SBSS, Perl DBD-ODBC, Paradox, Powerbuilder, Powerdesigner 32
  23074. bit, VC++ and Visual Basic.
  23075.  
  23076. If you know of any other applications that work with *MyODBC*, please
  23077. mail <myodbc@lists.mysql.com> about this!
  23078.  
  23079. With some programs you may get an error like: `Another user has
  23080. modifies the record that you have modified'. In most cases this can be
  23081. solved by doing one of the following things:
  23082.  
  23083.    * Add a primary key for the table if there isn't one already.
  23084.  
  23085.    * Add a timestamp column if there isn't one already.
  23086.  
  23087.    * Only use double float fields. Some programs may fails when they
  23088.      comparing single floats.
  23089.  
  23090. If the above doesn't help, you should do a `MyODBC' trace file and from
  23091. this try to figure out why things goes wrong.
  23092.  
  23093. Programs known to work with MyODBC
  23094. ==================================
  23095.  
  23096. Most programs should work with *MyODBC*, but for each of those listed
  23097. below, we have tested it ourselves or gotten confirmation from some
  23098. user that it works:
  23099.  
  23100. *Program*
  23101.      *Comment*
  23102.  
  23103. Access
  23104.      To make Access work:
  23105.         * You should have a primary key in the table.
  23106.  
  23107.         * You should have a timestamp in all tables you want to be able
  23108.           to update.
  23109.  
  23110.         * Only use double float fields. Access fails when comparing
  23111.           with single floats.
  23112.  
  23113.         * Set the `Return matching rows' option field when connecting
  23114.           to *MySQL*.
  23115.  
  23116.         * Access on NT will report `BLOB' columns as `OLE OBJECTS'. If
  23117.           you want to have `MEMO' columns instead, you should change the
  23118.           column to `TEXT' with `ALTER TABLE'.
  23119.  
  23120.         * Access can't always handle `DATE' columns properly. If you
  23121.           have a problem with these, change the columns to `DATETIME'.
  23122.  
  23123.         * In some cases, Access may generate illegal SQL queries that
  23124.           *MySQL* can't understand. You can fix this by selecting
  23125.           `"Query|SQLSpecific|Pass-Through"' from the Access menu.
  23126.  
  23127.  
  23128. Borland Builder 4
  23129.      When you start a query you can use the property `Active' or use the
  23130.      method `Open'.  Note that `Active' will start by automatically
  23131.      issue a `SELECT * FROM ...' query that may not be a good thing if
  23132.      your tables are big!
  23133.  
  23134. ColdFusion (On Unix)
  23135.      The following information is taken from the ColdFusion
  23136.      documentation:
  23137.  
  23138.      Use the following information to configure ColdFusion Server for
  23139.      Linux to use the unixODBC driver with *MyODBC* for *MySQL* data
  23140.      sources.  Allaire has verified that *MyODBC* version 2.50.26 works
  23141.      with *MySQL* version 3.22.27 and ColdFusion for Linux. (Any newer
  23142.      version should also work). You can download *MyODBC* at
  23143.      `http://www.mysql.com/downloads/api-myodbc.html'
  23144.  
  23145.      ColdFusion 4.5.1 allows you to us the ColdFusion Administrator to
  23146.      add the *MySQL* data source. However, the driver is not included
  23147.      with ColdFusion 4.5.1. Before the *MySQL* driver will appear in
  23148.      the ODBC datasources drop-down list, you must build and copy the
  23149.      *MyODBC* driver to `/opt/coldfusion/lib/libmyodbc.so'.
  23150.  
  23151. DataJunction
  23152.      You have to change it to output `VARCHAR' rather than `ENUM', as
  23153.      it exports the latter in a manner that causes *MySQL* grief.
  23154.  
  23155. Excel
  23156.      Works. Some tips:
  23157.         * If you have problems with dates, try to select them as
  23158.           strings using the `CONCAT()' function. For example:
  23159.                select CONCAT(rise_time), CONCAT(set_time)
  23160.                    from sunrise_sunset;
  23161.           Values retrieved as strings this way should be correctly
  23162.           recognized as time values by Excel97.
  23163.  
  23164.           The purpose of `CONCAT()' in this example is to fool ODBC
  23165.           into thinking the column is of "string type". Without the
  23166.           `CONCAT()', ODBC knows the column is of time type, and Excel
  23167.           does not understand that.
  23168.  
  23169.           Note that this is a bug in Excel, because it automatically
  23170.           converts a string to a time. This would be great if the
  23171.           source was a text file, but is plain stupid when the source
  23172.           is an ODBC connection that reports exact types for each
  23173.           column.
  23174.  
  23175. odbcadmin
  23176.      Test program for ODBC.
  23177.  
  23178. Delphi
  23179.      You must use DBE 3.2 or newer.  Set the `Don't optimize column
  23180.      width' option field when connecting to *MySQL*.
  23181.  
  23182.      Also, here is some potentially useful Delphi code that sets up
  23183.      both an ODBC entry and a BDE entry for *MyODBC* (the BDE entry
  23184.      requires a BDE Alias Editor which may be had for free at a Delphi
  23185.      Super Page near you.):  (Thanks to Bryan Brunton
  23186.      <bryan@flesherfab.com> for this)
  23187.  
  23188.           fReg:= TRegistry.Create;
  23189.             fReg.OpenKey('\Software\ODBC\ODBC.INI\DocumentsFab', True);
  23190.             fReg.WriteString('Database', 'Documents');
  23191.             fReg.WriteString('Description', ' ');
  23192.             fReg.WriteString('Driver', 'C:\WINNT\System32\myodbc.dll');
  23193.             fReg.WriteString('Flag', '1');
  23194.             fReg.WriteString('Password', '');
  23195.             fReg.WriteString('Port', ' ');
  23196.             fReg.WriteString('Server', 'xmark');
  23197.             fReg.WriteString('User', 'winuser');
  23198.             fReg.OpenKey('\Software\ODBC\ODBC.INI\ODBC Data Sources', True);
  23199.             fReg.WriteString('DocumentsFab', 'MySQL');
  23200.             fReg.CloseKey;
  23201.             fReg.Free;
  23202.           
  23203.             Memo1.Lines.Add('DATABASE NAME=');
  23204.             Memo1.Lines.Add('USER NAME=');
  23205.             Memo1.Lines.Add('ODBC DSN=DocumentsFab');
  23206.             Memo1.Lines.Add('OPEN MODE=READ/WRITE');
  23207.             Memo1.Lines.Add('BATCH COUNT=200');
  23208.             Memo1.Lines.Add('LANGDRIVER=');
  23209.             Memo1.Lines.Add('MAX ROWS=-1');
  23210.             Memo1.Lines.Add('SCHEMA CACHE DIR=');
  23211.             Memo1.Lines.Add('SCHEMA CACHE SIZE=8');
  23212.             Memo1.Lines.Add('SCHEMA CACHE TIME=-1');
  23213.             Memo1.Lines.Add('SQLPASSTHRU MODE=SHARED AUTOCOMMIT');
  23214.             Memo1.Lines.Add('SQLQRYMODE=');
  23215.             Memo1.Lines.Add('ENABLE SCHEMA CACHE=FALSE');
  23216.             Memo1.Lines.Add('ENABLE BCD=FALSE');
  23217.             Memo1.Lines.Add('ROWSET SIZE=20');
  23218.             Memo1.Lines.Add('BLOBS TO CACHE=64');
  23219.             Memo1.Lines.Add('BLOB SIZE=32');
  23220.           
  23221.             AliasEditor.Add('DocumentsFab','MySQL',Memo1.Lines);
  23222.  
  23223. C++Builder
  23224.      Tested with BDE 3.0. The only known problem is that when the table
  23225.      schema changes, query fields are not updated. BDE however does not
  23226.      seem to recognize primary keys, only the index PRIMARY, though
  23227.      this has not been a problem.
  23228.  
  23229. Visual Basic
  23230.      To be able to update a table, you must define a primary key for
  23231.      the table.
  23232.  
  23233.      Visual Basic with ADO can't handle big integers;  This means that
  23234.      some queries like `SHOW PROCESSLIST' will not work properly.  The
  23235.      fix is to set add the option `OPTION=16834' in the ODBC connect
  23236.      string or set the `Change BIGINT columns to INT' option in the
  23237.      MyODBC connect screen.
  23238.  
  23239. How to get the value of an `AUTO_INCREMENT' column in ODBC
  23240. ==========================================================
  23241.  
  23242. A common problem is how to get the value of an automatically generated
  23243. ID from an `INSERT'. With ODBC, you can do something like this (assuming
  23244. that `auto' is an `AUTO_INCREMENT' field):
  23245.  
  23246.      INSERT INTO foo (auto,text) VALUES(NULL,'text');
  23247.      SELECT LAST_INSERT_ID();
  23248.  
  23249. Or, if you are just going to insert the ID into another table, you can
  23250. do this:
  23251.  
  23252.      INSERT INTO foo (auto,text) VALUES(NULL,'text');
  23253.      INSERT INTO foo2 (id,text) VALUES(LAST_INSERT_ID(),'text');
  23254.  
  23255. For the benefit of some ODBC applications (at least Delphi and Access),
  23256. the following query can be used to find a newly-inserted row:
  23257.      SELECT * FROM tbl_name WHERE auto IS NULL;
  23258.  
  23259. Reporting problems with MyODBC
  23260. ==============================
  23261.  
  23262. If you encounter difficulties with *MyODBC*, you should start by making
  23263. a log file from the ODBC manager (the log you get when requesting logs
  23264. from ODBCADMIN) and a *MyODBC* log. To get a *MyODBC* log, tag the
  23265. `Trace MyODBC' option flag in the *MyODBC* connect/configure screen.
  23266. The log will be written to file `C:\myodbc.log'.  Note that you must
  23267. use `MYSQL.DLL' and not `MYSQL2.DLL' for this option to work!
  23268.  
  23269. Check the queries that MyODBC sends to the *MySQL* server; You should
  23270. be able to find this by searching after the string `>mysql_real_query'
  23271. in the `myodbc.log' file.
  23272.  
  23273. You should also try duplicating the queries in the `mysql' monitor or
  23274. `admndemo' to find out if the error is MyODBC or *MySQL*.
  23275.  
  23276. If you find out something is wrong, please only send the relevant rows
  23277. (max 40 rows) to the <myodbc@lists.mysql.com>.  Please never send the
  23278. whole MyODBC or ODBC log file!
  23279.  
  23280. If you are unable to find out what's wrong, the last option is to to
  23281. make an archive (tar or zip) that contains a MyODBC log file, the ODBC
  23282. log file and a README file that explains the problem.  You can send this
  23283. to `ftp://support.mysql.com/pub/mysql/secret'.  Only we at MySQL AB
  23284. will have access to the files you upload and we will be very discrete
  23285. with the data!
  23286.  
  23287. If you can create a program that also shows this problem, please upload
  23288. this too!
  23289.  
  23290. If the program works with some other SQL server, you should make an
  23291. ODBC log file where you do exactly the same thing in the other SQL
  23292. server.
  23293.  
  23294. Remember that the more information you can supply to us, the more
  23295. likely it is that we can fix the problem!
  23296.  
  23297. Using `MySQL' with some common programs
  23298. ***************************************
  23299.  
  23300. Using MySQL with Apache
  23301. =======================
  23302.  
  23303. The contrib section includes programs that let you authenticate your
  23304. users from a *MySQL* database and also let you log your log files into
  23305. a *MySQL* table. *Note Contrib::.
  23306.  
  23307. You can change the Apache logging format to be easily readable by
  23308. `MySQL' by putting the following into the Apache configuration file:
  23309.  
  23310.      LogFormat \
  23311.              "\"%h\",%{%Y%m%d%H%M%S}t,%>s,\"%b\",\"%{Content-Type}o\",  \
  23312.              \"%U\",\"%{Referer}i\",\"%{User-Agent}i\""
  23313.  
  23314. In *MySQL* you can do something like this:
  23315.  
  23316.      LOAD DATA INFILE '/local/access_log' INTO TABLE table_name
  23317.      FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '\\'
  23318.  
  23319. Problems and common errors
  23320. **************************
  23321.  
  23322. How to determinate what is causing problems
  23323. ===========================================
  23324.  
  23325. When you run into problems, the first thing you should do is to find out
  23326. which program / piece of equipment is causing problems.
  23327.  
  23328.    * If you have one of the following symptoms, then it is probably a
  23329.      hardware (like memory, motherboard, CPU, or harddisk) or kernel
  23330.      problem:
  23331.         * The keyboard doesn't work.  This can normally be checked by
  23332.           pressing Caps Lock;  If the Caps Lock light doesn't change
  23333.           you have to replace your keyboard.  (Before doing this, you
  23334.           should however try to reboot your computer and check all
  23335.           cables to the keyboard :)
  23336.  
  23337.         * The mouse pointer doesn't move.
  23338.  
  23339.         * The machine doesn't answer to a remote machine's pings.
  23340.  
  23341.         * Different, unrelated programs don't behave correctly.
  23342.  
  23343.         * If your system rebooted unexpectedly (a faulty user level
  23344.           program should NEVER be able to take down your system).
  23345.  
  23346.      In this case you should start by checking all your cables and run
  23347.      some diagnostic tool to check your hardware!  You should also
  23348.      check if there are any patches, updates or service packs for your
  23349.      operating system that could likely solve your problems.  Check
  23350.      also that all your libraries (like glibc) are up to date.
  23351.  
  23352.      It's always good to use a machine with ECC memory to discover
  23353.      memory problems early!
  23354.  
  23355.    * If your keyboard is locked up, you may be able to fix this by
  23356.      logging into your machine from another machine and execute
  23357.      `kbd_mode -a' on it.
  23358.  
  23359.    * Please examine your system log file, (/var/log/messages or
  23360.      similar) for reasons for your problems.  If you think the problem
  23361.      is in *MySQL* then you should also examine *MySQL*'s log files.
  23362.      *Note Update log::.
  23363.  
  23364.    * If you don't think you have hardware problems, you should try to
  23365.      find out which program is causing problems.
  23366.  
  23367.      Try using `top', `ps', `taskmanager' or some similar program, to
  23368.      check which program is taking all CPU, or is locking the machine.
  23369.  
  23370.    * Check with `top', `df' or a similar programs if you are out of
  23371.      memory, disk space, open files or some other critical resource.
  23372.  
  23373.    * If the problem is some runaway process, you can always try to kill
  23374.      if. If it doesn't want to die, this is probably a bug in the
  23375.      operating system.
  23376.  
  23377. If after you have examined all other possibilities and you have
  23378. concluded that its the *MySQL* server or a *MySQL* client that is
  23379. causing the problem, it's time to do a bug report for our mailing list
  23380. or our support team.  In the bug report, try to describe very detailed
  23381. how the system is behaving and what you think is happening. You should
  23382. also state why you think it's *MySQL* that is causing the problems.
  23383. Take in consideration all the situations in this chapter. State any
  23384. problems exactly how they appear when you examine your system.. Use the
  23385. 'cut and paste' method for any output and/or error messages from
  23386. programs and/or log files!
  23387.  
  23388. Try to describe very detailed which program is not working and all
  23389. symptoms you see!  We have in the past got many bug reports that just
  23390. states "the system doesn't work".  This doesn't provide us with any
  23391. information of what could be the problem.
  23392.  
  23393. If a program fails, it's always useful to know:
  23394.  
  23395.    * Has the program in question made a segmentation fault (core
  23396.      dumped)?
  23397.  
  23398.    * Is the program taking the whole CPU? Check with `top'. Let the
  23399.      program run for a while, it may be evaluating something heavy.
  23400.  
  23401.    * If it's the `mysqld' server that is causing problems; Can you do
  23402.      `mysqladmin -u root ping', or `mysqladmin -u root processlist'?
  23403.  
  23404.    * What does a client program say (try with `mysql' for example) when
  23405.      you try to connect to the *MySQL* server?  Does the client jam?
  23406.      Do you get any output from the program?
  23407.  
  23408. When send a bug report, you should of course follow the outlines
  23409. described in this manual. *Note Asking questions::.
  23410.  
  23411. What to do if MySQL keeps crashing
  23412. ==================================
  23413.  
  23414. All *MySQL* versions are tested on many platforms before they are
  23415. released.  This doesn't mean that there isn't any bugs in *MySQL*, but
  23416. that if there are bugs they are very few and can be hard to find.  If
  23417. you have a problem, it will always help if you try to find out exactly
  23418. what crashes your system as you will have a much better chance of
  23419. getting this fixed quickly.
  23420.  
  23421. First you should try to find out whether the problem is that the
  23422. `mysqld' daemon dies or whether your problem has to do with your
  23423. client.  You can check how long your `mysqld' server has been up by
  23424. executing `mysqladmin version'.  If `mysqld' has died, you may find the
  23425. reason for this in the file `mysql-data-directory/'hostname'.err'.
  23426.  
  23427. Many crashes of *MySQL* is caused by corrupted index / data files.
  23428. *MySQL* will update the data on disk, with the `write()' system call,
  23429. after every SQL statement and before the client is notified about the
  23430. result (this is not true if you are running with `delayed_key_writes',
  23431. in which case only the data is written).  This means that the data is
  23432. safe even if mysqld crashes as the OS will ensure that the not flushed
  23433. data is written to disk.  You can force *MySQL* to sync everything to
  23434. disk after every SQL command by starting `mysqld' with `--flush'.
  23435.  
  23436. The above means that normally you shouldn't get corrupted tables unless:
  23437.  
  23438.    * Someone/something killed `mysqld' or the machine in the middle of
  23439.      an update.
  23440.  
  23441.    * You have found a bug in `mysqld' that caused it to die in the
  23442.      middle of an update.
  23443.  
  23444.    * Someone is manipulating the data/index files outside of *mysqld*
  23445.      without locking the table properly.
  23446.  
  23447.    * If you are running many `mysqld' servers on the same data on a
  23448.      system that doesn't support good file system locks (normally
  23449.      handled by the `lockd' deamon.) or if you are running multiple
  23450.      servers with `--skip-locking'
  23451.  
  23452.    * You have a crashed index/data file that contains very wrong data
  23453.      that got mysqld confused.
  23454.  
  23455.    * You have found a bug in the data storage code. This isn't that
  23456.      likely, but it's at least possible.  In this case you can try to
  23457.      change the file type to another database handler by using `ALTER
  23458.      TABLE' on a repaired copy of the table!
  23459.  
  23460. Because it is very difficult to know why something is crashing, first
  23461. try to check whether or not things that work for others crash for you.
  23462. Please try the following things:
  23463.  
  23464.    * Take down the `mysqld' daemon with `mysqladmin shutdown', run
  23465.      `myisamchk --silent --force */*.MYI' on all tables and restart the
  23466.      `mysqld' daemon.  This will ensure that you are running from a
  23467.      clean state.  *Note Maintenance::.
  23468.  
  23469.    * Use `mysqld --log' and try to determine from the information in
  23470.      the log whether or not some specific query kills the server. 95%
  23471.      of all bugs are related to a particular query!  Normally this is
  23472.      one of the last queries in the log file just before *MySQL*
  23473.      restarted.
  23474.  
  23475.      You may be able to verify this using the following procedure:
  23476.  
  23477.         * Take down the *MySQL* daemon (with `mysqladmin shutdown')
  23478.  
  23479.         * Make a backup of files in the *MySQL* database directory.
  23480.           (As the server is stopped, you can just copy the files to
  23481.           some other directory)
  23482.  
  23483.         * Check the tables with `myisamchk -s */*.MYI' to verify that
  23484.           all tables are correct.  If any table is corrupted, repair it
  23485.           with `myisamchk -r path-to-table.MYI'.  You should take the
  23486.           backup before checking the tables as the problem could be
  23487.           related to corrupted tables.
  23488.  
  23489.         * Remove (or move away) any old log files from the *MySQL* data
  23490.           directory.
  23491.  
  23492.         * Start the server with `safe_mysqld --log-update' or
  23493.           `safe_mysqld --log --log-update'.
  23494.  
  23495.         * If `mysqld' now dies, you have two options:
  23496.              * First take a backup of your backup database. (Just copy
  23497.                the file(s) somewhere again). This is because we want to
  23498.                keep the original start situation untouched. Start a
  23499.                mysqld process on the other backup database (you can do
  23500.                this with option `--datadir=/path/to/backup/').
  23501.  
  23502.              * Just restore the backup on your original database and
  23503.                restart `mysqld'.  You will not any lose information,
  23504.                because you have the `log-update' file.
  23505.  
  23506.         *  Now you can test if the problem is a specific update
  23507.           statement by executing `mysql database_name <
  23508.           path-to-log-update-file'.
  23509.  
  23510.           You can also use the script `mysql_find_rows' to just execute
  23511.           some of the update statements if you want to narrow down the
  23512.           problem.
  23513.  
  23514.           If mysqld now crashes, then you have something repeatable
  23515.           available. Please mail <bugs@lists.mysql.com>, or
  23516.           <developers@mysql.com>, or (if you are a support customer) to
  23517.           <support@mysql.com> about the problem and the *MySQL* team
  23518.           will fix it as soon as possible.
  23519.  
  23520.    * Have you tried the benchmarks?  They should test *MySQL* rather
  23521.      well.  You can also add code that simulates your application!  The
  23522.      benchmarks can be found in the `bench' directory in the source
  23523.      distribution, or, for a binary distribution, in the `sql-bench'
  23524.      directory under your *MySQL* installation directory.
  23525.  
  23526.    * Try `fork_test.pl' and `fork2_test.pl'.
  23527.  
  23528.    * Check the file `mysql-data-directory/'hostname'.err' for any
  23529.      errors.
  23530.  
  23531.    * If you configure *MySQL* for debugging, it will be much easier to
  23532.      gather information about possible errors if something goes wrong.
  23533.      Reconfigure *MySQL* with the `--with-debug' option to `configure'
  23534.      and then recompile.  *Note Debugging server::.
  23535.  
  23536.    * Configuring *MySQL* for debugging causes a safe memory allocator
  23537.      to be included that can find some errors. It also provides a lot
  23538.      of output about what is happening.
  23539.  
  23540.    * Have you applied the latest patches for your operating system?
  23541.  
  23542.    * Use the `--skip-locking' option to `mysqld'.  On some systems, the
  23543.      `lockd' lock manager does not work properly; the `--skip-locking'
  23544.      option tells `mysqld' not to use external locking.  (This means
  23545.      that you cannot run 2 `mysqld' servers on the same data and that
  23546.      you must be careful if you use `myisamchk', but it may be
  23547.      instructive to try the option as a test.)
  23548.  
  23549.    * Have you tried `mysqladmin -u root processlist' when `mysqld'
  23550.      appears to be running but not responding?  Sometimes `mysqld' is
  23551.      not comatose even though you might think so.  The problem may be
  23552.      that all connections are in use, or there may be some internal
  23553.      lock problem.  `mysqladmin processlist' will usually be able to
  23554.      make a connection even in these cases, and can provide useful
  23555.      information about the current number of connections and their
  23556.      status.
  23557.  
  23558.    * Run the command `mysqladmin -i 5 status' in a separate window to
  23559.      produce statistics while you run your other queries.
  23560.  
  23561.    * Try the following:
  23562.        1. Start `mysqld' from `gdb' (or in another debugger).
  23563.  
  23564.        2. Run your test scripts.
  23565.  
  23566.        3. Print the backtrace and the local variables at the 3 lowest
  23567.           levels. In gdb you can do this with the following commands
  23568.           when `mysqld' has crashed inside gdb:
  23569.  
  23570.                backtrace
  23571.                info local
  23572.                up
  23573.                info local
  23574.                up
  23575.                info local
  23576.  
  23577.           With gdb you can also examine which threads there exists with
  23578.           `info threads' and switch to a specific thread with `thread
  23579.           #', where `#' is the thread id.
  23580.  
  23581.    * Try to simulate your application with a Perl script to force
  23582.      *MySQL* to crash or misbehave.
  23583.  
  23584.    * Send a normal bug report. *Note Bug reports::. Be even more
  23585.      detailed than usual.  Because *MySQL* works for many people, it
  23586.      may be that the crash results from something that exists only on
  23587.      your computer (for example, an error that is related to your
  23588.      particular system libraries).
  23589.  
  23590.    * If you have a problem with table with dynamic length rows and you
  23591.      are not using `BLOB/TEXT' columns (but only `VARCHAR' columns) you
  23592.      can try to change all `VARCHAR' to `CHAR' with `ALTER TABLE'.
  23593.      This will force *MySQL* to use fixed size rows.  Fixed size rows
  23594.      take a little extra space, but are much more tolerant to
  23595.      corruption!
  23596.  
  23597.      The current dynamic row code has been in use at MySQL AB for at
  23598.      least 3 years without any problems, but by nature dynamic length
  23599.      rows are more prone to errors, so it may be a good idea to try the
  23600.      above to see if it helps!
  23601.  
  23602. Problems when linking with the MySQL client library
  23603. ===================================================
  23604.  
  23605. If you are linking your program and you get errors for unreferenced
  23606. symbols that starts with `mysql_', like the following:
  23607.  
  23608.      /tmp/ccFKsdPa.o: In function `main':
  23609.      /tmp/ccFKsdPa.o(.text+0xb): undefined reference to `mysql_init'
  23610.      /tmp/ccFKsdPa.o(.text+0x31): undefined reference to `mysql_real_connect'
  23611.      /tmp/ccFKsdPa.o(.text+0x57): undefined reference to `mysql_real_connect'
  23612.      /tmp/ccFKsdPa.o(.text+0x69): undefined reference to `mysql_error'
  23613.      /tmp/ccFKsdPa.o(.text+0x9a): undefined reference to `mysql_close'
  23614.  
  23615. you should be able to solve this by adding `-Lpath-to-the-mysql-library
  23616. -lmysqlclient' *LAST* on your link line.
  23617.  
  23618. If you get `undefined reference' errors for the `compress' function,
  23619. add `-lgz' *LAST* on your link line and try again!
  23620.  
  23621. If you get `undefined reference' errors for functions that should exist
  23622. on your system, like `connect', check the man page, for the function in
  23623. question, for which libraries you should add to the link line!
  23624.  
  23625. If you get `undefined reference' errors for functions that doesn't
  23626. exist on your system, like the following:
  23627.  
  23628.      mf_format.o(.text+0x201): undefined reference to `__lxstat'
  23629.  
  23630. It usually means that your library is compiled on a system that is not
  23631. 100 % compatible with yours.  In this case you should download the
  23632. latest *MySQL* source distribution and compile this yourself.  *Note
  23633. Installing source::.
  23634.  
  23635. If you are trying to run a program and you then get errors for
  23636. unreferenced symbols that starts with `mysql_' or that the
  23637. `mysqlclient' library can't be found, this means that your system can't
  23638. find the share `libmysqlclient.so' library.
  23639.  
  23640. The fix for this is to either tell your system to search after shared
  23641. libraries where the library is located by one of the following methods:
  23642.  
  23643.    * Add the path to directory where you have `libmysqlclient.so' the
  23644.      `LD_LIBRARY_PATH' environment variable.
  23645.  
  23646.    * Add the path to directory where you have `libmysqlclient.so' the
  23647.      `LD_LIBRARY' environment variable.
  23648.  
  23649.    * Copy `libmysqlclient.so' to some place that is searched by your
  23650.      system, like `/lib' and update the shared library information by
  23651.      executing `ldconfig'.
  23652.  
  23653. Another way to solve this problem is to link your program staticly, with
  23654. `-static', or by removing the dynamic *MySQL* libraries before linking
  23655. your code. In the second case you should of course be sure that no
  23656. other programs is using the dynamic libraries!
  23657.  
  23658. Some common errors when using MySQL
  23659. ===================================
  23660.  
  23661. `MySQL server has gone away' error
  23662. ----------------------------------
  23663.  
  23664. This section also covers the related `Lost connection to server during
  23665. query' error.
  23666.  
  23667. The most common reason for the `MySQL server has gone away' error is
  23668. that the server timed out and closed the connection. By default, the
  23669. server closes the connection after 8 hours if nothing has happened. You
  23670. can change the time limit with by setting the `wait_timeout' variable
  23671. when you start mysqld.
  23672.  
  23673. You can check that the *MySQL* hasn't died by executing `mysqladmin
  23674. version' and examining the uptime.
  23675.  
  23676. If you have a script, you just have to issue the query again for the
  23677. client to do an automatic reconnection.
  23678.  
  23679. You normally can get the following error codes in this case (which one
  23680. you get is OS-dependent):
  23681.  
  23682. `CR_SERVER_GONE_ERROR' The client couldn't send a question to the server.
  23683. `CR_SERVER_LOST'       The client didn't get an error when writing to
  23684.                        the server, but it didn't get a full answer (or
  23685.                        any answer) to the question.
  23686.  
  23687. You can also get these errors if you send a query to the server that is
  23688. incorrect or too large. If `mysqld' gets a packet that is too large or
  23689. out of order, it assumes that something has gone wrong with the client
  23690. and closes the connection.  If you need big queries (for example, if
  23691. you are working with big `BLOB' columns), you can increase the query
  23692. limit by starting `mysqld' with the `-O max_allowed_packet=#' option
  23693. (default 1M). The extra memory is allocated on demand, so `mysqld' will
  23694. use more memory only when you issue a big query or when `mysqld' must
  23695. return a big result row!
  23696.  
  23697. `Can't connect to [local] MySQL server' error
  23698. ---------------------------------------------
  23699.  
  23700. A *MySQL* client on Unix can connect to the `mysqld' server in two
  23701. different ways: Unix sockets, which connect through a file in the file
  23702. system (default `/tmp/mysqld.sock'), or TCP/IP, which connects through
  23703. a port number.  Unix sockets are faster than TCP/IP but can only be
  23704. used when connecting to a server on the same computer.  Unix sockets
  23705. are used if you don't specify a hostname or if you specify the special
  23706. hostname `localhost'.
  23707.  
  23708. On Windows you can connect only with TCP/IP if the `mysqld' server is
  23709. running on Win95/Win98. If it's running on NT, you can also connect
  23710. with named pipes.  The name of the named pipe is `MySQL'.  If you don't
  23711. give a hostname when connecting to `mysqld', a *MySQL* client will
  23712. first try to connect to the named pipe and if this doesn't work it will
  23713. connect to the TCP/IP port.  You can force the use of named pipes on
  23714. Windows by using `.' as the hostname.
  23715.  
  23716. The error (2002) `Can't connect to ...' normally means that there isn't
  23717. a *MySQL* server running on the system or that you are using a wrong
  23718. socket file or TCP/IP port when trying to connect to the `mysqld'
  23719. server.
  23720.  
  23721. Start by checking (using `ps' or the task manager on Windows) that
  23722. there is a process running named `mysqld' on your server!  If there
  23723. isn't any `mysqld' process, you should start one. *Note Starting
  23724. server::.
  23725.  
  23726. If a `mysqld' process is running, you can check the server by trying
  23727. these different connections (the port number and socket pathname might
  23728. be different in your setup, of course):
  23729.  
  23730.      shell> mysqladmin version
  23731.      shell> mysqladmin variables
  23732.      shell> mysqladmin -h `hostname` version variables
  23733.      shell> mysqladmin -h `hostname` --port=3306 version
  23734.      shell> mysqladmin -h 'ip for your host' version
  23735.      shell> mysqladmin --socket=/tmp/mysql.sock version
  23736.  
  23737. Note the use of backquotes rather than forward quotes with the
  23738. `hostname' command; these cause the output of `hostname' (i.e., the
  23739. current hostname) to be substituted into the `mysqladmin' command.
  23740.  
  23741. Here are some reasons the `Can't connect to local MySQL server' error
  23742. might occur:
  23743.  
  23744.    * `mysqld' is not running.
  23745.  
  23746.    * You are running on a system that uses MIT-pthreads.  If you are
  23747.      running on a system that doesn't have native threads, `mysqld'
  23748.      uses the MIT-pthreads package.  *Note Which OS::.  However,
  23749.      MIT-pthreads doesn't support Unix sockets, so on such a system you
  23750.      must always specify the hostname explicitly when connecting to the
  23751.      server.  Try using this command to check the connection to the
  23752.      server:
  23753.           shell> mysqladmin -h `hostname` version
  23754.  
  23755.    * Someone has removed the Unix socket that `mysqld' uses (default
  23756.      `/tmp/mysqld.sock').  You might have a `cron' job that removes the
  23757.      *MySQL* socket (e.g., a job that removes old files from the `/tmp'
  23758.      directory).  You can always run `mysqladmin version' and check
  23759.      that the socket `mysqladmin' is trying to use really exists.  The
  23760.      fix in this case is to change the `cron' job to not remove
  23761.      `mysqld.sock' or to place the socket somewhere else. You can
  23762.      specify a different socket location at *MySQL* configuration time
  23763.      with this command:
  23764.           shell> ./configure --with-unix-socket-path=/path/to/socket
  23765.      You can also start `safe_mysqld' with the
  23766.      `--socket=/path/to/socket' option and set the environment variable
  23767.      `MYSQL_UNIX_PORT' to the socket pathname before starting your
  23768.      *MySQL* clients.
  23769.  
  23770.    * You have started the `mysqld' server with the
  23771.      `--socket=/path/to/socket' option.  If you change the socket
  23772.      pathname for the server, you must also notify the *MySQL* clients
  23773.      about the new path. You can do this by setting the environment
  23774.      variable `MYSQL_UNIX_PORT' to the socket pathname or by providing
  23775.      the socket path as an argument to the clients. You can test the
  23776.      socket with this command:
  23777.  
  23778.           shell> mysqladmin --socket=/path/to/socket version
  23779.  
  23780.    * You are using Linux and one thread has died (core dumped).  In
  23781.      this case you must kill the other `mysqld' threads (for example
  23782.      with the `mysql_zap' script before you can start a new *MySQL*
  23783.      server.  *Note Crashing::.
  23784.  
  23785. If you get the error message `Can't connect to MySQL server on
  23786. some_hostname', you can try the following things to find out what is the
  23787. problem:
  23788.  
  23789.    * Check if the server up by doing `telnet your-host-name
  23790.      tcp-ip-port-number' and press `RETURN' a couple of times.  If there
  23791.      is a *MySQL* server running on this port you should get a
  23792.      responses that includes the version number of the running *MySQL*
  23793.      server.  If you get an error like `telnet: Unable to connect to
  23794.      remote host: Connection refused', then there is no server running
  23795.      on the given port.
  23796.  
  23797.    * Try connecting to the `mysqld' daemon on the local machine and
  23798.      check the TCP/IP port that mysqld it's configured to use (variable
  23799.      `port') with `mysqladmin variables'.
  23800.  
  23801.    * Check that your `mysqld' server is not started with the
  23802.      `--skip-networking' option.
  23803.  
  23804. `Host '...' is blocked' error
  23805. -----------------------------
  23806.  
  23807. If you get an error like this:
  23808.  
  23809.      Host 'hostname' is blocked because of many connection errors.
  23810.      Unblock with 'mysqladmin flush-hosts'
  23811.  
  23812. This means that `mysqld' has gotten a lot (`max_connect_errors') of
  23813. connect requests from the host `'hostname'' that have been interrupted
  23814. in the middle. After `max_connect_errors' failed requests, `mysqld'
  23815. assumes that something is wrong (like an attack from a cracker), and
  23816. blocks the site from further connections until someone executes the
  23817. command `mysqladmin flush-hosts'.
  23818.  
  23819. By default, `mysqld' blocks a host after 10 connection errors.  You can
  23820. easily adjust this by starting the server like this:
  23821.  
  23822.      shell> safe_mysqld -O max_connect_errors=10000 &
  23823.  
  23824. Note that if you get this error message for a given host, you should
  23825. first check that there isn't anything wrong with TCP/IP connections
  23826. from that host.  If your TCP/IP connections aren't working, it won't do
  23827. you any good to increase the value of the `max_connect_errors' variable!
  23828.  
  23829. `Too many connections' error
  23830. ----------------------------
  23831.  
  23832. If you get the error `Too many connections' when you try to connect to
  23833. *MySQL*, this means that there is already `max_connections' clients
  23834. connected to the `mysqld' server.
  23835.  
  23836. If you need more connections than the default (100), then you should
  23837. restart `mysqld' with a bigger value for the `max_connections' variable.
  23838.  
  23839. Note that `mysqld' actually allows (`max_connections'+1) clients to
  23840. connect.  The last connection is reserved for a user with the *process*
  23841. privilege.  By not giving this privilege to normal users (they
  23842. shouldn't need this), an administrator with this privilege can login
  23843. and use `SHOW PROCESSLIST' to find out what could be wrong. *Note
  23844. SHOW::.
  23845.  
  23846. `Out of memory' error
  23847. ---------------------
  23848.  
  23849. If you issue a query and get something like the following error:
  23850.  
  23851.      mysql: Out of memory at line 42, 'malloc.c'
  23852.      mysql: needed 8136 byte (8k), memory in use: 12481367 bytes (12189k)
  23853.      ERROR 2008: MySQL client ran out of memory
  23854.  
  23855. Note that the error refers to the *MySQL* client `mysql'. The reason
  23856. for this error is simply that the client does not have enough memory to
  23857. store the whole result.
  23858.  
  23859. To remedy the problem, first check that your query is correct. Is it
  23860. reasonable that it should return so many rows?  If so, you can use
  23861. `mysql --quick', which uses `mysql_use_result()' to retrieve the result
  23862. set.  This places less of a load on the client (but more on the server).
  23863.  
  23864. `Packet too large' error
  23865. ------------------------
  23866.  
  23867. When a *MySQL* client or the `mysqld' server gets a packet bigger than
  23868. `max_allowed_packet' bytes, it issues a `Packet too large' error and
  23869. closes the connection.
  23870.  
  23871. If you are using the `mysql' client, you may specify a bigger buffer by
  23872. starting the client with `mysql --set-variable=max_allowed_packet=8M'.
  23873.  
  23874. If you are using other clients that do not allow you to specify the
  23875. maximum packet size (such as `DBI'), you need to set the packet size
  23876. when you start the server.  You cau use a command-line option to
  23877. `mysqld' to set `max_allowed_packet' to a larger size.  For example, if
  23878. you are expecting to store the full length of a `BLOB' into a table,
  23879. you'll need to start the server with the
  23880. `--set-variable=max_allowed_packet=24M' option.
  23881.  
  23882. Communication errors / Aborted connection
  23883. -----------------------------------------
  23884.  
  23885. If you find the error `Aborted connection' in the `hostname.err' log
  23886. file this could be because on of the following reasons:
  23887.  
  23888.    * The client had been sleeping more than `wait_timeout' without doing
  23889.      any requests. *Note SHOW VARIABLES::.
  23890.  
  23891.    * The client program ended abruptly in the middle of the transfer
  23892.  
  23893.    * The client program did not call `mysql_close()' before exit
  23894.  
  23895.    * Usage of duplex Ethernet protocol, both half and full with Linux.
  23896.      Many Linux Ethernet drivers have this bug. You should test for
  23897.      this bug by transferring a huge file via ftp between these tow
  23898.      machines. If a transfer goes in burst-pause-burst-pause .. mode
  23899.      then you are experiencing a Linux duplex syndrome. The only
  23900.      solution to this problem is switching of both half and full
  23901.      duplexing on hubs and switches
  23902.  
  23903.    * Some problem with the thread library that causes interrupts on
  23904.      reads.
  23905.  
  23906.    * Badly configured TCP/IP
  23907.  
  23908.    * Faulty Ethernets or hubs or switches, cables .. This can be
  23909.      diagnosed properly only by replacing hardware
  23910.  
  23911. `The table is full' error
  23912. -------------------------
  23913.  
  23914. This error occurs in older *MySQL* versions when an in-memory temporary
  23915. table becomes larger than `tmp_table_size' bytes. To avoid this
  23916. problem, you can use the `-O tmp_table_size=#' option to `mysqld' to
  23917. increase the temporary table size, or use the SQL option
  23918. `SQL_BIG_TABLES' before you issue the problematic query. *Note `SET
  23919. OPTION': SET OPTION.
  23920.  
  23921. You can also start `mysqld' with the `--big-tables' option.  This is
  23922. exactly the same as using `SQL_BIG_TABLES' for all queries.
  23923.  
  23924. In *MySQL* 3.23 in-memory temporary tables will automaticly be
  23925. converted to a disk based `MyISAM' table after the table size gets
  23926. bigger than `tmp_table_size'.
  23927.  
  23928. `Commands out of sync' error in client
  23929. --------------------------------------
  23930.  
  23931. If you get `Commands out of sync; You can't run this command now' in
  23932. your client code, you are calling client functions in the wrong order!
  23933.  
  23934. This can happen, for example, if you are using `mysql_use_result()' and
  23935. try to execute a new query before you have called `mysql_free_result()'.
  23936. It can also happen if you try to execute two queries that return data
  23937. without a `mysql_use_result()' or `mysql_store_result()' in between.
  23938.  
  23939. `Ignoring user' error
  23940. ---------------------
  23941.  
  23942. If you get the following error:
  23943.  
  23944. `Found wrong password for user: 'some_user@some_host'; Ignoring user'
  23945.  
  23946. This means that when `mysqld' was started or when it reloaded the
  23947. permissions tables, it found an entry in the `user' table with an
  23948. invalid password.  As a result, the entry is simply ignored by the
  23949. permission system.
  23950.  
  23951. Possible causes of and fixes for this problem:
  23952.  
  23953.    * You may be running a new version of `mysqld' with an old `user'
  23954.      table.  You can check this by executing `mysqlshow mysql user' to
  23955.      see if the password field is shorter than 16 characters. If so,
  23956.      you can correct this condition by running the
  23957.      `scripts/add_long_password' script.
  23958.  
  23959.    * The user has an old password (8 chararacters long) and you didn't
  23960.      start `mysqld' with the `--old-protocol' option.  Update the user
  23961.      in the `user' table with a new password or restart `mysqld' with
  23962.      `--old-protocol'.
  23963.  
  23964.    * You have specified a password in the `user' table without using the
  23965.      `PASSWORD()' function.  Use `mysql' to update the user in the
  23966.      `user' table with a new password. Make sure to use the `PASSWORD()'
  23967.      function:
  23968.  
  23969.           mysql> update user set password=PASSWORD('your password')
  23970.                      where user='XXX';
  23971.  
  23972. `Table 'xxx' doesn't exist' error
  23973. ---------------------------------
  23974.  
  23975. If you get the error `Table 'xxx' doesn't exist' or `Can't find file:
  23976. 'xxx' (errno: 2)', this means that no table exists in the current
  23977. database with the name `xxx'.
  23978.  
  23979. Note that as *MySQL* uses directories and files to store databases and
  23980. tables, the database and table names are *case sensitive*!  (On Win32
  23981. the databases and tables names are not case sensitive, but all
  23982. references to a given table within a query must use the same case!)
  23983.  
  23984. You can check which tables you have in the current database with `SHOW
  23985. TABLES'. *Note `SHOW': SHOW.
  23986.  
  23987. How MySQL handles a full disk
  23988. =============================
  23989.  
  23990. When a disk full condition occurs, *MySQL* does the following:
  23991.  
  23992.    * It checks once every minute to see whether or not there is enough
  23993.      space to write the current row. If there is enough space, it
  23994.      continues as if nothing had happened.
  23995.  
  23996.    * Every 6 minutes it writes an entry to the log file warning about
  23997.      the disk full condition.
  23998.  
  23999. To alleviate the problem, you can take the following actions:
  24000.  
  24001.    * To continue, you only have to free enough disk space to insert all
  24002.      records.
  24003.  
  24004.    * To abort the thread, you must send a `mysqladmin kill' to the
  24005.      thread.  The thread will be aborted the next time it checks the
  24006.      disk (in 1 minute).
  24007.  
  24008.    * Note that other threads may be waiting for the table that caused
  24009.      the "disk full" condition.  If you have several "locked" threads,
  24010.      killing the one thread that is waiting on the disk full condition
  24011.      will allow the other threads to continue.
  24012.  
  24013. How to run SQL commands from a text file
  24014. ========================================
  24015.  
  24016. The `mysql' client typically is used interactively, like this:
  24017.  
  24018.      shell> mysql database
  24019.  
  24020. However, it's also possible to put your SQL commands in a file and tell
  24021. `mysql' to read its input from that file.  To do so, create a text file
  24022. `text_file' that contains the commands you wish to execute.  Then
  24023. invoke `mysql' as shown below:
  24024.  
  24025.      shell> mysql database < text_file
  24026.  
  24027. You can also start your text file with a `USE db_name' statement.  In
  24028. this case, it is unnecessary to specify the database name on the command
  24029. line:
  24030.  
  24031.      shell> mysql < text_file
  24032.  
  24033. *Note Programs::.
  24034.  
  24035. Where MySQL stores temporary files
  24036. ==================================
  24037.  
  24038. *MySQL* uses the value of the `TMPDIR' environment variable as the
  24039. pathname of the directory in which to store temporary files.  If you
  24040. don't have `TMPDIR' set, *MySQL* uses the system default, which is
  24041. normally `/tmp' or `/usr/tmp'.  If the file system containing your
  24042. temporary file directory is too small, you should edit `safe_mysqld' to
  24043. set `TMPDIR' to point to a directory in a file system where you have
  24044. enough space!  You can also set the temporary directory using the
  24045. `--tmpdir' option to `mysqld'.
  24046.  
  24047. *MySQL* creates all temporary files as "hidden files". This ensures
  24048. that the temporary files will be removed if `mysqld' is terminated.  The
  24049. disadvantage of using hidden files is that you will not see a big
  24050. temporary file that fills up the file system in which the temporary
  24051. file directory is located.
  24052.  
  24053. When sorting (`ORDER BY' or `GROUP BY'), *MySQL* normally uses one or
  24054. two temporary files. The maximum disk-space needed is:
  24055.  
  24056.      (length of what is sorted + sizeof(database pointer))
  24057.      * number of matched rows
  24058.      * 2
  24059.  
  24060. `sizeof(database pointer)' is usually 4, but may grow in the future for
  24061. really big tables.
  24062.  
  24063. For some `SELECT' queries, *MySQL* also creates temporary SQL tables.
  24064. These are not hidden and have names of the form `SQL_*'.
  24065.  
  24066. `ALTER TABLE' and `OPTIMIZE TABLE' create a temporary table in the same
  24067. directory as the original table.
  24068.  
  24069. How to protect `/tmp/mysql.sock' from being deleted
  24070. ===================================================
  24071.  
  24072. If you have problems with the fact that anyone can delete the *MySQL*
  24073. communication socket `/tmp/mysql.sock', you can, on most versions of
  24074. Unix, protect your `/tmp' file system by setting the `sticky' bit on
  24075. it.  Log in as `root' and do the following:
  24076.  
  24077.      shell> chmod +t /tmp
  24078.  
  24079. This will protect your `/tmp' file system so that files can be deleted
  24080. only by their owners or the superuser (`root').
  24081.  
  24082. You can check if the `sticky' bit is set by executing `ls -ld /tmp'.
  24083. If the last permission bit is `t', the bit is set.
  24084.  
  24085. `Access denied' error
  24086. =====================
  24087.  
  24088. *Note Privileges::. And especially see *Note Access denied::.
  24089.  
  24090. How to run MySQL as a normal user
  24091. =================================
  24092.  
  24093. The *MySQL* server `mysqld' can be started and run by any user.  In
  24094. order to change `mysqld' to run as Unix user `user_name', you must do
  24095. the following:
  24096.  
  24097.   1. Stop the server if it's running (use `mysqladmin shutdown').
  24098.  
  24099.   2. Change the database directories and files so that `user_name' has
  24100.      privileges to read and write files in them (you may need to do
  24101.      this as the Unix `root' user):
  24102.  
  24103.           shell> chown -R user_name /path/to/mysql/datadir
  24104.  
  24105.      If directories or files within the *MySQL* data directory are
  24106.      symlinks, you'll also need to follow those links and change the
  24107.      directories and files they point to.  `chown -R' may not follow
  24108.      symlinks for you.
  24109.  
  24110.   3. Start the server as user `user_name', or, if you are using *MySQL*
  24111.      3.22 or later, start `mysqld' as the Unix `root' user and use the
  24112.      `--user=user_name' option.  `mysqld' will switch to run as Unix
  24113.      user `user_name' before accepting any connections.
  24114.  
  24115.   4. If you are using the `mysql.server' script to start `mysqld' when
  24116.      the system is rebooted, you should edit `mysql.server' to use `su'
  24117.      to run `mysqld' as user `user_name', or to invoke `mysqld' with
  24118.      the `--user' option.  (No changes to `safe_mysqld' are necessary.)
  24119.  
  24120. At this point, your `mysqld' process should be running fine and dandy as
  24121. the Unix user `user_name'. One thing hasn't changed, though: the
  24122. contents of the permissions tables. By default (right after running the
  24123. permissions table install script `mysql_install_db'), the *MySQL* user
  24124. `root' is the only user with permission to access the `mysql' database
  24125. or to create or drop databases.  Unless you have changed those
  24126. permissions, they still hold. This shouldn't stop you from accessing
  24127. *MySQL* as the *MySQL* `root' user when you're logged in as a Unix user
  24128. other than `root'; just specify the `-u root' option to the client
  24129. program.
  24130.  
  24131. Note that accessing *MySQL* as `root', by supplying `-u root' on the
  24132. command line, has _nothing_ to do with *MySQL* running as the Unix
  24133. `root' user, or, indeed, as other Unix user. The access permissions and
  24134. user names of *MySQL* are completely separate from Unix user names. The
  24135. only connection with Unix user names is that if you don't provide a
  24136. `-u' option when you invoke a client program, the client will try to
  24137. connect using your Unix login name as your *MySQL* user name.
  24138.  
  24139. If your Unix box itself isn't secured, you should probably at least put
  24140. a password on the *MySQL* `root' users in the access tables.
  24141. Otherwise, any user with an account on that machine can run `mysql -u
  24142. root db_name' and do whatever he likes.
  24143.  
  24144. How to reset a forgotten password.
  24145. ==================================
  24146.  
  24147. If you have forgotten the `root' user password for *MySQL*, you can
  24148. restore it with the following procedure.
  24149.  
  24150.   1. Take down the mysqld server by sending a `kill' (not `kill -9') to
  24151.      the `mysqld' server.  The pid is stored in a `.pid' file which is
  24152.      normally in the *MySQL* database directory:
  24153.  
  24154.           kill `cat /mysql-data-directory/hostname.pid`
  24155.  
  24156.      You must be either the Unix `root' user or the same user the server
  24157.      runs as to do this.
  24158.  
  24159.   2. Restart `mysqld' with the `--skip-grant-tables' option.
  24160.  
  24161.   3. Connect to the mysqld server with `mysql -h hostname mysql' and
  24162.      change the password with a `GRANT' command. *Note `GRANT': GRANT.
  24163.      You can also do this with `mysqladmin -h hostname -u user password
  24164.      'new password''
  24165.  
  24166.   4. Load the privilege tables with: `mysqladmin -h hostname
  24167.      flush-privileges' or with the SQL command `FLUSH PRIVILEGES'.
  24168.  
  24169. Problems with file permissions
  24170. ==============================
  24171.  
  24172. If you have problems with file permissions, for example, if `mysql'
  24173. issues the following error message when you create a table:
  24174.  
  24175.      ERROR: Can't find file: 'path/with/filename.frm' (Errcode: 13)
  24176.  
  24177. Then the environment variable `UMASK' might be set incorrectly when
  24178. `mysqld' starts up.  The default umask value is `0660'. You can change
  24179. this behavior by starting `safe_mysqld' as follows:
  24180.  
  24181.      shell> UMASK=384  # = 600 in octal
  24182.      shell> export UMASK
  24183.      shell> /path/to/safe_mysqld &
  24184.  
  24185. By default *MySQL* will create database and `RAID' directories with
  24186. permission type 0700.  You can modify this behaviour by setting the the
  24187. `UMASK_DIR' variable. If you set this, new directories are created with
  24188. the combined `UMASK' and `UMASK_DIR'. For example, if you want to give
  24189. group access to all new directories, you can do:
  24190.  
  24191.      shell> UMASK_DIR=504  # = 770 in octal
  24192.      shell> export UMASK_DIR
  24193.      shell> /path/to/safe_mysqld &
  24194.  
  24195. *Note Environment variables::.
  24196.  
  24197. File not found
  24198. ==============
  24199.  
  24200. If you get `ERROR '...' not found (errno: 23)', `Can't open file: ...
  24201. (errno: 24)' or any other error with `errno 23' or `errno 24' from
  24202. *MySQL*, it means that you haven't allocated enough file descriptors
  24203. for *MySQL*.  You can use the `perror' utility to get a description of
  24204. what the error number means:
  24205.  
  24206.      shell> perror 23
  24207.      File table overflow
  24208.      shell> perror 24
  24209.      Too many open files
  24210.  
  24211. The problem here is that `mysqld' is trying to keep open too many files
  24212. simultaneously.  You can either tell `mysqld' not to open so many files
  24213. at once, or increase the number of file descriptors available to
  24214. `mysqld'.
  24215.  
  24216. To tell `mysqld' to keep open fewer files at a time, you can make the
  24217. table cache smaller by using the `-O table_cache=32' option to
  24218. `safe_mysqld' (the default value is 64). Reducing the value of
  24219. `max_connections' will also reduce the number of open files (the default
  24220. value is 90).
  24221.  
  24222. To change the number of file descriptors available to `mysqld', modify
  24223. the `safe_mysqld' script.  There is a commented-out line `ulimit -n
  24224. 256' in the script.  You can remove the `'#'' character to uncomment
  24225. this line, and change the number 256 to change the number of file
  24226. descriptors available to `mysqld'.
  24227.  
  24228. `ulimit' can increase the number of file descriptors, but only up to the
  24229. limit imposed by the operating system.  If you need to increase the OS
  24230. limit on the number of file descriptors available to each process,
  24231. consult the documentation for your operating system.
  24232.  
  24233. Note that if you run the `tcsh' shell, `ulimit' will not work!  `tcsh'
  24234. will also report incorrect values when you ask for the current limits!
  24235. In this case you should start `safe_mysqld' with `sh'!
  24236.  
  24237. Problems using `DATE' columns
  24238. =============================
  24239.  
  24240. The format of a `DATE' value is `'YYYY-MM-DD''. According to ANSI SQL,
  24241. no other format is allowed. You should use this format in `UPDATE'
  24242. expressions and in the WHERE clause of `SELECT' statements.  For
  24243. example:
  24244.  
  24245.      mysql> SELECT * FROM tbl_name WHERE date >= '1997-05-05';
  24246.  
  24247. As a convenience, *MySQL* automatically converts a date to a number if
  24248. the date is used in a numeric context (and vice versa). It is also smart
  24249. enough to allow a "relaxed" string form when updating and in a `WHERE'
  24250. clause that compares a date to a `TIMESTAMP', `DATE' or a `DATETIME'
  24251. column.  (Relaxed form means that any punctuation character may be used
  24252. as the separator between parts. For example, `'1998-08-15'' and
  24253. `'1998#08#15'' are equivalent.) *MySQL* can also convert a string
  24254. containing no separators (such as `'19980815''), provided it makes
  24255. sense as a date.
  24256.  
  24257. The special date `'0000-00-00'' can be stored and retrieved as
  24258. `'0000-00-00'.' When using a `'0000-00-00'' date through *MyODBC*, it
  24259. will automatically be converted to `NULL' in *MyODBC* 2.50.12 and
  24260. above, because ODBC can't handle this kind of date.
  24261.  
  24262. Because *MySQL* performs the conversions described above, the following
  24263. statements work:
  24264.  
  24265.      mysql> INSERT INTO tbl_name (idate) VALUES (19970505);
  24266.      mysql> INSERT INTO tbl_name (idate) VALUES ('19970505');
  24267.      mysql> INSERT INTO tbl_name (idate) VALUES ('97-05-05');
  24268.      mysql> INSERT INTO tbl_name (idate) VALUES ('1997.05.05');
  24269.      mysql> INSERT INTO tbl_name (idate) VALUES ('1997 05 05');
  24270.      mysql> INSERT INTO tbl_name (idate) VALUES ('0000-00-00');
  24271.      
  24272.      mysql> SELECT idate FROM tbl_name WHERE idate >= '1997-05-05';
  24273.      mysql> SELECT idate FROM tbl_name WHERE idate >= 19970505;
  24274.      mysql> SELECT mod(idate,100) FROM tbl_name WHERE idate >= 19970505;
  24275.      mysql> SELECT idate FROM tbl_name WHERE idate >= '19970505';
  24276.  
  24277. However, the following will not work:
  24278.  
  24279.      mysql> SELECT idate FROM tbl_name WHERE STRCMP(idate,'19970505')=0;
  24280.  
  24281. `STRCMP()' is a string function, so it converts `idate' to a string and
  24282. performs a string comparison.  It does not convert `'19970505'' to a
  24283. date and perform a date comparison.
  24284.  
  24285. Note that *MySQL* does no checking whether or not the date is correct.
  24286. If you store an incorrect date, such as `'1998-2-31'', the wrong date
  24287. will be stored. If the date cannot be converted to any reasonable
  24288. value, a `0' is stored in the `DATE' field.  This is mainly a speed
  24289. issue and we think it is up to the application to check the dates, and
  24290. not the server.
  24291.  
  24292. Timezone problems
  24293. =================
  24294.  
  24295. If you have a problem with `SELECT NOW()' returning values in GMT and
  24296. not your local time, you have to set the `TZ' environment variable to
  24297. your current timezone.  This should be done for the environment in which
  24298. the server runs, for example in `safe_mysqld' or `mysql.server'.  *Note
  24299. Environment variables::.
  24300.  
  24301. Case sensitivity in searches
  24302. ============================
  24303.  
  24304. By default, *MySQL* searches are case-insensitive (although there are
  24305. some character sets that are never case insensitive, such as `czech').
  24306. That means that if you search with `col_name LIKE 'a%'', you will get
  24307. all column values that start with `A' or `a'. If you want to make this
  24308. search case-sensitive, use something like `INDEX(col_name, "A")=0' to
  24309. check a prefix. Or use `STRCMP(col_name, "A") = 0' if the column value
  24310. must be exactly `"A"'.
  24311.  
  24312. Simple comparison operations (`>=, >, = , < , <=', sorting and
  24313. grouping) are based on each character's "sort value". Characters with
  24314. the same sort value (like E, e and Θ) are treated as the same character!
  24315.  
  24316. In older *MySQL* versions `LIKE' comparisons where done on the
  24317. uppercase value of each character (E == e but E <> Θ).  In newer
  24318. *MySQL* versions `LIKE' works just like the other comparison operators.
  24319.  
  24320. If you want a column always to be treated in case-sensitive fashion,
  24321. declare it as `BINARY'. *Note `CREATE TABLE': CREATE TABLE.
  24322.  
  24323. If you are using Chinese data in the so-called big5 encoding, you want
  24324. to make all character columns `BINARY'. This works because the sorting
  24325. order of big5 encoding characters is based on the order of ASCII codes.
  24326.  
  24327. Problems with `NULL' values
  24328. ===========================
  24329.  
  24330. The concept of the `NULL' value is a common source of confusion for
  24331. newcomers to SQL, who often think that `NULL' is the same thing as an
  24332. empty string `'''.  This is not the case! For example, the following
  24333. statements are completely different:
  24334.  
  24335.      mysql> INSERT INTO my_table (phone) VALUES (NULL);
  24336.      mysql> INSERT INTO my_table (phone) VALUES ("");
  24337.  
  24338. Both statements insert a value into the `phone' column, but the first
  24339. inserts a `NULL' value and the second inserts an empty string.  The
  24340. meaning of the first can be regarded as "phone number is not known" and
  24341. the meaning of the second can be regarded as "she has no phone".
  24342.  
  24343. In SQL, the `NULL' value is always false in comparison to any other
  24344. value, even `NULL'.  An expression that contains `NULL' always produces
  24345. a `NULL' value unless otherwise indicated in the documentation for the
  24346. operators and functions involved in the expression. All columns in the
  24347. following example return `NULL':
  24348.  
  24349.      mysql> SELECT NULL,1+NULL,CONCAT('Invisible',NULL);
  24350.  
  24351. If you want to search for column values that are `NULL', you cannot use
  24352. the `=NULL' test. The following statement returns no rows, because
  24353. `expr = NULL' is FALSE, for any expression:
  24354.  
  24355.      mysql> SELECT * FROM my_table WHERE phone = NULL;
  24356.  
  24357. To look for `NULL' values, you must use the `IS NULL' test.  The
  24358. following shows how to find the `NULL' phone number and the empty phone
  24359. number:
  24360.  
  24361.      mysql> SELECT * FROM my_table WHERE phone IS NULL;
  24362.      mysql> SELECT * FROM my_table WHERE phone = "";
  24363.  
  24364. In *MySQL*, as in many other SQL servers, you can't index columns that
  24365. can have `NULL' values.  You must declare such columns `NOT NULL'.
  24366. Conversely, you cannot insert `NULL' into an indexed column.
  24367.  
  24368. When reading data with `LOAD DATA INFILE', empty columns are updated
  24369. with `'''. If you want a `NULL' value in a column, you should use `\N'
  24370. in the text file. The literal word `'NULL'' may also be used under some
  24371. circumstances.  *Note `LOAD DATA': LOAD DATA.
  24372.  
  24373. When using `ORDER BY', `NULL' values are presented first. If you sort
  24374. in descending order using `DESC', `NULL' values are presented last.
  24375. When using `GROUP BY', all `NULL' values are regarded as equal.
  24376.  
  24377. To help with `NULL' handling, you can use the `IS NULL' and `IS NOT
  24378. NULL' operators and the `IFNULL()' function.
  24379.  
  24380. For some column types, `NULL' values are handled specially.  If you
  24381. insert `NULL' into the first `TIMESTAMP' column of a table, the current
  24382. date and time is inserted.  If you insert `NULL' into an
  24383. `AUTO_INCREMENT' column, the next number in the sequence is inserted.
  24384.  
  24385. Problems with `alias'
  24386. =====================
  24387.  
  24388. You can use an alias to refer to a column in the `GROUP BY', `ORDER BY'
  24389. or in the `HAVING' part.  Aliases can also be used to give columns more
  24390. better names:
  24391.  
  24392.      SELECT SQRT(a*b) as rt FROM table_name GROUP BY rt HAVING rt > 0;
  24393.      SELECT id,COUNT(*) AS cnt FROM table_name GROUP BY id HAVING cnt > 0;
  24394.      SELECT id AS "Customer identity" FROM table_name;
  24395.  
  24396. Note that you ANSI SQL doesn't allow you to refer to an alias in a
  24397. `WHERE' clause.  This is because when the `WHERE' code is executed the
  24398. column value may not yet be determinated. For example the following
  24399. query is *illegal*:
  24400.  
  24401.      SELECT id,COUNT(*) AS cnt FROM table_name WHERE cnt > 0 GROUP BY id;
  24402.  
  24403. The `WHERE' statement is executed to determinate which rows should be
  24404. included in the `GROUP BY' part while `HAVING' is used to decide which
  24405. rows from the result set should be used.
  24406.  
  24407. Deleting rows from related tables
  24408. =================================
  24409.  
  24410. As *MySQL* doesn't support sub-selects or use of more than one table in
  24411. the `DELETE' statement, you should use the following approach to delete
  24412. rows from 2 related tables:
  24413.  
  24414.   1. `SELECT' the rows based on some `WHERE' condition in the main
  24415.      table.
  24416.  
  24417.   2. `DELETE' the rows in the main table based on the same condition.
  24418.  
  24419.   3. `DELETE FROM related_table WHERE related_column IN (selected_rows)'
  24420.  
  24421. If the total number of characters in the query with `related_column' is
  24422. more than 1,048,576 (the default value of `max_allowed_packet', you
  24423. should split it into smaller parts and execute multiple `DELETE'
  24424. statements.  You will probably get the fastest `DELETE' by only
  24425. deleting 100-1000 `related_column' id's per query if the
  24426. `related_column' is an index.  If the `related_column' isn't an index,
  24427. the speed is independent of the number of arguments in the `IN' clause.
  24428.  
  24429. Solving problems with no matching rows
  24430. ======================================
  24431.  
  24432. If you have a complicated query with many tables that doesn't return any
  24433. rows, you should use the following procedure to find out what is wrong
  24434. with your query:
  24435.  
  24436.   1. Test the query with `EXPLAIN' and check if you can find something
  24437.      that is obviously wrong. *Note `EXPLAIN': EXPLAIN.
  24438.  
  24439.   2. Select only those fields that are used in the `WHERE' clause.
  24440.  
  24441.   3. Remove one table at a time from the query until it returns some
  24442.      rows.  If the tables are big, it's a good idea to use `LIMIT 10'
  24443.      with the query.
  24444.  
  24445.   4. Do a `SELECT' for the column that should have matched a row,
  24446.      against the table that was last removed from the query.
  24447.  
  24448.   5. If you are comparing `FLOAT' or `DOUBLE' columns with numbers that
  24449.      have decimals, you can't use `='!  This problem is common in most
  24450.      computer languages because floating point values are not exact
  24451.      values.
  24452.  
  24453.           mysql> SELECT * FROM table_name WHERE float_column=3.5;
  24454.              ->
  24455.           mysql> SELECT * FROM table_name WHERE float_column between 3.45 and 3.55;
  24456.  
  24457.      In most cases, changing the `FLOAT' to a `DOUBLE' will fix this!
  24458.  
  24459.   6. If you still can't figure out what's wrong, create a minimal test
  24460.      that can be run with `mysql test < query.sql' that shows your
  24461.      problems.  You can create a test file with `mysqldump --quick
  24462.      database tables > query.sql'. Open the file in an editor, remove
  24463.      some insert lines (if there are too many of these) and add your
  24464.      select statement at the end of the file.
  24465.  
  24466.      Test that you still have your problem by doing:
  24467.  
  24468.           shell> mysqladmin create test2
  24469.           shell> mysql test2 < query.sql
  24470.  
  24471.      Post the test file using `mysqlbug' to <mysql@lists.mysql.com>.
  24472.  
  24473. Problems with `ALTER TABLE'.
  24474. ============================
  24475.  
  24476. If `ALTER TABLE' dies with an error like this:
  24477.  
  24478.      Error on rename of './database/name.frm' to './database/B-a.frm' (Errcode: 17)
  24479.  
  24480. The problem may be that *MySQL* has crashed in a previous `ALTER TABLE'
  24481. and there is an old table named `A-something' or `B-something' lying
  24482. around.  In this case, go to the *MySQL* data directory and delete all
  24483. files that have names starting with `A-' or `B-'.  (You may want to
  24484. move them elsewhere instead of deleting them).
  24485.  
  24486. `ALTER TABLE' works the following way:
  24487.  
  24488.    * Create a new table named `A-xxx' with the requested changes.
  24489.  
  24490.    * All rows from the old table are copied to `A-xxx'.
  24491.  
  24492.    * The old table is renamed `B-xxx'.
  24493.  
  24494.    * `A-xxx' is renamed to your old table name.
  24495.  
  24496.    * `B-xxx' is deleted.
  24497.  
  24498. If something goes wrong with the renaming operation, *MySQL* tries to
  24499. undo the changes.  If something goes seriously wrong (this shouldn't
  24500. happen, of course), *MySQL* may leave the old table as `B-xxx' but a
  24501. simple rename should get your data back.
  24502.  
  24503. How to change the order of columns in a table
  24504. =============================================
  24505.  
  24506. The whole point of SQL is to abstract the application from the data
  24507. storage format.  You should always specify the order in wish you wish to
  24508. retrieve your data.  For example:
  24509.  
  24510.      SELECT col_name1, col_name2, col_name3 FROM tbl_name;
  24511.  
  24512. will return columns in the order `col_name1', `col_name2', `col_name3',
  24513. whereas:
  24514.  
  24515.      SELECT col_name1, col_name3, col_name2 FROM tbl_name;
  24516.  
  24517. will return columns in the order `col_name1', `col_name3', `col_name2'.
  24518.  
  24519. You should *NEVER*, in an application, use `SELECT *' and retrieve the
  24520. columns based on their position, because the order in which columns are
  24521. returned *CANNOT* be guaranteed over time; A simple change to your
  24522. database may cause your application to fail rather dramatically.
  24523.  
  24524. If you want to change the order of columns anyway, you can do it as
  24525. follows:
  24526.  
  24527.   1. Create a new table with the columns in the right order.
  24528.  
  24529.   2. Execute `INSERT INTO new_table SELECT fields-in-new_table-order
  24530.      FROM old_table'.
  24531.  
  24532.   3. Drop or rename `old_table'
  24533.  
  24534.   4. `ALTER TABLE new_table RENAME old_table'
  24535.  
  24536. Solving some common problems with MySQL
  24537. ***************************************
  24538.  
  24539. Database replication with update log
  24540. ====================================
  24541.  
  24542. Now that master-slave internal replication is available starting in
  24543. 3.23.15, this is the recommended way. However, it is still possible to
  24544. replicate a database by using the update log. *Note Update log::. This
  24545. requires one database that acts as a master (to which data changes are
  24546. made) and one or more other databases that act as slaves. To update a
  24547. slave, just run `mysql < update_log'.  Supply host, user and password
  24548. options that are appropriate for the slave database, and use the update
  24549. log from the master database as input.
  24550.  
  24551. If you never delete anything from a table, you can use a `TIMESTAMP'
  24552. column to find out which rows have been inserted or changed in the table
  24553. since the last replication (by comparing to the time when you did the
  24554. replication last time) and only copy these rows to the mirror.
  24555.  
  24556. It is possible to make a two-way updating system using both the update
  24557. log (for deletes) and timestamps (on both sides). But in that case you
  24558. must be able to handle conflicts when the same data have been changed in
  24559. both ends. You probably want to keep the old version to help with
  24560. deciding what has been updated.
  24561.  
  24562. Because replication in this case is done with SQL statements, you
  24563. should not use the following functions in statements that update the
  24564. database; they may not return the same value as in the original
  24565. database:
  24566.  
  24567.    * `DATABASE()'
  24568.  
  24569.    * `GET_LOCK()' and `RELEASE_LOCK()'
  24570.  
  24571.    * `RAND()'
  24572.  
  24573.    * `USER()', `SYSTEM_USER()' or `SESSION_USER()'
  24574.  
  24575.    * `VERSION()', `CONNECT_ID()'
  24576.  
  24577. All time functions are safe to use, as the timestamp is sent to the
  24578. mirror if needed. `LAST_INSERT_ID()' is also safe to use.
  24579.  
  24580. Database backups
  24581. ================
  24582.  
  24583. Because *MySQL* tables are stored as files, it is easy to do a backup.
  24584. To get a consistent backup, do a `LOCK TABLES' on the relevant tables.
  24585. *Note `LOCK TABLES': LOCK TABLES. You only need a read lock; this
  24586. allows other threads to continue to query the tables while you are
  24587. making a copy of the files in the database directory. If you want to
  24588. make a SQL level backup of a table, you can use `SELECT INTO OUTFILE'.
  24589.  
  24590. Another way to backup a database is to use the `mysqldump' program:
  24591. *Note mysqldump::.
  24592.  
  24593.   1. Do a full backup of your databases:
  24594.  
  24595.           shell> mysqldump --tab=/path/to/some/dir --opt --full
  24596.  
  24597.      You can also simply copy all table files (`*.frm', `*.MYD' and
  24598.      `*.MYI' files), as long as the server isn't updating anything.
  24599.      The script `mysqlhotcopy' does use this method.
  24600.  
  24601.   2. Stop `mysqld' if it's running, then start it with the
  24602.      `--log-update[=file_name]' option.  *Note Update log::. The update
  24603.      log file(s) provide you with the information you need to replicate
  24604.      changes to the database that are made subsequent to the point at
  24605.      which you executed `mysqldump'.
  24606.  
  24607. If you have to restore something, try to recover your tables using
  24608. `myisamchk -r' first.  That should work in 99.9% of all cases.  If
  24609. `myisamchk' fails, try the following procedure: (This will only work if
  24610. you have started *MySQL* with `--log-update'. *Note Update log::.)
  24611.  
  24612.   1. Restore the original `mysqldump' backup.
  24613.  
  24614.   2. Execute the following command to re-run the updates in the update
  24615.      logs:
  24616.           shell> ls -1 -t -r hostname.[0-9]* | xargs cat | mysql
  24617.  
  24618. `ls' is used to get all the update log files in the right order.
  24619.  
  24620. You can also do selective backups with `SELECT * INTO OUTFILE
  24621. 'file_name' FROM tbl_name' and restore with `LOAD DATA INFILE
  24622. 'file_name' REPLACE ...' To avoid duplicate records, you need a
  24623. `PRIMARY KEY' or a `UNIQUE' key in the table. The `REPLACE' keyword
  24624. causes old records to be replaced with new ones when a new record
  24625. duplicates an old record on a unique key value.
  24626.  
  24627. The update log
  24628. ==============
  24629.  
  24630. When started with the `--log-update[=file_name]' option, `mysqld'
  24631. writes a log file containing all SQL commands that update data. If no
  24632. file name is given, it defaults to the name of the host machine, If
  24633. file name is given, but it doesn't contain a path the file is written
  24634. in the data directory. If file_name doesn't have an extension, `mysqld'
  24635. will create log file names of type `file_name.#', where `#' is a number
  24636. that is incremented each time you execute `mysqladmin refresh' or
  24637. `mysqladmin flush-logs', the `FLUSH LOGS' statement, or restart the
  24638. server.
  24639.  
  24640. *Note:* For the above scheme to work, you should NOT create own files
  24641. with the same file name as the update log + some extensions that may be
  24642. regarded as a number, in the directory used by the update log!
  24643.  
  24644. If you use the `--log' or `-l' options, `mysqld' writes a general log
  24645. with a filename of `hostname.log', and restarts and refreshes do not
  24646. cause a new log file to be generated (although it is closed and
  24647. reopened). In this case you can copy it (on Unix) by doing:
  24648.  
  24649.      mv hostname.log hostname-old.log
  24650.      mysqladmin flush-logs
  24651.      cp hostname-old.log to-backup-directory
  24652.      rm hostname-old.log
  24653.  
  24654. By default, the `mysql.server' script starts the *MySQL* server with
  24655. the `-l' option.  If you need better performance when you start using
  24656. *MySQL* in a production environment, you can remove the `-l' option
  24657. from `mysql.server' or change it to `--log-update'.
  24658.  
  24659. Update logging is smart because it logs only statements that really
  24660. update data. So an `UPDATE' or a `DELETE' with a `WHERE' that finds no
  24661. rows is not written to the log. It even skips `UPDATE' statements that
  24662. set a column to the value it already has.
  24663.  
  24664. If you want to update a database from update log files, you could do the
  24665. following (assuming your update logs have names of the form
  24666. `file_name.###'):
  24667.  
  24668.      shell> ls -1 -t -r file_name.[0-9]* | xargs cat | mysql
  24669.  
  24670. `ls' is used to get all the log files in the right order.
  24671.  
  24672. This can be useful if you have to revert to backup files after a crash
  24673. and you want to redo the updates that occurred between the time of the
  24674. backup and the crash.
  24675.  
  24676. You can also use the update logs when you have a mirrored database on
  24677. another host and you want to replicate the changes that have been made
  24678. to the master database. *Note Log Replication::.
  24679.  
  24680. Running multiple MySQL servers on the same machine
  24681. ==================================================
  24682.  
  24683. There are circumstances when you might want to run multiple servers on
  24684. the same machine.  For example, you might want to test a new *MySQL*
  24685. release while leaving your existing production setup undisturbed.  Or
  24686. you might be an Internet service provider that wants to provide
  24687. independent *MySQL* installations for different customers.
  24688.  
  24689. If you want to run multiple servers, the easiest way is to compile the
  24690. servers with different TCP/IP ports and socket files so they are not
  24691. both listening to the same TCP/IP port or socket file.
  24692.  
  24693. Assume an existing server is configured for the default port number and
  24694. socket file.  Then configure the new server with a `configure' command
  24695. something like this:
  24696.  
  24697.      shell> ./configure  --with-tcp-port=port_number \
  24698.                   --with-unix-socket=file_name \
  24699.                   --prefix=/usr/local/mysql-3.22.9
  24700.  
  24701. Here `port_number' and `file_name' should be different than the default
  24702. port number and socket file pathname, and the `--prefix' value should
  24703. specify an installation directory different than the one under which
  24704. the existing *MySQL* installation is located.
  24705.  
  24706. You can check the socket and port used by any currently-executing
  24707. *MySQL* server with this command:
  24708.  
  24709.      shell> mysqladmin -h hostname --port=port_number variables
  24710.  
  24711. If you have a *MySQL* server running on the port you used, you will get
  24712. a list of some of the most important configurable variables in *MySQL*,
  24713. including the socket name.
  24714.  
  24715. You should also edit the initialization script for your machine
  24716. (probably `mysql.server') to start and kill multiple `mysqld' servers.
  24717.  
  24718. You don't have to recompile a new *MySQL* server just to start with a
  24719. different port and socket.  You can change the port and socket to be
  24720. used by specifying them at runtime as options to `safe_mysqld':
  24721.  
  24722.      shell> /path/to/safe_mysqld --socket=file_name --port=port_number
  24723.  
  24724. If you run the new server on the same database directory as another
  24725. server with logging enabled, you should also specify the name of the
  24726. log files to `safe_mysqld' with `--log' and `--log-update'.  Otherwise,
  24727. both servers may be trying to write to the same log file.
  24728.  
  24729. *Warning*: Normally you should never have two servers that update data
  24730. in the same database!  If your OS doesn't support fault-free system
  24731. locking, this may lead to unpleasant surprises!
  24732.  
  24733. If you want to use another database directory for the second server, you
  24734. can use the `--datadir=path' option to `safe_mysqld'.
  24735.  
  24736. When you want to connect to a *MySQL* server that is running with a
  24737. different port than the port that is compiled into your client, you can
  24738. use one of the following methods:
  24739.  
  24740.    * Start the client with `--host 'hostname' --port=port_numer' or
  24741.      `[--host localhost] --socket=file_name'.
  24742.  
  24743.    * In your C or Perl programs, you can give the port and socket
  24744.      arguments when connecting to the *MySQL* server.
  24745.  
  24746.    * Set the `MYSQL_UNIX_PORT' and `MYSQL_TCP_PORT' environment
  24747.      variables to point to the Unix socket and TCP/IP port before you
  24748.      start your clients.  If you normally use a specific socket or
  24749.      port, you should place commands to set these environment variables
  24750.      in your `.login' file.  *Note Environment variables::. *Note
  24751.      Programs::.
  24752.  
  24753.    * Specify the default socket and TCP/IP port in the `.my.cnf' file
  24754.      in your home directory. *Note Option files::.
  24755.  
  24756. MySQL client tools and APIs
  24757. ***************************
  24758.  
  24759. MySQL C API
  24760. ===========
  24761.  
  24762. The C API code is distributed with *MySQL*. It is included in the
  24763. `mysqlclient' library and allows C programs to access a database.
  24764.  
  24765. Many of the clients in the *MySQL* source distribution are written in
  24766. C.  If you are looking for examples that demonstrate how to use the C
  24767. API, take a look at these clients. You can find these in the `clients'
  24768. directory in the *MySQL* source distribution.
  24769.  
  24770. Most of the other client APIs (all except Java) use the `mysqlclient'
  24771. library to communicate with the *MySQL* server. This means that, for
  24772. example, you can take advantage of many of the same environment
  24773. variables that are used by other client programs, because they are
  24774. referenced from the library.  See *Note Programs::, for a list of these
  24775. variables.
  24776.  
  24777. The client has a maximum communication buffer size. The size of the
  24778. buffer that is allocated initially (16K bytes) is automatically
  24779. increased up to the maximum size (the default maximum is 24M). Because
  24780. buffer sizes are increased only as demand warrants, simply increasing
  24781. the default maximum limit does not in itself cause more resources to be
  24782. used. This size check is mostly a check for erroneous queries and
  24783. communication packets.
  24784.  
  24785. The communication buffer must be large enough to contain a single SQL
  24786. statement (for client-to-server traffic) and one row of returned data
  24787. (for server-to-client traffic).  Each thread's communication buffer is
  24788. dynamically enlarged to handle any query or row up to the maximum
  24789. limit.  For example, if you have `BLOB' values that contain up to 16M
  24790. of data, you must have a communication buffer limit of at least 16M (in
  24791. both server and client).  The client's default maximum is 24M, but the
  24792. default maximum in the server is 1M.  You can increase this by changing
  24793. the value of the `max_allowed_packet' parameter when the server is
  24794. started.  *Note Server parameters::.
  24795.  
  24796. The *MySQL* server shrinks each communication buffer to
  24797. `net_buffer_length' bytes after each query.  For clients, the size of
  24798. the buffer associated with a connection is not decreased until the
  24799. connection is closed, at which time client memory is reclaimed.
  24800.  
  24801. If you are programming with threads, you should compile the *MySQL* C
  24802. API with `--with-thread-safe-client'.  This will make the C API thread
  24803. safe per connection.   You can let two threads share the same
  24804. connection as long as you do the following:
  24805.  
  24806.  
  24807.      Two threads can't send a query to the *MySQL* at the same time on
  24808.      the same connection.  In particular you have to ensure that
  24809.      between a `mysql_query()' and `mysql_store_result()' no other
  24810.      thread is using the same connection.
  24811.  
  24812.  
  24813.      Many threads can access different result sets that are retrieved
  24814.      with `mysql_store_result()'.
  24815.  
  24816.  
  24817.      If you use `mysql_use_result', you have to ensure that no other
  24818.      thread is asking anything on the same connection until the result
  24819.      set is closed.
  24820.  
  24821. C API datatypes
  24822. ===============
  24823.  
  24824. `MYSQL'
  24825.      This structure represents a handle to one database connection. It
  24826.      is used for almost all *MySQL* functions.
  24827.  
  24828. `MYSQL_RES'
  24829.      This structure represents the result of a query that returns rows
  24830.      (`SELECT', `SHOW', `DESCRIBE', `EXPLAIN').  The information
  24831.      returned from a query is called the _result set_ in the remainder
  24832.      of this section.
  24833.  
  24834. `MYSQL_ROW'
  24835.      This is a type-safe representation of one row of data. It is
  24836.      currently implemented as an array of counted byte strings.  (You
  24837.      cannot treat these as null-terminated strings if field values may
  24838.      contain binary data, because such values may contain null bytes
  24839.      internally.)  Rows are obtained by calling `mysql_fetch_row()'.
  24840.  
  24841. `MYSQL_FIELD'
  24842.      This structure contains information about a field, such as the
  24843.      field's name, type and size. Its members are described in more
  24844.      detail below.  You may obtain the `MYSQL_FIELD' structures for
  24845.      each field by calling `mysql_fetch_field()' repeatedly.  Field
  24846.      values are not part of this structure; they are contained in a
  24847.      `MYSQL_ROW' structure.
  24848.  
  24849. `MYSQL_FIELD_OFFSET'
  24850.      This is a type-safe representation of an offset into a *MySQL*
  24851.      field list.  (Used by `mysql_field_seek()'.)  Offsets are field
  24852.      numbers within a row, beginning at zero.
  24853.  
  24854. `my_ulonglong'
  24855.      The type used for the number of rows and for
  24856.      `mysql_affected_rows()', `mysql_num_rows()' and
  24857.      `mysql_insert_id()'. This type provides a range of `0' to
  24858.      `1.84e19'.
  24859.  
  24860.      On some systems, attempting to print a value of type `my_ulonglong'
  24861.      will not work.  To print such a value, convert it to `unsigned
  24862.      long' and use a `%lu' print format.  Example:
  24863.           printf (Number of rows: %lu\n", (unsigned long) mysql_num_rows(result));
  24864.  
  24865. The `MYSQL_FIELD' structure contains the members listed below:
  24866.  
  24867. `char * name'
  24868.      The name of the field, as a null-terminated string.
  24869.  
  24870. `char * table'
  24871.      The name of the table containing this field, if it isn't a
  24872.      calculated field.  For calculated fields, the `table' value is an
  24873.      empty string.
  24874.  
  24875. `char * def'
  24876.      The default value of this field, as a null-terminated string.
  24877.      This is set only if you use `mysql_list_fields()'.
  24878.  
  24879. `enum enum_field_types type'
  24880.      The type of the field.  The `type' value may be one of the
  24881.      following:
  24882.  
  24883.      *Type value*         *Type meaning*
  24884.      `FIELD_TYPE_TINY'    `TINYINT' field
  24885.      `FIELD_TYPE_SHORT'   `SMALLINT' field
  24886.      `FIELD_TYPE_LONG'    `INTEGER' field
  24887.      `FIELD_TYPE_INT24'   `MEDIUMINT' field
  24888.      `FIELD_TYPE_LONGLONG'`BIGINT' field
  24889.      `FIELD_TYPE_DECIMAL' `DECIMAL' or `NUMERIC' field
  24890.      `FIELD_TYPE_FLOAT'   `FLOAT' field
  24891.      `FIELD_TYPE_DOUBLE'  `DOUBLE' or `REAL' field
  24892.      `FIELD_TYPE_TIMESTAMP'`TIMESTAMP' field
  24893.      `FIELD_TYPE_DATE'    `DATE' field
  24894.      `FIELD_TYPE_TIME'    `TIME' field
  24895.      `FIELD_TYPE_DATETIME'`DATETIME' field
  24896.      `FIELD_TYPE_YEAR'    `YEAR' field
  24897.      `FIELD_TYPE_STRING'  String (`CHAR' or `VARCHAR') field
  24898.      `FIELD_TYPE_BLOB'    `BLOB' or `TEXT' field (use
  24899.                           `max_length' to determine the
  24900.                           maximum length)
  24901.      `FIELD_TYPE_SET'     `SET' field
  24902.      `FIELD_TYPE_ENUM'    `ENUM' field
  24903.      `FIELD_TYPE_NULL'    `NULL'-type field
  24904.      `FIELD_TYPE_CHAR'    Deprecated; use `FIELD_TYPE_TINY'
  24905.                           instead
  24906.  
  24907.      You can use the `IS_NUM()' macro to test whether or not a field
  24908.      has a numeric type.  Pass the `type' value to `IS_NUM()' and it
  24909.      will evaluate to TRUE if the field is numeric:
  24910.  
  24911.           if (IS_NUM(field->type))
  24912.               printf("Field is numeric\n");
  24913.  
  24914. `unsigned int length'
  24915.      The width of the field, as specified in the table definition.
  24916.  
  24917. `unsigned int max_length'
  24918.      The maximum width of the field for the result set (the length of
  24919.      the longest field value for the rows actually in the result set).
  24920.      If you use `mysql_store_result()' or `mysql_list_fields()', this
  24921.      contains the maximum length for the field.  If you use
  24922.      `mysql_use_result()', the value of this variable is zero.
  24923.  
  24924. `unsigned int flags'
  24925.      Different bit-flags for the field.  The `flags' value may have zero
  24926.      or more of the following bits set:
  24927.  
  24928.      *Flag value*         *Flag meaning*
  24929.      `NOT_NULL_FLAG'      Field can't be `NULL'
  24930.      `PRI_KEY_FLAG'       Field is part of a primary key
  24931.      `UNIQUE_KEY_FLAG'    Field is part of a unique key
  24932.      `MULTIPLE_KEY_FLAG'  Field is part of a non-unique key.
  24933.      `UNSIGNED_FLAG'      Field has the `UNSIGNED' attribute
  24934.      `ZEROFILL_FLAG'      Field has the `ZEROFILL' attribute
  24935.      `BINARY_FLAG'        Field has the `BINARY' attribute
  24936.      `AUTO_INCREMENT_FLAG'Field has the `AUTO_INCREMENT'
  24937.                           attribute
  24938.      `ENUM_FLAG'          Field is an `ENUM' (deprecated)
  24939.      `BLOB_FLAG'          Field is a `BLOB' or `TEXT'
  24940.                           (deprecated)
  24941.      `TIMESTAMP_FLAG'     Field is a `TIMESTAMP' (deprecated)
  24942.  
  24943.      Use of the `BLOB_FLAG', `ENUM_FLAG' and `TIMESTAMP_FLAG' flags is
  24944.      deprecated because they indicate the type of a field rather than an
  24945.      attribute of its type.  It is preferable to test `field->type'
  24946.      against `FIELD_TYPE_BLOB', `FIELD_TYPE_ENUM' or
  24947.      `FIELD_TYPE_TIMESTAMP' instead.
  24948.  
  24949.      The example below illustrates a typical use of the `flags' value:
  24950.  
  24951.           if (field->flags & NOT_NULL_FLAG)
  24952.               printf("Field can't be null\n");
  24953.  
  24954.      You may use the following convenience macros to determine the
  24955.      boolean status of the `flags' value:
  24956.  
  24957.      `IS_NOT_NULL(flags)' True if this field is defined as
  24958.                           `NOT NULL'
  24959.      `IS_PRI_KEY(flags)'  True if this field is a primary
  24960.                           key
  24961.      `IS_BLOB(flags)'     True if this field is a `BLOB' or
  24962.                           `TEXT' (deprecated; test
  24963.                           `field->type' instead)
  24964.  
  24965. `unsigned int decimals'
  24966.      The number of decimals for numeric fields.
  24967.  
  24968. C API function overview
  24969. =======================
  24970.  
  24971. The functions available in the C API are listed below and are described
  24972. in greater detail in the next section.  *Note C API functions::.
  24973.  
  24974. *mysql_affected_rows()* Returns the number of rows affected by the last
  24975.                        `UPDATE', `DELETE' or `INSERT' query.
  24976. *mysql_close()*         Closes a server connection.
  24977. *mysql_connect()*       Connects to a *MySQL* server. This function is
  24978.                        deprecated; use `mysql_real_connect()' instead.
  24979. *mysql_change_user()*   Change user and database on an open connection.
  24980. `mysql_character_set_name()' Returns the name of the default character set
  24981.                        for the connection.
  24982. *mysql_create_db()*     Creates a database. This function is deprecated;
  24983.                        use the SQL command `CREATE DATABASE' instead.
  24984. *mysql_data_seek()*     Seeks to an arbitrary row in a query result set.
  24985. *mysql_debug()*         Does a `DBUG_PUSH' with the given string.
  24986. *mysql_drop_db()*       Drops a database. This function is deprecated;
  24987.                        use the SQL command `DROP DATABASE' instead.
  24988. *mysql_dump_debug_info()* Makes the server write debug information to the
  24989.                        log.
  24990. *mysql_eof()*           Determines whether or not the last row of a
  24991.                        result set has been read.  This function is
  24992.                        deprecated; `mysql_errno()' or `mysql_error()'
  24993.                        may be used instead.
  24994. *mysql_errno()*         Returns the error number for the most recently
  24995.                        invoked *MySQL* function.
  24996. *mysql_error()*         Returns the error message for the most recently
  24997.                        invoked *MySQL* function.
  24998. *mysql_real_escape_string()* Escapes special characters in a string for use
  24999.                        in a SQL statement taking into account the
  25000.                        current charset of the connection.
  25001. *mysql_escape_string()* Escapes special characters in a string for use
  25002.                        in a SQL statement.
  25003. *mysql_fetch_field()*   Returns the type of the next table field.
  25004. *mysql_fetch_field_direct()* Returns the type of a table field, given a field
  25005.                        number.
  25006. *mysql_fetch_fields()*  Returns an array of all field structures.
  25007. *mysql_fetch_lengths()* Returns the lengths of all columns in the
  25008.                        current row.
  25009. *mysql_fetch_row()*     Fetches the next row from the result set.
  25010. *mysql_field_seek()*    Puts the column cursor on a specified column.
  25011. *mysql_field_count()*   Returns the number of result columns for the
  25012.                        most recent query.
  25013. *mysql_field_tell()*    Returns the position of the field cursor used
  25014.                        for the last `mysql_fetch_field()'.
  25015. *mysql_free_result()*   Frees memory used by a result set.
  25016. *mysql_get_client_info()* Returns client version information.
  25017. *mysql_get_host_info()* Returns a string describing the connection.
  25018. *mysql_get_proto_info()* Returns the protocol version used by the
  25019.                        connection.
  25020. *mysql_get_server_info()* Returns the server version number.
  25021. *mysql_info()*          Returns information about the most recently
  25022.                        executed query.
  25023. *mysql_init()*          Gets or initializes a `MYSQL' structure.
  25024. *mysql_insert_id()*     Returns the ID generated for an `AUTO_INCREMENT'
  25025.                        column by the previous query.
  25026. *mysql_kill()*          Kill a given thread.
  25027. *mysql_list_dbs()*      Returns database names matching a simple regular
  25028.                        expression.
  25029. *mysql_list_fields()*   Returns field names matching a simple regular
  25030.                        expression.
  25031. *mysql_list_processes()* Returns a list of the current server threads.
  25032. *mysql_list_tables()*   Returns table names matching a simple regular
  25033.                        expression.
  25034. *mysql_num_fields()*    Returns the number of columns in a result set.
  25035. *mysql_num_rows()*      Returns the number of rows in a result set.
  25036. *mysql_options()*       Set connect options for `mysql_connect()'.
  25037. *mysql_ping()*          Checks whether or not the connection to the
  25038.                        server is working, reconnecting as necessary.
  25039. *mysql_query()*         Executes a SQL query specified as a
  25040.                        null-terminated string.
  25041. *mysql_real_connect()*  Connects to a *MySQL* server.
  25042. *mysql_real_query()*    Executes a SQL query specified as a counted
  25043.                        string.
  25044. *mysql_reload()*        Tells the server to reload the grant tables.
  25045. *mysql_row_seek()*      Seeks to a row in a result set, using value
  25046.                        returned from `mysql_row_tell()'.
  25047. *mysql_row_tell()*      Returns the row cursor position.
  25048. *mysql_select_db()*     Selects a database.
  25049. *mysql_shutdown()*      Shuts down the database server.
  25050. *mysql_start_slave()*   Starts slave replication thread
  25051. *mysql_stat()*          Returns the server status as a string.
  25052. *mysql_store_result()*  Retrieves a complete result set to the client.
  25053. *mysql_stop_slave()*    Stops slave replication thread
  25054. *mysql_thread_id()*     Returns the current thread ID.
  25055. *mysql_thread_save()*   Returns 1 if the clients are compiled as
  25056.                        threadsafe.
  25057. *mysql_use_result()*    Initiates a row-by-row result set retrieval.
  25058.  
  25059. To connect to the server, call `mysql_init()' to initialize a
  25060. connection handler, then call `mysql_real_connect()' with that handler
  25061. (along with other information such as the hostname, user name and
  25062. password).  Upon connection, `mysql_real_connect()' sets the
  25063. `reconnect' flag (part of the MYSQL structure) to a value of `1'. This
  25064. flag indicates, in the event that a query cannot be performed because
  25065. of a lost connection, to try reconnecting to the server before giving
  25066. up.  When you are done with the connection, call `mysql_close()' to
  25067. terminate it.
  25068.  
  25069. While a connection is active, the client may send SQL queries to the
  25070. server using `mysql_query()' or `mysql_real_query()'.  The difference
  25071. between the two is that `mysql_query()' expects the query to be
  25072. specified as a null-terminated string whereas `mysql_real_query()'
  25073. expects a counted string.  If the string contains binary data (which may
  25074. include null bytes), you must use `mysql_real_query()'.
  25075.  
  25076. For each non-`SELECT' query (e.g., `INSERT', `UPDATE', `DELETE'), you
  25077. can found out how many rows were affected (changed) by calling
  25078. `mysql_affected_rows()'.
  25079.  
  25080. For `SELECT' queries, you retrieve the selected rows as a result set.
  25081. (Note that some statements are `SELECT'-like in that they return rows.
  25082. These include `SHOW', `DESCRIBE' and `EXPLAIN'.  They should be treated
  25083. the same way as `SELECT' statements.)
  25084.  
  25085. There are two ways for a client to process result sets.  One way is to
  25086. retrieve the entire result set all at once by calling
  25087. `mysql_store_result()'.  This function acquires from the server all the
  25088. rows returned by the query and stores them in the client.  The second
  25089. way is for the client to initiate a row-by-row result set retrieval by
  25090. calling `mysql_use_result()'.  This function initializes the retrieval,
  25091. but does not actually get any rows from the server.
  25092.  
  25093. In both cases, you access rows by calling `mysql_fetch_row()'.  With
  25094. `mysql_store_result()', `mysql_fetch_row()' accesses rows that have
  25095. already been fetched from the server.  With `mysql_use_result()',
  25096. `mysql_fetch_row()' actually retrieves the row from the server.
  25097. Information about the size of the data in each row is available by
  25098. calling `mysql_fetch_lengths()'.
  25099.  
  25100. After you are done with a result set, call `mysql_free_result()' to
  25101. free the memory used for it.
  25102.  
  25103. The two retrieval mechanisms are complementary.  Client programs should
  25104. choose the approach that is most appropriate for their requirements.
  25105. In practice, clients tend to use `mysql_store_result()' more commonly.
  25106.  
  25107. An advantage of `mysql_store_result()' is that because the rows have all
  25108. been fetched to the client, you not only can access rows sequentially,
  25109. you can move back and forth in the result set using `mysql_data_seek()'
  25110. or `mysql_row_seek()' to change the current row position within the
  25111. result set.  You can also find out how many rows there are by calling
  25112. `mysql_num_rows()'.  On the other hand, the memory requirements for
  25113. `mysql_store_result()' may be very high for large result sets and you
  25114. are more likely to encounter out-of-memory conditions.
  25115.  
  25116. An advantage of `mysql_use_result()' is that the client requires less
  25117. memory for the result set because it maintains only one row at a time
  25118. (and because there is less allocation overhead, `mysql_use_result()'
  25119. can be faster).  Disadvantages are that you must process each row
  25120. quickly to avoid tying up the server, you don't have random access to
  25121. rows within the result set (you can only access rows sequentially), and
  25122. you don't know how many rows are in the result set until you have
  25123. retrieved them all.  Furthermore, you _must_ retrieve all the rows even
  25124. if you determine in mid-retrieval that you've found the information you
  25125. were looking for.
  25126.  
  25127. The API makes it possible for clients to respond appropriately to
  25128. queries (retrieving rows only as necessary) without knowing whether or
  25129. not the query is a `SELECT'.  You can do this by calling
  25130. `mysql_store_result()' after each `mysql_query()' (or
  25131. `mysql_real_query()').  If the result set call succeeds, the query was
  25132. a `SELECT' and you can read the rows.  If the result set call fails,
  25133. call `mysql_field_count()' to determine whether or not a result was
  25134. actually to be expected.  If `mysql_field_count()' returns zero, the
  25135. query returned no data (indicating that it was an `INSERT', `UPDATE',
  25136. `DELETE', etc.), and thus not expected to return rows.  If
  25137. `mysql_field_count()' is non-zero, the query should have returned rows,
  25138. but didn't.  This indicates that the query was a `SELECT' that failed.
  25139. See the description for `mysql_field_count()' for an example of how
  25140. this can be done.
  25141.  
  25142. Both `mysql_store_result()' and `mysql_use_result()' allow you to
  25143. obtain information about the fields that make up the result set (the
  25144. number of fields, their names and types, etc.).  You can access field
  25145. information sequentially within the row by calling
  25146. `mysql_fetch_field()' repeatedly, or by field number within the row by
  25147. calling `mysql_fetch_field_direct()'.  The current field cursor
  25148. position may be changed by calling `mysql_field_seek()'.  Setting the
  25149. field cursor affects subsequent calls to `mysql_fetch_field()'.  You
  25150. can also get information for fields all at once by calling
  25151. `mysql_fetch_fields()'.
  25152.  
  25153. For detecting and reporting errors, *MySQL* provides access to error
  25154. information by means of the `mysql_errno()' and `mysql_error()'
  25155. functions.  These return the error code or error message for the most
  25156. recently invoked function that can succeed or fail, allowing you to
  25157. determine when an error occurred and what it was.
  25158.  
  25159. C API function descriptions
  25160. ===========================
  25161.  
  25162. In the descriptions below, a parameter or return value of `NULL' means
  25163. `NULL' in the sense of the C programming language, not a *MySQL* `NULL'
  25164. value.
  25165.  
  25166. Functions that return a value generally return a pointer or an integer.
  25167. Unless specified otherwise, functions returning a pointer return a
  25168. non-`NULL' value to indicate success or a `NULL' value to indicate an
  25169. error, and functions returning an integer return zero to indicate
  25170. success or non-zero to indicate an error.  Note that "non-zero" means
  25171. just that.  Unless the function description says otherwise, do not test
  25172. against a value other than zero:
  25173.  
  25174.      if (result)                   /* correct */
  25175.          ... error ...
  25176.      
  25177.      if (result < 0)               /* incorrect */
  25178.          ... error ...
  25179.      
  25180.      if (result == -1)             /* incorrect */
  25181.          ... error ...
  25182.  
  25183. When a function returns an error, the *Errors* subsection of the
  25184. function description lists the possible types of errors.  You can find
  25185. out which of these occurred by calling `mysql_errno()'.  A string
  25186. representation of the error may be obtained by calling `mysql_error()'.
  25187.  
  25188. `mysql_affected_rows()'
  25189. -----------------------
  25190.  
  25191. `my_ulonglong mysql_affected_rows(MYSQL *mysql)'
  25192.  
  25193. Description
  25194. ...........
  25195.  
  25196. Returns the number of rows affected (changed) by the last `UPDATE',
  25197. `DELETE' or `INSERT' query. May be called immediately after
  25198. `mysql_query()' for `UPDATE', `DELETE' or `INSERT' statements.  For
  25199. `SELECT' statements, `mysql_affected_rows()' works like
  25200. `mysql_num_rows()'.
  25201.  
  25202. `mysql_affected_rows()' is currently implemented as a macro.
  25203.  
  25204. Return values
  25205. .............
  25206.  
  25207. An integer greater than zero indicates the number of rows affected or
  25208. retrieved.  Zero indicates that no records matched the `WHERE' clause in
  25209. the query or that no query has yet been executed.  -1 indicates that the
  25210. query returned an error or that, for a `SELECT' query,
  25211. `mysql_affected_rows()' was called prior to calling
  25212. `mysql_store_result()'.
  25213.  
  25214. Errors
  25215. ......
  25216.  
  25217. None.
  25218.  
  25219. Example
  25220. .......
  25221.  
  25222.      mysql_query(&mysql,"UPDATE products SET cost=cost*1.25 WHERE group=10");
  25223.      printf("%d products updated",mysql_affected_rows(&mysql));
  25224.  
  25225. `mysql_close()'
  25226. ---------------
  25227.  
  25228. `void mysql_close(MYSQL *mysql)'
  25229.  
  25230. Description
  25231. ...........
  25232.  
  25233. Closes a previously opened connection.  `mysql_close()' also deallocates
  25234. the connection handle pointed to by `mysql' if the handle was allocated
  25235. automatically by `mysql_init()' or `mysql_connect()'.
  25236.  
  25237. Return values
  25238. .............
  25239.  
  25240. None.
  25241.  
  25242. Errors
  25243. ......
  25244.  
  25245. `CR_COMMANDS_OUT_OF_SYNC'
  25246.      Commands were executed in an improper order.
  25247.  
  25248. `CR_SERVER_GONE_ERROR'
  25249.      The *MySQL* server has gone away.
  25250.  
  25251. `CR_SERVER_LOST'
  25252.      The connection to the server was lost during the query.
  25253.  
  25254. `CR_UNKNOWN_ERROR'
  25255.      An unknown error occurred.
  25256.  
  25257. `mysql_connect()'
  25258. -----------------
  25259.  
  25260. `MYSQL *mysql_connect(MYSQL *mysql, const char *host, const char *user,
  25261. const char *passwd)'
  25262.  
  25263. Description
  25264. ...........
  25265.  
  25266. This function is deprecated.  It is preferable to use
  25267. `mysql_real_connect()' instead.
  25268.  
  25269. `mysql_connect()' attempts to establish a connection to a *MySQL*
  25270. database engine running on `host'.  `mysql_connect()' must complete
  25271. successfully before you can execute any of the other API functions,
  25272. with the exception of `mysql_get_client_info()'.
  25273.  
  25274. The meanings of the parameters are the same as for the corresponding
  25275. parameters for `mysql_real_connect()' with the difference that the
  25276. connection parameter may be `NULL'. In this case the C API allocates
  25277. memory for the connection structure automatically and frees it when you
  25278. call `mysql_close()'. The disadvantage of this approach is that you
  25279. can't retrieve an error message if the connection fails.  (To get error
  25280. information from `mysql_errno()' or `mysql_error()', you must provide a
  25281. valid `MYSQL' pointer.)
  25282.  
  25283. Return values
  25284. .............
  25285.  
  25286. Same as for `mysql_real_connect()'.
  25287.  
  25288. Errors
  25289. ......
  25290.  
  25291. Same as for `mysql_real_connect()'.
  25292.  
  25293. `mysql_change_user()'
  25294. ---------------------
  25295.  
  25296. `my_bool mysql_change_user(MYSQL *mysql, const char *user, const char
  25297. *password, const char *db)'
  25298.  
  25299. Description
  25300. ...........
  25301.  
  25302. Changes the user and causes the database specified by `db' to become
  25303. the default (current) database on the connection specified by `mysql'.
  25304. In subsequent queries, this database is the default for table
  25305. references that do not include an explicit database specifier.
  25306.  
  25307. This function was introduced in *MySQL* 3.23.3.
  25308.  
  25309. `mysql_change_user()' fails unless the connected user can be
  25310. authenticated or if he doesn't have permission to use the database.  In
  25311. this case the user and database are not changed
  25312.  
  25313. The `db' parameter may be set to `NULL' if you don't want to have a
  25314. default database.
  25315.  
  25316. Return values
  25317. .............
  25318.  
  25319. Zero for success.  Non-zero if an error occurred.
  25320.  
  25321. Errors
  25322. ......
  25323.  
  25324. The same that you can get from `mysql_real_connect()'.
  25325.  
  25326. `CR_COMMANDS_OUT_OF_SYNC'
  25327.      Commands were executed in an improper order.
  25328.  
  25329. `CR_SERVER_GONE_ERROR'
  25330.      The *MySQL* server has gone away.
  25331.  
  25332. `CR_SERVER_LOST'
  25333.      The connection to the server was lost during the query.
  25334.  
  25335. `CR_UNKNOWN_ERROR'
  25336.      An unknown error occurred.
  25337.  
  25338. `ER_UNKNOWN_COM_ERROR'
  25339.      The *MySQL* server doesn't implement this command (probably an old
  25340.      server)
  25341.  
  25342. `ER_ACCESS_DENIED_ERROR'
  25343.      The user or password was wrong.
  25344.  
  25345. `ER_BAD_DB_ERROR'
  25346.      The database didn't exists.
  25347.  
  25348. `ER_DBACCESS_DENIED_ERROR'
  25349.      The user did not have access rights to the database.
  25350.  
  25351. `ER_WRONG_DB_NAME'
  25352.      The database name was too long.
  25353.  
  25354. Example
  25355. .......
  25356.  
  25357.      if (mysql_change_user(&mysql, "user", "password", "new_database"))
  25358.      {
  25359.         fprintf(stderr, "Failed to change user.  Error: %s\n",
  25360.                 mysql_error(&mysql));
  25361.      }
  25362.  
  25363. `mysql_character_set_name()'
  25364. ----------------------------
  25365.  
  25366. `const char *mysql_character_set_name(MYSQL *mysql)'
  25367.  
  25368. Description
  25369. ...........
  25370.  
  25371. Returns the default character set for the current connection.
  25372.  
  25373. Return values
  25374. .............
  25375.  
  25376. The default character set
  25377.  
  25378. Errors
  25379. ......
  25380.  
  25381. None.
  25382.  
  25383. `mysql_create_db()'
  25384. -------------------
  25385.  
  25386. `int mysql_create_db(MYSQL *mysql, const char *db)'
  25387.  
  25388. Description
  25389. ...........
  25390.  
  25391. Creates the database named by the `db' parameter.
  25392.  
  25393. This function is deprecated.  It is preferable to use `mysql_query()'
  25394. to issue a SQL `CREATE DATABASE' statement instead.
  25395.  
  25396. Return values
  25397. .............
  25398.  
  25399. Zero if the database was created successfully. Non-zero if an error
  25400. occurred.
  25401.  
  25402. Errors
  25403. ......
  25404.  
  25405. `CR_COMMANDS_OUT_OF_SYNC'
  25406.      Commands were executed in an improper order.
  25407.  
  25408. `CR_SERVER_GONE_ERROR'
  25409.      The *MySQL* server has gone away.
  25410.  
  25411. `CR_SERVER_LOST'
  25412.      The connection to the server was lost during the query.
  25413.  
  25414. `CR_UNKNOWN_ERROR'
  25415.      An unknown error occurred.
  25416.  
  25417. Example
  25418. .......
  25419.  
  25420.      if(mysql_create_db(&mysql, "my_database"))
  25421.      {
  25422.         fprintf(stderr, "Failed to create new database.  Error: %s\n",
  25423.                 mysql_error(&mysql));
  25424.      }
  25425.  
  25426. `mysql_data_seek()'
  25427. -------------------
  25428.  
  25429. `void mysql_data_seek(MYSQL_RES *result, unsigned long long offset)'
  25430.  
  25431. Description
  25432. ...........
  25433.  
  25434. Seeks to an arbitrary row in a query result set.  This requires that the
  25435. result set structure contains the entire result of the query, so
  25436. `mysql_data_seek()' may be used in conjunction only with
  25437. `mysql_store_result()', not with `mysql_use_result()'.
  25438.  
  25439. The offset should be a value in the range from 0 to
  25440. `mysql_num_rows(result)-1'.
  25441.  
  25442. Return values
  25443. .............
  25444.  
  25445. None.
  25446.  
  25447. Errors
  25448. ......
  25449.  
  25450. None.
  25451.  
  25452. `mysql_debug()'
  25453. ---------------
  25454.  
  25455. `void mysql_debug(char *debug)'
  25456.  
  25457. Description
  25458. ...........
  25459.  
  25460. Does a `DBUG_PUSH' with the given string. `mysql_debug()' uses the Fred
  25461. Fish debug library. To use this function, you must compile the client
  25462. library to support debugging.  *Note Debugging server::. *Note
  25463. Debugging client::.
  25464.  
  25465. Return values
  25466. .............
  25467.  
  25468. None.
  25469.  
  25470. Errors
  25471. ......
  25472.  
  25473. None.
  25474.  
  25475. Example
  25476. .......
  25477.  
  25478. The call shown below causes the client library to generate a trace file
  25479. in `/tmp/client.trace' on the client machine:
  25480.  
  25481.      mysql_debug("d:t:O,/tmp/client.trace");
  25482.  
  25483. `mysql_drop_db()'
  25484. -----------------
  25485.  
  25486. `int mysql_drop_db(MYSQL *mysql, const char *db)'
  25487.  
  25488. Description
  25489. ...........
  25490.  
  25491. Drops the database named by the `db' parameter.
  25492.  
  25493. This function is deprecated.  It is preferable to use `mysql_query()'
  25494. to issue a SQL `DROP DATABASE' statement instead.
  25495.  
  25496. Return values
  25497. .............
  25498.  
  25499. Zero if the database was dropped successfully. Non-zero if an error
  25500. occurred.
  25501.  
  25502. Errors
  25503. ......
  25504.  
  25505. `CR_COMMANDS_OUT_OF_SYNC'
  25506.      Commands were executed in an improper order.
  25507.  
  25508. `CR_SERVER_GONE_ERROR'
  25509.      The *MySQL* server has gone away.
  25510.  
  25511. `CR_SERVER_LOST'
  25512.      The connection to the server was lost during the query.
  25513.  
  25514. `CR_UNKNOWN_ERROR'
  25515.      An unknown error occurred.
  25516.  
  25517. Example
  25518. .......
  25519.  
  25520.      if(mysql_drop_db(&mysql, "my_database"))
  25521.        fprintf(stderr, "Failed to drop the database: Error: %s\n",
  25522.                mysql_error(&mysql));
  25523.  
  25524. `mysql_dump_debug_info()'
  25525. -------------------------
  25526.  
  25527. `int mysql_dump_debug_info(MYSQL *mysql)'
  25528.  
  25529. Description
  25530. ...........
  25531.  
  25532. Instructs the server to write some debug information to the log.  The
  25533. connected user must have the *process* privilege for this to work.
  25534.  
  25535. Return values
  25536. .............
  25537.  
  25538. Zero if the command was successful. Non-zero if an error occurred.
  25539.  
  25540. Errors
  25541. ......
  25542.  
  25543. `CR_COMMANDS_OUT_OF_SYNC'
  25544.      Commands were executed in an improper order.
  25545.  
  25546. `CR_SERVER_GONE_ERROR'
  25547.      The *MySQL* server has gone away.
  25548.  
  25549. `CR_SERVER_LOST'
  25550.      The connection to the server was lost during the query.
  25551.  
  25552. `CR_UNKNOWN_ERROR'
  25553.      An unknown error occurred.
  25554.  
  25555. `mysql_eof()'
  25556. -------------
  25557.  
  25558. `my_bool mysql_eof(MYSQL_RES *result)'
  25559.  
  25560. Description
  25561. ...........
  25562.  
  25563. This function is deprecated.  `mysql_errno()' or `mysql_error()' may be
  25564. used instead.
  25565.  
  25566. `mysql_eof()' determines whether or not the last row of a result set
  25567. has been read.
  25568.  
  25569. If you acquire a result set from a successful call to
  25570. `mysql_store_result()', the client receives the entire set in one
  25571. operation.  In this case, a `NULL' return from `mysql_fetch_row()'
  25572. always means the end of the result set has been reached and it is
  25573. unnecessary to call `mysql_eof()'.
  25574.  
  25575. On the other hand, if you use `mysql_use_result()' to initiate a result
  25576. set retrieval, the rows of the set are obtained from the server one by
  25577. one as you call `mysql_fetch_row()' repeatedly.  Because an error may
  25578. occur on the connection during this process, a `NULL' return value from
  25579. `mysql_fetch_row()' does not necessarily mean the end of the result set
  25580. was reached normally.  In this case, you can use `mysql_eof()' to
  25581. determine what happened.  `mysql_eof()' returns a non-zero value if the
  25582. end of the result set was reached and zero if an error occurred.
  25583.  
  25584. Historically, `mysql_eof()' predates the standard *MySQL* error
  25585. functions `mysql_errno()' and `mysql_error()'.  Because those error
  25586. functions provide the same information, their use is preferred over
  25587. `mysql_eof()', which is now deprecated.  (In fact, they provide more
  25588. information, because `mysql_eof()' returns only a boolean value whereas
  25589. the error functions indicate a reason for the error when one occurs.)
  25590.  
  25591. Return values
  25592. .............
  25593.  
  25594. Zero if no error occurred. Non-zero if the end of the result set has
  25595. been reached.
  25596.  
  25597. Errors
  25598. ......
  25599.  
  25600. None.
  25601.  
  25602. Example
  25603. .......
  25604.  
  25605. The following example shows how you might use `mysql_eof()':
  25606.  
  25607.      mysql_query(&mysql,"SELECT * FROM some_table");
  25608.      result = mysql_use_result(&mysql);
  25609.      while((row = mysql_fetch_row(result)))
  25610.      {
  25611.          // do something with data
  25612.      }
  25613.      if(!mysql_eof(result))  // mysql_fetch_row() failed due to an error
  25614.      {
  25615.          fprintf(stderr, "Error: %s\n", mysql_error(&mysql));
  25616.      }
  25617.  
  25618. However, you can achieve the same effect with the standard *MySQL*
  25619. error functions:
  25620.  
  25621.      mysql_query(&mysql,"SELECT * FROM some_table");
  25622.      result = mysql_use_result(&mysql);
  25623.      while((row = mysql_fetch_row(result)))
  25624.      {
  25625.          // do something with data
  25626.      }
  25627.      if(mysql_errno(&mysql))  // mysql_fetch_row() failed due to an error
  25628.      {
  25629.          fprintf(stderr, "Error: %s\n", mysql_error(&mysql));
  25630.      }
  25631.  
  25632. `mysql_errno()'
  25633. ---------------
  25634.  
  25635. `unsigned int mysql_errno(MYSQL *mysql)'
  25636.  
  25637. Description
  25638. ...........
  25639.  
  25640. For the connection specified by `mysql', `mysql_errno()' returns the
  25641. error code for the most recently invoked API function that can succeed
  25642. or fail.  A return value of zero means that no error occurred. Client
  25643. error message numbers are listed in the *MySQL* `errmsg.h' header file.
  25644. Server error message numbers are listed in `mysqld_error.h'
  25645.  
  25646. Return values:
  25647. ..............
  25648.  
  25649. An error code value. Zero if no error occurred.
  25650.  
  25651. Errors
  25652. ......
  25653.  
  25654. None.
  25655.  
  25656. `mysql_error()'
  25657. ---------------
  25658.  
  25659. `char *mysql_error(MYSQL *mysql)'
  25660.  
  25661. Description
  25662. ...........
  25663.  
  25664. For the connection specified by `mysql', `mysql_error()' returns the
  25665. error message for the most recently invoked API function that can
  25666. succeed or fail.  An empty string (`""') is returned if no error
  25667. occurred.  This means the following two tests are equivalent:
  25668.  
  25669.      if(mysql_errno(&mysql))
  25670.      {
  25671.          // an error occurred
  25672.      }
  25673.      
  25674.      if(mysql_error(&mysql)[0] != '\0')
  25675.      {
  25676.          // an error occurred
  25677.      }
  25678.  
  25679. The language of the client error messages may be changed by recompiling
  25680. the *MySQL* client library. Currently you can choose error messages in
  25681. several different languages.  *Note Languages::.
  25682.  
  25683. Return values
  25684. .............
  25685.  
  25686. A character string that describes the error.  An empty string if no
  25687. error occurred.
  25688.  
  25689. Errors
  25690. ......
  25691.  
  25692. None.
  25693.  
  25694. `mysql_escape_string()'
  25695. -----------------------
  25696.  
  25697. You should use `mysql_real_escape_string()' instead!
  25698.  
  25699. This is identical to `mysql_real_escape_string()' except that it takes
  25700. the connection as the first argument. `mysql_real_escape_string()' will
  25701. escape the string according to the current character set while
  25702. `mysql_escape_string()' does not respect the current charset setting.
  25703.  
  25704. `mysql_fetch_field()'
  25705. ---------------------
  25706.  
  25707. `MYSQL_FIELD *mysql_fetch_field(MYSQL_RES *result)'
  25708.  
  25709. Description
  25710. ...........
  25711.  
  25712. Returns the definition of one column of a result set as a `MYSQL_FIELD'
  25713. structure. Call this function repeatedly to retrieve information about
  25714. all columns in the result set.  `mysql_fetch_field()' returns `NULL'
  25715. when no more fields are left.
  25716.  
  25717. `mysql_fetch_field()' is reset to return information about the first
  25718. field each time you execute a new `SELECT' query.  The field returned by
  25719. `mysql_fetch_field()' is also affected by calls to `mysql_field_seek()'.
  25720.  
  25721. If you've called `mysql_query()' to perform a `SELECT' on a table but
  25722. have not called `mysql_store_result()', *MySQL* returns the default
  25723. blob length (8K bytes) if you call `mysql_fetch_field()' to ask for the
  25724. length of a `BLOB' field.  (The 8K size is chosen because *MySQL*
  25725. doesn't know the maximum length for the `BLOB'. This should be made
  25726. configurable sometime.) Once you've retrieved the result set,
  25727. `field->max_length' contains the length of the largest value for this
  25728. column in the specific query.
  25729.  
  25730. Return values
  25731. .............
  25732.  
  25733. The `MYSQL_FIELD' structure for the current column. `NULL' if no
  25734. columns are left.
  25735.  
  25736. Errors
  25737. ......
  25738.  
  25739. None.
  25740.  
  25741. Example
  25742. .......
  25743.  
  25744.      MYSQL_FIELD *field;
  25745.      
  25746.      while((field = mysql_fetch_field(result)))
  25747.      {
  25748.          printf("field name %s\n", field->name);
  25749.      }
  25750.  
  25751. `mysql_fetch_fields()'
  25752. ----------------------
  25753.  
  25754. `MYSQL_FIELD *mysql_fetch_fields(MYSQL_RES *result)'
  25755.  
  25756. Description
  25757. ...........
  25758.  
  25759. Returns an array of all `MYSQL_FIELD' structures for a result set.
  25760. Each structure provides the field definition for one column of the
  25761. result set.
  25762.  
  25763. Return values
  25764. .............
  25765.  
  25766. An array of `MYSQL_FIELD' structures for all columns of a result set.
  25767.  
  25768. Errors
  25769. ......
  25770.  
  25771. None.
  25772.  
  25773. Example
  25774. .......
  25775.  
  25776.      unsigned int num_fields;
  25777.      unsigned int i;
  25778.      MYSQL_FIELD *fields;
  25779.      
  25780.      num_fields = mysql_num_fields(result);
  25781.      fields = mysql_fetch_fields(result);
  25782.      for(i = 0; i < num_fields; i++)
  25783.      {
  25784.         printf("Field %u is %s\n", i, fields[i].name);
  25785.      }
  25786.  
  25787. `mysql_fetch_field_direct()'
  25788. ----------------------------
  25789.  
  25790. `MYSQL_FIELD *mysql_fetch_field_direct(MYSQL_RES *result, unsigned int
  25791. fieldnr)'
  25792.  
  25793. Description
  25794. ...........
  25795.  
  25796. Given a field number `fieldnr' for a column within a result set, returns
  25797. that column's field definition as a `MYSQL_FIELD' structure. You may use
  25798. this function to retrieve the definition for an arbitrary column.  The
  25799. value of `fieldnr' should be in the range from 0 to
  25800. `mysql_num_fields(result)-1'.
  25801.  
  25802. Return values
  25803. .............
  25804.  
  25805. The `MYSQL_FIELD' structure for the specified column.
  25806.  
  25807. Errors
  25808. ......
  25809.  
  25810. None.
  25811.  
  25812. Example
  25813. .......
  25814.  
  25815.      unsigned int num_fields;
  25816.      unsigned int i;
  25817.      MYSQL_FIELD *field;
  25818.      
  25819.      num_fields = mysql_num_fields(result);
  25820.      for(i = 0; i < num_fields; i++)
  25821.      {
  25822.          field = mysql_fetch_field_direct(result, i);
  25823.          printf("Field %u is %s\n", i, field->name);
  25824.      }
  25825.  
  25826. `mysql_fetch_lengths()'
  25827. -----------------------
  25828.  
  25829. `unsigned long *mysql_fetch_lengths(MYSQL_RES *result)'
  25830.  
  25831. Description
  25832. ...........
  25833.  
  25834. Returns the lengths of the columns of the current row within a result
  25835. set.  If you plan to copy field values, this length information is also
  25836. useful for optimization, because you can avoid calling `strlen()'.  In
  25837. addition, if the result set contains binary data, you _must_ use this
  25838. function to determine the size of the data, because `strlen()' returns
  25839. incorrect results for any field containing null characters.
  25840.  
  25841. The length for empty columns and for columns containing `NULL' values is
  25842. zero.  To see how to distinguish these two cases, see the description
  25843. for `mysql_fetch_row()'.
  25844.  
  25845. Return values
  25846. .............
  25847.  
  25848. An array of unsigned long integers representing the size of each column
  25849. (not including any terminating null characters).  `NULL' if an error
  25850. occurred.
  25851.  
  25852. Errors
  25853. ......
  25854.  
  25855. `mysql_fetch_lengths()' is valid only for the current row of the result
  25856. set.  It returns `NULL' if you call it before calling
  25857. `mysql_fetch_row()' or after retrieving all rows in the result.
  25858.  
  25859. Example
  25860. .......
  25861.  
  25862.      MYSQL_ROW row;
  25863.      unsigned long *lengths;
  25864.      unsigned int num_fields;
  25865.      unsigned int i;
  25866.      
  25867.      row = mysql_fetch_row(result);
  25868.      if (row)
  25869.      {
  25870.          num_fields = mysql_num_fields(result);
  25871.          lengths = mysql_fetch_lengths(result);
  25872.          for(i = 0; i < num_fields; i++)
  25873.          {
  25874.               printf("Column %u is %lu bytes in length.\n", i, lengths[i]);
  25875.          }
  25876.      }
  25877.  
  25878. `mysql_fetch_row()'
  25879. -------------------
  25880.  
  25881. `MYSQL_ROW mysql_fetch_row(MYSQL_RES *result)'
  25882.  
  25883. Description
  25884. ...........
  25885.  
  25886. Retrieves the next row of a result set. When used after
  25887. `mysql_store_result()', `mysql_fetch_row()' returns `NULL' when there
  25888. are no more rows to retrieve.  When used after `mysql_use_result()',
  25889. `mysql_fetch_row()' returns `NULL' when there are no more rows to
  25890. retrieve or if an error occurred.
  25891.  
  25892. The number of values in the row is given by `mysql_num_fields(result)'.
  25893. If `row' holds the return value from a call to `mysql_fetch_row()',
  25894. pointers to the values are accessed as `row[0]' to
  25895. `row[mysql_num_fields(result)-1]'.  `NULL' values in the row are
  25896. indicated by `NULL' pointers.
  25897.  
  25898. The lengths of the field values in the row may be obtained by calling
  25899. `mysql_fetch_lengths()'.  Empty fields and fields containing `NULL'
  25900. both have length 0; you can distinguish these by checking the pointer
  25901. for the field value.  If the pointer is `NULL', the field is `NULL';
  25902. otherwise the field is empty.
  25903.  
  25904. Return values
  25905. .............
  25906.  
  25907. A `MYSQL_ROW' structure for the next row.  `NULL' if there are no more
  25908. rows to retrieve or if an error occurred.
  25909.  
  25910. Errors
  25911. ......
  25912.  
  25913. `CR_SERVER_LOST'
  25914.      The connection to the server was lost during the query.
  25915.  
  25916. `CR_UNKNOWN_ERROR'
  25917.      An unknown error occurred.
  25918.  
  25919. Example
  25920. .......
  25921.  
  25922.      MYSQL_ROW row;
  25923.      unsigned int num_fields;
  25924.      unsigned int i;
  25925.      
  25926.      num_fields = mysql_num_fields(result);
  25927.      while ((row = mysql_fetch_row(result)))
  25928.      {
  25929.         unsigned long *lengths;
  25930.         lengths = mysql_fetch_lengths(result);
  25931.         for(i = 0; i < num_fields; i++)
  25932.         {
  25933.             printf("[%.*s] ", (int) lengths[i], row[i] ? row[i] : "NULL");
  25934.         }
  25935.         printf("\n");
  25936.      }
  25937.  
  25938. `mysql_field_count()'
  25939. ---------------------
  25940.  
  25941. `unsigned int mysql_field_count(MYSQL *mysql)'
  25942.  
  25943. If you are using a version of *MySQL* earlier than 3.22.24, you should
  25944. use `unsigned int mysql_num_fields(MYSQL *mysql)' instead.
  25945.  
  25946. Description
  25947. ...........
  25948.  
  25949. Returns the number of columns for the most recent query on the
  25950. connection.
  25951.  
  25952. The normal use of this function is when `mysql_store_result()' returned
  25953. `NULL' (and thus you have no result set pointer).  In this case, you
  25954. can call `mysql_field_count()' to determine whether or not
  25955. `mysql_store_result()' should have produced a non-empty result.  This
  25956. allows the client program to take proper action without knowing whether
  25957. or not the query was a `SELECT' (or `SELECT'-like) statement.  The
  25958. example shown below illustrates how this may be done.
  25959.  
  25960. *Note `NULL mysql_store_result()': NULL mysql_store_result.
  25961.  
  25962. Return values
  25963. .............
  25964.  
  25965. An unsigned integer representing the number of fields in a result set.
  25966.  
  25967. Errors
  25968. ......
  25969.  
  25970. None.
  25971.  
  25972. Example
  25973. .......
  25974.  
  25975.      MYSQL_RES *result;
  25976.      unsigned int num_fields;
  25977.      unsigned int num_rows;
  25978.      
  25979.      if (mysql_query(&mysql,query_string))
  25980.      {
  25981.          // error
  25982.      }
  25983.      else // query succeeded, process any data returned by it
  25984.      {
  25985.          result = mysql_store_result(&mysql);
  25986.          if (result)  // there are rows
  25987.          {
  25988.              num_fields = mysql_num_fields(result);
  25989.              // retrieve rows, then call mysql_free_result(result)
  25990.          }
  25991.          else  // mysql_store_result() returned nothing; should it have?
  25992.          {
  25993.              if(mysql_field_count(&mysql) == 0)
  25994.              {
  25995.                  // query does not return data
  25996.                  // (it was not a SELECT)
  25997.                  num_rows = mysql_affected_rows(&mysql);
  25998.              }
  25999.              else // mysql_store_result() should have returned data
  26000.              {
  26001.                  fprintf(stderr, "Error: %s\n", mysql_error(&mysql));
  26002.              }
  26003.          }
  26004.      }
  26005.  
  26006. An alternative is to replace the `mysql_field_count(&mysql)' call with
  26007. `mysql_errno(&mysql)'.  In this case, you are checking directly for an
  26008. error from `mysql_store_result()' rather than inferring from the value
  26009. of `mysql_field_count()' whether or not the statement was a `SELECT'.
  26010.  
  26011. `mysql_field_seek()'
  26012. --------------------
  26013.  
  26014. `MYSQL_FIELD_OFFSET mysql_field_seek(MYSQL_RES *result,
  26015. MYSQL_FIELD_OFFSET offset)'
  26016.  
  26017. Description
  26018. ...........
  26019.  
  26020. Sets the field cursor to the given offset.   The next call to
  26021. `mysql_fetch_field()' will retrieve the field definition of the column
  26022. associated with that offset.
  26023.  
  26024. To seek to the beginning of a row, pass an `offset' value of zero.
  26025.  
  26026. Return values
  26027. .............
  26028.  
  26029. The previous value of the field cursor.
  26030.  
  26031. Errors
  26032. ......
  26033.  
  26034. None.
  26035.  
  26036. `mysql_field_tell()'
  26037. --------------------
  26038.  
  26039. `MYSQL_FIELD_OFFSET mysql_field_tell(MYSQL_RES *result)'
  26040.  
  26041. Description
  26042. ...........
  26043.  
  26044. Returns the position of the field cursor used for the last
  26045. `mysql_fetch_field()'. This value can be used as an argument to
  26046. `mysql_field_seek()'.
  26047.  
  26048. Return values
  26049. .............
  26050.  
  26051. The current offset of the field cursor.
  26052.  
  26053. Errors
  26054. ......
  26055.  
  26056. None.
  26057.  
  26058. `mysql_free_result()'
  26059. ---------------------
  26060.  
  26061. `void mysql_free_result(MYSQL_RES *result)'
  26062.  
  26063. Description
  26064. ...........
  26065.  
  26066. Frees the memory allocated for a result set by `mysql_store_result()',
  26067. `mysql_use_result()', `mysql_list_dbs()', etc.  When you are done with
  26068. a result set, you must free the memory it uses by calling
  26069. `mysql_free_result()'.
  26070.  
  26071. Return values
  26072. .............
  26073.  
  26074. None.
  26075.  
  26076. Errors
  26077. ......
  26078.  
  26079. None.
  26080.  
  26081. `mysql_get_client_info()'
  26082. -------------------------
  26083.  
  26084. `char *mysql_get_client_info(void)'
  26085.  
  26086. Description
  26087. ...........
  26088.  
  26089. Returns a string that represents the client library version.
  26090.  
  26091. Return values
  26092. .............
  26093.  
  26094. A character string that represents the *MySQL* client library version.
  26095.  
  26096. Errors
  26097. ......
  26098.  
  26099. None.
  26100.  
  26101. `mysql_get_host_info()'
  26102. -----------------------
  26103.  
  26104. `char *mysql_get_host_info(MYSQL *mysql)'
  26105.  
  26106. Description
  26107. ...........
  26108.  
  26109. Returns a string describing the type of connection in use, including the
  26110. server host name.
  26111.  
  26112. Return values
  26113. .............
  26114.  
  26115. A character string representing the server host name and the connection
  26116. type.
  26117.  
  26118. Errors
  26119. ......
  26120.  
  26121. None.
  26122.  
  26123. `mysql_get_proto_info()'
  26124. ------------------------
  26125.  
  26126. `unsigned int mysql_get_proto_info(MYSQL *mysql)'
  26127.  
  26128. Description
  26129. ...........
  26130.  
  26131. Returns the protocol version used by current connection.
  26132.  
  26133. Return values
  26134. .............
  26135.  
  26136. An unsigned integer representing the protocol version used by the
  26137. current connection.
  26138.  
  26139. Errors
  26140. ......
  26141.  
  26142. None.
  26143.  
  26144. `mysql_get_server_info()'
  26145. -------------------------
  26146.  
  26147. `char *mysql_get_server_info(MYSQL *mysql)'
  26148.  
  26149. Description
  26150. ...........
  26151.  
  26152. Returns a string that represents the server version number.
  26153.  
  26154. Return values
  26155. .............
  26156.  
  26157. A character string that represents the server version number.
  26158.  
  26159. Errors
  26160. ......
  26161.  
  26162. None.
  26163.  
  26164. `mysql_info()'
  26165. --------------
  26166.  
  26167. `char *mysql_info(MYSQL *mysql)'
  26168.  
  26169. Description
  26170. ...........
  26171.  
  26172. Retrieves a string providing information about the most recently
  26173. executed query, but only for the statements listed below.  For other
  26174. statements, `mysql_info()' returns `NULL'.  The format of the string
  26175. varies depending on the type of query, as described below.  The numbers
  26176. are illustrative only; the string will contain values appropriate for
  26177. the query.
  26178.  
  26179. `INSERT INTO ... SELECT ...'
  26180.      String format: `Records: 100 Duplicates: 0 Warnings: 0'
  26181.  
  26182. `INSERT INTO ... VALUES (...),(...),(...)...'
  26183.      String format: `Records: 3  Duplicates: 0  Warnings: 0'
  26184.  
  26185. `LOAD DATA INFILE ...'
  26186.      String format: `Records: 1 Deleted: 0 Skipped: 0 Warnings: 0'
  26187.  
  26188. `ALTER TABLE'
  26189.      String format: `Records: 3 Duplicates: 0 Warnings: 0'
  26190.  
  26191. `UPDATE'
  26192.      String format: `Rows matched: 40 Changed: 40 Warnings: 0'
  26193.  
  26194. Note that `mysql_info()' returns a non-`NULL' value for the `INSERT ...
  26195. VALUES' statement only if multiple value lists are specified in the
  26196. statement.
  26197.  
  26198. Return values
  26199. .............
  26200.  
  26201. A character string representing additional information about the most
  26202. recently executed query.  `NULL' if no information is available for the
  26203. query.
  26204.  
  26205. Errors
  26206. ......
  26207.  
  26208. None.
  26209.  
  26210. `mysql_init()'
  26211. --------------
  26212.  
  26213. `MYSQL *mysql_init(MYSQL *mysql)'
  26214.  
  26215. Description
  26216. ...........
  26217.  
  26218. Allocates or initializes a `MYSQL' object suitable for
  26219. `mysql_real_connect()'.  If `mysql' is a `NULL' pointer, the function
  26220. allocates, initializes and returns a new object.  Otherwise the object
  26221. is initialized and the address of the object is returned.  If
  26222. `mysql_init()' allocates a new object, it will be freed when
  26223. `mysql_close()' is called to close the connection.
  26224.  
  26225. Return values
  26226. .............
  26227.  
  26228. An initialized `MYSQL*' handle.  `NULL' if there was insufficient
  26229. memory to allocate a new object.
  26230.  
  26231. Errors
  26232. ......
  26233.  
  26234. In case of insufficient memory, `NULL' is returned.
  26235.  
  26236. `mysql_insert_id()'
  26237. -------------------
  26238.  
  26239. `my_ulonglong mysql_insert_id(MYSQL *mysql)'
  26240.  
  26241. Description
  26242. ...........
  26243.  
  26244. Returns the ID generated for an `AUTO_INCREMENT' column by the previous
  26245. query.  Use this function after you have performed an `INSERT' query
  26246. into a table that contains an `AUTO_INCREMENT' field.
  26247.  
  26248. Note that `mysql_insert_id()' returns `0' if the previous query does
  26249. not generate an `AUTO_INCREMENT' value.  If you need to save the value
  26250. for later, be sure to call `mysql_insert_id()' immediately after the
  26251. query that generates the value.
  26252.  
  26253. Also note that the value of the SQL `LAST_INSERT_ID()' function always
  26254. contains the most recently generated `AUTO_INCREMENT' value, and is not
  26255. reset between queries because the value of that function is maintained
  26256. in the server.
  26257.  
  26258. Return values
  26259. .............
  26260.  
  26261. The value of the `AUTO_INCREMENT' field that was updated by the previous
  26262. query.  Returns zero if there was no previous query on the connection
  26263. or if the query did not update an `AUTO_INCREMENT' value.
  26264.  
  26265. Errors
  26266. ......
  26267.  
  26268. None.
  26269.  
  26270. `mysql_kill()'
  26271. --------------
  26272.  
  26273. `int mysql_kill(MYSQL *mysql, unsigned long pid)'
  26274.  
  26275. Description
  26276. ...........
  26277.  
  26278. Asks the server to kill the thread specified by `pid'.
  26279.  
  26280. Return values
  26281. .............
  26282.  
  26283. Zero for success.  Non-zero if an error occurred.
  26284.  
  26285. Errors
  26286. ......
  26287.  
  26288. `CR_COMMANDS_OUT_OF_SYNC'
  26289.      Commands were executed in an improper order.
  26290.  
  26291. `CR_SERVER_GONE_ERROR'
  26292.      The *MySQL* server has gone away.
  26293.  
  26294. `CR_SERVER_LOST'
  26295.      The connection to the server was lost during the query.
  26296.  
  26297. `CR_UNKNOWN_ERROR'
  26298.      An unknown error occurred.
  26299.  
  26300. `mysql_list_dbs()'
  26301. ------------------
  26302.  
  26303. `MYSQL_RES *mysql_list_dbs(MYSQL *mysql, const char *wild)'
  26304.  
  26305. Description
  26306. ...........
  26307.  
  26308. Returns a result set consisting of database names on the server that
  26309. match the simple regular expression specified by the `wild' parameter.
  26310. `wild' may contain the wildcard characters `%' or `_', or may be a
  26311. `NULL' pointer to match all databases.  Calling `mysql_list_dbs()' is
  26312. similar to executing the query `SHOW databases [LIKE wild]'.
  26313.  
  26314. You must free the result set with `mysql_free_result()'.
  26315.  
  26316. Return values
  26317. .............
  26318.  
  26319. A `MYSQL_RES' result set for success.  `NULL' if an error occurred.
  26320.  
  26321. Errors
  26322. ......
  26323.  
  26324. `CR_COMMANDS_OUT_OF_SYNC'
  26325.      Commands were executed in an improper order.
  26326.  
  26327. `CR_OUT_OF_MEMORY'
  26328.      Out of memory.
  26329.  
  26330. `CR_SERVER_GONE_ERROR'
  26331.      The *MySQL* server has gone away.
  26332.  
  26333. `CR_SERVER_LOST'
  26334.      The connection to the server was lost during the query.
  26335.  
  26336. `CR_UNKNOWN_ERROR'
  26337.      An unknown error occurred.
  26338.  
  26339. `mysql_list_fields()'
  26340. ---------------------
  26341.  
  26342. `MYSQL_RES *mysql_list_fields(MYSQL *mysql, const char *table, const
  26343. char *wild)'
  26344.  
  26345. Description
  26346. ...........
  26347.  
  26348. Returns a result set consisting of field names in the given table that
  26349. match the simple regular expression specified by the `wild' parameter.
  26350. `wild' may contain the wildcard characters `%' or `_', or may be a
  26351. `NULL' pointer to match all fields.  Calling `mysql_list_fields()' is
  26352. similar to executing the query `SHOW COLUMNS FROM tbl_name [LIKE wild]'.
  26353.  
  26354. Note that it's recommended that you use `SHOW COLUMNS FROM tbl_name'
  26355. instead of `mysql_list_fields()'.
  26356.  
  26357. You must free the result set with `mysql_free_result()'.
  26358.  
  26359. Return values
  26360. .............
  26361.  
  26362. A `MYSQL_RES' result set for success.  `NULL' if an error occurred.
  26363.  
  26364. Errors
  26365. ......
  26366.  
  26367. `CR_COMMANDS_OUT_OF_SYNC'
  26368.      Commands were executed in an improper order.
  26369.  
  26370. `CR_SERVER_GONE_ERROR'
  26371.      The *MySQL* server has gone away.
  26372.  
  26373. `CR_SERVER_LOST'
  26374.      The connection to the server was lost during the query.
  26375.  
  26376. `CR_UNKNOWN_ERROR'
  26377.      An unknown error occurred.
  26378.  
  26379. `mysql_list_processes()'
  26380. ------------------------
  26381.  
  26382. `MYSQL_RES *mysql_list_processes(MYSQL *mysql)'
  26383.  
  26384. Description
  26385. ...........
  26386.  
  26387. Returns a result set describing the current server threads.  This is
  26388. the same kind of information as that reported by `mysqladmin
  26389. processlist' or a `SHOW PROCESSLIST' query.
  26390.  
  26391. You must free the result set with `mysql_free_result()'.
  26392.  
  26393. Return values
  26394. .............
  26395.  
  26396. A `MYSQL_RES' result set for success.  `NULL' if an error occurred.
  26397.  
  26398. Errors
  26399. ......
  26400.  
  26401. `CR_COMMANDS_OUT_OF_SYNC'
  26402.      Commands were executed in an improper order.
  26403.  
  26404. `CR_SERVER_GONE_ERROR'
  26405.      The *MySQL* server has gone away.
  26406.  
  26407. `CR_SERVER_LOST'
  26408.      The connection to the server was lost during the query.
  26409.  
  26410. `CR_UNKNOWN_ERROR'
  26411.      An unknown error occurred.
  26412.  
  26413. `mysql_list_tables()'
  26414. ---------------------
  26415.  
  26416. `MYSQL_RES *mysql_list_tables(MYSQL *mysql, const char *wild)'
  26417.  
  26418. Description
  26419. ...........
  26420.  
  26421. Returns a result set consisting of table names in the current database
  26422. that match the simple regular expression specified by the `wild'
  26423. parameter.  `wild' may contain the wildcard characters `%' or `_', or
  26424. may be a `NULL' pointer to match all tables.  Calling
  26425. `mysql_list_tables()' is similar to executing the query `SHOW tables
  26426. [LIKE wild]'.
  26427.  
  26428. You must free the result set with `mysql_free_result()'.
  26429.  
  26430. Return values
  26431. .............
  26432.  
  26433. A `MYSQL_RES' result set for success.  `NULL' if an error occurred.
  26434.  
  26435. Errors
  26436. ......
  26437.  
  26438. `CR_COMMANDS_OUT_OF_SYNC'
  26439.      Commands were executed in an improper order.
  26440.  
  26441. `CR_SERVER_GONE_ERROR'
  26442.      The *MySQL* server has gone away.
  26443.  
  26444. `CR_SERVER_LOST'
  26445.      The connection to the server was lost during the query.
  26446.  
  26447. `CR_UNKNOWN_ERROR'
  26448.      An unknown error occurred.
  26449.  
  26450. `mysql_num_fields()'
  26451. --------------------
  26452.  
  26453. `unsigned int mysql_num_fields(MYSQL_RES *result)'
  26454.  
  26455. or
  26456.  
  26457. `unsigned int mysql_num_fields(MYSQL *mysql)'
  26458.  
  26459. The second form doesn't work on *MySQL* 3.22.24 or newer.  To pass a
  26460. `MYSQL*' argument, you must use `unsigned int mysql_field_count(MYSQL
  26461. *mysql)' instead.
  26462.  
  26463. Description
  26464. ...........
  26465.  
  26466. Returns the number of columns in a result set.
  26467.  
  26468. Note that you can get the number of columns either from a pointer to a
  26469. result set or to a connection handle.  You would use the connection
  26470. handle if `mysql_store_result()' or `mysql_use_result()' returned
  26471. `NULL' (and thus you have no result set pointer).  In this case, you can
  26472. call `mysql_field_count()' to determine whether or not
  26473. `mysql_store_result()' should have produced a non-empty result.  This
  26474. allows the client program to take proper action without knowing whether
  26475. or not the query was a `SELECT' (or `SELECT'-like) statement.  The
  26476. example shown below illustrates how this may be done.
  26477.  
  26478. *Note `NULL mysql_store_result()': NULL mysql_store_result.
  26479.  
  26480. Return values
  26481. .............
  26482.  
  26483. An unsigned integer representing the number of fields in a result set.
  26484.  
  26485. Errors
  26486. ......
  26487.  
  26488. None.
  26489.  
  26490. Example
  26491. .......
  26492.  
  26493.      MYSQL_RES *result;
  26494.      unsigned int num_fields;
  26495.      unsigned int num_rows;
  26496.      
  26497.      if (mysql_query(&mysql,query_string))
  26498.      {
  26499.          // error
  26500.      }
  26501.      else // query succeeded, process any data returned by it
  26502.      {
  26503.          result = mysql_store_result(&mysql);
  26504.          if (result)  // there are rows
  26505.          {
  26506.              num_fields = mysql_num_fields(result);
  26507.              // retrieve rows, then call mysql_free_result(result)
  26508.          }
  26509.          else  // mysql_store_result() returned nothing; should it have?
  26510.          {
  26511.              if (mysql_errno(&mysql))
  26512.          {
  26513.                 fprintf(stderr, "Error: %s\n", mysql_error(&mysql));
  26514.          }
  26515.              else if (mysql_field_count(&mysql) == 0)
  26516.              {
  26517.                  // query does not return data
  26518.                  // (it was not a SELECT)
  26519.                  num_rows = mysql_affected_rows(&mysql);
  26520.              }
  26521.          }
  26522.      }
  26523.  
  26524. An alternative (if you KNOW that your query should have returned a
  26525. result set) is to replace the `mysql_errno(&mysql)' call with a check if
  26526. `mysql_field_count(&mysql)' is = 0.  This will only happen if something
  26527. went wrong.
  26528.  
  26529. `mysql_num_rows()'
  26530. ------------------
  26531.  
  26532. `my_ulonglong mysql_num_rows(MYSQL_RES *result)'
  26533.  
  26534. Description
  26535. ...........
  26536.  
  26537. Returns the number of rows in the result set.
  26538.  
  26539. The use of `mysql_num_rows()' depends on whether you use
  26540. `mysql_store_result()' or `mysql_use_result()' to return the result
  26541. set.  If you use `mysql_store_result()', `mysql_num_rows()' may be
  26542. called immediately.  If you use `mysql_use_result()',
  26543. `mysql_num_rows()' will not return the correct value until all the rows
  26544. in the result set have been retrieved.
  26545.  
  26546. Return values
  26547. .............
  26548.  
  26549. The number of rows in the result set.
  26550.  
  26551. Errors
  26552. ......
  26553.  
  26554. None.
  26555.  
  26556. `mysql_options()'
  26557. -----------------
  26558.  
  26559. `int mysql_options(MYSQL *mysql, enum mysql_option option, const char
  26560. *arg)'
  26561.  
  26562. Description
  26563. ...........
  26564.  
  26565. Can be used to set extra connect options and affect behavior for a
  26566. connection.  This function may be called multiple times to set several
  26567. options.
  26568.  
  26569. `mysql_options()' should be called after `mysql_init()' and before
  26570. `mysql_connect()' or `mysql_real_connect()'.
  26571.  
  26572. The `option' argument is the option that you want to set; the `arg'
  26573. argument is the value for the option. If the option is an integer, then
  26574. `arg' should point to the value of the integer.
  26575.  
  26576. Possible options values:
  26577.  
  26578. *Option*           *Argument type*    *Function*
  26579. `MYSQL_OPT_CONNECT_TIMEOUT'`unsigned int *'   Connect timeout in seconds.
  26580. `MYSQL_OPT_COMPRESS'Not used           Use the compressed client/server
  26581.                                       protocol.
  26582. `MYSQL_OPT_NAMED_PIPE'Not used           Use named pipes to connect to a
  26583.                                       *MySQL* server on NT.
  26584. `MYSQL_INIT_COMMAND'`char *'           Command to execute when connecting
  26585.                                       to the *MySQL* server. Will
  26586.                                       automatically be re-executed when
  26587.                                       reconnecting.
  26588. `MYSQL_READ_DEFAULT_FILE'`char *'           Read options from the named option
  26589.                                       file instead of from `my.cnf'.
  26590. `MYSQL_READ_DEFAULT_GROUP'`char *'           Read options from the named group
  26591.                                       from `my.cnf' or the file specified
  26592.                                       with `MYSQL_READ_DEFAULT_FILE'.
  26593.  
  26594. Note that the group `client' is always read if you use
  26595. `MYSQL_READ_DEFAULT_FILE' or `MYSQL_READ_DEFAULT_GROUP'.
  26596.  
  26597. The specified group in the option file may contain the following
  26598. options:
  26599.  
  26600. `compress'             Use the compressed client/server protocol.
  26601. `database'             Connect to this database if no database was
  26602.                        specified in the connect command.
  26603. `debug'                Debug options.
  26604. `host'                 Default host name.
  26605. `init-command'         Command to execute when connecting to *MySQL*
  26606.                        server. Will automatically be re-executed when
  26607.                        reconnecting.
  26608. `password'             Default password.
  26609. `pipe'                 Use named pipes to connect to a *MySQL* server on
  26610.                        NT.
  26611. `port'                 Default port number.
  26612. `return-found-rows'    Tell `mysql_info()' to return found rows instead
  26613.                        of updated rows when using `UPDATE'.
  26614. `socket'               Default socket number.
  26615. `timeout'              Connect timeout in seconds.
  26616. `user'                 Default user.
  26617.  
  26618. For more information about option files, see *Note Option files::.
  26619.  
  26620. Return values
  26621. .............
  26622.  
  26623. Zero for success.  Non-zero if you used an unknown option.
  26624.  
  26625. Example
  26626. .......
  26627.  
  26628.      MYSQL mysql;
  26629.      
  26630.      mysql_init(&mysql);
  26631.      mysql_options(&mysql,MYSQL_OPT_COMPRESS,0);
  26632.      mysql_options(&mysql,MYSQL_READ_DEFAULT_GROUP,"odbc");
  26633.      if (!mysql_real_connect(&mysql,"host","user","passwd","database",0,NULL,0))
  26634.      {
  26635.          fprintf(stderr, "Failed to connect to database: Error: %s\n",
  26636.                mysql_error(&mysql));
  26637.      }
  26638.  
  26639. The above requests the client to use the compressed client/server
  26640. protocol and read the additional options from the `odbc' section in the
  26641. `my.cnf' file.
  26642.  
  26643. `mysql_ping()'
  26644. --------------
  26645.  
  26646. `int mysql_ping(MYSQL *mysql)'
  26647.  
  26648. Description
  26649. ...........
  26650.  
  26651. Checks whether or not the connection to the server is working. If it
  26652. has gone down, an automatic reconnection is attempted.
  26653.  
  26654. This function can be used by clients that remain idle for a long while,
  26655. to check whether or not the server has closed the connection and
  26656. reconnect if necessary.
  26657.  
  26658. Return values
  26659. .............
  26660.  
  26661. Zero if the server is alive. Non-zero if an error occurred.
  26662.  
  26663. Errors
  26664. ......
  26665.  
  26666. `CR_COMMANDS_OUT_OF_SYNC'
  26667.      Commands were executed in an improper order.
  26668.  
  26669. `CR_SERVER_GONE_ERROR'
  26670.      The *MySQL* server has gone away.
  26671.  
  26672. `CR_UNKNOWN_ERROR'
  26673.      An unknown error occurred.
  26674.  
  26675. `mysql_query()'
  26676. ---------------
  26677.  
  26678. `int mysql_query(MYSQL *mysql, const char *query)'
  26679.  
  26680. Description
  26681. ...........
  26682.  
  26683. Executes the SQL query pointed to by the null-terminated string `query'.
  26684. The query must consist of a single SQL statement.  You should not add a
  26685. terminating semicolon (`;') or `\g' to the statement.
  26686.  
  26687. `mysql_query()' cannot be used for queries that contain binary data; you
  26688. should use `mysql_real_query()' instead.  (Binary data may contain the
  26689. `\0' character, which `mysql_query()' interprets as the end of the
  26690. query string.)
  26691.  
  26692. If you want to know if the query should return a result set or not, you
  26693. can use `mysql_field_count()' to check for this.  *Note
  26694. `mysql_field_count': mysql_field_count.
  26695.  
  26696. Return values
  26697. .............
  26698.  
  26699. Zero if the query was successful. Non-zero if an error occurred.
  26700.  
  26701. Errors
  26702. ......
  26703.  
  26704. `CR_COMMANDS_OUT_OF_SYNC'
  26705.      Commands were executed in an improper order.
  26706.  
  26707. `CR_SERVER_GONE_ERROR'
  26708.      The *MySQL* server has gone away.
  26709.  
  26710. `CR_SERVER_LOST'
  26711.      The connection to the server was lost during the query.
  26712.  
  26713. `CR_UNKNOWN_ERROR'
  26714.      An unknown error occurred.
  26715.  
  26716. `mysql_real_connect()'
  26717. ----------------------
  26718.  
  26719. `MYSQL *mysql_real_connect(MYSQL *mysql, const char *host,
  26720.             const char *user, const char *passwd, const char *db,
  26721.                     unsigned int port, const char *unix_socket,
  26722.                   unsigned int client_flag)'
  26723.  
  26724. Description
  26725. ...........
  26726.  
  26727. `mysql_real_connect()' attempts to establish a connection to a *MySQL*
  26728. database engine running on `host'.  `mysql_real_connect()' must
  26729. complete successfully before you can execute any of the other API
  26730. functions, with the exception of `mysql_get_client_info()'.
  26731.  
  26732. The parameters are specified as follows:
  26733.  
  26734.    * The first parameter should be the address of an existing `MYSQL'
  26735.      structure.  Before calling `mysql_real_connect()' you must call
  26736.      `mysql_init()' to initialize the `MYSQL' structure.  See the
  26737.      example below.
  26738.  
  26739.    * The value of `host' may be either a hostname or an IP address.  If
  26740.      `host' is `NULL' or the string `"localhost"', a connection to the
  26741.      local host is assumed. If the OS supports sockets (Unix) or named
  26742.      pipes (Win32), they are used instead of TCP/IP to connect to the
  26743.      server.
  26744.  
  26745.    * The `user' parameter contains the user's *MySQL* login ID.  If
  26746.      `user' is `NULL', the current user is assumed.  Under Unix, this is
  26747.      the current login name.  Under Windows ODBC, the current user name
  26748.      must be specified explicitly.  *Note ODBC administrator::.
  26749.  
  26750.    * The `passwd' parameter contains the password for `user'.  If
  26751.      `passwd' is `NULL', only entries in the `user' table for the user
  26752.      that have a blank password field will be checked for a match. This
  26753.      allows the database administrator to set up the *MySQL* privilege
  26754.      system in such a way that users get different privileges depending
  26755.      on whether or not they have specified a password.
  26756.  
  26757.      Note: Do not attempt to encrypt the password before calling
  26758.      `mysql_real_connect()'; password encryption is handled
  26759.      automatically by the client API.
  26760.  
  26761.    * `db' is the database name.  If `db' is not `NULL', the connection
  26762.      will set the default database to this value.
  26763.  
  26764.    * If `port' is not 0, the value will be used as the port number for
  26765.      the TCP/IP connection.  Note that the `host' parameter determines
  26766.      the type of the connection.
  26767.  
  26768.    * If `unix_socket' is not `NULL', the string specifies the socket or
  26769.      named pipe that should be used.  Note that the `host' parameter
  26770.      determines the type of the connection.
  26771.  
  26772.    * The value of `client_flag' is usually 0, but can be set to a
  26773.      combination of the following flags in very special circumstances:
  26774.  
  26775.      *Flag name*       *Flag meaning*
  26776.      `CLIENT_FOUND_ROWS'Return the number of found (matched) rows, not
  26777.                        the number of affected rows.
  26778.      `CLIENT_NO_SCHEMA'Don't allow the `db_name.tbl_name.col_name'
  26779.                        syntax.  This is for ODBC; It causes the
  26780.                        parser to generate an error if you use that
  26781.                        syntax, which is useful for trapping bugs in
  26782.                        some ODBC programs.
  26783.      `CLIENT_COMPRESS' Use compression protocol.
  26784.      `CLIENT_ODBC'     The client is an ODBC client. This changes
  26785.                        `mysqld' to be more ODBC-friendly.
  26786.  
  26787. Return values
  26788. .............
  26789.  
  26790. A `MYSQL*' connection handle if the connection was successful, `NULL'
  26791. if the connection was unsuccessful.  For a successful connection, the
  26792. return value is the same as the value of the first parameter, unless you
  26793. pass `NULL' for that parameter.
  26794.  
  26795. Errors
  26796. ......
  26797.  
  26798. `CR_CONN_HOST_ERROR'
  26799.      Failed to connect to the *MySQL* server.
  26800.  
  26801. `CR_CONNECTION_ERROR'
  26802.      Failed to connect to the local *MySQL* server.
  26803.  
  26804. `CR_IPSOCK_ERROR'
  26805.      Failed to create an IP socket.
  26806.  
  26807. `CR_OUT_OF_MEMORY'
  26808.      Out of memory.
  26809.  
  26810. `CR_SOCKET_CREATE_ERROR'
  26811.      Failed to create a Unix socket.
  26812.  
  26813. `CR_UNKNOWN_HOST'
  26814.      Failed to find the IP address for the hostname.
  26815.  
  26816. `CR_VERSION_ERROR'
  26817.      A protocol mismatch resulted from attempting to connect to a
  26818.      server with a client library that uses a different protocol
  26819.      version.  This can happen if you use a very old client library to
  26820.      connect to a new server that wasn't started with the
  26821.      `--old-protocol' option.
  26822.  
  26823. `CR_NAMEDPIPEOPEN_ERROR;'
  26824.      Failed to create a named pipe on Win32.
  26825.  
  26826. `CR_NAMEDPIPEWAIT_ERROR;'
  26827.      Failed to wait for a named pipe on Win32.
  26828.  
  26829. `CR_NAMEDPIPESETSTATE_ERROR;'
  26830.      Failed to get a pipe handler on Win32.
  26831.  
  26832. Example
  26833. .......
  26834.  
  26835.      MYSQL mysql;
  26836.      
  26837.      mysql_init(&mysql);
  26838.      mysql_options(&mysql,MYSQL_READ_DEFAULT_GROUP,"your_prog_name");
  26839.      if (!mysql_real_connect(&mysql,"host","user","passwd","database",0,NULL,0))
  26840.      {
  26841.          fprintf(stderr, "Failed to connect to database: Error: %s\n",
  26842.                mysql_error(&mysql));
  26843.      }
  26844.  
  26845. By using `mysql_options()' the *MySQL* library will read the `[client]'
  26846. and `your_prog_name' sections in the `my.cnf' file which will ensure
  26847. that your program will work, even if someone has set up *MySQL* in some
  26848. non-standard way.
  26849.  
  26850. Note that upon connection, `mysql_real_connect()' sets the `reconnect'
  26851. flag (part of the MYSQL structure) to a value of `1'. This flag
  26852. indicates, in the event that a query cannot be performed because of a
  26853. lost connection, to try reconnecting to the server before giving up.
  26854.  
  26855. `mysql_real_escape_string()'
  26856. ----------------------------
  26857.  
  26858. `unsigned int mysql_real_escape_string(MYSQL *mysql, char *to, const
  26859. char *from, unsigned int length)'
  26860.  
  26861. Description
  26862. ...........
  26863.  
  26864. Encodes the string in `from' to an escaped SQL string, taking into
  26865. account the current charset of the connection, that can be sent to the
  26866. server in a SQL statement, places the result in `to', and adds a
  26867. terminating null byte.  Characters encoded are `NUL' (ASCII 0), `\n',
  26868. `\r', `\', `'', `"' and Control-Z (*note Literals::).
  26869.  
  26870. The string pointed to by `from' must be `length' bytes long.  You must
  26871. allocate the `to' buffer to be at least `length*2+1' bytes long.  (In
  26872. the worse case, each character may need to be encoded as using two
  26873. bytes, and you need room for the terminating null byte.)  When
  26874. `mysql_escape_string()' returns, the contents of `to' will be a
  26875. null-terminated string.  The return value is the length of the encoded
  26876. string, not including the terminating null character.
  26877.  
  26878. Example
  26879. .......
  26880.  
  26881.      char query[1000],*end;
  26882.      
  26883.      end = strmov(query,"INSERT INTO test_table values(");
  26884.      *end++ = '\'';
  26885.      end += mysql_real_escape_string(&mysql, end,"What's this",11);
  26886.      *end++ = '\'';
  26887.      *end++ = ',';
  26888.      *end++ = '\'';
  26889.      end += mysql_real_escape_string(&mysql, end,"binary data: \0\r\n",16);
  26890.      *end++ = '\'';
  26891.      *end++ = ')';
  26892.      
  26893.      if (mysql_real_query(&mysql,query,(unsigned int) (end - query)))
  26894.      {
  26895.         fprintf(stderr, "Failed to insert row, Error: %s\n",
  26896.                 mysql_error(&mysql));
  26897.      }
  26898.  
  26899. The `strmov()' function used in the example is included in the
  26900. `mysqlclient' library and works like `strcpy()' but returns a pointer
  26901. to the terminating null of the first parameter.
  26902.  
  26903. Return values
  26904. .............
  26905.  
  26906. The length of the value placed into `to', not including the terminating
  26907. null character.
  26908.  
  26909. Errors
  26910. ......
  26911.  
  26912. None.
  26913.  
  26914. `mysql_real_query()'
  26915. --------------------
  26916.  
  26917. `int mysql_real_query(MYSQL *mysql, const char *query, unsigned int
  26918. length)'
  26919.  
  26920. Description
  26921. ...........
  26922.  
  26923. Executes the SQL query pointed to by `query', which should be a string
  26924. `length' bytes long.  The query must consist of a single SQL statement.
  26925. You should not add a terminating semicolon (`;') or `\g' to the
  26926. statement.
  26927.  
  26928. You _must_ use `mysql_real_query()' rather than `mysql_query()' for
  26929. queries that contain binary data, because binary data may contain the
  26930. `\0' character.  In addition, `mysql_real_query()' is faster than
  26931. `mysql_query()' because it does not call `strlen()' on the query string.
  26932.  
  26933. If you want to know if the query should return a result set or not, you
  26934. can use `mysql_field_count()' to check for this.  *Note
  26935. `mysql_field_count': mysql_field_count.
  26936.  
  26937. Return values
  26938. .............
  26939.  
  26940. Zero if the query was successful. Non-zero if an error occurred.
  26941.  
  26942. Errors
  26943. ......
  26944.  
  26945. `CR_COMMANDS_OUT_OF_SYNC'
  26946.      Commands were executed in an improper order.
  26947.  
  26948. `CR_SERVER_GONE_ERROR'
  26949.      The *MySQL* server has gone away.
  26950.  
  26951. `CR_SERVER_LOST'
  26952.      The connection to the server was lost during the query.
  26953.  
  26954. `CR_UNKNOWN_ERROR'
  26955.      An unknown error occurred.
  26956.  
  26957. `mysql_reload()'
  26958. ----------------
  26959.  
  26960. `int mysql_reload(MYSQL *mysql)'
  26961.  
  26962. Description
  26963. ...........
  26964.  
  26965. Asks the *MySQL* server to reload the grant tables. The connected user
  26966. must have the *reload* privilege.
  26967.  
  26968. This function is deprecated.  It is preferable to use `mysql_query()'
  26969. to issue a SQL `FLUSH PRIVILEGES' statement instead.
  26970.  
  26971. Return values
  26972. .............
  26973.  
  26974. Zero for success.  Non-zero if an error occurred.
  26975.  
  26976. Errors
  26977. ......
  26978.  
  26979. `CR_COMMANDS_OUT_OF_SYNC'
  26980.      Commands were executed in an improper order.
  26981.  
  26982. `CR_SERVER_GONE_ERROR'
  26983.      The *MySQL* server has gone away.
  26984.  
  26985. `CR_SERVER_LOST'
  26986.      The connection to the server was lost during the query.
  26987.  
  26988. `CR_UNKNOWN_ERROR'
  26989.      An unknown error occurred.
  26990.  
  26991. `mysql_row_seek()'
  26992. ------------------
  26993.  
  26994. `MYSQL_ROW_OFFSET mysql_row_seek(MYSQL_RES *result, MYSQL_ROW_OFFSET
  26995. offset)'
  26996.  
  26997. Description
  26998. ...........
  26999.  
  27000. Sets the row cursor to an arbitrary row in a query result set.  This
  27001. requires that the result set structure contains the entire result of
  27002. the query, so `mysql_row_seek()' may be used in conjunction only with
  27003. `mysql_store_result()', not with `mysql_use_result()'.
  27004.  
  27005. The offset should be a value returned from a call to `mysql_row_tell()'
  27006. or to `mysql_row_seek()'.  This value is not simply a row number; if you
  27007. want to seek to a row within a result set using a row number, use
  27008. `mysql_data_seek()' instead.
  27009.  
  27010. Return values
  27011. .............
  27012.  
  27013. The previous value of the row cursor.  This value may be passed to a
  27014. subsequent call to `mysql_row_seek()'.
  27015.  
  27016. Errors
  27017. ......
  27018.  
  27019. None.
  27020.  
  27021. `mysql_row_tell()'
  27022. ------------------
  27023.  
  27024. `MYSQL_ROW_OFFSET mysql_row_tell(MYSQL_RES *result)'
  27025.  
  27026. Description
  27027. ...........
  27028.  
  27029. Returns the current position of the row cursor for the last
  27030. `mysql_fetch_row()'. This value can be used as an argument to
  27031. `mysql_row_seek()'.
  27032.  
  27033. You should use `mysql_row_tell()' only after `mysql_store_result()',
  27034. not after `mysql_use_result()'.
  27035.  
  27036. Return values
  27037. .............
  27038.  
  27039. The current offset of the row cursor.
  27040.  
  27041. Errors
  27042. ......
  27043.  
  27044. None.
  27045.  
  27046. `mysql_select_db()'
  27047. -------------------
  27048.  
  27049. `int mysql_select_db(MYSQL *mysql, const char *db)'
  27050.  
  27051. Description
  27052. ...........
  27053.  
  27054. Causes the database specified by `db' to become the default (current)
  27055. database on the connection specified by `mysql'.  In subsequent queries,
  27056. this database is the default for table references that do not include an
  27057. explicit database specifier.
  27058.  
  27059. `mysql_select_db()' fails unless the connected user can be authenticated
  27060. as having permission to use the database.
  27061.  
  27062. Return values
  27063. .............
  27064.  
  27065. Zero for success.  Non-zero if an error occurred.
  27066.  
  27067. Errors
  27068. ......
  27069.  
  27070. `CR_COMMANDS_OUT_OF_SYNC'
  27071.      Commands were executed in an improper order.
  27072.  
  27073. `CR_SERVER_GONE_ERROR'
  27074.      The *MySQL* server has gone away.
  27075.  
  27076. `CR_SERVER_LOST'
  27077.      The connection to the server was lost during the query.
  27078.  
  27079. `CR_UNKNOWN_ERROR'
  27080.      An unknown error occurred.
  27081.  
  27082. `mysql_shutdown()'
  27083. ------------------
  27084.  
  27085. `int mysql_shutdown(MYSQL *mysql)'
  27086.  
  27087. Description
  27088. ...........
  27089.  
  27090. Asks the database server to shutdown. The connected user must have
  27091. *shutdown* privileges.
  27092.  
  27093. Return values
  27094. .............
  27095.  
  27096. Zero for success.  Non-zero if an error occurred.
  27097.  
  27098. Errors
  27099. ......
  27100.  
  27101. `CR_COMMANDS_OUT_OF_SYNC'
  27102.      Commands were executed in an improper order.
  27103.  
  27104. `CR_SERVER_GONE_ERROR'
  27105.      The *MySQL* server has gone away.
  27106.  
  27107. `CR_SERVER_LOST'
  27108.      The connection to the server was lost during the query.
  27109.  
  27110. `CR_UNKNOWN_ERROR'
  27111.      An unknown error occurred.
  27112.  
  27113. `mysql_stat()'
  27114. --------------
  27115.  
  27116. `char *mysql_stat(MYSQL *mysql)'
  27117.  
  27118. Description
  27119. ...........
  27120.  
  27121. Returns a character string containing information similar to that
  27122. provided by the `mysqladmin status' command.  This includes uptime in
  27123. seconds and the number of running threads, questions, reloads and open
  27124. tables.
  27125.  
  27126. Return values
  27127. .............
  27128.  
  27129. A character string describing the server status. `NULL' if an error
  27130. occurred.
  27131.  
  27132. Errors
  27133. ......
  27134.  
  27135. `CR_COMMANDS_OUT_OF_SYNC'
  27136.      Commands were executed in an improper order.
  27137.  
  27138. `CR_SERVER_GONE_ERROR'
  27139.      The *MySQL* server has gone away.
  27140.  
  27141. `CR_SERVER_LOST'
  27142.      The connection to the server was lost during the query.
  27143.  
  27144. `CR_UNKNOWN_ERROR'
  27145.      An unknown error occurred.
  27146.  
  27147. `mysql_store_result()'
  27148. ----------------------
  27149.  
  27150. `MYSQL_RES *mysql_store_result(MYSQL *mysql)'
  27151.  
  27152. Description
  27153. ...........
  27154.  
  27155. You must call `mysql_store_result()' or `mysql_use_result()' for every
  27156. query which successfully retrieves data (`SELECT', `SHOW', `DESCRIBE',
  27157. `EXPLAIN').
  27158.  
  27159. If you want to know if the query should return a result set or not, you
  27160. can use `mysql_field_count()' to check for this.  *Note
  27161. `mysql_field_count': mysql_field_count.
  27162.  
  27163. `mysql_store_result()' reads the entire result of a query to the client,
  27164. allocates a `MYSQL_RES' structure, and places the result into this
  27165. structure.
  27166.  
  27167. `mysql_store_results()' returns a null pointer if the query didn't
  27168. return a result sets (If the query was for example an `INSERT'
  27169. statement).
  27170.  
  27171. `mysql_store_results()' returns also null pointer if reading of the
  27172. result set failed. You can check if you got an error by checking if
  27173. `mysql_error()' doesn't return a null pointer, if `mysql_errno()'
  27174. returns <> 0 or if `mysql_field_count()' returns <> 0.
  27175.  
  27176. An empty result set is returned if there are no rows returned.  (An
  27177. empty result set differs from a null pointer as a return value.)
  27178.  
  27179. Once you have called `mysql_store_result()' and got a result back which
  27180. isn't a null pointer, you may call `mysql_num_rows()' to find out how
  27181. many rows are in the result set.
  27182.  
  27183. You can call `mysql_fetch_row()' to fetch rows from the result set, or
  27184. `mysql_row_seek()' and `mysql_row_tell()' to obtain or set the current
  27185. row position within the result set.
  27186.  
  27187. You must call `mysql_free_result()' once you are done with the result
  27188. set.
  27189.  
  27190. *Note `NULL mysql_store_result()': NULL mysql_store_result.
  27191.  
  27192. Return values
  27193. .............
  27194.  
  27195. A `MYSQL_RES' result structure with the results. `NULL' if an error
  27196. occurred.
  27197.  
  27198. Errors
  27199. ......
  27200.  
  27201. `CR_COMMANDS_OUT_OF_SYNC'
  27202.      Commands were executed in an improper order.
  27203.  
  27204. `CR_OUT_OF_MEMORY'
  27205.      Out of memory.
  27206.  
  27207. `CR_SERVER_GONE_ERROR'
  27208.      The *MySQL* server has gone away.
  27209.  
  27210. `CR_SERVER_LOST'
  27211.      The connection to the server was lost during the query.
  27212.  
  27213. `CR_UNKNOWN_ERROR'
  27214.      An unknown error occurred.
  27215.  
  27216. `mysql_thread_id()'
  27217. -------------------
  27218.  
  27219. `unsigned long mysql_thread_id(MYSQL *mysql)'
  27220.  
  27221. Description
  27222. ...........
  27223.  
  27224. Returns the thread ID of the current connection.  This value can be
  27225. used as an argument to `mysql_kill()' to kill the thread.
  27226.  
  27227. If the connection is lost and you reconnect with `mysql_ping()', the
  27228. thread ID will change.  This means you should not get the thread ID and
  27229. store it for later, you should get it when you need it.
  27230.  
  27231. Return values
  27232. .............
  27233.  
  27234. The thread ID of the current connection.
  27235.  
  27236. Errors
  27237. ......
  27238.  
  27239. None.
  27240.  
  27241. `mysql_use_result()'
  27242. --------------------
  27243.  
  27244. `MYSQL_RES *mysql_use_result(MYSQL *mysql)'
  27245.  
  27246. Description
  27247. ...........
  27248.  
  27249. You must call `mysql_store_result()' or `mysql_use_result()' for every
  27250. query which successfully retrieves data (`SELECT', `SHOW', `DESCRIBE',
  27251. `EXPLAIN').
  27252.  
  27253. `mysql_use_result()' initiates a result set retrieval but does not
  27254. actually read the result set into the client like `mysql_store_result()'
  27255. does.  Instead, each row must be retrieved individually by making calls
  27256. to `mysql_fetch_row()'.  This reads the result of a query directly from
  27257. the server without storing it in a temporary table or local buffer,
  27258. which is somewhat faster and uses much less memory than
  27259. `mysql_store_result()'.  The client will only allocate memory for the
  27260. current row and a communication buffer that may grow up to
  27261. `max_allowed_packet' bytes.
  27262.  
  27263. On the other hand, you shouldn't use `mysql_use_result()' if you are
  27264. doing a lot of processing for each row on the client side, or if the
  27265. output is sent to a screen on which the user may type a `^S' (stop
  27266. scroll).  This will tie up the server and prevent other threads from
  27267. updating any tables from which the data is being fetched.
  27268.  
  27269. When using `mysql_use_result()', you must execute `mysql_fetch_row()'
  27270. until a `NULL' value is returned, otherwise the unfetched rows will be
  27271. returned as part of the result set for your next query. The C API will
  27272. give the error `Commands out of sync; You can't run this command now'
  27273. if you forget to do this!
  27274.  
  27275. You may not use `mysql_data_seek()', `mysql_row_seek()',
  27276. `mysql_row_tell()', `mysql_num_rows()' or `mysql_affected_rows()' with
  27277. a result returned from `mysql_use_result()', nor may you issue other
  27278. queries until the `mysql_use_result()' has finished.  (However, after
  27279. you have fetched all the rows, `mysql_num_rows()' will accurately
  27280. return the number of rows fetched.)
  27281.  
  27282. You must call `mysql_free_result()' once you are done with the result
  27283. set.
  27284.  
  27285. Return values
  27286. .............
  27287.  
  27288. A `MYSQL_RES' result structure. `NULL' if an error occurred.
  27289.  
  27290. Errors
  27291. ......
  27292.  
  27293. `CR_COMMANDS_OUT_OF_SYNC'
  27294.      Commands were executed in an improper order.
  27295.  
  27296. `CR_OUT_OF_MEMORY'
  27297.      Out of memory.
  27298.  
  27299. `CR_SERVER_GONE_ERROR'
  27300.      The *MySQL* server has gone away.
  27301.  
  27302. `CR_SERVER_LOST'
  27303.      The connection to the server was lost during the query.
  27304.  
  27305. `CR_UNKNOWN_ERROR'
  27306.      An unknown error occurred.
  27307.  
  27308. Why is it that after `mysql_query()' returns success, `mysql_store_result()' sometimes returns `NULL?'
  27309. ------------------------------------------------------------------------------------------------------
  27310.  
  27311. It is possible for `mysql_store_result()' to return `NULL' following a
  27312. successful call to `mysql_query()'.  When this happens, it means one of
  27313. the following conditions occurred:
  27314.  
  27315.    * There was a `malloc()' failure (for example, if the result set was
  27316.      too large).
  27317.  
  27318.    * The data couldn't be read (an error occurred on the connection).
  27319.  
  27320.    * The query returned no data (e.g., it was an `INSERT', `UPDATE' or
  27321.      `DELETE').
  27322.  
  27323. You can always check whether or not the statement should have produced a
  27324. non-empty result by calling `mysql_field_count()'.  If
  27325. `mysql_field_count()' returns zero, the result is empty and the last
  27326. query was a statement that does not return values (for example, an
  27327. `INSERT' or a `DELETE').  If `mysql_field_count()' returns a non-zero
  27328. value, the statement should have produced a non-empty result.  See the
  27329. description of the `mysql_field_count()' function for an example.
  27330.  
  27331. You can test for an error by calling `mysql_error()' or `mysql_errno()'.
  27332.  
  27333. What results can I get from a query?
  27334. ------------------------------------
  27335.  
  27336. In addition to the result set returned by a query, you can also get the
  27337. following information:
  27338.  
  27339.    * `mysql_affected_rows()' returns the number of rows affected by the
  27340.      last query when doing an `INSERT', `UPDATE' or `DELETE'. An
  27341.      exception is that if `DELETE' is used without a `WHERE' clause, the
  27342.      table is recreated empty, which is much faster! In this case,
  27343.      `mysql_affected_rows()' returns zero for the number of records
  27344.      affected.
  27345.  
  27346.    * `mysql_num_rows()' returns the number of rows in a result set.
  27347.      With `mysql_store_result()', `mysql_num_rows()' may be called as
  27348.      soon as `mysql_store_result()' returns.  With `mysql_use_result()',
  27349.      `mysql_num_rows()' may be called only after you have fetched all
  27350.      the rows with `mysql_fetch_row()'.
  27351.  
  27352.    * `mysql_insert_id()' returns the ID generated by the last query
  27353.      that inserted a row into a table with an `AUTO_INCREMENT' index.
  27354.      *Note `mysql_insert_id()': mysql_insert_id.
  27355.  
  27356.    * Some queries (`LOAD DATA INFILE ...', `INSERT INTO ... SELECT
  27357.      ...', `UPDATE') return additional info.  The result is returned by
  27358.      `mysql_info()'.  See the description for `mysql_info()' for the
  27359.      format of the string that it returns.  `mysql_info()' returns a
  27360.      `NULL' pointer if there is no additional information.
  27361.  
  27362. How can I get the unique ID for the last inserted row?
  27363. ------------------------------------------------------
  27364.  
  27365. If you insert a record in a table containing a column that has the
  27366. `AUTO_INCREMENT' attribute, you can get the most recently generated ID
  27367. by calling the `mysql_insert_id()' function.
  27368.  
  27369. You can also retrieve the ID by using the `LAST_INSERT_ID()' function in
  27370. a query string that you pass to `mysql_query()'.
  27371.  
  27372. You can check if an `AUTO_INCREMENT' index is used by executing the
  27373. following code. This also checks if the query was an `INSERT' with an
  27374. `AUTO_INCREMENT' index:
  27375.  
  27376.      if (mysql_error(&mysql)[0] == 0 &&
  27377.          mysql_num_fields(result) == 0 &&
  27378.          mysql_insert_id(&mysql) != 0)
  27379.      {
  27380.          used_id = mysql_insert_id(&mysql);
  27381.      }
  27382.  
  27383. The most recently generated ID is maintained in the server on a
  27384. per-connection basis.  It will not be changed by another client. It
  27385. will not even be changed if you update another `AUTO_INCREMENT' column
  27386. with a non-magic value (that is, a value that is not `NULL' and not
  27387. `0').
  27388.  
  27389. If you want to use the ID that was generated for one table and insert
  27390. it into a second table, you can use SQL statements like this:
  27391.  
  27392.      INSERT INTO foo (auto,text)
  27393.          VALUES(NULL,'text');              # generate ID by inserting NULL
  27394.      INSERT INTO foo2 (id,text)
  27395.          VALUES(LAST_INSERT_ID(),'text');  # use ID in second table
  27396.  
  27397. Problems linking with the C API
  27398. -------------------------------
  27399.  
  27400. When linking with the C API, the following errors may occur on some
  27401. systems:
  27402.  
  27403.      gcc -g -o client test.o -L/usr/local/lib/mysql -lmysqlclient -lsocket -lnsl
  27404.      
  27405.      Undefined        first referenced
  27406.       symbol          in file
  27407.      floor            /usr/local/lib/mysql/libmysqlclient.a(password.o)
  27408.      ld: fatal: Symbol referencing errors. No output written to client
  27409.  
  27410. If this happens on your system, you must include the math library by
  27411. adding `-lm' to the end of the compile/link line.
  27412.  
  27413. How to make a thread-safe client
  27414. --------------------------------
  27415.  
  27416. The client library is "almost" thread-safe. The biggest problem is that
  27417. the subroutines in `net.c' that read from sockets are not
  27418. interrupt-safe.  This was done with the thought that you might want to
  27419. have your own alarm that can break a long read to a server.  If you
  27420. install an interrupt handlers for the `SIGPIPE' interrupt, the socket
  27421. handling should be thread safe.
  27422.  
  27423. In the standard binaries we distribute on our web site, the client
  27424. libraries are not normally compiled with the thread safe option.
  27425.  
  27426. To get a really thread-safe client where you can interrupt the client
  27427. from other threads and set timeouts when talking with the MySQL server,
  27428. you should use the `-lmysys', `-lstring' and `-ldbug' libraries and the
  27429. `net_serv.o' code that the server uses.
  27430.  
  27431. If you don't need interrupts or timeouts you can just compile the client
  27432. library `(mysqlclient)' to be thread safe and use this.  In this case
  27433. you don't have to worry about the `net_serv.o' object file or the other
  27434. *MySQL* libraries.
  27435.  
  27436. When using a threaded client and you want to use timeouts and
  27437. interrupts, you can make great use of the routines in the `thr_alarm.c'
  27438. file.  If you are using routines from the `mysys' library, the only
  27439. thing you must remember is to call `my_init()' first!
  27440.  
  27441. All functions except `mysql_real_connect()' are by default thread-safe.
  27442. The following notes describe how to compile a thread-safe client
  27443. library and use it in a thread-safe manner.  (The notes below for
  27444. `mysql_real_connect()' actually apply to `mysql_connect()' as well, but
  27445. because `mysql_connect()' is deprecated, you should be using
  27446. `mysql_real_connect()' anyway.)
  27447.  
  27448. To make `mysql_real_connect()' thread-safe, you must recompile the
  27449. client library with this command:
  27450.  
  27451.      shell> ./configure --enable-thread-safe-client
  27452.  
  27453. This will ensure that the client library will use the header files
  27454. required for thread safe programs and also that `mysql_real_connect()'
  27455. will use a thread safe version of the `gethostbyname()' call.
  27456.  
  27457. You may get some errors because of undefined symbols when linking the
  27458. standard client, because the pthread libraries are not included by
  27459. default.
  27460.  
  27461. The resulting `libmysqlclient.a' library is now thread-safe.  What this
  27462. means is that client code is thread-safe as long as two threads don't
  27463. query the same connection handle returned by `mysql_real_connect()' at
  27464. the same time; the client/server protocol allows only one request at a
  27465. time on a given connection.  If you want to use multiple threads on the
  27466. same connection, you must have a mutex lock around your `mysql_query()'
  27467. and `mysql_store_result()' call combination.  Once
  27468. `mysql_store_result()' is ready, the lock can be released and other
  27469. threads may query the same connection.  (In other words, different
  27470. threads can use different `MYSQL_RES' pointers that were created with
  27471. `mysql_store_result()', as long as they use the proper locking
  27472. protocol.) If you program with POSIX threads, you can use
  27473. `pthread_mutex_lock()' and `pthread_mutex_unlock()' to establish and
  27474. release a mutex lock.
  27475.  
  27476. If you used `mysql_use_result()' rather than `mysql_store_result()',
  27477. the lock would need to surround `mysql_use_result()' and the calls to
  27478. `mysql_fetch_row()'.  However, it really is best for threaded clients
  27479. not to use `mysql_use_result()'.
  27480.  
  27481. MySQL Perl API
  27482. ==============
  27483.  
  27484. This section documents the Perl `DBI' interface.  The former interface
  27485. was called `mysqlperl'.  `DBI'/`DBD' now is the recommended Perl
  27486. interface, so `mysqlperl' is obsolete and is not documented here.
  27487.  
  27488. `DBI' with `DBD::mysql'
  27489. -----------------------
  27490.  
  27491. `DBI' is a generic interface for many databases. That means that you
  27492. can write a script that works with many different database engines
  27493. without change. You need a DataBase Driver (DBD) defined for each
  27494. database type. For *MySQL*, this driver is called `DBD::mysql'.
  27495.  
  27496. For more information on the Perl5 DBI, please visit the `DBI' web page
  27497. and read the documentation:
  27498.      `http://www.symbolstone.org/technology/perl/DBI/index.html'
  27499. For more information on Object Oriented Programming (OOP) as defined in
  27500. Perl5, see the Perl OOP page:
  27501.      `http://language.perl.com/info/documentation.html'
  27502.  
  27503. Installation instructions for *MySQL* Perl support are given in *Note
  27504. Perl support::.
  27505.  
  27506. The `DBI' interface
  27507. -------------------
  27508.  
  27509. *Portable DBI methods*
  27510.  
  27511. `connect'              Establishes a connection to a database server.
  27512. `disconnect'           Disconnects from the database server.
  27513. `prepare'              Prepares a SQL statement for execution.
  27514. `execute'              Executes prepared statements.
  27515. `do'                   Prepares and executes a SQL statement.
  27516. `quote'                Quotes string or `BLOB' values to be inserted.
  27517. `fetchrow_array'       Fetches the next row as an array of fields.
  27518. `fetchrow_arrayref'    Fetches next row as a reference array of fields.
  27519. `fetchrow_hashref'     Fetches next row as a reference to a hashtable.
  27520. `fetchall_arrayref'    Fetches all data as an array of arrays.
  27521. `finish'               Finishes a statement and lets the system free
  27522.                        resources.
  27523. `rows'                 Returns the number of rows affected.
  27524. `data_sources'         Returns an array of databases available on
  27525.                        localhost.
  27526. `ChopBlanks'           Controls whether `fetchrow_*' methods trim spaces.
  27527. `NUM_OF_PARAMS'        The number of placeholders in the prepared
  27528.                        statement.
  27529. `NULLABLE'             Which columns can be `NULL'.
  27530. `trace'                Perform tracing for debugging.
  27531.  
  27532. *MySQL-specific methods*
  27533.  
  27534. `insertid'             The latest `AUTO_INCREMENT' value.
  27535. `is_blob'              Which column are `BLOB' values.
  27536. `is_key'               Which columns are keys.
  27537. `is_num'               Which columns are numeric.
  27538. `is_pri_key'           Which columns are primary keys.
  27539. `is_not_null'          Which columns CANNOT be `NULL'. See `NULLABLE'.
  27540. `length'               Maximum possible column sizes.
  27541. `max_length'           Maximum column sizes actually present in result.
  27542. `NAME'                 Column names.
  27543. `NUM_OF_FIELDS'        Number of fields returned.
  27544. `table'                Table names in returned set.
  27545. `type'                 All column types.
  27546.  
  27547. The Perl methods are described in more detail in the following sections.
  27548. Variables used for method return values have these meanings:
  27549.  
  27550. `$dbh'
  27551.      Database handle
  27552.  
  27553. `$sth'
  27554.      Statement handle
  27555.  
  27556. `$rc'
  27557.      Return code (often a status)
  27558.  
  27559. `$rv'
  27560.      Return value (often a row count)
  27561.  
  27562. *Portable DBI methods*
  27563.  
  27564. `connect($data_source, $username, $password)'
  27565.      Use the `connect' method to make a database connection to the data
  27566.      source. The `$data_source' value should begin with
  27567.      `DBI:driver_name:'.  Example uses of `connect' with the
  27568.      `DBD::mysql' driver:
  27569.           $dbh = DBI->connect("DBI:mysql:$database", $user, $password);
  27570.           $dbh = DBI->connect("DBI:mysql:$database:$hostname",
  27571.                               $user, $password);
  27572.           $dbh = DBI->connect("DBI:mysql:$database:$hostname:$port",
  27573.                               $user, $password);
  27574.      If the user name and/or password are undefined, `DBI' uses the
  27575.      values of the `DBI_USER' and `DBI_PASS' environment variables,
  27576.      respectively. If you don't specify a hostname, it defaults to
  27577.      `'localhost''. If you don't specify a port number, it defaults to
  27578.      the default *MySQL* port (3306).
  27579.  
  27580.      As of `Msql-Mysql-modules' version 1.2009, the `$data_source'
  27581.      value allows certain modifiers:
  27582.  
  27583.     `mysql_read_default_file=file_name'
  27584.           Read `filename' as an option file.  For information on option
  27585.           files, see *Note Option files::.
  27586.  
  27587.     `mysql_read_default_group=group_name'
  27588.           The default group when reading an option file is normally the
  27589.           `[client]' group.  By specifying the
  27590.           `mysql_read_default_group' option, the default group becomes
  27591.           the `[group_name]' group.
  27592.  
  27593.     `mysql_compression=1'
  27594.           Use compressed communication between the client and server
  27595.           (*MySQL* 3.22.3 or later).
  27596.  
  27597.     `mysql_socket=/path/to/socket'
  27598.           Specify the pathname of the Unix socket that is used to
  27599.           connect to the server (*MySQL* 3.21.15 or later).
  27600.  
  27601.      Multiple modifiers may be given; each must be preceded by a
  27602.      semicolon.
  27603.  
  27604.      For example, if you want to avoid hardcoding the user name and
  27605.      password into a `DBI' script, you can take them from the user's
  27606.      `~/.my.cnf' option file instead by writing your `connect' call
  27607.      like this:
  27608.  
  27609.           $dbh = DBI->connect("DBI:mysql:$database"
  27610.                           . ";mysql_read_default_file=$ENV{HOME}/.my.cnf",
  27611.                           $user, $password);
  27612.  
  27613.      This call will read options defined for the `[client]' group in the
  27614.      option file.  If you wanted to do the same thing, but use options
  27615.      specified for the `[perl]' group as well, you could use this:
  27616.  
  27617.           $dbh = DBI->connect("DBI:mysql:$database"
  27618.                           . ";mysql_read_default_file=$ENV{HOME}/.my.cnf"
  27619.                           . ";mysql_read_default_group=perl",
  27620.                           $user, $password);
  27621.  
  27622. `disconnect'
  27623.      The `disconnect' method disconnects the database handle from the
  27624.      database.  This is typically called right before you exit from the
  27625.      program.  Example:
  27626.           $rc = $dbh->disconnect;
  27627.  
  27628. `prepare($statement)'
  27629.      Prepares a SQL statement for execution by the database engine and
  27630.      returns a statement handle `($sth)' which you can use to invoke
  27631.      the `execute' method.  Typically you handle `SELECT' statements
  27632.      (and `SELECT'-like statements such as `SHOW', `DESCRIBE' and
  27633.      `EXPLAIN') by means of `prepare' and `execute'.  Example:
  27634.           $sth = $dbh->prepare($statement)
  27635.               or die "Can't prepare $statement: $dbh->errstr\n";
  27636.  
  27637. `execute'
  27638.      The `execute' method executes a prepared statement. For
  27639.      non-`SELECT' statements, `execute' returns the number of rows
  27640.      affected.  If no rows are affected, `execute' returns `"0E0"',
  27641.      which Perl treats as zero but regards as true. If an error occurs,
  27642.      `execute' returns `undef'. For `SELECT' statements, `execute' only
  27643.      starts the SQL query in the database; you need to use one of the
  27644.      `fetch_*' methods described below to retrieve the data.  Example:
  27645.           $rv = $sth->execute
  27646.                     or die "can't execute the query: $sth->errstr;
  27647.  
  27648. `do($statement)'
  27649.      The `do' method prepares and executes a SQL statement and returns
  27650.      the number of rows affected.  If no rows are affected, `do' returns
  27651.      `"0E0"', which Perl treats as zero but regards as true.  This
  27652.      method is generally used for non-`SELECT' statements which cannot
  27653.      be prepared in advance (due to driver limitations) or which do not
  27654.      need to executed more than once (inserts, deletes, etc.). Example:
  27655.           $rv = $dbh->do($statement)
  27656.                   or die "Can't execute $statement: $dbh- >errstr\n";
  27657.  
  27658.      Generally the 'do' statement is MUCH faster (and is preferable)
  27659.      than prepare/execute for statements that doesn't contain
  27660.      parameters.
  27661.  
  27662. `quote($string)'
  27663.      The `quote' method is used to "escape" any special characters
  27664.      contained in the string and to add the required outer quotation
  27665.      marks.  Example:
  27666.           $sql = $dbh->quote($string)
  27667.  
  27668. `fetchrow_array'
  27669.      This method fetches the next row of data and returns it as an
  27670.      array of field values.  Example:
  27671.           while(@row = $sth->fetchrow_array) {
  27672.                   print qw($row[0]\t$row[1]\t$row[2]\n);
  27673.           }
  27674.  
  27675. `fetchrow_arrayref'
  27676.      This method fetches the next row of data and returns it as a
  27677.      reference to an array of field values. Example:
  27678.           while($row_ref = $sth->fetchrow_arrayref) {
  27679.                   print qw($row_ref->[0]\t$row_ref->[1]\t$row_ref->[2]\n);
  27680.           }
  27681.  
  27682. `fetchrow_hashref'
  27683.      This method fetches a row of data and returns a reference to a hash
  27684.      table containing field name/value pairs. This method is not nearly
  27685.      as efficient as using array references as demonstrated above.
  27686.      Example:
  27687.           while($hash_ref = $sth->fetchrow_hashref) {
  27688.                   print qw($hash_ref->{firstname}\t$hash_ref->{lastname}\t\
  27689.                           $hash_ref- > title}\n);
  27690.           }
  27691.  
  27692. `fetchall_arrayref'
  27693.      This method is used to get all the data (rows) to be returned from
  27694.      the SQL statement. It returns a reference to an array of
  27695.      references to arrays for each row. You access or print the data by
  27696.      using a nested loop. Example:
  27697.           my $table = $sth->fetchall_arrayref
  27698.                           or die "$sth->errstr\n";
  27699.           my($i, $j);
  27700.           for $i ( 0 .. $#{$table} ) {
  27701.                   for $j ( 0 .. $#{$table->[$i]} ) {
  27702.                           print "$table->[$i][$j]\t";
  27703.                   }
  27704.                   print "\n";
  27705.           }
  27706.  
  27707. `finish'
  27708.      Indicates that no more data will be fetched from this statement
  27709.      handle. You call this method to free up the statement handle and
  27710.      any system resources associated with it.  Example:
  27711.           $rc = $sth->finish;
  27712.  
  27713. `rows'
  27714.      Returns the number of rows changed (updated, deleted, etc.) by the
  27715.      last command.  This is usually used after a non-`SELECT' `execute'
  27716.      statement.  Example:
  27717.           $rv = $sth->rows;
  27718.  
  27719. `NULLABLE'
  27720.      Returns a reference to an array of boolean values; for each
  27721.      element of the array, a value of TRUE indicates that this column
  27722.      may contain `NULL' values.  Example:
  27723.           $null_possible = $sth->{NULLABLE};
  27724.  
  27725. `NUM_OF_FIELDS'
  27726.      This attribute indicates the number of fields returned by a
  27727.      `SELECT' or `SHOW FIELDS' statement.  You may use this for
  27728.      checking whether a statement returned a result: A zero value
  27729.      indicates a non-`SELECT' statement like `INSERT', `DELETE' or
  27730.      `UPDATE'.  Example:
  27731.           $nr_of_fields = $sth->{NUM_OF_FIELDS};
  27732.  
  27733. `data_sources($driver_name)'
  27734.      This method returns an array containing names of databases
  27735.      available to the *MySQL* server on the host `'localhost''.
  27736.      Example:
  27737.           @dbs = DBI->data_sources("mysql");
  27738.  
  27739. `ChopBlanks'
  27740.      This attribute determines whether the `fetchrow_*' methods will
  27741.      chop leading and trailing blanks from the returned values.
  27742.      Example:
  27743.           $sth->{'ChopBlanks'} =1;
  27744.  
  27745. `trace($trace_level)'
  27746. `trace($trace_level, $trace_filename)'
  27747.      The `trace' method enables or disables tracing.  When invoked as a
  27748.      `DBI' class method, it affects tracing for all handles.  When
  27749.      invoked as a database or statement handle method, it affects
  27750.      tracing for the given handle (and any future children of the
  27751.      handle).  Setting `$trace_level' to 2 provides detailed trace
  27752.      information.  Setting `$trace_level' to 0 disables tracing.  Trace
  27753.      output goes to the standard error output by default.  If
  27754.      `$trace_filename' is specified, the file is opened in append mode
  27755.      and output for _all_ traced handles is written to that file.
  27756.      Example:
  27757.           DBI->trace(2);                # trace everything
  27758.           DBI->trace(2,"/tmp/dbi.out"); # trace everything to /tmp/dbi.out
  27759.           $dth->trace(2);               # trace this database handle
  27760.           $sth->trace(2);               # trace this statement handle
  27761.  
  27762.      You can also enable `DBI' tracing by setting the `DBI_TRACE'
  27763.      environment variable.  Setting it to a numeric value is equivalent
  27764.      to calling `DBI->(value)'.  Setting it to a pathname is equivalent
  27765.      to calling `DBI->(2,value)'.
  27766.  
  27767. *MySQL-specific methods*
  27768.  
  27769. The methods shown below are *MySQL*-specific and not part of the `DBI'
  27770. standard.  Several of them are now deprecated: `is_blob', `is_key',
  27771. `is_num', `is_pri_key', `is_not_null', `length', `max_length', and
  27772. `table'.  Where `DBI'-standard alternatives exist, they are noted below.
  27773.  
  27774. `insertid'
  27775.      If you use the `AUTO_INCREMENT' feature of *MySQL*, the new
  27776.      auto-incremented values will be stored here.  Example:
  27777.           $new_id = $sth->{insertid};
  27778.  
  27779.      As an alternative, you can use `$dbh->{'mysql_insertid'}'.
  27780.  
  27781. `is_blob'
  27782.      Returns a reference to an array of boolean values; for each
  27783.      element of the array, a value of TRUE indicates that the
  27784.      respective column is a `BLOB'.  Example:
  27785.           $keys = $sth->{is_blob};
  27786.  
  27787. `is_key'
  27788.      Returns a reference to an array of boolean values; for each
  27789.      element of the array, a value of TRUE indicates that the
  27790.      respective column is a key.  Example:
  27791.           $keys = $sth->{is_key};
  27792.  
  27793. `is_num'
  27794.      Returns a reference to an array of boolean values; for each
  27795.      element of the array, a value of TRUE indicates that the
  27796.      respective column contains numeric values.  Example:
  27797.           $nums = $sth->{is_num};
  27798.  
  27799. `is_pri_key'
  27800.      Returns a reference to an array of boolean values; for each
  27801.      element of the array, a value of TRUE indicates that the
  27802.      respective column is a primary key.  Example:
  27803.           $pri_keys = $sth->{is_pri_key};
  27804.  
  27805. `is_not_null'
  27806.      Returns a reference to an array of boolean values; for each
  27807.      element of the array, a value of FALSE indicates that this column
  27808.      may contain `NULL' values.  Example:
  27809.           $not_nulls = $sth->{is_not_null};
  27810.  
  27811.      `is_not_null' is deprecated; it is preferable to use the
  27812.      `NULLABLE' attribute (described above), because that is a DBI
  27813.      standard.
  27814.  
  27815. `length'
  27816. `max_length'
  27817.      Each of these methods returns a reference to an array of column
  27818.      sizes.  The `length' array indicates the maximum possible sizes
  27819.      that each column may be (as declared in the table description).
  27820.      The `max_length' array indicates the maximum sizes actually
  27821.      present in the result table.  Example:
  27822.  
  27823.           $lengths = $sth->{length};
  27824.           $max_lengths = $sth->{max_length};
  27825.  
  27826. `NAME'
  27827.      Returns a reference to an array of column names.  Example:
  27828.           $names = $sth->{NAME};
  27829.  
  27830. `table'
  27831.      Returns a reference to an array of table names.  Example:
  27832.           $tables = $sth->{table};
  27833.  
  27834. `type'
  27835.      Returns a reference to an array of column types.  Example:
  27836.           $types = $sth->{type};
  27837.  
  27838. More `DBI'/`DBD' information
  27839. ----------------------------
  27840.  
  27841. You can use the `perldoc' command to get more information about `DBI'.
  27842.  
  27843.      perldoc DBI
  27844.      perldoc DBI::FAQ
  27845.      perldoc DBD::mysql
  27846.  
  27847. You can also use the `pod2man', `pod2html', etc., tools to translate to
  27848. other formats.
  27849.  
  27850. And of course you can find the latest `DBI' information at the `DBI'
  27851. web page:
  27852.      `http://www.symbolstone.org/technology/perl/DBI/index.html'
  27853.  
  27854. MySQL Eiffel wrapper
  27855. ====================
  27856.  
  27857. The *MySQL* Contrib directory (http://www.mysql.com/Downloads/Contrib/)
  27858. contains an Eiffel wrapper written by Michael Ravits.
  27859.  
  27860. You can also find this at: <http://www.netpedia.net/hosting/newplayer/>
  27861.  
  27862. MySQL Java connectivity (JDBC)
  27863. ==============================
  27864.  
  27865. There are 2 supported JDBC drivers for *MySQL* (the twz and mm driver).
  27866. You can find a copy of these at
  27867. `http://www.mysql.com/Downloads/Contrib/'.  For documentation consult
  27868. any JDBC documentation and the drivers own documentation for *MySQL*
  27869. specific features.
  27870.  
  27871. MySQL PHP API
  27872. =============
  27873.  
  27874. PHP is a server-side, HTML embedded scripting language that may be used
  27875. to create dynamic web pages.  It contains support for accessing several
  27876. databases, including *MySQL*.  PHP may be run as a separate program, or
  27877. compiled as a module for use with the Apache web server.
  27878.  
  27879. The distribution and documentation are available at the PHP website
  27880. (http://www.php.net/).
  27881.  
  27882. Common problems with MySQL and PHP
  27883. ----------------------------------
  27884.  
  27885.    * Error: "Maximum Execution Time Exeeded" This is a PHP limit;  Go
  27886.      into the `php3.ini' file and set the maximum execution time up
  27887.      from 30 seconds to something higher, as needed.  It is also not a
  27888.      bad idea to double the ram allowed per script to 16 instead of 8
  27889.      MB.
  27890.  
  27891.    * Error: "Fatal error: Call to unsupported or undefined function
  27892.      mysql_connect() in .."  This means that your PHP version isn't
  27893.      compiled with *MySQL* support.  You can either compile a dynamic
  27894.      *MySQL* module and load it into PHP or recompile PHP with built-in
  27895.      `MySQL' support.  This is described in detail in the PHP manual.
  27896.  
  27897. MySQL C++ APIs
  27898. ==============
  27899.  
  27900. Two API's are available in the *MySQL* Contrib directory
  27901. (http://www.mysql.com/Contrib/).
  27902.  
  27903. MySQL Python APIs
  27904. =================
  27905.  
  27906. The *MySQL* Contrib directory (http://www.mysql.com/Contrib/) contains
  27907. a Python interface written by Joseph Skinner.
  27908.  
  27909. You can also use the Python interface to iODBC to access a *MySQL*
  27910. server.  mxODBC (http://starship.skyport.net/~lemburg/)
  27911.  
  27912. MySQL Tcl APIs
  27913. ==============
  27914.  
  27915. Tcl at binevolve (http://www.binevolve.com/~tdarugar/tcl-sql/).  The
  27916. Contrib directory (http://www.mysql.com/Contrib) contains a Tcl
  27917. interface that is based on msqltcl 1.50.
  27918.  
  27919. How MySQL compares to other databases
  27920. *************************************
  27921.  
  27922. How MySQL compares to `mSQL'
  27923. ============================
  27924.  
  27925. This section has been written by the *MySQL* developers, so it should
  27926. be read with that in mind. But there are NO factual errors that we know
  27927. of.
  27928.  
  27929. For a list of all supported limits, functions and types, see the
  27930. `crash-me' web page (http://www.mysql.com/information/crash-me.php).
  27931.  
  27932. *Performance*
  27933.      For a true comparison of speed, consult the growing *MySQL*
  27934.      benchmark suite. *Note Benchmarks::.
  27935.  
  27936.      Because there is no thread creation overhead, a small parser, few
  27937.      features and simple security, `mSQL' should be quicker at:
  27938.  
  27939.         * Tests that perform repeated connects and disconnects, running
  27940.           a very simple query during each connection.
  27941.  
  27942.         * `INSERT' operations into very simple tables with few columns
  27943.           and keys.
  27944.  
  27945.         * `CREATE TABLE' and `DROP TABLE'.
  27946.  
  27947.         * `SELECT' on something that isn't an index. (A table scan is
  27948.           very easy.)
  27949.  
  27950.      Because these operations are so simple, it is hard to be better at
  27951.      them when you have a higher startup overhead. After the connection
  27952.      is established, *MySQL* should perform much better.
  27953.  
  27954.      On the other hand, *MySQL* is much faster than `mSQL' (and most
  27955.      other SQL implementions) on the following:
  27956.  
  27957.         * Complex `SELECT' operations.
  27958.  
  27959.         * Retrieving large results (*MySQL* has a better, faster and
  27960.           safer protocol).
  27961.  
  27962.         * Tables with variable-length strings, because *MySQL* has more
  27963.           efficent handling and can have indexes on `VARCHAR' columns.
  27964.  
  27965.         * Handling tables with many columns.
  27966.  
  27967.         * Handling tables with large record lengths.
  27968.  
  27969.         * `SELECT' with many expressions.
  27970.  
  27971.         * `SELECT' on large tables.
  27972.  
  27973.         * Handling many connections at the same time. *MySQL* is fully
  27974.           multi-threaded. Each connection has its own thread, which
  27975.           means that no thread has to wait for another (unless a thread
  27976.           is modifying a table another thread wants to access.) In
  27977.           `mSQL', once one connection is established, all others must
  27978.           wait until the first has finished, regardless of whether the
  27979.           connection is running a query that is short or long. When the
  27980.           first connection terminates, the next can be served, while
  27981.           all the others wait again, etc.
  27982.  
  27983.         * Joins.  `mSQL' can become pathologically slow if you change
  27984.           the order of tables in a `SELECT'. In the benchmark suite, a
  27985.           time more than 15000 times slower than *MySQL* was seen.
  27986.           This is due to `mSQL''s lack of a join optimizer to order
  27987.           tables in the optimal order. However, if you put the tables
  27988.           in exactly the right order in `mSQL'2 and the `WHERE' is
  27989.           simple and uses index columns, the join will be relatively
  27990.           fast!  *Note Benchmarks::.
  27991.  
  27992.         * `ORDER BY' and `GROUP BY'.
  27993.  
  27994.         * `DISTINCT'.
  27995.  
  27996.         * Using `TEXT' or `BLOB' columns.
  27997.  
  27998. *SQL Features*
  27999.         * `GROUP BY' and `HAVING'.  `mSQL' does not support `GROUP BY'
  28000.           at all.  *MySQL* supports a full `GROUP BY' with both
  28001.           `HAVING' and the following functions: `COUNT()', `AVG()',
  28002.           `MIN()', `MAX()', `SUM()' and `STD()'.  `COUNT(*)' is
  28003.           optimized to return very quickly if the `SELECT' retrieves
  28004.           from one table, no other columns are retrieved and there is
  28005.           no `WHERE' clause.  `MIN()' and `MAX()' may take string
  28006.           arguments.
  28007.  
  28008.         * `INSERT' and `UPDATE' with calculations.  *MySQL* can do
  28009.           calculations in an `INSERT' or `UPDATE'.  For example:
  28010.                mysql> UPDATE SET x=x*10+y WHERE x<20;
  28011.  
  28012.         * Aliasing.  *MySQL* has column aliasing.
  28013.  
  28014.         * Qualifying column names.  In *MySQL*, if a column name is
  28015.           unique among the tables used in a query, you do not have to
  28016.           use the full qualifier.
  28017.  
  28018.         * `SELECT' with functions.  *MySQL* has many functions (too
  28019.           many to list here; see *Note Functions::).
  28020.  
  28021.  
  28022. *Disk space efficiency*
  28023.      That is, how small can you make your tables?
  28024.  
  28025.      *MySQL* has very precise types, so you can create tables that take
  28026.      very little space. An example of a useful *MySQL* datatype is the
  28027.      `MEDIUMINT' that is 3 bytes long. If you have 100,000,000 records,
  28028.      saving even one byte per record is very important.
  28029.  
  28030.      `mSQL2' has a more limited set of column types, so it is more
  28031.      difficult to get small tables.
  28032.  
  28033. *Stability*
  28034.      This is harder to judge objectively. For a discussion of *MySQL*
  28035.      stability, see *Note Stability::.
  28036.  
  28037.      We have no experience with `mSQL' stability, so we cannot say
  28038.      anything about that.
  28039.  
  28040. *Price*
  28041.      Another important issue is the license. *MySQL* has a more
  28042.      flexible license than `mSQL', and is also less expensive than
  28043.      `mSQL'.  Whichever product you choose to use, remember to at least
  28044.      consider paying for a license or email support.  (You are required
  28045.      to get a license if you include *MySQL* with a product that you
  28046.      sell, of course.)
  28047.  
  28048. *Perl interfaces*
  28049.      *MySQL* has basically the same interfaces to Perl as `mSQL' with
  28050.      some added features.
  28051.  
  28052. *JDBC (Java)*
  28053.      *MySQL* currently has 4 JDBC drivers:
  28054.         * The gwe driver: A Java interface by GWE technologies (not
  28055.           supported anymore).
  28056.  
  28057.         * The jms driver: An improved gwe driver by Xiaokun Kelvin ZHU
  28058.           <X.Zhu@brad.ac.uk>.
  28059.  
  28060.         * The twz driver: A type 4 JDBC driver by Terrence W. Zellers
  28061.           <zellert@voicenet.com>.  This is commercial but is free for
  28062.           private and educational use.
  28063.  
  28064.         * The mm driver: A type 4 JDBC driver by Mark Matthews
  28065.           <mmatthew@ecn.purdue.edu>.  This is released under the GPL.
  28066.  
  28067.      The recommended drivers are the twz or mm driver. Both are
  28068.      reported to work excellently.
  28069.  
  28070.      We know that `mSQL' has a JDBC driver, but we have too little
  28071.      experience with it to compare.
  28072.  
  28073. *Rate of development*
  28074.      *MySQL* has a very small team of developers, but we are quite used
  28075.      to coding C and C++ very rapidly. Because threads, functions,
  28076.      `GROUP BY' and so on are still not implemented in `mSQL', it has a
  28077.      lot of catching up to do. To get some perspective on this, you can
  28078.      view the `mSQL' `HISTORY' file for the last year and compare it
  28079.      with the News section of the *MySQL* Reference Manual (*note
  28080.      News::). It should be pretty obvious which one has developed most
  28081.      rapidly.
  28082.  
  28083. *Utility programs*
  28084.      Both `mSQL' and *MySQL* have many interesting third-party tools.
  28085.      Because it is very easy to port upward (from `mSQL' to *MySQL*),
  28086.      almost all the interesting applications that are available for
  28087.      `mSQL' are also available for *MySQL*.
  28088.  
  28089.      *MySQL* comes with a simple `msql2mysql' program that fixes
  28090.      differences in spelling between `mSQL' and *MySQL* for the
  28091.      most-used C API functions.  For example, it changes instances of
  28092.      `msqlConnect()' to `mysql_connect()'. Converting a client program
  28093.      from `mSQL' to *MySQL* usually takes a couple of minutes.
  28094.  
  28095. How to convert `mSQL' tools for MySQL
  28096. -------------------------------------
  28097.  
  28098. According to our experience, it would just take a few hours to convert
  28099. tools such as `msql-tcl' and `msqljava' that use the `mSQL' C API so
  28100. that they work with the *MySQL* C API.
  28101.  
  28102. The conversion procedure is:
  28103.  
  28104.   1. Run the shell script `msql2mysql' on the source. This requires the
  28105.      `replace' program, which is distributed with *MySQL*.
  28106.  
  28107.   2. Compile.
  28108.  
  28109.   3. Fix all compiler errors.
  28110.  
  28111. Differences between the `mSQL' C API and the *MySQL* C API are:
  28112.    * *MySQL* uses a `MYSQL' structure as a connection type (`mSQL' uses
  28113.      an `int').
  28114.  
  28115.    * `mysql_connect()' takes a pointer to a `MYSQL' structure as a
  28116.      parameter.  It is easy to define one globally or to use `malloc()'
  28117.      to get one.  `mysql_connect()' also takes two parameters for
  28118.      specifying the user and password.  You may set these to `NULL,
  28119.      NULL' for default use.
  28120.  
  28121.    * `mysql_error()' takes the `MYSQL' structure as a parameter. Just
  28122.      add the parameter to your old `msql_error()' code if you are
  28123.      porting old code.
  28124.  
  28125.    * *MySQL* returns an error number and a text error message for all
  28126.      errors. `mSQL' returns only a text error message.
  28127.  
  28128.    * Some incompatibilities exist as a result of *MySQL* supporting
  28129.      multiple connections to the server from the same process.
  28130.  
  28131. How `mSQL' and MySQL client/server communications protocols differ
  28132. ------------------------------------------------------------------
  28133.  
  28134. There are enough differences that it is impossible (or at least not
  28135. easy) to support both.
  28136.  
  28137. The most significant ways in which the *MySQL* protocol differs from
  28138. the `mSQL' protocol are listed below:
  28139.  
  28140.    * A message buffer may contain many result rows.
  28141.  
  28142.    * The message buffers are dynamically enlarged if the query or the
  28143.      result is bigger than the current buffer, up to a configurable
  28144.      server and client limit.
  28145.  
  28146.    * All packets are numbered to catch duplicated or missing packets.
  28147.  
  28148.    * All column values are sent in ASCII. The lengths of columns and
  28149.      rows are sent in packed binary coding (1, 2 or 3 bytes).
  28150.  
  28151.    * *MySQL* can read in the result unbuffered (without having to store
  28152.      the full set in the client).
  28153.  
  28154.    * If a single read/write takes more than 30 seconds, the server
  28155.      closes the connection.
  28156.  
  28157.    * If a connection is idle for 8 hours, the server closes the
  28158.      connection.
  28159.  
  28160. How `mSQL' 2.0 SQL syntax differs from MySQL
  28161. --------------------------------------------
  28162.  
  28163. *Column types*
  28164.  
  28165. `*MySQL*'
  28166.      Has the following additional types (among others; see *note
  28167.      `CREATE TABLE': CREATE TABLE.):
  28168.         * `ENUM' type for one of a set of strings.
  28169.  
  28170.         * `SET' type for many of a set of strings.
  28171.  
  28172.         * `BIGINT' type for 64-bit integers.
  28173.  
  28174. `'
  28175.      *MySQL* also supports the following additional type attributes:
  28176.         * `UNSIGNED' option for integer columns.
  28177.  
  28178.         * `ZEROFILL' option for integer columns.
  28179.  
  28180.         * `AUTO_INCREMENT' option for integer columns that are a
  28181.           `PRIMARY KEY'.  *Note `mysql_insert_id()': mysql_insert_id.
  28182.  
  28183.         * `DEFAULT' value for all columns.
  28184.  
  28185. `mSQL2'
  28186.      `mSQL' column types correspond to the *MySQL* types shown below:
  28187.      `mSQL'     *Corresponding *MySQL* type*
  28188.      *type*     
  28189.      `CHAR(len)'`CHAR(len)'
  28190.      `TEXT(len)'`TEXT(len)'. `len' is the maximal length.  And `LIKE'
  28191.                 works.
  28192.      `INT'      `INT'. With many more options!
  28193.      `REAL'     `REAL'. Or `FLOAT'. Both 4- and 8-byte versions are
  28194.                 available.
  28195.      `UINT'     `INT UNSIGNED'
  28196.      `DATE'     `DATE'. Uses ANSI SQL format rather than `mSQL''s own
  28197.                 format.
  28198.      `TIME'     `TIME'
  28199.      `MONEY'    `DECIMAL(12,2)'. A fixed-point value with two decimals.
  28200.  
  28201. *Index creation*
  28202.  
  28203. `*MySQL*'
  28204.      Indexes may be specified at table creation time with the `CREATE
  28205.      TABLE' statement.
  28206.  
  28207. `mSQL'
  28208.      Indexes must be created after the table has been created, with
  28209.      separate `CREATE INDEX' statements.
  28210.  
  28211. *To insert a unique identifier into a table*
  28212.  
  28213. `*MySQL*'
  28214.      Use `AUTO_INCREMENT' as a column type specifier.  *Note
  28215.      `mysql_insert_id()': mysql_insert_id.
  28216.  
  28217. `mSQL'
  28218.      Create a `SEQUENCE' on a table and select the `_seq' column.
  28219.  
  28220. *To obtain a unique identifier for a row*
  28221.  
  28222. `*MySQL*'
  28223.      Add a `PRIMARY KEY' or `UNIQUE' key to the table and use this.
  28224.      New in 3.23.11: If the `PRIMARY' or `UNIQUE' key consists of only
  28225.      one column and this is of type integer, one can also refer to it as
  28226.      `_rowid'.
  28227.  
  28228. `mSQL'
  28229.      Use the `_rowid' column. Observe that `_rowid' may change over time
  28230.      depending on many factors.
  28231.  
  28232. *To get the time a column was last modified*
  28233.  
  28234. `*MySQL*'
  28235.      Add a `TIMESTAMP' column to the table. This column is
  28236.      automatically set to the current date and time for `INSERT' or
  28237.      `UPDATE' statements if you don't give the column a value or if you
  28238.      give it a `NULL' value.
  28239.  
  28240. `mSQL'
  28241.      Use the `_timestamp' column.
  28242.  
  28243. *`NULL' value comparisons*
  28244.  
  28245. `*MySQL*'
  28246.      *MySQL* follows ANSI SQL and a comparison with `NULL' is always
  28247.      `NULL'.
  28248.  
  28249. `mSQL'
  28250.      In `mSQL', `NULL = NULL' is TRUE.  You must change `=NULL' to `IS
  28251.      NULL' and `<>NULL' to `IS NOT NULL' when porting old code from
  28252.      `mSQL' to *MySQL*.
  28253.  
  28254. *String comparisons*
  28255.  
  28256. `*MySQL*'
  28257.      Normally, string comparisons are performed in case-independent
  28258.      fashion with the sort order determined by the current character
  28259.      set (ISO-8859-1 Latin1 by default).  If you don't like this,
  28260.      declare your columns with the `BINARY' attribute, which causes
  28261.      comparisons to be done according to the ASCII order used on the
  28262.      *MySQL* server host.
  28263.  
  28264. `mSQL'
  28265.      All string comparisons are performed in case-sensitive fashion with
  28266.      sorting in ASCII order.
  28267.  
  28268. *Case-insensitive searching*
  28269.  
  28270. `*MySQL*'
  28271.      `LIKE' is a case-insensitive or case-sensitive operator, depending
  28272.      on the columns involved. If possible, *MySQL* uses indexes if the
  28273.      `LIKE' argument doesn't start with a wildcard character.
  28274.  
  28275. `mSQL'
  28276.      Use `CLIKE'.
  28277.  
  28278. *Handling of trailing spaces*
  28279.  
  28280. `*MySQL*'
  28281.      Strips all spaces at the end of `CHAR' and `VARCHAR' columns. Use
  28282.      a `TEXT' column if this behavior is not desired.
  28283.  
  28284. `mSQL'
  28285.      Retains trailing space.
  28286.  
  28287. *`WHERE' clauses*
  28288.  
  28289. `*MySQL*'
  28290.      *MySQL* correctly prioritizes everything (`AND' is evaluated
  28291.      before `OR'). To get `mSQL' behavior in *MySQL*, use parentheses
  28292.      (as shown below).
  28293.  
  28294. `mSQL'
  28295.      Evaluates everything from left to right. This means that some
  28296.      logical calculations with more than three arguments cannot be
  28297.      expressed in any way. It also means you must change some queries
  28298.      when you upgrade to *MySQL*. You do this easily by adding
  28299.      parentheses.  Suppose you have the following `mSQL' query:
  28300.           mysql> SELECT * FROM table WHERE a=1 AND b=2 OR a=3 AND b=4;
  28301.      To make *MySQL* evaluate this the way that `mSQL' would, you must
  28302.      add parentheses:
  28303.           mysql> SELECT * FROM table WHERE (a=1 AND (b=2 OR (a=3 AND (b=4))));
  28304.  
  28305. *Access control*
  28306.  
  28307. `*MySQL*'
  28308.      Has tables to store grant (permission) options per user, host and
  28309.      database. *Note Privileges::.
  28310.  
  28311. `mSQL'
  28312.      Has a file `mSQL.acl' in which you can grant read/write privileges
  28313.      for users.
  28314.  
  28315. `'
  28316. How MySQL compares to PostgreSQL
  28317. ================================
  28318.  
  28319. We would first like to note that `PostgreSQL' and *MySQL* are both
  28320. widely used products but their design goals are completely different.
  28321. This means that for some applications *MySQL* is more suitable and for
  28322. others `PostgreSQL' is more suitable.  When choosing which database to
  28323. use you should first check if the databases feature set is good enough
  28324. to satisfy your application.  If you need speed then *MySQL* is
  28325. probably your best choice, if you need some of the extra features that
  28326. `PostgreSQL' can offer you should use `PostgreSQL'.
  28327.  
  28328. `PostgreSQL' has some more advanced features like user-defined types,
  28329. triggers, rules and some transaction support (currently it's has about
  28330. same symantic as `MySQL''s transactions in that the transaction is not
  28331. 100 % atomic) . However, PostgreSQL lacks many of the standard types
  28332. and functions from ANSI SQL and ODBC. See the `crash-me' web page
  28333. (http://www.mysql.com/information/crash-me.php) for a complete list of
  28334. limits and which types and functions are supported or unsupported.
  28335.  
  28336. Normally, `PostgreSQL' is a magnitude slower than *MySQL*. *Note
  28337. Benchmarks::.  This is due largely to they have only transaction safe
  28338. tables and that their transactions system is not as sophisticated as
  28339. Berkeley DB's.  In *MySQL* you can decide per table if you want the
  28340. table to be fast or take the speed penalty of making it transaction
  28341. safe.
  28342.  
  28343. The most important things that `PostgreSQL' supports that *MySQL* don't
  28344. yet support:
  28345.  
  28346. `Sub select'
  28347.  
  28348. `Foregin keys'
  28349.  
  28350. `Stored procedures'
  28351.  
  28352. `An extendable type system.'
  28353.  
  28354. `A way to extend the SQL to handle new key types (like R-trees)'
  28355. *MySQL* on the other hand supports a many ANSI SQL constructs that
  28356. `PostgreSQL' doesn't support;  Most of these can be found at the
  28357. `crash-me' web page (http://www.mysql.com/information/crash-me.php).
  28358.  
  28359. If you really need the rich type system `PostgreSQL' offers and you can
  28360. afford the speed penalty of having to do everything transaction safe,
  28361. you should take a look at `PostgreSQL'.
  28362.  
  28363. MySQL internals
  28364. ***************
  28365.  
  28366. This chapter describes a lot of things that you need to know when
  28367. working on the *MySQL* code.
  28368.  
  28369. MySQL threads
  28370. =============
  28371.  
  28372. The *MySQL* server creates the the following threads:
  28373.  
  28374.    * The TCP/IP connection thread handles all connect requests and
  28375.      creates a new dedicated thread to handle the authentication and
  28376.      and SQL query processing for the connection.
  28377.  
  28378.    * On NT there is a named pipe handler thread that does the same work
  28379.      as the TCP/IP connection thread on named pipe connect requests.
  28380.  
  28381.    * The signal thread handles all signals. This thread also normally
  28382.      handles alarms and calls `process_alarm()' to force timeouts on
  28383.      connections that have been idle too long.
  28384.  
  28385.    * If compiled with `-DUSE_ALARM_THREAD', a dedicated thread that
  28386.      handles alarms is created. This is only used on some systems where
  28387.      there are some problems with `sigwait()' or if one wants to use the
  28388.      `thr_alarm()' code in ones application without a dedicated signal
  28389.      handling thread.
  28390.  
  28391.    * If one uses the `--flush_time=#' option, a dedicated thread is
  28392.      created to flush all tables at the given interval.
  28393.  
  28394.    * Every connection has its own thread.
  28395.  
  28396.    * Every different table on which one uses `INSERT DELAYED' gets its
  28397.      own thread.
  28398.  
  28399.    * If you use `--master-host' , slave replication thread will be
  28400.      started to read and apply updates from the master.
  28401.  
  28402. `mysqladmin processlist' only shows the connection and `INSERT DELAYED'
  28403. threads.
  28404.  
  28405. Environment variables
  28406. *********************
  28407.  
  28408. Here follows a list of all environment variables that are used directly
  28409. or indirectly by *MySQL*. Most of these can also be found at other
  28410. places in this manual.
  28411.  
  28412. Note that any options on the command line will take precedence over
  28413. values specified in configuration files and environment variables, and
  28414. values in configuration files take precedence over values in environment
  28415. variables.
  28416.  
  28417. In many cases its preferable to use a configure file instead of
  28418. environment variables to modify the behaviour of *MySQL*. *Note Option
  28419. files::.
  28420.  
  28421. `CCX'          Set this to your C++ compiler when running configure.
  28422. `CC'           Set this to your C compiler when running configure.
  28423. `CFLAGS'       Flags for your C compiler when running configure.
  28424. `CXXFLAGS'     Flags for your C++ compiler when running configure.
  28425. `DBI_USER'     The default user name for Perl DBI.
  28426. `DBI_TRACE'    Used when tracing Perl DBI.
  28427. `HOME'         The default path for the `mysql' history file is
  28428.                `$HOME/.mysql_history'.
  28429. `LD_RUN_PATH'  Used to specify where your `libmysqlclient.so' is.
  28430. `MYSQL_DEBUG'  Debug-trace options when debugging
  28431. `MYSQL_HISTFILE'The path to the `mysql' history file.
  28432. `MYSQL_HOST'   Default host name used by the `mysql' command line prompt.
  28433. `MYSQL_PWD'    The default password when connecting to mysqld. Note that
  28434.                use of this is insecure!
  28435. `MYSQL_TCP_PORT'The default TCP/IP port.
  28436. `MYSQL_UNIX_PORT'The default socket; used for connections to `localhost'.
  28437. `PATH'         Used by the shell to finds the *MySQL* programs.
  28438. `TMPDIR'       The directory where temporary tables/files are created.
  28439. `TZ'           This should be set to your local timezone. *Note Timezone
  28440.                problems::.
  28441. `UMASK_DIR'    The user-directory creation mask when creating
  28442.                directories. Note that this is ANDed with `UMASK'!
  28443. `UMASK'        The user-file creation mask when creating files.
  28444. `USER'         The default user on Windows to use when connecting to
  28445.                `mysqld'.
  28446.  
  28447. Some MySQL users
  28448. ****************
  28449.  
  28450. General news sites
  28451. ==================
  28452.  
  28453.    * Yahoo! (http://www.yahoo.com/)
  28454.  
  28455.    * Slashdot: A pro-Linux/tech news and comment/discussion site
  28456.      (http://slashdot.org/)
  28457.  
  28458.    * All about Linux (http://www.linux.com/)
  28459.  
  28460.    * Linuxtoday (http://www.linuxtoday.com/)
  28461.  
  28462.    * 32Bits Online: because there's more than one way to compute
  28463.      (http://www.32bitsonline.com/)
  28464.  
  28465.    * Freshmeat: News about new versions of computer related stuff
  28466.      (http://www.freshmeat.net/)
  28467.  
  28468.  
  28469. Some Web search engines
  28470. =======================
  28471.  
  28472.    * AAA Matilda Web Search (http://www.aaa.com.au)
  28473.  
  28474.    * What's New (http://www.whatsnu.com/)
  28475.  
  28476.    * Aladin (http://www.aladin.de/)
  28477.  
  28478.    * Columbus Finder (http://www.columbus-finder.de/)
  28479.  
  28480.    * Spider (http://www.spider.de/)
  28481.  
  28482.    * Blitzsuche (http://www.blitzsuche.de/)
  28483.  
  28484.    * Indoseek Indonesia (http://www.indoseek.co.id)
  28485.  
  28486.    * Yaboo - Yet Another BOOkmarker (http://www.yaboo.dk/)
  28487.  
  28488.    * OzSearch Internet Guide (http://www.ozsearch.com.au)
  28489.  
  28490.    * Splat! Search (http://www.splatsearch.com/)
  28491.  
  28492.    * The Open Source Digital Library System Project
  28493.      (http://osdls.library.arizona.edu/)
  28494.  
  28495. Some Information search engines concentrated on some area
  28496. =========================================================
  28497.  
  28498.    * TuCows Network; Free Software archive (http://www.tucows.com/)
  28499.  
  28500.    * Jobvertise: Post and search for jobs (http://www.jobvertise.com)
  28501.  
  28502.    * The Music Database (http://www.musicdatabase.com)
  28503.  
  28504.    * Fotball (Soccer) search page (http://www.soccersearch.com)
  28505.  
  28506.    * TAKEDOWN - wrestling (http://www.headrush.net/takedown)
  28507.  
  28508.    * The International Lyrics Network (http://www.lyrics.net)
  28509.  
  28510.    * Musicians looking for other musicians (Free Service)
  28511.      (http://TheMatrix.com/~matrix/band_search.phtml)
  28512.  
  28513.    * AddALL books searching and price comparison
  28514.      (http://www.addall.com/AddBooks/Stores.html)
  28515.  
  28516.    * Harvard's Gray Herbarium Index of Plant Names
  28517.      (http://www.herbaria.harvard.edu/Data/Gray/gray.html)
  28518.  
  28519.    * The Game Development Search Engine (http://www.game-developer.com/)
  28520.  
  28521.    * My-Recipe.com; Cookbook at i-run.com
  28522.      (http://www.i-run.com/html/cookbook.html)
  28523.  
  28524.    * The Innkeeper Vacation Guides (www.theinnkeeper.com)
  28525.  
  28526.    * The Mac Game Database uses PHP and MySQL
  28527.      (http://www.macgamedatabase.com/)
  28528.  
  28529.    * Research Publications at Monash University in Australia
  28530.      (http://www.csse.monash.edu.au/publications/)
  28531.  
  28532.    * Occupational Health & Safety website databse (a project for the
  28533.      ECC) (http://www.ipielle.emr.it/bts/index.html)
  28534.  
  28535.    * Bioinformatics databases at the Montreal Children's Hospital using
  28536.      MySQL (http://data.mch.mcgill.ca/)
  28537.  
  28538. Online magazines
  28539. ================
  28540.  
  28541.    * Spoiler Webzine (http://www.spoiler.com).  An online magazine
  28542.      featuring music, literature, arts, and design content.
  28543.  
  28544.    * Daily news about Linux in German language
  28545.      (http://www.linux-magazin.de/newsflash/)
  28546.  
  28547.    * Betazine - The Ultimate Online Beta Tester's Magazine
  28548.      (http://www.betazine.com)
  28549.  
  28550.    * Computer Currents Magazine
  28551.      (http://www.currents.net/ccinfo/aboutcc.html)
  28552.  
  28553. Web sites that use MySQL as a backend
  28554. =====================================
  28555.  
  28556.    * Qt Widget and Object Repository (http://lindev.jmc.tju.edu/qwor)
  28557.  
  28558.    * Brazilian samba site (in Portuguese)
  28559.      (http://www.samba-choro.com.br)
  28560.  
  28561.    * Polish General Social Survey
  28562.      (http://pgss.iss.uw.edu.pl/en_index.ISS)
  28563.  
  28564.    * Expo2000 (http://www.expo2000.com) World-wide distribution of
  28565.      tickets for this event is implemented using *MySQL* and tcl/tk.
  28566.      More than 5000 travel-agencies all over the world have access to
  28567.      it.
  28568.  
  28569.    * FreeVote.com is a free voting service with millions of users.
  28570.      (http://www.freevote.com/)
  28571.  
  28572.    * Forza Motorsport (http://f1.tauzero.se)
  28573.  
  28574. Some Domain/Internet/Web and related services
  28575. =============================================
  28576.  
  28577.    * Registry of Web providers that support *MySQL*
  28578.      (http://www.wix.com/mysql-hosting)
  28579.  
  28580.    * Dynamic DNS Services (http://www.yi.org/)
  28581.  
  28582.    * Dynamic domain name service (http://www.dynodns.net/)
  28583.  
  28584.    * Open DNS Project; free dynamic DNS service (http://www.ods.org/)
  28585.  
  28586.    * Free 3rd level domains (http://www.fdns.net/)
  28587.  
  28588.    * Online Database (http://worldcommunity.com/)
  28589.  
  28590.    * BigBiz Internet Services (http://www.bigbiz.com)
  28591.  
  28592.    * The Virt Gazette (http://virt.circle.net)
  28593.  
  28594.    * Global InfoNet Inc (http://www.california.com)
  28595.  
  28596.    * WebHosters - A Guide to WWW Providers (http://www.webhosters.com)
  28597.  
  28598.    * Internet information server (http://online.dn.ru)
  28599.  
  28600.    * A technology news site (http://www.stopbit.com)
  28601.  
  28602.    * WorldNet Communications - An Internet Services Provider
  28603.      (http://www.worldnetla.net)
  28604.  
  28605.    * Netizen: Australian-based web consultancy
  28606.      (http://www.netizen.com.au/)
  28607.  
  28608.    * Search site for training courses in the UK
  28609.      (http://www.trainingpages.co.uk)
  28610.  
  28611.    * Gannon Chat (GPL). Written in Perl and Javascript
  28612.      (http://chat.nitco.com)
  28613.  
  28614.    * A general links directory (http://www.addurls.com/)
  28615.  
  28616.    * A web-based bookmark management service
  28617.      (http://www.bookmarktracker.com)
  28618.  
  28619.    * Walnut Creek CDROM (http://www.cdrom.com)
  28620.  
  28621.    * WWWThreads; Interactive discussion Forums
  28622.      (http://www.wwwthreads.org/)
  28623.  
  28624.    * In Italian; Storage data from meteo station
  28625.      (http://pvmon.portici.enea.it/Meteo)
  28626.  
  28627.    * Online "Person To Person" Auction (http://www.buysell.net/)
  28628.  
  28629.    * Tips on web development (http://tips.pair.com)
  28630.  
  28631.    * Mailfriends.com is a FREE service for everybody who wants to find
  28632.      friends over the internet. (http://www.mailfriends.com)
  28633.  
  28634.    * Web Page Telnet BBS List
  28635.      (http://www.uninova.com/cgi-bin/wctelnets?list)
  28636.  
  28637.    * UniNova Digital Postcards (http://www.uninova.com/cnc.html)
  28638.  
  28639.    * DSL providers search with reviews (http://www.dslreports.com) Made
  28640.      with *MySQL* and Modperl, all pages are generated dynamically out
  28641.      of the *MySQL* database
  28642.  
  28643. Web sites that use `PHP' and MySQL
  28644. ==================================
  28645.  
  28646.    * Jgaa's Internet - Official Support Site
  28647.      (http://war.jgaa.com:8080/support/index.php3)
  28648.  
  28649.    * Ionline - online publication: (http://io.incluso.com) *MySQL*,
  28650.      PHP, Java, Web programming, DB development
  28651.  
  28652.    * BaBoo(Browse and bookmark). Free web-based bookmark manager and
  28653.      Calendar (http://www.baboo.com)
  28654.  
  28655.    * Course Schedule System at Pensacola Junior College
  28656.      (http://www.courses.pjc.cc.fl.us/Schedule/index.php)
  28657.  
  28658.    * Florida Community College at Jacksonville (http://www.fccj.org)
  28659.  
  28660.    * 32bit.com; An extensive shareware / freeware archive
  28661.      (http://www.32bit.com/)
  28662.  
  28663.    * Jokes 2000 (http://www.jokes2000.com/)
  28664.  
  28665.    * Burken.NU (http://www.burken.nu/) Burken is a webhotel that
  28666.      provides scripts, among other things, for remote users, like
  28667.      counters, guestbooks etc.
  28668.  
  28669.    * tips.pair.com (http://tips.pair.com) Contains tips on html,
  28670.      javascript, 2d/3d graphics and PHP3/MySQL. All pages are generated
  28671.      from a database.
  28672.  
  28673.  
  28674. Some MySQL consultants
  28675. ======================
  28676.  
  28677.    * Ayni AG (http://www.ayni.com)
  28678.  
  28679.    * Online Database (http://worldcommunity.com/)
  28680.  
  28681.    * DataGuard (Uses *MySQL* and PHP) (http://www2.dataguard.no/)
  28682.  
  28683.    * WWITS (Uses *MySQL* and PHP)
  28684.      (http://wwits.net/programs/mysql.phtml)
  28685.  
  28686.    * WCN - The World Community Network (http://www.worldcommunity.com/)
  28687.  
  28688.    * Chip Castle Dot Com Inc (http://www.chipcastle.com)
  28689.  
  28690.    * Cybersource Pty. Ltd (http://www.cyber.com.au/)
  28691.  
  28692.    * Spring infotainment gmbh & co. kg (http://www.spring.de)
  28693.  
  28694.    * Develops websites using MySQL (http://www.wamdesign.com/)
  28695.  
  28696.    * Berkeley Consultants Group (http://www.berkeleyconsultants.com)
  28697.  
  28698.  
  28699. Programming
  28700. ===========
  28701.  
  28702.    * The Perl CPAN Testers results page
  28703.      (http://www.perl.org/cpan-testers)
  28704.  
  28705. Uncategorized pages
  28706. ===================
  28707.  
  28708.    * AZC.COM's Feature Showcase
  28709.      (http://www.feature-showcase.com/htmls/demo_mysql.sql)
  28710.  
  28711.    * Course Search
  28712.      (http://www.teach.org.uk/subjects/trainingcourse/g.html)
  28713.  
  28714.    * Northerbys Online Auctions (http://www.northerbys.com)
  28715.  
  28716.    * Amsterdam Airport Schiphol
  28717.      (http://www.schiphol.nl/flights/home.htm)
  28718.  
  28719.    * CD database (http://TheMatrix.com/seventhsin/query.phtml)
  28720.  
  28721.    * Used Audio Gear Database (http://TheMatrix.com/~flmm/GEAR.html)
  28722.  
  28723.    * Musical note-sheets (http://www.kiss.de/musik-mueller)
  28724.  
  28725.    * Bagism - A John Lennon fan page (http://www.bagism.com)
  28726.  
  28727.    * US Folk art broker (http://www.selftaught.com/)
  28728.  
  28729.    * Mail reading on the web (http://organizer.net/)
  28730.  
  28731.    * Free home pages on www.somecoolname.mypage.org
  28732.      (http://www.mypage.org/)
  28733.  
  28734.    * Der Server fu"r Schulen im Web (In German)
  28735.      (http://www.schulweb.de/)
  28736.  
  28737.    * Auldhaefen Online Services (http://www.ald.net/)
  28738.  
  28739.    * CaryNET Information Center (http://www.cary.net/)
  28740.  
  28741.    * Dataden Computer Systems (http://www.dataden.com/)
  28742.  
  28743.    * Andre'museet (In Swedish) (http://andree.grm.se/)
  28744.  
  28745.    * HOMESITE Internet Marketing (http://www.him.net/)
  28746.  
  28747.    * Jade-V Network Services (http://www.jade-v.com/techinfo.html)
  28748.  
  28749.    * Weather World 2010 Technical Credits
  28750.      (http://ww2010.atmos.uiuc.edu/(Gl)/abt/aknw/tech.rxml)
  28751.    * About The Gimp plugin registry
  28752.      (http://gimp.foebud.org/registry/doc/)
  28753.  
  28754.    * Java tool Archiver technical detail (Slightly optimistic about
  28755.      *MySQL* ANSI-92 compliance)
  28756.      (http://www.fast-inc.com/Products/Archiver/database.html)
  28757.  
  28758.    * Games Domain Cheats Database
  28759.      (http://www.gamesdomain.com/cheats/usrcheat.phtml)
  28760.  
  28761.    * The "Powered By" Page (Kcilink) (http://www.kcilink.com/poweredby/)
  28762.  
  28763.    * Netcasting (http://www.netcasting.net/index.whtml)
  28764.  
  28765.    * NBL (Australian National Basketball League) tipping
  28766.      (http://homepages.tig.com.au/~mjj/nbltips)
  28767.  
  28768.    * CGI shop (http://www.cgishop.com/)
  28769.  
  28770.    * Whirlycott: Website Design (http://www.whirlycott.com/)
  28771.  
  28772.    * Museum Tusculanum Press (http://www.mtp.dk)
  28773.  
  28774.    * Centro Siciliano di Documentazione
  28775.      (http://csdgi.historie.ku.dk/biblio)
  28776.  
  28777.    * Quake statistics database (http://caribou.dyn.ml.org:8000)
  28778.  
  28779.    * Astroforum: Astrologie and related things (in German)
  28780.      (http://www.astroforum.ch)
  28781.  
  28782.    * OpenDebate - Interactive Polls & Open Discussion
  28783.      (http://www.opendebate.com)
  28784.  
  28785.    * Online chemical dissertation server
  28786.      (http://vermeer.organik.uni-erlangen.de/dissertationen/)
  28787.  
  28788.    * FreSch! The Free Scholarship Search Service
  28789.      (http://www.freschinfo.com)
  28790.  
  28791.    * Stockholm Pinball Locator
  28792.      (http://www.nada.kth.se/~staffanu/pinball)
  28793.  
  28794.    * HEK A construction company (http://www.hek.com)
  28795.  
  28796.    * Elsevier Bussines Information (http://www.nbi.nl)
  28797.  
  28798.    * Medical Links (Using ColdFusion and *MySQL*)
  28799.      (http://vaccination.medicallink.se/)
  28800.  
  28801.    * Search for jobs & people at JobLink-USA
  28802.      (http://www.joblink-usa.com)
  28803.  
  28804.    * Competition Formation Skydiving (http://www.skydive.net/competfs)
  28805.  
  28806.    * E-commerce and internal accounting
  28807.      (http://www.galaxy-net.net/Galaxy-NET Telecommunications)
  28808.  
  28809.    * Denmark's leading business daily newspaper B/orsen
  28810.      (http://www.borsen.dk/)
  28811.  
  28812.    * The Internet NES Database (http://tmmm.simplenet.com/indb/)
  28813.  
  28814.    * Travel agency in Prague in 3 languages (http://www.russia.cz)
  28815.  
  28816.    * Linkstation (http://www.linkstation.de)
  28817.  
  28818.    * Searchable online database at Peoplestaff
  28819.      (http://www.peoplestaff.com)
  28820.  
  28821.    * A searchable database system for horse classified ads
  28822.      (http://www.dreamhorse.com)
  28823.  
  28824.    * The Poot site (http://pootpoot.com/)
  28825.  
  28826.    * "Playin' in the LAN"; a network monitoring suite
  28827.      (http://grateful.net/hw_html/)
  28828.  
  28829.    * U.S. Army Publishing Agency (http://www.usapa.army.mil)
  28830.  
  28831.    * Realestate handling in Yugoslavia (http://www.nekretnine.co.yu/)
  28832.  
  28833.    * PIMS; a Patient Information Management System
  28834.      (http://demo.cpsoft.com/pims/devFAQ.html)
  28835.  
  28836.    * Pilkington Software Inc (http://cpsoft.com)
  28837.  
  28838.    * A Vietnam Veteran's Memorial (The Wall) database.
  28839.      (http://www.no-quarter.org/)
  28840.  
  28841.    * Gamer's Union specializes inauctions of used & out of print gaming
  28842.      material (http://www.gamers-union.com/)
  28843.  
  28844.    * A daily bulletin at Monterey High school
  28845.      (http://www.montereyhigh.com/office/dbul.php3)
  28846.  
  28847.    * Community-owned site serving Lake Washington's Eastside residents
  28848.      and businesses (http://www.myEastside.com)
  28849.  
  28850.    * French bowling site (http://bowling-france.net/).
  28851.  
  28852. Send any additions to this list to <webmaster@mysql.com>.
  28853.  
  28854. Contributed programs
  28855. ********************
  28856.  
  28857. Many users of *MySQL* have contributed _very_ useful support tools and
  28858. addons.
  28859.  
  28860. A list of what is available at `http://www.mysql.com/Downloads/Contrib/'
  28861. (or any mirror) is shown below.  If you want to build *MySQL* support
  28862. for the Perl `DBI'/`DBD' interface, you should fetch the `Data-Dumper',
  28863. `DBI', and `Msql-Mysql-modules' files and install them.  *Note Perl
  28864. support::.
  28865.  
  28866. 00-README (http://www.mysql.com/Downloads/Contrib/00-README) This
  28867. listing.
  28868.  
  28869. API's
  28870. =====
  28871.  
  28872.    * Perl modules
  28873.         * Data-Dumper-2.101.tar.gz
  28874.           (http://www.mysql.com/Downloads/Contrib/Data-Dumper-2.101.tar.gz)
  28875.           Perl `Data-Dumper' module.  Useful with `DBI'/`DBD' support
  28876.           for older perl installations.
  28877.  
  28878.         * DBI-1.13.tar.gz
  28879.           (http://www.mysql.com/Downloads/Contrib/DBI-1.13.tar.gz) Perl
  28880.           `DBI' module.
  28881.  
  28882.         * KAMXbase1.0.tar.gz
  28883.           (http://www.mysql.com/Downloads/Contrib/KAMXbase1.0.tar.gz)
  28884.           Convert between `.dbf' files and *MySQL* tables.  Perl module
  28885.           written by Pratap Pereira <pereira@ee.eng.ohio-state.edu>,
  28886.           extened by Kevin A. McGrail
  28887.           <kmcgrail@digital1.peregrinehw.com>.  This converter can
  28888.           handle MEMO fields.
  28889.  
  28890.         * Msql-Mysql-modules-1.2214.tar.gz
  28891.           (http://www.mysql.com/Downloads/Contrib/Msql-Mysql-modules-1.2214.tar.gz)
  28892.           Perl `DBD' module to access mSQL and *MySQL* databases..
  28893.  
  28894.         * Data-ShowTable-3.3.tar.gz
  28895.           (http://www.mysql.com/Downloads/Contrib/Data-ShowTable-3.3.tar.gz)
  28896.           Perl `Data-ShowTable' module.  Useful with `DBI'/`DBD'
  28897.           support.
  28898.  
  28899.    * JDBC
  28900.         * mm.mysql.jdbc-1.2c.tar.gz
  28901.           (http://www.mysql.com/Downloads/Contrib/mm.mysql.jdbc-1.2c.tar.gz)
  28902.           The mm JDBC driver for *MySQL*. This is a production release
  28903.           and is actively developed. By Mark Matthews
  28904.           (<mmatthew@ecn.purdue.edu>).
  28905.  
  28906.         * mm.mysql.jdbc-2.0pre5.tar.gz
  28907.           (http://www.mysql.com/Downloads/Contrib/mm.mysql.jdbc-2.0pre5.tar.gz)
  28908.           The mm JDBC driver for *MySQL*. This is a pre-release beta
  28909.           version and is actively developed. By Mark Matthews
  28910.           (<mmatthew@ecn.purdue.edu>).  The two drivers above have an
  28911.           LGPL license. Please check
  28912.           `http://www.worldserver.com/mm.mysql/' for the latest drivers
  28913.           (and other JDBC information) because these drivers may be out
  28914.           of date.
  28915.  
  28916.         * twz1jdbcForMysql-1.0.4-GA.tar.gz
  28917.           (http://www.mysql.com/Downloads/Contrib/twz1jdbcForMysql-1.0.4-GA.tar.gz)
  28918.           The twz driver: A type 4 JDBC driver by Terrence W. Zellers
  28919.           <zellert@voicenet.com>.  This is commercial but is free for
  28920.           private and educational use.
  28921.  
  28922.         *        * pmdamysql.tgz
  28923.           (http://www.mysql.com/Downloads/Contrib/pmdamysql.tgz) A
  28924.           *MySQL* PMDA. Provides *MySQL* server status and configuration
  28925.           variables.
  28926.  
  28927.    * C++
  28928.         * mysql-c++-0.02.tar.gz
  28929.           (http://www.mysql.com/Downloads/Contrib/mysql-c++-0.02.tar.gz)
  28930.           *MySQL* C++ wrapper library. By Roland Haenel,
  28931.           <rh@ginster.net>.
  28932.  
  28933.         * MyDAO (http://www.mysql.com/Downloads/Contrib/MyDAO.tar.gz)
  28934.           *MySQL* C++ API. By Satish <spitfire@pn3.vsnl.net.in>.
  28935.           Inspired by Roland Haenel's C++ API and Ed Carp's MyC library.
  28936.  
  28937.         * mysql++ (http://www.mysql.com/download_mysql++.html) *MySQL*
  28938.           C++ API (More than just a wrapper library). Originally by
  28939.           <kevina@clark.net>. Nowadays maintained by Sinisa at MySQL AB.
  28940.  
  28941.         * NJrAPI (http://nelsonjr.homepage.com/NJrAPI) A C++ database
  28942.           independent library that supports *MySQL*.
  28943.  
  28944.    * Delphi
  28945.         * delphi-interface.gz
  28946.           (http://www.mysql.com/Downloads/Contrib/delphi-interface.gz)
  28947.           Delphi interface to `libmysql.dll', by Blestan Tabakov,
  28948.           <root@tdg.bis.bg>.
  28949.  
  28950.         * DelphiMySQL2.zip
  28951.           (http://www.mysql.com/Downloads/Contrib/DelphiMySQL2.zip)
  28952.           Delphi interface to `libmysql.dll', by
  28953.           <bsilva@umesd.k12.or.us>
  28954.  
  28955.         * Udmysql.pas
  28956.           (http://www.mysql.com/Downloads/Contrib/Udmysel.pas) A
  28957.           wrapper for libmysql.dll for usage in Delphi. By Reiner
  28958.           Sombrowsky.
  28959.  
  28960.         * A Delphi interface to *MySQL*.
  28961.           (http://www.fichtner.net/delphi/mysql.delphi.phtml) With
  28962.           source code. By Matthias Fichtner.
  28963.  
  28964.         * *TmySQL* A library to use *MySQL* with Delphi
  28965.           (http://www.productivity.org/projects/mysql/)
  28966.  
  28967.         * Delphi TDataset-component
  28968.           (http://www.geocities.com/CapeCanaveral/2064/mysql.html)
  28969.  
  28970.    * mysql-ruby-2.2.0.tar.gz
  28971.      (http://www.mysql.com/Downloads/Contrib/mysql-ruby-2.2.0.tar.gz)
  28972.      *MySQL* Ruby module. By TOMITA Masahiro <tommy@tmtm.org> Ruby
  28973.      (http://www.netlab.co.jp/ruby/) is an Object-Oriented Interpreter
  28974.      Language.
  28975.  
  28976.    * JdmMysqlDriver-0.1.0.tar.gz
  28977.      (http://www.mysql.com/Downloads/Contrib/JdmMysqlDriver-0.1.0.tar.gz)
  28978.      A VisualWorks 3.0 Smalltalk driver for *MySQL*. By
  28979.      <joshmiller@earthlink.net>
  28980.  
  28981.    * Db.py (http://www.mysql.com/Downloads/Contrib/Db.py) Python module
  28982.      with caching. By <gandalf@rosmail.com>.
  28983.  
  28984.    * MySQLmodule-1.4.tar.gz
  28985.      (http://www.mysql.com/Downloads/Contrib/MySQLmodule-1.4.tar.gz)
  28986.      Python interface for *MySQL*. By Joseph Skinner
  28987.      <joe@earthlight.co.nz>;  Modified by Joerg Senekowitsch
  28988.      <senekow@ibm.net>
  28989.  
  28990.    * mysql_mex_1_1.tar.gz
  28991.      (http://www.mysql.com/Downloads/Contrib/mysql_mex_1_1.tar.gz) An
  28992.      interface program for the Matlab program by MathWorks.  The
  28993.      interface is done by Kimmo Uutela and John Fisher (not by
  28994.      Mathworks).  Check mysqlmex.html
  28995.      (http://boojum.hut.fi/~kuutela/mysqlmex.html) for more information.
  28996.  
  28997.    * mysqltcl-1.53.tar.gz
  28998.      (http://www.mysql.com/Downloads/Contrib/mysqltcl-1.53.tar.gz) Tcl
  28999.      interface for *MySQL*. Based on `msqltcl-1.50.tar.gz'.  Updated by
  29000.      Tobias Ritzau, <tobri@ida.liu.se>.
  29001.  
  29002.    * MyC-0.1.tar.gz
  29003.      (http://www.mysql.com/Downloads/Contrib/MyC-0.1.tar.gz) A Visual
  29004.      Basic-like API, by Ed Carp.
  29005.  
  29006.    * sqlscreens-1.0.1.tar.gz
  29007.      (http://www.mysql.com/Downloads/Contrib/sqlscreens-1.0.1.tar.gz)
  29008.      Tcl/Tk code to generate database screens. By Jean-Francois Dockes.
  29009.  
  29010.    * Vdb-dflts-2.1.tar.gz
  29011.      (http://www.mysql.com/Downloads/Contrib/Vdb-dflts-2.1.tar.gz) This
  29012.      is a new version of a set of library utilities intended to provide
  29013.      a generic interface to SQL database engines such that your
  29014.      application becomes a 3-tiered application.  The advantage is that
  29015.      you can easily switch between and move to other database engines by
  29016.      implementing one file for the new backend without needing to make
  29017.      any changes to your applications. By <damian@cablenet.net>.
  29018.  
  29019.    * DbFramework-1.10.tar.gz
  29020.      (http://www.mysql.com/Downloads/Contrib/DbFramework-1.10.tar.gz)
  29021.      DbFramework is a collection of classes for manipulating *MySQL*
  29022.      databases.  The classes are loosely based on the CDIF Data Model
  29023.      Subject Area. By Paul Sharpe <paul@miraclefish.com>.
  29024.  
  29025.    * pike-mysql-1.4.tar.gz
  29026.      (http://www.mysql.com/Downloads/Contrib/pike-mysql-1.4.tar.gz)
  29027.      *MySQL* module for pike. For use with the Roxen web server.
  29028.  
  29029.    * squile.tar.gz
  29030.      (http://www.mysql.com/Downloads/Contrib/squile.tar.gz) Module for
  29031.      `guile' that allows `guile' to interact with SQL databases. By Hal
  29032.      Roberts.
  29033.  
  29034.    * stk-mysql.tar.gz
  29035.      (http://www.mysql.com/Downloads/Contrib/stk-mysql.tar.gz)
  29036.      Interface for Stk. Stk is the Tk widgets with Scheme underneath
  29037.      instead of Tcl.  By Terry Jones
  29038.  
  29039.    * eiffel-wrapper-1.0.tar.gz
  29040.      (http://www.mysql.com/Downloads/Contrib/eiffel-wrapper-1.0.tar.gz).
  29041.      Eiffel wrapper by Michael Ravits.
  29042.  
  29043. Clients
  29044. =======
  29045.  
  29046.    * Graphical clients
  29047.         * mysqlgui homepage (http://www.mysql.com/download_clients.html)
  29048.           The *MySQL* GUI client homepage. By Sinisa at MySQL AB.
  29049.  
  29050.         * kmysqladmin-0.4.1.tar.gz
  29051.           (http://www.mysql.com/Downloads/Contrib/kmysqladmin-0.4.1.tar.gz)
  29052.  
  29053.         * kmysqladmin-0.4.1-1.src.rpm
  29054.           (http://www.mysql.com/Downloads/Contrib/kmysqladmin-0.4.1-1.src.rpm)
  29055.  
  29056.         * kmysqladmin-0.4.1-1.i386.rpm
  29057.           (http://www.mysql.com/Downloads/Contrib/kmysqladmin-0.4.1-1.i386.rpm)
  29058.           An administration tool for the *MySQL* server using QT / KDE.
  29059.           Tested only on Linux.
  29060.  
  29061.         * Java client using Swing
  29062.           (http://www.mysql.com/Downloads/Contrib/mysql-admin-using-java+swing.tar.gz)
  29063.           By Fredy Fischer, <se-afs@dial.eunet.ch>. You can always find
  29064.           the latest version here
  29065.           (http://www.trash.net/~ffischer/admin/index.html).
  29066.  
  29067.         * mysqlwinadmn.zip
  29068.           (http://www.mysql.com/Downloads/Contrib/mysqlwinadmn.zip)
  29069.           Win32 GUI (binary only) to administrate a database, by David
  29070.           B. Mansel, <david@zhadum.org>.
  29071.  
  29072.         * netadmin.zip
  29073.           (http://www.mysql.com/Downloads/Contrib/netadmin.zip) An
  29074.           administrator tool for *MySQL* on Windows 95/98 and Windows NT
  29075.           4.0. Only tested with *MySQL* 3.23.5 - 3.23.7. Written using
  29076.           the Tmysql components.
  29077.  
  29078.           You can write queries and show tables, indexes, table syntax
  29079.           and administrate user,host and database and so on. The is
  29080.           still beta and have still some bugs. you can test the program
  29081.           with all features. Please send bugs and hints to Marco Suess
  29082.           <ms@it-netservice.de>. Original URL
  29083.           <http://www.it-netservice.de/pages/software/index.html>.
  29084.  
  29085.         * Atronic's *MySQL* client for Win32 1.3.0.0
  29086.           (http://www.mysql.com/Downloads/Win32/admin13.exe) and
  29087.           Atronic's *MySQL* client readme
  29088.           (http://www.mysql.com/Downloads/Win32/admin13.readme).  Home
  29089.           page for this can be found at: `http://www.artronic.hr'.
  29090.  
  29091.         * Utility from Artronic to stop MySQL on win9x
  29092.           (http://www.mysql.com/Downloads/Win32/W9xstop.zip)
  29093.  
  29094.         * xmysqladmin-1.0.tar.gz
  29095.           (http://www.mysql.com/Downloads/Contrib/xmysqladmin-1.0.tar.gz)
  29096.           An X based front end to the *MySQL* database engine.  It
  29097.           allows reloads, status check, process control, myisamchk,
  29098.           grant/revoke privileges, creating databases, dropping
  29099.           databases, create, alter, browse and drop tables.  Originally
  29100.           by Gilbert Therrien, <gilbert@ican.net> but now in public
  29101.           domain and supported by MySQL AB.
  29102.  
  29103.         * xmysql-1.9.tar.gz
  29104.           (http://www.mysql.com/Downloads/Contrib/xmysql-1.9.tar.gz)
  29105.  
  29106.         * xmysql home page (http://web.wt.net/~dblhack) A front end to
  29107.           the *MySQL* database engine. It allows for simple queries and
  29108.           table maintenance, as well as batch queries. By Rick
  29109.           Mehalick, <dblhack@wt.net>.  Requires xforms 0.88
  29110.           (http://bragg.phys.uwm.edu/xforms) to work.
  29111.  
  29112.         * dbMetrix (http://www.tamos.net/sw/dbMetrix) An open source
  29113.           client for exploring databases and executing SQL. Supports
  29114.           *MySQL*, Oracle, PostgreSQL and mSQL.
  29115.  
  29116.         * GtkSQL (http://www.multimania.com/bbrox/GtkSQL) A query tool
  29117.           for *MySQL* and PostgreSQL.
  29118.  
  29119.         * dbMan (http://dbman.linux.cz/) A query tool written in Perl.
  29120.           Uses DBI and Tk.
  29121.  
  29122.         * mascon1.exe
  29123.           (http://www.mysql.com/Downloads/Contrib/mascon1.exe) You can
  29124.           get the newest one from http://www.SciBit.com
  29125.           (http://www.SciBit.com).
  29126.  
  29127.         * DBUI (http://www.virtualbeer.net/dbui/) DBUI is a Gtk
  29128.           graphical database editor.
  29129.  
  29130.    * Web clients
  29131.         * mysqladmin-atif-1.0.tar.gz
  29132.           (http://www.mysql.com/Downloads/Contrib/mysqladmin-atif-1.0.tar.gz)
  29133.           WWW *MySQL* administrator for the `user,' `db' and `host'
  29134.           tables.  By Tim Sailer, modified by Atif Ghaffar
  29135.           <aghaffar@artemedia.ch>.
  29136.  
  29137.         * mysql-webadmin-1.0a8-rz.tar.gz
  29138.           (http://www.mysql.com/Downloads/Contrib/mysql-webadmin-1.0a8-rz.tar.gz)
  29139.           A tool written in PHP-FI to administrate *MySQL* databases
  29140.           remotely over the web within a Web-Browser. By Peter
  29141.           Kuppelwieser, <peter.kuppelwieser@kantea.it>. Updated by Wim
  29142.           Bonis, <bonis@kiss.de>. Not maintained anymore!
  29143.  
  29144.         * mysqladm.tar.gz
  29145.           (http://www.mysql.com/Downloads/Contrib/mysqladm.tar.gz)
  29146.           *MySQL* Web Database Administration written in Perl.  By Tim
  29147.           Sailer.
  29148.  
  29149.         * mysqladm-2.tar.gz
  29150.           (http://www.mysql.com/Downloads/Contrib/mysqladm-2.tar.gz)
  29151.           Updated version of `mysqladm.tar.gz', by High Tide.
  29152.  
  29153.         * billowmysql.zip
  29154.           (http://www.mysql.com/Downloads/Contrib/billowmysql.zip)
  29155.           Updated version of `mysqladm.tar.gz', by Ying Gao.  You can
  29156.           get the newest version from the home site
  29157.           (http://civeng.com/sqldemo/).
  29158.  
  29159.         * myadmin-0.4.tar.gz
  29160.           (http://www.mysql.com/Downloads/Contrib/myadmin-0.4.tar.gz)
  29161.  
  29162.         * MyAdmin home page (http://myadmin.cheapnet.net/) A web based
  29163.           mysql administrator by Mike Machado.
  29164.  
  29165.         * phpMyAdmin_2.0.1.tar.gz
  29166.           (http://www.mysql.com/Downloads/Contrib/phpMyAdmin_2.0.1.tar.gz)
  29167.           A set of PHP3-scripts to adminstrate *MySQL* over the WWW.
  29168.  
  29169.         * phpMyAdmin home page (http://www.htmlwizard.net/phpMyAdmin/)
  29170.           A PHP3 tool in the spirit of mysql-webadmin, by Tobias
  29171.           Ratschiller, tobias@dnet.it
  29172.  
  29173.         * useradm.tar.gz
  29174.           (http://www.mysql.com/Downloads/Contrib/useradm.tar.gz)
  29175.           *MySQL* administrator in PHP. By Ofni Thomas
  29176.           <othomas@vaidsystems.com>.
  29177.  
  29178.    * mysql-editor.tar.gz
  29179.      (http://www.mysql.com/Downloads/Contrib/mysql-editor.tar.gz) This
  29180.      cgi scripts in Perl enables you to edit content of Mysql database.
  29181.      By Tomas Zeman.
  29182.  
  29183.    * FutureSQL Web Database Administration Tool
  29184.      (http://futurerealm.com/opensource/futuresql.htm).  FutureSQL by
  29185.      Peter F. Brown, is a Free, Open Source Rapid Application
  29186.      Development web database administration tool, written in Perl,
  29187.      using *MySQL*. It uses `DBI:DBD' and `CGI.pm'.
  29188.  
  29189.      FutureSQL allows one to easily setup config files to view, edit,
  29190.      delete and otherwise process records from a *MySQL* database. It
  29191.      uses a data dictionary, configuration files and templates, and
  29192.      allows "pre-processing" and "post-processing" on both fields,
  29193.      records and operations.
  29194.  
  29195. Web tools
  29196. =========
  29197.  
  29198.    * mod_mysql_include_1.0.tar.gz
  29199.      (http://www.mysql.com/Downloads/Contrib/mod_mysql_include_1.0.tar.gz)
  29200.      Apache module to include HTML from MySQL queries into your pages,
  29201.      and run update queries.  Originally written to implement a simple
  29202.      fast low-overhead banner-rotation system.  By Sasha Pachev.
  29203.  
  29204.    * `http://www.odbsoft.com/cook/sources.htm' This package has various
  29205.      functions for generating html code from a SQL table structure and
  29206.      for generating SQL statements (Select, Insert, Update, Delete)
  29207.      from an html form. You can build a complete forms interface to a
  29208.      SQL database (query, add, update, delete) without any programming!
  29209.      By Marc Beneteau, <marc@odbsoft.com>.
  29210.  
  29211.    * sqlhtml.tar.gz
  29212.      (http://www.mysql.com/Downloads/Contrib/sqlhtml.tar.gz) SQL/HTML
  29213.      is an HTML database manager for *MySQL* using `DBI' 1.06.
  29214.  
  29215.    * UdmSearch 2.2.1b (stable version)
  29216.      (http://www.mysql.com/Downloads/Contrib/udmsearch-2.2.1b.tar.gz)
  29217.  
  29218.    * UdmSearch 3.0.5 (development version)
  29219.      (http://www.mysql.com/Downloads/Contrib/udmsearch-3.0.5.tar.gz)
  29220.  
  29221.    * UdmSearch home page (http://mysearch.udm.net) A *MySQL*- and PHP-
  29222.      based search engine over HTTP. By Alexander I. Barkov
  29223.      <bar@izhcom.ru>.
  29224.  
  29225.    * wmtcl.doc (http://www.mysql.com/Downloads/Contrib/wmtcl.doc)
  29226.  
  29227.    * wmtcl.lex (http://www.mysql.com/Downloads/Contrib/wmtcl.lex) With
  29228.      this you can write HTML files with inclusions of Tcl code. By
  29229.      <vvs@scil.npi.msu.su>.
  29230.  
  29231.    * www-sql-0.5.7.lsm
  29232.      (http://www.mysql.com/Downloads/Contrib/www-sql-0.5.7.lsm)
  29233.  
  29234.    * www-sql-0.5.7.tar.gz
  29235.      (http://www.mysql.com/Downloads/Contrib/www-sql-0.5.7.tar.gz) A
  29236.      CGI program that parses an HTML file containing special tags,
  29237.      parses them and inserts data from a *MySQL* database.
  29238.  
  29239.    * genquery.zip (http://www.mysql.com/Downloads/Contrib/genquery.zip)
  29240.      Perl SQL database interface package for html.
  29241.  
  29242.    * cgi++-0.8.tar.gz
  29243.      (http://www.mysql.com/Downloads/Contrib/cgi++-0.8.tar.gz) A
  29244.      macro-processor to simply writing CGI/Database programs in C++ by
  29245.      Sasha Pachev.
  29246.  
  29247.    * WebBoard 1.0
  29248.      (http://www.mysql.com/Downloads/Contrib/webboard-1.0.zip)
  29249.      EU-Industries Internet-Message-Board.
  29250.  
  29251.    * DBIx-TextIndex-0.02.tar.gz
  29252.      (http://www.mysql.com/Downloads/Contrib/DBIx-TextIndex-0.02.tar.gz)
  29253.      Full-text searching with Perl on `BLOB'/`TEXT' columns by Daniel
  29254.      Koch.
  29255.  
  29256. Performance Benchmarking tools
  29257. ==============================
  29258.  
  29259.    * mysql-super-smack and friends
  29260.      (http://www.mysql.com/Downloads/Contrib/mysql-bench-0.6.tar.gz)
  29261.      User-customizable multi-threaded tool set to benchmark *MySQL*. By
  29262.      Sasha Pachev.
  29263.  
  29264. Authentication tools
  29265. ====================
  29266.  
  29267.    * ascend-radius-mysql-0.7.1.patch.gz
  29268.      (http://www.mysql.com/Downloads/Contrib/ascend-radius-mysql-0.7.1.patch.gz)
  29269.      This is authentication and logging patch using *MySQL* for
  29270.      Ascend-Radius. By <takeshi@SoftAgency.co.jp>.
  29271.  
  29272.    * icradius 0.10
  29273.      (http://www.mysql.com/Downloads/Contrib/icradius-0.10.tar.gz)
  29274.      icradius readme file
  29275.      (http://www.mysql.com/Downloads/Contrib/icradius.README)
  29276.  
  29277.    * checkpassword-0.81-mysql-0.6.5.patch.gz
  29278.      (http://www.mysql.com/Downloads/Contrib/checkpassword-0.81-mysql-0.6.5.patch.gz)
  29279.      *MySQL* authentication patch for QMAIL and checkpassword. These are
  29280.      useful for management user(mail,pop account) by *MySQL*.  By
  29281.      <takeshi@SoftAgency.co.jp>
  29282.  
  29283.    * jradius-diff.gz
  29284.      (http://www.mysql.com/Downloads/Contrib/jradius-diff.gz) *MySQL*
  29285.      support for Livingston's Radius 2.01. Authentication and
  29286.      Accounting. By Jose de Leon, <jdl@thevision.net>
  29287.  
  29288.    * mod_auth_mysql-2.20.tar.gz
  29289.      (http://www.mysql.com/Downloads/Contrib/mod_auth_mysql-2.20.tar.gz)
  29290.      Apache authentication module for *MySQL*. By Zeev Suraski,
  29291.      <bourbon@netvision.net.il>.
  29292.  
  29293.      *Please* register this module at:
  29294.      <http://bourbon.netvision.net.il/mysql/mod_auth_mysql/register.html>.
  29295.      The registering information is only used for statistical purposes
  29296.      and will encourage further development of this module!
  29297.  
  29298.    * mod_log_mysql-1.05.tar.gz
  29299.      (http://www.mysql.com/Downloads/Contrib/mod_log_mysql-1.05.tar.gz)
  29300.      *MySQL* logging module for Apache. By Zeev Suraski,
  29301.      <bourbon@netvision.net.il>.
  29302.  
  29303.    * mypasswd-2.0.tar.gz
  29304.      (http://www.mysql.com/Downloads/Contrib/mypasswd-2.0.tar.gz) Extra
  29305.      for `mod_auth_mysql'. This is a little tool that allows you to
  29306.      add/change user records storing group and/or password entries in
  29307.      *MySQL* tables. By Harry Brueckner, <brueckner@respublica.de>.
  29308.  
  29309.    * mysql-passwd.README
  29310.      (http://www.mysql.com/Downloads/Contrib/mysql-passwd.README)
  29311.  
  29312.    * mysql-passwd-1.2.tar.gz
  29313.      (http://www.mysql.com/Downloads/Contrib/mysql-passwd-1.2.tar.gz)
  29314.      Extra for `mod_auth_mysql'. This is a two-part system for use with
  29315.      `mod_auth_mysql'.
  29316.  
  29317.    * pam_mysql.tar.gz
  29318.      (http://www.mysql.com/Downloads/Contrib/pam_mysql.tar.gz) This
  29319.      module authenticates users via `pam', using *MySQL*.
  29320.  
  29321.    * nsapi_auth_mysql.tar
  29322.      (http://www.mysql.com/Downloads/Contrib/nsapi_auth_mysql.tar)
  29323.      Netscape Web Server API (NSAPI) functions to authenticate (BASIC)
  29324.      users against *MySQL* tables. By Yuan John Jiang.
  29325.  
  29326.    * qmail-1.03-mysql-0.6.5.patch.gz
  29327.      (http://www.mysql.com/Downloads/Contrib/qmail-1.03-mysql-0.6.5.patch.gz)
  29328.      Patch for qmail to authenticate users from a *MySQL* table.
  29329.  
  29330.    * pwcheck_mysql-0.1.tar.gz
  29331.      (http://www.mysql.com/Downloads/Contrib/pwcheck_mysql-0.1.tar.gz)
  29332.      An authentication module for the Cyrus IMAP server. By Aaron
  29333.      Newsome.
  29334.  
  29335. Converters
  29336. ==========
  29337.  
  29338.    * dbf2mysql-1.14.tgz
  29339.      (http://www.mysql.com/Downloads/Contrib/dbf2mysql-1.14.tgz)
  29340.      Convert between `.dbf' files and *MySQL* tables. By Maarten
  29341.      Boekhold, <boekhold@cindy.et.tudelft.nl>, William Volkman and
  29342.      Michael Widenius.  This converter includes rudementary read-only
  29343.      support for MEMO fields.
  29344.  
  29345.    * dbf2mysql-1.13.tgz
  29346.      (http://www.mysql.com/Downloads/Contrib/dbf2mysql-1.13.tgz)
  29347.      Convert between `.dbf' files and *MySQL* tables. By Maarten
  29348.      Boekhold, <boekhold@cindy.et.tudelft.nl>, and Michael Widenius.
  29349.      This converter can't handle MEMO fields.
  29350.  
  29351.    * dbf2mysql.zip
  29352.      (http://www.mysql.com/Downloads/Contrib/dbf2mysql.zip) Convert
  29353.      between FoxPro `.dbf' files and *MySQL* tables on Win32.  By
  29354.      Alexander Eltsyn, <ae@nica.ru> or <ae@usa.net>.
  29355.  
  29356.    * dump2h-1.20.gz
  29357.      (http://www.mysql.com/Downloads/Contrib/dump2h-1.20.gz) Convert
  29358.      from `mysqldump' output to a C header file. By Harry Brueckner,
  29359.      <brueckner@mail.respublica.de>.
  29360.  
  29361.    * exportsql.txt
  29362.      (http://www.mysql.com/Downloads/Contrib/exportsql.txt) A script
  29363.      that is similar to `access_to_mysql.txt', except that this one is
  29364.      fully configurable, has better type conversion (including
  29365.      detection of `TIMESTAMP' fields), provides warnings and suggestions
  29366.      while converting, quotes *all* special characters in text and
  29367.      binary data, and so on.  It will also convert to `mSQL' v1 and v2,
  29368.      and is free of charge for anyone. See
  29369.      `http://www.cynergi.net/prod/exportsql/' for latest version. By
  29370.      Pedro Freire, <support@cynergi.net>.  Note: Doesn't work with
  29371.      Access2!
  29372.  
  29373.    * access_to_mysql.txt
  29374.      (http://www.mysql.com/Downloads/Contrib/access_to_mysql.txt) Paste
  29375.      this function into an Access module of a database which has the
  29376.      tables you want to export. See also `exportsql'. By Brian Andrews.
  29377.      Note: Doesn't work with Access2!
  29378.  
  29379.    * importsql.txt
  29380.      (http://www.mysql.com/Downloads/Contrib/importsql.txt) A script
  29381.      that does the exact reverse of `exportsql.txt'.  That is, it
  29382.      imports data from *MySQL* into an Access database via ODBC. This
  29383.      is very handy when combined with exportsql, because it lets you
  29384.      use Access for all DB design and administration, and synchronize
  29385.      with your actual *MySQL* server either way. Free of charge. See
  29386.      `http://www.netdive.com/freebies/importsql/' for any updates.
  29387.      Created by Laurent Bossavit of NetDIVE.  *Note:* Doesn't work with
  29388.      Access2!
  29389.  
  29390.    * /msql2mysqlWrapper 1.0
  29391.      (http://www.mysql.com/Downloads/Contrib/msql2mysqlWrapper-1.0.tgz)
  29392.      A C wrapper from `mSQL' to *MySQL*. By <alfred@sb.net>
  29393.  
  29394.    * sqlconv.pl (http://www.mysql.com/Downloads/Contrib/sqlconv.pl) A
  29395.      simple script that can be used to copy fields from one *MySQL*
  29396.      table to another in bulk. Basically, you can run `mysqldump' and
  29397.      pipe it to the `sqlconv.pl' script and the script will parse
  29398.      through the `mysqldump' output and will rearrange the fields so
  29399.      they can be inserted into a new table. An example is when you want
  29400.      to create a new table for a different site you are working on, but
  29401.      the table is just a bit different (ie - fields in different order,
  29402.      etc.).  By Steve Shreeve.
  29403.  
  29404. Using MySQL with other products
  29405. ===============================
  29406.  
  29407.    * emacs-sql-mode.tar.gz
  29408.      (http://www.mysql.com/Downloads/Contrib/emacs-sql-mode.tar.gz) Raw
  29409.      port of a SQL mode for XEmacs. Supports completion. Original by
  29410.      Peter D. Pezaris <pez@atlantic2.sbi.com> and partial *MySQL* port
  29411.      by David Axmark.
  29412.  
  29413.    * MyAccess97 1.01
  29414.      (http://www.mysql.com/Downloads/Win32/MyAccess97_Ver_1_01.zip)
  29415.      MyAccess is an AddIn for Access 97 and handles a lot of
  29416.      maintanance work for *MySQL* databases.
  29417.  
  29418.    * MyAccess2000 1.01
  29419.      (http://www.mysql.com/Downloads/Win32/MyAccess2000_Ver_1_01.zip)
  29420.      MyAccess is an AddIn for Access 2000 and handles a lot of
  29421.      maintanance work for *MySQL* databases.
  29422.  
  29423.      MyAccess-readme
  29424.      (http://www.mysql.com/Downloads/Win32/MyAccess-1.01.readme).  By
  29425.      Hubertus Hiden.
  29426.  
  29427.    * radius-0.3.tar.gz
  29428.      (http://www.mysql.com/Downloads/Contrib/radius-0.3.tar.gz) Patches
  29429.      for `radiusd' to make it support *MySQL*. By Wim Bonis,
  29430.      <bonis@kiss.de>.
  29431.  
  29432. Useful tools
  29433. ============
  29434.  
  29435.    * mysql_watchdog.pl
  29436.      (http://www.mysql.com/Downloads/Contrib/mysql_watchdog.pl) Monitor
  29437.      the *MySQL* daemon for possible lockups. By Yermo Lamers,
  29438.      <yml@yml.com>.
  29439.  
  29440.    * mysqltop.tar.gz
  29441.      (http://www.mysql.com/Downloads/Contrib/mysqltop.tar.gz) Sends a
  29442.      query in a fixed time interval to the server and shows the
  29443.      resulting table. By Thomas Wana.
  29444.  
  29445.    * mysql_structure_dumper.tar.gz
  29446.      (http://www.mysql.com/Downloads/Contrib/mysql_structure_dumper.tar.gz)
  29447.      Prints out the structure of the all tables in a database. By
  29448.      Thomas Wana.
  29449.  
  29450.    * structure_dumper.tgz
  29451.      (http://www.mysql.com/Downloads/Contrib/mysql_structure_dumper.tgz)
  29452.      Prints the structure of every table in a database. By Thomas Wana.
  29453.  
  29454.    * mysqlsync-1.0-alpha.tar.gz
  29455.      (http://www.mysql.com/Downloads/Contrib/mysqlsync).  A perl script
  29456.      to keep remote copies of a *MySQL* database in sync with a central
  29457.      master copy. By Mark Jeftovic.  <markjr@easydns.com>
  29458.  
  29459.    * MySQLTutor
  29460.      (http://www.mysql.com/Downloads/Contrib/MySQLTutor-0.2.tar.gz).
  29461.      MySQLTutor. A tutor of *MySQL* for beginners
  29462.  
  29463.    * MySQLDB.zip (http://www.mysql.com/Downloads/Contrib/MySQLDB.zip) A
  29464.      COM library for *MySQL* by Alok Singh.
  29465.  
  29466.    * MySQLDB-readme.html
  29467.      (http://www.mysql.com/Downloads/Contrib/MySQLDB-readme.html)
  29468.  
  29469.    * mysql_replicate.pl
  29470.      (http://www.mysql.com/Downloads/Contrib/mysql_replicate.pl) Perl
  29471.      program that handles replication.  By <elble@icculus.nsg.nwu.edu>
  29472.  
  29473.    * DBIx-TextIndex-0.02.tar.gz
  29474.      (http://www.mysql.com/Downloads/Contrib/DBIx-TextIndex-0.02.tar.gz)
  29475.      Perl script that uses reverse indexing to handle text searching.
  29476.      By Daniel Koch.
  29477.  
  29478.    * dbcheck (http://www.mysql.com/Downloads/Contrib/dbcheck) Perl
  29479.      script that takes a backup of a tables before running isamchk on
  29480.      them.  By Elizabeth.
  29481.  
  29482. RPMs for common tools (Most are for RedHat 6.1)
  29483. ===============================================
  29484.  
  29485.    * perl-Data-ShowTable-3.3-2.i386.rpm
  29486.      (http://www.mysql.com/Downloads/Contrib/perl-Data-ShowTable-3.3-2.i386.rpm)
  29487.  
  29488.    * perl-Msql-Mysql-modules-1.2210-2.i386.rpm
  29489.      (http://www.mysql.com/Downloads/Contrib/perl-Msql-Mysql-modules-1.2210-2.i386.rpm)
  29490.  
  29491.    * php-pg-3.0.13-1.i386.rpm
  29492.      (http://www.mysql.com/Downloads/Contrib/php-pg-3.0.13-1.i386.rpm)
  29493.  
  29494.    * php-pg-manual-3.0.13-1.i386.rpm
  29495.      (http://www.mysql.com/Downloads/Contrib/php-pg-manual-3.0.13-1.i386.rpm)
  29496.  
  29497.    * php-pg-mysql-3.0.13-1.i386.rpm
  29498.      (http://www.mysql.com/Downloads/Contrib/php-pg-mysql-3.0.13-1.i386.rpm)
  29499.  
  29500.    * phpMyAdmin-2.0.5-1.noarch.rpm
  29501.      (http://www.mysql.com/Downloads/Contrib/phpMyAdmin-2.0.5-1.noarch.rpm)
  29502.  
  29503. Useful functions
  29504. ================
  29505.  
  29506.    * mysnprintf.c (http://www.mysql.com/Downloads/Contrib/mysnprintf.c)
  29507.      sprintf() function for SQL queries that can escape blobs. By
  29508.      Chunhua Liu.
  29509.  
  29510. Uncategorized
  29511. =============
  29512.  
  29513.    * findres.pl (http://www.mysql.com/Downloads/Contrib/findres.pl)
  29514.      Find reserved words in tables. By Nem W Schlecht.
  29515.  
  29516.    * handicap.tar.gz
  29517.      (http://www.mysql.com/Downloads/Contrib/handicap.tar.gz)
  29518.      Performance handicapping system for yachts. Uses PHP. By
  29519.      <rhill@stobyn.ml.org>.
  29520.  
  29521.    * hylalog-1.0.tar.gz
  29522.      (http://www.mysql.com/Downloads/Contrib/hylalog-1.0.tar.gz) Store
  29523.      `hylafax' outgoing faxes in a *MySQL* database. By Sinisa
  29524.      Milivojevic, <sinisa@mysql.com>.
  29525.  
  29526.    * mrtg-mysql-1.0.tar.gz
  29527.      (http://www.mysql.com/Downloads/Contrib/mrtg-mysql-1.0.tar.gz)
  29528.      *MySQL* status plotting with MRTG, by Luuk de Boer, <luuk@wxs.nl>.
  29529.  
  29530.    * wuftpd-2.4.2.18-mysql_support.2.tar.gz
  29531.      (http://www.mysql.com/Downloads/Contrib/wuftpd-2.4.2.18-mysql_support.2.tar.gz)
  29532.      Patches to add logging to *MySQL* for WU-ftpd. By Zeev Suraski,
  29533.      <bourbon@netvision.net.il>.
  29534.  
  29535.    * wu-ftpd-2.6.0-mysql.4.tar.gz
  29536.      (http://www.mysql.com/Downloads/Contrib/wu-ftpd-2.6.0-mysql.4.tar.gz)
  29537.      Patches to add logging to *MySQL* for WU-ftpd 2.6.0. By,
  29538.      <takeshi@SoftAgency.co.jp>, based on Zeev Suraski wuftpd patches.
  29539.  
  29540.    * Old-Versions (http://www.mysql.com/Downloads/Contrib/Old-Versions)
  29541.      Previous versions of things found here that you probably won't be
  29542.      interested in.
  29543.  
  29544. Contributors to MySQL
  29545. *********************
  29546.  
  29547. Contributors to the *MySQL* distribution are listed below, in somewhat
  29548. random order:
  29549.  
  29550. Michael (Monty) Widenius
  29551.      Has written the following parts of *MySQL*:
  29552.         * All the main code in `mysqld'.
  29553.  
  29554.         * New functions for the string library.
  29555.  
  29556.         * Most of the `mysys' library.
  29557.  
  29558.         * The `ISAM' and `MyISAM' libraries (B-tree index file handlers
  29559.           with index compression and different record formats).
  29560.  
  29561.         * The `HEAP' library. A memory table system with our superior
  29562.           full dynamic hashing. In use since 1981 and published around
  29563.           1984.
  29564.  
  29565.         * The `replace' program (look into it, it's COOL!).
  29566.  
  29567.         * *MyODBC*, the ODBC driver for Windows95.
  29568.  
  29569.         * Fixing bugs in MIT-pthreads to get it to work for *MySQL*. And
  29570.           also Unireg, a curses-based application tool with many
  29571.           utilities.
  29572.  
  29573.         * Porting of `mSQL' tools like `msqlperl', `DBD'/`DBI' and
  29574.           `DB2mysql'.
  29575.  
  29576.         * Most parts of crash-me and the *MySQL* benchmarks.
  29577.  
  29578. David Axmark
  29579.         * Coordinator and main writer for the *Reference Manual*,
  29580.           including enhancements to `texi2html'. Also automatic website
  29581.           updating from this manual.
  29582.  
  29583.         * Autoconf, Automake and `libtool' support.
  29584.  
  29585.         * The licensing stuff.
  29586.  
  29587.         * Parts of all the text files.  (Nowadays only the `README' is
  29588.           left. The rest ended up in the manual.)
  29589.  
  29590.         * Our Mail master.
  29591.  
  29592.         * Lots of testing of new features.
  29593.  
  29594.         * Our in-house "free" software lawyer.
  29595.  
  29596.         * Mailing list maintainer (who never has the time to do it
  29597.           right...)
  29598.  
  29599.         * Our original portability code (more than 10 years old now).
  29600.           Nowadays only some parts of `mysys' are left.
  29601.  
  29602.         * Someone for Monty to call in the middle of the night when he
  29603.           just got that new feature to work. :-)
  29604.  
  29605. Paul DuBois
  29606.      Help with making the Reference Manual correct and understandable.
  29607.      That includes rewriting Monty's and David's attempts at English
  29608.      into English as other people know it.
  29609.  
  29610. Gianmassimo Vigazzola <qwerg@mbox.vol.it> or <qwerg@tin.it>
  29611.      The initial port to Win32/NT.
  29612.  
  29613. Kim Aldale
  29614.      Helped to rewrite Monty's and David's early attempts at English
  29615.      into English.
  29616.  
  29617. Allan Larsson (The BOSS for TCX DataKonsult AB)
  29618.      For all the time he has allowed Monty to spend on this "maybe
  29619.      useful" tool (*MySQL*). Dedicated user (and bug finder) of Unireg &
  29620.      *MySQL*.
  29621.  
  29622. Per Eric Olsson
  29623.      For more or less constructive criticism and real testing of the
  29624.      dynamic record format.
  29625.  
  29626. Irena Pancirov <irena@mail.yacc.it>
  29627.      Win32 port with Borland compiler.  `mysqlshutdown.exe' and
  29628.      `mysqlwatch.exe'
  29629.  
  29630. David J. Hughes
  29631.      For the effort to make a shareware SQL database. We at TcX started
  29632.      with `mSQL', but found that it couldn't satisfy our purposes so
  29633.      instead we wrote a SQL interface to our application builder
  29634.      Unireg.  `mysqladmin' and `mysql' are programs that were largely
  29635.      influenced by their `mSQL' counterparts. We have put a lot of
  29636.      effort into making the *MySQL* syntax a superset of `mSQL'. Many
  29637.      of the APIs ideas are borrowed from `mSQL' to make it easy to port
  29638.      free `mSQL' programs to *MySQL*. *MySQL* doesn't contain any code
  29639.      from `mSQL'.  Two files in the distribution
  29640.      (`client/insert_test.c' and `client/select_test.c') are based on
  29641.      the corresponding (non-copyrighted) files in the `mSQL'
  29642.      distribution, but are modified as examples showing the changes
  29643.      necessary to convert code from `mSQL' to *MySQL*.  (`mSQL' is
  29644.      copyrighted David J. Hughes.)
  29645.  
  29646. Fred Fish
  29647.      For his excellent C debugging and trace library. Monty has made a
  29648.      number of smaller improvements to the library (speed and
  29649.      additional options).
  29650.  
  29651. Richard A. O'Keefe
  29652.      For his public domain string library.
  29653.  
  29654. Henry Spencer
  29655.      For his regex library, used in `WHERE column REGEXP regexp'.
  29656.  
  29657. Free Software Foundation
  29658.      From whom we got an excellent compiler (`gcc'), the `libc' library
  29659.      (from which we have borrowed `strto.c' to get some code working in
  29660.      Linux) and the `readline' library (for the `mysql' client).
  29661.  
  29662. Free Software Foundation & The XEmacs development team
  29663.      For a really great editor/environment used by almost everybody at
  29664.      TcX/MySQL AB/detron.
  29665.  
  29666. Patrick Lynch
  29667.      For helping us acquire `http://www.mysql.com/'.
  29668.  
  29669. Fred Lindberg
  29670.      For setting up qmail to handle *MySQL* mailing list and for the
  29671.      incredible help we got in managing the *MySQL* mailing lists.
  29672.  
  29673. Igor Romanenko <igor@frog.kiev.ua>
  29674.      `mysqldump' (previously `msqldump', but ported and enhanced by
  29675.      Monty).
  29676.  
  29677. Tim Bunce, Alligator Descartes
  29678.      For the `DBD' (Perl) interface.
  29679.  
  29680. Andreas Koenig <a.koenig@mind.de>
  29681.      For the Perl interface to *MySQL*.
  29682.  
  29683. Eugene Chan <eugene@acenet.com.sg>
  29684.      For porting PHP to *MySQL*.
  29685.  
  29686. Michael J. Miller Jr. <mke@terrapin.turbolift.com>
  29687.      For the first *MySQL* manual. And a lot of spelling/language fixes
  29688.      for the FAQ (that turned into the *MySQL* manual a long time ago).
  29689.  
  29690. Giovanni Maruzzelli <maruzz@matrice.it>
  29691.      For porting iODBC (Unix ODBC).
  29692.  
  29693. Chris Provenzano
  29694.      Portable user level pthreads. From the copyright: This product
  29695.      includes software developed by Chris Provenzano, the University of
  29696.      California, Berkeley, and contributors.  We are currently using
  29697.      version 1_60_beta6 patched by Monty (see
  29698.      `mit-pthreads/Changes-mysql').
  29699.  
  29700. Xavier Leroy <Xavier.Leroy@inria.fr>
  29701.      The author of LinuxThreads (used by *MySQL* on Linux).
  29702.  
  29703. Zarko Mocnik <zarko.mocnik@dem.si>
  29704.      Sorting for Slovenian language and the `cset.tar.gz' module that
  29705.      makes it easier to add other character sets.
  29706.  
  29707. "TAMITO" <tommy@valley.ne.jp>
  29708.      The `_MB' character set macros and the ujis and sjis character
  29709.      sets.
  29710.  
  29711. Joshua Chamas <joshua@chamas.com>
  29712.      Base for concurrent insert, extended date syntax, debugging on NT
  29713.      and answering on the *MySQL* mailing list.
  29714.  
  29715. Yves Carlier <Yves.Carlier@rug.ac.be>
  29716.      `mysqlaccess', a program to show the access rights for a user.
  29717.  
  29718. Rhys Jones <rhys@wales.com> (And GWE Technologies Limited)
  29719.      For the JDBC, a module to extract data from *MySQL* with a Java
  29720.      client.
  29721.  
  29722. Dr Xiaokun Kelvin ZHU <X.Zhu@brad.ac.uk>
  29723.      Further development of the JDBC driver and other *MySQL*-related
  29724.      Java tools.
  29725.  
  29726. James Cooper <pixel@organic.com>
  29727.      For setting up a searchable mailing list archive at his site.
  29728.  
  29729. Rick Mehalick <Rick_Mehalick@i-o.com>
  29730.      For `xmysql', a graphical X client for *MySQL*.
  29731.  
  29732. Doug Sisk <sisk@wix.com>
  29733.      For providing RPM packages of *MySQL* for RedHat Linux.
  29734.  
  29735. Diemand Alexander V. <axeld@vial.ethz.ch>
  29736.      For providing RPM packages of *MySQL* for RedHat Linux-Alpha.
  29737.  
  29738. Antoni Pamies Olive <toni@readysoft.es>
  29739.      For providing RPM versions of a lot of *MySQL* clients for Intel
  29740.      and SPARC.
  29741.  
  29742. Jay Bloodworth <jay@pathways.sde.state.sc.us>
  29743.      For providing RPM versions for *MySQL* 3.21 versions.
  29744.  
  29745. Jochen Wiedmann <wiedmann@neckar-alb.de>
  29746.      For maintaining the Perl `DBD::mysql' module.
  29747.  
  29748. Therrien Gilbert <gilbert@ican.net>, Jean-Marc Pouyot <jmp@scalaire.fr>
  29749.      French error messages.
  29750.  
  29751. Petr snajdr, <snajdr@pvt.net>
  29752.      Czech error messages.
  29753.  
  29754. Jaroslaw Lewandowski <jotel@itnet.com.pl>
  29755.      Polish error messages.
  29756.  
  29757. Miguel Angel Fernandez Roiz
  29758.      Spanish error messages.
  29759.  
  29760. Roy-Magne Mo <rmo@www.hivolda.no>
  29761.      Norwegian error messages and testing of 3.21.#.
  29762.  
  29763. Timur I. Bakeyev <root@timur.tatarstan.ru>
  29764.      Russian error messages.
  29765.  
  29766. <brenno@dewinter.com> && Filippo Grassilli <phil@hyppo.com>
  29767.      Italian error messages.
  29768.  
  29769. Dirk Munzinger <dirk@trinity.saar.de>
  29770.      German error messages.
  29771.  
  29772. Billik Stefan <billik@sun.uniag.sk>
  29773.      Slovak error messages.
  29774.  
  29775. Stefan Saroiu <tzoompy@cs.washington.edu>
  29776.      Romanian error messages.
  29777.  
  29778. Peter Feher
  29779.      Hungarian error messages
  29780.  
  29781. David Sacerdote <davids@secnet.com>
  29782.      Ideas for secure checking of DNS hostnames.
  29783.  
  29784. Wei-Jou Chen <jou@nematic.ieo.nctu.edu.tw>
  29785.      Some support for Chinese(BIG5) characters.
  29786.  
  29787. Wei He <hewei@mail.ied.ac.cn>
  29788.      A lot of functionality for the Chinese(GBK) character set.
  29789.  
  29790. Zeev Suraski <bourbon@netvision.net.il>
  29791.      `FROM_UNIXTIME()' time formatting, `ENCRYPT()' functions, and
  29792.      `bison' advisor.  Active mailing list member.
  29793.  
  29794. Luuk de Boer <luuk@wxs.nl>
  29795.      Ported (and extended) the benchmark suite to `DBI'/`DBD'. Have
  29796.      been of great help with `crash-me' and running benchmarks. Some new
  29797.      date functions. The mysql_setpermissions script.
  29798.  
  29799. Jay Flaherty <fty@utk.edu>
  29800.      Big parts of the Perl `DBI'/`DBD' section in the manual.
  29801.  
  29802. Paul Southworth <pauls@etext.org>, Ray Loyzaga <yar@cs.su.oz.au>
  29803.      Proof-reading of the Reference Manual.
  29804.  
  29805. Alexis Mikhailov <root@medinf.chuvashia.su>
  29806.      User definable functions (UDFs); `CREATE FUNCTION' and `DROP
  29807.      FUNCTION'.
  29808.  
  29809. Andreas F. Bobak <bobak@relog.ch>
  29810.      The `AGGREGATE' extension to UDF functions.
  29811.  
  29812. Ross Wakelin <R.Wakelin@march.co.uk>
  29813.      Help to set up InstallShield for *MySQL*-Win32.
  29814.  
  29815. Jethro Wright III <jetman@li.net>
  29816.      The `libmysql.dll' library.
  29817.  
  29818. James Pereria <jpereira@iafrica.com>
  29819.      Mysqlmanager, a Win32 GUI tool for administrating *MySQL*.
  29820.  
  29821. Curt Sampson <cjs@portal.ca>
  29822.      Porting of MIT-pthreads to NetBSD/Alpha and NetBSD 1.3/i386.
  29823.  
  29824. Sinisa Milivojevic <sinisa@coresinc.com>
  29825.      Compression (with `zlib') to the client/server protocol.  Perfect
  29826.      hashing for the lexical analyzer phase.
  29827.  
  29828. Antony T. Curtis <antony.curtis@olcs.net>
  29829.      Porting of *MySQL* to OS/2.
  29830.  
  29831. Martin Ramsch <m.ramsch@computer.org>
  29832.      Examples in the *MySQL* Tutorial.
  29833.  
  29834. Tim Bunce
  29835.      Author of `mysqlhotcopy'.
  29836.  
  29837. Steve Harvey
  29838.      For making `mysqlaccess' more secure.
  29839.  
  29840. Jeremy Cole <jeremy@spaceapes.com>
  29841.      Proofreading and editing this fine manual.
  29842.  
  29843. Valueclick Inc.
  29844.      For sponsoring the optimize section in this manual.
  29845.  
  29846. Other contributors, bugfinders and testers: James H. Thompson, Maurizio
  29847. Menghini, Wojciech Tryc, Luca Berra, Zarko Mocnik, Wim Bonis, Elmar
  29848. Haneke, <jehamby@lightside>, <psmith@BayNetworks.COM>,
  29849. <duane@connect.com.au>, Ted Deppner <ted@psyber.com>, Mike Simons,
  29850. Jaakko Hyva"tti.
  29851.  
  29852. And lots of bug report/patches from the folks on the mailing list.
  29853.  
  29854. And a big tribute to those that help us answer questions on the
  29855. `mysql@lists.mysql.com' mailing list:
  29856.  
  29857. Daniel Koch <dkoch@amcity.com>
  29858.      Irix setup.
  29859.  
  29860. Luuk de Boer <luuk@wxs.nl>
  29861.      Benchmark questions.
  29862.  
  29863. Tim Sailer <tps@users.buoy.com>
  29864.      `DBD-mysql' questions.
  29865.  
  29866. Boyd Lynn Gerber <gerberb@zenez.com>
  29867.      SCO related questions.
  29868.  
  29869. Richard Mehalick <RM186061@shellus.com>
  29870.      `xmysql'-related questions and basic installation questions.
  29871.  
  29872. Zeev Suraski <bourbon@netvision.net.il>
  29873.      Apache module configuration questions (log & auth), PHP-related
  29874.      questions, SQL syntax related questions and other general
  29875.      questions.
  29876.  
  29877. Francesc Guasch <frankie@citel.upc.es>
  29878.      General questions.
  29879.  
  29880. Jonathan J Smith <jsmith@wtp.net>
  29881.      Questions pertaining to OS-specifics with Linux, SQL syntax, and
  29882.      other things that might be needing some work.
  29883.  
  29884. David Sklar <sklar@student.net>
  29885.      Using *MySQL* from PHP and Perl.
  29886.  
  29887. Alistair MacDonald <A.MacDonald@uel.ac.uk>
  29888.      Not yet specified, but is flexible and can handle Linux and maybe
  29889.      HP-UX.  Will try to get user to use `mysqlbug'.
  29890.  
  29891. John Lyon <jlyon@imag.net>
  29892.      Questions about installing *MySQL* on Linux systems, using either
  29893.      `.rpm' files, or compiling from source.
  29894.  
  29895. Lorvid Ltd. <lorvid@WOLFENET.com>
  29896.      Simple billing/license/support/copyright issues.
  29897.  
  29898. Patrick Sherrill <patrick@coconet.com>
  29899.      ODBC and VisualC++ interface questions.
  29900.  
  29901. Randy Harmon <rjharmon@uptimecomputers.com>
  29902.      `DBD', Linux, some SQL syntax questions.
  29903.  
  29904. MySQL change history
  29905. ********************
  29906.  
  29907. Note that we tend to update the manual at the same time we implement new
  29908. things to *MySQL*. If you find a version listed below that you can't
  29909. find on the *MySQL* download page (http://www.mysql.com/downloads/),
  29910. this means that the version has not yet been released!
  29911.  
  29912. Changes in release 3.23.x  (Released as alpha)
  29913. ==============================================
  29914.  
  29915. The major difference between release 3.23 and releases 3.22 and 3.21 is
  29916. that 3.23 contains a new ISAM library (MyISAM), which is more tuned for
  29917. SQL than the old ISAM was.
  29918.  
  29919. The 3.23 release is under development, and things will be added at a
  29920. fast pace to it.  For the moment we recommend this version only for
  29921. users that desperately need a new feature that is found only in this
  29922. release (like big file support and machine-independent tables).  (Note
  29923. that all new functionality in *MySQL* 3.23 is extensively tested, but as
  29924. this release involves much new code, it's difficult to test everything).
  29925.  
  29926. We are not adding any more new features that are likely to break any
  29927. old code in *MySQL* 3.23 so this version should stabilise pretty soon
  29928. and will soon be declared beta, gamma and release.
  29929.  
  29930. Changes in release 3.23.22
  29931. --------------------------
  29932.  
  29933.    * Fixed that `lex_hash.h' is created properly for each `MySQL'
  29934.      distribution.
  29935.  
  29936.    * Fixed that `MASTER' and `COLLECTION' are not a reserved words.
  29937.  
  29938.    * The log generated by `--slow-query-log' didn't contain the whole
  29939.      queries.
  29940.  
  29941.    * Fixed that open transactions in BDB tables are rolled back if the
  29942.      connection is closed unexpectedly.
  29943.  
  29944.    * Added workaround for a bug in gcc 2.96 (intel) and gcc 2.9 (Ia64)
  29945.      in gen_lex_hash.c.
  29946.  
  29947.    * Fixed memory leak in the client library when using `host=..' in the
  29948.      `my.cnf' file.
  29949.  
  29950.    * Optimized functions that manipulates the hours/minutes/seconds.
  29951.  
  29952.    * Fixed bug when comparing the result of `DATE_ADD'/`DATE_SUB'
  29953.      against a number
  29954.  
  29955.    * Changed the meaning of `-F, --fast' for `myisamchk'. Added option
  29956.      `-C, --check-only-changed' to `myisamchk'.
  29957.  
  29958.    * Added `ANALYZE table_name' to update key statistics for tables.
  29959.  
  29960.    * Changed binary items `0x...' to be default regarded as an integer
  29961.  
  29962. Changes in release 3.23.21
  29963. --------------------------
  29964.  
  29965.    * Added `mysql_character_set_name(MYSQL *mysql)' function to the
  29966.      MySQL API.
  29967.  
  29968.    * Made the update log `ASCII 0' safe.
  29969.  
  29970.    * Added the `mysql_config' script.
  29971.  
  29972.    * Fixed problem when using `<' or `>' with a char column that was
  29973.      only partly indexed.
  29974.  
  29975.    * One would get a core dump if the log file was not readable by the
  29976.      MySQL user.
  29977.  
  29978.    * Changed `mysqladmin' to use the `CREATE DATABASE'/`DROP DATABASE'
  29979.      commands instead of the old deprecated API calls.
  29980.  
  29981.    * Fixed `chown' warning in `safe_mysqld'.
  29982.  
  29983.    * Fixed a bug in `ORDER BY' that was introduced in 3.23.19.
  29984.  
  29985.    * Only optimize the `DELETE FROM table_name' to do a drop+create of
  29986.      the table if we are in `AUTOCOMMIT' mode.  (Needed for BDB tables).
  29987.  
  29988.    * Added extra checks to avoid index corruption when the
  29989.      `ISAM'/`MyISAM' index files gets full during an `INSERT'/`UPDATE'.
  29990.  
  29991.    * `myisamchk' didn't correctly update row checksum when used with
  29992.      `-ro' (This only gave an warning in subsequent runs).
  29993.  
  29994.    * Fixed bug in `REPAIR TABLE' so that it works with tables without
  29995.      index.
  29996.  
  29997.    * Fixed buffer overrun in `DROP DATABASE'
  29998.  
  29999.    * `LOAD TABLE FROM MASTER' is sufficiently bug-free to announce it as
  30000.      a feature.
  30001.  
  30002.    * `MATCH' and `AGAINST' are now reserved words.
  30003.  
  30004. Changes in release 3.23.20
  30005. --------------------------
  30006.  
  30007.    * Fixed bug in 3.23.19; `DELETE FROM table_name' removed the .frm
  30008.      file.
  30009.  
  30010. Changes in release 3.23.19
  30011. --------------------------
  30012.  
  30013.    * Changed copyright for all files to GPL for the server code and
  30014.      utilities and LGPL for the client libraries.
  30015.  
  30016.    * Fixed bug where all rows matching weren't updated on a `MyISAM'
  30017.      table when doing update based on key on a table with many keys and
  30018.      some key changed values.
  30019.  
  30020.    * The Linux *MySQL* RPM's and binaries are now staticly linked with
  30021.      a linuxthread version that has faster mutex handling when used with
  30022.      *MySQL*.
  30023.  
  30024.    * `ORDER BY' can now uses `REF' keys to find subset the rows that
  30025.      needs to be sorted.
  30026.  
  30027.    * Changed name of `print_defaults' to `my_print_defaults' to avoid
  30028.      name confusion.
  30029.  
  30030.    * Fixed `NULLIF()' to work according to ANSI SQL99.
  30031.  
  30032.    * Added `net_read_timeout' and `net_write_timeout' as startup
  30033.      parameters to `mysqld'.
  30034.  
  30035.    * Fixed bug that destroyed index when doing `myisamchk
  30036.      --sort-records' on a table with prefix compressed index.
  30037.  
  30038.    * Added pack_isam and myisampack to the standard *MySQL*
  30039.      distribution.
  30040.  
  30041.    * Added the syntax `BEGIN WORK' (the same as `BEGIN').
  30042.  
  30043.    * Fixed core dump bug when using `ORDER BY' on a `CONV()' expression.
  30044.  
  30045.    * Added `LOAD TABLE FROM MASTER'
  30046.  
  30047.    * Added `FLUSH MASTER' and `FLUSH SLAVE'
  30048.  
  30049.    * Fixed big/little endian problem in the replication
  30050.  
  30051. Changes in release 3.23.18
  30052. --------------------------
  30053.  
  30054.    * Fixed a problem from 3.23.17 when choosing character set on the
  30055.      client side.
  30056.  
  30057.    * Added `FLUSH TABLES WITH READ LOCK' to make a global lock suitable
  30058.      to make a copy of *MySQL* data files.
  30059.  
  30060.    * `CREATE TABLE  ... SELECT ... PROCEDURE' now works.
  30061.  
  30062.    * Internal temporary tables will now uses compressed index when using
  30063.      `GROUP BY' on `VARCHAR/CHAR' columns.
  30064.  
  30065.    * Fixed a problem when locking the same table with both a `READ' and
  30066.      a `WRITE' lock.
  30067.  
  30068.    * Fixed problem with myisamchk and `RAID' tables.
  30069.  
  30070. Changes in release 3.23.17
  30071. --------------------------
  30072.  
  30073.    * Fixed a bug in `find_in_set()' when the first argument was `NULL'.
  30074.  
  30075.    * Added table locks to Berkeley DB.
  30076.  
  30077.    * Fixed a bug with `LEFT JOIN' and `ORDER BY' where the first table
  30078.      had only one matching row.
  30079.  
  30080.    * Added 4 sample `my.cfg' example files in the `support-files'
  30081.      directory.
  30082.  
  30083.    * Fixed `duplicated key' problem when doing big `GROUP BY''s.  (This
  30084.      bug was probably introduced in 3.23.15).
  30085.  
  30086.    * Changed syntax for `INNER JOIN' to match ANSI SQL.
  30087.  
  30088.    * Added `NATURAL JOIN' syntax.
  30089.  
  30090.    * A lot of fixes in the `BDB' interface.
  30091.  
  30092.    * Added handling of `--no-defaults' and `--defaults-file' to
  30093.      `safe_mysqld.sh' and `mysql_install_db.sh'.
  30094.  
  30095.    * Fixed bug in reading compressed tables with many threads.
  30096.  
  30097.    * Fixed that `USE INDEX' works with `PRIMARY' keys.
  30098.  
  30099.    * Added `BEGIN' statement to start a transaction in `AUTOCOMMIT'
  30100.      mode.
  30101.  
  30102.    * Added symbolic links support for Win32.
  30103.  
  30104.    * Changed protocol to let client know if the server is in AUTOCOMMIT
  30105.      mode and if there is a pending transaction.  If there is a pending
  30106.      transaction the client library will give an error before
  30107.      reconnecting to the server to let the client know that the server
  30108.      did a rollback.  The protocol is still backward compatible with
  30109.      old clients
  30110.  
  30111.    * `KILL' now works on a thread that is locked on a 'write' to a dead
  30112.      client.
  30113.  
  30114.    * Fixed memory leak in the replication slave thread.
  30115.  
  30116.    * Added new option `log-slave-updates' to allow daisy-chaining the
  30117.      slaves.
  30118.  
  30119.    * Fixed compile error on FreeBSD and other systems where `pthread_t'
  30120.      is not the same as `int'.
  30121.  
  30122.    * Fixed master shutdown aborting the slave thread.
  30123.  
  30124.    * Fixed a race condition in `INSERT DELAYED' code when doing `ALTER
  30125.      TABLE'.
  30126.  
  30127.    * Added deadlock detection sanity checks to `INSERT DELAYED'
  30128.  
  30129. Changes in release 3.23.16
  30130. --------------------------
  30131.  
  30132.    * Added option `TYPE=QUICK' to `CHECK' and `REPAIR'.
  30133.  
  30134.    * Fixed bug in `REPAIR TABLE' when the table was in use by other
  30135.      threads.
  30136.  
  30137.    * Added a thread cache to make it possible to debug *MySQL* with
  30138.      `gdb' when one does a lot of reconnects. This will also improve
  30139.      systems where you can't use persistent connections.
  30140.  
  30141.    * Lots of fixes in the Berekely DB interface.
  30142.  
  30143.    * `UPDATE IGNORE' will not abort if an update results in a
  30144.      `DUPLICATE_KEY' error.
  30145.  
  30146.    * Put `CREATE TEMPORARY TABLE' commands in the update log.
  30147.  
  30148.    * Fixed bug in handling of masked IP numbers in the privilege tables.
  30149.  
  30150.    * Fixed bug with `delayed_key_writes' tables and `CHECK TABLE'.
  30151.  
  30152.    * Added `replicate-do-db' and `replicate-ignore-db' options to
  30153.      restrict which databases get replicated
  30154.  
  30155.    * Added `SQL_LOG_BIN' option
  30156.  
  30157. Changes in release 3.23.15
  30158. --------------------------
  30159.  
  30160.    * To start `mysqld' as `root', you must now use the `--user=root'
  30161.      option.
  30162.  
  30163.    * Added interface to Berkeley DB. (This is not yet functional;  Play
  30164.      with it at your own risk!)
  30165.  
  30166.    * Replication between master and slaves.
  30167.  
  30168.    * Fixed bug that other threads could steal a lock when a thread had
  30169.      a lock on a table and did a `FLUSH TABLES' command.
  30170.  
  30171.    * Added the `slow_launch_time' variable and the `Slow_launch_threads'
  30172.      status variable to `mysqld'.  These can be examined with
  30173.      `mysqladmin variables' and `mysqladmin extended-status'.
  30174.  
  30175.    * Added functions `INET_NTOA()' and `INET_ATON()'.
  30176.  
  30177.    * The default type of `IF()' now depends on the second and third
  30178.      arguments and not only on the second argument.
  30179.  
  30180.    * Fixed case when `myisamchk' could go into a loop when trying to
  30181.      repair a crashed table.
  30182.  
  30183.    * Don't write `INSERT DELAYED' to update log if `SQL_LOG_UPDATE=0'.
  30184.  
  30185.    * Fixed problem with `REPLACE' on `HEAP' tables.
  30186.  
  30187.    * Added possible character sets and time zone to `SHOW VARIABLES'.
  30188.  
  30189.    * Fixed bug in locking code that could result it locking problems
  30190.      with concurrent inserts under high load.
  30191.  
  30192.    * Fixed a problem with `DELETE' of many rows on a table with
  30193.      compressed keys where *MySQL* scanned the index to find the rows.
  30194.  
  30195.    * Fixed problem with `CHECK' on table with deleted keyblocks.
  30196.  
  30197.    * Fixed a bug in reconnect (at the client side) where it didn't free
  30198.      memory properly in some contexts.
  30199.  
  30200.    * Fixed problems in update log when using `LAST_INSERT_ID()' to
  30201.      update a table with an auto_increment key.
  30202.  
  30203.    * Added function `NULLIF()'.
  30204.  
  30205.    * Fixed bug when using `LOAD DATA INFILE' on a table with
  30206.      `BLOB/TEXT' columns.
  30207.  
  30208.    * Optimised MyISAM to be faster when inserting keys in sorted order.
  30209.  
  30210.    * `EXPLAIN SELECT..' now also prints out whether *MySQL* needs to
  30211.      create a temporary table or use file sorting when resolving the
  30212.      `SELECT'.
  30213.  
  30214.    * Added optimization to skip `ORDER BY' parts where the part is a
  30215.      constant expression in the `WHERE' part.  Indexes can now be used
  30216.      even if the `ORDER BY' doesn't match the index exactly, as long as
  30217.      all the not used index parts and all the extra `ORDER BY' columns
  30218.      are constants in the `WHERE' clause.  *Note MySQL indexes::.
  30219.  
  30220.    * `UPDATE' and `DELETE' on a whole unique key in the `WHERE' part,
  30221.      is now faster than before.
  30222.  
  30223.    * Changed `RAID_CHUNKSIZE' to be in 1024 byte increments.
  30224.  
  30225.    * Fixed coredump in LOAD_FILE(NULL).
  30226.  
  30227. Changes in release 3.23.14
  30228. --------------------------
  30229.  
  30230.    * Fixed a bug in `CONCAT()' where one of the arguments was a function
  30231.      that returned a modified argument.
  30232.  
  30233.    * Fixed a critical bug in `myisamchk', where it updated the header in
  30234.      the index file when one only checked the table.  This confused the
  30235.      `mysqld' daemon if it updated the same table at the same time. Now
  30236.      the status in the index file is only updated if one uses
  30237.      `--update-state'.  With older `myisamchk' versions you should use
  30238.      `--read-only' when only checking tables, if there is the slightest
  30239.      chance that the `mysqld' server is working on the table at the
  30240.      same time!
  30241.  
  30242.    * Fixed that `DROP TABLE' is logged in the update log.
  30243.  
  30244.    * Fixed problem when searching on `DECIMAL()' key field where the
  30245.      column data contained leading zeros.
  30246.  
  30247.    * Fix bug in `myisamchk' when the auto_increment isn't the first key.
  30248.  
  30249.    * Allow `DATETIME' in ISO8601 format: 2000-03-12T12:00:00
  30250.  
  30251.    * Dynamic character sets.  A `mysqld' binary can now handle many
  30252.      different character sets (you can choose which when starting
  30253.      `mysqld').
  30254.  
  30255.    * Added command `REPAIR TABLE'.
  30256.  
  30257.    * Added C API function `mysql_thread_safe()'.
  30258.  
  30259.    * Added the `UMASK_DIR' environment variable.
  30260.  
  30261.    * Added function `CONNECTION_ID()'.
  30262.  
  30263.    * When using `=' on `BLOB' or `VARCHAR BINARY' keys, where only a
  30264.      part of the column was indexed, the whole column of the result row
  30265.      wasn't compared.
  30266.  
  30267.    * Fix for sjis character set and `ORDER BY'.
  30268.  
  30269.    * When running in ANSI mode, don't allow columns to be used that
  30270.      aren't in the `GROUP BY' part.
  30271.  
  30272. Changes in release 3.23.13
  30273. --------------------------
  30274.  
  30275.    * Fixed problem when doing locks on the same table more than 2 times
  30276.      in the same `LOCK TABLE' command; This fixed the problem one got
  30277.      when running the test-ATIS test with `--fast' or
  30278.      `--check-only-changed'.
  30279.  
  30280.    * Added option `SQL_BUFFER_RESULT' to `SELECT'.
  30281.  
  30282.    * Removed end space from double/float numbers in results from
  30283.      temporary tables.  Added `CHECK TABLE' command.
  30284.  
  30285.    * Added changes for MyISAM in 3.23.12 that didn't get into the source
  30286.      distribution because of CVS problems.
  30287.  
  30288.    * Fixed bug so that mysqladmin shutdown will wait for the local
  30289.      server to close down.
  30290.  
  30291.    * Fixed a possible endless loop when calculating timestamp.
  30292.  
  30293.    * Added print_defaults to the .rpm files. Removed mysqlbug from the
  30294.      client rpm file.
  30295.  
  30296. Changes in release 3.23.12
  30297. --------------------------
  30298.  
  30299.    * Fixed bug in `MyISAM' involving `REPLACE ... SELECT' which could
  30300.      give a corrupted table.
  30301.  
  30302.    * Fixed bug in `myisamchk' where it wrongly reset the auto_increment
  30303.      value.
  30304.  
  30305.    * LOTS of patches for Linux Alpha. *MySQL* now appears to be
  30306.      relatively stable on Alpha.
  30307.  
  30308.    * Changed `DISTINCT' on `HEAP' temporary tables to use hashed keys
  30309.      to quickly find duplicated rows. This mostly concerns queries of
  30310.      type `SELECT DISTINCT ... GROUP BY ..'.  This fixes a problem where
  30311.      not all duplicates were removed in queries of the above type.  In
  30312.      addition, the new code is MUCH faster.
  30313.  
  30314.    * Added patches to make `MySQL' compile on MacOS X.
  30315.  
  30316.    * Added option `IF NOT EXISTS' to `CREATE DATABASE'.
  30317.  
  30318.    * Added options `--all-databases' and `--databases' to `mysqldump'
  30319.      to allow dumping of many databases at the same time.
  30320.  
  30321.    * Fixed bug in compressed `DECIMAL()' index in `MyISAM' tables.
  30322.  
  30323.    * Fixed bug when storing 0 into a timestamp.
  30324.  
  30325.    * When doing `mysqladmin shutdown' on a local connection,
  30326.      `mysqladmin' now waits until the pidfile is gone before
  30327.      terminating.
  30328.  
  30329.    * Fixed core dump with some `COUNT(DISTINCT ...)' queries.
  30330.  
  30331.    * Fixed that `myisamchk' works properly with RAID:ed tables.
  30332.  
  30333.    * Fixed problem with `LEFT JOIN' and `key_field IS NULL'.
  30334.  
  30335.    * Fixed bug in `net_clear()' which could give the error `Aborted
  30336.      connection' in the *MySQL* clients.
  30337.  
  30338.    * Added options `USE INDEX (key_list)' and `IGNORE INDEX (key_list)'
  30339.      as join parameters in `SELECT'.
  30340.  
  30341.    * `DELETE' and `RENAME' should now work on `RAID' tables.
  30342.  
  30343. Changes in release 3.23.11
  30344. --------------------------
  30345.  
  30346.    * Allow the `ALTER TABLE tbl_name ADD (field_list)' syntax.
  30347.  
  30348.    * Fixed problem with optimizer that could sometimes use wrong keys.
  30349.  
  30350.    * Fixed that `GRANT/REVOKE ALL PRIVILEGES' doesn't affect `GRANT
  30351.      OPTION'.
  30352.  
  30353.    * Removed extra `)' from the output of `SHOW GRANTS'
  30354.  
  30355.    * Fixed problem when storing numbers in timestamps.
  30356.  
  30357.    * Fix problem with timezones that have half hour offsets.
  30358.  
  30359.    * Allow the syntax `UNIQUE INDEX' in `CREATE' statements.
  30360.  
  30361.    * `mysqlhotcopy' - fast on-line hot-backup utility for local *MySQL*
  30362.      databases. By Tim Bunce.
  30363.  
  30364.    * New more secure `mysqlaccess'. Thanks to Steve Harvey for this.
  30365.  
  30366.    * Added options `--i-am-a-dummy' and `--safe-updates' to `mysql'.
  30367.  
  30368.    * Added variables `select_limit' and `max_join_size' to `mysql'.
  30369.  
  30370.    * Added sql variables: `SQL_MAX_JOIN_SIZE' and `SQL_SAFE_UPDATES'.
  30371.  
  30372.    * Added `READ LOCAL' lock that doesn't lock the table for concurrent
  30373.      inserts. (This is used by `mysqldump').
  30374.  
  30375.    * Changed that `LOCK TABLES .. READ' doesn't anymore allow concurrent
  30376.      inserts.
  30377.  
  30378.    * Added option `--skip-delay-key-write' to `mysqld'.
  30379.  
  30380.    * Fixed security problem in the protocol regarding password checking.
  30381.  
  30382.    * `_rowid' can now be used as an alias for an integer type unique
  30383.      indexed column.
  30384.  
  30385.    * Added back blocking of `SIGPIPE' when compiling with
  30386.      `--thread-safe-clients' to make things safe for old clients.
  30387.  
  30388. Changes in release 3.23.10
  30389. --------------------------
  30390.  
  30391.    * Fixed bug in 3.23.9 where memory wasn't properly freed when doing
  30392.      `LOCK TABLES'.
  30393.  
  30394. Changes in release 3.23.9
  30395. -------------------------
  30396.  
  30397.    * Fixed problem that affected queries that did arithmetic on group
  30398.      functions.
  30399.  
  30400.    * Fixed problem with timestamps and `INSERT DELAYED'.
  30401.  
  30402.    * Fixed that `date_column BETWEEN const_date AND const_date' works.
  30403.  
  30404.    * Fixed problem when only changing a 0 to `NULL' in a table with
  30405.      `BLOB/TEXT' columns.
  30406.  
  30407.    * Fixed bug in range optimizer when using many key parts and or on
  30408.      the middle key parts:  `WHERE K1=1 and K3=2 and (K2=2 and K4=4 or
  30409.      K2=3 and K4=5)'
  30410.  
  30411.    * Added command `source' to `mysql' to allow reading of batch files
  30412.      inside the `mysql' client.  Original patch by Matthew Vanecek.
  30413.  
  30414.    * Fixed critical problem with the `WITH GRANT OPTION' option.
  30415.  
  30416.    * Don't give an unnecessary `GRANT' error when using tables from many
  30417.      databases in the same query.
  30418.  
  30419.    * Added VIO wrapper (needed for SSL support ; By Andrei Errapart and
  30420.      T⌡nu Samuel).
  30421.  
  30422.    * Fixed optimizer problem on `SELECT' when using many overlapping
  30423.      indexes.  *MySQL* should now be able to choose keys even better
  30424.      when there is many keys to choose from.
  30425.  
  30426.    * Changed optimizer to prefer a range key instead of a ref key when
  30427.      the range key can uses more columns than the ref key (which only
  30428.      can use columns with =).  For example, the following type of
  30429.      queries should now be faster: `SELECT * from key_part_1=const and
  30430.      key_part_2 > const2'
  30431.  
  30432.    * Fixed bug that a change of all `VARCHAR' columns to `CHAR' columns
  30433.      didn't change row type from dynamic to fixed.
  30434.  
  30435.    * Disabled floating point exceptions for FreeBSD to fix core dump
  30436.      when doing `SELECT floor(pow(2,63))'.
  30437.  
  30438.    * Changed `mysqld' startup option `--delay-key-write' to
  30439.      `--delay-key-write-for-all-tables'
  30440.  
  30441.    * Added `read-next-on-key' to `HEAP' tables.  This should fix all
  30442.      problems with `HEAP' tables when using not `UNIQUE' keys.
  30443.  
  30444.    * Added print of default arguments options to all clients.
  30445.  
  30446.    * Added `--log-slow-queries' to `mysqld' to log all queries that
  30447.      take a long time to a separate log file with a time of how long
  30448.      the query took.
  30449.  
  30450.    * Fixed core dump when doing `WHERE key_column=RAND(...)'
  30451.  
  30452.    * Fixed optimization bug in `SELECT .. LEFT JOIN ... key_column IS
  30453.      NULL', when `key_column' could contain `NULL' values.
  30454.  
  30455.    * Fixed problem with 8-bit characters as separators in `LOAD DATA
  30456.      INFILE'.
  30457.  
  30458.    *
  30459. Changes in release 3.23.8
  30460. -------------------------
  30461.  
  30462.    * Fixed problem when handling indexfiles larger than 8G.
  30463.  
  30464.    * Added latest patches to mit-pthreads for NetBSD.
  30465.  
  30466.    * Fixed problem with timezones that are < GMT -11.
  30467.  
  30468.    * Fixed a bug when deleting packed keys in `NISAM'.
  30469.  
  30470.    * Fixed problem with `ISAM' when doing some `ORDER BY ... DESC'
  30471.      queries.
  30472.  
  30473.    * Fixed bug when doing a join on a text key which didn't cover the
  30474.      whole key.
  30475.  
  30476.    * Option `--delay-key-write' didn't enable delayed key writing.
  30477.  
  30478.    * Fixed update of `TEXT' column which only involved case changes.
  30479.  
  30480.    * Fixed that `INSERT DELAYED' doesn't update timestamps that are
  30481.      given.
  30482.  
  30483.    * Added function `YEARWEEK()' and options `x', `X', `v' and `V' to
  30484.      `DATE_FORMAT()'.
  30485.  
  30486.    * Fixed problem with `MAX(indexed_column)' and HEAP tables.
  30487.  
  30488.    * Fixed problem with `BLOB NULL' keys and `LIKE' "prefix%".
  30489.  
  30490.    * Fixed problem with `MyISAM' and fixed length rows < 5 bytes.
  30491.  
  30492.    * Fixed problem that could cause *MySQL* to touch freed memory when
  30493.      doing very complicated `GROUP BY' queries.
  30494.  
  30495.    * Fixed core dump if you got a crashed table where an `ENUM' field
  30496.      value was too big.
  30497.  
  30498. Changes in release 3.23.7
  30499. -------------------------
  30500.  
  30501.    * Fixed workaround under Linux to avoid problems with
  30502.      `pthread_mutex_timedwait', which is used with `INSERT DELAYED'.
  30503.      *Note Linux::.
  30504.  
  30505.    * Fixed that one will get a 'disk full' error message if one gets
  30506.      disk full when doing sorting (instead of waiting until we got more
  30507.      disk space).
  30508.  
  30509.    * Fixed a bug in `MyISAM' with keys > 250 characters.
  30510.  
  30511.    * In `MyISAM' one can now do an `INSERT' at the same time as other
  30512.      threads are reading from the table.
  30513.  
  30514.    * Added variable `max_write_lock_count' to `mysqld' to force a
  30515.      `READ' lock after a certain number of `WRITE' locks.
  30516.  
  30517.    * Inverted flag `delayed_key_write' on `show variables'.
  30518.  
  30519.    * Renamed variable `concurrency' to `thread_concurrency'.
  30520.  
  30521.    * The following functions are now multi-byte-safe:
  30522.      `LOCATE(substr,str)', `POSITION(substr IN str)',
  30523.      `LOCATE(substr,str,pos)', `INSTR(str,substr)', `LEFT(str,len)',
  30524.      `RIGHT(str,len)', `SUBSTRING(str,pos,len)', `SUBSTRING(str FROM
  30525.      pos FOR len)', `MID(str,pos,len)', `SUBSTRING(str,pos)',
  30526.      `SUBSTRING(str FROM pos)', `SUBSTRING_INDEX(str,delim,count)',
  30527.      `RTRIM(str)', `TRIM([[BOTH | TRAILING] [remstr] FROM] str)',
  30528.      `REPLACE(str,from_str,to_str)', `REVERSE(str)',
  30529.      `INSERT(str,pos,len,newstr)', `LCASE(str)', `LOWER(str)',
  30530.      `UCASE(str)' and `UPPER(str)';  Patch by Wei He.
  30531.  
  30532.    * Fix core dump when releasing a lock from a non-existant table.
  30533.  
  30534.    * Remove locks on tables before starting to remove duplicates.
  30535.  
  30536.    * Added option `FULL' to `SHOW PROCESSLIST'.
  30537.  
  30538.    * Added option `--verbose' to `mysqladmin'.
  30539.  
  30540.    * Fixed problem when automatically converting HEAP to MyISAM.
  30541.  
  30542.    * Fixed bug in HEAP tables when doing insert + delete + insert +
  30543.      scan the table.
  30544.  
  30545.    * Fixed bugs on Alpha with `REPLACE()' and `LOAD DATA INFILE'.
  30546.  
  30547.    * Added `mysqld' variable `interactive_timeout'.
  30548.  
  30549.    * Changed the argument to `mysql_data_seek()' from `ulong' to
  30550.      `ulonglong'.
  30551.  
  30552. Changes in release 3.23.6
  30553. -------------------------
  30554.  
  30555.    * Added `mysqld' option `-O lower_case_table_names={0|1}' to allow
  30556.      users to force table names to lower case.
  30557.  
  30558.    * Added `SELECT ... INTO DUMPFILE'.
  30559.  
  30560.    * Added mysqld option `--ansi' to make some functions `ANSI SQL'
  30561.      compatible.
  30562.  
  30563.    * Temporary tables now starts with `#sql'.
  30564.  
  30565.    * Added quoting of identifiers with ``' (`"' in `--ansi' mode).
  30566.  
  30567.    * Changed to use snprintf() when printing floats to avoid some buffer
  30568.      overflows on FreeBSD.
  30569.  
  30570.    * Made `[floor()' overflow safe on FreeBSD.
  30571.  
  30572.    * Added option `--quote-names' to `mysqldump'
  30573.  
  30574.    * Fixed bug that one could make a part of a `PRIMARY KEY NOT NULL'.
  30575.  
  30576.    * Fixed `encrypt()' to be thread safe and not reuse buffer.
  30577.  
  30578.    * Added `mysql_odbc_escape_string()' function to support big5
  30579.      characters in MyOBC.
  30580.  
  30581.    * Rewrote the table handler to use classes.  This introduces a lot
  30582.      of new code, but will make table handling faster and better.
  30583.  
  30584.    * Added patch by Sasha for user defined variables.
  30585.  
  30586.    * Changed that `FLOAT' and `DOUBLE' (without any length modifiers)
  30587.      are not anymore fixed decimal point numbers.
  30588.  
  30589.    * Changed the meaning of `FLOAT(X)': Now this is the same as `FLOAT'
  30590.      if X <= 24 and a `DOUBLE' if 24 < X <= 53.
  30591.  
  30592.    * `DECIMAL(X)' is now an alias for `DECIMAL(X,0)' and `DECIMAL' is
  30593.      now an alias for `DECIMAL(10,0)'.  The same goes for `NUMERIC'.
  30594.  
  30595.    * Added option `ROW_FORMAT={default | dynamic | static |
  30596.      compressed}' to `CREATE_TABLE'.
  30597.  
  30598.    * `DELETE FROM table_name' didn't work on temporary tables.
  30599.  
  30600.    * Changed function `CHAR_LENGTH()' to be multi-byte character safe.
  30601.  
  30602.    * Added function `ORD(string)'.
  30603.  
  30604. Changes in release 3.23.5
  30605. -------------------------
  30606.  
  30607.    * Fixed some Y2K problems in the new date handling in 3.23.
  30608.  
  30609.    * Fixed problem with `SELECT DISTINCT ... ORDER BY RAND()'.
  30610.  
  30611.    * Added patches by Sergei A. Golubchik for text searching on the
  30612.      MyISAM level.
  30613.  
  30614.    * Fixed cache overflow problem when using full joins without keys.
  30615.  
  30616.    * Fixed some configure issues.
  30617.  
  30618.    * Some small changes to make parsing faster.
  30619.  
  30620.    * `ALTER TABLE' + adding a column after the last field didn't work.
  30621.  
  30622.    * Fixed problem when using an auto_increment column in two keys
  30623.  
  30624.    * One can now with MyISAM have the auto_increment part as a sub part:
  30625.      `CREATE TABLE foo (a int not null auto_increment, b char(5),
  30626.      primary key (b,a))'
  30627.  
  30628.    * Fixed bug in MyISAM with packed char keys that could be `NULL'.
  30629.  
  30630.    * `AS' on fieldname with `CREATE TABLE table_name SELECT ...' didn't
  30631.      work.
  30632.  
  30633.    * Allow use of `NATIONAL' and `NCHAR' when defining character
  30634.      columns.  This is the same as not using `BINARY'.
  30635.  
  30636.    * Don't allow `NULL' columns in a `PRIMARY KEY' (only in `UNIQUE'
  30637.      keys).
  30638.  
  30639.    * Clear `LAST_INSERT_ID' if one uses this in ODBC: `WHERE
  30640.      auto_increment_column IS NULL'.  This seems to fix some problems
  30641.      with Access.
  30642.  
  30643.    * `SET SQL_AUTO_IS_NULL=0|1' now turns on/off the handling of
  30644.      searching after the last inserted row with `WHERE
  30645.      auto_increment_column IS NULL'.
  30646.  
  30647.    * Added new `mysqld' variable `concurrency' for Solaris.
  30648.  
  30649.    * Added option `--relative' to `mysqladmin' to make
  30650.      `extended-status' more useful to monitor changes.
  30651.  
  30652.    * Fixed bug when using `COUNT(DISTINCT..)' on an empty table.
  30653.  
  30654.    * Added support for the Chinese character set GBK.
  30655.  
  30656.    * Fixed problem with `LOAD DATA INFILE' and `BLOB' columns.
  30657.  
  30658.    * Added bit operator `~' (negation).
  30659.  
  30660.    * Fixed problem with `UDF' functions.
  30661.  
  30662. Changes in release 3.23.4
  30663. -------------------------
  30664.  
  30665.    * Inserting a `DATETIME' into a `TIME' column will not anymore try
  30666.      to store 'days' in it.
  30667.  
  30668.    * Fixed problem with storage of float/double on little endian
  30669.      machines.  (This affected `SUM()'.)
  30670.  
  30671.    * Added connect timeout on TCP/IP connections.
  30672.  
  30673.    * Fixed problem with `LIKE' "%" on an index that may have `NULL'
  30674.      values.
  30675.  
  30676.    * `REVOKE ALL PRIVILEGES' didn't revoke all privileges.
  30677.  
  30678.    * Allow creation of temporary tables with same name as the original
  30679.      table.
  30680.  
  30681.    * When granting a user a grant option for a database, he couldn't
  30682.      grant privileges to other users.
  30683.  
  30684.    * New command: `SHOW GRANTS FOR user' (by Sinisa).
  30685.  
  30686.    * New `date_add' syntax:  `date/datetime + INTERVAL # interval_type'.
  30687.      By Joshua Chamas.
  30688.  
  30689.    * Fixed privilege check for `LOAD DATA REPLACE'.
  30690.  
  30691.    * Automatic fixing of broken include files on Solaris 2.7
  30692.  
  30693.    * Some configure issues to fix problems with big file system
  30694.      detection.
  30695.  
  30696.    * `REGEXP' is now case insensitive if you use non-binary strings.
  30697.  
  30698. Changes in release 3.23.3
  30699. -------------------------
  30700.  
  30701.      Added patches for MIT-pthreads on NetBSD.
  30702.  
  30703.    * Fixed range bug in MyISAM.
  30704.  
  30705.    * `ASC' is now the default again for `ORDER BY'.
  30706.  
  30707.    * Added `LIMIT' to `UPDATE'.
  30708.  
  30709.    * New client function: `mysql_change_user()'.
  30710.  
  30711.    * Added character set to `SHOW VARIABLES'.
  30712.  
  30713.    * Added support of `--[whitespace]' comments.
  30714.  
  30715.    * Allow `INSERT into tbl_name VALUES ()', that is, you may now
  30716.      specify an empty value list to insert a row in which each column
  30717.      is set to its default value.
  30718.  
  30719.    * Changed `SUBSTRING(text FROM pos)' to conform to ANSI SQL. (Before
  30720.      this construct returned the rightmost 'pos' characters).
  30721.  
  30722.    * `SUM(..)' with `GROUP BY' returned 0 on some systems.
  30723.  
  30724.    * Changed output for `SHOW TABLE STATUS'.
  30725.  
  30726.    * Added `DELAY_KEY_WRITE' option to `CREATE TABLE'.
  30727.  
  30728.    * Allow `AUTO_INCREMENT' on any key part.
  30729.  
  30730.    * Fixed problem with `YEAR(NOW())' and `YEAR(CURDATE())'.
  30731.  
  30732.    * Added `CASE' construct.
  30733.  
  30734.    * New function `COALESCE()'.
  30735.  
  30736. Changes in release 3.23.2
  30737. -------------------------
  30738.  
  30739.    * Fixed range optimizer bug: `SELECT * FROM table_name WHERE
  30740.      key_part1 >= const AND (key_part2 = const OR key_part2 = const)'.
  30741.      The bug was that some rows could be duplicated in the result.
  30742.  
  30743.    * Running `myisamchk' without `-a' updated the index distribution
  30744.      wrong.
  30745.  
  30746.    * `SET SQL_LOW_PRIORITY_UPDATES=1' gave parse error before.
  30747.  
  30748.    * You can now update indexes columns that are used in the `WHERE'
  30749.      clause.  `UPDATE tbl_name SET KEY=KEY+1 WHERE KEY > 100'
  30750.  
  30751.    * Date handling should now be a bit faster.
  30752.  
  30753.    * Added handling of fuzzy dates (dates where day or month is 0):
  30754.      (Like: 1999-01-00)
  30755.  
  30756.    * Fixed optimization of `SELECT ... WHERE key_part1=const1 AND
  30757.      key_part_2=const2 AND key_part1=const4 AND key_part2=const4' ;
  30758.      Indextype should be `range' instead of `ref'.
  30759.  
  30760.    * Fixed `egcs' 1.1.2 optimizer bug (when using `BLOB's) on Linux
  30761.      Alpha.
  30762.  
  30763.    * Fixed problem with `LOCK TABLES' combined with `DELETE FROM table'.
  30764.  
  30765.    * MyISAM tables now allow keys on `NULL' and `BLOB/TEXT' columns.
  30766.  
  30767.    * The following join is now much faster: `SELECT ... FROM t1 LEFT
  30768.      JOIN t2 ON ... WHERE t2.not_null_column IS NULL'.
  30769.  
  30770.    * `ORDER BY' and `GROUP BY' can be done on functions.
  30771.  
  30772.    * Changed handling of 'const_item' to allow handling of `ORDER BY
  30773.      RAND()'.
  30774.  
  30775.    * Indexes are now used for `WHERE key_column = function'.
  30776.  
  30777.    * Indexes are now used for `WHERE key_column = column_name' even if
  30778.      the columns are not identically packed.
  30779.  
  30780.    * Indexes are now used for `WHERE column_name IS NULL'.
  30781.  
  30782.    * Changed heap tables to be stored in low_byte_first order (to make
  30783.      it easy to convert to MyISAM tables)
  30784.  
  30785.    * Automatic change of HEAP temporary tables to MyISAM tables in case
  30786.      of 'table is full' errors.
  30787.  
  30788.    * Added option `--init-file=file_name' to `mysqld'.
  30789.  
  30790.    * `COUNT(DISTINCT value,[value,...])'
  30791.  
  30792.    * `CREATE TEMPORARY TABLE' now creates a temporary table, in its own
  30793.      namespace, that is automatically deleted if connection is dropped.
  30794.  
  30795.    * New reserved words (required for `CASE'):  `CASE, THEN, WHEN, ELSE
  30796.      and END'.
  30797.  
  30798.    * New functions `EXPORT_SET()' and `MD5()'.
  30799.  
  30800.    * Support for the GB2312 Chinese character set.
  30801.  
  30802. Changes in release 3.23.1
  30803. -------------------------
  30804.  
  30805.    * Fixed some compilation problems.
  30806.  
  30807. Changes in release 3.23.0
  30808. -------------------------
  30809.  
  30810.      A new table handler library (`MyISAM') with a lot of new features.
  30811.      *Note MyISAM::.
  30812.  
  30813.    * You can create in-memory `HEAP' tables which are extremely fast for
  30814.      lookups.
  30815.  
  30816.    * Support for big files (63 bit) on OSes that support big files.
  30817.  
  30818.    * New function `LOAD_FILE(filename)' to get the contents of a file
  30819.      as a string value.
  30820.  
  30821.    * New operator `<=>' which will act as `=' but will return TRUE if
  30822.      both arguments are `NULL'.  This is useful for comparing changes
  30823.      between tables.
  30824.  
  30825.    * Added the ODBC 3.0 `EXTRACT(interval FROM datetime)' function.
  30826.  
  30827.    * Columns defined as `FLOAT(X)' is not rounded on storage and may be
  30828.      in scientific notation (1.0 E+10) when retrieved.
  30829.  
  30830.    * `REPLACE' is now faster than before.
  30831.  
  30832.    * Changed `LIKE' character comparison to behave as `='; This means
  30833.      that `'e' LIKE 'e''' is now true.
  30834.  
  30835.    * `SHOW TABLE STATUS' returns a lot of information about the tables.
  30836.  
  30837.    * Added `LIKE' to the `SHOW STATUS' command.
  30838.  
  30839.    * Added privilege column to `SHOW COLUMNS'.
  30840.  
  30841.    * Added columns `packed' and `comment' to `SHOW INDEX'.
  30842.  
  30843.    * Added comments to tables (with `CREATE TABLE ... COMMENT "xxx"').
  30844.  
  30845.    * Added `UNIQUE', as in `CREATE TABLE table_name (col int not null
  30846.      UNIQUE)'
  30847.  
  30848.    * New create syntax: `CREATE TABLE table_name SELECT ....'
  30849.  
  30850.    * New create syntax: `CREATE TABLE IF NOT EXISTS ...'
  30851.  
  30852.    * Allow creation of `CHAR(0)' columns.
  30853.  
  30854.    * `DATE_FORMAT()' now requires `%' before any format character.
  30855.  
  30856.    * `DELAYED' is now a reserved word (sorry about that :( ).
  30857.  
  30858.    * An example procedure is added: `analyse', file: `sql_analyse.c'.
  30859.      This will describe the data in your query.  Try the following:
  30860.           SELECT ... FROM ... WHERE ... PROCEDURE ANALYSE([max elements,[max memory]])
  30861.  
  30862.      This procedure is extremely useful when you want to check the data
  30863.      in your table!
  30864.  
  30865.    * `BINARY' cast to force a string to be compared case sensitively.
  30866.  
  30867.    * Added option `--skip-show-database' to `mysqld'.
  30868.  
  30869.    * Check if a row has changed in an `UPDATE' now also works with
  30870.      `BLOB'/`TEXT' columns.
  30871.  
  30872.    * Added the `INNER' join syntax.  *NOTE*:  This made `INNER' a
  30873.      reserved word!
  30874.  
  30875.    * Added support for netmasks to the hostname in the *MySQL* tables.
  30876.      You can specify a netmask using the `IP/NETMASK' syntax.
  30877.  
  30878.    * If you compare a `NOT NULL DATE/DATETIME' column with `IS NULL',
  30879.      this is changed to a compare against `0' to satisfy some ODBC
  30880.      applications.  (By <shreeve@uci.edu>).
  30881.  
  30882.    * `NULL IN (...)' now returns `NULL' instead of `0'.  This will
  30883.      ensure that `null_column NOT IN (...)' doesn't match `NULL' values.
  30884.  
  30885.    * Fix storage of floating point values in `TIME' columns.
  30886.  
  30887.    * Changed parsing of `TIME' strings to be more strict.  Now the
  30888.      fractional second part is detected (and currently skipped). The
  30889.      following formats are supported:
  30890.     `[[DAYS] [H]H:]MM:]SS[.fraction]'
  30891.  
  30892.     `[[[[[H]H]H]H]MM]SS[.fraction]'
  30893.    * Detect (and ignore) second fraction part from `DATETIME'.
  30894.  
  30895.    * Added the `LOW_PRIORITY' attribute to `LOAD DATA INFILE'.
  30896.  
  30897.    * The default index name now uses the same case as the used column
  30898.      name.
  30899.  
  30900.    * Changed default number of connections to 100.
  30901.  
  30902.    * Use bigger buffers when using `LOAD DATA INFILE'.
  30903.  
  30904.    * `DECIMAL(x,y)' now works according to ANSI SQL.
  30905.  
  30906.    * Added aggregate UDF functions. Thanks to Andreas F. Bobak
  30907.      <bobak@relog.ch> for this!
  30908.  
  30909.    * `LAST_INSERT_ID()' is now updated for `INSERT INTO ... SELECT'.
  30910.  
  30911.    * Some small changes to the join table optimizer to make some joins
  30912.      faster.
  30913.  
  30914.    * `SELECT DISTINCT' is much faster; It uses the new `UNIQUE'
  30915.      functionality in `MyISAM'. One difference compared to *MySQL* 3.22
  30916.      is that the output of `DISTINCT' is not sorted anymore.
  30917.  
  30918.    * All C client API macros are now functions to make shared libraries
  30919.      more reliable. Because of this, you can no longer call
  30920.      `mysql_num_fields()' on a `MYSQL' object, you must use
  30921.      `mysql_field_count()' instead.
  30922.  
  30923.    * Added use of `LIBEWRAP';  Patch by Henning P . Schmiedehausen.
  30924.  
  30925.    * Don't allow `AUTO_INCREMENT' for other than numerical columns.
  30926.  
  30927.    * Using `AUTO_INCREMENT' will now automatically make the column `NOT
  30928.      NULL'.
  30929.  
  30930.    * Show `NULL' as the default value for AUTO_INCREMENT columns.
  30931.  
  30932.    * Added `SQL_BIG_RESULT';  `SQL_SMALL_RESULT' is now default.
  30933.  
  30934.    * Added a shared library RPM. This enchancement was contributed by
  30935.      David Fox (dsfox@cogsci.ucsd.edu).
  30936.  
  30937.    * Added a `--enable-large-files/--disable-large-files' switch to
  30938.      `configure'. See `configure.in' for some systems where this is
  30939.      automatically turned off because of broken implementations.
  30940.  
  30941.    * Upgraded `readline' to 4.0.
  30942.  
  30943.    * New `CREATE TABLE' options: `PACK_KEYS' and `CHECKSUM'.
  30944.  
  30945.    * Added `mysqld' option `--default-table-type'.
  30946.  
  30947. Changes in release 3.22.x
  30948. =========================
  30949.  
  30950. The 3.22 version has faster and safer connect code and a lot of new nice
  30951. enhancements.  The reason for not including these changes in the 3.21
  30952. version is mainly that we are trying to avoid big changes to 3.21 to
  30953. keep it as stable as possible.  As there aren't really any MAJOR
  30954. changes, upgrading to 3.22 should be very easy and painless.  *Note
  30955. Upgrading-from-3.21::.
  30956.  
  30957. 3.22 should also be used with the new `DBD-mysql' (1.20xx) driver that
  30958. can use the new connect protocol!
  30959.  
  30960. Changes in release 3.22.35
  30961. --------------------------
  30962.  
  30963.    * Fixed problem with `STD()'.
  30964.  
  30965.    * Merged changes from the newest `ISAM' library from 3.23.
  30966.  
  30967.    * Fixed problem with `INSERT DELAYED'.
  30968.  
  30969.    * Fixed a bug core dump when using a `LEFT JOIN'/`STRAIGHT_JOIN' on
  30970.      a table with only one row.
  30971.  
  30972. Changes in release 3.22.34
  30973. --------------------------
  30974.  
  30975.    * Fixed problem with `GROUP BY' on `TINYBLOB' columns;  This caused
  30976.      bugzilla to not show rows in some queries.
  30977.  
  30978.    * Had to do total recompile of the Windows binary version as VC++
  30979.      didn't compile all relevant files for 3.22.33 :(
  30980.  
  30981. Changes in release 3.22.33
  30982. --------------------------
  30983.  
  30984.    * Fixed problems in windows when locking tables with `LOCK TABLE'
  30985.  
  30986.    * Quicker kill of `SELECT DISTINCT' queries.
  30987.  
  30988. Changes in release 3.22.32
  30989. --------------------------
  30990.  
  30991.    * Fixed problem when storing numbers in timestamps.
  30992.  
  30993.    * Fix problem with timezones that have half hour offsets.
  30994.  
  30995.    * `mysqlhotcopy' - fast on-line hot-backup utility for local *MySQL*
  30996.      databases. By Tim Bunce.
  30997.  
  30998.    * New more secure `mysqlaccess'. Thanks to Steve Harvey for this.
  30999.  
  31000.    * Fixed security problem in the protocol regarding password checking.
  31001.  
  31002.    * Fixed problem that affected queries that did arithmetic on `GROUP'
  31003.      functions.
  31004.  
  31005.    * Fixed a bug in the `ISAM' code when deleting rows on tables with
  31006.      packed indexes.
  31007.  
  31008. Changes in release 3.22.31
  31009. --------------------------
  31010.  
  31011.    * A few small fixes for the Win32 version.
  31012.  
  31013. Changes in release 3.22.30
  31014. --------------------------
  31015.  
  31016.    * Fixed optimizer problem on `SELECT' when using many overlapping
  31017.      indexes.
  31018.  
  31019.    * Disabled floating point exceptions for FreeBSD to fix core dump
  31020.      when doing `SELECT floor(pow(2,63))'.
  31021.  
  31022.    * Added print of default arguments options to all clients.
  31023.  
  31024.    * Fixed critical problem with the `WITH GRANT OPTION' option.
  31025.  
  31026.    * Fixed non-critical Y2K problem when writing short date to log
  31027.      files.
  31028.  
  31029. Changes in release 3.22.29
  31030. --------------------------
  31031.  
  31032.    * Upgraded the configure and include files to match the latest 3.23
  31033.      version.  This should increase portability and make it easier to
  31034.      build shared libraries.
  31035.  
  31036.    * Added latest patches to mit-pthreads for NetBSD.
  31037.  
  31038.    * Fixed problem with timezones that are < GMT -11.
  31039.  
  31040.    * Fixed a bug when deleting packed keys in NISAM.
  31041.  
  31042.    * Fixed problem that could cause *MySQL* to touch freed memory when
  31043.      doing very complicated `GROUP BY' queries.
  31044.  
  31045.    * Fixed core dump if you got a crashed table where an `ENUM' field
  31046.      value was too big.
  31047.  
  31048.    * Added `mysqlshutdown.exe' and `mysqlwatch.exe' to the Windows
  31049.      distribution.
  31050.  
  31051.    * Fixed problem when doing `ORDER BY' on a reference key.
  31052.  
  31053.    * Fixed that `INSERT DELAYED' doesn't update timestamps that are
  31054.      given.
  31055.  
  31056.  
  31057. Changes in release 3.22.28
  31058. --------------------------
  31059.  
  31060.    * Fixed problem with `LEFT JOIN' and `COUNT()' on a column which was
  31061.      declared `NULL' + and it had a `DEFAULT' value.
  31062.  
  31063.    * Fixed core dump problem when using `CONCAT()' in a `WHERE' clause.
  31064.  
  31065.    * Fixed problem with `AVG()' and `STD()' with `NULL' values.
  31066.  
  31067. Changes in release 3.22.27
  31068. --------------------------
  31069.  
  31070.    * Fixed prototype in `my_ctype.h' when using other character sets.
  31071.  
  31072.    * Some configure issues to fix problems with big file system
  31073.      detection.
  31074.  
  31075.    * Fixed problem when sorting on big blob columns.
  31076.  
  31077.    * `ROUND()' will now work on Win32.
  31078.  
  31079. Changes in release 3.22.26
  31080. --------------------------
  31081.  
  31082.    * Fixed core dump with empty `BLOB/TEXT' column to `REVERSE()'.
  31083.  
  31084.    * Extended `/*! */' with version numbers.
  31085.  
  31086.    * Changed `SUBSTRING(text FROM pos)' to conform to ANSI SQL. (Before
  31087.      this construct returned the rightmost 'pos' characters).
  31088.  
  31089.    * Fixed problem with `LOCK TABLES' combined with `DELETE FROM table'
  31090.  
  31091.    * Fixed problem that INSERT ... SELECT didn't use SQL_BIG_TABLES.
  31092.  
  31093.    * `SET SQL_LOW_PRIORITY_UPDATES=#' didn't work.
  31094.  
  31095.    * Password wasn't updated correctly if privileges didn't change on:
  31096.      `GRANT ... IDENTIFIED BY'
  31097.  
  31098.    * Fixed range optimizer bug in `SELECT * FROM table_name WHERE
  31099.      key_part1 >= const AND (key_part2 = const OR key_part2 = const)'
  31100.  
  31101.    * Fixed bug in compression key handling in ISAM.
  31102.  
  31103. Changes in release 3.22.25
  31104. --------------------------
  31105.  
  31106.    * Fixed some small problems with the installation.
  31107.  
  31108. Changes in release 3.22.24
  31109. --------------------------
  31110.  
  31111.    * `DATA' is not a reserved word anymore.
  31112.  
  31113.    * Fixed optimizer bug with tables with only one row.
  31114.  
  31115.    * Fixed bug when using `LOCK TABLES table_name READ; FLUSH TABLES;'
  31116.  
  31117.    * Applied some patches for HP-UX.
  31118.  
  31119.    * `isamchk' should now work on Win32.
  31120.  
  31121.    * Changed `configure' to not use big file handling on Linux as this
  31122.      crashes some RedHat 6.0 systems
  31123.  
  31124. Changes in release 3.22.23
  31125. --------------------------
  31126.  
  31127.    * Upgraded to use Autoconf 2.13, Automake 1.4 and `libtool' 1.3.2.
  31128.  
  31129.    * Better support for SCO in `configure'.
  31130.  
  31131.    * Added option `--defaults-file=###' to option file handling to
  31132.      force use of only one specific option file.
  31133.  
  31134.    * Extended `CREATE' syntax to ignore *MySQL* 3.23 keywords.
  31135.  
  31136.    * Fixed deadlock problem when using `INSERT DELAYED' on a table
  31137.      locked with `LOCK TABLES'.
  31138.  
  31139.    * Fixed deadlock problem when using `DROP TABLE' on a table that was
  31140.      locked by another thread.
  31141.  
  31142.    * Add logging of `GRANT/REVOKE' commands in the update log.
  31143.  
  31144.    * Fixed `isamchk' to detect a new error condition.
  31145.  
  31146.    * Fixed bug in `NATURAL LEFT JOIN'.
  31147.  
  31148. Changes in release 3.22.22
  31149. --------------------------
  31150.  
  31151.    * Fixed problem in the C API when you called `mysql_close()'
  31152.      directly after `mysql_init()'.
  31153.  
  31154.    * Better client error message when you can't open socket.
  31155.  
  31156.    * Fixed `delayed_insert_thread' counting when you couldn't create a
  31157.      new delayed_insert thread.
  31158.  
  31159.    * Fixed bug in `CONCAT()' with many arguments.
  31160.  
  31161.    * Added patches for DEC 3.2 and SCO.
  31162.  
  31163.    * Fixed path-bug when installing *MySQL* as a service on NT.
  31164.  
  31165.    * The *MySQL*-Win32 version is now compiled with VC++ 6.0 instead of
  31166.      with VC++ 5.0.
  31167.  
  31168.    * New installation setup for *MySQL*-Win32.
  31169.  
  31170. Changes in release 3.22.21
  31171. --------------------------
  31172.  
  31173.    * Fixed problem with `DELETE FROM TABLE' when table was locked by
  31174.      another thread.
  31175.  
  31176.    * Fixed bug in `LEFT JOIN' involving empty tables.
  31177.  
  31178.    * Changed the `mysql.db' column from `char(32)' to `char(60)'.
  31179.  
  31180.    * `MODIFY' and `DELAYED' are not reserved words anymore.
  31181.  
  31182.    * Fixed a bug when storing days in a `TIME' column.
  31183.  
  31184.    * Fixed a problem with `Host '..' is not allowed to connect to this
  31185.      MySQL server' after one had inserted a new *MySQL* user with a
  31186.      `GRANT' command.
  31187.  
  31188.    * Changed to use `TCP_NODELAY' also on Linux (Should give faster
  31189.      TCP/IP connections).
  31190.  
  31191. Changes in release 3.22.20
  31192. --------------------------
  31193.  
  31194.    * Fixed `STD()' for big tables when result should be 0.
  31195.  
  31196.    * The update log didn't have newlines on some operating systems.
  31197.  
  31198.    * `INSERT DELAYED' had some garbage at end in the update log.
  31199.  
  31200. Changes in release 3.22.19
  31201. --------------------------
  31202.  
  31203.    * Fixed bug in `mysql_install_db' (from 3.22.17).
  31204.  
  31205.    * Changed default key cache size to 8M.
  31206.  
  31207.    * Fixed problem with queries that needed temporary tables with `BLOB'
  31208.      columns.
  31209.  
  31210. Changes in release 3.22.18
  31211. --------------------------
  31212.  
  31213.    * Fixes a fatal problem in 3.22.17 on Linux;  After `shutdown' all
  31214.      threads didn't die properly.
  31215.  
  31216.    * Added option `-O flush_time=#' to `mysqld'.  This is mostly useful
  31217.      on Win32 and tells how often *MySQL* should close all unused
  31218.      tables and flush all updated tables to disk.
  31219.  
  31220.    * Fixed problem that a `VARCHAR' column compared with `CHAR' column
  31221.      didn't use keys efficiently.
  31222.  
  31223. Changes in release 3.22.17
  31224. --------------------------
  31225.  
  31226.    * Fixed a core dump problem when using `--log-update' and connecting
  31227.      without a default database.
  31228.  
  31229.    * Fixed some `configure' and portability problems.
  31230.  
  31231.    * Using `LEFT JOIN' on tables that had circular dependencies caused
  31232.      `mysqld' to hang forever.
  31233.  
  31234. Changes in release 3.22.16
  31235. --------------------------
  31236.  
  31237.    * `mysqladmin processlist' could kill the server if a new user
  31238.      logged in.
  31239.  
  31240.    * `DELETE FROM tbl_name WHERE key_column=col_name' didn't find any
  31241.      matching rows.  Fixed.
  31242.  
  31243.    * `DATE_ADD(column,...)' didn't work.
  31244.  
  31245.    * `INSERT DELAYED' could deadlock with status 'upgrading lock'
  31246.  
  31247.    * Extended `ENCRYPT()' to take longer salt strings than 2 characters.
  31248.  
  31249.    * `longlong2str' is now much faster than before.  For `Intel x86'
  31250.      platforms, this function is written in optimized assembler.
  31251.  
  31252.    * Added the `MODIFY' keyword to `ALTER TABLE'.
  31253.  
  31254. Changes in release 3.22.15
  31255. --------------------------
  31256.  
  31257.    * `GRANT' used with `IDENTIFIED BY' didn't take effect until
  31258.      privileges were flushed.
  31259.  
  31260.    * Name change of some variables in `SHOW STATUS'.
  31261.  
  31262.    * Fixed problem with `ORDER BY' with 'only index' optimization when
  31263.      there were multiple key definitions for a used column.
  31264.  
  31265.    * `DATE' and `DATETIME' columns are now up to 5 times faster than
  31266.      before.
  31267.  
  31268.    * `INSERT DELAYED' can be used to let the client do other things
  31269.      while the server inserts rows into a table.
  31270.  
  31271.    * `LEFT JOIN USING (col1,col2)' didn't work if one used it with
  31272.      tables from 2 different databases.
  31273.  
  31274.    * `LOAD DATA LOCAL INFILE' didn't work in the Unix version because of
  31275.      a missing file.
  31276.  
  31277.    * Fixed problems with `VARCHAR'/`BLOB' on very short rows (< 4
  31278.      bytes); error 127 could occur when deleting rows.
  31279.  
  31280.    * Updating `BLOB/TEXT' through formulas didn't work for short (< 256
  31281.      char) strings.
  31282.  
  31283.    * When you did a `GRANT' on a new host, `mysqld' could die on the
  31284.      first connect from this host.
  31285.  
  31286.    * Fixed bug when one used `ORDER BY' on column name that was the same
  31287.      name as an alias.
  31288.  
  31289.    * Added `BENCHMARK(loop_count,expression)' function to time
  31290.      expressions.
  31291.  
  31292. Changes in release 3.22.14
  31293. --------------------------
  31294.  
  31295.    * Allow empty arguments to `mysqld' to make it easier to start from
  31296.      shell scripts.
  31297.  
  31298.    * Setting a `TIMESTAMP' column to `NULL' didn't record the timestamp
  31299.      value in the update log.
  31300.  
  31301.    * Fixed lock handler bug when one did `INSERT INTO TABLE ... SELECT
  31302.      ... GROUP BY'.
  31303.  
  31304.    * Added a patch for `localtime_r()' on Win32 so that it will not
  31305.      crash anymore if your date is > 2039, but instead will return a
  31306.      time of all zero.
  31307.  
  31308.    * Names for user-defined functions are no longer case sensitive.
  31309.  
  31310.    * Added escape of `^Z' (ASCII 26) to `\Z' as `^Z' doesn't work with
  31311.      pipes on Win32.
  31312.  
  31313.    * `mysql_fix_privileges' adds a new column to the `mysql.func' to
  31314.      support aggregate UDF functions in future *MySQL* releases.
  31315.  
  31316. Changes in release 3.22.13
  31317. --------------------------
  31318.  
  31319.    * Saving `NOW()', `CURDATE()' or `CURTIME()' directly in a column
  31320.      didn't work.
  31321.  
  31322.    * `SELECT COUNT(*) ... LEFT JOIN ...' didn't work with no `WHERE'
  31323.      part.
  31324.  
  31325.    * Updated `config.guess' to allow *MySQL* to configure on UnixWare
  31326.      7.0.x.
  31327.  
  31328.    * Changed the implementation of `pthread_cond()' on the Win32
  31329.      version.  `get_lock()' now correctly times out on Win32!
  31330.  
  31331. Changes in release 3.22.12
  31332. --------------------------
  31333.  
  31334.    * Fixed problem when using `DATE_ADD()' and `DATE_SUB()' in a
  31335.      `WHERE' clause.
  31336.  
  31337.    * You can now set the password for a user with the `GRANT ... TO user
  31338.      IDENTIFIED BY 'password'' syntax.
  31339.  
  31340.    * Fixed bug in `GRANT' checking with `SELECT' on many tables.
  31341.  
  31342.    * Added missing file `mysql_fix_privilege_tables' to the RPM
  31343.      distribution. This is not run by default because it relies on the
  31344.      client package.
  31345.  
  31346.    * Added option `SQL_SMALL_RESULT' to `SELECT' to force use of fast
  31347.      temporary tables when you know that the result set will be small.
  31348.  
  31349.    * Allow use of negative real numbers without a decimal point.
  31350.  
  31351.    * Day number is now adjusted to maximum days in month if the
  31352.      resulting month after `DATE_ADD'/`DATE_SUB()' doesn't have enough
  31353.      days.
  31354.  
  31355.    * Fix that `GRANT' compares columns in case-insensitive fashion.
  31356.  
  31357.    * Fixed a bug in `sql_list.h' that made `ALTER TABLE' dump core in
  31358.      some contexts.
  31359.  
  31360.    * The hostname in `user@hostname' can now include `.' and `-'
  31361.      without quotes in the context of the `GRANT', `REVOKE' and `SET
  31362.      PASSWORD FOR ...' statements.
  31363.  
  31364.    * Fix for `isamchk' for tables which need big temporary files.
  31365.  
  31366. Changes in release 3.22.11
  31367. --------------------------
  31368.  
  31369.    * *IMPORTANT*: You must run the `mysql_fix_privilege_tables' script
  31370.      when you upgrade to this version!  This is needed because of the
  31371.      new `GRANT' system. If you don't do this, you will get `Access
  31372.      denied' when you try to use `ALTER TABLE', `CREATE INDEX' or `DROP
  31373.      INDEX'.
  31374.  
  31375.    * `GRANT' to allow/deny users table and column access.
  31376.  
  31377.    * Changed `USER()' to return `user@host'
  31378.  
  31379.    * Changed the syntax for how to set `PASSWORD' for another user.
  31380.  
  31381.    * New command `FLUSH STATUS' that sets most status variables to zero.
  31382.  
  31383.    * New status variables: `aborted_threads', `aborted_connects'.
  31384.  
  31385.    * New option variable: `connection_timeout'.
  31386.  
  31387.    * Added support for Thai sorting (by Pruet Boonma
  31388.      <pruet@ds90.intanon.nectec.or.th>).
  31389.  
  31390.    * Slovak and japanese error messages.
  31391.  
  31392.    * Configuration and portability fixes.
  31393.  
  31394.    * Added option `SET SQL_WARNINGS=1' to get a warning count also for
  31395.      simple inserts.
  31396.  
  31397.    * *MySQL* now uses `SIGTERM' instead of `SIGQUIT' with shutdown to
  31398.      work better on FreeBSD.
  31399.  
  31400.    * Added option `\G' (print vertically) to `mysql'.
  31401.  
  31402.    * `SELECT HIGH_PRIORITY' ... killed `mysqld'.
  31403.  
  31404.    * `IS NULL' on a `AUTO_INCREMENT' column in a `LEFT JOIN' didn't
  31405.      work as expected.
  31406.  
  31407.    * New function `MAKE_SET()'.
  31408.  
  31409. Changes in release 3.22.10
  31410. --------------------------
  31411.  
  31412.    * `mysql_install_db' no longer starts the *MySQL* server!  You
  31413.      should start `mysqld' with `safe_mysqld' after installing it!  The
  31414.      *MySQL* RPM will however start the server as before.
  31415.  
  31416.    * Added `--bootstrap' option to `mysqld' and recoded
  31417.      `mysql_install_db' to use it.  This will make it easier to install
  31418.      *MySQL* with RPMs.
  31419.  
  31420.    * Changed `+', `-' (sign and minus), `*', `/', `%', `ABS()' and
  31421.      `MOD()' to be `BIGINT' aware (64-bit safe).
  31422.  
  31423.    * Fixed a bug in `ALTER TABLE' that caused `mysqld' to crash.
  31424.  
  31425.    * *MySQL* now always reports the conflicting key values when a
  31426.      duplicate key entry occurs. (Before this was only reported for
  31427.      `INSERT').
  31428.  
  31429.    * New syntax: `INSERT INTO tbl_name SET
  31430.      col_name=value,col_name=value,...'
  31431.  
  31432.    * Most errors in the `.err' log are now prefixed with a time stamp.
  31433.  
  31434.    * Added option `MYSQL_INIT_COMMAND' to `mysql_options()' to make a
  31435.      query on connect or reconnect.
  31436.  
  31437.    * Added option `MYSQL_READ_DEFAULT_FILE' and
  31438.      `MYSQL_READ_DEFAULT_GROUP' to `mysql_options()' to read the
  31439.      following parameters from the *MySQL* option files: `port',
  31440.      `socket', `compress', `password', `pipe', `timeout', `user',
  31441.      `init-command', `host' and `database'.
  31442.  
  31443.    * Added `maybe_null' to the UDF structure.
  31444.  
  31445.    * Added option `IGNORE' to `INSERT' statemants with many rows.
  31446.  
  31447.    * Fixed some problems with sorting of the koi8 character sets; Users
  31448.      of koi8 *MUST* run `isamchk -rq' on each table that has an index on
  31449.      a `CHAR' or `VARCHAR' column.
  31450.  
  31451.    * New script `mysql_setpermission', by Luuk de Boer, allows one to
  31452.      easily create new users with permissions for specific databases.
  31453.  
  31454.    * Allow use of hexadecimal strings (0x...) when specifying a
  31455.      constant string (like in the column separators with `LOAD DATA
  31456.      INFILE').
  31457.  
  31458.    * Ported to OS/2 (thanks to Antony T. Curtis
  31459.      <antony.curtis@olcs.net>).
  31460.  
  31461.    * Added more variables to `SHOW STATUS' and changed format of output
  31462.      to be like `SHOW VARIABLES'.
  31463.  
  31464.    * Added `extended-status' command to `mysqladmin' which will show the
  31465.      new status variables.
  31466.  
  31467. Changes in release 3.22.9
  31468. -------------------------
  31469.  
  31470.    * `SET SQL_LOG_UPDATE=0' caused a lockup of the server.
  31471.  
  31472.    * New SQL command:  `FLUSH [ TABLES | HOSTS | LOGS | PRIVILEGES ] [,
  31473.      ...]'
  31474.  
  31475.    * New SQL command:  `KILL' `thread_id'.
  31476.  
  31477.    * Added casts and changed include files to make *MySQL* easier to
  31478.      compile on AIX and DEC OSF1 4.x
  31479.  
  31480.    * Fixed conversion problem when using `ALTER TABLE' from a `INT' to
  31481.      a short `CHAR()' column.
  31482.  
  31483.    * Added `SELECT HIGH_PRIORITY'; This will get a lock for the
  31484.      `SELECT' even if there is a thread waiting for another `SELECT' to
  31485.      get a `WRITE LOCK'.
  31486.  
  31487.    * Moved wild_compare to string class to be able to use `LIKE' on
  31488.      `BLOB'/`TEXT' columns with `\0'.
  31489.  
  31490.    * Added `ESCAPE' option to `LIKE'.
  31491.  
  31492.    * Added a lot more output to `mysqladmin debug'.
  31493.  
  31494.    * You can now start `mysqld' on Win32 with the `--flush' option.
  31495.      This will flush all tables to disk after each update.  This makes
  31496.      things much safer on NT/Win98 but also *MUCH* slower.
  31497.  
  31498. Changes in release 3.22.8
  31499. -------------------------
  31500.  
  31501.    * Czech character sets should now work much better.  You must also
  31502.      install
  31503.      `http://www.mysql.com/Downloads/Patches/czech-3.22.8-patch'.  This
  31504.      patch should also be installed if you are using a character set
  31505.      with uses `my_strcoll()'!  The patch should always be safe to
  31506.      install (for any system), but as this patch changes ISAM internals
  31507.      it's not yet in the default distribution.
  31508.  
  31509.    * `DATE_ADD()' and `DATE_SUB()' didn't work with group functions.
  31510.  
  31511.    * `mysql' will now also try to reconnect on `USE DATABASE' commands.
  31512.  
  31513.    * Fix problem with `ORDER BY' and `LEFT JOIN' and `const' tables.
  31514.  
  31515.    * Fixed problem with `ORDER BY' if the first `ORDER BY' column was a
  31516.      key and the rest of the `ORDER BY' columns wasn't part of the key.
  31517.  
  31518.    * Fixed a big problem with `OPTIMIZE TABLE'.
  31519.  
  31520.    * *MySQL* clients on NT will now by default first try to connect with
  31521.      named pipes and after this with TCP/IP.
  31522.  
  31523.    * Fixed a problem with `DROP TABLE' and `mysqladmin shutdown' on
  31524.      Win32 (a fatal bug from 3.22.6).
  31525.  
  31526.    * Fixed problems with `TIME columns' and negative strings.
  31527.  
  31528.    * Added an extra thread signal loop on shutdown to avoid some error
  31529.      messages from the client.
  31530.  
  31531.    * *MySQL* now uses the next available number as extension for the
  31532.      update log file.
  31533.  
  31534.    * Added patches for UNIXWARE 7.
  31535.  
  31536. Changes in release 3.22.7
  31537. -------------------------
  31538.  
  31539.    * Added `LIMIT' clause for the `DELETE' statement.
  31540.  
  31541.    * You can now use the `/*! ... */' syntax to hide *MySQL*-specific
  31542.      keywords when you write portable code.  *MySQL* will parse the code
  31543.      inside the comments as if the surrounding `/*!' and `*/' comment
  31544.      characters didn't exist.
  31545.  
  31546.    * `OPTIMIZE TABLE tbl_name' can now be used to reclaim disk space
  31547.      after many deletes.  Currently, this uses `ALTER TABLE' to
  31548.      re-generate the table, but in the future it will use an integrated
  31549.      `isamchk' for more speed.
  31550.  
  31551.    * Upgraded `libtool' to get the configure more portable.
  31552.  
  31553.    * Fixed slow `UPDATE' and `DELETE' operations when using `DATETIME'
  31554.      or `DATE' keys.
  31555.  
  31556.    * Changed optimizer to make it better at deciding when to do a full
  31557.      join and when using keys.
  31558.  
  31559.    * You can now use `mysqladmin proc' to display information about
  31560.      your own threads. Only users with the *Process_priv* privilege can
  31561.      get information about all threads.
  31562.  
  31563.    * Added handling of formats `YYMMDD', `YYYYMMDD', `YYMMDDHHMMSS' for
  31564.      numbers when using `DATETIME' and `TIMESTAMP' types. (Formerly
  31565.      these formats only worked with strings.)
  31566.  
  31567.    * Added connect option `CLIENT_IGNORE_SPACE' to allow use of spaces
  31568.      after function names and before `(' (Powerbuilder requires this).
  31569.      This will make all function names reserved words.
  31570.  
  31571.    * Added the `--log-long-format' option to `mysqld' to enable
  31572.      timestamps and INSERT_ID's in the update log.
  31573.  
  31574.    * Added `--where' option to `mysqldump' (patch by Jim Faucette).
  31575.  
  31576.    * The lexical analyzer now uses "perfect hashing" for faster parsing
  31577.      of SQL statements.
  31578.  
  31579. Changes in release 3.22.6
  31580. -------------------------
  31581.  
  31582.    * Faster `mysqldump'.
  31583.  
  31584.    * For the `LOAD DATA INFILE' statement, you can now use the new
  31585.      `LOCAL' keyword to read the file from the client.  `mysqlimport'
  31586.      will automatically use `LOCAL' when importing with the TCP/IP
  31587.      protocol.
  31588.  
  31589.    * Fixed small optimize problem when updating keys.
  31590.  
  31591.    * Changed makefiles to support shared libraries.
  31592.  
  31593.    * *MySQL*-NT can now use named pipes, which means that you can now
  31594.      use *MySQL*-NT without having to install TCP/IP.
  31595.  
  31596. Changes in release 3.22.5
  31597. -------------------------
  31598.  
  31599.    * All table lock handing is changed to avoid some very subtle
  31600.      deadlocks when using `DROP TABLE', `ALTER TABLE', `DELETE FROM
  31601.      TABLE' and `mysqladmin flush-tables' under heavy usage.  Changed
  31602.      locking code to get better handling of locks of different types.
  31603.  
  31604.    * Updated `DBI' to 1.00 and `DBD' to 1.2.0.
  31605.  
  31606.    * Added a check that the error message file contains error messages
  31607.      suitable for the current version of `mysqld'. (To avoid errors if
  31608.      you accidentally try to use an old error message file.)
  31609.  
  31610.    * All count structures in the client (`affected_rows()',
  31611.      `insert_id()',...) are now of type `BIGINT' to allow 64-bit values
  31612.      to be used.  This required a minor change in the *MySQL* protocol
  31613.      which should affect only old clients when using tables with
  31614.      `AUTO_INCREMENT' values > 24M.
  31615.  
  31616.    * The return type of `mysql_fetch_lengths()' has changed from `uint
  31617.      *' to `ulong *'. This may give a warning for old clients but
  31618.      should work on most machines.
  31619.  
  31620.    * Change `mysys' and `dbug' libraries to allocate all thread
  31621.      variables in one struct.  This makes it easier to make a threaded
  31622.      `libmysql.dll' library.
  31623.  
  31624.    * Use the result from `gethostname()' (instead of `uname()') when
  31625.      constructing `.pid' file names.
  31626.  
  31627.    * New better compressed server/client protocol.
  31628.  
  31629.    * `COUNT()', `STD()' and `AVG()' are extended to handle more than 4G
  31630.      rows.
  31631.  
  31632.    * You can now store values in the range `-838:59:59' <= x <=
  31633.      `838:59:59' in a `TIME' column.
  31634.  
  31635.    * *WARNING: INCOMPATIBLE CHANGE!!* If you set a `TIME' column to too
  31636.      short a value, *MySQL* now assumes the value is given as: `[[[D
  31637.      ]HH:]MM:]SS' instead of `HH[:MM[:SS]]'.
  31638.  
  31639.    * `TIME_TO_SEC()' and `SEC_TO_TIME()' can now handle negative times
  31640.      and hours up to 32767.
  31641.  
  31642.    * Added new option `SET OPTION SQL_LOG_UPDATE={0|1}' to allow users
  31643.      with the *process* privilege to bypass the update log.  (Modified
  31644.      patch from Sergey A Mukhin <violet@rosnet.net>.)
  31645.  
  31646.    * Fixed fatal bug in `LPAD()'.
  31647.  
  31648.    * Initialize line buffer in `mysql.cc' to make `BLOB' reading from
  31649.      pipes safer.
  31650.  
  31651.    * Added `-O max_connect_errors=#' option to `mysqld'.  Connect
  31652.      errors are now reset for each correct connection.
  31653.  
  31654.    * Increased the default value of `max_allowed_packet' to `1M' in
  31655.      `mysqld'.
  31656.  
  31657.    * Added `--low-priority-updates' option to `mysqld', to give
  31658.      table-modifying operations (`INSERT', `REPLACE', `UPDATE',
  31659.      `DELETE') lower priority than retrievals.  You can now use
  31660.      `{INSERT | REPLACE | UPDATE | DELETE} LOW_PRIORITY ...' You can
  31661.      also use `SET OPTION SQL_LOW_PRIORITY_UPDATES={0|1}' to change the
  31662.      priority for one thread.  One side effect is that `LOW_PRIORITY'
  31663.      is now a reserved word. :(
  31664.  
  31665.    * Add support for `INSERT INTO table ... VALUES(...),(...),(...)',
  31666.      to allow inserting multiple rows with a single statement.
  31667.  
  31668.    * `INSERT INTO tbl_name' is now also cached when used with `LOCK
  31669.      TABLES'.  (Previously only `INSERT ... SELECT' and `LOAD DATA
  31670.      INFILE' were cached.)
  31671.  
  31672.    * Allow `GROUP BY' functions with `HAVING':
  31673.           mysql> SELECT col FROM table GROUP BY col HAVING COUNT(*)>0;
  31674.  
  31675.    * `mysqld' will now ignore trailing `;' characters in queries. This
  31676.      is to make it easier to migrate from some other SQL servers that
  31677.      require the trailing `;'.
  31678.  
  31679.    * Fix for corrupted fixed-format output generated by `SELECT INTO
  31680.      OUTFILE'.
  31681.  
  31682.    * *WARNING: INCOMPATIBLE CHANGE!!* Added Oracle `GREATEST()' and
  31683.      `LEAST()' functions.  You must now use these instead of the
  31684.      `MAX()' and `MIN()' functions to get the largest/smallest value
  31685.      from a list of values. These can now handle `REAL', `BIGINT' and
  31686.      string (`CHAR' or `VARCHAR') values.
  31687.  
  31688.    * *WARNING: INCOMPATIBLE CHANGE!!* `DAYOFWEEK()' had offset 0 for
  31689.      Sunday. Changed the offset to 1.
  31690.  
  31691.    * Give an error for queries that mix `GROUP BY' columns and fields
  31692.      when there is no `GROUP BY' specification.
  31693.  
  31694.    * Added `--vertical' option to `mysql', for printing results in
  31695.      vertical mode.
  31696.  
  31697.    * Index-only optimization; some queries are now resolved using only
  31698.      indexes.  Until *MySQL* 4.0, this works only for numeric columns.
  31699.      *Note *MySQL* indexes: MySQL indexes.
  31700.  
  31701.    * Lots of new benchmarks.
  31702.  
  31703.    * A new C API chapter and lots of other improvements in the manual.
  31704.  
  31705. Changes in release 3.22.4
  31706. -------------------------
  31707.  
  31708.    * Added `--tmpdir' option to `mysqld', for specifying the location
  31709.      of the temporary file directory.
  31710.  
  31711.    * *MySQL* now automatically changes a query from an ODBC client:
  31712.           SELECT ... FROM table WHERE auto_increment_column IS NULL
  31713.      to:
  31714.           SELECT ... FROM table WHERE auto_increment_column == LAST_INSERT_ID()
  31715.      This allows some ODBC programs (Delphi, Access) to retrieve the
  31716.      newly inserted row to fetch the `AUTO_INCREMENT' id.
  31717.  
  31718.    * `DROP TABLE' now waits for all users to free a table before
  31719.      deleting it.
  31720.  
  31721.    * Fixed small memory leak in the new connect protocol.
  31722.  
  31723.    * New functions `BIN()', `OCT()', `HEX()' and `CONV()' for
  31724.      converting between different number bases.
  31725.  
  31726.    * Added function `SUBSTRING()' with 2 arguments.
  31727.  
  31728.    * If you created a table with a record length smaller than 5, you
  31729.      couldn't delete rows from the table.
  31730.  
  31731.    * Added optimization to remove const reference tables from `ORDER
  31732.      BY' and `GROUP BY'.
  31733.  
  31734.    * `mysqld' now automatically disables system locking on Linux and
  31735.      Win32, and for systems that use MIT-pthreads.  You can force the
  31736.      use of locking with the `--enable-locking' option.
  31737.  
  31738.    * Added `--console' option to `mysqld', to force a console window
  31739.      (for error messages) when using Win32.
  31740.  
  31741.    * Fixed table locks for Win32.
  31742.  
  31743.    * Allow `$' in identifiers.
  31744.  
  31745.    * Changed name of user-specific configuration file from `my.cnf' to
  31746.      `.my.cnf' (Unix only).
  31747.  
  31748.    * Added `DATE_ADD()' and `DATE_SUB()' functions.
  31749.  
  31750. Changes in release 3.22.3
  31751. -------------------------
  31752.  
  31753.    * Fixed a lock problem (bug in *MySQL* 3.22.1) when closing
  31754.      temporary tables.
  31755.  
  31756.    * Added missing `mysql_ping()' to the client library.
  31757.  
  31758.    * Added `--compress' option to all *MySQL* clients.
  31759.  
  31760.    * Changed `byte' to `char' in `mysql.h' and `mysql_com.h'.
  31761.  
  31762. Changes in release 3.22.2
  31763. -------------------------
  31764.  
  31765.    * Searching on multiple constant keys that matched more than 30% of
  31766.      the rows didn't always use the best possible key.
  31767.  
  31768.    * New functions `<<', `>>', `RPAD()' and `LPAD()'.
  31769.  
  31770.    * You can now save default options (like passwords) in a
  31771.      configuration file (`my.cnf').
  31772.  
  31773.    * Lots of small changes to get `ORDER BY' to work when no records
  31774.      are found when using fields that are not in `GROUP BY' (*MySQL*
  31775.      extension).
  31776.  
  31777.    * Added `--chroot' option to `mysqld', to start `mysqld' in a chroot
  31778.      environment (by Nikki Chumakov <nikkic@cityline.ru>).
  31779.  
  31780.    * Trailing spaces are now ignored when comparing case-sensitive
  31781.      strings; this should fix some problems with ODBC and flag 512!
  31782.  
  31783.    * Fixed a core-dump bug in the range optimizer.
  31784.  
  31785.    * Added `--one-thread' option to `mysqld', for debugging with
  31786.      LinuxThreads (or `glibc').  (This replaces the `-T32' flag)
  31787.  
  31788.    * Added `DROP TABLE IF EXISTS' to prevent an error from occurring if
  31789.      the table doesn't exist.
  31790.  
  31791.    * `IF' and `EXISTS' are now reserved words (they would have to be
  31792.      sooner or later).
  31793.  
  31794.    * Added lots of new options to `mysqldump'.
  31795.  
  31796.    * Server error messages are now in `mysqld_error.h'.
  31797.  
  31798.    * The server/client protocol now supports compression.
  31799.  
  31800.    * All bug fixes from *MySQL* 3.21.32.
  31801.  
  31802. Changes in release 3.22.1
  31803. -------------------------
  31804.  
  31805.    * Added new C API function `mysql_ping()'.
  31806.  
  31807.    * Added new API functions `mysql_init()' and `mysql_options()'.  You
  31808.      now MUST call `mysql_init()' before you call
  31809.      `mysql_real_connect()'.  You don't have to call `mysql_init()' if
  31810.      you only use `mysql_connect()'.
  31811.  
  31812.    * Added `mysql_options(...,MYSQL_OPT_CONNECT_TIMEOUT,...)' so you
  31813.      can set a timeout for connecting to a server.
  31814.  
  31815.    * Added `--timeout' option to `mysqladmin', as a test of
  31816.      `mysql_options()'.
  31817.  
  31818.    * Added `AFTER column' and `FIRST' options to `ALTER TABLE ... ADD
  31819.      columns'.  This makes it possible to add a new column at some
  31820.      specific location within a row in an existing table.
  31821.  
  31822.    * `WEEK()' now takes an optional argument to allow handling of weeks
  31823.      when the week starts on Monday (some European countries).  By
  31824.      default, `WEEK()' assumes the week starts on Sunday.
  31825.  
  31826.    * `TIME' columns weren't stored properly (bug in *MySQL* 3.22.0).
  31827.  
  31828.    * `UPDATE' now returns information about how many rows were matched
  31829.      and updated, and how many "warnings" occurred when doing the
  31830.      update.
  31831.  
  31832.    * Fixed incorrect result from `FORMAT(-100,2)'.
  31833.  
  31834.    * `ENUM' and `SET' columns were compared in binary (case-sensitive)
  31835.      fashion; changed to be case insensitive.
  31836.  
  31837. Changes in release 3.22.0
  31838. -------------------------
  31839.  
  31840.    * New (backward compatible) connect protocol that allows you to
  31841.      specify the database to use when connecting, to get much faster
  31842.      connections to a specific database.
  31843.  
  31844.      The `mysql_real_connect()' call is changed to:
  31845.  
  31846.           mysql_real_connect(MYSQL *mysql, const char *host, const char *user,
  31847.                              const char *passwd, const char *db, uint port,
  31848.                              const char *unix_socket, uint client_flag)
  31849.  
  31850.    * Each connection is handled by its own thread, rather than by the
  31851.      master `accept()' thread.  This fixes permanently the telnet bug
  31852.      that was a topic on the mail list some time ago.
  31853.  
  31854.    * All TCP/IP connections are now checked with backward resolution of
  31855.      the hostname to get better security. `mysqld' now has a local
  31856.      hostname resolver cache so connections should actually be faster
  31857.      than before, even with this feature.
  31858.  
  31859.    * A site automatically will be blocked from future connections if
  31860.      someone repeatedly connects with an "improper header" (like when
  31861.      one uses telnet).
  31862.  
  31863.    * You can now refer to tables in different databases with references
  31864.      of the form `tbl_name@db_name' or `db_name.tbl_name'.  This makes
  31865.      it possible to give a user read access to some tables and write
  31866.      access to others simply by keeping them in different databases!
  31867.  
  31868.    * Added `--user' option to `mysqld', to allow it to run as another
  31869.      Unix user (if it is started as the Unix `root' user).
  31870.  
  31871.    * Added caching of users and access rights (for faster access rights
  31872.      checking)
  31873.  
  31874.    * Normal users (not anonymous ones) can change their password with
  31875.      `mysqladmin password 'new_password''.  This uses encrypted
  31876.      passwords that are not logged in the normal *MySQL* log!
  31877.  
  31878.    * All important string functions are now coded in assembler for x86
  31879.      Linux machines.  This gives a speedup of 10% in many cases.
  31880.  
  31881.    * For tables that have many columns, the column names are now hashed
  31882.      for much faster column name lookup (this will speed up some
  31883.      benchmark tests a lot!)
  31884.  
  31885.    * Some benchmarks are changed to get better individual timing.
  31886.      (Some loops were so short that a specific test took < 2 seconds.
  31887.      The loops have been changed to take about 20 seconds to make it
  31888.      easier to compare different databases. A test that took 1-2
  31889.      seconds before now takes 11-24 seconds, which is much better)
  31890.  
  31891.    * Re-arranged `SELECT' code to handle some very specific queries
  31892.      involving group functions (like `COUNT(*)') without a `GROUP BY'
  31893.      but with `HAVING'. The following now works:
  31894.           mysql> SELECT count(*) as C FROM table HAVING C > 1;
  31895.  
  31896.    * Changed the protocol for field functions to be faster and avoid
  31897.      some calls to `malloc()'.
  31898.  
  31899.    * Added `-T32' option to `mysqld', for running all queries under the
  31900.      main thread.  This makes it possible to debug `mysqld' under Linux
  31901.      with `gdb'!
  31902.  
  31903.    * Added optimization of `not_null_column IS NULL' (needed for some
  31904.      Access queries).
  31905.  
  31906.    * Allow `STRAIGHT_JOIN' to be used between two tables to force the
  31907.      optimizer to join them in a specific order.
  31908.  
  31909.    * String functions now return `VARCHAR' rather than `CHAR' and the
  31910.      column type is now `VARCHAR' for fields saved as `VARCHAR'.  This
  31911.      should make the *MyODBC* driver better, but may break some old
  31912.      *MySQL* clients that don't handle `FIELD_TYPE_VARCHAR' the same
  31913.      way as `FIELD_TYPE_CHAR'.
  31914.  
  31915.    * `CREATE INDEX' and `DROP INDEX' are now implemented through `ALTER
  31916.      TABLE'.  `CREATE TABLE' is still the recommended (fast) way to
  31917.      create indexes.
  31918.  
  31919.    * Added `--set-variable' option `wait_timeout' to `mysqld'.
  31920.  
  31921.    * Added time column to `mysqladmin processlist' to show how long a
  31922.      query has taken or how long a thread has slept.
  31923.  
  31924.    * Added lots of new variables to `show variables' and some new to
  31925.      `show status'.
  31926.  
  31927.    * Added new type `YEAR'. `YEAR' is stored in 1 byte with allowable
  31928.      values of 0, and 1901 to 2155.
  31929.  
  31930.    * Added new `DATE' type that is stored in 3 bytes rather than 4
  31931.      bytes.  All new tables are created with the new date type if you
  31932.      don't use the `--old-protocol' option to `mysqld'.
  31933.  
  31934.    * Fixed bug in record caches; for some queries, you could get `Error
  31935.      from table handler: #' on some operating systems.
  31936.  
  31937.    * Added `--enable-assembler' option to `configure', for x86 machines
  31938.      (tested on Linux + `gcc').  This will enable assembler functions
  31939.      for the most important string functions for more speed!
  31940.  
  31941. Changes in release 3.21.x
  31942. =========================
  31943.  
  31944. Changes in release 3.21.33
  31945. --------------------------
  31946.  
  31947.    * Fixed problem when sending `SIGHUP' to `mysqld'; `mysqld' core
  31948.      dumped when starting from boot on some systems.
  31949.  
  31950.    * Fixed problem with losing a little memory for some connections.
  31951.  
  31952.    * `DELETE FROM tbl_name' without a `WHERE' condition is now done the
  31953.      long way when you use `LOCK TABLES' or if the table is in use, to
  31954.      avoid race conditions.
  31955.  
  31956.    * `INSERT INTO TABLE (timestamp_column) VALUES (NULL);' didn't set
  31957.      timestamp.
  31958.  
  31959. Changes in release 3.21.32
  31960. --------------------------
  31961.  
  31962.    * Fixed some possible race conditions when doing many reopen/close
  31963.      on the same tables under heavy load!  This can happen if you
  31964.      execute `mysqladmin refresh' often. This could in some very rare
  31965.      cases corrupt the header of the index file and cause error 126 or
  31966.      138.
  31967.  
  31968.    * Fixed fatal bug in `refresh()' when running with the
  31969.      `--skip-locking' option.  There was a "very small" time gap after
  31970.      a `mysqladmin refresh' when a table could be corrupted if one
  31971.      thread updated a table while another thread did `mysqladmin
  31972.      refresh' and another thread started a new update ont the same table
  31973.      before the first thread had finished.  A refresh (or
  31974.      `--flush-tables') will now not return until all used tables are
  31975.      closed!
  31976.  
  31977.    * `SELECT DISTINCT' with a `WHERE' clause that didn't match any rows
  31978.      returned a row in some contexts (bug only in 3.21.31).
  31979.  
  31980.    * `GROUP BY' + `ORDER BY' returned one empty row when no rows where
  31981.      found.
  31982.  
  31983.    * Fixed a bug in the range optimizer that wrote `Use_count: Wrong
  31984.      count for ...' in the error log file.
  31985.  
  31986. Changes in release 3.21.31
  31987. --------------------------
  31988.  
  31989.    * Fixed a sign extension problem for the `TINYINT' type on Irix.
  31990.  
  31991.    * Fixed problem with `LEFT("constant_string",function)'.
  31992.  
  31993.    * Fixed problem with `FIND_IN_SET()'.
  31994.  
  31995.    * `LEFT JOIN' core dumped if the second table is used with a constant
  31996.      `WHERE/ON' expression that uniquely identifies one record.
  31997.  
  31998.    * Fixed problems with `DATE_FORMAT()' and incorrect dates.
  31999.      `DATE_FORMAT()' now ignores `'%'' to make it possible to extend it
  32000.      more easily in the future.
  32001.  
  32002. Changes in release 3.21.30
  32003. --------------------------
  32004.  
  32005.    * `mysql' now returns an exit code > 0 if the query returned an
  32006.      error.
  32007.  
  32008.    * Saving of command line history to file in `mysql' client.  By
  32009.      Tommy Larsen <tommy@mix.hive.no>.
  32010.  
  32011.    * Fixed problem with empty lines that were ignored in `mysql.cc'.
  32012.  
  32013.    * Save the pid of the signal handler thread in the pid file instead
  32014.      of the pid of the main thread.
  32015.  
  32016.    * Added patch by <tommy@valley.ne.jp> to support Japanese characters
  32017.      SJIS and UJIS.
  32018.  
  32019.    * Changed `safe_mysqld' to redirect startup messages to
  32020.      `'hostname'.err' instead of `'hostname'.log' to reclaim file space
  32021.      on `mysqladmin refresh'.
  32022.  
  32023.    * `ENUM' always had the first entry as default value.
  32024.  
  32025.    * `ALTER TABLE' wrote two entries to the update log.
  32026.  
  32027.    * `sql_acc()' now closes the `mysql' grant tables after a reload to
  32028.      save table space and memory.
  32029.  
  32030.    * Changed `LOAD DATA' to use less memory with tables and `BLOB'
  32031.      columns.
  32032.  
  32033.    * Sorting on a function which made a division / 0 produced a wrong
  32034.      set in some cases.
  32035.  
  32036.    * Fixed `SELECT' problem with `LEFT()' when using the czech character
  32037.      set.
  32038.  
  32039.    * Fixed problem in `isamchk'; it couldn't repair a packed table in a
  32040.      very unusual case.
  32041.  
  32042.    * `SELECT' statements with `&' or `|' (bit functions) failed on
  32043.      columns with `NULL' values.
  32044.  
  32045.    * When comparing a field = field, where one of the fields was a part
  32046.      key, only the length of the part key was compared.
  32047.  
  32048. Changes in release 3.21.29
  32049. --------------------------
  32050.  
  32051.    * `LOCK TABLES' + `DELETE from tbl_name' never removed locks
  32052.      properly.
  32053.  
  32054.    * Fixed problem when grouping on an `OR' function.
  32055.  
  32056.    * Fixed permission problem with `umask()' and creating new databases.
  32057.  
  32058.    * Fixed permission problem on result file with `SELECT ... INTO
  32059.      OUTFILE ...'
  32060.  
  32061.    * Fixed problem in range optimizer (core dump) for a very complex
  32062.      query.
  32063.  
  32064.    * Fixed problem when using `MIN(integer)' or `MAX(integer)' in
  32065.      `GROUP BY'.
  32066.  
  32067.    * Fixed bug on Alpha when using integer keys. (Other keys worked on
  32068.      Alpha).
  32069.  
  32070.    * Fixed bug in `WEEK("XXXX-xx-01")'.
  32071.  
  32072. Changes in release 3.21.28
  32073. --------------------------
  32074.  
  32075.    * Fixed socket permission (clients couldn't connect to Unix socket
  32076.      on Linux).
  32077.  
  32078.    * Fixed bug in record caches; for some queries, you could get `Error
  32079.      from table handler: #' on some operating systems.
  32080.  
  32081. Changes in release 3.21.27
  32082. --------------------------
  32083.  
  32084.    * Added user level lock functions `GET_LOCK(string,timeout)',
  32085.      `RELEASE_LOCK(string)'.
  32086.  
  32087.    * Added `opened_tables' to `show status'.
  32088.  
  32089.    * Changed connect timeout to 3 seconds to make it somewhat harder
  32090.      for crackers to kill `mysqld' through telnet + TCP/IP.
  32091.  
  32092.    * Fixed bug in range optimizer when using `WHERE key_part_1 >=
  32093.      something AND key_part_2 <= something_else'.
  32094.  
  32095.    * Changed `configure' for detection of FreeBSD 3.0 9803xx and above
  32096.  
  32097.    * `WHERE' with string_column_key = constant_string didn't always find
  32098.      all rows if the column had many values differing only with
  32099.      characters of the same sort value (like e and e').
  32100.  
  32101.    * Strings keys looked up with 'ref' were not compared in
  32102.      case-sensitive fashion.
  32103.  
  32104.    * Added `umask()' to make log files non-readable for normal users.
  32105.  
  32106.    * Ignore users with old (8-byte) password on startup if not using
  32107.      `--old-protocol' option to `mysqld'.
  32108.  
  32109.    * `SELECT' which matched all key fields returned the values in the
  32110.      case of the matched values, not of the found values. (Minor
  32111.      problem.)
  32112.  
  32113. Changes in release 3.21.26
  32114. --------------------------
  32115.  
  32116.    * `FROM_DAYS(0)' now returns "0000-00-00".
  32117.  
  32118.    * In `DATE_FORMAT()', PM and AM were swapped for hours 00 and 12.
  32119.  
  32120.    * Extended the default maximum key size to 256.
  32121.  
  32122.    * Fixed bug when using `BLOB'/`TEXT' in `GROUP BY' with many tables.
  32123.  
  32124.    * An `ENUM' field that is not declared `NOT NULL' has `NULL' as the
  32125.      default value.  (Previously, the default value was the first
  32126.      enumeration value.)
  32127.  
  32128.    * Fixed bug in the join optimizer code when using many part keys on
  32129.      the same key:  `INDEX (Organization,Surname(35),Initials(35))'.
  32130.  
  32131.    * Added some tests to the table order optimizer to get some cases
  32132.      with `SELECT ... FROM many_tables' much faster.
  32133.  
  32134.    * Added a retry loop around `accept()' to possibly fix some problems
  32135.      on some Linux machines.
  32136.  
  32137. Changes in release 3.21.25
  32138. --------------------------
  32139.  
  32140.    * Changed `typedef 'string'' to `typedef 'my_string'' for better
  32141.      portability.
  32142.  
  32143.    * You can now kill threads that are waiting on a disk full condition.
  32144.  
  32145.    * Fixed some problems with UDF functions.
  32146.  
  32147.    * Added long options to `isamchk'. Try `isamchk --help'.
  32148.  
  32149.    * Fixed a bug when using 8 bytes long (alpha); `filesort()' didn't
  32150.      work.  Affects `DISTINCT', `ORDER BY' and `GROUP BY' on 64-bit
  32151.      processors.
  32152.  
  32153. Changes in release 3.21.24
  32154. --------------------------
  32155.  
  32156.    * Dynamic loadable functions. Based on source from Alexis Mikhailov.
  32157.  
  32158.    * You couldn't delete from a table if no one had done a `SELECT' on
  32159.      the table.
  32160.  
  32161.    * Fixed problem with range optimizer with many `OR' operators on key
  32162.      parts inside each other.
  32163.  
  32164.    * Recoded `MIN()' and `MAX()' to work properly with strings and
  32165.      `HAVING'.
  32166.  
  32167.    * Changed default umask value for new files from `0664' to `0660'.
  32168.  
  32169.    * Fixed problem with `LEFT JOIN' and constant expressions in the `ON'
  32170.      part.
  32171.  
  32172.    * Added Italian error messages from <brenno@dewinter.com>.
  32173.  
  32174.    * `configure' now works better on OSF1 (tested on 4.0D).
  32175.  
  32176.    * Added hooks to allow `LIKE' optimization with international
  32177.      character support.
  32178.  
  32179.    * Upgraded `DBI' to 0.93.
  32180.  
  32181. Changes in release 3.21.23
  32182. --------------------------
  32183.  
  32184.    * The following symbols are now reserved words: `TIME', `DATE',
  32185.      `TIMESTAMP', `TEXT', `BIT', `ENUM', `NO', `ACTION', `CHECK',
  32186.      `YEAR', `MONTH', `DAY', `HOUR', `MINUTE', `SECOND', `STATUS',
  32187.      `VARIABLES'.
  32188.  
  32189.    * Setting a `TIMESTAMP' to `NULL' in `LOAD DATA INFILE ...' didn't
  32190.      set the current time for the `TIMESTAMP'.
  32191.  
  32192.    * Fix `BETWEEN' to recognize binary strings. Now `BETWEEN' is case
  32193.      sensitive.
  32194.  
  32195.    * Added `--skip-thread-priority' option to `mysqld', for systems
  32196.      where `mysqld''s thread scheduling doesn't work properly (BSDI
  32197.      3.1).
  32198.  
  32199.    * Added ODBC functions `DAYNAME()' and `MONTHNAME()'.
  32200.  
  32201.    * Added function `TIME_FORMAT()'.  This works like `DATE_FORMAT()',
  32202.      but takes a time string (`'HH:MM:DD'') as argument.
  32203.  
  32204.    * Fixed unlikely(?) key optimizer bug when using `OR's of key parts
  32205.      inside `AND's.
  32206.  
  32207.    * Added command `variables' to `mysqladmin'.
  32208.  
  32209.    * A lot of small changes to the binary releases.
  32210.  
  32211.    * Fixed a bug in the new protocol from *MySQL* 3.21.20.
  32212.  
  32213.    * Changed `ALTER TABLE' to work with Win32 (Win32 can't rename open
  32214.      files).  Also fixed a couple of small bugs in the Win32 version.
  32215.  
  32216.    * All standard *MySQL* clients are now ported to *MySQL*-Win32.
  32217.  
  32218.    * *MySQL* can now be started as a service on NT.
  32219.  
  32220. Changes in release 3.21.22
  32221. --------------------------
  32222.  
  32223.    * Starting with this version, all *MySQL* distributions will be
  32224.      configured, compiled and tested with `crash-me' and the benchmarks
  32225.      on the following platforms: SunOS 5.6 sun4u, SunOS 5.5.1 sun4u,
  32226.      SunOS 4.14 sun4c, SunOS 5.6 i86pc, Irix 6.3 mips5k, HP-UX 10.20
  32227.      hppa, AIX 4.2.1 ppc, OSF1 V4.0 alpha, FreeBSD 2.2.2 i86pc and BSDI
  32228.      3.1 i386.
  32229.  
  32230.    * Fix `COUNT(*)' problems when the `WHERE' clause didn't match any
  32231.      records.  (Bug from 3.21.17.)
  32232.  
  32233.    * Removed that `NULL = NULL' is true.  Now you must use `IS NULL' or
  32234.      `IS NOT NULL' to test whether or not a value is `NULL'.  (This is
  32235.      according to ANSI SQL but may break old applications that are
  32236.      ported from `mSQL'.)  You can get the old behavior by compiling
  32237.      with `-DmSQL_COMPLIANT'.
  32238.  
  32239.    * Fixed bug that core dumped when using many `LEFT OUTER JOIN'
  32240.      clauses.
  32241.  
  32242.    * Fixed bug in `ORDER BY' on string formula with possible `NULL'
  32243.      values.
  32244.  
  32245.    * Fixed problem in range optimizer when using <= on sub index.
  32246.  
  32247.    * Added functions `DAYOFYEAR()', `DAYOFMONTH()', `MONTH()',
  32248.      `YEAR()', `WEEK()', `QUARTER()', `HOUR()', `MINUTE()', `SECOND()'
  32249.      and `FIND_IN_SET()'.
  32250.  
  32251.    * Added command `SHOW VARIABLES'.
  32252.  
  32253.    * Added support of "long constant strings" from ANSI SQL:
  32254.           mysql> SELECT 'first ' 'second';       -> 'first second'
  32255.  
  32256.    * Upgraded mSQL-Mysql-modules to 1.1825.
  32257.  
  32258.    * Upgraded `mysqlaccess' to 2.02.
  32259.  
  32260.    * Fixed problem with Russian character set and `LIKE'.
  32261.  
  32262.    * Ported to OpenBSD 2.1.
  32263.  
  32264.    * New Dutch error messages.
  32265.  
  32266. Changes in release 3.21.21a
  32267. ---------------------------
  32268.  
  32269.    * Configure changes for some operating systems.
  32270.  
  32271. Changes in release 3.21.21
  32272. --------------------------
  32273.  
  32274.    * Fixed optimizer bug when using `WHERE data_field = date_field2 AND
  32275.      date_field2 = constant'.
  32276.  
  32277.    * Added command `SHOW STATUS'.
  32278.  
  32279.    * Removed `manual.ps' from the source distribution to make it
  32280.      smaller.
  32281.  
  32282. Changes in release 3.21.20
  32283. --------------------------
  32284.  
  32285.    * Changed the maximum table name and column name lengths from 32 to
  32286.      64.
  32287.  
  32288.    * Aliases can now be of "any" length.
  32289.  
  32290.    * Fixed `mysqladmin stat' to return the right number of queries.
  32291.  
  32292.    * Changed protocol (downward compatible) to mark if a column has the
  32293.      `AUTO_INCREMENT' attribute or is a `TIMESTAMP'. This is needed for
  32294.      the new Java driver.
  32295.  
  32296.    * Added Hebrew sorting order by Zeev Suraski.
  32297.  
  32298.    * Solaris 2.6: Fixed `configure' bugs and increased maximum table
  32299.      size from 2G to 4G.
  32300.  
  32301. Changes in release 3.21.19
  32302. --------------------------
  32303.  
  32304.    * Upgraded `DBD' to 1823. This version implements `mysql_use_result'
  32305.      in `DBD-Mysql'.
  32306.  
  32307.    * Benchmarks updated for empress (by Luuk).
  32308.  
  32309.    * Fixed a case of slow range searching.
  32310.  
  32311.    * Configure fixes (`Docs' directory).
  32312.  
  32313.    * Added function `REVERSE()' (by Zeev Suraski).
  32314.  
  32315. Changes in release 3.21.18
  32316. --------------------------
  32317.  
  32318.    * Issue error message if client C functions are called in wrong
  32319.      order.
  32320.  
  32321.    * Added automatic reconnect to the `libmysql.c' library. If a write
  32322.      command fails, an automatic reconnect is done.
  32323.  
  32324.    * Small sort sets no longer use temporary files.
  32325.  
  32326.    * Upgraded `DBI' to 0.91.
  32327.  
  32328.    * Fixed a couple of problems with `LEFT OUTER JOIN'.
  32329.  
  32330.    * Added `CROSS JOIN' syntax. `CROSS' is now a reserved word.
  32331.  
  32332.    * Recoded `yacc'/`bison' stack allocation to be even safer and to
  32333.      allow *MySQL* to handle even bigger expressions.
  32334.  
  32335.    * Fixed a couple of problems with the update log.
  32336.  
  32337.    * `ORDER BY' was slow when used with key ranges.
  32338.  
  32339. Changes in release 3.21.17
  32340. --------------------------
  32341.  
  32342.    * Changed documentation string of `--with-unix-socket-path' to avoid
  32343.      confusion.
  32344.  
  32345.    * Added ODBC and ANSI SQL style `LEFT OUTER JOIN'.
  32346.  
  32347.    * The following are new reserved words: `LEFT', `NATURAL', `USING'.
  32348.  
  32349.    * The client library now uses the value of the environment variable
  32350.      `MYSQL_HOST' as the default host if it's defined.
  32351.  
  32352.    * `SELECT col_name, SUM(expr)' now returns `NULL' for `col_name'
  32353.      when there are matching rows.
  32354.  
  32355.    * Fixed problem with comparing binary strings and `BLOB's with ASCII
  32356.      characters over 127.
  32357.  
  32358.    * Fixed lock problem: when freeing a read lock on a table with
  32359.      multiple read locks, a thread waiting for a write lock would have
  32360.      been given the lock.  This shouldn't affect data integrity, but
  32361.      could possibly make `mysqld' restart if one thread was reading
  32362.      data that another thread modified.
  32363.  
  32364.    * `LIMIT offset,count' didn't work in `INSERT ... SELECT'.
  32365.  
  32366.    * Optimized key block caching. This will be quicker than the old
  32367.      algorithm when using bigger key caches.
  32368.  
  32369. Changes in release 3.21.16
  32370. --------------------------
  32371.  
  32372.    * Added ODBC 2.0 & 3.0 functions `POWER()', `SPACE()', `COT()',
  32373.      `DEGREES()', `RADIANS()', `ROUND(2 arg)' and `TRUNCATE()'.
  32374.  
  32375.    * *WARNING: INCOMPATIBLE CHANGE!!* `LOCATE()' parameters were
  32376.      swapped according to ODBC standard. Fixed.
  32377.  
  32378.    * Added function `TIME_TO_SEC()'.
  32379.  
  32380.    * In some cases, default values were not used for `NOT NULL' fields.
  32381.  
  32382.    * Timestamp wasn't always updated properly in `UPDATE SET ...'
  32383.      statements.
  32384.  
  32385.    * Allow empty strings as default values for `BLOB' and `TEXT', to be
  32386.      compatible with `mysqldump'.
  32387.  
  32388. Changes in release 3.21.15
  32389. --------------------------
  32390.  
  32391.    * *WARNING: INCOMPATIBLE CHANGE!!* `mysqlperl' is now from
  32392.      Msql-Mysql-modules. This means that `connect()' now takes `host',
  32393.      `database', `user', `password' arguments! The old version took
  32394.      `host', `database', `password', `user'.
  32395.  
  32396.    * Allow `DATE '1997-01-01'', `TIME '12:10:10'' and `TIMESTAMP
  32397.      '1997-01-01 12:10:10'' formats required by ANSI SQL.  *WARNING:
  32398.      INCOMPATIBLE CHANGE!!* This has the unfortunate side-effect that
  32399.      you no longer can have columns named `DATE', `TIME' or
  32400.      `TIMESTAMP'. :( Old columns can still be accessed through
  32401.      `tablename.columnname'!)
  32402.  
  32403.    * Changed Makefiles to hopefully work better with BSD systems. Also,
  32404.      `manual.dvi' is now included in the distribution to avoid having
  32405.      stupid `make' programs trying to rebuild it.
  32406.  
  32407.    * `readline' library upgraded to version 2.1.
  32408.  
  32409.    * A new sortorder german-1. That is a normal ISO-Latin1 with a
  32410.      german sort order.
  32411.  
  32412.    * Perl `DBI'/`DBD' is now included in the distribution. `DBI' is now
  32413.      the recommended way to connect to *MySQL* from Perl.
  32414.  
  32415.    * New portable benchmark suite with `DBD', with test results from
  32416.      `mSQL' 2.0.3, *MySQL*, PostgreSQL 6.2.1 and Solid server 2.2.
  32417.  
  32418.    * `crash-me' is now included with the benchmarks; This is a Perl
  32419.      program designed to find as many limits as possible in a SQL
  32420.      server. Tested with `mSQL', PostgreSQL, Solid and *MySQL*.
  32421.  
  32422.    * Fixed bug in range-optimizer that crashed *MySQL* on some queries.
  32423.  
  32424.    * Table and column name completion for `mysql' command line tool, by
  32425.      Zeev Suraski and Andi Gutmans.
  32426.  
  32427.    * Added new command `REPLACE' that works like `INSERT' but replaces
  32428.      conflicting records with the new record. `REPLACE INTO TABLE ...
  32429.      SELECT ...' works also.
  32430.  
  32431.    * Added new commands `CREATE DATABASE db_name' and `DROP DATABASE
  32432.      db_name'.
  32433.  
  32434.    * Added `RENAME' option to `ALTER TABLE': `ALTER TABLE name RENAME
  32435.      AS new_name'.
  32436.  
  32437.    * `make_binary_distribution' now includes `libgcc.a' in
  32438.      `libmysqlclient.a'. This should make linking work for people who
  32439.      don't have `gcc'.
  32440.  
  32441.    * Changed `net_write()' to `my_net_write()' because of a name
  32442.      conflict with Sybase.
  32443.  
  32444.    * New function `DAYOFWEEK()' compatible with ODBC.
  32445.  
  32446.    * Stack checking and `bison' memory overrun checking to make *MySQL*
  32447.      safer with weird queries.
  32448.  
  32449. Changes in release 3.21.14b
  32450. ---------------------------
  32451.  
  32452.    * Fixed a couple of small `configure' problems on some platforms.
  32453.  
  32454. Changes in release 3.21.14a
  32455. ---------------------------
  32456.  
  32457.    * Ported to SCO Openserver 5.0.4  with FSU Pthreads.
  32458.  
  32459.    * HP-UX 10.20 should work.
  32460.  
  32461.    * Added new function `DATE_FORMAT()'.
  32462.  
  32463.    * Added `NOT IN'.
  32464.  
  32465.    * Added automatic removal of 'ODBC function conversions': `{fn now()
  32466.      }'
  32467.  
  32468.    * Handle ODBC 2.50.3 option flags.
  32469.  
  32470.    * Fixed comparison of `DATE' and `TIME' values with `NULL'.
  32471.  
  32472.    * Changed language name from germany to german to be consistent with
  32473.      the other language names.
  32474.  
  32475.    * Fixed sorting problem on functions returning a `FLOAT'.
  32476.      Previously, the values were converted to `INT's before sorting.
  32477.  
  32478.    * Fixed slow sorting when sorting on key field when using
  32479.      `key_column=constant'.
  32480.  
  32481.    * Sorting on calculated `DOUBLE' values sorted on integer results
  32482.      instead.
  32483.  
  32484.    * `mysql' no longer needs a database argument.
  32485.  
  32486.    * Changed the place where `HAVING' should be. According to ANSI, it
  32487.      should be after `GROUP BY' but before `ORDER BY'. *MySQL* 3.20
  32488.      incorrectly had it last.
  32489.  
  32490.    * Added Sybase command `USE DATABASE' to start using another
  32491.      database.
  32492.  
  32493.    * Added automatic adjusting of number of connections and table cache
  32494.      size if the maximum number of files that can be opened is less
  32495.      than needed.  This should fix that `mysqld' doesn't crash even if
  32496.      you haven't done a `ulimit -n 256' before starting `mysqld'.
  32497.  
  32498.    * Added lots of limit checks to make it safer when running with too
  32499.      little memory or when doing weird queries.
  32500.  
  32501. Changes in release 3.21.13
  32502. --------------------------
  32503.  
  32504.    * Added retry of interrupted reads and clearing of `errno'.  This
  32505.      makes Linux systems much safer!
  32506.  
  32507.    * Fixed locking bug when using many aliases on the same table in the
  32508.      same `SELECT'.
  32509.  
  32510.    * Fixed bug with `LIKE' on number key.
  32511.  
  32512.    * New error message so you can check whether the connection was lost
  32513.      while the command was running or whether the connection was down
  32514.      from the start.
  32515.  
  32516.    * Added `--table' option to `mysql' to print in table format.  Moved
  32517.      time and row information after query result.  Added automatic
  32518.      reconnect of lost connections.
  32519.  
  32520.    * Added `!=' as a synonym for `<>'.
  32521.  
  32522.    * Added function `VERSION()' to make easier logs.
  32523.  
  32524.    * New multi-user test `tests/fork_test.pl' to put some strain on the
  32525.      thread library.
  32526.  
  32527. Changes in release 3.21.12
  32528. --------------------------
  32529.  
  32530.    * Fixed `ftruncate()' call in MIT-pthreads. This made `isamchk'
  32531.      destroy the `.ISM' files on (Free)BSD 2.x systems.
  32532.  
  32533.    * Fixed broken `__P_' patch in MIT-pthreads.
  32534.  
  32535.    * Many memory overrun checks. All string functions now return `NULL'
  32536.      if the returned string should be longer than `max_allowed_packet'
  32537.      bytes.
  32538.  
  32539.    * Changed the name of the `INTERVAL' type to `ENUM', because
  32540.      `INTERVAL' is used in ANSI SQL.
  32541.  
  32542.    * In some cases, doing a `JOIN' + `GROUP' + `INTO OUTFILE', the
  32543.      result wasn't grouped.
  32544.  
  32545.    * `LIKE' with `'_'' as last character didn't work. Fixed.
  32546.  
  32547.    * Added extended ANSI SQL `TRIM()' function.
  32548.  
  32549.    * Added `CURTIME()'.
  32550.  
  32551.    * Added `ENCRYPT()' function by Zeev Suraski.
  32552.  
  32553.    * Fixed better `FOREIGN KEY' syntax skipping. New reserved words:
  32554.      `MATCH', `FULL', `PARTIAL'.
  32555.  
  32556.    * `mysqld' now allows IP number and hostname to the `--bind-address'
  32557.      option.
  32558.  
  32559.    * Added `SET OPTION CHARACTER SET cp1251_koi8' to enable conversions
  32560.      of data to/from cp1251_koi8.
  32561.  
  32562.    * Lots of changes for Win95 port. In theory, this version should now
  32563.      be easily portable to Win95.
  32564.  
  32565.    * Changed the `CREATE COLUMN' syntax of `NOT NULL' columns to be
  32566.      after the `DEFAULT' value, as specified in the ANSI SQL standard.
  32567.      This will make `mysqldump' with `NOT NULL' and default values
  32568.      incompatible with *MySQL* 3.20.
  32569.  
  32570.    * Added many function name aliases so the functions can be used with
  32571.      ODBC or ANSI SQL92 syntax.
  32572.  
  32573.    * Fixed syntax of `ALTER TABLE tbl_name ALTER COLUMN col_name SET
  32574.      DEFAULT NULL'.
  32575.  
  32576.    * Added `CHAR' and `BIT' as synonyms for `CHAR(1)'.
  32577.  
  32578.    * Fixed core dump when updating as a user who has only *select*
  32579.      privilege.
  32580.  
  32581.    * `INSERT ... SELECT ... GROUP BY' didn't work in some cases. An
  32582.      `Invalid use of group function' error occurred.
  32583.  
  32584.    * When using `LIMIT', `SELECT' now always uses keys instead of record
  32585.      scan.  This will give better performance on `SELECT' and a `WHERE'
  32586.      that matches many rows.
  32587.  
  32588.    * Added Russian error messages.
  32589.  
  32590. Changes in release 3.21.11
  32591. --------------------------
  32592.  
  32593.    * Configure changes.
  32594.  
  32595.    * *MySQL* now works with the new thread library on BSD/OS 3.0.
  32596.  
  32597.    * Added new group functions `BIT_OR()' and `BIT_AND()'.
  32598.  
  32599.    * Added compatibility functions `CHECK' and `REFERENCES'.  `CHECK'
  32600.      is now a reserved word.
  32601.  
  32602.    * Added `ALL' option to `GRANT' for better compatibility. (`GRANT'
  32603.      is still a dummy function.)
  32604.  
  32605.    * Added partly-translated dutch messages.
  32606.  
  32607.    * Fixed bug in `ORDER BY' and `GROUP BY' with `NULL' columns.
  32608.  
  32609.    * Added function `last_insert_id()' to retrieve last `AUTO_INCREMENT'
  32610.      value.  This is intended for clients to ODBC that can't use the
  32611.      `mysql_insert_id()' API function, but can be used by any client.
  32612.  
  32613.    * Added `--flush-logs' option to `mysqladmin'.
  32614.  
  32615.    * Added command `STATUS' to `mysql'.
  32616.  
  32617.    * Fixed problem with `ORDER BY'/`GROUP BY' because of bug in `gcc'.
  32618.  
  32619.    * Fixed problem with `INSERT ... SELECT ... GROUP BY'.
  32620.  
  32621. Changes in release 3.21.10
  32622. --------------------------
  32623.  
  32624.    * New `mysqlaccess'.
  32625.  
  32626.    * `CREATE' now supports all ODBC types and the `mSQL' `TEXT' type.
  32627.      All ODBC 2.5 functions are also supported (added `REPEAT'). This
  32628.      provides better portability.
  32629.  
  32630.    * Added text types `TINYTEXT', `TEXT', `MEDIUMTEXT' and `LONGTEXT'.
  32631.      These are actually `BLOB'types, but all searching is done in
  32632.      case-insensitive fashion.
  32633.  
  32634.    * All old `BLOB' fields are now `TEXT' fields.  This only changes
  32635.      that all searching on strings is done in case-sensitive fashion.
  32636.      You must do an `ALTER TABLE' and change the field type to `BLOB'
  32637.      if you want to have tests done in case-sensitive fashion.
  32638.  
  32639.    * Fixed some `configure' issues.
  32640.  
  32641.    * Made the locking code a bit safer. Fixed very unlikely deadlock
  32642.      situation.
  32643.  
  32644.    * Fixed a couple of bugs in the range optimizer. Now the new range
  32645.      benchmark `test-select' works.
  32646.  
  32647. Changes in release 3.21.9
  32648. -------------------------
  32649.  
  32650.    * Added `--enable-unix-socket=pathname' option to `configure'.
  32651.  
  32652.    * Fixed a couple of portability problems with include files.
  32653.  
  32654.    * Fixed bug in range calculation that could return empty set when
  32655.      searching on multiple key with only one entry (very rare).
  32656.  
  32657.    * Most things ported to FSU Pthreads, which should allow *MySQL* to
  32658.      run on SCO. *Note SCO::.
  32659.  
  32660. Changes in release 3.21.8
  32661. -------------------------
  32662.  
  32663.    * Works now in Solaris 2.6.
  32664.  
  32665.    * Added handling of calculation of `SUM()' functions.  For example,
  32666.      you can now use `SUM(column)/COUNT(column)'.
  32667.  
  32668.    * Added handling of trigometric functions: `PI()', `ACOS()',
  32669.      `ASIN()', `ATAN()', `COS()', `SIN()' and `TAN()'.
  32670.  
  32671.    * New languages: norwegian, norwegian-ny and portuguese.
  32672.  
  32673.    * Fixed parameter bug in `net_print()' in `procedure.cc'.
  32674.  
  32675.    * Fixed a couple of memory leaks.
  32676.  
  32677.    * Now allow also the old `SELECT ... INTO OUTFILE' syntax.
  32678.  
  32679.    * Fixed bug with `GROUP BY' and `SELECT' on key with many values.
  32680.  
  32681.    * `mysql_fetch_lengths()' sometimes returned incorrect lengths when
  32682.      you used `mysql_use_result()'. This affected at least some cases of
  32683.      `mysqldump --quick'.
  32684.  
  32685.    * Fixed bug in optimization of `WHERE const op field'.
  32686.  
  32687.    * Fixed problem when sorting on `NULL' fields.
  32688.  
  32689.    * Fixed a couple of 64-bit (Alpha) problems.
  32690.  
  32691.    * Added `--pid-file=#' option to `mysqld'.
  32692.  
  32693.    * Added date formatting to `FROM_UNIXTIME()', originally by Zeev
  32694.      Suraski.
  32695.  
  32696.    * Fixed bug in `BETWEEN' in range optimizer (Did only test = of the
  32697.      first argument).
  32698.  
  32699.    * Added machine-dependent files for MIT-pthreads i386-SCO. There is
  32700.      probably more to do to get this to work on SCO 3.5.
  32701.  
  32702. Changes in release 3.21.7
  32703. -------------------------
  32704.  
  32705.    * Changed `Makefile.am' to take advantage of Automake 1.2.
  32706.  
  32707.    * Added the beginnings of a benchmark suite.
  32708.  
  32709.    * Added more secure password handling.
  32710.  
  32711.    * Added new client function `mysql_errno()', to get the error number
  32712.      of the error message. This makes error checking in the client much
  32713.      easier.  This makes the new server incompatible with the 3.20.x
  32714.      server when running without `--old-protocol'.  The client code is
  32715.      backward compatible.  More information can be found in the
  32716.      `README' file!
  32717.  
  32718.    * Fixed some problems when using very long, illegal names.
  32719.  
  32720. Changes in release 3.21.6
  32721. -------------------------
  32722.  
  32723.    * Fixed more portability issues (incorrect `sigwait' and `sigset'
  32724.      defines).
  32725.  
  32726.    * `configure' should now be able to detect the last argument to
  32727.      `accept()'.
  32728.  
  32729. Changes in release 3.21.5
  32730. -------------------------
  32731.  
  32732.    * Should now work with FreeBSD 3.0 if used with
  32733.      `FreeBSD-3.0-libc_r-1.0.diff', which can be found at
  32734.      `http://www.mysql.com/Downloads/Patches/'.
  32735.  
  32736.    * Added new option `-O tmp_table_size=#' to `mysqld'.
  32737.  
  32738.    * New function `FROM_UNIXTIME(timestamp)' which returns a date
  32739.      string in 'YYYY-MM-DD HH:MM:DD' format.
  32740.  
  32741.    * New function `SEC_TO_TIME(seconds)' which returns a string in
  32742.      'HH:MM:SS' format.
  32743.  
  32744.    * New function `SUBSTRING_INDEX()', originally by Zeev Suraski.
  32745.  
  32746. Changes in release 3.21.4
  32747. -------------------------
  32748.  
  32749.    * Should now configure and compile on OSF1 4.0 with the DEC compiler.
  32750.  
  32751.    * Configuration and compilation on BSD/OS 3.0 works, but due to some
  32752.      bugs in BSD/OS 3.0, `mysqld' doesn't work on it yet.
  32753.  
  32754.    * Configuration and compilation on FreeBSD 3.0 works, but I couldn't
  32755.      get `pthread_create' to work.
  32756.  
  32757. Changes in release 3.21.3
  32758. -------------------------
  32759.  
  32760.    * Added reverse check lookup of hostnames to get better security.
  32761.  
  32762.    * Fixed some possible buffer overflows if filenames that are too
  32763.      long are used.
  32764.  
  32765.    * `mysqld' doesn't accept hostnames that start with digits followed
  32766.      by a `'.'', because the hostname may look like an IP number.
  32767.  
  32768.    * Added `--skip-networking' option to `mysqld', to only allow socket
  32769.      connections.  (This will not work with MIT-pthreads!)
  32770.  
  32771.    * Added check of too long table names for alias.
  32772.  
  32773.    * Added check if database name is okay.
  32774.  
  32775.    * Added check if too long table names.
  32776.  
  32777.    * Removed incorrect `free()' that killed the server on `CREATE
  32778.      DATABASE' or `DROP DATABASE'.
  32779.  
  32780.    * Changed some `mysqld' `-O' options to better names.
  32781.  
  32782.    * Added `-O join_cache_size=#' option to `mysqld'.
  32783.  
  32784.    * Added `-O max_join_size=#' option to `mysqld', to be able to set a
  32785.      limit how big queries (in this case big = slow) one should be able
  32786.      to handle without specifying `SET OPTION SQL_BIG_SELECTS=1'.  A #
  32787.      = is about 10 examined records. The default is "unlimited".
  32788.  
  32789.    * When comparing a `TIME', `DATE', `DATETIME' or `TIMESTAMP' column
  32790.      to a constant, the constant is converted to a time value before
  32791.      performing the comparison.  This will make it easier to get ODBC
  32792.      (particularly Access97) to work with the above types. It should
  32793.      also make dates easier to use and the comparisons should be
  32794.      quicker than before.
  32795.  
  32796.    * Applied patch from Jochen Wiedmann that allows `query()' in
  32797.      `mysqlperl' to take a query with `\0' in it.
  32798.  
  32799.    * Storing a timestamp with a 2-digit year (`YYMMDD') didn't work.
  32800.  
  32801.    * Fix that timestamp wasn't automatically updated if set in an
  32802.      `UPDATE' clause.
  32803.  
  32804.    * Now the automatic timestamp field is the FIRST timestamp field.
  32805.  
  32806.    * `SELECT * INTO OUTFILE', which didn't correctly if the outfile
  32807.      already existed.
  32808.  
  32809.    * `mysql' now shows the thread ID when starting or doing a reconnect.
  32810.  
  32811.    * Changed the default sort buffer size from 2M to 1M.
  32812.  
  32813. Changes in release 3.21.2
  32814. -------------------------
  32815.  
  32816.    * The range optimizer is coded, but only 85% tested. It can be
  32817.      enabled with `--new', but it crashes core a lot yet...
  32818.  
  32819.    * More portable. Should compile on AIX and alpha-digital.  At least
  32820.      the `isam' library should be relatively 64-bit clean.
  32821.  
  32822.    * New `isamchk' which can detect and fix more problems.
  32823.  
  32824.    * New options for `isamlog'.
  32825.  
  32826.    * Using new version of Automake.
  32827.  
  32828.    * Many small portability changes (from the AIX and alpha-digital
  32829.      port) Better checking of pthread(s) library.
  32830.  
  32831.    * czech error messages by <snajdr@pvt.net>.
  32832.  
  32833.    * Decreased size of some buffers to get fewer problems on systems
  32834.      with little memory.  Also added more checks to handle "out of
  32835.      memory" problems.
  32836.  
  32837.    * `mysqladmin': you can now do `mysqladmin kill 5,6,7,8' to kill
  32838.      multiple threads.
  32839.  
  32840.    * When the maximum connection limit is reached, one extra connection
  32841.      by a user with the *PROCESS_ACL* privilege is granted.
  32842.  
  32843.    * Added `-O backlog=#' option to `mysqld'.
  32844.  
  32845.    * Increased maximum packet size from 512K to 1024K for client.
  32846.  
  32847.    * Almost all of the function code is now tested in the internal test
  32848.      suite.
  32849.  
  32850.    * `ALTER TABLE' now returns warnings from field conversions.
  32851.  
  32852.    * Port changed to 3306 (got it reserved from ISI).
  32853.  
  32854.    * Added a fix for Visual FoxBase so that any schema name from a table
  32855.      specification is automatically removed.
  32856.  
  32857.    * New function `ASCII()'.
  32858.  
  32859.    * Removed function `BETWEEN(a,b,c)'. Use the standard ANSI synax
  32860.      instead: `expr BETWEEN expr AND expr'.
  32861.  
  32862.    * *MySQL* no longer has to use an extra temporary table when sorting
  32863.      on functions or `SUM()' functions.
  32864.  
  32865.    * Fixed bug that you couldn't use `tbl_name.field_name' in `UPDATE'.
  32866.  
  32867.    * Fixed `SELECT DISTINCT' when using 'hidden group'. For example:
  32868.           mysql> SELECT DISTINCT MOD(some_field,10) FROM test
  32869.                      GROUP BY some_field;
  32870.      Note: `some_field' is normally in the `SELECT' part. ANSI SQL
  32871.      should require it.
  32872.  
  32873. Changes in release 3.21.0
  32874. -------------------------
  32875.  
  32876.    * New reserved words used: `INTERVAL', `EXPLAIN', `READ', `WRITE',
  32877.      `BINARY'.
  32878.  
  32879.    * Added ODBC function `CHAR(num,...)'.
  32880.  
  32881.    * New operator `IN'. This uses a binary search to find a match.
  32882.  
  32883.    * New command `LOCK TABLES tbl_name [AS alias] {READ|WRITE} ...'
  32884.  
  32885.    * Added `--log-update' option to `mysqld', to get a log suitable for
  32886.      incremental updates.
  32887.  
  32888.    * New command `EXPLAIN SELECT ...' to get information about how the
  32889.      optimizer will do the join.
  32890.  
  32891.    * For easier client code, the client should no longer use
  32892.      `FIELD_TYPE_TINY_BLOB', `FIELD_TYPE_MEDIUM_BLOB',
  32893.      `FIELD_TYPE_LONG_BLOB' or `FIELD_TYPE_VAR_STRING' (as previously
  32894.      returned by `mysql_list_fields').  You should instead only use
  32895.      `FIELD_TYPE_BLOB' or `FIELD_TYPE_STRING'.  If you want exact
  32896.      types, you should use the command `SHOW FIELDS'.
  32897.  
  32898.    * Added varbinary syntax: `0x######' which can be used as a string
  32899.      (default) or a number.
  32900.  
  32901.    * `FIELD_TYPE_CHAR' is renamed to `FIELD_TYPE_TINY'.
  32902.  
  32903.    * Changed all fields to C++ classes.
  32904.  
  32905.    * Removed FORM struct.
  32906.  
  32907.    * Fields with `DEFAULT' values no longer need to be `NOT NULL'.
  32908.  
  32909.    * New field types:
  32910.     `ENUM'
  32911.           A string which can take only a couple of defined values. The
  32912.           value is stored as a 1-3 byte number that is mapped
  32913.           automatically to a string.  This is sorted according to
  32914.           string positions!
  32915.  
  32916.     `SET'
  32917.           A string which may have one or many string values separated
  32918.           with ','.  The string is stored as a 1-, 2-, 3-, 4- or 8-byte
  32919.           number where each bit stands for a specific set member.  This
  32920.           is sorted according to the unsigned value of the stored
  32921.           packed number.
  32922.  
  32923.    * Now all function calculation is done with `double' or `long long'.
  32924.      This will provide the full 64-bit range with bit functions and fix
  32925.      some conversions that previously could result in precision losses.
  32926.      One should avoid using `unsigned long long' columns with full
  32927.      64-bit range (numbers bigger than 9223372036854775807) because
  32928.      calculations are done with `signed long long'.
  32929.  
  32930.    * `ORDER BY' will now put `NULL' field values first. `GROUP BY' will
  32931.      also work with `NULL' values.
  32932.  
  32933.    * Full `WHERE' with expressions.
  32934.  
  32935.    * New range optimizer that can resolve ranges when some keypart
  32936.      prefix is constant. Example:
  32937.           mysql> SELECT * FROM tbl_name
  32938.                      WHERE key_part_1="customer"
  32939.                      AND key_part_2>=10 AND key_part_2<=10;
  32940.  
  32941. Changes in release 3.20.x
  32942. =========================
  32943.  
  32944. Changes from 3.20.18 to 3.20.32b are not documented here because the
  32945. 3.21 release branched here. And the relevant changes are also
  32946. documented as changes to the 3.21 version.
  32947.  
  32948. Changes in release 3.20.18
  32949. --------------------------
  32950.  
  32951.    * Added `-p#' (remove `#' directories from path) to `isamlog'.  All
  32952.      files are written with a relative path from the database directory
  32953.      Now `mysqld' shouldn't crash on shutdown when using the
  32954.      `--log-isam' option.
  32955.  
  32956.    * New `mysqlperl' version. It is now compatible with `msqlperl-0.63'.
  32957.  
  32958.    * New `DBD' module available at
  32959.      `http://www.mysql.com/Downloads/Contrib/' site.
  32960.  
  32961.    * Added group function `STD()' (standard deviation).
  32962.  
  32963.    * The `mysqld' server is now compiled by default without debugging
  32964.      information.  This will make the daemon smaller and faster.
  32965.  
  32966.    * Now one usually only has to specify the `--basedir' option to
  32967.      `mysqld'. All other paths are relative in a normal installation.
  32968.  
  32969.    * `BLOB' columns sometimes contained garbage when used with a
  32970.      `SELECT' on more than one table and `ORDER BY'.
  32971.  
  32972.    * Fixed that calculations that are not in `GROUP BY' work as expected
  32973.      (ANSI SQL extension).  Example:
  32974.           mysql> SELECT id,id+1 FROM table GROUP BY id;
  32975.  
  32976.    * The test of using `MYSQL_PWD' was reversed. Now `MYSQL_PWD' is
  32977.      enabled as default in the default release.
  32978.  
  32979.    * Fixed conversion bug which caused `mysqld' to core dump with
  32980.      Arithmetic error on Sparc-386.
  32981.  
  32982.    * Added `--unbuffered' option to `mysql', for new `mysqlaccess'.
  32983.  
  32984.    * When using overlapping (unnecessary) keys and join over many
  32985.      tables, the optimizer could get confused and return 0 records.
  32986.  
  32987. Changes in release 3.20.17
  32988. --------------------------
  32989.  
  32990.    * You can now use `BLOB' columns and the functions `IS NULL' and `IS
  32991.      NOT NULL' in the `WHERE' clause.
  32992.  
  32993.    * All communication packets and row buffers are now allocated
  32994.      dynamically on demand. The default value of `max_allowed_packet'
  32995.      is now 64K for the server and 512K for the client. This is mainly
  32996.      used to catch incorrect packets that could trash all memory. The
  32997.      server limit may be changed when it is started.
  32998.  
  32999.    * Changed stack usage to use less memory.
  33000.  
  33001.    * Changed `safe_mysqld' to check for running daemon.
  33002.  
  33003.    * The `ELT()' function is renamed to `FIELD()'.  The new `ELT()'
  33004.      function returns a value based on an index: `FIELD()' is the
  33005.      inverse of `ELT()' Example: `ELT(2,"A","B","C")' returns `"B"'.
  33006.      `FIELD("B","A","B","C")' returns `2'.
  33007.  
  33008.    * `COUNT(field)', where `field' could have a `NULL' value, now works.
  33009.  
  33010.    * A couple of bugs fixed in `SELECT ... GROUP BY'.
  33011.  
  33012.    * Fixed memory overrun bug in `WHERE' with many unoptimizable brace
  33013.      levels.
  33014.  
  33015.    * Fixed some small bugs in the grant code.
  33016.  
  33017.    * If hostname isn't found by `get_hostname', only the IP is checked.
  33018.      Previously, you got `Access denied'.
  33019.  
  33020.    * Inserts of timestamps with values didn't always work.
  33021.  
  33022.    * `INSERT INTO ... SELECT ... WHERE' could give the error
  33023.      `Duplicated field'.
  33024.  
  33025.    * Added some tests to `safe_mysqld' to make it "safer".
  33026.  
  33027.    * `LIKE' was case sensitive in some places and case insensitive in
  33028.      others.  Now `LIKE' is always case insensitive.
  33029.  
  33030.    * `mysql.cc': Allow `'#'' anywhere on the line.
  33031.  
  33032.    * New command `SET OPTION SQL_SELECT_LIMIT=#'. See the FAQ for more
  33033.      details.
  33034.  
  33035.    * New version of the `mysqlaccess' script.
  33036.  
  33037.    * Change `FROM_DAYS()' and `WEEKDAY()' to also take a full
  33038.      `TIMESTAMP' or `DATETIME' as argument. Before they only took a
  33039.      number of type `YYYYMMDD' or `YYMMDD'.
  33040.  
  33041.    * Added new function `UNIX_TIMESTAMP(timestamp_column)'.
  33042.  
  33043. Changes in release 3.20.16
  33044. --------------------------
  33045.  
  33046.    * More changes in MIT-pthreads to get them safer. Fixed also some
  33047.      link bugs at least in SunOS.
  33048.  
  33049.    * Changed `mysqld' to work around a bug in MIT-pthreads. This makes
  33050.      multiple small `SELECT' operations 20 times faster. Now
  33051.      `lock_test.pl' should work.
  33052.  
  33053.    * Added `mysql_FetchHash(handle)' to `mysqlperl'.
  33054.  
  33055.    * The `mysqlbug' script is now distributed built to allow for
  33056.      reporting bugs that appear during the build with it.
  33057.  
  33058.    * Changed `libmysql.c' to prefer `getpwuid()' instead of `cuserid()'.
  33059.  
  33060.    * Fixed bug in `SELECT' optimizer when using many tables with the
  33061.      same column used as key to different tables.
  33062.  
  33063.    * Added new latin2 and Russian KOI8 character tables.
  33064.  
  33065.    * Added support for a dummy `GRANT' command to satisfy Powerbuilder.
  33066.  
  33067. Changes in release 3.20.15
  33068. --------------------------
  33069.  
  33070.    * Fixed fatal bug `packets out of order' when using MIT-pthreads.
  33071.  
  33072.    * Removed possible loop when a thread waits for command from client
  33073.      and `fcntl()' fails. Thanks to Mike Bretz for finding this bug.
  33074.  
  33075.    * Changed alarm loop in `mysqld.cc' because shutdown didn't always
  33076.      succeed in Linux.
  33077.  
  33078.    * Removed use of `termbits' from `mysql.cc'.  This conflicted with
  33079.      `glibc' 2.0.
  33080.  
  33081.    * Fixed some syntax errors for at least BSD and Linux.
  33082.  
  33083.    * Fixed bug when doing a `SELECT' as superuser without a database.
  33084.  
  33085.    * Fixed bug when doing `SELECT' with group calculation to outfile.
  33086.  
  33087. Changes in release 3.20.14
  33088. --------------------------
  33089.  
  33090.    * If one gives `-p' or `--password' option to `mysql' without an
  33091.      argument, the user is solicited for the password from the tty.
  33092.  
  33093.    * Added default password from `MYSQL_PWD' (by Elmar Haneke).
  33094.  
  33095.    * Added command `kill' to `mysqladmin' to kill a specific *MySQL*
  33096.      thread.
  33097.  
  33098.    * Sometimes when doing a reconnect on a down connection this
  33099.      succeeded first on second try.
  33100.  
  33101.    * Fixed adding an `AUTO_INCREMENT' key with `ALTER_TABLE'.
  33102.  
  33103.    * `AVG()' gave too small value on some `SELECT's with `GROUP BY' and
  33104.      `ORDER BY'.
  33105.  
  33106.    * Added new `DATETIME' type (by Giovanni Maruzzelli
  33107.      <maruzz@matrice.it>).
  33108.  
  33109.    * Fixed that define `DONT_USE_DEFAULT_FIELDS' works.
  33110.  
  33111.    * Changed to use a thread to handle alarms instead of signals on
  33112.      Solaris to avoid race conditions.
  33113.  
  33114.    * Fixed default length of signed numbers. (George Harvey
  33115.      <georgeh@pinacl.co.uk>.)
  33116.  
  33117.    * Allow anything for `CREATE INDEX'.
  33118.  
  33119.    * Add prezeros when packing numbers to `DATE', `TIME' and
  33120.      `TIMESTAMP'.
  33121.  
  33122.    * Fixed a bug in `OR' of multiple tables (gave empty set).
  33123.  
  33124.    * Added many patches to MIT-pthreads. This fixes at least one lookup
  33125.      bug.
  33126.  
  33127. Changes in release 3.20.13
  33128. --------------------------
  33129.  
  33130.    * Added ANSI SQL94 `DATE' and `TIME' types.
  33131.  
  33132.    * Fixed bug in `SELECT' with `AND'-`OR' levels.
  33133.  
  33134.    * Added support for Slovenian characters. The `Contrib' directory
  33135.      contains source and instructions for adding other character sets.
  33136.  
  33137.    * Fixed bug with `LIMIT' and `ORDER BY'.
  33138.  
  33139.    * Allow `ORDER BY' and `GROUP BY' on items that aren't in the
  33140.      `SELECT' list.  (Thanks to Wim Bonis <bonis@kiss.de>, for pointing
  33141.      this out.)
  33142.  
  33143.    * Allow setting of timestamp values in `INSERT'.
  33144.  
  33145.    * Fixed bug with `SELECT ... WHERE ... = NULL'.
  33146.  
  33147.    * Added changes for `glibc' 2.0. To get `glibc' to work, you should
  33148.      add the `gibc-2.0-sigwait-patch' before compiling `glibc'.
  33149.  
  33150.    * Fixed bug in `ALTER TABLE' when changing a `NOT NULL' field to
  33151.      allow `NULL' values.
  33152.  
  33153.    * Added some ANSI92 synonyms as field types to `CREATE TABLE'.
  33154.      `CREATE TABLE' now allows `FLOAT(4)' and `FLOAT(8)' to mean
  33155.      `FLOAT' and `DOUBLE'.
  33156.  
  33157.    * New utility program `mysqlaccess' by <Yves.Carlier@rug.ac.be>.
  33158.      This program shows the access rights for a specific user and the
  33159.      grant rows that determine this grant.
  33160.  
  33161.    * Added `WHERE const op field' (by <bonis@kiss.de>).
  33162.  
  33163. Changes in release 3.20.11
  33164. --------------------------
  33165.  
  33166.    * When using `SELECT ... INTO OUTFILE', all temporary tables are ISAM
  33167.      instead of HEAP to allow big dumps.
  33168.  
  33169.    * Changed date functions to be string functions. This fixed some
  33170.      "funny" side effects when sorting on dates.
  33171.  
  33172.    * Extended `ALTER TABLE' according to SQL92.
  33173.  
  33174.    * Some minor compability changes.
  33175.  
  33176.    * Added `--port' and `--socket' options to all utility programs and
  33177.      `mysqld'.
  33178.  
  33179.    * Fixed MIT-pthreads `readdir_r()'. Now `mysqladmin create database'
  33180.      and `mysqladmin drop database' should work.
  33181.  
  33182.    * Changed MIT-pthreads to use our `tempnam()'. This should fix the
  33183.      "sort aborted" bug.
  33184.  
  33185.    * Added sync of records count in `sql_update'. This fixed slow
  33186.      updates on first connection. (Thanks to Vaclav Bittner for the
  33187.      test.)
  33188.  
  33189. Changes in release 3.20.10
  33190. --------------------------
  33191.  
  33192.    * New insert type: `INSERT INTO ... SELECT ...'
  33193.  
  33194.    * `MEDIUMBLOB' fixed.
  33195.  
  33196.    * Fixed bug in `ALTER TABLE' and `BLOB's.
  33197.  
  33198.    * `SELECT ... INTO OUTFILE' now creates the file in the current
  33199.      database directory.
  33200.  
  33201.    * `DROP TABLE' now can take a list of tables.
  33202.  
  33203.    * Oracle synonym `DESCRIBE' (`DESC').
  33204.  
  33205.    * Changes to `make_binary_distribution'.
  33206.  
  33207.    * Added some comments to installation instructions about
  33208.      `configure''s C++ link test.
  33209.  
  33210.    * Added `--without-perl' option to `configure'.
  33211.  
  33212.    * Lots of small portability changes.
  33213.  
  33214. Changes in release 3.20.9
  33215. -------------------------
  33216.  
  33217.    * `ALTER TABLE' didn't copy null bit. As a result, fields that were
  33218.      allowed to have `NULL' values were always `NULL'.
  33219.  
  33220.    * `CREATE' didn't take numbers as `DEFAULT'.
  33221.  
  33222.    * Some compatibility changes for SunOS.
  33223.  
  33224.    * Removed `config.cache' from old distribution.
  33225.  
  33226. Changes in release 3.20.8
  33227. -------------------------
  33228.  
  33229.    * Fixed bug with `ALTER TABLE' and multi-part keys.
  33230.  
  33231. Changes in release 3.20.7
  33232. -------------------------
  33233.  
  33234.    * New commands: `ALTER TABLE', `SELECT ... INTO OUTFILE' and `LOAD
  33235.      DATA INFILE'.
  33236.  
  33237.    * New function: `NOW()'.
  33238.  
  33239.    * Added new field *file_priv* to `mysql/user' table.
  33240.  
  33241.    * New script `add_file_priv' which adds the new field *file_priv* to
  33242.      the `user' table. This script must be executed if you want to use
  33243.      the new `SELECT ... INTO' and `LOAD DATA INFILE ...' commands with
  33244.      a version of *MySQL* earlier than 3.20.7.
  33245.  
  33246.    * Fixed bug in locking code, which made `lock_test.pl' test fail.
  33247.  
  33248.    * New files `NEW' and `BUGS'.
  33249.  
  33250.    * Changed `select_test.c' and `insert_test.c' to include `config.h'.
  33251.  
  33252.    * Added command `status' to `mysqladmin' for short logging.
  33253.  
  33254.    * Increased maximum number of keys to 16 and maximum number of key
  33255.      parts to 15.
  33256.  
  33257.    * Use of sub keys. A key may now be a prefix of a string field.
  33258.  
  33259.    * Added `-k' option to `mysqlshow', to get key information for a
  33260.      table.
  33261.  
  33262.    * Added long options to `mysqldump'.
  33263.  
  33264. Changes in release 3.20.6
  33265. -------------------------
  33266.  
  33267.    * Portable to more systems because of MIT-pthreads, which will be
  33268.      used automatically if `configure' cannot find a `-lpthreads'
  33269.      library.
  33270.  
  33271.    * Added GNU-style long options to almost all programs. Test with
  33272.      `program --help'.
  33273.  
  33274.    * Some shared library support for Linux.
  33275.  
  33276.    * The FAQ is now in `.texi' format and is available in `.html',
  33277.      `.txt' and `.ps' formats.
  33278.  
  33279.    * Added new SQL function `RAND([init])'.
  33280.  
  33281.    * Changed `sql_lex' to handle `\0' unquoted, but the client can't
  33282.      send the query through the C API, because it takes a str pointer.
  33283.      You must use `mysql_real_query()' to send the query.
  33284.  
  33285.    * Added API function `mysql_get_client_info()'.
  33286.  
  33287.    * `mysqld' now uses the `N_MAX_KEY_LENGTH' from `nisam.h' as the
  33288.      maximum allowed key length.
  33289.  
  33290.    * The following now works:
  33291.           mysql> SELECT filter_nr,filter_nr FROM filter ORDER BY filter_nr;
  33292.      Previously, this resulted in the error: `Column: 'filter_nr' in
  33293.      order clause is ambiguous'.
  33294.  
  33295.    * `mysql' now outputs `'\0'', `'\t'', `'\n'' and `'\\'' when
  33296.      encountering ASCII 0, tab, newline or `'\'' while writing
  33297.      tab-separated output.  This is to allow printing of binary data in
  33298.      a portable format.  To get the old behavior, use `-r' (or `--raw').
  33299.  
  33300.    * Added german error messages (60 of 80 error messages translated).
  33301.  
  33302.    * Added new API function `mysql_fetch_lengths(MYSQL_RES *)', which
  33303.      returns an array of of column lengths (of type `uint').
  33304.  
  33305.    * Fixed bug with `IS NULL' in `WHERE' clause.
  33306.  
  33307.    * Changed the optimizer a little to get better results when
  33308.      searching on a key part.
  33309.  
  33310.    * Added `SELECT' option `STRAIGHT_JOIN' to tell the optimizer that
  33311.      it should join tables in the given order.
  33312.  
  33313.    * Added support for comments starting with `'--'' in `mysql.cc'
  33314.      (Postgres syntax).
  33315.  
  33316.    * You can have `SELECT' expressions and table columns in a `SELECT'
  33317.      which are not used in the group part. This makes it efficient to
  33318.      implement lookups.  The column that is used should be a constant
  33319.      for each group because the value is calculated only once for the
  33320.      first row that is found for a group.
  33321.           mysql> SELECT id,lookup.text,sum(*) FROM test,lookup
  33322.                    WHERE test.id=lookup.id GROUP BY id;
  33323.  
  33324.    * Fixed bug in `SUM(function)' (could cause a core dump).
  33325.  
  33326.    * Changed `AUTO_INCREMENT' placement in the SQL query:
  33327.           INSERT into table (auto_field) values (0);
  33328.      inserted 0, but it should insert an `AUTO_INCREMENT' value.
  33329.  
  33330.    * `mysqlshow.c': Added number of records in table. Had to change the
  33331.      client code a little to fix this.
  33332.  
  33333.    * `mysql' now allows doubled `''' or `""' within strings for
  33334.      embedded `'' or `"'.
  33335.  
  33336.    * New math functions: `EXP()', `LOG()', `SQRT()', `ROUND()',
  33337.      `CEILING()'.
  33338.  
  33339. Changes in release 3.20.3
  33340. -------------------------
  33341.  
  33342.    * The `configure' source now compiles a thread-free client library
  33343.      `-lmysqlclient'. This is the only library that needs to be linked
  33344.      with client applications.  When using the binary releases, you must
  33345.      link with `-lmysql -lmysys -ldbug -lstrings' as before.
  33346.  
  33347.    * New `readline' library from `bash-2.0'.
  33348.  
  33349.    * LOTS of small changes to `configure' and makefiles (and related
  33350.      source).
  33351.  
  33352.    * It should now be possible to compile in another directory using
  33353.      `VPATH'. Tested with GNU Make 3.75.
  33354.  
  33355.    * `safe_mysqld' and `mysql.server' changed to be more compatible
  33356.      between the source and the binary releases.
  33357.  
  33358.    * `LIMIT' now takes one or two numeric arguments.  If one argument
  33359.      is given, it indicates the maximum number of rows in a result. If
  33360.      two arguments are given, the first argument indicates the offset
  33361.      of the first row to return, the second is the maximum number of
  33362.      rows.  With this it's easy to do a poor man's next page/previous
  33363.      page WWW application.
  33364.  
  33365.    * Changed name of SQL function `FIELDS()' to `ELT()'.  Changed SQL
  33366.      function `INTERVALL()' to `INTERVAL()'.
  33367.  
  33368.    * Made `SHOW COLUMNS' a synonym for `SHOW FIELDS'.  Added
  33369.      compatibility syntax `FRIEND KEY' to `CREATE TABLE'. In *MySQL*,
  33370.      this creates a non-unique key on the given columns.
  33371.  
  33372.    * Added `CREATE INDEX' and `DROP INDEX' as compatibility functions.
  33373.      In *MySQL*, `CREATE INDEX' only checks if the index exists and
  33374.      issues an error if it doesn't exist. `DROP INDEX' always succeeds.
  33375.  
  33376.    * `mysqladmin.c': added client version to version information.
  33377.  
  33378.    * Fixed core dump bug in `sql_acl' (core on new connection).
  33379.  
  33380.    * Removed `host', `user' and `db' tables from database `test' in the
  33381.      distribution.
  33382.  
  33383.    * `FIELD_TYPE_CHAR' can now be signed (-128 - 127) or unsigned (0 -
  33384.      255) Previously, it was always unsigned.
  33385.  
  33386.    * Bug fixes in `CONCAT()' and `WEEKDAY()'.
  33387.  
  33388.    * Changed a lot of source to get `mysqld' to be compiled with SunPro
  33389.      compiler.
  33390.  
  33391.    * SQL functions must now have a `'('' immediately after the function
  33392.      name (no intervening space).  For example, `'user('' is regarded
  33393.      as beginning a function call, and `'user ('' is regarded as an
  33394.      identifier `user' followed by a `'('', not as a function call.
  33395.  
  33396. Changes in release 3.20.0
  33397. -------------------------
  33398.  
  33399.    * The source distribution is done with `configure' and Automake.  It
  33400.      will make porting much easier.  The `readline' library is included
  33401.      in the distribution.
  33402.  
  33403.    * Separate client compilation: the client code should be very easy
  33404.      to compile on systems which don't have threads.
  33405.  
  33406.    * The old Perl interface code is automatically compiled and
  33407.      installed.  Automatic compiling of `DBD' will follow when the new
  33408.      `DBD' code is ported.
  33409.  
  33410.    * Dynamic language support: `mysqld' can now be started with Swedish
  33411.      or English (default) error messages.
  33412.  
  33413.    * New functions: `INSERT()', `RTRIM()', `LTRIM()' and `FORMAT()'.
  33414.  
  33415.    * `mysqldump' now works correctly for all field types (even
  33416.      `AUTO_INCREMENT'). The format for `SHOW FIELDS FROM tbl_name' is
  33417.      changed so the `Type' column contains information suitable for
  33418.      `CREATE TABLE'.  In previous releases, some `CREATE TABLE'
  33419.      information had to be patched when recreating tables.
  33420.  
  33421.    * Some parser bugs from 3.19.5 (`BLOB' and `TIMESTAMP') are
  33422.      corrected.  `TIMESTAMP' now returns different date information
  33423.      depending on its create length.
  33424.  
  33425.    * Changed parser to allow a database, table or field name to start
  33426.      with a number or `'_''.
  33427.  
  33428.    * All old C code from Unireg changed to C++ and cleaned up. This
  33429.      makes the daemon a little smaller and easier to understand.
  33430.  
  33431.    * A lot of small bug fixes done.
  33432.  
  33433.    * New `INSTALL' files (not final version) and some info regarding
  33434.      porting.
  33435.  
  33436. Changes in release 3.19.x
  33437. =========================
  33438.  
  33439. Changes in release 3.19.5
  33440. -------------------------
  33441.  
  33442.    * Some new functions, some more optimization on joins.
  33443.  
  33444.    * Should now compile clean on Linux (2.0.x).
  33445.  
  33446.    * Added functions `DATABASE()', `USER()', `POW()', `LOG10()' (needed
  33447.      for ODBC).
  33448.  
  33449.    * In a `WHERE' with an `ORDER BY' on fields from only one table, the
  33450.      table is now preferred as first table in a multi-join.
  33451.  
  33452.    * `HAVING' and `IS NULL' or `IS NOT NULL' now works.
  33453.  
  33454.    * A group on one column and a sort on a group function (`SUM()',
  33455.      `AVG()'...) didn't work together. Fixed.
  33456.  
  33457.    * `mysqldump': Didn't send password to server.
  33458.  
  33459. Changes in release 3.19.4
  33460. -------------------------
  33461.  
  33462.    * Fixed horrible locking bug when inserting in one thread and reading
  33463.      in another thread.
  33464.  
  33465.    * Fixed one-off decimal bug.  1.00 was output as 1.0.
  33466.  
  33467.    * Added attribute `'Locked'' to process list as info if a query is
  33468.      locked by another query.
  33469.  
  33470.    * Fixed full magic timestamp. Timestamp length may now be 14, 12,
  33471.      10, 8, 6, 4 or 2 bytes.
  33472.  
  33473.    * Sort on some numeric functions could sort incorrectly on last
  33474.      number.
  33475.  
  33476.    * `IF(arg,syntax_error,syntax_error)' crashed.
  33477.  
  33478.    * Added functions `CEILING()', `ROUND()', `EXP()', `LOG()' and
  33479.      `SQRT()'.
  33480.  
  33481.    * Enhanced `BETWEEN' to handle strings.
  33482.  
  33483. Changes in release 3.19.3
  33484. -------------------------
  33485.  
  33486.    * Fixed `SELECT' with grouping on `BLOB' columns not to return
  33487.      incorrect `BLOB' info. Grouping, sorting and distinct on `BLOB'
  33488.      columns will not yet work as expected (probably it will group/sort
  33489.      by the first 7 characters in the `BLOB'). Grouping on formulas
  33490.      with a fixed string size (use `MID()' on a `BLOB') should work.
  33491.  
  33492.    * When doing a full join (no direct keys) on multiple tables with
  33493.      `BLOB' fields, the `BLOB' was garbage on output.
  33494.  
  33495.    * Fixed `DISTINCT' with calculated columns.
  33496.  
  33497. Known errors and design deficiencies in MySQL
  33498. *********************************************
  33499.  
  33500. The following is known bugs in *MySQL* 3.23.22 that will be fixed in
  33501. the next release:
  33502.    * Searching on part keys on BDB tables doesn't return all rows:
  33503.  
  33504.           CREATE TABLE t1 (
  33505.             user_id int(10) DEFAULT '0' NOT NULL,
  33506.             name varchar(100),
  33507.             phone varchar(100),
  33508.             ref_email varchar(100) DEFAULT '' NOT NULL,
  33509.             detail varchar(200),
  33510.             PRIMARY KEY (user_id,ref_email)
  33511.           )type=bdb;
  33512.           INSERT INTO t1 VALUES (10292,'sanjeev','29153373','sansh777.hotmail.com','xxx'),(10292,'shirish','2333604','shirish.yahoo.com','ddsds'),(10292,'sonali','323232','sonali.bolly.com','filmstar');
  33513.           select * from t1 where user_id=10292;
  33514.  
  33515. Other known problems:
  33516.  
  33517.    * You cannot build in another directory when using MIT-pthreads.
  33518.      Because this requires changes to MIT-pthreads, we are not likely
  33519.      to fix this.
  33520.  
  33521.    * `BLOB' values can't "reliably" be used in `GROUP BY' or `ORDER BY'
  33522.      or `DISTINCT'. Only the first `max_sort_length' bytes (default
  33523.      1024) are used when comparing `BLOB'bs in these cases.  This can
  33524.      be changed with the `-O max_sort_length' option to `mysqld'. A
  33525.      workaround for most cases is to use a substring: `SELECT DISTINCT
  33526.      LEFT(blob,2048) FROM tbl_name'.
  33527.  
  33528.    * Calculation is done with `BIGINT' or `DOUBLE' (both are normally
  33529.      64 bits long). It depends on the function which precision one
  33530.      gets. The general rule is that bit functions are done with `BIGINT'
  33531.      precision, `IF', and `ELT()' with `BIGINT' or `DOUBLE' precision
  33532.      and the rest with `DOUBLE' precision.  One should try to avoid
  33533.      using bigger unsigned long long values than 63 bits
  33534.      (9223372036854775807) for anything else than bit fields!
  33535.  
  33536.    * All string columns, except `BLOB' and `TEXT' columns, automatically
  33537.      have all trailing spaces removed when retrieved. For `CHAR' types
  33538.      this is okay, and may be regarded as a feature according to ANSI
  33539.      SQL92. The bug is that in *MySQL*, `VARCHAR' columns are treated
  33540.      the same way.
  33541.  
  33542.    * You can only have up to 255 `ENUM' and `SET' columns in one table.
  33543.  
  33544.    * `safe_mysqld' re-directs all messages from `mysqld' to the
  33545.      `mysqld' log.  One problem with this is that if you execute
  33546.      `mysqladmin refresh' to close and reopen the log, `stdout' and
  33547.      `stderr' are still redirected to the old log.  If you use `--log'
  33548.      extensively, you should edit `safe_mysqld' to log to
  33549.      `'hostname'.err' instead of `'hostname'.log' so you can easily
  33550.      reclaim the space for the old log by deleting the old one and
  33551.      executing `mysqladmin refresh'.
  33552.  
  33553.    * In the `UPDATE' statement, columns are updated from left to right.
  33554.      If you refer to a updated column, you will get the updated value
  33555.      instead of the original value. For example:
  33556.           mysql> UPDATE tbl_name SET KEY=KEY+1,KEY=KEY+1
  33557.      will update `KEY' with `2' instead of with `1'.
  33558.  
  33559.    * You can't use temporary tables more than once in the same query.
  33560.  
  33561.           select * from temporary_table, temporary_table as t2;
  33562.  
  33563.    * Because *MySQL* allows you to work with table types that doesn't
  33564.      support transactions (and thus can't `rollback' data) some things
  33565.      behaves a little different in *MySQL* than in other SQL servers:
  33566.      (This is just to ensure that *MySQL* never need to do a rollback
  33567.      for a SQL command).  This may be a little akward at times as column
  33568.      values must be checked in the application, but this will actually
  33569.      give you a nice speed increase as it allows *MySQL* to do some
  33570.      optimizations that otherwice would be very hard to do.
  33571.  
  33572.      If you set a colum to a wrong value, *MySQL* will instead of doing
  33573.      a rollback instead store the `best possible value' in the column.
  33574.  
  33575.         * If you try to store a value outside of the range in a
  33576.           numerical column, *MySQL* will instead store the smallest or
  33577.           biggest possible value in the column.
  33578.  
  33579.         * If you try to store a string, that doesn't start with a
  33580.           number, into a numerical column *MySQL* will store 0 into it.
  33581.  
  33582.         * If you try to to store `NULL' into a column that doesn't take
  33583.           `NULL' values, `MySQL' will store 0 or `''' (empty string) in
  33584.           it instead. (This behavour can however be changed with the
  33585.           -DDONT_USE_DEFAULT_FIELDS compile option).
  33586.  
  33587.         * *MySQL* allows you to store some wrong date values into
  33588.           `DATE' and `DATETIME' columns. (Like 2000-02-31 or
  33589.           2000-02-00).  If the date is totally wrong, *MySQL* will
  33590.           store the special 0000-00-00 date value in the column.
  33591.  
  33592.         * If you set an `enum' to an not supported value, it will be
  33593.           set to the error value 'empty string', with numeric value 0.
  33594.  
  33595.    * If you execute a `PROCEDURE' on a query with returns an empty set
  33596.      then in some cases the `PROCEDURE' will not transform the columns.
  33597.  
  33598. The following is known bugs in earlier versions of *MySQL*:
  33599.  
  33600.    * You can get a hanged thread if you do a `DROP TABLE' on a table
  33601.      that is one among many tables that is locked with `LOCK TABLES'.
  33602.  
  33603.    * In the following case you can get a core dump:
  33604.        1. Delayed insert handler has pending inserts to a table.
  33605.  
  33606.        2. `LOCK table' with `WRITE'
  33607.  
  33608.        3. `FLUSH TABLES'
  33609.  
  33610.    * Before *MySQL* 3.23.2 an `UPDATE' that updated a key with a
  33611.      `WHERE' on the same key may have failed because the key was used to
  33612.      search for records and the same row may have been found multiple
  33613.      times:
  33614.  
  33615.           UPDATE tbl_name SET KEY=KEY+1 WHERE KEY > 100;
  33616.  
  33617.      A workaround is to use:
  33618.  
  33619.           mysql> UPDATE tbl_name SET KEY=KEY+1 WHERE KEY+0 > 100;
  33620.  
  33621.      This will work because *MySQL* will not use index on expressions in
  33622.      the `WHERE' clause.
  33623.  
  33624.    * Before *MySQL* 3.23, all numeric types where treated as fixed-point
  33625.      fields. That means you had to specify how many decimals a
  33626.      floating-point field shall have. All results were returned with
  33627.      the correct number of decimals.
  33628.  
  33629. For platform-specific bugs, see the sections about compiling and
  33630. porting.
  33631.  
  33632. List of things we want to add to MySQL in the future (The TODO)
  33633. ***************************************************************
  33634.  
  33635. Everything in this list is in the order it will be done.  If you want to
  33636. affect the priority order, please register a license or support us and
  33637. tell us what you want to have done more quickly. *Note Licensing and
  33638. Support::.
  33639.  
  33640. Things that must done in the real near future
  33641. =============================================
  33642.  
  33643.    * Fail safe replication.
  33644.  
  33645.    * Optimize, test and document transactions safe tables
  33646.  
  33647.    * Subqueries. `select id from t where grp in (select grp from g
  33648.      where u > 100)'
  33649.  
  33650.    * Port of *MySQL* to BeOS.
  33651.  
  33652.    * Add a temporary key buffer cache during `insert/delete/update' so
  33653.      that we can gracefully recover if the index file gets full.
  33654.  
  33655.    * If you perform an `ALTER TABLE' on a table that is symlinked to
  33656.      another disk, create temporary tables on this disk.
  33657.  
  33658.    * `RENAME table as table, table as table [,...]'
  33659.  
  33660.    * Allow users to change startup options.
  33661.  
  33662.    * FreeBSD and MIT-pthreads;  Do sleeping threads take CPU?
  33663.  
  33664.    * Check if locked threads take any CPU.
  33665.  
  33666.    * Change to use mkstemp() instead of tempnam() for system that
  33667.      supports the call.  We need to add a my_mkstemp() function in
  33668.      mysys and also change the cache code to not create the filename
  33669.      until we do the actual open.
  33670.  
  33671.    * Allow join on key parts (optimization issue).
  33672.  
  33673.    * Entry for `DECRYPT()'.
  33674.  
  33675.    * `INSERT SQL_CONCURRENT' and `mysqld --concurrent-insert' to do a
  33676.      concurrent insert at the end of the file if the file is
  33677.      read-locked.
  33678.  
  33679.    * Remember `FOREIGN' key definitions in the `.frm' file.
  33680.  
  33681.    * Server side cursors.
  33682.  
  33683.    * Check if `lockd' works with modern Linux kernels; If not, we have
  33684.      to fix `lockd'!  To test this, start `mysqld' with
  33685.      `--enable-locking' and run the different fork* test suits. They
  33686.      shouldn't give any errors if `lockd' works.
  33687.  
  33688.    * Allow SQL variables in `LIMIT', like in `LIMIT @a,@b'.
  33689.  
  33690.    * Don't add automatic `DEFAULT' values to columns.  Give an error
  33691.      when using an `INSERT' that doesn't contain a column that doesn't
  33692.      have a `DEFAULT'.
  33693.  
  33694.    * Caching of queries and results. This should be done as a separated
  33695.      module that examines each query and if this is query is in the
  33696.      cache the cached result should be returned.  When one updates a
  33697.      table one should remove as few queries as possible from the cache.
  33698.      This should give a big speed bost on machines with much RAM where
  33699.      queries are often repeated (like WWW applications).  One idea
  33700.      would be to only cache queries of type: `SELECT CACHED ....'
  33701.  
  33702.    * Fix `libmysql.c' to allow two `mysql_query()' commands in a row
  33703.      without reading results or give a nice error message when one does
  33704.      this.
  33705.  
  33706.    * Optimize `BIT' type to take 1 bit (now `BIT' takes 1 char).
  33707.  
  33708.    * Check why MIT-pthreads `ctime()' doesn't work on some FreeBSD
  33709.      systems.
  33710.  
  33711.    * Add `ORDER BY' to update. This would be handy with functions like:
  33712.      `generate_id(start,step)'.
  33713.  
  33714.    * Add an `IMAGE' option to `LOAD DATA INFILE' to not update
  33715.      `TIMESTAMP' and `AUTO_INCREMENT' fields.
  33716.  
  33717.    * Make `LOAD DATA INFILE' understand a syntax like:
  33718.           LOAD DATA INFILE 'file_name.txt' INTO TABLE tbl_name
  33719.           TEXT_FIELDS (text_field1, text_field2, text_field3)
  33720.           SET table_field1=concatenate(text_field1, text_field2), table_field3=23
  33721.           IGNORE text_field3
  33722.  
  33723.    * `LOAD DATA INFILE 'file_name' INTO TABLE 'table_name' ERRORS TO
  33724.      err_table_name' which would cause any errors/warnings to be logged
  33725.      into the err_table_name table. That table would have a structure
  33726.      like:
  33727.  
  33728.           line_number    - line number in data file
  33729.           error_message  - the error/warning message
  33730.           and maybe
  33731.           data_line      - the line from the data file
  33732.  
  33733.    * We should extend `LOAD DATA INFILE' so that we can skip over extra
  33734.      columns in the text file.
  33735.  
  33736.    * Add true `VARCHAR' support (There is already support for this in
  33737.      MyISAM).
  33738.  
  33739.    * Automatic output from `mysql' to netscape.
  33740.  
  33741.    * `LOCK DATABASES'. (with various options)
  33742.  
  33743.    * Change sort to allocate memory in "hunks" to get better memory
  33744.      utilization.
  33745.  
  33746.    * `DECIMAL' and `NUMERIC' types can't read exponential numbers;
  33747.      `Field_decimal::store(const char *from,uint len)' must be recoded
  33748.      to fix this.
  33749.  
  33750.    * Fix `mysql.cc' to do fewer `malloc()' calls when hashing field
  33751.      names.
  33752.  
  33753.    * Functions: ADD_TO_SET(value,set) and REMOVE_FROM_SET(value,set)
  33754.  
  33755.    * Add use of `t1 JOIN t2 ON ...' and `t1 JOIN t2 USING ...'
  33756.      Currently, you can only use this syntax with `LEFT JOIN'.
  33757.  
  33758.    * Add full support for `unsigned long long' type.
  33759.  
  33760.    * Function `CASE'.
  33761.  
  33762.    * Many more variables for `show status'.  Counts for:
  33763.      `INSERT'/`DELETE'/`UPDATE' statements. Records reads and updated.
  33764.      Selects on 1 table and selects with joins.  Mean number of tables
  33765.      in select. Key buffer read/write hits (logical and real).  `ORDER
  33766.      BY', `GROUP BY', temporary tables created.
  33767.  
  33768.    * If you abort `mysql' in the middle of a query, you should open
  33769.      another connection and kill the old running query.  Alternatively,
  33770.      an attempt should be made to detect this in the server.
  33771.  
  33772.    * Add a handler interface for table information so you can use it as
  33773.      a system table. This would be a bit slow if you requested
  33774.      information about all tables, but very flexible.  `SHOW INFO FROM
  33775.      tbl_name' for basic table information should be implemented.
  33776.  
  33777.    * Add support for UNICODE.
  33778.  
  33779.    * `NATURAL JOIN'.
  33780.  
  33781.    * Oracle like `CONNECT BY PRIOR ...' to search hierarchy structures.
  33782.  
  33783.    * `RENAME DATABASE'
  33784.  
  33785.    * `mysqladmin copy database new-database'.
  33786.  
  33787.    * Processlist should show number of queries/thread.
  33788.  
  33789.    * `DELETE' and `REPLACE' options to the `UPDATE' statement (this
  33790.      will delete rows when one gets a dupplicate key error while
  33791.      updating).
  33792.  
  33793.    * Change the format of `DATETIME' to store fractions of seconds.
  33794.  
  33795.    * Add all missing ANSI92 and ODBC 3.0 types.
  33796.  
  33797.    * Change table names from empty strings to `NULL' for calculated
  33798.      columns.
  33799.  
  33800.    * Don't use 'Item_copy_string' on numerical values to avoid
  33801.      number->string->number conversion in case of: `SELECT
  33802.      COUNT(*)*(id+0) FROM table_name GROUP BY id'
  33803.  
  33804.    * Make it possible to use the new GNU regexp library instead of the
  33805.      current one (The GNU library should be much faster than the old
  33806.      one).
  33807.  
  33808.    * Change that `ALTER TABLE' doesn't abort clients that executes
  33809.      `INSERT DELAYED'.
  33810.  
  33811.    * Allow `select a from crash_me left join crash_me2 using (a)'; In
  33812.      this case a is assumed to come from the crash_me table.
  33813.  
  33814.    * Fix that when columns referenced in an `UPDATE' clause contains
  33815.      the old values before the update started.
  33816.  
  33817.    * Allow update of varibles in `UPDATE' statements. For example:
  33818.      `UPDATE TABLE foo SET @a=a+b,a=@a, b=@a+c'
  33819.  
  33820.    * `myisamchk', `REPAIR' and `OPTIMIZE TABLE' should be able to
  33821.      handle cases where the data and/or index files are symbolic links.
  33822.  
  33823.    * Add simulation of `pread()'/`pwrite()' on windows to enable
  33824.      concurrent inserts.
  33825.  
  33826.    * A logfile analyzer that could parsed out information about which
  33827.      tables are hit most often, how often multi-table joins are
  33828.      executed, etc.  It should help users identify areas or table
  33829.      design that could be optimized to execute much more efficient
  33830.      queries.
  33831.  
  33832. Things that have to be done sometime
  33833. ====================================
  33834.  
  33835.    * Implement function: `get_changed_tables(timeout,table1,table2,...)'
  33836.  
  33837.    * Atomic updates; This includes a language that one can even use for
  33838.      a set of stored procedures.
  33839.  
  33840.    * `update items,month set items.price=month.price where
  33841.      items.id=month.id;'
  33842.  
  33843.    * Change reading through tables to use memmap when possible. Now only
  33844.      compressed tables use memmap.
  33845.  
  33846.    * Add a new privilege *'Show_priv'* for `SHOW' commands.
  33847.  
  33848.    * Make the automatic timestamp code nicer.  Add timestamps to the
  33849.      update log with `SET TIMESTAMP=#;'
  33850.  
  33851.    * Use read/write mutex in some places to get more speed.
  33852.  
  33853.    * Full foreign key support. One probably wants to implement a
  33854.      procedural language first.
  33855.  
  33856.    * Simple views (first on one table, later on any expression).
  33857.  
  33858.    * Automatically close some tables if a table, temporary table or
  33859.      temporary files gets error 23 (not enough open files).
  33860.  
  33861.    * When one finds a field=#, change all occurrences of field to #.
  33862.      Now this is only done for some simple cases.
  33863.  
  33864.    * Change all const expressions with calculated expressions if
  33865.      possible.
  33866.  
  33867.    * Optimize key = expression. At the moment only key = field or key =
  33868.      constant are optimized.
  33869.  
  33870.    * Join some of the copy functions for nicer code.
  33871.  
  33872.    * Change `sql_yacc.yy' to an inline parser to reduce its size and get
  33873.      better error messages (5 days).
  33874.  
  33875.    * Change the parser to use only one rule per different number of
  33876.      arguments in function.
  33877.  
  33878.    * Use of full calculation names in the order part. (For ACCESS97)
  33879.  
  33880.    * `UNION', `MINUS', `INTERSECT' and `FULL OUTER JOIN'.  (Currently
  33881.      only `LEFT OUTER JOIN' is supported)
  33882.  
  33883.    * Allow `UNIQUE' on fields that can be `NULL'.
  33884.  
  33885.    * `SQL_OPTION MAX_SELECT_TIME=#' to put a time limit on a query.
  33886.  
  33887.    * Make the update log to a database.
  33888.  
  33889.    * Negative `LIMIT' to retrieve data from the end.
  33890.  
  33891.    * Alarm around client connect/read/write functions.
  33892.  
  33893.    * Make a `mysqld' version which isn't multithreaded (3-5 days).
  33894.  
  33895.    * Please note the changes to `safe_mysqld': according to FSSTND
  33896.      (which Debian tries to follow) PID files should go into
  33897.      `/var/run/<progname>.pid' and log files into `/var/log'. It would
  33898.      be nice if you could put the "DATADIR" in the first declaration of
  33899.      "pidfile" and "log", so the placement of these files can be
  33900.      changed with a single statement.
  33901.  
  33902.    * Better dynamic record layout to avoid fragmentation.
  33903.  
  33904.    * `UPDATE SET blob=read_blob_from_file('my_gif') where id=1;'
  33905.  
  33906.    * Allow a client to request logging.
  33907.  
  33908.    * Add use of `zlib()' for `gzip'-ed files to `LOAD DATA INFILE'.
  33909.  
  33910.    * Fix sorting and grouping of `BLOB' columns (partly solved now).
  33911.  
  33912.    * Stored procedures.  This is currently not regarded to be very
  33913.      important as stored procedures are not very standardized yet.
  33914.      Another problem is that true stored procedures make it much harder
  33915.      for the optimizer and in many cases the result is slower than
  33916.      before We will, on the other hand, add a simple (atomic) update
  33917.      language that can be used to write loops and such in the *MySQL*
  33918.      server.
  33919.  
  33920.    * Change to use semaphores when counting threads.  One should first
  33921.      implement a semaphore library to MIT-pthreads.
  33922.  
  33923.    * Don't assign a new `AUTO_INCREMENT' value when one sets a column
  33924.      to 0.  Use `NULL' instead.
  33925.  
  33926.    * Add full support for `JOIN' with parentheses.
  33927.  
  33928.    * Reuse threads for systems with a lot of connections.
  33929.  
  33930.    * As an alternative for one thread / connection manage a pool of
  33931.      threads to handle the queries.
  33932.  
  33933.    * Allow one to get more than one lock with `GET_LOCK'.  When doing
  33934.      this, one must also handle the possible deadlocks this change will
  33935.      introduce.
  33936.  
  33937. Time is given according to amount of work, not real time.
  33938.  
  33939. Some things we don't have any plans to do
  33940. =========================================
  33941.  
  33942.    * Nothing;  In the long run we plan to be fully ANSI 92 / ANSI 99
  33943.      compliant.
  33944.  
  33945. Comments on porting to other systems
  33946. ************************************
  33947.  
  33948. A working Posix thread library is needed for the server. On Solaris 2.5
  33949. we use Sun PThreads (the native thread support in 2.4 and earlier
  33950. versions are not good enough) and on Linux we use LinuxThreads by Xavier
  33951. Leroy, <Xavier.Leroy@inria.fr>.
  33952.  
  33953. The hard part of porting to a new Unix variant without good native
  33954. thread support is probably to port MIT-pthreads. See
  33955. `mit-pthreads/README' and Programming POSIX Threads
  33956. (http://www.humanfactor.com/pthreads/).
  33957.  
  33958. The *MySQL* distribution includes a patched version of Provenzano's
  33959. Pthreads from MIT (see MIT Pthreads web page
  33960. (http://www.mit.edu:8001/people/proven/pthreads.html)). This can be
  33961. used for some operating systems that do not have POSIX threads.
  33962.  
  33963. It is also possible to use another user level thread package named FSU
  33964. Pthreads (see FSU Pthreads home page
  33965. (http://www.informatik.hu-berlin.de/~mueller/pthreads.html)). This
  33966. implementation is being used for the SCO port.
  33967.  
  33968. See the `thr_lock.c' and `thr_alarm.c' programs in the `mysys'
  33969. directory for some tests/examples of these problems.
  33970.  
  33971. Both the server and the client need a working C++ compiler (we use `gcc'
  33972. and have tried SparcWorks). Another compiler that is known to work is
  33973. the Irix `cc'.
  33974.  
  33975. To compile only the client use `./configure --without-server'.
  33976.  
  33977. There is currently no support for only compiling the server, nor is it
  33978. likly to be added unless someone has a good reason for it.
  33979.  
  33980. If you want/need to change any `Makefile' or the configure script you
  33981. must get Automake and Autoconf. We have used the `automake-1.2' and
  33982. `autoconf-2.12' distributions.
  33983.  
  33984. All steps needed to remake everything from the most basic files.
  33985.  
  33986.      /bin/rm */.deps/*.P
  33987.      /bin/rm -f config.cache
  33988.      aclocal
  33989.      autoheader
  33990.      aclocal
  33991.      automake
  33992.      autoconf
  33993.      ./configure --with-debug --prefix='your installation directory'
  33994.      
  33995.      # The makefiles generated above need GNU make 3.75 or newer.
  33996.      # (called gmake below)
  33997.      gmake clean all install init-db
  33998.  
  33999. If you run into problems with a new port, you may have to do some
  34000. debugging of *MySQL*!  *Note Debugging server::.
  34001.  
  34002. *Note:* Before you start debugging `mysqld', first get the test
  34003. programs `mysys/thr_alarm' and `mysys/thr_lock' to work.  This will
  34004. ensure that your thread installation has even a remote chance to work!
  34005.  
  34006. Debugging a MySQL server
  34007. ========================
  34008.  
  34009. If you are using some functionality that is very new in *MySQL*, you
  34010. can try to run mysqld with the `--skip-new' (which will disable all
  34011. new, potentially unsafe functionality) or with `--safe-mode' which
  34012. disables a lot of optimization that may cause problems.  *Note
  34013. Crashing::.
  34014.  
  34015. If `mysqld' doesn't want to start, you should check that you don't have
  34016. any `my.cnf' files that interfere with your setup!  You can check your
  34017. `my.cnf' arguments with `mysqld --print-defaults' and avoid using them
  34018. by starting with `mysqld --no-defaults ...'.
  34019.  
  34020. If you have some very specific problem, you can always try to debug
  34021. *MySQL*.  To do this you must configure *MySQL* with the option
  34022. `--with-debug'.  You can check whether or not *MySQL* was compiled with
  34023. debugging by doing: `mysqld --help'.  If the `--debug' flag is listed
  34024. with the options then you have debugging enabled.  `mysqladmin ver'
  34025. also lists the `mysqld' version as `mysql ... -debug' in this case.
  34026.  
  34027. If you are using gcc or egcs, the recommended configure line is:
  34028.  
  34029.      CC=gcc CFLAGS="-O6" CXX=gcc CXXFLAGS="-O6 -felide-constructors -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local/mysql --with-debug --with-extra-charsets=complex
  34030.  
  34031. This will avoid problems with the `libstdc++' library and with C++
  34032. exceptions (many compilers have problems with C++ exceptions in threaded
  34033. code) and compile a *MySQL* version with support for all character sets.
  34034.  
  34035. If `mysqld' stops crashing when you compile it with `--with-debug', you
  34036. have probably found a compiler bug or a timing bug within *MySQL*.  In
  34037. this case you can try to add `-g' to the `CFLAGS' and `CXXFLAGS'
  34038. variables above and not use `--with-debug'. If `mysqld' now dies, you
  34039. can at least attach to it with `gdb' or use `gdb' on the core file to
  34040. find out what happened.
  34041.  
  34042. If you can cause the `mysqld' server to crash quickly, you can try to
  34043. create a trace file of this:
  34044.  
  34045. Start the `mysqld' server with a trace log in `/tmp/mysql.trace'.  The
  34046. log file will get very _BIG_.
  34047.  
  34048. `mysqld --debug --log'
  34049.  
  34050. or you can start it with
  34051.  
  34052. `mysqld --debug=d,info,error,query,general,where:O,/tmp/mysql.trace'
  34053.  
  34054. which only prints information with the most interesting tags.
  34055.  
  34056. When you configure *MySQL* for debugging you automatically enable a lot
  34057. of extra safety check functions that monitor the health of `mysqld'.
  34058. If they find something "unexpected," an entry will be written to
  34059. `stderr', which `safe_mysqld' directs to the error log!  This also
  34060. means that if you are having some unexpected problems with *MySQL* and
  34061. are using a source distribution, the first thing you should do is to
  34062. configure *MySQL* for debugging!  (The second thing, of course, is to
  34063. send mail to <mysql@lists.mysql.com> and ask for help.  Please use the
  34064. `mysqlbug' script for all bug reports or questions regarding the
  34065. *MySQL* version you are using!
  34066.  
  34067. On most system you can also start `mysqld' from `gdb' to get more
  34068. information if `mysqld' crashes.
  34069.  
  34070. With some older `gdb' versions on Linux you must use `run --one-thread'
  34071. if you want to be able to debug `mysqld' threads.  In this case you can
  34072. only have one thread active at a time.
  34073.  
  34074. It's very hard to debug *MySQL* under `gdb' if you do a lot of new
  34075. connections the whole time as `gdb' doesn't free the memory for old
  34076. threads.  You can avoid this problem by starting `mysqld' with `-O
  34077. thread_cache_size= 'max_connections +1''.  In most cases just using `-O
  34078. thread_cache_size= 5'' will help a lot!
  34079.  
  34080. If you are using gdb 4.17.x or above on Linux, you should install a
  34081. `.gdb' file, with the following information, in your current directory:
  34082.  
  34083.      set print sevenbit off
  34084.      handle SIGUSR1 nostop noprint
  34085.      handle SIGUSR2 nostop noprint
  34086.      handle SIGWAITING nostop noprint
  34087.      handle SIGLWP nostop noprint
  34088.      handle SIGPIPE nostop
  34089.      handle SIGALRM nostop
  34090.      handle SIGHUP nostop
  34091.      handle SIGTERM nostop noprint
  34092.  
  34093. If you have problems debugging threads with gdb, you should download
  34094. gdb 5.x and try this instead. The new gdb version has very improved
  34095. thread handling!
  34096.  
  34097. Here follows an example how to debug mysqld:
  34098.  
  34099.      shell> gdb /usr/local/libexec/mysqld
  34100.      gdb> run
  34101.      ...
  34102.      back   # Do this when mysqld crashes
  34103.      info locals
  34104.      up
  34105.      info locals
  34106.      up
  34107.      ...
  34108.      (until you get some information about local variables)
  34109.      
  34110.      quit
  34111.  
  34112. Include the above output in a mail generated with `mysqlbug' and mail
  34113. this to `mysql@lists.mysql.com'.
  34114.  
  34115. If `mysqld' hangs you can try to use some system tools like `strace' or
  34116. `/usr/proc/bin/pstack' to examine where `mysqld' has hung.
  34117.  
  34118. If `mysqld' starts to eat up CPU or memory or if it "hangs", you can
  34119. use `mysqladmin processlist status' to find out if someone is executing
  34120. a query that takes a long time.  It may be a good idea to run
  34121. `mysqladmin -i10 processlist status' in some window if you are
  34122. experiencing performance problems or problems when new clients can't
  34123. connect.
  34124.  
  34125. If `mysqld' dies or hangs, you should start `mysqld' with `--log'.
  34126. When `mysqld' dies again, you can check in the log file for the query
  34127. that killed `mysqld'.  Note that before starting `mysqld' with `--log'
  34128. you should check all your tables with `myisamchk'.  *Note Maintenance::.
  34129.  
  34130. If you are using a log file, `mysqld --log', you should check the
  34131. 'hostname' log files, that you can find in the database directory, for
  34132. any queries that could cause a problem. Try the command `EXPLAIN' on
  34133. all `SELECT' statements that takes a long time to ensure that mysqld
  34134. are using indexes properly. *Note `EXPLAIN': EXPLAIN. You should also
  34135. test complicated queries that didn't complete within the `mysql'
  34136. command line tool.
  34137.  
  34138. If you find the text `mysqld restarted' in the error log file (normally
  34139. named `hostname.err') you have probably found a query that causes
  34140. `mysqld' to fail.  If this happens you should check all your tables with
  34141. `myisamchk' (*note Maintenance::), and test the queries in the *MySQL*
  34142. log files to see if one doesn't work.  If you find such a query, try
  34143. first upgrading to the newest *MySQL* version.  If this doesn't help
  34144. and you can't find anything in the `mysql' mail archive, you should
  34145. report the bug to <mysql@lists.mysql.com>.  Links to mail archives are
  34146. available online at the *MySQL* documentation page
  34147. (http://www.mysql.com/documentation/).
  34148.  
  34149. If you get corrupted tables or if `mysqld' always fails after some
  34150. update commands, you can test if this bug is reproducible by doing the
  34151. following:
  34152.  
  34153.    * Stop the mysqld daemon (with `mysqladmin shutdown')
  34154.  
  34155.    * Check all tables with `myisamchk -s database/*.MYI'.  Repair any
  34156.      wrong tables with `myisamchk -r database/table.MYI'.
  34157.  
  34158.    * Start `mysqld' with `--log-update'. *Note Update log::.
  34159.  
  34160.    * When you have gotten a crashed table, stop the `mysqld server'.
  34161.  
  34162.    * Restore the backup.
  34163.  
  34164.    * Restart the `mysqld' server *without* `--log-update'
  34165.  
  34166.    * Re-execute the commands with `mysql < update-log'.  The update log
  34167.      is saved in the *MySQL* database directory with the name
  34168.      `your-hostname.#'.
  34169.  
  34170.    * If the tables are corrupted again, you have found reproducible bug
  34171.      in the `ISAM' code!  FTP the tables and the update log to
  34172.      `ftp://support.mysql.com/pub/mysql/secret' and we will fix this as
  34173.      soon as possible!
  34174.  
  34175. The command `mysqladmin debug' will dump some information about locks
  34176. in use, used memory and query usage to the mysql log file. This may
  34177. help solve some problems.  This command also provides some useful
  34178. information even if you haven't compiled *MySQL* for debugging!
  34179.  
  34180. If the problem is that some tables are getting slower and slower you
  34181. should try to optimize the table with `OPTIMIZE TABLE' or `myisamchk'.
  34182. *Note Maintenance::. You should also check the slow queries with
  34183. `EXPLAIN'.
  34184.  
  34185. You should also read the OS-specific section in this manual for
  34186. problems that may be unique to your environment.  *Note Source install
  34187. system issues::.
  34188.  
  34189. If you are using the Perl `DBI' interface, you can turn on debugging
  34190. information by using the `trace' method or by setting the `DBI_TRACE'
  34191. environment variable.  *Note Perl `DBI' Class: Perl DBI Class.
  34192.  
  34193. Debugging a MySQL client
  34194. ========================
  34195.  
  34196. To be able to debug a *MySQL* client with the integrated debug package,
  34197. you should configure *MySQL* with `--with-debug'.  *Note configure
  34198. options::.
  34199.  
  34200. Before running a client, you should set the `MYSQL_DEBUG' environment
  34201. variable:
  34202.  
  34203.      shell> MYSQL_DEBUG=d:t:O,/tmp/client.trace
  34204.      shell> export MYSQL_DEBUG
  34205.  
  34206. This causes clients to generate a trace file in `/tmp/client.trace'.
  34207.  
  34208. If you have problems with your own client code, you should attempt to
  34209. connect to the server and run your query using a client that is known to
  34210. work.  Do this by running `mysql' in debugging mode (assuming you have
  34211. compiled *MySQL* with debugging on):
  34212.  
  34213.      shell> mysql --debug=d:t:O,/tmp/client.trace
  34214.  
  34215. This will provide useful information in case you mail a bug report.
  34216. *Note Bug reports::.
  34217.  
  34218. If your client crashes at some 'legal' looking code, you should check
  34219. that your `mysql.h' include file matches your mysql library file.  A
  34220. very common mistake is to use an old `mysql.h' file from an old *MySQL*
  34221. installation with new *MySQL* library.
  34222.  
  34223. The DBUG package.
  34224. =================
  34225.  
  34226. The *MySQL* server and most *MySQL* clients are compiled with the DBUG
  34227. package originally made by Fred Fish.  When one has configured *MySQL*
  34228. for debugging, this package makes it possible to get a trace file of
  34229. what the program is debugging.
  34230.  
  34231. One uses the debug package by invoking the program with the
  34232. `--debug="..."' or the `-#...' option.
  34233.  
  34234. The debug control string is a sequence of colon separated fields as
  34235. follows:
  34236.  
  34237.      <field_1>:<field_2>:...:<field_N>
  34238.  
  34239. Each field consists of a mandatory flag character followed by an
  34240. optional "," and comma separated list of modifiers:
  34241.  
  34242.      flag[,modifier,modifier,...,modifier]
  34243.  
  34244. The currently recognized flag characters are:
  34245.  
  34246. d       Enable output from DBUG_<N> macros for for the current state.
  34247.         May be followed by a list of keywords which selects output only
  34248.         for the DBUG macros with that keyword. A empty list of keywords
  34249.         implies output for all macros.
  34250. D       Delay after each debugger output line. The argument is the
  34251.         number of tenths of seconds to delay, subject to machine
  34252.         capabilities. I.E.  `-#D,20' is delay two seconds.
  34253. f    tab   
  34254. Limit   
  34255. debugging
  34256. and/or  
  34257. tracing,
  34258. and     
  34259. profiling
  34260. to the  
  34261. list    
  34262. of      
  34263. named   
  34264. functions.
  34265. Note    
  34266. that a  
  34267. null    
  34268. list    
  34269. will    
  34270. disable 
  34271. all     
  34272. functions.    The
  34273. appropriate
  34274. "d" or  
  34275. "t"     
  34276. flags   
  34277. must    
  34278. still   
  34279. be      
  34280. given,  
  34281. this    
  34282. flag    
  34283. only    
  34284. limits  
  34285. their   
  34286. actions 
  34287. if      
  34288. they    
  34289. are     
  34290. enabled.
  34291. F       Identify the source file name for each line of debug or trace
  34292.         output.
  34293. i       Identify the process with the pid or thread id for each line of
  34294.         debug or trace output.
  34295. g       Enable profiling.  Create a file called 'dbugmon.out' containing
  34296.         information that can be used to profile the program.  May be
  34297.         followed by a list of keywords that select profiling only for
  34298.         the functions in that list.  A null list implies that all
  34299.         functions are considered.
  34300. L       Identify the source file line number for each line of debug or
  34301.         trace output.
  34302. n       Print the current function nesting depth for each line of debug
  34303.         or trace output.
  34304. N       Number each line of dbug output.
  34305. o       Redirect the debugger output stream to the specified file.  The
  34306.         default output is stderr.
  34307. O       As `O' but the file is really flushed between each write. When
  34308.         neaded the file is closed and reopened between each write.
  34309. p       Limit debugger actions to specified processes. A process must be
  34310.         identified with the DBUG_PROCESS macro and match one in the list
  34311.         for debugger actions to occur.
  34312. P       Print the current process name for each line of debug or trace
  34313.         output.
  34314. r       When pushing a new state, do not inherit the previous state's
  34315.         function nesting level. Useful when the output is to start at
  34316.         the left margin.
  34317. S       Do function _sanity(_file_,_line_) at each debugged function
  34318.         until _sanity() returns something that differs from 0. (Mostly
  34319.         used with safemalloc to find memory leaks)
  34320. t       Enable function call/exit trace lines. May be followed by a list
  34321.         (containing only one modifier) giving a numeric maximum trace
  34322.         level, beyond which no output will occur for either debugging or
  34323.         tracing macros.  The default is a compile time option.
  34324.  
  34325. Some examples of debug control strings which might appear on a shell
  34326. command line (the "-#" is typically used to introduce a control string
  34327. to an application program) are:
  34328.  
  34329.      -#d:t
  34330.      -#d:f,main,subr1:F:L:t,20
  34331.      -#d,input,output,files:n
  34332.      -#d:t:i:O,\\mysqld.trace
  34333.  
  34334. In *MySQL*, common tags to print (with the `d' option) are:
  34335. `enter',`exit',`error',`warning',`info' and `loop'.
  34336.  
  34337. Locking methods
  34338. ===============
  34339.  
  34340. Currently MySQL only supports table locking for `ISAM'/`MyISAM' and
  34341. `HEAP' tables and page level locking for `BDB' tables. *Note Internal
  34342. locking::.  With `MyISAM' tables one can freely mix `INSERT' and
  34343. `SELECT' without locks (`Versioning').
  34344.  
  34345. Some database users claim that *MySQL* cannot support near the number
  34346. of concurrent users because it lacks row-level locking.  This is a may
  34347. be true for some specific applications, but is' not generally true. As
  34348. always this depends totally on what the application does and what is
  34349. the access/update pattern of the data.
  34350.  
  34351. Pros for row locking:
  34352.  
  34353.    * Fewer lock conflicts when accessing different rows in many threads.
  34354.  
  34355.    * Less changes for rollbacks.
  34356.  
  34357.    * Makes it possbile to lock a single row a long time.
  34358.  
  34359. Cons:
  34360.  
  34361.    * Takes more memory than page level or table locks.
  34362.  
  34363.    * Is slower than page level or table locks when used one a big part
  34364.      of the table, because one has to do many more locks.
  34365.  
  34366.    * Is definitely much worse than other locks if you do often do `GROUP
  34367.      BY' on a large part of the data or if one has to often scan the
  34368.      whole table.
  34369.  
  34370.    * With higher level locks one can also more easily support locks of
  34371.      different types to tune the application as the lock overhead is
  34372.      less notable as for row level locks.
  34373.  
  34374. Table locks are superior to page level / row level locks in the
  34375. following cases:
  34376.  
  34377.    * Mostly reads
  34378.  
  34379.    * Read and updates on strict keys; This is where one updates or
  34380.      deletes a row that can be fetched with one key read:
  34381.           UPDATE table_name SET column=value WHERE unique_key#
  34382.           DELETE FROM table_name WHERE unique_key=#
  34383.  
  34384.    * `SELECT' combined with `INSERT' (and very few `UPDATE''s and
  34385.      `DELETE''s.
  34386.  
  34387.    * Many scans / `GROUP BY' on the whole table without any writers.
  34388.  
  34389. Other options than row / page level locking:
  34390.  
  34391. Versioning (like we use in MySQL for concurrent inserts) where you can
  34392. have one writer at the same time as many readers.  This means that the
  34393. database/table supports different views for the data depending on when
  34394. one started to access it. Other names for this are time travel, copy on
  34395. write or copy on demand.
  34396.  
  34397. Copy on demand is in many case much better than page or row level
  34398. locking; The worst case does however use much more memory than when
  34399. using normal locks.
  34400.  
  34401. Instead of using row level locks one can use application level locks.
  34402. (Like get_lock/release_lock in *MySQL*).  This works of course only in
  34403. well-behaved applications.
  34404.  
  34405. In many cases one can do an educated guess which locking type is best
  34406. for the application but generally it's very hard to say that a given
  34407. lock type is better than another; Everything depends on the application
  34408. and different part of the application may require different lock types.
  34409.  
  34410. Here follows some tips about locking in *MySQL*:
  34411.  
  34412. On web application most applications do lots of selects, very few
  34413. deletes, updates mainly on keys and inserts in some specific tables.
  34414. The base *MySQL* setup is VERY tuned for this.
  34415.  
  34416. Concurrent users is not a problem if one doesn't mix updates and selects
  34417. that needs to examine many rows in the same table.
  34418.  
  34419. If one mix a insert and deletes on the same table then `INSERT DELAY'
  34420. may be of great help.
  34421.  
  34422. One can also use `LOCK TABLES' to speed up things (many updates within
  34423. a single lock is much faster than updates without locks).  Splitting
  34424. thing to different tables will also helps.
  34425.  
  34426. If you get speed problems with the table locks in *MySQL*, you may be
  34427. able to solve these to convert some of your tables to `BDB' tables.
  34428. *Note BDB::.
  34429.  
  34430. The optimization section in the manual covers a lot of different
  34431. aspects of how to tune ones application. *Note Tips::.
  34432.  
  34433. Comments about RTS threads
  34434. ==========================
  34435.  
  34436. I have tried to use the RTS thread packages with *MySQL* but stumbled
  34437. on the following problems:
  34438.  
  34439. They use an old version of a lot of POSIX calls and it is very tedious
  34440. to make wrappers for all functions. I am inclined to think that it would
  34441. be easier to change the thread libraries to the newest POSIX
  34442. specification.
  34443.  
  34444. Some wrappers are already written. See `mysys/my_pthread.c' for more
  34445. info.
  34446.  
  34447. At least the following should be changed:
  34448.  
  34449. `pthread_get_specific' should use one argument.  `sigwait' should take
  34450. two arguments.  A lot of functions (at least `pthread_cond_wait',
  34451. `pthread_cond_timedwait') should return the error code on error. Now
  34452. they return -1 and set `errno'.
  34453.  
  34454. Another problem is that user-level threads use the `ALRM' signal and
  34455. this aborts a lot of functions (`read', `write', `open'...).  *MySQL*
  34456. should do a retry on interrupt on all of these but it is not that easy
  34457. to verify it.
  34458.  
  34459. The biggest unsolved problem is the following:
  34460.  
  34461. To get thread-level alarms I changed `mysys/thr_alarm.c' to wait between
  34462. alarms with `pthread_cond_timedwait()', but this aborts with error
  34463. `EINTR'.  I tried to debug the thread library as to why this happens,
  34464. but couldn't find any easy solution.
  34465.  
  34466. If someone wants to try *MySQL* with RTS threads I suggest the
  34467. following:
  34468.  
  34469.    * Change functions *MySQL* uses from the thread library to POSIX.
  34470.      This shouldn't take that long.
  34471.  
  34472.    * Compile all libraries with the `-DHAVE_rts_threads'.
  34473.  
  34474.    * Compile `thr_alarm'.
  34475.  
  34476.    * If there are some small differences in the implementation, they
  34477.      may be fixed by changing `my_pthread.h' and `my_pthread.c'.
  34478.  
  34479.    * Run `thr_alarm'. If it runs without any "warning", "error" or
  34480.      aborted messages, you are on the right track. Here follows a
  34481.      successful run on Solaris:
  34482.           Main thread: 1
  34483.           Tread 0 (5) started
  34484.           Thread: 5  Waiting
  34485.           process_alarm
  34486.           Tread 1 (6) started
  34487.           Thread: 6  Waiting
  34488.           process_alarm
  34489.           process_alarm
  34490.           thread_alarm
  34491.           Thread: 6  Slept for 1 (1) sec
  34492.           Thread: 6  Waiting
  34493.           process_alarm
  34494.           process_alarm
  34495.           thread_alarm
  34496.           Thread: 6  Slept for 2 (2) sec
  34497.           Thread: 6  Simulation of no alarm needed
  34498.           Thread: 6  Slept for 0 (3) sec
  34499.           Thread: 6  Waiting
  34500.           process_alarm
  34501.           process_alarm
  34502.           thread_alarm
  34503.           Thread: 6  Slept for 4 (4) sec
  34504.           Thread: 6  Waiting
  34505.           process_alarm
  34506.           thread_alarm
  34507.           Thread: 5  Slept for 10 (10) sec
  34508.           Thread: 5  Waiting
  34509.           process_alarm
  34510.           process_alarm
  34511.           thread_alarm
  34512.           Thread: 6  Slept for 5 (5) sec
  34513.           Thread: 6  Waiting
  34514.           process_alarm
  34515.           process_alarm
  34516.           
  34517.           ...
  34518.           thread_alarm
  34519.           Thread: 5  Slept for 0 (1) sec
  34520.           end
  34521.  
  34522. Differences between different thread packages
  34523. =============================================
  34524.  
  34525. *MySQL* is very dependent on the thread package used. So when choosing
  34526. a good platform for *MySQL*, the thread package is very important.
  34527.  
  34528. There are at least three types of thread packages:
  34529.  
  34530.    * User threads in a single process. Thread switching is managed with
  34531.      alarms and the threads library manages all non-thread-safe
  34532.      functions with locks. Read, write and select operations are
  34533.      usually managed with a thread-specific select that switches to
  34534.      another thread if the running threads have to wait for data.  If
  34535.      the user thread packages are integrated in the standard libs
  34536.      (FreeBSD and BSDI threads) the thread package requires less
  34537.      overhead than thread packages that have to map all unsafe calls
  34538.      (MIT-pthreads, FSU Pthreads and RTS threads).  In some
  34539.      environments (for example, SCO), all system calls are thread-safe
  34540.      so the mapping can be done very easily (FSU Pthreads on SCO).
  34541.      Downside: All mapped calls take a little time and it's quite
  34542.      tricky to be able to handle all situations. There are usually also
  34543.      some system calls that are not handled by the thread package (like
  34544.      MIT-pthreads and sockets). Thread scheduling isn't always optimal.
  34545.  
  34546.    * User threads in separate processes. Thread switching is done by the
  34547.      kernel and all data are shared between threads.  The thread package
  34548.      manages the standard thread calls to allow sharing data between
  34549.      threads.  LinuxThreads is using this method.  Downside: Lots of
  34550.      processes. Thread creating is slow. If one thread dies the rest
  34551.      are usually left hanging and you must kill them all before
  34552.      restarting. Thread switching is somewhat expensive.
  34553.  
  34554.    * Kernel threads. Thread switching is handled by the thread library
  34555.      or the kernel and is very fast. Everything is done in one process,
  34556.      but on some systems, `ps' may show the different threads. If one
  34557.      thread aborts, the whole process aborts. Most system calls are
  34558.      thread-safe and should require very little overhead.  Solaris,
  34559.      HP-UX, AIX and OSF1 have kernel threads.
  34560.  
  34561. In some systems kernel threads are managed by integrating user level
  34562. threads in the system libraries. In such cases, the thread switching
  34563. can only be done by the thread library and the kernel isn't really
  34564. "thread aware".
  34565.  
  34566. Description of MySQL regular expression syntax
  34567. **********************************************
  34568.  
  34569. A regular expression (regex) is a powerful way of specifying a complex
  34570. search.
  34571.  
  34572. *MySQL* uses Henry Spencer's implementation of regular expressions,
  34573. which is aimed to conform to POSIX 1003.2. *MySQL* uses the extended
  34574. version.
  34575.  
  34576. This is a simplistic reference that skips the details. To get more exact
  34577. information, see Henry Spencer's `regex(7)' manual page that is
  34578. included in the source distribution. *Note Credits::.
  34579.  
  34580. A regular expression describes a set of strings. The simplest regexp is
  34581. one that has no special characters in it. For example, the regexp
  34582. `hello' matches `hello' and nothing else.
  34583.  
  34584. Non-trivial regular expressions use certain special constructs so that
  34585. they can match more than one string. For example, the regexp
  34586. `hello|word' matches either the string `hello' or the string `word'.
  34587.  
  34588. As a more complex example, the regexp `B[an]*s' matches any of the
  34589. strings `Bananas', `Baaaaas', `Bs' and any other string starting with a
  34590. `B', ending with an `s', and containing any number of `a' or `n'
  34591. characters in between.
  34592.  
  34593. A regular expression may use any of the following special
  34594. characters/constructs:
  34595. `^'
  34596.      Match the beginning of a string.
  34597.           mysql> select "fo\nfo" REGEXP "^fo$";           -> 0
  34598.           mysql> select "fofo" REGEXP "^fo";              -> 1
  34599.  
  34600. `$'
  34601.      Match the end of a string.
  34602.           mysql> select "fo\no" REGEXP "^fo\no$";         -> 1
  34603.           mysql> select "fo\no" REGEXP "^fo$";            -> 0
  34604.  
  34605. `.'
  34606.      Match any character (including newline).
  34607.           mysql> select "fofo" REGEXP "^f.*";             -> 1
  34608.           mysql> select "fo\nfo" REGEXP "^f.*";           -> 1
  34609.  
  34610. `a*'
  34611.      Match any sequence of zero or more `a' characters.
  34612.           mysql> select "Ban" REGEXP "^Ba*n";             -> 1
  34613.           mysql> select "Baaan" REGEXP "^Ba*n";           -> 1
  34614.           mysql> select "Bn" REGEXP "^Ba*n";              -> 1
  34615.  
  34616. `a+'
  34617.      Match any sequence of one or more `a' characters.
  34618.           mysql> select "Ban" REGEXP "^Ba+n";             -> 1
  34619.           mysql> select "Bn" REGEXP "^Ba+n";              -> 0
  34620.  
  34621. `a?'
  34622.      Match either zero or one `a' character.
  34623.           mysql> select "Bn" REGEXP "^Ba?n";              -> 1
  34624.           mysql> select "Ban" REGEXP "^Ba?n";             -> 1
  34625.           mysql> select "Baan" REGEXP "^Ba?n";            -> 0
  34626.  
  34627. `de|abc'
  34628.      Match either of the sequences `de' or `abc'.
  34629.           mysql> select "pi" REGEXP "pi|apa";             -> 1
  34630.           mysql> select "axe" REGEXP "pi|apa";            -> 0
  34631.           mysql> select "apa" REGEXP "pi|apa";            -> 1
  34632.           mysql> select "apa" REGEXP "^(pi|apa)$";        -> 1
  34633.           mysql> select "pi" REGEXP "^(pi|apa)$";         -> 1
  34634.           mysql> select "pix" REGEXP "^(pi|apa)$";        -> 0
  34635.  
  34636. `(abc)*'
  34637.      Match zero or more instances of the sequence `abc'.
  34638.           mysql> select "pi" REGEXP "^(pi)*$";            -> 1
  34639.           mysql> select "pip" REGEXP "^(pi)*$";           -> 0
  34640.           mysql> select "pipi" REGEXP "^(pi)*$";          -> 1
  34641.  
  34642. `{1}'
  34643. `{2,3}'
  34644.      The is a more general way of writing regexps that match many
  34645.      occurrences of the previous atom.
  34646.     `a*'
  34647.           Can be written as `a{0,}'.
  34648.  
  34649.     `a+'
  34650.           Can be written as `a{1,}'.
  34651.  
  34652.     `a?'
  34653.           Can be written as `a{0,1}'.  To be more precise, an atom
  34654.      followed by a bound containing one integer `i' and no comma
  34655.      matches a sequence of exactly `i' matches of the atom. An atom
  34656.      followed by a bound containing one integer `i' and a comma matches
  34657.      a sequence of `i' or more matches of the atom.  An atom followed
  34658.      by a bound containing two integers `i' and `j' matches a sequence
  34659.      of `i' through `j' (inclusive) matches of the atom.
  34660.  
  34661.      Both arguments must `0 >= value <= RE_DUP_MAX (default 255)'.  If
  34662.      there are two arguments, the second must be greater than or equal
  34663.      to the first.
  34664.  
  34665. `[a-dX]'
  34666. `[^a-dX]'
  34667.      Matches any character which is (or is not, if ^ is used) either
  34668.      `a', `b', `c', `d' or `X'. To include a literal `]' character, it
  34669.      must immediately follow the opening bracket `['.  To include a
  34670.      literal `-' character, it must be written first or last. So
  34671.      `[0-9]' matches any decimal digit. Any character that does not have
  34672.      a defined meaning inside a `[]' pair has no special meaning and
  34673.      matches only itself.
  34674.           mysql> select "aXbc" REGEXP "[a-dXYZ]";         -> 1
  34675.           mysql> select "aXbc" REGEXP "^[a-dXYZ]$";       -> 0
  34676.           mysql> select "aXbc" REGEXP "^[a-dXYZ]+$";      -> 1
  34677.           mysql> select "aXbc" REGEXP "^[^a-dXYZ]+$";     -> 0
  34678.           mysql> select "gheis" REGEXP "^[^a-dXYZ]+$";    -> 1
  34679.           mysql> select "gheisa" REGEXP "^[^a-dXYZ]+$";   -> 0
  34680.  
  34681. `[[.characters.]]'
  34682.      The sequence of characters of that collating element. The sequence
  34683.      is a single element of the bracket expression's list. A bracket
  34684.      expression containing a multi-character collating element can thus
  34685.      match more than one character, e.g., if the collating sequence
  34686.      includes a `ch' collating element, then the regular expression
  34687.      `[[.ch.]]*c' matches the first five characters of `chchcc'.
  34688.  
  34689. `[=character_class=]'
  34690.      An equivalence class, standing for the sequences of characters of
  34691.      all collating elements equivalent to that one, including itself.
  34692.  
  34693.      For example, if `o' and `(+)' are the members of an equivalence
  34694.      class, then `[[=o=]]', `[[=(+)=]]', and `[o(+)]' are all
  34695.      synonymous. An equivalence class may not be an endpoint of a range.
  34696.  
  34697. `[:character_class:]'
  34698.      Within a bracket expression, the name of a character class
  34699.      enclosed in `[:' and `:]' stands for the list of all characters
  34700.      belonging to that class. Standard character class names are:
  34701.  
  34702.      alnum                  digit                  punct
  34703.      alpha                  graph                  space
  34704.      blank                  lower                  upper
  34705.      cntrl                  print                  xdigit
  34706.  
  34707.      These stand for the character classes defined in the `ctype(3)'
  34708.      manual page. A locale may provide others. A character class may
  34709.      not be used as an endpoint of a range.
  34710.           mysql> select "justalnums" REGEXP "[[:alnum:]]+";       -> 1
  34711.           mysql> select "!!" REGEXP "[[:alnum:]]+";               -> 0
  34712.  
  34713. `[[:<:]]'
  34714. `[[:>:]]'
  34715.      These match the null string at the beginning and end of a word
  34716.      respectively.  A word is defined as a sequence of word characters
  34717.      which is neither preceded nor followed by word characters. A word
  34718.      character is an alnum character (as defined by `ctype(3)') or an
  34719.      underscore (`_').
  34720.           mysql> select "a word a" REGEXP "[[:<:]]word[[:>:]]";      -> 1
  34721.           mysql> select "a xword a" REGEXP "[[:<:]]word[[:>:]]";     -> 0
  34722.  
  34723.      mysql> select "weeknights" REGEXP "^(wee|week)(knights|nights)$"; -> 1
  34724.  
  34725. What is Unireg?
  34726. ***************
  34727.  
  34728. Unireg is our tty interface builder, but it uses a low level connection
  34729. to our ISAM (which is used by *MySQL*) and because of this it is very
  34730. quick. It has existed since 1979 (on Unix in C since ~1986).
  34731.  
  34732. Unireg has the following components:
  34733.  
  34734.    * One table viewer with updates/browsing.
  34735.  
  34736.    * Multi table viewer (with one scrolling region).
  34737.  
  34738.    * Table creator. (With lots of column tags you can't create with
  34739.      *MySQL*) This is WYSIWYG (for a tty). You design a screen and
  34740.      Unireg prompts for the column specification.
  34741.  
  34742.    * Report generator.
  34743.  
  34744.    * A lot of utilities (quick import/export of tables to/from text
  34745.      files, analysis of table contents...).
  34746.  
  34747.    * Powerful multi-table updates (which we use a lot) with a BASIC-like
  34748.      language with LOTS of functions.
  34749.  
  34750.    * Dynamic languages (at present in Swedish and Finnish). If somebody
  34751.      wants an English version there are a few files that would have to
  34752.      be translated.
  34753.  
  34754.    * The ability to run updates interactively or in a batch.
  34755.  
  34756.    * Emacs-like key definitions with keyboard macros.
  34757.  
  34758.    * All this in a binary of 800K.
  34759.  
  34760.    * The `convform' utility. Converts `.frm' and text files between
  34761.      different character sets.
  34762.  
  34763.    * The `myisampack' utility. Packs an ISAM table (makes it 50-80%
  34764.      smaller). The table can be read by *MySQL* like an ordinary table.
  34765.      Only one record has to be decompressed per access. Cannot handle
  34766.      `BLOB' or `TEXT' columns or updates (yet).
  34767.  
  34768. We update most of our production databases with the Unireg interface and
  34769. serve web pages through *MySQL* (and in some extreme cases the Unireg
  34770. report generator).
  34771.  
  34772. Unireg takes about 3M of disk space and works on at least the following
  34773. platforms: SunOS 4.x, Solaris, Linux, HP-UX, ICL Unix, DNIX, SCO and
  34774. MS-DOS.
  34775.  
  34776. Unireg is currently only available in Swedish and Finnish.
  34777.  
  34778. The price tag for Unireg is 10,000 Swedish kr (about $1500 US), but this
  34779. includes support. Unireg is distributed as a binary. (But all the ISAM
  34780. sources can be found in *MySQL*). Usually we compile the binary for the
  34781. customer at their site.
  34782.  
  34783. All new development is concentrated to *MySQL*.
  34784.  
  34785. GNU General Public License
  34786. **************************
  34787.  
  34788.                  GNU GENERAL PUBLIC LICENSE
  34789.                     Version 2, June 1991
  34790.      
  34791.       Copyright (C) 1989, 1991 Free Software Foundation, Inc.
  34792.                                675 Mass Ave, Cambridge, MA 02139, USA
  34793.       Everyone is permitted to copy and distribute verbatim copies
  34794.       of this license document, but changing it is not allowed.
  34795.      
  34796.                      Preamble
  34797.      
  34798.        The licenses for most software are designed to take away your
  34799.      freedom to share and change it.  By contrast, the GNU General Public
  34800.      License is intended to guarantee your freedom to share and change free
  34801.      software--to make sure the software is free for all its users.  This
  34802.      General Public License applies to most of the Free Software
  34803.      Foundation's software and to any other program whose authors commit to
  34804.      using it.  (Some other Free Software Foundation software is covered by
  34805.      the GNU Library General Public License instead.)  You can apply it to
  34806.      your programs, too.
  34807.      
  34808.        When we speak of free software, we are referring to freedom, not
  34809.      price.  Our General Public Licenses are designed to make sure that you
  34810.      have the freedom to distribute copies of free software (and charge for
  34811.      this service if you wish), that you receive source code or can get it
  34812.      if you want it, that you can change the software or use pieces of it
  34813.      in new free programs; and that you know you can do these things.
  34814.      
  34815.        To protect your rights, we need to make restrictions that forbid
  34816.      anyone to deny you these rights or to ask you to surrender the rights.
  34817.      These restrictions translate to certain responsibilities for you if you
  34818.      distribute copies of the software, or if you modify it.
  34819.      
  34820.        For example, if you distribute copies of such a program, whether
  34821.      gratis or for a fee, you must give the recipients all the rights that
  34822.      you have.  You must make sure that they, too, receive or can get the
  34823.      source code.  And you must show them these terms so they know their
  34824.      rights.
  34825.      
  34826.        We protect your rights with two steps: (1) copyright the software, and
  34827.      (2) offer you this license which gives you legal permission to copy,
  34828.      distribute and/or modify the software.
  34829.      
  34830.        Also, for each author's protection and ours, we want to make certain
  34831.      that everyone understands that there is no warranty for this free
  34832.      software.  If the software is modified by someone else and passed on, we
  34833.      want its recipients to know that what they have is not the original, so
  34834.      that any problems introduced by others will not reflect on the original
  34835.      authors' reputations.
  34836.      
  34837.        Finally, any free program is threatened constantly by software
  34838.      patents.  We wish to avoid the danger that redistributors of a free
  34839.      program will individually obtain patent licenses, in effect making the
  34840.      program proprietary.  To prevent this, we have made it clear that any
  34841.      patent must be licensed for everyone's free use or not licensed at all.
  34842.      
  34843.        The precise terms and conditions for copying, distribution and
  34844.      modification follow.
  34845.      
  34846.                  GNU GENERAL PUBLIC LICENSE
  34847.         TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
  34848.      
  34849.        0. This License applies to any program or other work which contains
  34850.      a notice placed by the copyright holder saying it may be distributed
  34851.      under the terms of this General Public License.  The "Program", below,
  34852.      refers to any such program or work, and a "work based on the Program"
  34853.      means either the Program or any derivative work under copyright law:
  34854.      that is to say, a work containing the Program or a portion of it,
  34855.      either verbatim or with modifications and/or translated into another
  34856.      language.  (Hereinafter, translation is included without limitation in
  34857.      the term "modification".)  Each licensee is addressed as "you".
  34858.      
  34859.      Activities other than copying, distribution and modification are not
  34860.      covered by this License; they are outside its scope.  The act of
  34861.      running the Program is not restricted, and the output from the Program
  34862.      is covered only if its contents constitute a work based on the
  34863.      Program (independent of having been made by running the Program).
  34864.      Whether that is true depends on what the Program does.
  34865.      
  34866.        1. You may copy and distribute verbatim copies of the Program's
  34867.      source code as you receive it, in any medium, provided that you
  34868.      conspicuously and appropriately publish on each copy an appropriate
  34869.      copyright notice and disclaimer of warranty; keep intact all the
  34870.      notices that refer to this License and to the absence of any warranty;
  34871.      and give any other recipients of the Program a copy of this License
  34872.      along with the Program.
  34873.      
  34874.      You may charge a fee for the physical act of transferring a copy, and
  34875.      you may at your option offer warranty protection in exchange for a fee.
  34876.      
  34877.        2. You may modify your copy or copies of the Program or any portion
  34878.      of it, thus forming a work based on the Program, and copy and
  34879.      distribute such modifications or work under the terms of Section 1
  34880.      above, provided that you also meet all of these conditions:
  34881.      
  34882.          a) You must cause the modified files to carry prominent notices
  34883.          stating that you changed the files and the date of any change.
  34884.      
  34885.          b) You must cause any work that you distribute or publish, that in
  34886.          whole or in part contains or is derived from the Program or any
  34887.          part thereof, to be licensed as a whole at no charge to all third
  34888.          parties under the terms of this License.
  34889.      
  34890.          c) If the modified program normally reads commands interactively
  34891.          when run, you must cause it, when started running for such
  34892.          interactive use in the most ordinary way, to print or display an
  34893.          announcement including an appropriate copyright notice and a
  34894.          notice that there is no warranty (or else, saying that you provide
  34895.          a warranty) and that users may redistribute the program under
  34896.          these conditions, and telling the user how to view a copy of this
  34897.          License.  (Exception: if the Program itself is interactive but
  34898.          does not normally print such an announcement, your work based on
  34899.          the Program is not required to print an announcement.)
  34900.      
  34901.      These requirements apply to the modified work as a whole.  If
  34902.      identifiable sections of that work are not derived from the Program,
  34903.      and can be reasonably considered independent and separate works in
  34904.      themselves, then this License, and its terms, do not apply to those
  34905.      sections when you distribute them as separate works.  But when you
  34906.      distribute the same sections as part of a whole which is a work based
  34907.      on the Program, the distribution of the whole must be on the terms of
  34908.      this License, whose permissions for other licensees extend to the
  34909.      entire whole, and thus to each and every part regardless of who wrote it.
  34910.      
  34911.      Thus, it is not the intent of this section to claim rights or contest
  34912.      your rights to work written entirely by you; rather, the intent is to
  34913.      exercise the right to control the distribution of derivative or
  34914.      collective works based on the Program.
  34915.      
  34916.      In addition, mere aggregation of another work not based on the Program
  34917.      with the Program (or with a work based on the Program) on a volume of
  34918.      a storage or distribution medium does not bring the other work under
  34919.      the scope of this License.
  34920.      
  34921.        3. You may copy and distribute the Program (or a work based on it,
  34922.      under Section 2) in object code or executable form under the terms of
  34923.      Sections 1 and 2 above provided that you also do one of the following:
  34924.      
  34925.          a) Accompany it with the complete corresponding machine-readable
  34926.          source code, which must be distributed under the terms of Sections
  34927.          1 and 2 above on a medium customarily used for software interchange; or,
  34928.      
  34929.          b) Accompany it with a written offer, valid for at least three
  34930.          years, to give any third party, for a charge no more than your
  34931.          cost of physically performing source distribution, a complete
  34932.          machine-readable copy of the corresponding source code, to be
  34933.          distributed under the terms of Sections 1 and 2 above on a medium
  34934.          customarily used for software interchange; or,
  34935.      
  34936.          c) Accompany it with the information you received as to the offer
  34937.          to distribute corresponding source code.  (This alternative is
  34938.          allowed only for noncommercial distribution and only if you
  34939.          received the program in object code or executable form with such
  34940.          an offer, in accord with Subsection b above.)
  34941.      
  34942.      The source code for a work means the preferred form of the work for
  34943.      making modifications to it.  For an executable work, complete source
  34944.      code means all the source code for all modules it contains, plus any
  34945.      associated interface definition files, plus the scripts used to
  34946.      control compilation and installation of the executable.  However, as a
  34947.      special exception, the source code distributed need not include
  34948.      anything that is normally distributed (in either source or binary
  34949.      form) with the major components (compiler, kernel, and so on) of the
  34950.      operating system on which the executable runs, unless that component
  34951.      itself accompanies the executable.
  34952.      
  34953.      If distribution of executable or object code is made by offering
  34954.      access to copy from a designated place, then offering equivalent
  34955.      access to copy the source code from the same place counts as
  34956.      distribution of the source code, even though third parties are not
  34957.      compelled to copy the source along with the object code.
  34958.      
  34959.        4. You may not copy, modify, sublicense, or distribute the Program
  34960.      except as expressly provided under this License.  Any attempt
  34961.      otherwise to copy, modify, sublicense or distribute the Program is
  34962.      void, and will automatically terminate your rights under this License.
  34963.      However, parties who have received copies, or rights, from you under
  34964.      this License will not have their licenses terminated so long as such
  34965.      parties remain in full compliance.
  34966.      
  34967.        5. You are not required to accept this License, since you have not
  34968.      signed it.  However, nothing else grants you permission to modify or
  34969.      distribute the Program or its derivative works.  These actions are
  34970.      prohibited by law if you do not accept this License.  Therefore, by
  34971.      modifying or distributing the Program (or any work based on the
  34972.      Program), you indicate your acceptance of this License to do so, and
  34973.      all its terms and conditions for copying, distributing or modifying
  34974.      the Program or works based on it.
  34975.      
  34976.        6. Each time you redistribute the Program (or any work based on the
  34977.      Program), the recipient automatically receives a license from the
  34978.      original licensor to copy, distribute or modify the Program subject to
  34979.      these terms and conditions.  You may not impose any further
  34980.      restrictions on the recipients' exercise of the rights granted herein.
  34981.      You are not responsible for enforcing compliance by third parties to
  34982.      this License.
  34983.      
  34984.        7. If, as a consequence of a court judgment or allegation of patent
  34985.      infringement or for any other reason (not limited to patent issues),
  34986.      conditions are imposed on you (whether by court order, agreement or
  34987.      otherwise) that contradict the conditions of this License, they do not
  34988.      excuse you from the conditions of this License.  If you cannot
  34989.      distribute so as to satisfy simultaneously your obligations under this
  34990.      License and any other pertinent obligations, then as a consequence you
  34991.      may not distribute the Program at all.  For example, if a patent
  34992.      license would not permit royalty-free redistribution of the Program by
  34993.      all those who receive copies directly or indirectly through you, then
  34994.      the only way you could satisfy both it and this License would be to
  34995.      refrain entirely from distribution of the Program.
  34996.      
  34997.      If any portion of this section is held invalid or unenforceable under
  34998.      any particular circumstance, the balance of the section is intended to
  34999.      apply and the section as a whole is intended to apply in other
  35000.      circumstances.
  35001.      
  35002.      It is not the purpose of this section to induce you to infringe any
  35003.      patents or other property right claims or to contest validity of any
  35004.      such claims; this section has the sole purpose of protecting the
  35005.      integrity of the free software distribution system, which is
  35006.      implemented by public license practices.  Many people have made
  35007.      generous contributions to the wide range of software distributed
  35008.      through that system in reliance on consistent application of that
  35009.      system; it is up to the author/donor to decide if he or she is willing
  35010.      to distribute software through any other system and a licensee cannot
  35011.      impose that choice.
  35012.      
  35013.      This section is intended to make thoroughly clear what is believed to
  35014.      be a consequence of the rest of this License.
  35015.      
  35016.        8. If the distribution and/or use of the Program is restricted in
  35017.      certain countries either by patents or by copyrighted interfaces, the
  35018.      original copyright holder who places the Program under this License
  35019.      may add an explicit geographical distribution limitation excluding
  35020.      those countries, so that distribution is permitted only in or among
  35021.      countries not thus excluded.  In such case, this License incorporates
  35022.      the limitation as if written in the body of this License.
  35023.      
  35024.        9. The Free Software Foundation may publish revised and/or new versions
  35025.      of the General Public License from time to time.  Such new versions will
  35026.      be similar in spirit to the present version, but may differ in detail to
  35027.      address new problems or concerns.
  35028.      
  35029.      Each version is given a distinguishing version number.  If the Program
  35030.      specifies a version number of this License which applies to it and "any
  35031.      later version", you have the option of following the terms and conditions
  35032.      either of that version or of any later version published by the Free
  35033.      Software Foundation.  If the Program does not specify a version number of
  35034.      this License, you may choose any version ever published by the Free Software
  35035.      Foundation.
  35036.      
  35037.        10. If you wish to incorporate parts of the Program into other free
  35038.      programs whose distribution conditions are different, write to the author
  35039.      to ask for permission.  For software which is copyrighted by the Free
  35040.      Software Foundation, write to the Free Software Foundation; we sometimes
  35041.      make exceptions for this.  Our decision will be guided by the two goals
  35042.      of preserving the free status of all derivatives of our free software and
  35043.      of promoting the sharing and reuse of software generally.
  35044.      
  35045.                      NO WARRANTY
  35046.      
  35047.        11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
  35048.      FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
  35049.      OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
  35050.      PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
  35051.      OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  35052.      MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
  35053.      TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
  35054.      PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
  35055.      REPAIR OR CORRECTION.
  35056.      
  35057.        12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
  35058.      WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
  35059.      REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
  35060.      INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
  35061.      OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
  35062.      TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
  35063.      YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
  35064.      PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
  35065.      POSSIBILITY OF SUCH DAMAGES.
  35066.      
  35067.                   END OF TERMS AND CONDITIONS
  35068.      
  35069.          Appendix: How to Apply These Terms to Your New Programs
  35070.      
  35071.        If you develop a new program, and you want it to be of the greatest
  35072.      possible use to the public, the best way to achieve this is to make it
  35073.      free software which everyone can redistribute and change under these terms.
  35074.      
  35075.        To do so, attach the following notices to the program.  It is safest
  35076.      to attach them to the start of each source file to most effectively
  35077.      convey the exclusion of warranty; and each file should have at least
  35078.      the "copyright" line and a pointer to where the full notice is found.
  35079.      
  35080.          <one line to give the program's name and a brief idea of what it does.>
  35081.          Copyright (C) 19yy  <name of author>
  35082.      
  35083.          This program is free software; you can redistribute it and/or modify
  35084.          it under the terms of the GNU General Public License as published by
  35085.          the Free Software Foundation; either version 2 of the License, or
  35086.          (at your option) any later version.
  35087.      
  35088.          This program is distributed in the hope that it will be useful,
  35089.          but WITHOUT ANY WARRANTY; without even the implied warranty of
  35090.          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  35091.          GNU General Public License for more details.
  35092.      
  35093.          You should have received a copy of the GNU General Public License
  35094.          along with this program; if not, write to the Free Software
  35095.          Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  35096.      
  35097.      Also add information on how to contact you by electronic and paper mail.
  35098.      
  35099.      If the program is interactive, make it output a short notice like this
  35100.      when it starts in an interactive mode:
  35101.      
  35102.          Gnomovision version 69, Copyright (C) 19yy name of author
  35103.          Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
  35104.          This is free software, and you are welcome to redistribute it
  35105.          under certain conditions; type `show c' for details.
  35106.      
  35107.      The hypothetical commands `show w' and `show c' should show the appropriate
  35108.      parts of the General Public License.  Of course, the commands you use may
  35109.      be called something other than `show w' and `show c'; they could even be
  35110.      mouse-clicks or menu items--whatever suits your program.
  35111.      
  35112.      You should also get your employer (if you work as a programmer) or your
  35113.      school, if any, to sign a "copyright disclaimer" for the program, if
  35114.      necessary.  Here is a sample; alter the names:
  35115.      
  35116.        Yoyodyne, Inc., hereby disclaims all copyright interest in the program
  35117.        `Gnomovision' (which makes passes at compilers) written by James Hacker.
  35118.      
  35119.        <signature of Ty Coon>, 1 April 1989
  35120.        Ty Coon, President of Vice
  35121.      
  35122.      This General Public License does not permit incorporating your program into
  35123.      proprietary programs.  If your program is a subroutine library, you may
  35124.      consider it more useful to permit linking proprietary applications with the
  35125.      library.  If this is what you want to do, use the GNU Library General
  35126.      Public License instead of this License.
  35127.  
  35128. GNU Library General Public License
  35129. **********************************
  35130.  
  35131.                GNU LIBRARY GENERAL PUBLIC LICENSE
  35132.                     Version 2, June 1991
  35133.      
  35134.       Copyright (C) 1991 Free Software Foundation, Inc.
  35135.                          675 Mass Ave, Cambridge, MA 02139, USA
  35136.       Everyone is permitted to copy and distribute verbatim copies
  35137.       of this license document, but changing it is not allowed.
  35138.      
  35139.      [This is the first released version of the library GPL.  It is
  35140.       numbered 2 because it goes with version 2 of the ordinary GPL.]
  35141.      
  35142.                      Preamble
  35143.      
  35144.        The licenses for most software are designed to take away your
  35145.      freedom to share and change it.  By contrast, the GNU General Public
  35146.      Licenses are intended to guarantee your freedom to share and change
  35147.      free software--to make sure the software is free for all its users.
  35148.      
  35149.        This license, the Library General Public License, applies to some
  35150.      specially designated Free Software Foundation software, and to any
  35151.      other libraries whose authors decide to use it.  You can use it for
  35152.      your libraries, too.
  35153.      
  35154.        When we speak of free software, we are referring to freedom, not
  35155.      price.  Our General Public Licenses are designed to make sure that you
  35156.      have the freedom to distribute copies of free software (and charge for
  35157.      this service if you wish), that you receive source code or can get it
  35158.      if you want it, that you can change the software or use pieces of it
  35159.      in new free programs; and that you know you can do these things.
  35160.      
  35161.        To protect your rights, we need to make restrictions that forbid
  35162.      anyone to deny you these rights or to ask you to surrender the rights.
  35163.      These restrictions translate to certain responsibilities for you if
  35164.      you distribute copies of the library, or if you modify it.
  35165.      
  35166.        For example, if you distribute copies of the library, whether gratis
  35167.      or for a fee, you must give the recipients all the rights that we gave
  35168.      you.  You must make sure that they, too, receive or can get the source
  35169.      code.  If you link a program with the library, you must provide
  35170.      complete object files to the recipients so that they can relink them
  35171.      with the library, after making changes to the library and recompiling
  35172.      it.  And you must show them these terms so they know their rights.
  35173.      
  35174.        Our method of protecting your rights has two steps: (1) copyright
  35175.      the library, and (2) offer you this license which gives you legal
  35176.      permission to copy, distribute and/or modify the library.
  35177.      
  35178.        Also, for each distributor's protection, we want to make certain
  35179.      that everyone understands that there is no warranty for this free
  35180.      library.  If the library is modified by someone else and passed on, we
  35181.      want its recipients to know that what they have is not the original
  35182.      version, so that any problems introduced by others will not reflect on
  35183.      the original authors' reputations.
  35184.      
  35185.        Finally, any free program is threatened constantly by software
  35186.      patents.  We wish to avoid the danger that companies distributing free
  35187.      software will individually obtain patent licenses, thus in effect
  35188.      transforming the program into proprietary software.  To prevent this,
  35189.      we have made it clear that any patent must be licensed for everyone's
  35190.      free use or not licensed at all.
  35191.      
  35192.        Most GNU software, including some libraries, is covered by the ordinary
  35193.      GNU General Public License, which was designed for utility programs.  This
  35194.      license, the GNU Library General Public License, applies to certain
  35195.      designated libraries.  This license is quite different from the ordinary
  35196.      one; be sure to read it in full, and don't assume that anything in it is
  35197.      the same as in the ordinary license.
  35198.      
  35199.        The reason we have a separate public license for some libraries is that
  35200.      they blur the distinction we usually make between modifying or adding to a
  35201.      program and simply using it.  Linking a program with a library, without
  35202.      changing the library, is in some sense simply using the library, and is
  35203.      analogous to running a utility program or application program.  However, in
  35204.      a textual and legal sense, the linked executable is a combined work, a
  35205.      derivative of the original library, and the ordinary General Public License
  35206.      treats it as such.
  35207.      
  35208.        Because of this blurred distinction, using the ordinary General
  35209.      Public License for libraries did not effectively promote software
  35210.      sharing, because most developers did not use the libraries.  We
  35211.      concluded that weaker conditions might promote sharing better.
  35212.      
  35213.        However, unrestricted linking of non-free programs would deprive the
  35214.      users of those programs of all benefit from the free status of the
  35215.      libraries themselves.  This Library General Public License is intended to
  35216.      permit developers of non-free programs to use free libraries, while
  35217.      preserving your freedom as a user of such programs to change the free
  35218.      libraries that are incorporated in them.  (We have not seen how to achieve
  35219.      this as regards changes in header files, but we have achieved it as regards
  35220.      changes in the actual functions of the Library.)  The hope is that this
  35221.      will lead to faster development of free libraries.
  35222.      
  35223.        The precise terms and conditions for copying, distribution and
  35224.      modification follow.  Pay close attention to the difference between a
  35225.      "work based on the library" and a "work that uses the library".  The
  35226.      former contains code derived from the library, while the latter only
  35227.      works together with the library.
  35228.      
  35229.        Note that it is possible for a library to be covered by the ordinary
  35230.      General Public License rather than by this special one.
  35231.      
  35232.                GNU LIBRARY GENERAL PUBLIC LICENSE
  35233.         TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
  35234.      
  35235.        0. This License Agreement applies to any software library which
  35236.      contains a notice placed by the copyright holder or other authorized
  35237.      party saying it may be distributed under the terms of this Library
  35238.      General Public License (also called "this License").  Each licensee is
  35239.      addressed as "you".
  35240.      
  35241.        A "library" means a collection of software functions and/or data
  35242.      prepared so as to be conveniently linked with application programs
  35243.      (which use some of those functions and data) to form executables.
  35244.      
  35245.        The "Library", below, refers to any such software library or work
  35246.      which has been distributed under these terms.  A "work based on the
  35247.      Library" means either the Library or any derivative work under
  35248.      copyright law: that is to say, a work containing the Library or a
  35249.      portion of it, either verbatim or with modifications and/or translated
  35250.      straightforwardly into another language.  (Hereinafter, translation is
  35251.      included without limitation in the term "modification".)
  35252.      
  35253.        "Source code" for a work means the preferred form of the work for
  35254.      making modifications to it.  For a library, complete source code means
  35255.      all the source code for all modules it contains, plus any associated
  35256.      interface definition files, plus the scripts used to control compilation
  35257.      and installation of the library.
  35258.      
  35259.        Activities other than copying, distribution and modification are not
  35260.      covered by this License; they are outside its scope.  The act of
  35261.      running a program using the Library is not restricted, and output from
  35262.      such a program is covered only if its contents constitute a work based
  35263.      on the Library (independent of the use of the Library in a tool for
  35264.      writing it).  Whether that is true depends on what the Library does
  35265.      and what the program that uses the Library does.
  35266.      
  35267.        1. You may copy and distribute verbatim copies of the Library's
  35268.      complete source code as you receive it, in any medium, provided that
  35269.      you conspicuously and appropriately publish on each copy an
  35270.      appropriate copyright notice and disclaimer of warranty; keep intact
  35271.      all the notices that refer to this License and to the absence of any
  35272.      warranty; and distribute a copy of this License along with the
  35273.      Library.
  35274.      
  35275.        You may charge a fee for the physical act of transferring a copy,
  35276.      and you may at your option offer warranty protection in exchange for a
  35277.      fee.
  35278.      
  35279.        2. You may modify your copy or copies of the Library or any portion
  35280.      of it, thus forming a work based on the Library, and copy and
  35281.      distribute such modifications or work under the terms of Section 1
  35282.      above, provided that you also meet all of these conditions:
  35283.      
  35284.          a) The modified work must itself be a software library.
  35285.      
  35286.          b) You must cause the files modified to carry prominent notices
  35287.          stating that you changed the files and the date of any change.
  35288.      
  35289.          c) You must cause the whole of the work to be licensed at no
  35290.          charge to all third parties under the terms of this License.
  35291.      
  35292.          d) If a facility in the modified Library refers to a function or a
  35293.          table of data to be supplied by an application program that uses
  35294.          the facility, other than as an argument passed when the facility
  35295.          is invoked, then you must make a good faith effort to ensure that,
  35296.          in the event an application does not supply such function or
  35297.          table, the facility still operates, and performs whatever part of
  35298.          its purpose remains meaningful.
  35299.      
  35300.          (For example, a function in a library to compute square roots has
  35301.          a purpose that is entirely well-defined independent of the
  35302.          application.  Therefore, Subsection 2d requires that any
  35303.          application-supplied function or table used by this function must
  35304.          be optional: if the application does not supply it, the square
  35305.          root function must still compute square roots.)
  35306.      
  35307.      These requirements apply to the modified work as a whole.  If
  35308.      identifiable sections of that work are not derived from the Library,
  35309.      and can be reasonably considered independent and separate works in
  35310.      themselves, then this License, and its terms, do not apply to those
  35311.      sections when you distribute them as separate works.  But when you
  35312.      distribute the same sections as part of a whole which is a work based
  35313.      on the Library, the distribution of the whole must be on the terms of
  35314.      this License, whose permissions for other licensees extend to the
  35315.      entire whole, and thus to each and every part regardless of who wrote
  35316.      it.
  35317.      
  35318.      Thus, it is not the intent of this section to claim rights or contest
  35319.      your rights to work written entirely by you; rather, the intent is to
  35320.      exercise the right to control the distribution of derivative or
  35321.      collective works based on the Library.
  35322.      
  35323.      In addition, mere aggregation of another work not based on the Library
  35324.      with the Library (or with a work based on the Library) on a volume of
  35325.      a storage or distribution medium does not bring the other work under
  35326.      the scope of this License.
  35327.      
  35328.        3. You may opt to apply the terms of the ordinary GNU General Public
  35329.      License instead of this License to a given copy of the Library.  To do
  35330.      this, you must alter all the notices that refer to this License, so
  35331.      that they refer to the ordinary GNU General Public License, version 2,
  35332.      instead of to this License.  (If a newer version than version 2 of the
  35333.      ordinary GNU General Public License has appeared, then you can specify
  35334.      that version instead if you wish.)  Do not make any other change in
  35335.      these notices.
  35336.      
  35337.        Once this change is made in a given copy, it is irreversible for
  35338.      that copy, so the ordinary GNU General Public License applies to all
  35339.      subsequent copies and derivative works made from that copy.
  35340.      
  35341.        This option is useful when you wish to copy part of the code of
  35342.      the Library into a program that is not a library.
  35343.      
  35344.        4. You may copy and distribute the Library (or a portion or
  35345.      derivative of it, under Section 2) in object code or executable form
  35346.      under the terms of Sections 1 and 2 above provided that you accompany
  35347.      it with the complete corresponding machine-readable source code, which
  35348.      must be distributed under the terms of Sections 1 and 2 above on a
  35349.      medium customarily used for software interchange.
  35350.      
  35351.        If distribution of object code is made by offering access to copy
  35352.      from a designated place, then offering equivalent access to copy the
  35353.      source code from the same place satisfies the requirement to
  35354.      distribute the source code, even though third parties are not
  35355.      compelled to copy the source along with the object code.
  35356.      
  35357.        5. A program that contains no derivative of any portion of the
  35358.      Library, but is designed to work with the Library by being compiled or
  35359.      linked with it, is called a "work that uses the Library".  Such a
  35360.      work, in isolation, is not a derivative work of the Library, and
  35361.      therefore falls outside the scope of this License.
  35362.      
  35363.        However, linking a "work that uses the Library" with the Library
  35364.      creates an executable that is a derivative of the Library (because it
  35365.      contains portions of the Library), rather than a "work that uses the
  35366.      library".  The executable is therefore covered by this License.
  35367.      Section 6 states terms for distribution of such executables.
  35368.      
  35369.        When a "work that uses the Library" uses material from a header file
  35370.      that is part of the Library, the object code for the work may be a
  35371.      derivative work of the Library even though the source code is not.
  35372.      Whether this is true is especially significant if the work can be
  35373.      linked without the Library, or if the work is itself a library.  The
  35374.      threshold for this to be true is not precisely defined by law.
  35375.      
  35376.        If such an object file uses only numerical parameters, data
  35377.      structure layouts and accessors, and small macros and small inline
  35378.      functions (ten lines or less in length), then the use of the object
  35379.      file is unrestricted, regardless of whether it is legally a derivative
  35380.      work.  (Executables containing this object code plus portions of the
  35381.      Library will still fall under Section 6.)
  35382.      
  35383.        Otherwise, if the work is a derivative of the Library, you may
  35384.      distribute the object code for the work under the terms of Section 6.
  35385.      Any executables containing that work also fall under Section 6,
  35386.      whether or not they are linked directly with the Library itself.
  35387.      
  35388.        6. As an exception to the Sections above, you may also compile or
  35389.      link a "work that uses the Library" with the Library to produce a
  35390.      work containing portions of the Library, and distribute that work
  35391.      under terms of your choice, provided that the terms permit
  35392.      modification of the work for the customer's own use and reverse
  35393.      engineering for debugging such modifications.
  35394.      
  35395.        You must give prominent notice with each copy of the work that the
  35396.      Library is used in it and that the Library and its use are covered by
  35397.      this License.  You must supply a copy of this License.  If the work
  35398.      during execution displays copyright notices, you must include the
  35399.      copyright notice for the Library among them, as well as a reference
  35400.      directing the user to the copy of this License.  Also, you must do one
  35401.      of these things:
  35402.      
  35403.          a) Accompany the work with the complete corresponding
  35404.          machine-readable source code for the Library including whatever
  35405.          changes were used in the work (which must be distributed under
  35406.          Sections 1 and 2 above); and, if the work is an executable linked
  35407.          with the Library, with the complete machine-readable "work that
  35408.          uses the Library", as object code and/or source code, so that the
  35409.          user can modify the Library and then relink to produce a modified
  35410.          executable containing the modified Library.  (It is understood
  35411.          that the user who changes the contents of definitions files in the
  35412.          Library will not necessarily be able to recompile the application
  35413.          to use the modified definitions.)
  35414.      
  35415.          b) Accompany the work with a written offer, valid for at
  35416.          least three years, to give the same user the materials
  35417.          specified in Subsection 6a, above, for a charge no more
  35418.          than the cost of performing this distribution.
  35419.      
  35420.          c) If distribution of the work is made by offering access to copy
  35421.          from a designated place, offer equivalent access to copy the above
  35422.          specified materials from the same place.
  35423.      
  35424.          d) Verify that the user has already received a copy of these
  35425.          materials or that you have already sent this user a copy.
  35426.      
  35427.        For an executable, the required form of the "work that uses the
  35428.      Library" must include any data and utility programs needed for
  35429.      reproducing the executable from it.  However, as a special exception,
  35430.      the source code distributed need not include anything that is normally
  35431.      distributed (in either source or binary form) with the major
  35432.      components (compiler, kernel, and so on) of the operating system on
  35433.      which the executable runs, unless that component itself accompanies
  35434.      the executable.
  35435.      
  35436.        It may happen that this requirement contradicts the license
  35437.      restrictions of other proprietary libraries that do not normally
  35438.      accompany the operating system.  Such a contradiction means you cannot
  35439.      use both them and the Library together in an executable that you
  35440.      distribute.
  35441.      
  35442.        7. You may place library facilities that are a work based on the
  35443.      Library side-by-side in a single library together with other library
  35444.      facilities not covered by this License, and distribute such a combined
  35445.      library, provided that the separate distribution of the work based on
  35446.      the Library and of the other library facilities is otherwise
  35447.      permitted, and provided that you do these two things:
  35448.      
  35449.          a) Accompany the combined library with a copy of the same work
  35450.          based on the Library, uncombined with any other library
  35451.          facilities.  This must be distributed under the terms of the
  35452.          Sections above.
  35453.      
  35454.          b) Give prominent notice with the combined library of the fact
  35455.          that part of it is a work based on the Library, and explaining
  35456.          where to find the accompanying uncombined form of the same work.
  35457.      
  35458.        8. You may not copy, modify, sublicense, link with, or distribute
  35459.      the Library except as expressly provided under this License.  Any
  35460.      attempt otherwise to copy, modify, sublicense, link with, or
  35461.      distribute the Library is void, and will automatically terminate your
  35462.      rights under this License.  However, parties who have received copies,
  35463.      or rights, from you under this License will not have their licenses
  35464.      terminated so long as such parties remain in full compliance.
  35465.      
  35466.        9. You are not required to accept this License, since you have not
  35467.      signed it.  However, nothing else grants you permission to modify or
  35468.      distribute the Library or its derivative works.  These actions are
  35469.      prohibited by law if you do not accept this License.  Therefore, by
  35470.      modifying or distributing the Library (or any work based on the
  35471.      Library), you indicate your acceptance of this License to do so, and
  35472.      all its terms and conditions for copying, distributing or modifying
  35473.      the Library or works based on it.
  35474.      
  35475.        10. Each time you redistribute the Library (or any work based on the
  35476.      Library), the recipient automatically receives a license from the
  35477.      original licensor to copy, distribute, link with or modify the Library
  35478.      subject to these terms and conditions.  You may not impose any further
  35479.      restrictions on the recipients' exercise of the rights granted herein.
  35480.      You are not responsible for enforcing compliance by third parties to
  35481.      this License.
  35482.      
  35483.        11. If, as a consequence of a court judgment or allegation of patent
  35484.      infringement or for any other reason (not limited to patent issues),
  35485.      conditions are imposed on you (whether by court order, agreement or
  35486.      otherwise) that contradict the conditions of this License, they do not
  35487.      excuse you from the conditions of this License.  If you cannot
  35488.      distribute so as to satisfy simultaneously your obligations under this
  35489.      License and any other pertinent obligations, then as a consequence you
  35490.      may not distribute the Library at all.  For example, if a patent
  35491.      license would not permit royalty-free redistribution of the Library by
  35492.      all those who receive copies directly or indirectly through you, then
  35493.      the only way you could satisfy both it and this License would be to
  35494.      refrain entirely from distribution of the Library.
  35495.      
  35496.      If any portion of this section is held invalid or unenforceable under any
  35497.      particular circumstance, the balance of the section is intended to apply,
  35498.      and the section as a whole is intended to apply in other circumstances.
  35499.      
  35500.      It is not the purpose of this section to induce you to infringe any
  35501.      patents or other property right claims or to contest validity of any
  35502.      such claims; this section has the sole purpose of protecting the
  35503.      integrity of the free software distribution system which is
  35504.      implemented by public license practices.  Many people have made
  35505.      generous contributions to the wide range of software distributed
  35506.      through that system in reliance on consistent application of that
  35507.      system; it is up to the author/donor to decide if he or she is willing
  35508.      to distribute software through any other system and a licensee cannot
  35509.      impose that choice.
  35510.      
  35511.      This section is intended to make thoroughly clear what is believed to
  35512.      be a consequence of the rest of this License.
  35513.      
  35514.        12. If the distribution and/or use of the Library is restricted in
  35515.      certain countries either by patents or by copyrighted interfaces, the
  35516.      original copyright holder who places the Library under this License may add
  35517.      an explicit geographical distribution limitation excluding those countries,
  35518.      so that distribution is permitted only in or among countries not thus
  35519.      excluded.  In such case, this License incorporates the limitation as if
  35520.      written in the body of this License.
  35521.      
  35522.        13. The Free Software Foundation may publish revised and/or new
  35523.      versions of the Library General Public License from time to time.
  35524.      Such new versions will be similar in spirit to the present version,
  35525.      but may differ in detail to address new problems or concerns.
  35526.      
  35527.      Each version is given a distinguishing version number.  If the Library
  35528.      specifies a version number of this License which applies to it and
  35529.      "any later version", you have the option of following the terms and
  35530.      conditions either of that version or of any later version published by
  35531.      the Free Software Foundation.  If the Library does not specify a
  35532.      license version number, you may choose any version ever published by
  35533.      the Free Software Foundation.
  35534.      
  35535.        14. If you wish to incorporate parts of the Library into other free
  35536.      programs whose distribution conditions are incompatible with these,
  35537.      write to the author to ask for permission.  For software which is
  35538.      copyrighted by the Free Software Foundation, write to the Free
  35539.      Software Foundation; we sometimes make exceptions for this.  Our
  35540.      decision will be guided by the two goals of preserving the free status
  35541.      of all derivatives of our free software and of promoting the sharing
  35542.      and reuse of software generally.
  35543.      
  35544.                      NO WARRANTY
  35545.      
  35546.        15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
  35547.      WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
  35548.      EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
  35549.      OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
  35550.      KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
  35551.      IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  35552.      PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
  35553.      LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
  35554.      THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
  35555.      
  35556.        16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
  35557.      WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
  35558.      AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
  35559.      FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
  35560.      CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
  35561.      LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
  35562.      RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
  35563.      FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
  35564.      SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
  35565.      DAMAGES.
  35566.      
  35567.                   END OF TERMS AND CONDITIONS
  35568.      
  35569.           Appendix: How to Apply These Terms to Your New Libraries
  35570.      
  35571.        If you develop a new library, and you want it to be of the greatest
  35572.      possible use to the public, we recommend making it free software that
  35573.      everyone can redistribute and change.  You can do so by permitting
  35574.      redistribution under these terms (or, alternatively, under the terms of the
  35575.      ordinary General Public License).
  35576.      
  35577.        To apply these terms, attach the following notices to the library.  It is
  35578.      safest to attach them to the start of each source file to most effectively
  35579.      convey the exclusion of warranty; and each file should have at least the
  35580.      "copyright" line and a pointer to where the full notice is found.
  35581.      
  35582.          <one line to give the library's name and a brief idea of what it does.>
  35583.          Copyright (C) <year>  <name of author>
  35584.      
  35585.          This library is free software; you can redistribute it and/or
  35586.          modify it under the terms of the GNU Library General Public
  35587.          License as published by the Free Software Foundation; either
  35588.          version 2 of the License, or (at your option) any later version.
  35589.      
  35590.          This library is distributed in the hope that it will be useful,
  35591.          but WITHOUT ANY WARRANTY; without even the implied warranty of
  35592.          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  35593.          Library General Public License for more details.
  35594.      
  35595.          You should have received a copy of the GNU Library General Public
  35596.          License along with this library; if not, write to the Free
  35597.          Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  35598.      
  35599.      Also add information on how to contact you by electronic and paper mail.
  35600.      
  35601.      You should also get your employer (if you work as a programmer) or your
  35602.      school, if any, to sign a "copyright disclaimer" for the library, if
  35603.      necessary.  Here is a sample; alter the names:
  35604.      
  35605.        Yoyodyne, Inc., hereby disclaims all copyright interest in the
  35606.        library `Frob' (a library for tweaking knobs) written by James Random Hacker.
  35607.      
  35608.        <signature of Ty Coon>, 1 April 1990
  35609.        Ty Coon, President of Vice
  35610.      
  35611.      That's all there is to it!
  35612.  
  35613. SQL command, type and function index
  35614. ************************************
  35615.  
  35616. ! (logical NOT):
  35617.           See ``Logical operations''.
  35618. != (not equal):
  35619.           See ``Comparison operators''.
  35620. ":
  35621.           See ``Database, table, index, column and alias names''.
  35622. % (modulo):
  35623.           See ``Mathematical functions''.
  35624. % (wildcard character):
  35625.           See ``Strings''.
  35626. & (bitwise AND):
  35627.           See ``Bit functions''.
  35628. && (logical AND):
  35629.           See ``Logical operations''.
  35630. () (parentheses):
  35631.           See ``Grouping functions''.
  35632. * (multiplication):
  35633.           See ``Normal arithmetic operations''.
  35634. + (addition):
  35635.           See ``Normal arithmetic operations''.
  35636. - (subtraction):
  35637.           See ``Normal arithmetic operations''.
  35638. - (unary minus):
  35639.           See ``Mathematical functions''.
  35640. .my.cnf file <1>:
  35641.           See ``Running multiple MySQL servers on the same machine''.
  35642. .my.cnf file <2>:
  35643.           See ``Causes of `Access denied' errors''.
  35644. .my.cnf file <3>:
  35645.           See ``Keeping your password secure''.
  35646. .my.cnf file <4>:
  35647.           See ``Connecting to the MySQL server''.
  35648. .my.cnf file <5>:
  35649.           See ``Option files''.
  35650. .my.cnf file:
  35651.           See ``MySQL-Win32 compared to Unix MySQL''.
  35652. .mysql_history file:
  35653.           See ``Overview of the different MySQL programs''.
  35654. .pid (process ID) file:
  35655.           See ``Setting up a table maintenance regimen''.
  35656. / (division):
  35657.           See ``Normal arithmetic operations''.
  35658. /etc/passwd <1>:
  35659.           See ```SELECT' syntax''.
  35660. /etc/passwd:
  35661.           See ``How to make MySQL secure against crackers''.
  35662. < (less than):
  35663.           See ``Comparison operators''.
  35664. << (left shift):
  35665.           See ``Bit functions''.
  35666. <= (less than or equal):
  35667.           See ``Comparison operators''.
  35668. <=> (Equal to):
  35669.           See ``Comparison operators''.
  35670. <> (not equal):
  35671.           See ``Comparison operators''.
  35672. = (equal):
  35673.           See ``Comparison operators''.
  35674. > (greater than):
  35675.           See ``Comparison operators''.
  35676. >= (greater than or equal):
  35677.           See ``Comparison operators''.
  35678. >> (right shift):
  35679.           See ``Bit functions''.
  35680. \" (double quote):
  35681.           See ``Strings''.
  35682. \' (single quote):
  35683.           See ``Strings''.
  35684. \0 (ASCII 0):
  35685.           See ``Strings''.
  35686. \\ (escape):
  35687.           See ``Strings''.
  35688. \b (backspace):
  35689.           See ``Strings''.
  35690. \n (newline):
  35691.           See ``Strings''.
  35692. \r (carriage return):
  35693.           See ``Strings''.
  35694. \t (tab):
  35695.           See ``Strings''.
  35696. _ (wildcard character):
  35697.           See ``Strings''.
  35698. `:
  35699.           See ``Database, table, index, column and alias names''.
  35700. ABS():
  35701.           See ``Mathematical functions''.
  35702. ACOS():
  35703.           See ``Mathematical functions''.
  35704. ADDDATE():
  35705.           See ``Date and time functions''.
  35706. addition (+):
  35707.           See ``Normal arithmetic operations''.
  35708. alias:
  35709.           See ``Problems with `NULL' values''.
  35710. ALTER TABLE:
  35711.           See ``Silent column specification changes''.
  35712. ANALYZE TABLE:
  35713.           See ```CHECK TABLE' syntax''.
  35714. AND, bitwise:
  35715.           See ``Bit functions''.
  35716. AND, logical:
  35717.           See ``Logical operations''.
  35718. Arithmetic functions:
  35719.           See ``Normal arithmetic operations''.
  35720. ASCII():
  35721.           See ``String functions''.
  35722. ASIN():
  35723.           See ``Mathematical functions''.
  35724. ATAN():
  35725.           See ``Mathematical functions''.
  35726. ATAN2():
  35727.           See ``Mathematical functions''.
  35728. AUTO_INCREMENT, using with DBI:
  35729.           See ``The `DBI' interface''.
  35730. AVG():
  35731.           See ``Functions for use with `GROUP BY' clauses''.
  35732. backspace (\b):
  35733.           See ``Strings''.
  35734. BEGIN:
  35735.           See ```DESCRIBE' syntax (Get information about columns)''.
  35736. BENCHMARK():
  35737.           See ``Miscellaneous functions''.
  35738. BETWEEN ... AND:
  35739.           See ``Comparison operators''.
  35740. BIGINT:
  35741.           See ``Column types''.
  35742. BIN():
  35743.           See ``String functions''.
  35744. BINARY:
  35745.           See ``Cast operators''.
  35746. Bit functions:
  35747.           See ``Normal arithmetic operations''.
  35748. BIT_AND():
  35749.           See ``Functions for use with `GROUP BY' clauses''.
  35750. BIT_COUNT():
  35751.           See ``Bit functions''.
  35752. BIT_OR():
  35753.           See ``Functions for use with `GROUP BY' clauses''.
  35754. BLOB <1>:
  35755.           See ``The `CHAR' and `VARCHAR' types''.
  35756. BLOB:
  35757.           See ``Column types''.
  35758. carriage return (\r):
  35759.           See ``Strings''.
  35760. CASE:
  35761.           See ``Control flow functions''.
  35762. Casts:
  35763.           See ``String comparison functions''.
  35764. CC environment variable <1>:
  35765.           See ``Environment variables''.
  35766. CC environment variable <2>:
  35767.           See ``Problems compiling?''.
  35768. CC environment variable:
  35769.           See ``Typical `configure' options''.
  35770. CCX environment variable:
  35771.           See ``Environment variables''.
  35772. CEILING():
  35773.           See ``Mathematical functions''.
  35774. CFLAGS environment variable <1>:
  35775.           See ``Environment variables''.
  35776. CFLAGS environment variable:
  35777.           See ``Problems compiling?''.
  35778. CHAR <1>:
  35779.           See ``String types''.
  35780. CHAR:
  35781.           See ``Column types''.
  35782. CHAR VARYING:
  35783.           See ``Column types''.
  35784. CHAR():
  35785.           See ``String functions''.
  35786. CHAR_LENGTH():
  35787.           See ``String functions''.
  35788. CHARACTER:
  35789.           See ``Column types''.
  35790. CHARACTER VARYING:
  35791.           See ``Column types''.
  35792. CHARACTER_LENGTH():
  35793.           See ``String functions''.
  35794. CHECK TABLE:
  35795.           See ```OPTIMIZE TABLE' syntax''.
  35796. ChopBlanks DBI method:
  35797.           See ``The `DBI' interface''.
  35798. COALESCE():
  35799.           See ``Comparison operators''.
  35800. Comment syntax:
  35801.           See ```DROP INDEX' syntax''.
  35802. COMMIT:
  35803.           See ```DESCRIBE' syntax (Get information about columns)''.
  35804. Comparison operators:
  35805.           See ``Logical operations''.
  35806. CONCAT():
  35807.           See ``String functions''.
  35808. CONCAT_WS():
  35809.           See ``String functions''.
  35810. connect() DBI method:
  35811.           See ``The `DBI' interface''.
  35812. CONNECTION_ID():
  35813.           See ``Miscellaneous functions''.
  35814. Control flow functions:
  35815.           See ``Cast operators''.
  35816. CONV():
  35817.           See ``String functions''.
  35818. COS():
  35819.           See ``Mathematical functions''.
  35820. COT():
  35821.           See ``Mathematical functions''.
  35822. COUNT():
  35823.           See ``Functions for use with `GROUP BY' clauses''.
  35824. COUNT(DISTINCT):
  35825.           See ``Functions for use with `GROUP BY' clauses''.
  35826. CREATE DATABASE:
  35827.           See ``Functions for use with `GROUP BY' clauses''.
  35828. CREATE FUNCTION:
  35829.           See ``Comment syntax''.
  35830. CREATE INDEX:
  35831.           See ```GRANT' and `REVOKE' syntax''.
  35832. CREATE TABLE:
  35833.           See ```DROP DATABASE' syntax''.
  35834. CROSS JOIN:
  35835.           See ```SELECT' syntax''.
  35836. CURDATE():
  35837.           See ``Date and time functions''.
  35838. CURRENT_DATE:
  35839.           See ``Date and time functions''.
  35840. CURRENT_TIME:
  35841.           See ``Date and time functions''.
  35842. CURRENT_TIMESTAMP:
  35843.           See ``Date and time functions''.
  35844. CURTIME():
  35845.           See ``Date and time functions''.
  35846. CXX environment variable <1>:
  35847.           See ``Problems compiling?''.
  35848. CXX environment variable:
  35849.           See ``Typical `configure' options''.
  35850. CXXFLAGS environment variable <1>:
  35851.           See ``Environment variables''.
  35852. CXXFLAGS environment variable <2>:
  35853.           See ``Problems compiling?''.
  35854. CXXFLAGS environment variable:
  35855.           See ``Typical `configure' options''.
  35856. data_sources() DBI method:
  35857.           See ``The `DBI' interface''.
  35858. DATABASE():
  35859.           See ``Miscellaneous functions''.
  35860. DATE <1>:
  35861.           See ``Y2K issues and date types''.
  35862. DATE:
  35863.           See ``Column types''.
  35864. Date and time functions:
  35865.           See ``String functions''.
  35866. DATE_ADD():
  35867.           See ``Date and time functions''.
  35868. DATE_FORMAT():
  35869.           See ``Date and time functions''.
  35870. DATE_SUB():
  35871.           See ``Date and time functions''.
  35872. DATETIME <1>:
  35873.           See ``Y2K issues and date types''.
  35874. DATETIME:
  35875.           See ``Column types''.
  35876. DAYNAME():
  35877.           See ``Date and time functions''.
  35878. DAYOFMONTH():
  35879.           See ``Date and time functions''.
  35880. DAYOFWEEK():
  35881.           See ``Date and time functions''.
  35882. DAYOFYEAR():
  35883.           See ``Date and time functions''.
  35884. DBI->connect():
  35885.           See ``The `DBI' interface''.
  35886. DBI->data_sources():
  35887.           See ``The `DBI' interface''.
  35888. DBI->disconnect:
  35889.           See ``The `DBI' interface''.
  35890. DBI->do():
  35891.           See ``The `DBI' interface''.
  35892. DBI->execute:
  35893.           See ``The `DBI' interface''.
  35894. DBI->fetchall_arrayref:
  35895.           See ``The `DBI' interface''.
  35896. DBI->fetchrow_array:
  35897.           See ``The `DBI' interface''.
  35898. DBI->fetchrow_arrayref:
  35899.           See ``The `DBI' interface''.
  35900. DBI->fetchrow_hashref:
  35901.           See ``The `DBI' interface''.
  35902. DBI->finish:
  35903.           See ``The `DBI' interface''.
  35904. DBI->prepare():
  35905.           See ``The `DBI' interface''.
  35906. DBI->quote:
  35907.           See ``Strings''.
  35908. DBI->quote():
  35909.           See ``The `DBI' interface''.
  35910. DBI->rows:
  35911.           See ``The `DBI' interface''.
  35912. DBI->trace <1>:
  35913.           See ``Debugging a MySQL server''.
  35914. DBI->trace:
  35915.           See ``The `DBI' interface''.
  35916. DBI->{ChopBlanks}:
  35917.           See ``The `DBI' interface''.
  35918. DBI->{insertid}:
  35919.           See ``The `DBI' interface''.
  35920. DBI->{is_blob}:
  35921.           See ``The `DBI' interface''.
  35922. DBI->{is_key}:
  35923.           See ``The `DBI' interface''.
  35924. DBI->{is_not_null}:
  35925.           See ``The `DBI' interface''.
  35926. DBI->{is_num}:
  35927.           See ``The `DBI' interface''.
  35928. DBI->{is_pri_key}:
  35929.           See ``The `DBI' interface''.
  35930. DBI->{length}:
  35931.           See ``The `DBI' interface''.
  35932. DBI->{max_length}:
  35933.           See ``The `DBI' interface''.
  35934. DBI->{NAME}:
  35935.           See ``The `DBI' interface''.
  35936. DBI->{NULLABLE}:
  35937.           See ``The `DBI' interface''.
  35938. DBI->{NUM_OF_FIELDS}:
  35939.           See ``The `DBI' interface''.
  35940. DBI->{table}:
  35941.           See ``The `DBI' interface''.
  35942. DBI->{type}:
  35943.           See ``The `DBI' interface''.
  35944. DBI_TRACE environment variable <1>:
  35945.           See ``Debugging a MySQL server''.
  35946. DBI_TRACE environment variable <2>:
  35947.           See ``Environment variables''.
  35948. DBI_TRACE environment variable:
  35949.           See ``The `DBI' interface''.
  35950. DBI_USER environment variable:
  35951.           See ``Environment variables''.
  35952. DECIMAL:
  35953.           See ``Column types''.
  35954. DECODE():
  35955.           See ``Miscellaneous functions''.
  35956. DEGREES():
  35957.           See ``Mathematical functions''.
  35958. DELAYED:
  35959.           See ```INSERT' syntax''.
  35960. DELETE:
  35961.           See ```REPAIR TABLE' syntax''.
  35962. DESC:
  35963.           See ```EXPLAIN' syntax (Get information about a `SELECT')''.
  35964. DESCRIBE:
  35965.           See ```EXPLAIN' syntax (Get information about a `SELECT')''.
  35966. disconnect DBI method:
  35967.           See ``The `DBI' interface''.
  35968. DISTINCT <1>:
  35969.           See ``Selecting particular columns''.
  35970. DISTINCT:
  35971.           See ``Functions for use with `GROUP BY' clauses''.
  35972. division (/):
  35973.           See ``Normal arithmetic operations''.
  35974. do() DBI method:
  35975.           See ``The `DBI' interface''.
  35976. DOUBLE:
  35977.           See ``Column types''.
  35978. DOUBLE PRECISION:
  35979.           See ``Column types''.
  35980. double quote (\"):
  35981.           See ``Strings''.
  35982. DROP DATABASE:
  35983.           See ```CREATE DATABASE' syntax''.
  35984. DROP FUNCTION:
  35985.           See ``Comment syntax''.
  35986. DROP INDEX:
  35987.           See ```CREATE INDEX' syntax''.
  35988. DROP TABLE:
  35989.           See ```ALTER TABLE' syntax''.
  35990. DUMPFILE:
  35991.           See ```SELECT' syntax''.
  35992. ELT():
  35993.           See ``String functions''.
  35994. ENCODE():
  35995.           See ``Miscellaneous functions''.
  35996. ENCRYPT():
  35997.           See ``Miscellaneous functions''.
  35998. ENUM <1>:
  35999.           See ``The `BLOB' and `TEXT' types''.
  36000. ENUM:
  36001.           See ``Column types''.
  36002. Environment variable, CC <1>:
  36003.           See ``Environment variables''.
  36004. Environment variable, CC <2>:
  36005.           See ``Problems compiling?''.
  36006. Environment variable, CC:
  36007.           See ``Typical `configure' options''.
  36008. Environment variable, CCX:
  36009.           See ``Environment variables''.
  36010. Environment variable, CFLAGS <1>:
  36011.           See ``Environment variables''.
  36012. Environment variable, CFLAGS:
  36013.           See ``Problems compiling?''.
  36014. Environment variable, CXX <1>:
  36015.           See ``Problems compiling?''.
  36016. Environment variable, CXX:
  36017.           See ``Typical `configure' options''.
  36018. Environment variable, CXXFLAGS <1>:
  36019.           See ``Environment variables''.
  36020. Environment variable, CXXFLAGS <2>:
  36021.           See ``Problems compiling?''.
  36022. Environment variable, CXXFLAGS:
  36023.           See ``Typical `configure' options''.
  36024. Environment variable, DBI_TRACE <1>:
  36025.           See ``Debugging a MySQL server''.
  36026. Environment variable, DBI_TRACE <2>:
  36027.           See ``Environment variables''.
  36028. Environment variable, DBI_TRACE:
  36029.           See ``The `DBI' interface''.
  36030. Environment variable, DBI_USER:
  36031.           See ``Environment variables''.
  36032. Environment variable, HOME <1>:
  36033.           See ``Environment variables''.
  36034. Environment variable, HOME:
  36035.           See ``Overview of the different MySQL programs''.
  36036. Environment variable, LD_RUN_PATH <1>:
  36037.           See ``Environment variables''.
  36038. Environment variable, LD_RUN_PATH <2>:
  36039.           See ``Linux notes (all Linux versions)''.
  36040. Environment variable, LD_RUN_PATH <3>:
  36041.           See ``Solaris notes''.
  36042. Environment variable, LD_RUN_PATH:
  36043.           See ``Problems using the Perl `DBI'/`DBD' interface''.
  36044. Environment variable, MYSQL_DEBUG <1>:
  36045.           See ``Debugging a MySQL client''.
  36046. Environment variable, MYSQL_DEBUG <2>:
  36047.           See ``Environment variables''.
  36048. Environment variable, MYSQL_DEBUG:
  36049.           See ``Overview of the different MySQL programs''.
  36050. Environment variable, MYSQL_HISTFILE <1>:
  36051.           See ``Environment variables''.
  36052. Environment variable, MYSQL_HISTFILE:
  36053.           See ``Overview of the different MySQL programs''.
  36054. Environment variable, MYSQL_HOST <1>:
  36055.           See ``Environment variables''.
  36056. Environment variable, MYSQL_HOST:
  36057.           See ``Connecting to the MySQL server''.
  36058. Environment variable, MYSQL_PWD <1>:
  36059.           See ``Environment variables''.
  36060. Environment variable, MYSQL_PWD <2>:
  36061.           See ``Overview of the different MySQL programs''.
  36062. Environment variable, MYSQL_PWD:
  36063.           See ``Connecting to the MySQL server''.
  36064. Environment variable, MYSQL_TCP_PORT <1>:
  36065.           See ``Environment variables''.
  36066. Environment variable, MYSQL_TCP_PORT <2>:
  36067.           See ``Running multiple MySQL servers on the same machine''.
  36068. Environment variable, MYSQL_TCP_PORT <3>:
  36069.           See ``Overview of the different MySQL programs''.
  36070. Environment variable, MYSQL_TCP_PORT:
  36071.           See ``Problems running `mysql_install_db'''.
  36072. Environment variable, MYSQL_UNIX_PORT <1>:
  36073.           See ``Environment variables''.
  36074. Environment variable, MYSQL_UNIX_PORT <2>:
  36075.           See ``Running multiple MySQL servers on the same machine''.
  36076. Environment variable, MYSQL_UNIX_PORT <3>:
  36077.           See ``Overview of the different MySQL programs''.
  36078. Environment variable, MYSQL_UNIX_PORT:
  36079.           See ``Problems running `mysql_install_db'''.
  36080. Environment variable, PATH <1>:
  36081.           See ``Environment variables''.
  36082. Environment variable, PATH:
  36083.           See ``Installing a MySQL binary distribution''.
  36084. Environment variable, TMPDIR <1>:
  36085.           See ``Environment variables''.
  36086. Environment variable, TMPDIR:
  36087.           See ``Problems running `mysql_install_db'''.
  36088. Environment variable, TZ <1>:
  36089.           See ``Environment variables''.
  36090. Environment variable, TZ:
  36091.           See ``Problems using `DATE' columns''.
  36092. Environment variable, UMASK <1>:
  36093.           See ``Environment variables''.
  36094. Environment variable, UMASK:
  36095.           See ``Problems with file permissions''.
  36096. Environment variable, UMASK_DIR <1>:
  36097.           See ``Environment variables''.
  36098. Environment variable, UMASK_DIR:
  36099.           See ``Problems with file permissions''.
  36100. Environment variable, USER <1>:
  36101.           See ``Environment variables''.
  36102. Environment variable, USER:
  36103.           See ``Connecting to the MySQL server''.
  36104. Environment variables, CXX:
  36105.           See ``Problems compiling?''.
  36106. equal (=):
  36107.           See ``Comparison operators''.
  36108. escape (\\):
  36109.           See ``Strings''.
  36110. execute DBI method:
  36111.           See ``The `DBI' interface''.
  36112. EXP():
  36113.           See ``Mathematical functions''.
  36114. EXPLAIN:
  36115.           See ``SHOW GRANTS (privileges) for a user''.
  36116. EXPORT_SET():
  36117.           See ``String functions''.
  36118. EXTRACT(type FROM date):
  36119.           See ``Date and time functions''.
  36120. fetchall_arrayref DBI method:
  36121.           See ``The `DBI' interface''.
  36122. fetchrow_array DBI method:
  36123.           See ``The `DBI' interface''.
  36124. fetchrow_arrayref DBI method:
  36125.           See ``The `DBI' interface''.
  36126. fetchrow_hashref DBI method:
  36127.           See ``The `DBI' interface''.
  36128. FIELD():
  36129.           See ``String functions''.
  36130. FILE:
  36131.           See ``String functions''.
  36132. FIND_IN_SET():
  36133.           See ``String functions''.
  36134. finish DBI method:
  36135.           See ``The `DBI' interface''.
  36136. FLOAT:
  36137.           See ``Column types''.
  36138. FLOAT(M,D):
  36139.           See ``Column types''.
  36140. FLOAT(precision):
  36141.           See ``Column types''.
  36142. FLOOR():
  36143.           See ``Mathematical functions''.
  36144. FLUSH:
  36145.           See ```USE' syntax''.
  36146. FORMAT():
  36147.           See ``Miscellaneous functions''.
  36148. FROM_DAYS():
  36149.           See ``Date and time functions''.
  36150. FROM_UNIXTIME():
  36151.           See ``Date and time functions''.
  36152. Functions, arithmetic:
  36153.           See ``Normal arithmetic operations''.
  36154. Functions, bit:
  36155.           See ``Normal arithmetic operations''.
  36156. Functions, control flow:
  36157.           See ``Cast operators''.
  36158. Functions, date and time:
  36159.           See ``String functions''.
  36160. Functions, GROUP BY:
  36161.           See ``Miscellaneous functions''.
  36162. Functions, logical:
  36163.           See ``Bit functions''.
  36164. Functions, mathematical:
  36165.           See ``Control flow functions''.
  36166. Functions, miscellaneous:
  36167.           See ``Date and time functions''.
  36168. Functions, string:
  36169.           See ``Mathematical functions''.
  36170. Functions, string comparison:
  36171.           See ``Comparison operators''.
  36172. Functions, user-defined:
  36173.           See ``Comment syntax''.
  36174. GET_LOCK():
  36175.           See ``Miscellaneous functions''.
  36176. GRANT:
  36177.           See ```SET' syntax''.
  36178. greater than (>):
  36179.           See ``Comparison operators''.
  36180. greater than or equal (>=):
  36181.           See ``Comparison operators''.
  36182. GREATEST():
  36183.           See ``Mathematical functions''.
  36184. GROUP BY functions:
  36185.           See ``Miscellaneous functions''.
  36186. HEX():
  36187.           See ``String functions''.
  36188. Hexadecimal values:
  36189.           See ``Numbers''.
  36190. HOME environment variable <1>:
  36191.           See ``Environment variables''.
  36192. HOME environment variable:
  36193.           See ``Overview of the different MySQL programs''.
  36194. host.frm, problems finding:
  36195.           See ``Post-installation setup and testing''.
  36196. HOUR():
  36197.           See ``Date and time functions''.
  36198. IF():
  36199.           See ``Control flow functions''.
  36200. IFNULL():
  36201.           See ``Control flow functions''.
  36202. IN:
  36203.           See ``Comparison operators''.
  36204. INET_ATON():
  36205.           See ``Miscellaneous functions''.
  36206. INET_NTOA():
  36207.           See ``Miscellaneous functions''.
  36208. INNER JOIN:
  36209.           See ```SELECT' syntax''.
  36210. INSERT:
  36211.           See ```JOIN' syntax''.
  36212. INSERT DELAYED:
  36213.           See ```INSERT' syntax''.
  36214. INSERT():
  36215.           See ``String functions''.
  36216. insertid DBI method:
  36217.           See ``The `DBI' interface''.
  36218. INSTR():
  36219.           See ``String functions''.
  36220. INT:
  36221.           See ``Column types''.
  36222. INTEGER:
  36223.           See ``Column types''.
  36224. INTERVAL():
  36225.           See ``Comparison operators''.
  36226. IS NOT NULL:
  36227.           See ``Comparison operators''.
  36228. IS NULL:
  36229.           See ``Comparison operators''.
  36230. IS NULL, and indexes:
  36231.           See ``How *MySQL* uses indexes''.
  36232. is_blob DBI method:
  36233.           See ``The `DBI' interface''.
  36234. is_key DBI method:
  36235.           See ``The `DBI' interface''.
  36236. is_not_null DBI method:
  36237.           See ``The `DBI' interface''.
  36238. is_num DBI method:
  36239.           See ``The `DBI' interface''.
  36240. is_pri_key DBI method:
  36241.           See ``The `DBI' interface''.
  36242. ISNULL():
  36243.           See ``Comparison operators''.
  36244. JOIN:
  36245.           See ```SELECT' syntax''.
  36246. KILL:
  36247.           See ```FLUSH' syntax (clearing caches)''.
  36248. LAST_INSERT_ID():
  36249.           See ``How to cope without `COMMIT'/`ROLLBACK'''.
  36250. LAST_INSERT_ID([expr]):
  36251.           See ``Miscellaneous functions''.
  36252. LCASE():
  36253.           See ``String functions''.
  36254. LD_RUN_PATH environment variable <1>:
  36255.           See ``Environment variables''.
  36256. LD_RUN_PATH environment variable <2>:
  36257.           See ``Linux notes (all Linux versions)''.
  36258. LD_RUN_PATH environment variable <3>:
  36259.           See ``Solaris notes''.
  36260. LD_RUN_PATH environment variable:
  36261.           See ``Problems using the Perl `DBI'/`DBD' interface''.
  36262. LEAST():
  36263.           See ``Mathematical functions''.
  36264. LEFT JOIN:
  36265.           See ```SELECT' syntax''.
  36266. LEFT OUTER JOIN:
  36267.           See ```SELECT' syntax''.
  36268. LEFT():
  36269.           See ``String functions''.
  36270. length DBI method:
  36271.           See ``The `DBI' interface''.
  36272. LENGTH():
  36273.           See ``String functions''.
  36274. less than (<):
  36275.           See ``Comparison operators''.
  36276. less than or equal (<=):
  36277.           See ``Comparison operators''.
  36278. LIKE:
  36279.           See ``String comparison functions''.
  36280. LIKE, and indexes:
  36281.           See ``How *MySQL* uses indexes''.
  36282. LIKE, and wildcards:
  36283.           See ``How *MySQL* uses indexes''.
  36284. LOAD DATA INFILE <1>:
  36285.           See ``Problems with `NULL' values''.
  36286. LOAD DATA INFILE:
  36287.           See ```REPLACE' syntax''.
  36288. LOCATE():
  36289.           See ``String functions''.
  36290. LOCK TABLES:
  36291.           See ```BEGIN/COMMIT/ROLLBACK' syntax''.
  36292. LOG():
  36293.           See ``Mathematical functions''.
  36294. LOG10():
  36295.           See ``Mathematical functions''.
  36296. Logical functions:
  36297.           See ``Bit functions''.
  36298. LONGBLOB:
  36299.           See ``Column types''.
  36300. LONGTEXT:
  36301.           See ``Column types''.
  36302. LOWER():
  36303.           See ``String functions''.
  36304. LPAD():
  36305.           See ``String functions''.
  36306. LTRIM():
  36307.           See ``String functions''.
  36308. MAKE_SET():
  36309.           See ``String functions''.
  36310. Mathematical functions:
  36311.           See ``Control flow functions''.
  36312. MAX():
  36313.           See ``Functions for use with `GROUP BY' clauses''.
  36314. max_length DBI method:
  36315.           See ``The `DBI' interface''.
  36316. MD5():
  36317.           See ``Miscellaneous functions''.
  36318. MEDIUMBLOB:
  36319.           See ``Column types''.
  36320. MEDIUMINT:
  36321.           See ``Column types''.
  36322. MEDIUMTEXT:
  36323.           See ``Column types''.
  36324. MID():
  36325.           See ``String functions''.
  36326. MIN():
  36327.           See ``Functions for use with `GROUP BY' clauses''.
  36328. minus, unary (-):
  36329.           See ``Mathematical functions''.
  36330. MINUTE():
  36331.           See ``Date and time functions''.
  36332. Miscellaneous functions:
  36333.           See ``Date and time functions''.
  36334. MOD():
  36335.           See ``Mathematical functions''.
  36336. modulo (%):
  36337.           See ``Mathematical functions''.
  36338. MONTH():
  36339.           See ``Date and time functions''.
  36340. MONTHNAME():
  36341.           See ``Date and time functions''.
  36342. multiplication (*):
  36343.           See ``Normal arithmetic operations''.
  36344. my_ulonglong C type:
  36345.           See ``C API datatypes''.
  36346. my_ulonglong values, printing:
  36347.           See ``C API datatypes''.
  36348. MYSQL C type:
  36349.           See ``C API datatypes''.
  36350. mysql_affected_rows():
  36351.           See ``C API function descriptions''.
  36352. mysql_change_user():
  36353.           See ```mysql_connect()'''.
  36354. mysql_character_set_name():
  36355.           See ```mysql_change_user()'''.
  36356. mysql_close():
  36357.           See ```mysql_affected_rows()'''.
  36358. mysql_connect():
  36359.           See ```mysql_close()'''.
  36360. mysql_create_db():
  36361.           See ```mysql_character_set_name()'''.
  36362. mysql_data_seek():
  36363.           See ```mysql_create_db()'''.
  36364. MYSQL_DEBUG environment variable <1>:
  36365.           See ``Debugging a MySQL client''.
  36366. MYSQL_DEBUG environment variable <2>:
  36367.           See ``Environment variables''.
  36368. MYSQL_DEBUG environment variable:
  36369.           See ``Overview of the different MySQL programs''.
  36370. mysql_debug():
  36371.           See ```mysql_data_seek()'''.
  36372. mysql_drop_db():
  36373.           See ```mysql_debug()'''.
  36374. mysql_dump_debug_info():
  36375.           See ```mysql_drop_db()'''.
  36376. mysql_eof():
  36377.           See ```mysql_dump_debug_info()'''.
  36378. mysql_errno():
  36379.           See ```mysql_eof()'''.
  36380. mysql_error():
  36381.           See ```mysql_errno()'''.
  36382. mysql_escape_string() <1>:
  36383.           See ```mysql_error()'''.
  36384. mysql_escape_string():
  36385.           See ``Strings''.
  36386. mysql_fetch_field():
  36387.           See ```mysql_escape_string()'''.
  36388. mysql_fetch_field_direct():
  36389.           See ```mysql_fetch_fields()'''.
  36390. mysql_fetch_fields():
  36391.           See ```mysql_fetch_field()'''.
  36392. mysql_fetch_lengths():
  36393.           See ```mysql_fetch_field_direct()'''.
  36394. mysql_fetch_row():
  36395.           See ```mysql_fetch_lengths()'''.
  36396. MYSQL_FIELD C type:
  36397.           See ``C API datatypes''.
  36398. mysql_field_count() <1>:
  36399.           See ```mysql_list_tables()'''.
  36400. mysql_field_count():
  36401.           See ```mysql_fetch_row()'''.
  36402. MYSQL_FIELD_OFFSET C type:
  36403.           See ``C API datatypes''.
  36404. mysql_field_seek():
  36405.           See ```mysql_field_count()'''.
  36406. mysql_field_tell():
  36407.           See ```mysql_field_seek()'''.
  36408. mysql_free_result():
  36409.           See ```mysql_field_tell()'''.
  36410. mysql_get_client_info():
  36411.           See ```mysql_free_result()'''.
  36412. mysql_get_host_info():
  36413.           See ```mysql_get_client_info()'''.
  36414. mysql_get_proto_info():
  36415.           See ```mysql_get_host_info()'''.
  36416. mysql_get_server_info():
  36417.           See ```mysql_get_proto_info()'''.
  36418. MYSQL_HISTFILE environment variable <1>:
  36419.           See ``Environment variables''.
  36420. MYSQL_HISTFILE environment variable:
  36421.           See ``Overview of the different MySQL programs''.
  36422. MYSQL_HOST environment variable <1>:
  36423.           See ``Environment variables''.
  36424. MYSQL_HOST environment variable:
  36425.           See ``Connecting to the MySQL server''.
  36426. mysql_info() <1>:
  36427.           See ```mysql_get_server_info()'''.
  36428. mysql_info() <2>:
  36429.           See ```UPDATE' syntax''.
  36430. mysql_info() <3>:
  36431.           See ```LOAD DATA INFILE' syntax''.
  36432. mysql_info() <4>:
  36433.           See ```INSERT' syntax''.
  36434. mysql_info():
  36435.           See ```ALTER TABLE' syntax''.
  36436. mysql_init():
  36437.           See ```mysql_info()'''.
  36438. mysql_insert_id() <1>:
  36439.           See ```mysql_init()'''.
  36440. mysql_insert_id():
  36441.           See ``How to cope without `COMMIT'/`ROLLBACK'''.
  36442. mysql_kill():
  36443.           See ```mysql_insert_id()'''.
  36444. mysql_list_dbs():
  36445.           See ```mysql_kill()'''.
  36446. mysql_list_fields():
  36447.           See ```mysql_list_dbs()'''.
  36448. mysql_list_processes():
  36449.           See ```mysql_list_fields()'''.
  36450. mysql_list_tables():
  36451.           See ```mysql_list_processes()'''.
  36452. mysql_num_fields():
  36453.           See ```mysql_list_tables()'''.
  36454. mysql_num_rows():
  36455.           See ```mysql_num_fields()'''.
  36456. mysql_options():
  36457.           See ```mysql_num_rows()'''.
  36458. mysql_ping():
  36459.           See ```mysql_options()'''.
  36460. MYSQL_PWD environment variable <1>:
  36461.           See ``Environment variables''.
  36462. MYSQL_PWD environment variable <2>:
  36463.           See ``Overview of the different MySQL programs''.
  36464. MYSQL_PWD environment variable:
  36465.           See ``Connecting to the MySQL server''.
  36466. mysql_query():
  36467.           See ```mysql_ping()'''.
  36468. mysql_real_connect():
  36469.           See ```mysql_query()'''.
  36470. mysql_real_escape_string():
  36471.           See ```mysql_real_connect()'''.
  36472. mysql_real_query():
  36473.           See ```mysql_real_escape_string()'''.
  36474. mysql_reload():
  36475.           See ```mysql_real_query()'''.
  36476. MYSQL_RES C type:
  36477.           See ``C API datatypes''.
  36478. MYSQL_ROW C type:
  36479.           See ``C API datatypes''.
  36480. mysql_row_seek():
  36481.           See ```mysql_reload()'''.
  36482. mysql_row_tell():
  36483.           See ```mysql_row_seek()'''.
  36484. mysql_select_db():
  36485.           See ```mysql_row_tell()'''.
  36486. mysql_shutdown():
  36487.           See ```mysql_select_db()'''.
  36488. mysql_stat():
  36489.           See ```mysql_shutdown()'''.
  36490. mysql_store_result():
  36491.           See ```mysql_stat()'''.
  36492. MYSQL_TCP_PORT environment variable <1>:
  36493.           See ``Environment variables''.
  36494. MYSQL_TCP_PORT environment variable <2>:
  36495.           See ``Running multiple MySQL servers on the same machine''.
  36496. MYSQL_TCP_PORT environment variable <3>:
  36497.           See ``Overview of the different MySQL programs''.
  36498. MYSQL_TCP_PORT environment variable:
  36499.           See ``Problems running `mysql_install_db'''.
  36500. mysql_thread_id():
  36501.           See ```mysql_store_result()'''.
  36502. MYSQL_UNIX_PORT environment variable <1>:
  36503.           See ``Environment variables''.
  36504. MYSQL_UNIX_PORT environment variable <2>:
  36505.           See ``Running multiple MySQL servers on the same machine''.
  36506. MYSQL_UNIX_PORT environment variable <3>:
  36507.           See ``Overview of the different MySQL programs''.
  36508. MYSQL_UNIX_PORT environment variable:
  36509.           See ``Problems running `mysql_install_db'''.
  36510. mysql_use_result():
  36511.           See ```mysql_thread_id()'''.
  36512. NAME DBI method:
  36513.           See ``The `DBI' interface''.
  36514. NATIONAL CHAR:
  36515.           See ``Column types''.
  36516. NATURAL LEFT JOIN:
  36517.           See ```SELECT' syntax''.
  36518. NATURAL LEFT OUTER JOIN:
  36519.           See ```SELECT' syntax''.
  36520. NCHAR:
  36521.           See ``Column types''.
  36522. newline (\n):
  36523.           See ``Strings''.
  36524. not equal (!=):
  36525.           See ``Comparison operators''.
  36526. not equal (<>):
  36527.           See ``Comparison operators''.
  36528. NOT IN:
  36529.           See ``Comparison operators''.
  36530. NOT LIKE:
  36531.           See ``String comparison functions''.
  36532. NOT REGEXP:
  36533.           See ``String comparison functions''.
  36534. NOT, logical:
  36535.           See ``Logical operations''.
  36536. NOW():
  36537.           See ``Date and time functions''.
  36538. NUL:
  36539.           See ``Strings''.
  36540. NULL:
  36541.           See ``Case sensitivity in searches''.
  36542. NULL value:
  36543.           See ``Hexadecimal values''.
  36544. NULLABLE DBI method:
  36545.           See ``The `DBI' interface''.
  36546. NULLIF():
  36547.           See ``Control flow functions''.
  36548. NUM_OF_FIELDS DBI method:
  36549.           See ``The `DBI' interface''.
  36550. NUMERIC:
  36551.           See ``Column types''.
  36552. OCT():
  36553.           See ``String functions''.
  36554. OCTET_LENGTH():
  36555.           See ``String functions''.
  36556. OPTIMIZE TABLE:
  36557.           See ```DROP TABLE' syntax''.
  36558. OR, bitwise:
  36559.           See ``Bit functions''.
  36560. OR, logical:
  36561.           See ``Logical operations''.
  36562. ORD():
  36563.           See ``String functions''.
  36564. parentheses ( and ):
  36565.           See ``Grouping functions''.
  36566. PASSWORD() <1>:
  36567.           See ```Ignoring user' error''.
  36568. PASSWORD() <2>:
  36569.           See ``Miscellaneous functions''.
  36570. PASSWORD() <3>:
  36571.           See ``How to set up passwords''.
  36572. PASSWORD():
  36573.           See ``Access control, stage 1: Connection verification''.
  36574. PATH environment variable <1>:
  36575.           See ``Environment variables''.
  36576. PATH environment variable:
  36577.           See ``Installing a MySQL binary distribution''.
  36578. PERIOD_ADD():
  36579.           See ``Date and time functions''.
  36580. PERIOD_DIFF():
  36581.           See ``Date and time functions''.
  36582. PI():
  36583.           See ``Mathematical functions''.
  36584. POSITION():
  36585.           See ``String functions''.
  36586. POW():
  36587.           See ``Mathematical functions''.
  36588. POWER():
  36589.           See ``Mathematical functions''.
  36590. prepare() DBI method:
  36591.           See ``The `DBI' interface''.
  36592. PROCESSLIST:
  36593.           See ``SHOW VARIABLES''.
  36594. QUARTER():
  36595.           See ``Date and time functions''.
  36596. quote() DBI method:
  36597.           See ``The `DBI' interface''.
  36598. Quoting of identifiers:
  36599.           See ``Database, table, index, column and alias names''.
  36600. RADIANS():
  36601.           See ``Mathematical functions''.
  36602. RAND():
  36603.           See ``Mathematical functions''.
  36604. REAL:
  36605.           See ``Column types''.
  36606. REGEXP:
  36607.           See ``String comparison functions''.
  36608. RELEASE_LOCK():
  36609.           See ``Miscellaneous functions''.
  36610. REPAIR TABLE:
  36611.           See ```ANALYZE TABLE' syntax''.
  36612. REPEAT():
  36613.           See ``String functions''.
  36614. REPLACE:
  36615.           See ```INSERT' syntax''.
  36616. REPLACE():
  36617.           See ``String functions''.
  36618. return (\r):
  36619.           See ``Strings''.
  36620. REVERSE():
  36621.           See ``String functions''.
  36622. REVOKE:
  36623.           See ```SET' syntax''.
  36624. RIGHT():
  36625.           See ``String functions''.
  36626. RLIKE:
  36627.           See ``String comparison functions''.
  36628. ROLLBACK:
  36629.           See ```DESCRIBE' syntax (Get information about columns)''.
  36630. ROUND():
  36631.           See ``Mathematical functions''.
  36632. rows DBI method:
  36633.           See ``The `DBI' interface''.
  36634. RPAD():
  36635.           See ``String functions''.
  36636. RTRIM():
  36637.           See ``String functions''.
  36638. SEC_TO_TIME():
  36639.           See ``Date and time functions''.
  36640. SECOND():
  36641.           See ``Date and time functions''.
  36642. SELECT:
  36643.           See ```DELETE' syntax''.
  36644. SELECT, optimizing:
  36645.           See ``SHOW GRANTS (privileges) for a user''.
  36646. SESSION_USER():
  36647.           See ``Miscellaneous functions''.
  36648. SET <1>:
  36649.           See ``The `ENUM' type''.
  36650. SET:
  36651.           See ``Column types''.
  36652. SET OPTION:
  36653.           See ```LOCK TABLES/UNLOCK TABLES' syntax''.
  36654. SHOW COLUMNS <1>:
  36655.           See ```SHOW' syntax (Get information about tables, columns,...)''.
  36656. SHOW COLUMNS:
  36657.           See ```KILL' syntax''.
  36658. SHOW DATABASES <1>:
  36659.           See ```SHOW' syntax (Get information about tables, columns,...)''.
  36660. SHOW DATABASES:
  36661.           See ```KILL' syntax''.
  36662. SHOW FIELDS <1>:
  36663.           See ```SHOW' syntax (Get information about tables, columns,...)''.
  36664. SHOW FIELDS:
  36665.           See ```KILL' syntax''.
  36666. SHOW GRANTS:
  36667.           See ```KILL' syntax''.
  36668. SHOW INDEX <1>:
  36669.           See ```SHOW' syntax (Get information about tables, columns,...)''.
  36670. SHOW INDEX:
  36671.           See ```KILL' syntax''.
  36672. SHOW KEYS <1>:
  36673.           See ```SHOW' syntax (Get information about tables, columns,...)''.
  36674. SHOW KEYS:
  36675.           See ```KILL' syntax''.
  36676. SHOW PROCESSLIST:
  36677.           See ```KILL' syntax''.
  36678. SHOW STATUS:
  36679.           See ```KILL' syntax''.
  36680. SHOW TABLE STATUS:
  36681.           See ```KILL' syntax''.
  36682. SHOW TABLES <1>:
  36683.           See ```SHOW' syntax (Get information about tables, columns,...)''.
  36684. SHOW TABLES:
  36685.           See ```KILL' syntax''.
  36686. SHOW VARIABLES:
  36687.           See ```KILL' syntax''.
  36688. SIGN():
  36689.           See ``Mathematical functions''.
  36690. SIN():
  36691.           See ``Mathematical functions''.
  36692. single quote (\'):
  36693.           See ``Strings''.
  36694. SMALLINT:
  36695.           See ``Column types''.
  36696. SOUNDEX():
  36697.           See ``String functions''.
  36698. SPACE():
  36699.           See ``String functions''.
  36700. SQRT():
  36701.           See ``Mathematical functions''.
  36702. STD():
  36703.           See ``Functions for use with `GROUP BY' clauses''.
  36704. STDDEV():
  36705.           See ``Functions for use with `GROUP BY' clauses''.
  36706. STRAIGHT_JOIN:
  36707.           See ```SELECT' syntax''.
  36708. STRCMP():
  36709.           See ``String comparison functions''.
  36710. String comparison functions:
  36711.           See ``Comparison operators''.
  36712. String functions:
  36713.           See ``Mathematical functions''.
  36714. SUBDATE():
  36715.           See ``Date and time functions''.
  36716. SUBSTRING():
  36717.           See ``String functions''.
  36718. SUBSTRING_INDEX():
  36719.           See ``String functions''.
  36720. subtraction (-):
  36721.           See ``Normal arithmetic operations''.
  36722. SUM():
  36723.           See ``Functions for use with `GROUP BY' clauses''.
  36724. Symbolic links:
  36725.           See ``Connecting to a remote MySQL from Win32 with SSH''.
  36726. SYSDATE():
  36727.           See ``Date and time functions''.
  36728. SYSTEM_USER():
  36729.           See ``Miscellaneous functions''.
  36730. tab (\t):
  36731.           See ``Strings''.
  36732. table DBI method:
  36733.           See ``The `DBI' interface''.
  36734. table_cache:
  36735.           See ``Tuning server parameters''.
  36736. TAN():
  36737.           See ``Mathematical functions''.
  36738. TEXT <1>:
  36739.           See ``The `CHAR' and `VARCHAR' types''.
  36740. TEXT:
  36741.           See ``Column types''.
  36742. Threads:
  36743.           See ``SHOW VARIABLES''.
  36744. TIME <1>:
  36745.           See ``The `DATETIME', `DATE' and `TIMESTAMP' types''.
  36746. TIME:
  36747.           See ``Column types''.
  36748. TIME_FORMAT():
  36749.           See ``Date and time functions''.
  36750. TIME_TO_SEC():
  36751.           See ``Date and time functions''.
  36752. TIMESTAMP <1>:
  36753.           See ``Y2K issues and date types''.
  36754. TIMESTAMP:
  36755.           See ``Column types''.
  36756. TINYBLOB:
  36757.           See ``Column types''.
  36758. TINYINT:
  36759.           See ``Column types''.
  36760. TINYTEXT:
  36761.           See ``Column types''.
  36762. TMPDIR environment variable <1>:
  36763.           See ``Environment variables''.
  36764. TMPDIR environment variable:
  36765.           See ``Problems running `mysql_install_db'''.
  36766. TO_DAYS():
  36767.           See ``Date and time functions''.
  36768. trace DBI method <1>:
  36769.           See ``Debugging a MySQL server''.
  36770. trace DBI method:
  36771.           See ``The `DBI' interface''.
  36772. TRIM():
  36773.           See ``String functions''.
  36774. TRUNCATE():
  36775.           See ``Mathematical functions''.
  36776. type DBI method:
  36777.           See ``The `DBI' interface''.
  36778. Types:
  36779.           See ``Column types''.
  36780. TZ environment variable <1>:
  36781.           See ``Environment variables''.
  36782. TZ environment variable:
  36783.           See ``Problems using `DATE' columns''.
  36784. UCASE():
  36785.           See ``String functions''.
  36786. UDF functions:
  36787.           See ``Comment syntax''.
  36788. ulimit:
  36789.           See ``File not found''.
  36790. UMASK environment variable <1>:
  36791.           See ``Environment variables''.
  36792. UMASK environment variable:
  36793.           See ``Problems with file permissions''.
  36794. UMASK_DIR environment variable <1>:
  36795.           See ``Environment variables''.
  36796. UMASK_DIR environment variable:
  36797.           See ``Problems with file permissions''.
  36798. unary minus (-):
  36799.           See ``Mathematical functions''.
  36800. UNION:
  36801.           See ``Using foreign keys''.
  36802. UNIX_TIMESTAMP():
  36803.           See ``Date and time functions''.
  36804. UNLOCK TABLES:
  36805.           See ```BEGIN/COMMIT/ROLLBACK' syntax''.
  36806. UPDATE:
  36807.           See ```LOAD DATA INFILE' syntax''.
  36808. UPPER():
  36809.           See ``String functions''.
  36810. USE:
  36811.           See ```UPDATE' syntax''.
  36812. USER environment variable <1>:
  36813.           See ``Environment variables''.
  36814. USER environment variable:
  36815.           See ``Connecting to the MySQL server''.
  36816. USER():
  36817.           See ``Miscellaneous functions''.
  36818. User-defined functions:
  36819.           See ``Comment syntax''.
  36820. Using multiple disks to start data:
  36821.           See ``Connecting to a remote MySQL from Win32 with SSH''.
  36822. VARCHAR <1>:
  36823.           See ``String types''.
  36824. VARCHAR:
  36825.           See ``Column types''.
  36826. VERSION():
  36827.           See ``Miscellaneous functions''.
  36828. WEEK():
  36829.           See ``Date and time functions''.
  36830. WEEKDAY():
  36831.           See ``Date and time functions''.
  36832. Wildcard character (%):
  36833.           See ``Strings''.
  36834. Wildcard character (_):
  36835.           See ``Strings''.
  36836. YEAR <1>:
  36837.           See ``The `TIME' type''.
  36838. YEAR:
  36839.           See ``Column types''.
  36840. YEAR():
  36841.           See ``Date and time functions''.
  36842. | (bitwise OR):
  36843.           See ``Bit functions''.
  36844. || (logical OR):
  36845.           See ``Logical operations''.
  36846. ~:
  36847.           See ``Bit functions''.
  36848. Concept Index
  36849. *************
  36850.  
  36851. *MySQL* binary distribution:
  36852.           See ``Operating systems supported by MySQL''.
  36853. *MySQL* mailing lists:
  36854.           See ``Useful MySQL-related links''.
  36855. *MySQL* source distribution:
  36856.           See ``Operating systems supported by MySQL''.
  36857. *MySQL* version <1>:
  36858.           See ``Installing MySQL''.
  36859. *MySQL* version:
  36860.           See ``Conventions used in this manual''.
  36861. *MySQL*, how to pronounce:
  36862.           See ``What is MySQL''.
  36863. *MySQL*, what it is:
  36864.           See ``General Information about MySQL''.
  36865. Aborted connection:
  36866.           See ```Packet too large' error''.
  36867. Adding native functions:
  36868.           See ``Compiling and installing user-definable functions''.
  36869. Adding user-definable functions:
  36870.           See ``Adding new functions to MySQL''.
  36871. Alias names, case sensitivity:
  36872.           See ``Case sensitivity in names''.
  36873. Aliases, for expressions:
  36874.           See ``Functions for use with `GROUP BY' clauses''.
  36875. Aliases, for tables:
  36876.           See ```SELECT' syntax''.
  36877. Aliases, in GROUP BY clauses:
  36878.           See ``Functions for use with `GROUP BY' clauses''.
  36879. Aliases, in ORDER BY clauses:
  36880.           See ``Functions for use with `GROUP BY' clauses''.
  36881. Aliases, on expressions:
  36882.           See ```SELECT' syntax''.
  36883. Anonymous user <1>:
  36884.           See ``Setting up the initial MySQL privileges''.
  36885. Anonymous user <2>:
  36886.           See ``Access control, stage 2: Request verification''.
  36887. Anonymous user:
  36888.           See ``Access control, stage 1: Connection verification''.
  36889. ANSI SQL, differences from:
  36890.           See ```GRANT' and `REVOKE' syntax''.
  36891. Arithmetic expressions:
  36892.           See ``Normal arithmetic operations''.
  36893. AUTO_INCREMENT, and NULL values:
  36894.           See ``Problems with `NULL' values''.
  36895. Backups:
  36896.           See ``Database replication with update log''.
  36897. BDB table type:
  36898.           See ``Is MySQL picky about reserved words?''.
  36899. Berkeley_db table type:
  36900.           See ``Is MySQL picky about reserved words?''.
  36901. Big5 Chinese character encoding:
  36902.           See ``Timezone problems''.
  36903. BLOB columns, default values:
  36904.           See ``The `BLOB' and `TEXT' types''.
  36905. BLOB columns, indexing:
  36906.           See ```CREATE TABLE' syntax''.
  36907. BLOB, inserting binary data:
  36908.           See ``Strings''.
  36909. Bug reports:
  36910.           See ``Asking questions or reporting bugs''.
  36911. C++ compiler cannot create executables:
  36912.           See ``Problems compiling?''.
  36913. Case sensitivity, in access checking:
  36914.           See ``How the privilege system works''.
  36915. Case sensitivity, in searches:
  36916.           See ``Timezone problems''.
  36917. Case sensitivity, in string comparisons:
  36918.           See ``String comparison functions''.
  36919. Case sensitivity, of alias names:
  36920.           See ``Case sensitivity in names''.
  36921. Case sensitivity, of column names:
  36922.           See ``Case sensitivity in names''.
  36923. Case sensitivity, of database names <1>:
  36924.           See ``Case sensitivity in names''.
  36925. Case sensitivity, of database names:
  36926.           See ``MySQL extensions to ANSI SQL92''.
  36927. Case sensitivity, of table names <1>:
  36928.           See ``Case sensitivity in names''.
  36929. Case sensitivity, of table names:
  36930.           See ``MySQL extensions to ANSI SQL92''.
  36931. Casts:
  36932.           See ``Logical operations''.
  36933. cc1plus problems:
  36934.           See ``Problems compiling?''.
  36935. Checking tables for errors:
  36936.           See ``Using `myisamchk' for crash recovery''.
  36937. Chinese:
  36938.           See ``Timezone problems''.
  36939. Choosing types:
  36940.           See ``The `SET' type''.
  36941. Choosing version:
  36942.           See ``Operating systems supported by MySQL''.
  36943. Client programs, building:
  36944.           See ``Linux RPM notes''.
  36945. Column names, case sensitivity:
  36946.           See ``Case sensitivity in names''.
  36947. Command line history:
  36948.           See ``Overview of the different MySQL programs''.
  36949. Command-line options:
  36950.           See ``Starting and stopping MySQL automatically''.
  36951. Commands out of sync:
  36952.           See ```The table is full' error''.
  36953. Compatibility, between MySQL versions <1>:
  36954.           See ``Upgrading from a 3.22 version to 3.23''.
  36955. Compatibility, between MySQL versions:
  36956.           See ``Is there anything special to do when upgrading/downgrading MySQL?''.
  36957. Compatibility, with ANSI SQL:
  36958.           See ``Upgrading to another architecture''.
  36959. Compatibility, with mSQL:
  36960.           See ``String comparison functions''.
  36961. Compatibility, with ODBC <1>:
  36962.           See ``Changes in release 3.21.15''.
  36963. Compatibility, with ODBC <2>:
  36964.           See ```JOIN' syntax''.
  36965. Compatibility, with ODBC <3>:
  36966.           See ```CREATE TABLE' syntax''.
  36967. Compatibility, with ODBC <4>:
  36968.           See ``Comparison operators''.
  36969. Compatibility, with ODBC <5>:
  36970.           See ``Column types''.
  36971. Compatibility, with ODBC:
  36972.           See ``Database, table, index, column and alias names''.
  36973. Compatibility, with Oracle <1>:
  36974.           See ```DESCRIBE' syntax (Get information about columns)''.
  36975. Compatibility, with Oracle <2>:
  36976.           See ``Functions for use with `GROUP BY' clauses''.
  36977. Compatibility, with Oracle:
  36978.           See ``MySQL extensions to ANSI SQL92''.
  36979. Compatibility, with PostgreSQL:
  36980.           See ``MySQL extensions to ANSI SQL92''.
  36981. Compatibility, with Sybase:
  36982.           See ```USE' syntax''.
  36983. Configuration files:
  36984.           See ``Causes of `Access denied' errors''.
  36985. configure, running after prior invocation:
  36986.           See ``Problems compiling?''.
  36987. Constant table <1>:
  36988.           See ``How MySQL optimizes `WHERE' clauses''.
  36989. Constant table:
  36990.           See ```EXPLAIN' syntax (Get information about a `SELECT')''.
  36991. Contact information:
  36992.           See ``Payment information''.
  36993. Copyright:
  36994.           See ``MySQL licensing policy''.
  36995. Costs, licensing and support:
  36996.           See ``Running a web server using *MySQL*''.
  36997. Database mirroring:
  36998.           See ``The update log''.
  36999. Database names, case sensitivity <1>:
  37000.           See ``Case sensitivity in names''.
  37001. Database names, case sensitivity:
  37002.           See ``MySQL extensions to ANSI SQL92''.
  37003. Database replication <1>:
  37004.           See ``The update log''.
  37005. Database replication:
  37006.           See ``Solving some common problems with MySQL''.
  37007. Date and Time types:
  37008.           See ``Numeric types''.
  37009. db table, sorting:
  37010.           See ``Access control, stage 2: Request verification''.
  37011. DBI Perl module:
  37012.           See ```DBI' with `DBD::mysql'''.
  37013. Default options:
  37014.           See ``Command-line options''.
  37015. Default values, BLOB and TEXT columns:
  37016.           See ``The `BLOB' and `TEXT' types''.
  37017. Disk full:
  37018.           See ```Table 'xxx' doesn't exist' error''.
  37019. Downloading:
  37020.           See ``Installing MySQL''.
  37021. Environment variables <1>:
  37022.           See ``MySQL Utilites''.
  37023. Environment variables <2>:
  37024.           See ``Causes of `Access denied' errors''.
  37025. Environment variables:
  37026.           See ``Option files''.
  37027. Expression aliases:
  37028.           See ```SELECT' syntax''.
  37029. Expressions, aliases for:
  37030.           See ``Functions for use with `GROUP BY' clauses''.
  37031. fatal signal 11:
  37032.           See ``Problems compiling?''.
  37033. Foreign keys:
  37034.           See ```ALTER TABLE' syntax''.
  37035. FreeBSD troubleshooting:
  37036.           See ``Problems compiling?''.
  37037. Full disk:
  37038.           See ```Table 'xxx' doesn't exist' error''.
  37039. Functions for SELECT and WHERE clauses:
  37040.           See ``Using column types from other database engines''.
  37041. Functions, native, adding:
  37042.           See ``Compiling and installing user-definable functions''.
  37043. Functions, user-definable, adding:
  37044.           See ``Adding new functions to MySQL''.
  37045. General Information: See node Top.
  37046. Getting *MySQL*:
  37047.           See ``Installing MySQL''.
  37048. Grant tables, sorting <1>:
  37049.           See ``Access control, stage 2: Request verification''.
  37050. Grant tables, sorting:
  37051.           See ``Access control, stage 1: Connection verification''.
  37052. GROUP BY, aliases in:
  37053.           See ``Functions for use with `GROUP BY' clauses''.
  37054. Grouping of expressions:
  37055.           See ``Grouping functions''.
  37056. HEAP table type:
  37057.           See ``Is MySQL picky about reserved words?''.
  37058. History file:
  37059.           See ``Overview of the different MySQL programs''.
  37060. host table, sorting:
  37061.           See ``Access control, stage 2: Request verification''.
  37062. How to pronounce *MySQL*:
  37063.           See ``What is MySQL''.
  37064. Indexes <1>:
  37065.           See ```GRANT' and `REVOKE' syntax''.
  37066. Indexes:
  37067.           See ``Choosing the right type for a column''.
  37068. Indexes, and BLOB columns:
  37069.           See ```CREATE TABLE' syntax''.
  37070. Indexes, and IS NULL:
  37071.           See ``How *MySQL* uses indexes''.
  37072. Indexes, and LIKE:
  37073.           See ``How *MySQL* uses indexes''.
  37074. Indexes, and NULL values:
  37075.           See ```CREATE TABLE' syntax''.
  37076. Indexes, and TEXT columns:
  37077.           See ```CREATE TABLE' syntax''.
  37078. Indexes, leftmost prefix of:
  37079.           See ``How *MySQL* uses indexes''.
  37080. Indexes, multi-part:
  37081.           See ```GRANT' and `REVOKE' syntax''.
  37082. Internal compiler errors:
  37083.           See ``Problems compiling?''.
  37084. ISAM table type:
  37085.           See ``Is MySQL picky about reserved words?''.
  37086. Keys:
  37087.           See ``Choosing the right type for a column''.
  37088. Keywords:
  37089.           See ```CREATE FUNCTION/DROP FUNCTION' syntax''.
  37090. Language support:
  37091.           See ``MySQL server functions''.
  37092. Leftmost prefix of indexes:
  37093.           See ``How *MySQL* uses indexes''.
  37094. Licensing costs:
  37095.           See ``Running a web server using *MySQL*''.
  37096. Licensing policy:
  37097.           See ``MySQL licensing and support''.
  37098. Licensing terms:
  37099.           See ``Guidelines for answering questions on the mailing list''.
  37100. Linking:
  37101.           See ``Linux RPM notes''.
  37102. Log file, names:
  37103.           See ``Database backups''.
  37104. make_binary_distribution:
  37105.           See ``Overview of the different MySQL programs''.
  37106. Manual information:
  37107.           See ``What is MySQL''.
  37108. Memory use:
  37109.           See ``Why so many open tables?''.
  37110. Mirroring, database:
  37111.           See ``The update log''.
  37112. mSQL compatibility:
  37113.           See ``String comparison functions''.
  37114. msql2mysql:
  37115.           See ``Overview of the different MySQL programs''.
  37116. Multi-byte characters:
  37117.           See ``String collating support''.
  37118. Multi-part index:
  37119.           See ```GRANT' and `REVOKE' syntax''.
  37120. Multiple servers:
  37121.           See ``The update log''.
  37122. MyISAM table type:
  37123.           See ``Is MySQL picky about reserved words?''.
  37124. myisamchk <1>:
  37125.           See ``Overview of the different MySQL programs''.
  37126. myisamchk:
  37127.           See ``Typical `configure' options''.
  37128. myisampack <1>:
  37129.           See ``Showing databases, tables and columns''.
  37130. myisampack <2>:
  37131.           See ``Silent column specification changes''.
  37132. myisampack:
  37133.           See ``Basic email support''.
  37134. MyODBC:
  37135.           See ``Writing a procedure.''.
  37136. mysql:
  37137.           See ``Overview of the different MySQL programs''.
  37138. MySQL table types:
  37139.           See ``Is MySQL picky about reserved words?''.
  37140. mysql_fix_privilege_tables:
  37141.           See ``Causes of `Access denied' errors''.
  37142. mysql_install_db:
  37143.           See ``Overview of the different MySQL programs''.
  37144. mysqlaccess:
  37145.           See ``Overview of the different MySQL programs''.
  37146. mysqladmin <1>:
  37147.           See ``Overview of the different MySQL programs''.
  37148. mysqladmin <2>:
  37149.           See ``SHOW status information''.
  37150. mysqladmin <3>:
  37151.           See ```FLUSH' syntax (clearing caches)''.
  37152. mysqladmin <4>:
  37153.           See ```USE' syntax''.
  37154. mysqladmin <5>:
  37155.           See ```DROP DATABASE' syntax''.
  37156. mysqladmin:
  37157.           See ```CREATE DATABASE' syntax''.
  37158. mysqlbug:
  37159.           See ``Overview of the different MySQL programs''.
  37160. mysqld:
  37161.           See ``Overview of the different MySQL programs''.
  37162. mysqldump <1>:
  37163.           See ``Overview of the different MySQL programs''.
  37164. mysqldump:
  37165.           See ``Upgrading to another architecture''.
  37166. mysqlimport <1>:
  37167.           See ``Overview of the different MySQL programs''.
  37168. mysqlimport <2>:
  37169.           See ```LOAD DATA INFILE' syntax''.
  37170. mysqlimport:
  37171.           See ``Upgrading to another architecture''.
  37172. mysqlshow:
  37173.           See ``Overview of the different MySQL programs''.
  37174. Native functions, adding:
  37175.           See ``Compiling and installing user-definable functions''.
  37176. Net etiquette <1>:
  37177.           See ``How to report bugs or problems''.
  37178. Net etiquette:
  37179.           See ``The MySQL mailing lists''.
  37180. Netmask notation, in mysql.user table:
  37181.           See ``Access control, stage 1: Connection verification''.
  37182. NULL values vs. empty values:
  37183.           See ``Case sensitivity in searches''.
  37184. NULL values, and AUTO_INCREMENT columns:
  37185.           See ``Problems with `NULL' values''.
  37186. NULL values, and indexes:
  37187.           See ```CREATE TABLE' syntax''.
  37188. NULL values, and TIMESTAMP columns:
  37189.           See ``Problems with `NULL' values''.
  37190. ODBC:
  37191.           See ``Writing a procedure.''.
  37192. ODBC compatibility <1>:
  37193.           See ``Changes in release 3.21.15''.
  37194. ODBC compatibility <2>:
  37195.           See ```JOIN' syntax''.
  37196. ODBC compatibility <3>:
  37197.           See ```CREATE TABLE' syntax''.
  37198. ODBC compatibility <4>:
  37199.           See ``Comparison operators''.
  37200. ODBC compatibility <5>:
  37201.           See ``Column types''.
  37202. ODBC compatibility:
  37203.           See ``Database, table, index, column and alias names''.
  37204. Optimization:
  37205.           See ``SQL commands related to replication''.
  37206. Optimizations:
  37207.           See ``Speed of `SELECT' queries''.
  37208. Option files:
  37209.           See ``Command-line options''.
  37210. Oracle compatibility <1>:
  37211.           See ```DESCRIBE' syntax (Get information about columns)''.
  37212. Oracle compatibility <2>:
  37213.           See ``Functions for use with `GROUP BY' clauses''.
  37214. Oracle compatibility:
  37215.           See ``MySQL extensions to ANSI SQL92''.
  37216. ORDER BY, aliases in:
  37217.           See ``Functions for use with `GROUP BY' clauses''.
  37218. Overview: See node Top.
  37219. pack_isam:
  37220.           See ``Showing databases, tables and columns''.
  37221. Password encryption, reversibility of:
  37222.           See ``Miscellaneous functions''.
  37223. Passwords, setting <1>:
  37224.           See ```GRANT' and `REVOKE' syntax''.
  37225. Passwords, setting <2>:
  37226.           See ```SET' syntax''.
  37227. Passwords, setting:
  37228.           See ``How to set up passwords''.
  37229. Payment information:
  37230.           See ``*MySQL* licensing and support costs''.
  37231. Performance:
  37232.           See ``SQL commands related to replication''.
  37233. PostgreSQL compatibility:
  37234.           See ``MySQL extensions to ANSI SQL92''.
  37235. Protocol mismatch:
  37236.           See ``Upgrading from a 3.20 version to 3.21''.
  37237. Quoting:
  37238.           See ``Strings''.
  37239. Quoting binary data:
  37240.           See ``Strings''.
  37241. Quoting strings:
  37242.           See ``The `DBI' interface''.
  37243. RedHat Package Manager:
  37244.           See ``Installing a MySQL binary distribution''.
  37245. References:
  37246.           See ```ALTER TABLE' syntax''.
  37247. Release numbers:
  37248.           See ``Operating systems supported by MySQL''.
  37249. replace:
  37250.           See ``Overview of the different MySQL programs''.
  37251. Replication <1>:
  37252.           See ``Solving some common problems with MySQL''.
  37253. Replication:
  37254.           See ``How big MySQL tables can be''.
  37255. Replication, database <1>:
  37256.           See ``The update log''.
  37257. Replication, database:
  37258.           See ``Solving some common problems with MySQL''.
  37259. Reporting bugs:
  37260.           See ``Asking questions or reporting bugs''.
  37261. Reporting errors:
  37262.           See ``Useful MySQL-related links''.
  37263. Reserved words:
  37264.           See ```CREATE FUNCTION/DROP FUNCTION' syntax''.
  37265. Reserved words, exceptions:
  37266.           See ```CREATE FUNCTION/DROP FUNCTION' syntax''.
  37267. Row-level locking:
  37268.           See ``How to cope without `COMMIT'/`ROLLBACK'''.
  37269. RPM:
  37270.           See ``Installing a MySQL binary distribution''.
  37271. Running configure after prior invocation:
  37272.           See ``Problems compiling?''.
  37273. safe_mysqld:
  37274.           See ``Overview of the different MySQL programs''.
  37275. Scripts:
  37276.           See ``Overview of the different MySQL programs''.
  37277. Sequence emulation:
  37278.           See ``Miscellaneous functions''.
  37279. Server functions:
  37280.           See ``Show a table on twin pair status''.
  37281. Size of tables:
  37282.           See ``Multi-byte character support''.
  37283. Solaris troubleshooting:
  37284.           See ``Problems compiling?''.
  37285. Sorting, grant tables <1>:
  37286.           See ``Access control, stage 2: Request verification''.
  37287. Sorting, grant tables:
  37288.           See ``Access control, stage 1: Connection verification''.
  37289. sql_yacc.cc problems:
  37290.           See ``Problems compiling?''.
  37291. Stability:
  37292.           See ``The main features of MySQL''.
  37293. Startup parameters:
  37294.           See ``Using symbolic links for databases and tables''.
  37295. Storage requirements:
  37296.           See ``Column types''.
  37297. String collating:
  37298.           See ``Adding a new character set''.
  37299. String comparisons, case sensitivity:
  37300.           See ``String comparison functions''.
  37301. Strings:
  37302.           See ``MySQL language reference''.
  37303. Strings, escaping characters:
  37304.           See ``MySQL language reference''.
  37305. Strings, quoting:
  37306.           See ``The `DBI' interface''.
  37307. Support costs:
  37308.           See ``Running a web server using *MySQL*''.
  37309. Support terms:
  37310.           See ``Guidelines for answering questions on the mailing list''.
  37311. Support, types:
  37312.           See ``Contact information''.
  37313. Sybase compatibility:
  37314.           See ```USE' syntax''.
  37315. System table:
  37316.           See ```EXPLAIN' syntax (Get information about a `SELECT')''.
  37317. Table aliases:
  37318.           See ```SELECT' syntax''.
  37319. Table cache:
  37320.           See ``Tuning server parameters''.
  37321. Table names, case sensitivity <1>:
  37322.           See ``Case sensitivity in names''.
  37323. Table names, case sensitivity:
  37324.           See ``MySQL extensions to ANSI SQL92''.
  37325. Table size:
  37326.           See ``Multi-byte character support''.
  37327. Table types, Choosing:
  37328.           See ``Is MySQL picky about reserved words?''.
  37329. Table, constant <1>:
  37330.           See ``How MySQL optimizes `WHERE' clauses''.
  37331. Table, constant:
  37332.           See ```EXPLAIN' syntax (Get information about a `SELECT')''.
  37333. Table, system:
  37334.           See ```EXPLAIN' syntax (Get information about a `SELECT')''.
  37335. TEXT columns, default values:
  37336.           See ``The `BLOB' and `TEXT' types''.
  37337. TEXT columns, indexing:
  37338.           See ```CREATE TABLE' syntax''.
  37339. The table is full <1>:
  37340.           See ``Communication errors / Aborted connection''.
  37341. The table is full:
  37342.           See ```SET' syntax''.
  37343. TIMESTAMP, and NULL values:
  37344.           See ``Problems with `NULL' values''.
  37345. Timezone problems:
  37346.           See ``Problems using `DATE' columns''.
  37347. TODO:
  37348.           See ``Known errors and design deficiencies in MySQL''.
  37349. Troubleshooting, FreeBSD:
  37350.           See ``Problems compiling?''.
  37351. Troubleshooting, Solaris:
  37352.           See ``Problems compiling?''.
  37353. Type conversions:
  37354.           See ``Logical operations''.
  37355. Type portability:
  37356.           See ``Multiple-column indexes''.
  37357. Types of support:
  37358.           See ``Contact information''.
  37359. Types, choosing:
  37360.           See ``The `SET' type''.
  37361. Types, Date and Time:
  37362.           See ``Numeric types''.
  37363. Update log:
  37364.           See ``Database backups''.
  37365. user table, sorting:
  37366.           See ``Access control, stage 1: Connection verification''.
  37367. User-definable functions, adding:
  37368.           See ``Adding new functions to MySQL''.
  37369. Version, choosing:
  37370.           See ``Operating systems supported by MySQL''.
  37371. Version, latest:
  37372.           See ``Installing MySQL''.
  37373. Virtual memory problems while compiling:
  37374.           See ``Problems compiling?''.
  37375. Which languages *MySQL* supports:
  37376.           See ``MySQL server functions''.
  37377. Wildcards, and LIKE:
  37378.           See ``How *MySQL* uses indexes''.
  37379. Wildcards, in mysql.columns_priv table:
  37380.           See ``Access control, stage 2: Request verification''.
  37381. Wildcards, in mysql.db table:
  37382.           See ``Access control, stage 2: Request verification''.
  37383. Wildcards, in mysql.host table:
  37384.           See ``Access control, stage 2: Request verification''.
  37385. Wildcards, in mysql.tables_priv table:
  37386.           See ``Access control, stage 2: Request verification''.
  37387. Wildcards, in mysql.user table:
  37388.           See ``Access control, stage 1: Connection verification''.
  37389. Windows:
  37390.           See ``Writing a procedure.''.
  37391. Year 2000 compliance:
  37392.           See ``How stable is MySQL?''.
  37393. Year 2000 issues:
  37394.           See ``Date and time types''.
  37395.  
  37396. Table of Contents
  37397. *****************
  37398.  
  37399.  
  37400. General Information about MySQL
  37401.   What is MySQL
  37402.   About this manual
  37403.     Conventions used in this manual
  37404.   History of MySQL
  37405.   Books about MySQL
  37406.   The main features of MySQL
  37407.   How stable is MySQL?
  37408.   Year 2000 compliance
  37409.   General SQL information and tutorials
  37410.   Useful MySQL-related links
  37411.  
  37412. MySQL mailing lists and how to ask questions or report errors (bugs)
  37413.   The MySQL mailing lists
  37414.   Asking questions or reporting bugs
  37415.   How to report bugs or problems
  37416.   Guidelines for answering questions on the mailing list
  37417.  
  37418. MySQL licensing and support
  37419.   MySQL licensing policy
  37420.   Copyrights used by MySQL
  37421.     Copyright changes
  37422.   Example licensing situations
  37423.     Selling products that use *MySQL*
  37424.     ISP *MySQL* services
  37425.     Running a web server using *MySQL*
  37426.   *MySQL* licensing and support costs
  37427.     Payment information
  37428.     Contact information
  37429.   Types of commercial support
  37430.     Basic email support
  37431.     Extended email support
  37432.     Login support
  37433.     Extended login support
  37434.  
  37435. Installing MySQL
  37436.   How to get MySQL
  37437.   Operating systems supported by MySQL
  37438.   Which MySQL version to use
  37439.   How and when updates are released
  37440.   Installation layouts
  37441.   Installing a MySQL binary distribution
  37442.     Linux RPM notes
  37443.     Building client programs
  37444.     System-specific issues
  37445.       Linux notes
  37446.       HP-UX notes
  37447.   Installing a MySQL source distribution
  37448.     Quick installation overview
  37449.     Applying patches
  37450.     Typical `configure' options
  37451.   Problems compiling?
  37452.   MIT-pthreads notes
  37453.   Perl installation comments
  37454.     Installing Perl on Unix
  37455.     Installing ActiveState Perl on Win32
  37456.     Installing the MySQL Perl distribution on Win32
  37457.     Problems using the Perl `DBI'/`DBD' interface
  37458.   System-specific issues
  37459.     Solaris notes
  37460.     Solaris 2.7 / 2.8 notes
  37461.     Solaris x86 notes
  37462.     SunOS 4 notes
  37463.     Linux notes (all Linux versions)
  37464.       Linux-x86 notes
  37465.       RedHat 5.0 notes
  37466.       RedHat 5.1 notes
  37467.       Linux-SPARC notes
  37468.       Linux-Alpha notes
  37469.       MkLinux notes
  37470.       Qube2 Linux notes
  37471.     Alpha-DEC-Unix notes
  37472.     Alpha-DEC-OSF1 notes
  37473.     SGI-Irix notes
  37474.     FreeBSD notes
  37475.     NetBSD notes
  37476.     OpenBSD 2.5 notes
  37477.     BSD/OS notes
  37478.       BSD/OS 2.x notes
  37479.       BSD/OS 3.x notes
  37480.       BSD/OS 4.x notes
  37481.     SCO notes
  37482.     SCO Unixware 7.0 notes
  37483.     IBM-AIX notes
  37484.     HP-UX 10.20 notes
  37485.     HP-UX 11.x notes
  37486.     MacOS X notes
  37487.   Win32 notes
  37488.     Installing MySQL on Win32
  37489.     Starting MySQL on Win95 / Win98
  37490.     Starting MySQL on NT / Win200
  37491.     Running MySQL on Win32
  37492.     Connecting to a remote MySQL from Win32 with SSH
  37493.     Splitting data across different disks under Win32
  37494.     Compiling MySQL clients on Windows.
  37495.     MySQL-Win32 compared to Unix MySQL
  37496.   OS/2 notes
  37497.   MySQL binaries
  37498.   Post-installation setup and testing
  37499.     Problems running `mysql_install_db'
  37500.     Problems starting the MySQL server
  37501.     Starting and stopping MySQL automatically
  37502.     Command-line options
  37503.     Option files
  37504.   Is there anything special to do when upgrading/downgrading MySQL?
  37505.     Upgrading from a 3.22 version to 3.23
  37506.     Upgrading from a 3.21 version to 3.22
  37507.     Upgrading from a 3.20 version to 3.21
  37508.     Upgrading to another architecture
  37509.  
  37510. How standards-compatible is MySQL?
  37511.   MySQL extensions to ANSI SQL92
  37512.   Runnning MySQL in ANSI mode
  37513.   MySQL differences compared to ANSI SQL92
  37514.   Functionality missing from MySQL
  37515.     Sub-selects
  37516.     `SELECT INTO TABLE'
  37517.     Transactions
  37518.     Stored procedures and triggers
  37519.     Foreign Keys
  37520.       Reasons NOT to use foreign keys
  37521.     Views
  37522.     `--' as the start of a comment
  37523.   What standards does MySQL follow?
  37524.   How to cope without `COMMIT'/`ROLLBACK'
  37525.  
  37526. The MySQL access privilege system
  37527.   General security
  37528.   How to make MySQL secure against crackers
  37529.   What the privilege system does
  37530.   MySQL user names and passwords
  37531.   Connecting to the MySQL server
  37532.   Keeping your password secure
  37533.   Privileges provided by MySQL
  37534.   How the privilege system works
  37535.   Access control, stage 1: Connection verification
  37536.   Access control, stage 2: Request verification
  37537.   When privilege changes take effect
  37538.   Setting up the initial MySQL privileges
  37539.   Adding new user privileges to MySQL
  37540.   How to set up passwords
  37541.   Causes of `Access denied' errors
  37542.  
  37543. MySQL language reference
  37544.   Literals: how to write strings and numbers
  37545.     Strings
  37546.     Numbers
  37547.     Hexadecimal values
  37548.     `NULL' values
  37549.     Database, table, index, column and alias names
  37550.       Case sensitivity in names
  37551.   User variables
  37552.   Column types
  37553.     Column type storage requirements
  37554.     Numeric types
  37555.     Date and time types
  37556.       Y2K issues and date types
  37557.       The `DATETIME', `DATE' and `TIMESTAMP' types
  37558.       The `TIME' type
  37559.       The `YEAR' type
  37560.     String types
  37561.       The `CHAR' and `VARCHAR' types
  37562.       The `BLOB' and `TEXT' types
  37563.       The `ENUM' type
  37564.       The `SET' type
  37565.     Choosing the right type for a column
  37566.     Column indexes
  37567.     Multiple-column indexes
  37568.     Using column types from other database engines
  37569.   Functions for use in `SELECT' and `WHERE' clauses
  37570.     Grouping functions
  37571.     Normal arithmetic operations
  37572.     Bit functions
  37573.     Logical operations
  37574.     Comparison operators
  37575.     String comparison functions
  37576.     Cast operators
  37577.     Control flow functions
  37578.     Mathematical functions
  37579.     String functions
  37580.     Date and time functions
  37581.     Miscellaneous functions
  37582.     Functions for use with `GROUP BY' clauses
  37583.   `CREATE DATABASE' syntax
  37584.   `DROP DATABASE' syntax
  37585.   `CREATE TABLE' syntax
  37586.     Silent column specification changes
  37587.   `ALTER TABLE' syntax
  37588.   `DROP TABLE' syntax
  37589.   `OPTIMIZE TABLE' syntax
  37590.   `CHECK TABLE' syntax
  37591.   `ANALYZE TABLE' syntax
  37592.   `REPAIR TABLE' syntax
  37593.   `DELETE' syntax
  37594.   `SELECT' syntax
  37595.   `JOIN' syntax
  37596.   `INSERT' syntax
  37597.   `REPLACE' syntax
  37598.   `LOAD DATA INFILE' syntax
  37599.   `UPDATE' syntax
  37600.   `USE' syntax
  37601.   `FLUSH' syntax (clearing caches)
  37602.   `KILL' syntax
  37603.   `SHOW' syntax (Get information about tables, columns,...)
  37604.     SHOW information about database, tables, columns and index
  37605.     SHOW status information about tables
  37606.     SHOW status information
  37607.     SHOW VARIABLES
  37608.     SHOW information about connected threads (processes)
  37609.     SHOW GRANTS (privileges) for a user
  37610.   `EXPLAIN' syntax (Get information about a `SELECT')
  37611.   `DESCRIBE' syntax (Get information about columns)
  37612.   `BEGIN/COMMIT/ROLLBACK' syntax
  37613.   `LOCK TABLES/UNLOCK TABLES' syntax
  37614.   `SET' syntax
  37615.   `GRANT' and `REVOKE' syntax
  37616.   `CREATE INDEX' syntax
  37617.   `DROP INDEX' syntax
  37618.   Comment syntax
  37619.   `CREATE FUNCTION/DROP FUNCTION' syntax
  37620.   Is MySQL picky about reserved words?
  37621.  
  37622. MySQL table types
  37623.   MyISAM tables
  37624.     Space needed for keys
  37625.     MyISAM table formats
  37626.       Static (Fixed-length) table characteristics
  37627.       Dynamic table characteristics
  37628.       Compressed table characteristics
  37629.   ISAM tables
  37630.   HEAP tables
  37631.   BDB or Berkeley_db tables
  37632.  
  37633. MySQL Tutorial
  37634.   Connecting to and disconnecting from the server
  37635.   Entering queries
  37636.   Examples of common queries
  37637.     The maximum value for a column
  37638.     The row holding the maximum of a certain column
  37639.     Maximum of column: per group: only the values
  37640.     The rows holding the group-wise maximum of a certain field
  37641.     Using foreign keys
  37642.   Searching on two keys
  37643.   Creating and using a database
  37644.     Creating and selecting a database
  37645.     Creating a table
  37646.     Loading data into a table
  37647.     Retrieving information from a table
  37648.       Selecting all data
  37649.       Selecting particular rows
  37650.       Selecting particular columns
  37651.       Sorting rows
  37652.       Date calculations
  37653.       Working with `NULL' values
  37654.       Pattern matching
  37655.       Counting rows
  37656.     Using more than one table
  37657.   Getting information about databases and tables
  37658.   Using `mysql' in batch mode
  37659.   Queries from twin project
  37660.     Find all non-distributed twins
  37661.     Show a table on twin pair status
  37662.  
  37663. MySQL server functions
  37664.   What languages are supported by MySQL?
  37665.     The character set used for data and sorting
  37666.     Adding a new character set
  37667.     String collating support
  37668.     Multi-byte character support
  37669.   How big MySQL tables can be
  37670.  
  37671. Replication in MySQL
  37672.   Introduction
  37673.   Replication Implementation Overview
  37674.   HOWTO
  37675.   Replication Features
  37676.   Replication Options in my.cnf
  37677.   SQL commands related to replication
  37678.  
  37679. Getting maximum performance from MySQL
  37680.   Optimization overview
  37681.   System/Compile time and startup parameter tuning
  37682.     How compiling and linking affects the speed of MySQL
  37683.     Disk issues
  37684.       Using symbolic links for databases and tables
  37685.     Tuning server parameters
  37686.     How MySQL opens and closes tables
  37687.     Drawbacks of creating large numbers of tables in the same database
  37688.     Why so many open tables?
  37689.     How MySQL uses memory
  37690.     How MySQL locks tables
  37691.     Table locking issues
  37692.   Get your data as small as possible
  37693.   How *MySQL* uses indexes
  37694.   Speed of queries that access or update data
  37695.     Estimating query performance
  37696.     Speed of `SELECT' queries
  37697.     How MySQL optimizes `WHERE' clauses
  37698.     How MySQL optimizes `LEFT JOIN'
  37699.     How MySQL optimizes `LIMIT'
  37700.     Speed of `INSERT' queries
  37701.     Speed of `UPDATE' queries
  37702.     Speed of `DELETE' queries
  37703.   Other optimization tips
  37704.   Using your own benchmarks
  37705.   Design choices
  37706.   MySQL design limitations/tradeoffs
  37707.   Portability
  37708.   What have we used MySQL for?
  37709.  
  37710. The MySQL benchmark suite
  37711.  
  37712. MySQL Utilites
  37713.   Overview of the different MySQL programs
  37714.   The command line tool
  37715.   Administering a MySQL server
  37716.   Dumping the structure and data from MySQL databases and tables
  37717.   Importing data from text files
  37718.   Showing databases, tables and columns
  37719.   The MySQL compressed read-only table generator.
  37720.  
  37721. Maintaining a MySQL installation
  37722.   Using `myisamchk' for table maintenance and crash recovery
  37723.     `myisamchk' invocation syntax
  37724.       General options for myisamchk
  37725.       Check options for myisamchk
  37726.       Repair options for myisamchk
  37727.       Other options for myisamchk
  37728.     `myisamchk' memory usage
  37729.   Setting up a table maintenance regimen
  37730.   Getting information about a table
  37731.   Using `myisamchk' for crash recovery
  37732.     How to check tables for errors
  37733.     How to repair tables
  37734.     Table optimization
  37735.   Log file maintenance
  37736.  
  37737. Adding new functions to MySQL
  37738.   Adding a new user-definable function
  37739.     UDF calling sequences
  37740.     Argument processing
  37741.     Return values and error handling
  37742.     Compiling and installing user-definable functions
  37743.   Adding a new native function
  37744.  
  37745. Adding new procedures to MySQL
  37746.   Procedure analyse
  37747.   Writing a procedure.
  37748.  
  37749. MySQL ODBC Support
  37750.   Operating systems supported by MyODBC
  37751.   How to fill in the various fields in the ODBC administrator program
  37752.   How to report problems with MyODBC
  37753.   Programs known to work with MyODBC
  37754.   How to get the value of an `AUTO_INCREMENT' column in ODBC
  37755.   Reporting problems with MyODBC
  37756.  
  37757. Using `MySQL' with some common programs
  37758.   Using MySQL with Apache
  37759.  
  37760. Problems and common errors
  37761.   How to determinate what is causing problems
  37762.   What to do if MySQL keeps crashing
  37763.   Problems when linking with the MySQL client library
  37764.   Some common errors when using MySQL
  37765.     `MySQL server has gone away' error
  37766.     `Can't connect to [local] MySQL server' error
  37767.     `Host '...' is blocked' error
  37768.     `Too many connections' error
  37769.     `Out of memory' error
  37770.     `Packet too large' error
  37771.     Communication errors / Aborted connection
  37772.     `The table is full' error
  37773.     `Commands out of sync' error in client
  37774.     `Ignoring user' error
  37775.     `Table 'xxx' doesn't exist' error
  37776.   How MySQL handles a full disk
  37777.   How to run SQL commands from a text file
  37778.   Where MySQL stores temporary files
  37779.   How to protect `/tmp/mysql.sock' from being deleted
  37780.   `Access denied' error
  37781.   How to run MySQL as a normal user
  37782.   How to reset a forgotten password.
  37783.   Problems with file permissions
  37784.   File not found
  37785.   Problems using `DATE' columns
  37786.   Timezone problems
  37787.   Case sensitivity in searches
  37788.   Problems with `NULL' values
  37789.   Problems with `alias'
  37790.   Deleting rows from related tables
  37791.   Solving problems with no matching rows
  37792.   Problems with `ALTER TABLE'.
  37793.   How to change the order of columns in a table
  37794.  
  37795. Solving some common problems with MySQL
  37796.   Database replication with update log
  37797.   Database backups
  37798.   The update log
  37799.   Running multiple MySQL servers on the same machine
  37800.  
  37801. MySQL client tools and APIs
  37802.   MySQL C API
  37803.   C API datatypes
  37804.   C API function overview
  37805.   C API function descriptions
  37806.     `mysql_affected_rows()'
  37807.     `mysql_close()'
  37808.     `mysql_connect()'
  37809.     `mysql_change_user()'
  37810.     `mysql_character_set_name()'
  37811.     `mysql_create_db()'
  37812.     `mysql_data_seek()'
  37813.     `mysql_debug()'
  37814.     `mysql_drop_db()'
  37815.     `mysql_dump_debug_info()'
  37816.     `mysql_eof()'
  37817.     `mysql_errno()'
  37818.     `mysql_error()'
  37819.     `mysql_escape_string()'
  37820.     `mysql_fetch_field()'
  37821.     `mysql_fetch_fields()'
  37822.     `mysql_fetch_field_direct()'
  37823.     `mysql_fetch_lengths()'
  37824.     `mysql_fetch_row()'
  37825.     `mysql_field_count()'
  37826.     `mysql_field_seek()'
  37827.     `mysql_field_tell()'
  37828.     `mysql_free_result()'
  37829.     `mysql_get_client_info()'
  37830.     `mysql_get_host_info()'
  37831.     `mysql_get_proto_info()'
  37832.     `mysql_get_server_info()'
  37833.     `mysql_info()'
  37834.     `mysql_init()'
  37835.     `mysql_insert_id()'
  37836.     `mysql_kill()'
  37837.     `mysql_list_dbs()'
  37838.     `mysql_list_fields()'
  37839.     `mysql_list_processes()'
  37840.     `mysql_list_tables()'
  37841.     `mysql_num_fields()'
  37842.     `mysql_num_rows()'
  37843.     `mysql_options()'
  37844.     `mysql_ping()'
  37845.     `mysql_query()'
  37846.     `mysql_real_connect()'
  37847.     `mysql_real_escape_string()'
  37848.     `mysql_real_query()'
  37849.     `mysql_reload()'
  37850.     `mysql_row_seek()'
  37851.     `mysql_row_tell()'
  37852.     `mysql_select_db()'
  37853.     `mysql_shutdown()'
  37854.     `mysql_stat()'
  37855.     `mysql_store_result()'
  37856.     `mysql_thread_id()'
  37857.     `mysql_use_result()'
  37858.     Why is it that after `mysql_query()' returns success, `mysql_store_result()' sometimes returns `NULL?'
  37859.     What results can I get from a query?
  37860.     How can I get the unique ID for the last inserted row?
  37861.     Problems linking with the C API
  37862.     How to make a thread-safe client
  37863.   MySQL Perl API
  37864.     `DBI' with `DBD::mysql'
  37865.     The `DBI' interface
  37866.     More `DBI'/`DBD' information
  37867.   MySQL Eiffel wrapper
  37868.   MySQL Java connectivity (JDBC)
  37869.   MySQL PHP API
  37870.     Common problems with MySQL and PHP
  37871.   MySQL C++ APIs
  37872.   MySQL Python APIs
  37873.   MySQL Tcl APIs
  37874.  
  37875. How MySQL compares to other databases
  37876.   How MySQL compares to `mSQL'
  37877.     How to convert `mSQL' tools for MySQL
  37878.     How `mSQL' and MySQL client/server communications protocols differ
  37879.     How `mSQL' 2.0 SQL syntax differs from MySQL
  37880.   How MySQL compares to PostgreSQL
  37881.  
  37882. MySQL internals
  37883.   MySQL threads
  37884.  
  37885. Environment variables
  37886.  
  37887. Some MySQL users
  37888.   General news sites
  37889.   Some Web search engines
  37890.   Some Information search engines concentrated on some area
  37891.   Online magazines
  37892.   Web sites that use MySQL as a backend
  37893.   Some Domain/Internet/Web and related services
  37894.   Web sites that use `PHP' and MySQL
  37895.   Some MySQL consultants
  37896.   Programming
  37897.   Uncategorized pages
  37898.  
  37899. Contributed programs
  37900.   API's
  37901.   Clients
  37902.   Web tools
  37903.   Performance Benchmarking tools
  37904.   Authentication tools
  37905.   Converters
  37906.   Using MySQL with other products
  37907.   Useful tools
  37908.   RPMs for common tools (Most are for RedHat 6.1)
  37909.   Useful functions
  37910.   Uncategorized
  37911.  
  37912. Contributors to MySQL
  37913.  
  37914. MySQL change history
  37915.   Changes in release 3.23.x  (Released as alpha)
  37916.     Changes in release 3.23.22
  37917.     Changes in release 3.23.21
  37918.     Changes in release 3.23.20
  37919.     Changes in release 3.23.19
  37920.     Changes in release 3.23.18
  37921.     Changes in release 3.23.17
  37922.     Changes in release 3.23.16
  37923.     Changes in release 3.23.15
  37924.     Changes in release 3.23.14
  37925.     Changes in release 3.23.13
  37926.     Changes in release 3.23.12
  37927.     Changes in release 3.23.11
  37928.     Changes in release 3.23.10
  37929.     Changes in release 3.23.9
  37930.     Changes in release 3.23.8
  37931.     Changes in release 3.23.7
  37932.     Changes in release 3.23.6
  37933.     Changes in release 3.23.5
  37934.     Changes in release 3.23.4
  37935.     Changes in release 3.23.3
  37936.     Changes in release 3.23.2
  37937.     Changes in release 3.23.1
  37938.     Changes in release 3.23.0
  37939.   Changes in release 3.22.x
  37940.     Changes in release 3.22.35
  37941.     Changes in release 3.22.34
  37942.     Changes in release 3.22.33
  37943.     Changes in release 3.22.32
  37944.     Changes in release 3.22.31
  37945.     Changes in release 3.22.30
  37946.     Changes in release 3.22.29
  37947.     Changes in release 3.22.28
  37948.     Changes in release 3.22.27
  37949.     Changes in release 3.22.26
  37950.     Changes in release 3.22.25
  37951.     Changes in release 3.22.24
  37952.     Changes in release 3.22.23
  37953.     Changes in release 3.22.22
  37954.     Changes in release 3.22.21
  37955.     Changes in release 3.22.20
  37956.     Changes in release 3.22.19
  37957.     Changes in release 3.22.18
  37958.     Changes in release 3.22.17
  37959.     Changes in release 3.22.16
  37960.     Changes in release 3.22.15
  37961.     Changes in release 3.22.14
  37962.     Changes in release 3.22.13
  37963.     Changes in release 3.22.12
  37964.     Changes in release 3.22.11
  37965.     Changes in release 3.22.10
  37966.     Changes in release 3.22.9
  37967.     Changes in release 3.22.8
  37968.     Changes in release 3.22.7
  37969.     Changes in release 3.22.6
  37970.     Changes in release 3.22.5
  37971.     Changes in release 3.22.4
  37972.     Changes in release 3.22.3
  37973.     Changes in release 3.22.2
  37974.     Changes in release 3.22.1
  37975.     Changes in release 3.22.0
  37976.   Changes in release 3.21.x
  37977.     Changes in release 3.21.33
  37978.     Changes in release 3.21.32
  37979.     Changes in release 3.21.31
  37980.     Changes in release 3.21.30
  37981.     Changes in release 3.21.29
  37982.     Changes in release 3.21.28
  37983.     Changes in release 3.21.27
  37984.     Changes in release 3.21.26
  37985.     Changes in release 3.21.25
  37986.     Changes in release 3.21.24
  37987.     Changes in release 3.21.23
  37988.     Changes in release 3.21.22
  37989.     Changes in release 3.21.21a
  37990.     Changes in release 3.21.21
  37991.     Changes in release 3.21.20
  37992.     Changes in release 3.21.19
  37993.     Changes in release 3.21.18
  37994.     Changes in release 3.21.17
  37995.     Changes in release 3.21.16
  37996.     Changes in release 3.21.15
  37997.     Changes in release 3.21.14b
  37998.     Changes in release 3.21.14a
  37999.     Changes in release 3.21.13
  38000.     Changes in release 3.21.12
  38001.     Changes in release 3.21.11
  38002.     Changes in release 3.21.10
  38003.     Changes in release 3.21.9
  38004.     Changes in release 3.21.8
  38005.     Changes in release 3.21.7
  38006.     Changes in release 3.21.6
  38007.     Changes in release 3.21.5
  38008.     Changes in release 3.21.4
  38009.     Changes in release 3.21.3
  38010.     Changes in release 3.21.2
  38011.     Changes in release 3.21.0
  38012.   Changes in release 3.20.x
  38013.     Changes in release 3.20.18
  38014.     Changes in release 3.20.17
  38015.     Changes in release 3.20.16
  38016.     Changes in release 3.20.15
  38017.     Changes in release 3.20.14
  38018.     Changes in release 3.20.13
  38019.     Changes in release 3.20.11
  38020.     Changes in release 3.20.10
  38021.     Changes in release 3.20.9
  38022.     Changes in release 3.20.8
  38023.     Changes in release 3.20.7
  38024.     Changes in release 3.20.6
  38025.     Changes in release 3.20.3
  38026.     Changes in release 3.20.0
  38027.   Changes in release 3.19.x
  38028.     Changes in release 3.19.5
  38029.     Changes in release 3.19.4
  38030.     Changes in release 3.19.3
  38031.  
  38032. Known errors and design deficiencies in MySQL
  38033.  
  38034. List of things we want to add to MySQL in the future (The TODO)
  38035.   Things that must done in the real near future
  38036.   Things that have to be done sometime
  38037.   Some things we don't have any plans to do
  38038.  
  38039. Comments on porting to other systems
  38040.   Debugging a MySQL server
  38041.   Debugging a MySQL client
  38042.   The DBUG package.
  38043.   Locking methods
  38044.   Comments about RTS threads
  38045.   Differences between different thread packages
  38046.  
  38047. Description of MySQL regular expression syntax
  38048.  
  38049. What is Unireg?
  38050.  
  38051. GNU General Public License
  38052.  
  38053. GNU Library General Public License
  38054.  
  38055. SQL command, type and function index
  38056.  
  38057. Concept Index
  38058.  
  38059.  
  38060.