Commit c6a67ce9 authored by unknown's avatar unknown

Lots of manual changes

Changed 'static inline' to 'inline' for SCO new's compiler


Docs/manual.texi:
  Lots of changes in "Debugging a MySQL server" and in Log files handling
mysys/hash.c:
  Changed 'static inline' to 'inline'
sql/hostname.cc:
  Changed 'static inline' to 'inline'
sql/item.cc:
  Changed 'static inline' to 'inline'
sql/net_serv.cc:
  Changed 'static inline' to 'inline'
sql/password.c:
  Changed 'static inline' to 'inline'
sql/slave.cc:
  Changed 'static inline' to 'inline'
sql/sql_acl.cc:
  Changed 'static inline' to 'inline'
sql/sql_base.cc:
  Changed mysql_list_field() to convert field names again
sql/sql_parse.cc:
  Changed 'static inline' to 'inline'
sql/sql_repl.cc:
  fixed typo
parent 060cd1a1
......@@ -130,6 +130,7 @@ version see the relevant distribution.
* Common programs:: Using @strong{MySQL} with some common programs
* Problems:: Problems
* Common problems:: Solving some common problems with @strong{MySQL}
* Log files::
* Clients:: @strong{MySQL} client tools and APIs
* Comparisons:: How does @strong{MySQL} compare with other databases?
* MySQL internals:: @strong{MySQL} internals
......@@ -566,7 +567,7 @@ Replication in MySQL
* Replication Options:: Replication Options in my.cnf
* Replication SQL:: SQL Commands related to replication
* Replication FAQ:: Frequently Asked Questions about replication
* Troubleshooting Replication:: Troubleshooting Replication. Troubleshooting Replication
* Troubleshooting Replication:: Troubleshooting Replication. Troubleshooting Replication. Troubleshooting Replication. Troubleshooting Replication. Troubleshooting Replication. Troubleshooting Replication. Troubleshooting Replication. Troubleshooting Replication. Troubleshooting Replication
Getting Maximum Performance from MySQL
......@@ -631,7 +632,7 @@ Maintaining a MySQL Installation
* Maintenance regimen:: Setting up a table maintenance regimen
* Table-info:: Getting information about a table
* Crash recovery:: Using @code{myisamchk} for crash recovery
* Log files:: Log file maintenance
* Log file maintenance:: Log file maintenance
Using @code{myisamchk} for Table Maintenance and Crash Recovery
......@@ -726,11 +727,16 @@ Solving Some Common Problems with MySQL
* Log Replication:: Database replication with update log
* Backup:: Database backups
* Update log:: The update log
* Binary log:: The binary log
* Slow query log:: Log of slow queries
* Multiple servers:: Running multiple @strong{MySQL} servers on the same machine
The MySQL log files
* Error log::
* Query log::
* Update log::
* Binary log::
* Slow query log::
MySQL Client Tools and APIs
* C:: @strong{MySQL} C API
......@@ -1007,6 +1013,14 @@ Comments on porting to other systems
* RTS-threads:: Comments about RTS threads
* Thread packages:: Differences between different thread packages
Debugging a MySQL server
* Compiling for debugging::
* Making trace files::
* Using stack trace::
* Using log files::
* Reproducable test case::
@end detailmenu
@end menu
......@@ -3188,7 +3202,7 @@ try repairing your tables with @code{myisamchk} or @code{CHECK TABLE}/
If you often get corrupted tables you should try to find out when and
why this happens! In this case, the
@file{mysql-data-directory/'hostname'.err} file may contain some
information about what happened. Please include any relevant
information about what happened. @xref{Error log}. Please include any relevant
information from this file in your bug report! Normally @code{mysqld}
should @strong{NEVER} crash a table if nothing killed it in the middle
of an update! If you can find the cause of @code{mysqld} dying,
......@@ -8482,12 +8496,7 @@ utility in Win95. You must take it down with @code{mysqladmin shutdown}.
Filenames are case insensitive on Windows, so database and table names
are also case insensitive in @strong{MySQL} for Windows. The only
restriction is that database and table names must be given in the same
case throughout a given statement. The following query would not work
because it refers to a table both as @code{my_table} and as
@code{MY_TABLE}:
@example
SELECT * FROM my_table WHERE MY_TABLE.col=1;
@end example
case throughout a given statement. @xref{Name case sensitivity}.
@item The @samp{\} directory character
Pathname components in Win95 are separated by the @samp{\} character, which is
......@@ -9407,7 +9416,7 @@ Client error messages in given language. May be given as a full path.
@xref{Languages}.
@item -l, --log[=file]
Log connections and queries to file.
Log connections and queries to file. @xref{Query log}.
@item --log-isam[=file]
Log all ISAM/MyISAM changes to file (only used when debugging ISAM/MyISAM).
......@@ -10211,9 +10220,7 @@ This has a few implications:
@item
Database names and table names are case sensitive in @strong{MySQL} on
operating systems that have case-sensitive filenames (like most Unix
systems). If you have a problem remembering table names, adopt a consistent
convention, such as always creating databases and tables using lowercase
names.
systems). @xref{Name case sensitivity}.
@item
Database, table, index, column, or alias names may begin with a digit
......@@ -13358,7 +13365,7 @@ In @strong{MySQL}, databases and tables correspond to directories and files
within those directories. Consequently, the case sensitivity of the
underlying operating system determines the case sensitivity of database and
table names. This means database and table names are case sensitive in Unix
and case insensitive in Windows.
and case insensitive in Windows. @xref{Extensions to ANSI}.
@strong{NOTE:} Although database and table names are case insensitive for
Windows, you should not refer to a given database or table using different
......@@ -13381,6 +13388,17 @@ mysql> SELECT col_name FROM tbl_name AS a
Aliases on columns are case insensitive.
If you have a problem remembering the used cases for a table names,
adopt a consistent convention, such as always creating databases and
tables using lowercase names.
One way to avoid this problem is to start @code{mysqld} with @code{-O
lower_case_table_names=1}.
In this case @strong{MySQL} will convert all table names to lower case on
storage and lookup. Not that you need to first convert your old table
names to lower case before starting @code{mysqld} with this option.
@cindex variables, user
@cindex user variables
@cindex names, variables
......@@ -20711,13 +20729,9 @@ will be incremented. If you are using @code{--log-slow-queries}, the query
will be logged to the slow query logfile. @xref{Slow query log}.
@item @code{lower_case_table_names}
Is 1 if table names are stored in lowercase on disk. On @strong{MySQL} on Unix
tables are always case-sensitive; Is this a big problem for you can
start @code{mysqld} with @code{-O lower_case_table_names=1}
In this case @strong{MySQL} will convert all table names to lower case on
storage and lookup. Not that you need to first convert your old table
names to lower case before starting @code{mysqld} with this option.
If set to 1 table names are stored in lowercase on disk. This will enable
you to access the table names case-insensitive also on Unix.
@xref{Name case sensitivity}.
@item @code{max_allowed_packet}
The maximum size of one packet. The message buffer is initialized to
......@@ -22594,8 +22608,10 @@ that can be used as one. You can only @code{SELECT}, @code{DELETE}, and
specification.
With identical tables we mean that all tables are created with identical
column information. Some of the tables can be compressed with
@code{myisampack}. @xref{myisampack}.
column information. You can't put a MERGE over tables where the columns
are packed differently or doesn't have exactly the same columns.
Some of the tables can however be compressed with @code{myisampack}.
@xref{myisampack}.
When you create a @code{MERGE} table, you will get a @code{.frm} table
definition file and a @code{.MRG} table list file. The @code{.MRG} just
......@@ -22636,6 +22652,10 @@ batch, you should instead create a @code{MERGE} table on them on demand.
This is much faster and will save a lot of disk space.
@item
Go around the file size limit for the operating system.
@item
You can create an alias/synonym for a table by just using MERGE over one
table. There shouldn't be any really notable performance impacts of doing this
(only a couple of indirect calls and memcpy's for each read).
@end itemize
The disadvantages with @code{MERGE} tables are:
......@@ -22703,8 +22723,7 @@ mysql> select * from total;
@end example
To remap a @code{MERGE} table you must either @code{DROP} it and
re-create it, use @code{ALTER TABLE} with a new @code{UNION}
specification, or change the @code{.MRG} file and issue a @code{FLUSH
re-create it or change the @code{.MRG} file and issue a @code{FLUSH
TABLE} on the @code{MERGE} table and all underlying tables to force the
handler to read the new definition file.
......@@ -22821,6 +22840,7 @@ SUM_OVER_ALL_KEYS(max_length_of_key + sizeof(char*) * 2)
@code{sizeof(char*)} is 4 on 32-bit machines and 8 on 64-bit machines.
@cindex tables, @code{BDB}
@cindex tables, @code{Berkeley DB}
@node BDB, , HEAP, Table types
@section BDB or Berkeley_db Tables
......@@ -23007,6 +23027,11 @@ unexpectedly. It should not be fatal even if this number is not 100 %
correct. One can update the number of rows by executing @code{ANALYZE
TABLE} or @code{OPTIMIZE TABLE}. @xref{ANALYZE TABLE} . @xref{OPTIMIZE
TABLE}.
@item
If you get full disk with a @code{BDB} table, you will get an error
(probably error 28) and the transaction should roll back. This is in
contrast with @code{MyISAM} and @code{ISAM} tables where mysqld will
wait for enough free disk before continuing.
@end itemize
@node BDB TODO, BDB errors, BDB characteristic, BDB
......@@ -25621,16 +25646,18 @@ must be a positive integer).
@node Multi-byte characters, , String collating, Languages
@subsection Multi-byte Character Support
If your character set includes multi-byte characters, you need to use
the multi-byte character functions.
If your want to add support for a new character set that includes
multi-byte characters, you need to use the multi-byte character
functions.
Right now the best documentation on this is the character sets that are
already implemented. Look at the euc_kr, gb2312, gbk, sjis and ujis
character sets for examples.
character sets for examples. These are implemented in the
@code{ctype-'charset'.c} files in the @file{strings} directory.
You must specify the @code{mbmaxlen_MYSET=N} value in the
special comment at the top of the file. @code{N} should be set to
the size in bytes of the largest character in the set.
You must specify the @code{mbmaxlen_MYSET=N} value in the special
comment at the top of the source file. @code{N} should be set to the
size in bytes of the largest character in the set.
@cindex tables, maximum size
@cindex size of tables
......@@ -25701,7 +25728,7 @@ tables}.
* Replication Options:: Replication Options in my.cnf
* Replication SQL:: SQL Commands related to replication
* Replication FAQ:: Frequently Asked Questions about replication
* Troubleshooting Replication:: Troubleshooting Replication. Troubleshooting Replication
* Troubleshooting Replication:: Troubleshooting Replication. Troubleshooting Replication. Troubleshooting Replication. Troubleshooting Replication. Troubleshooting Replication. Troubleshooting Replication. Troubleshooting Replication. Troubleshooting Replication. Troubleshooting Replication
@end menu
@node Replication Intro, Replication Implementation, Replication, Replication
......@@ -26496,7 +26523,7 @@ the slaves of the master change in case of failure. Some suggestions:
@item
To tell a slave to change the master use the @code{CHANGE MASTER TO} command.
@item
A good way to keep your applications informed where the master is is by
A good way to keep your applications informed where the master is by
having a dynamic DNS entry for the master. With @strong{bind} you can
use @code{nsupdate} to dynamically update your DNS.
@item
......@@ -30422,7 +30449,7 @@ to start using the new table.
* Maintenance regimen:: Setting up a table maintenance regimen
* Table-info:: Getting information about a table
* Crash recovery:: Using @code{myisamchk} for crash recovery
* Log files:: Log file maintenance
* Log file maintenance:: Log file maintenance
@end menu
@node Table maintenance, Maintenance regimen, Maintenance, Maintenance
......@@ -31172,7 +31199,7 @@ information and a description of what it means.
@cindex crash, recovery
@cindex recovery, from crash
@node Crash recovery, Log files, Table-info, Maintenance
@node Crash recovery, Log file maintenance, Table-info, Maintenance
@section Using @code{myisamchk} for Crash Recovery
If you run @code{mysqld} with @code{--skip-locking} (which is the default on
......@@ -31363,7 +31390,7 @@ If you are using @strong{MySQL} Version 3.23.16 and above, you can (and should)
@code{CHECK} and @code{REPAIR} commands to check and repair @code{MyISAM}
tables. @xref{CHECK TABLE}. @xref{REPAIR TABLE}.
The manual section about table maintenence includes the options to
The manual section about table maintenance includes the options to
@code{isamchk}/@code{myisamchk}. @xref{Table maintenance}.
The following section is for the cases where the above command fails or
......@@ -31512,17 +31539,23 @@ For a full description of the option, see @xref{myisamchk syntax}.
@cindex files, log
@cindex maintaining, log files
@cindex log files, maintaining
@node Log files, , Crash recovery, Maintenance
@node Log file maintenance, , Crash recovery, Maintenance
@section Log file Maintenance
@strong{MySQL} has a lot of log files which make it easy to see what is
going. @xref{Log files}. One must however from time to time clean up
after @code{MysQL} to ensure that the logs doesn't take up too much disk
space.
When using @strong{MySQL} with log files, you will, from time to time,
want to remove/backup old log files and tell @strong{MySQL} to start
logging on new files. @xref{Update log}.
logging on new files. @xref{Backup}.
On a Linux (@code{Redhat}) installation, you can use the
@code{mysql-log-rotate} script for this. If you installed @strong{MySQL}
from an RPM distribution, the script should have been installed
automatically.
automatically. Note that you should be careful with this if you are using
the log for replication!
On other systems you must install a short script yourself that you
start from @code{cron} to handle log files.
......@@ -32852,7 +32885,7 @@ First, you should try to find out whether the problem is that the
client. You can check how long your @code{mysqld} server has been up by
executing @code{mysqladmin version}. If @code{mysqld} has died, you may
find the reason for this in the file
@file{mysql-data-directory/'hostname'.err}.
@file{mysql-data-directory/'hostname'.err}. @xref{Error log}.
Many crashes of @strong{MySQL} are caused by corrupted index / data
files. @strong{MySQL} will update the data on disk, with the
......@@ -32906,68 +32939,28 @@ state. @xref{Maintenance}.
Use @code{mysqld --log} and try to determine from the information in the log
whether or not some specific query kills the server. About 95% of all bugs are
related to a particular query! Normally this is one of the last queries in
the log file just before @strong{MySQL} restarted.
You may be able to verify this using the following procedure:
@itemize @minus
@item
Take down the @strong{MySQL} daemon (with @code{mysqladmin shutdown}).
@item
Make a backup of files in the @strong{MySQL} database directory.
(As the server is stopped, you can just copy the files to some other
directory)
@item
Check the tables with @code{myisamchk -s */*.MYI} to verify that all
tables are correct. If any table is corrupted, repair it with
@code{myisamchk -r path-to-table.MYI}. You should take the backup
before checking the tables, as the problem could be related to corrupted
tables.
@item
Remove (or move away) any old log files from the @strong{MySQL} data directory.
@item
Start the server with @code{safe_mysqld --log-update} or
@code{safe_mysqld --log --log-update}.
@item
If @code{mysqld} now dies, you have two options:
@itemize @bullet
@item
First take a backup of your backup database. (Just copy the file(s)
somewhere again.) This is because we want to keep the original start
situation untouched. Start a mysqld process on the other backup database
(you can do this with option @code{--datadir=/path/to/backup/}).
@item
Just restore the backup on your original database and restart @code{mysqld}.
You will not any lose information, because you have the @code{log-update} file.
@end itemize
the log file just before @strong{MySQL} restarted. @xref{Query log}.
If you can repeatadly kill @strong{MySQL} with one of the queries, even
when you have checked all tables just before doing the query, then you
have been able to locate the bug and should do a bug report for this!
@xref{Bug reports}.
@item
Now you can test if the problem is a specific update statement by executing
@code{mysql database_name < path-to-log-update-file}.
You can also use the script @code{mysql_find_rows} to just execute some of the
update statements if you want to narrow down the problem.
If mysqld now crashes, then you have something repeatable
available. Please send mail to @email{bugs@@lists.mysql.com} or
@email{developers@@mysql.com} or (if you are a support customer) to
@email{support@@mysql.com} about the problem and the @strong{MySQL} team
will fix it as soon as possible.
@end itemize
Try to make a test case that we can use to reproduce the problem.
@xref{Reproducable test case}.
@item
Have you tried the benchmarks? They should test @strong{MySQL} rather well.
You can also add code that simulates your application! The benchmarks can be
found in the @file{bench} directory in the source distribution or, for a
binary distribution, in the @file{sql-bench} directory under your
@strong{MySQL} installation directory.
Try running the included mysql-test test and the @code{MySQL}
benchmarks. @xref{MySQL test suite}. They should test @strong{MySQL}
rather well. You can also add code that to the benchmarks to simulates
your application! The benchmarks can be found in the @file{bench}
directory in the source distribution or, for a binary distribution, in
the @file{sql-bench} directory under your @strong{MySQL} installation
directory.
@item
Try @code{fork_test.pl} and @code{fork2_test.pl}.
@item
Check the file @file{mysql-data-directory/'hostname'.err} for any errors.
@item
If you configure @strong{MySQL} for debugging, it will be much easier to
gather information about possible errors if something goes wrong.
......@@ -33404,7 +33397,7 @@ The client program ended abruptly in the middle of the transfer.
@end itemize
When the above happens, the mysqld will write a note about an
@code{Aborted connection} in the @code{hostname.err}
@code{Aborted connection} in the @code{hostname.err} file. @xref{Error log}.
The server variable @code{Aborted_connects} is incremented when:
......@@ -34263,16 +34256,13 @@ Drop or rename @code{old_table}.
@cindex problems, solving
@cindex solving, problems
@cindex databases, replicating
@node Common problems, Clients, Problems, Top
@node Common problems, Log files, Problems, Top
@chapter Solving Some Common Problems with MySQL
@cindex replication
@menu
* Log Replication:: Database replication with update log
* Backup:: Database backups
* Update log:: The update log
* Binary log:: The binary log
* Slow query log:: Log of slow queries
* Multiple servers:: Running multiple @strong{MySQL} servers on the same machine
@end menu
......@@ -34321,7 +34311,7 @@ mirror if needed. @code{LAST_INSERT_ID()} is also safe to use.
@cindex databases, backups
@cindex backups
@node Backup, Update log, Log Replication, Common problems
@node Backup, Multiple servers, Log Replication, Common problems
@section Database Backups
Because @strong{MySQL} tables are stored as files, it is easy to do a
......@@ -34402,9 +34392,190 @@ If you get performance problems in making backups on your system, you can
solve this by setting up replication and do the backups on the slave
instead of on the master. @xref{Replication Intro}.
@cindex multiple servers
@cindex servers, multiple
@cindex running, multiple servers
@node Multiple servers, , Backup, Common problems
@section Running Multiple MySQL Servers on the Same Machine
There are circumstances when you might want to run multiple servers on the same
machine. For example, you might want to test a new @strong{MySQL} release
while leaving your existing production setup undisturbed. Or you might
be an Internet service provider that wants to provide independent
@strong{MySQL} installations for different customers.
If you want to run multiple servers, the easiest way is to compile the servers
with different TCP/IP ports and socket files so they are not
both listening to the same TCP/IP port or socket file. @xref{mysqld_multi}.
Assume an existing server is configured for the default port number and
socket file. Then configure the new server with a @code{configure} command
something like this:
@example
shell> ./configure --with-tcp-port=port_number \
--with-unix-socket-path=file_name \
--prefix=/usr/local/mysql-3.22.9
@end example
Here @code{port_number} and @code{file_name} should be different than the
default port number and socket file pathname, and the @code{--prefix} value
should specify an installation directory different than the one under which
the existing @strong{MySQL} installation is located.
You can check the socket and port used by any currently executing
@strong{MySQL} server with this command:
@example
shell> mysqladmin -h hostname --port=port_number variables
@end example
If you have a @strong{MySQL} server running on the port you used, you will
get a list of some of the most important configurable variables in
@strong{MySQL}, including the socket name.
You don't have to recompile a new @strong{MySQL} server just to start with
a different port and socket. You can change the port and socket to be used
by specifying them at run time as options to @code{safe_mysqld}:
@example
shell> /path/to/safe_mysqld --socket=file_name --port=port_number
@end example
@code{mysqld_multi} can also take @code{safe_mysqld} (or @code{mysqld})
as an argument and pass the options from a configuration file to
@code{safe_mysqld} and further to @code{mysqld}.
If you run the new server on the same database directory as another
server with logging enabled, you should also specify the name of the log
files to @code{safe_mysqld} with @code{--log}, @code{--log-update}, or
@code{--log-slow-queries}. Otherwise, both servers may be trying to
write to the same log file.
@strong{WARNING}: Normally you should never have two servers that update
data in the same database! If your OS doesn't support fault-free system
locking, this may lead to unpleasant surprises!
If you want to use another database directory for the second server, you
can use the @code{--datadir=path} option to @code{safe_mysqld}.
@strong{NOTE} also that starting several @strong{MySQL} servers
(@code{mysqlds}) in different machines and letting them access one data
directory over @code{NFS} is generally a @strong{BAD IDEA}! The problem
is that the @code{NFS} will become the bottleneck with the speed. It is
not meant for such use. And last but not least, you would still have to
come up with a solution how to make sure that two or more @code{mysqlds}
are not interfering with each other. At the moment there is no platform
that would 100% reliable do the file locking (@code{lockd} daemon
usually) in every situation. Yet there would be one more possible risk
with @code{NFS}; it would make the work even more complicated for
@code{lockd} daemon to handle. So make it easy for your self and forget
about the idea. The working solution is to have one computer with an
operating system that efficiently handles threads and have several CPUs
in it.
When you want to connect to a @strong{MySQL} server that is running with
a different port than the port that is compiled into your client, you
can use one of the following methods:
@itemize @bullet
@item
Start the client with @code{--host 'hostname' --port=port_numer} or
@code{[--host localhost] --socket=file_name}.
@item
In your C or Perl programs, you can give the port and socket arguments
when connecting to the @strong{MySQL} server.
@item
If your are using the @strong{MySQL} perl DBD module you can read the options
from the @strong{MySQL} option files. @xref{Option files}.
@example
$dsn = "DBI:mysql:test;mysql_read_default_group=client;"
$dbh = DBI->connect($dsn, $user, $password);
@end example
@item
@tindex MYSQL_UNIX_PORT environment variable
@tindex MYSQL_TCP_PORT environment variable
@tindex Environment variable, MYSQL_UNIX_PORT
@tindex Environment variable, MYSQL_TCP_PORT
Set the @code{MYSQL_UNIX_PORT} and @code{MYSQL_TCP_PORT} environment variables
to point to the Unix socket and TCP/IP port before you start your clients.
If you normally use a specific socket or port, you should place commands
to set these environment variables in your @file{.login} file.
@xref{Environment variables}. @xref{Programs}.
@item
@tindex .my.cnf file
Specify the default socket and TCP/IP port in the @file{.my.cnf} file in your
home directory. @xref{Option files}.
@end itemize
@cindex Log files
@node Log files, Clients, Common problems, Top
@chapter The MySQL log files
@strong{MySQL} has a lot of different log files which can help you find
out what's going on inside @code{mysqld}:
@multitable @columnfractions .3 .7
@item The error log @tab Problems encountering starting, running or stopping mysqld.
@item The isam log @tab Logs all changes to the ISAM tables. Used only for debugging the isam code.
@item The query log @tab Established connections and executed queries.
@item The update log @tab Depricated: Stores all statements that changes data
@item The binary log @tab Stores all statements that changes something. Used also for replication
@item The slow log @tab Stores all queries that took more than @code{long_query_time} to execute or didn't use indexes.
@end multitable
All logs can be found in the @code{mysqld} database directory. You can
tell force mysqld to switch to reopen the log files (or in some cases
switch to a new log) by executing @code{FLUSH LOGS}. @xref{FLUSH}.
@cindex error log
@cindex files, error log
@menu
* Error log::
* Query log::
* Update log::
* Binary log::
* Slow query log::
@end menu
@node Error log, Query log, Log files, Log files
@section The Error Log
@code{mysqld} writes all errors to the stderr, which the
@code{safe_mysqld} script redirects to a file called
@code{'hostname'.err}. (On windows @code{mysqld} writes this directly
to @file{mysql.err}).
This contains information on when mysqld was started and stopped and
also any critical errors found when running. If @code{mysqld} dies
unexpectedly and @code{safe_mysqld} needs to restart @code{mysqld},
@code{safe_mysqld} will write a @code{restarted mysqld} row in this
file. This log also holds a warning if @code{mysqld} notices a table
that needs to be automaticly checked or repaired.
On some operating systems, the error log will contain a stack trace
for where mysqld died. This can be used to find out where mysqld died.
@xref{Using stack trace}.
@cindex query log
@cindex files, query log
@node Query log, Update log, Error log, Log files
@section The Query Log
If you want to know what happens within @code{mysqld}, you should start
it with @code{--log[=file]}. This will log all connections and queries
to the log file (by default named 'hostname.log'). This log can
be very useful when you suspect an error in a client and want to know
exactly what @code{mysqld} thought the client send to it.
@cindex update log
@cindex files, update log
@node Update log, Binary log, Backup, Common problems
@node Update log, Binary log, Query log, Log files
@section The Update Log
@strong{NOTE}: The update log is replaced by the binary
......@@ -34464,7 +34635,7 @@ and the crash.
@cindex binary log
@cindex files, binary log
@node Binary log, Slow query log, Update log, Common problems
@node Binary log, Slow query log, Update log, Log files
@section The Binary Log
In the future the binary log will replace the update log, so we
......@@ -34530,7 +34701,7 @@ to cache a multi-transaction query.
@cindex slow query log
@cindex files, slow query log
@node Slow query log, Multiple servers, Binary log, Common problems
@node Slow query log, , Binary log, Log files
@section The Slow Query Log
When started with the @code{--log-slow-queries[=file_name]} option,
......@@ -34556,133 +34727,12 @@ You can also use the update logs when you have a mirrored database on
another host and you want to replicate the changes that have been made
to the master database. @xref{Log Replication}.
@cindex multiple servers
@cindex servers, multiple
@cindex running, multiple servers
@node Multiple servers, , Slow query log, Common problems
@section Running Multiple MySQL Servers on the Same Machine
There are circumstances when you might want to run multiple servers on the same
machine. For example, you might want to test a new @strong{MySQL} release
while leaving your existing production setup undisturbed. Or you might
be an Internet service provider that wants to provide independent
@strong{MySQL} installations for different customers.
If you want to run multiple servers, the easiest way is to compile the servers
with different TCP/IP ports and socket files so they are not
both listening to the same TCP/IP port or socket file. @xref{mysqld_multi}.
Assume an existing server is configured for the default port number and
socket file. Then configure the new server with a @code{configure} command
something like this:
@example
shell> ./configure --with-tcp-port=port_number \
--with-unix-socket-path=file_name \
--prefix=/usr/local/mysql-3.22.9
@end example
Here @code{port_number} and @code{file_name} should be different than the
default port number and socket file pathname, and the @code{--prefix} value
should specify an installation directory different than the one under which
the existing @strong{MySQL} installation is located.
You can check the socket and port used by any currently executing
@strong{MySQL} server with this command:
@example
shell> mysqladmin -h hostname --port=port_number variables
@end example
If you have a @strong{MySQL} server running on the port you used, you will
get a list of some of the most important configurable variables in
@strong{MySQL}, including the socket name.
You don't have to recompile a new @strong{MySQL} server just to start with
a different port and socket. You can change the port and socket to be used
by specifying them at run time as options to @code{safe_mysqld}:
@example
shell> /path/to/safe_mysqld --socket=file_name --port=port_number
@end example
@code{mysqld_multi} can also take @code{safe_mysqld} (or @code{mysqld})
as an argument and pass the options from a configuration file to
@code{safe_mysqld} and further to @code{mysqld}.
If you run the new server on the same database directory as another
server with logging enabled, you should also specify the name of the log
files to @code{safe_mysqld} with @code{--log}, @code{--log-update}, or
@code{--log-slow-queries}. Otherwise, both servers may be trying to
write to the same log file.
@strong{WARNING}: Normally you should never have two servers that update
data in the same database! If your OS doesn't support fault-free system
locking, this may lead to unpleasant surprises!
If you want to use another database directory for the second server, you
can use the @code{--datadir=path} option to @code{safe_mysqld}.
@strong{NOTE} also that starting several @strong{MySQL} servers
(@code{mysqlds}) in different machines and letting them access one data
directory over @code{NFS} is generally a @strong{BAD IDEA}! The problem
is that the @code{NFS} will become the bottleneck with the speed. It is
not meant for such use. And last but not least, you would still have to
come up with a solution how to make sure that two or more @code{mysqlds}
are not interfering with each other. At the moment there is no platform
that would 100% reliable do the file locking (@code{lockd} daemon
usually) in every situation. Yet there would be one more possible risk
with @code{NFS}; it would make the work even more complicated for
@code{lockd} daemon to handle. So make it easy for your self and forget
about the idea. The working solution is to have one computer with an
operating system that efficiently handles threads and have several CPUs
in it.
When you want to connect to a @strong{MySQL} server that is running with
a different port than the port that is compiled into your client, you
can use one of the following methods:
@itemize @bullet
@item
Start the client with @code{--host 'hostname' --port=port_numer} or
@code{[--host localhost] --socket=file_name}.
@item
In your C or Perl programs, you can give the port and socket arguments
when connecting to the @strong{MySQL} server.
@item
If your are using the @strong{MySQL} perl DBD module you can read the options
from the @strong{MySQL} option files. @xref{Option files}.
@example
$dsn = "DBI:mysql:test;mysql_read_default_group=client;"
$dbh = DBI->connect($dsn, $user, $password);
@end example
@item
@tindex MYSQL_UNIX_PORT environment variable
@tindex MYSQL_TCP_PORT environment variable
@tindex Environment variable, MYSQL_UNIX_PORT
@tindex Environment variable, MYSQL_TCP_PORT
Set the @code{MYSQL_UNIX_PORT} and @code{MYSQL_TCP_PORT} environment variables
to point to the Unix socket and TCP/IP port before you start your clients.
If you normally use a specific socket or port, you should place commands
to set these environment variables in your @file{.login} file.
@xref{Environment variables}. @xref{Programs}.
@item
@tindex .my.cnf file
Specify the default socket and TCP/IP port in the @file{.my.cnf} file in your
home directory. @xref{Option files}.
@end itemize
@cindex client tools
@cindex APIs
@cindex @code{mysqlclient} library
@cindex buffer sizes, client
@cindex library, @code{mysqlclient}
@node Clients, Comparisons, Common problems, Top
@node Clients, Comparisons, Log files, Top
@chapter MySQL Client Tools and APIs
@menu
......@@ -39726,8 +39776,8 @@ Windows GUI (binary only) to administrate a database, by David B. Mansel,
@item @uref{http://www.mysql.com/Downloads/Win32/netadmin.zip, netadmin.zip}
An administrator tool for @strong{MySQL} on Windows 95/98 and Windows NT
4.0. Only tested with @strong{MySQL} Versions 3.23.5 - 3.23.7. Written using the
Tmysql components.
4.0. Only tested with @strong{MySQL} Versions 3.23.5 - 3.23.7. Written
using the Tmysql components.
You can write queries and show tables, indexes, table syntax, and
administrate user, host, and database and so on. This is beta and
......@@ -39740,6 +39790,12 @@ New version of netadmin. See above for details.
@item @uref{http://www.mysql.com/Downloads/Win32/ARTADMIN203.EXE,Atronic's @strong{MySQL} client for Windows 2.0.3.0}.
Home page for this can be found at: @uref{http://www.artronic.hr}.
@item @uref{http://www.mysql.com/Downloads/Win32/mysqlfront.zip, mysqlfront}
Home page: @uref{http://my.anse.de/}.
Win32-Client for accessing and managing dbs, tables, table-data, indexes,
import-/export-files. (Freeware). By Ansgar Becker.
@item @uref{http://www.mysql.com/Downloads/Win32/W9xstop.zip,Utility from Artronic to stop MySQL on win9x}.
@item @uref{http://dbtools.vila.bol.com.br/, Dbtools}
......@@ -45385,6 +45441,10 @@ The following problems are known and will be fixed in due time:
@itemize @bullet
@item
@code{ALTER TABLE} can't be used to change the @code{UNION} of a @code{MERGE}
table. For the moment, you should drop the MERGE table and create it again
if you need to change the @code{UNION}.
@item
@code{mysqldump} on a @code{MERGE} table doesn't include the current
mapped tables.
@item
......@@ -46065,6 +46125,37 @@ any @code{my.cnf} files that interfere with your setup!
You can check your @code{my.cnf} arguments with @code{mysqld --print-defaults}
and avoid using them by starting with @code{mysqld --no-defaults ...}.
If @code{mysqld} starts to eat up CPU or memory or if it ``hangs'', you
can use @code{mysqladmin processlist status} to find out if someone is
executing a query that takes a long time. It may be a good idea to
run @code{mysqladmin -i10 processlist status} in some window if you are
experiencing performance problems or problems when new clients can't connect.
The command @code{mysqladmin debug} will dump some information about
locks in use, used memory and query usage to the mysql log file. This
may help solve some problems. This command also provides some useful
information even if you haven't compiled @strong{MySQL} for debugging!
If the problem is that some tables are getting slower and slower you
should try to optimize the table with @code{OPTIMIZE TABLE} or
@code{myisamchk}. @xref{Maintenance}. You should also check the slow
queries with @code{EXPLAIN}.
You should also read the OS-specific section in this manual for
problems that may be unique to your environment.
@xref{Source install system issues}.
@menu
* Compiling for debugging::
* Making trace files::
* Using stack trace::
* Using log files::
* Reproducable test case::
@end menu
@node Compiling for debugging, Making trace files, Debugging server, Debugging server
@appendixsubsec Compiling MYSQL for debugging.
If you have some very specific problem, you can always try to debug
@strong{MySQL}. To do this you must configure @strong{MySQL} with the
option @code{--with-debug}. You can check whether or not
......@@ -46083,6 +46174,11 @@ This will avoid problems with the @code{libstdc++} library and with C++
exceptions (many compilers have problems with C++ exceptions in threaded
code) and compile a @strong{MySQL} version with support for all character sets.
If you suspect a memory overrun error, you can use @code{--with-debug=full},
which will install a memory allocation checker. This is however quite slow
so this is not something one should do on a server in a heavy production
environment.
If @code{mysqld} stops crashing when you compile it with
@code{--with-debug}, you have probably found a compiler bug or a timing
bug within @strong{MySQL}. In this case you can try to add @code{-g} to
......@@ -46091,6 +46187,20 @@ the @code{CFLAGS} and @code{CXXFLAGS} variables above and not use
to it with @code{gdb} or use @code{gdb} on the core file to find out
what happened.
When you configure @strong{MySQL} for debugging you automatically enable a
lot of extra safety check functions that monitor the health of @code{mysqld}.
If they find something ``unexpected,'' an entry will be written to
@code{stderr}, which @code{safe_mysqld} directs to the error log! This also
means that if you are having some unexpected problems with @strong{MySQL} and
are using a source distribution, the first thing you should do is to
configure @strong{MySQL} for debugging! (The second thing, of course, is to
send mail to @email{mysql@@lists.mysql.com} and ask for help. Please use the
@code{mysqlbug} script for all bug reports or questions regarding the
@strong{MySQL} version you are using!
@node Making trace files, Using stack trace, Compiling for debugging, Debugging server
@appendixsubsec Creating trace files and using gdb on mysqld
If you can cause the @code{mysqld} server to crash quickly, you can try to
create a trace file of this:
......@@ -46105,17 +46215,6 @@ or you can start it with
which only prints information with the most interesting tags.
When you configure @strong{MySQL} for debugging you automatically enable a
lot of extra safety check functions that monitor the health of @code{mysqld}.
If they find something ``unexpected,'' an entry will be written to
@code{stderr}, which @code{safe_mysqld} directs to the error log! This also
means that if you are having some unexpected problems with @strong{MySQL} and
are using a source distribution, the first thing you should do is to
configure @strong{MySQL} for debugging! (The second thing, of course, is to
send mail to @email{mysql@@lists.mysql.com} and ask for help. Please use the
@code{mysqlbug} script for all bug reports or questions regarding the
@strong{MySQL} version you are using!
On most system you can also start @code{mysqld} from @code{gdb} to get
more information if @code{mysqld} crashes.
......@@ -46191,11 +46290,79 @@ If @code{mysqld} hangs you can try to use some system tools like
strace /tmp/log libexec/mysqld
@end example
If @code{mysqld} starts to eat up CPU or memory or if it ``hangs'', you
can use @code{mysqladmin processlist status} to find out if someone is
executing a query that takes a long time. It may be a good idea to
run @code{mysqladmin -i10 processlist status} in some window if you are
experiencing performance problems or problems when new clients can't connect.
@findex DBI->trace
@findex trace DBI method
@tindex DBI_TRACE environment variable
@tindex Environment variable, DBI_TRACE
If you are using the Perl @code{DBI} interface, you can turn on
debugging information by using the @code{trace} method or by
setting the @code{DBI_TRACE} environment variable.
@xref{Perl DBI Class, , Perl @code{DBI} Class}.
@node Using stack trace, Using log files, Making trace files, Debugging server
@appendixsubsec Using a stack trace
On some operating systems, the error log will contain a stack trace if
@code{mysqld} dies unexpectedly. You can use this to find out where (and
maybe why) @code{mysqld} died. @xref{Error log}. To get a stack trace,
you should NOT compile @code{mysqld} with the
@code{-fomit-frame-pointer} option to gcc.
@xref{Compiling for debugging}.
If the error file contains something like the following:
@example
mysqld got signal 11;
The manual section 'Debugging a MySQL server' tells you how to use a
stack trace and/or the core file to produce a readable backtrace that may
help in finding out why mysqld died
Attemping backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong
stack range sanity check, ok, backtrace follows
0x40077552
0x81281a0
0x8128f47
0x8127be0
0x8127995
0x8104947
0x80ff28f
0x810131b
0x80ee4bc
0x80c3c91
0x80c6b43
0x80c1fd9
0x80c1686
@end example
you can find where mysqld died by doing the following:
@enumerate
@item
Copy the above numbers to a file, for example @file{mysqld.stack}.
@item
Make a symbol file for the @code{mysqld} server:
@example
nm -n libexec/mysqld > /tmp/mysqld.sym
@end example
Note that many MySQL binary distributions comes with the above file,
named @code{mysqld.sym.gz}. In this case you must unpack this by doing
@example
gunzip < bin/mysqld.sym.gz > /tmp/mysqld.sym
@end example
@item
Execute @code{resolve_stack_dump -s /tmp/mysqld.sym -n mysqld.stack}.
This will print out where @code{mysqld} died. If this doesn't help you
find out why @code{mysqld} died, you should make a bug report and include
the output from the above commend with the bug report. @xref{Bug reports}.
@end enumerate
@node Using log files, Reproducable test case, Using stack trace, Debugging server
@appendixsubsec Using log files to find cause of errors in mysqld
If @code{mysqld} dies or hangs, you should start @code{mysqld} with
@code{--log}. When @code{mysqld} dies again, you can check in the log
......@@ -46226,18 +46393,45 @@ version. If this doesn't help and you can't find anything in the
online at the @uref{http://www.mysql.com/documentation/, @strong{MySQL}
documentation page}.
If you have started @code{mysqld} with @code{--with-myisam-recover},
@strong{MySQL} will automaticly check and try to repair @code{MyISAM}
tables if they are marked as 'not closed properly' or 'crashed'. If
this happens, @strong{MySQL} will write an entry in the
@code{hostname.err} file @code{'Warning: Checking table ...'} which is
followed by @code{Warning: Repairing table} if the table needs to be
repaired. If you get a lot of these errors, without @code{mysqld} having
died unexpectedly just before, then something is wrong and needs to
be investigated further. @xref{Command-line options}.
It's of course not a good sign if @code{mysqld} did died unexpectedly,
but in this case one shouldn't investigate the @code{Checking table...}
messages but instead try to find out why @code{mysqld} died.
@node Reproducable test case, , Using log files, Debugging server
@appendixsubsec Makeing a test case when you get crashed tables
If you get corrupted tables or if @code{mysqld} always fails after some
update commands, you can test if this bug is reproducible by doing the
following:
@itemize @bullet
@item
Stop the mysqld daemon (with @code{mysqladmin shutdown})
Take down the @strong{MySQL} daemon (with @code{mysqladmin shutdown}).
@item
Make a backup of the tables (to guard against the very unlikely case that
the repair will do something bad).
@item
Check all tables with @code{myisamchk -s database/*.MYI}. Repair any
wrong tables with @code{myisamchk -r database/table.MYI}.
@item
Make a second backup of the tables.
@item
Remove (or move away) any old log files from the @strong{MySQL} data
directory if you need more space.
@item
Start @code{mysqld} with @code{--log-binary}. @xref{Binary log}.
If you want to find a query that crashes @code{mysqld}, you should use
@code{--log --log-binary}.
@item
When you have gotten a crashed table, stop the @code{mysqld server}.
@item
......@@ -46249,34 +46443,17 @@ Re-execute the commands with @code{mysqlbinlog update-log-file | mysql}.
The update log is saved in the @strong{MySQL} database directory with
the name @code{hostname-bin.#}.
@item
If the tables are corrupted again, you have found reproducible bug
in the @code{MyISAM} code! FTP the tables and the update log to
@uref{ftp://support.mysql.com/pub/mysql/secret} and we will fix this as soon as
possible!
If the tables are corrupted again or you can get @code{mysqld} to die with the
above command, you have found reproducible bug that should be easy to
fix! FTP the tables and the binary log to
@uref{ftp://support.mysql.com/pub/mysql/secret} and send a mail to
@email{bugs@@lists.mysql.com} or (if you are a support customer) to
@email{support@@mysql.com} about the problem and the @strong{MySQL} team
will fix it as soon as possible.
@end itemize
The command @code{mysqladmin debug} will dump some information about
locks in use, used memory and query usage to the mysql log file. This
may help solve some problems. This command also provides some useful
information even if you haven't compiled @strong{MySQL} for debugging!
If the problem is that some tables are getting slower and slower you
should try to optimize the table with @code{OPTIMIZE TABLE} or
@code{myisamchk}. @xref{Maintenance}. You should also check the slow
queries with @code{EXPLAIN}.
You should also read the OS-specific section in this manual for
problems that may be unique to your environment.
@xref{Source install system issues}.
@findex DBI->trace
@findex trace DBI method
@tindex DBI_TRACE environment variable
@tindex Environment variable, DBI_TRACE
If you are using the Perl @code{DBI} interface, you can turn on
debugging information by using the @code{trace} method or by
setting the @code{DBI_TRACE} environment variable.
@xref{Perl DBI Class, , Perl @code{DBI} Class}.
You can also use the script @code{mysql_find_rows} to just execute some of the
update statements if you want to narrow down the problem.
@cindex debugging, client
@cindex clients, debugging
......@@ -83,7 +83,7 @@ void hash_free(HASH *hash)
/* some helper functions */
static inline byte*
inline byte*
hash_key(HASH *hash,const byte *record,uint *length,my_bool first)
{
if (hash->get_key)
......@@ -180,7 +180,7 @@ uint calc_hashnr_caseup(const byte *key, uint len)
#endif
static inline uint rec_hashnr(HASH *hash,const byte *record)
inline uint rec_hashnr(HASH *hash,const byte *record)
{
uint length;
byte *key=hash_key(hash,record,&length,0);
......
......@@ -100,7 +100,7 @@ static void add_hostname(struct in_addr *in,const char *name)
}
static inline void add_wrong_ip(struct in_addr *in)
inline void add_wrong_ip(struct in_addr *in)
{
add_hostname(in,NullS);
}
......
......@@ -471,7 +471,7 @@ bool Item_real::save_in_field(Field *field)
** In number context this is a longlong value.
****************************************************************************/
static inline uint char_val(char X)
inline uint char_val(char X)
{
return (uint) (X >= '0' && X <= '9' ? X-'0' :
X >= 'A' && X <= 'Z' ? X-'A'+10 :
......
......@@ -74,7 +74,7 @@ typedef my_bool ALARM;
#define thr_alarm_in_use(A) (*(A))
#define thr_end_alarm(A)
#define thr_alarm(A,B,C) local_thr_alarm((A),(B),(C))
static inline int local_thr_alarm(my_bool *A,int B __attribute__((unused)),ALARM *C __attribute__((unused)))
inline int local_thr_alarm(my_bool *A,int B __attribute__((unused)),ALARM *C __attribute__((unused)))
{
*A=1;
return 0;
......
......@@ -91,7 +91,7 @@ void make_scrambled_password(char *to,const char *password)
sprintf(to,"%08lx%08lx",hash_res[0],hash_res[1]);
}
static inline uint char_val(char X)
inline uint char_val(char X)
{
return (uint) (X >= '0' && X <= '9' ? X-'0' :
X >= 'A' && X <= 'Z' ? X-'A'+10 :
......
......@@ -45,8 +45,8 @@ static int stuck_count = 0;
#endif
static inline void skip_load_data_infile(NET* net);
static inline bool slave_killed(THD* thd);
inline void skip_load_data_infile(NET* net);
inline bool slave_killed(THD* thd);
static int init_slave_thread(THD* thd);
static int safe_connect(THD* thd, MYSQL* mysql, MASTER_INFO* mi);
static int safe_reconnect(THD* thd, MYSQL* mysql, MASTER_INFO* mi);
......@@ -54,7 +54,7 @@ static int safe_sleep(THD* thd, int sec);
static int request_table_dump(MYSQL* mysql, char* db, char* table);
static int create_table_from_dump(THD* thd, NET* net, const char* db,
const char* table_name);
static inline char* rewrite_db(char* db);
inline char* rewrite_db(char* db);
static void free_table_ent(TABLE_RULE_ENT* e)
{
my_free((gptr) e, MYF(0));
......@@ -194,12 +194,12 @@ void end_slave()
free_string_array(&replicate_wild_ignore_table);
}
static inline bool slave_killed(THD* thd)
inline bool slave_killed(THD* thd)
{
return abort_slave || abort_loop || thd->killed;
}
static inline void skip_load_data_infile(NET* net)
inline void skip_load_data_infile(NET* net)
{
(void)my_net_write(net, "\xfb/dev/null", 10);
(void)net_flush(net);
......@@ -207,7 +207,7 @@ static inline void skip_load_data_infile(NET* net)
send_ok(net); // the master expects it
}
static inline char* rewrite_db(char* db)
inline char* rewrite_db(char* db)
{
if(replicate_rewrite_db.is_empty() || !db) return db;
I_List_iterator<i_string_pair> it(replicate_rewrite_db);
......
......@@ -1287,7 +1287,7 @@ static GRANT_TABLE *table_hash_search(const char *host,const char* ip,
static inline GRANT_COLUMN *
inline GRANT_COLUMN *
column_hash_search(GRANT_TABLE *t, const char *cname,
uint length)
{
......
......@@ -187,7 +187,8 @@ query_table_status(THD *thd,const char *db,const char *table_name)
** Sum fields has table name empty and field_name.
** flag is a bit mask with the following functions:
** 1 send number of rows
** 2 send default values; Don't convert field names
** 2 send default values
** 4 Don't convert field names
******************************************************************************/
bool
......@@ -196,7 +197,7 @@ send_fields(THD *thd,List<Item> &list,uint flag)
List_iterator<Item> it(list);
Item *item;
char buff[80];
CONVERT *convert= (flag & 2) ? (CONVERT*) 0 : thd->convert_set;
CONVERT *convert= (flag & 4) ? (CONVERT*) 0 : thd->convert_set;
String tmp((char*) buff,sizeof(buff)),*res,*packet= &thd->packet;
......
......@@ -71,7 +71,7 @@ static void init_signals(void)
}
#endif
static inline bool end_active_trans(THD *thd)
inline bool end_active_trans(THD *thd)
{
int error=0;
if (thd->options & (OPTION_NOT_AUTO_COMMIT | OPTION_BEGIN))
......@@ -496,7 +496,7 @@ pthread_handler_decl(handle_bootstrap,arg)
}
static inline void free_items(THD *thd)
inline void free_items(THD *thd)
{
/* This works because items are allocated with sql_alloc() */
for (Item *item=thd->free_list ; item ; item=item->next)
......
......@@ -237,7 +237,7 @@ binlog purge"; break;
break;
case LOG_INFO_MEM: errmsg = "Out of memory"; break;
case LOG_INFO_FATAL: errmsg = "Fatal error during purge"; break;
case LOG_INFO_IN_USE: errmsg = "A purgable log is in use, will not purge";
case LOG_INFO_IN_USE: errmsg = "A purgeable log is in use, will not purge";
break;
default:
errmsg = "Unknown error during purge"; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment